GasTeX: Graphs and Automata Simplified in TeX
Documentation

version 3.1


Last update: February 12, 2024
Remark: Version 3.1 of GasTeX is available here on CTAN since 2024/02/12.
Known problems with TeXLive 2021: If you have problems using gastex simultaneously with the documentclass lipics-v2021 or the package todonotes or the library shadows of tikz (and possibly in other situtations), see the known problems and solutions.
For a quick startup guide with some examples, see gastex-doc.tex and the resulting gastex-doc.pdf.

Download and Installation

The last version of GasTeX is always available here. It consists of the following two files.

Usage and package options

Usage

\usepackage{gastex}
\usepackage[options]{gastex}

Package options

Thanks to the packages pst-pdf and auto-pst-pdf, GasTeX is now fully compatible with pdflatex. This feature is controlled with two options pdflatex and recompilepics as explained below.

gpicture and gusepicture

Pictures should be defined inside a gpicture environment allowing the same source file to be compiled both with pdflatex and with latex+dvips(+ps2pdf). The (depreciated) picture environment may still be used only if compilation is with latex+dvips(+ps2pdf). One may safely replace all picture environments with gpicture, even when using latex+dvips(+ps2pdf).


Drawing commands

Commands should be used in the gpicture environment to draw lines, nodes, arrows, etc. Here is a simple example:
\begin{gpicture}
  \node[Nmarks=i](A)(0,0){0}
  \node(B)(20,0){1}
  \node[Nmarks=f](C)(40,0){2}
  \drawedge(A,B){$a$}
  \drawloop(B){$b$}
  \drawedge(B,C){$c$}
\end{gpicture}
example1
Each drawing command has a name, some optional parameters, and some mandatory arguments:
\commandname[optional parameters]<mandatory arguments>

General parameters

Commands for nodes (work in progress)

Examples for \node, \rpnode, \imark, \fmark, \rmark, \nodelabel

Nodes1

\begin{gpicture}
\gasset{Nw=8,Nh=8}
\node(A)(0,0){1}
\node[Nw=15,Nmr=0](A)(25,0){rectangle}
\node[Nw=15,Nmr=4](A)(50,0){oval}
\node[Nw=15,Nmr=2](A)(75,0){corner}

\node(B)(0,-15){Nadjust=n}
\node[Nadjust=w,Nmr=2](B)(25,-15){Nadjust=w}
\node[Nadjust=wh,Nmr=0](B)(50,-15){Nadjust=wh}
\node[Nadjust=wh,,Nadjustdist=3](B)(75,-15){Nadjustdist}

\gasset{Nadjust=w,Nadjustdist=3}
\node[Nmarks=ifr](C)(0,-30){all}
\node[Nmarks=i,iangle=210,ilength=5](C)(25,-30){imark}
\imark[iangle=150,ilength=10,linecolor=red](C)
\node[Nmarks=f,fangle=30,flength=5,linecolor=green](C)(50,-30){fmark}
\fmark[fangle=-30,flength=10,linecolor=blue](C)
\node[Nmarks=r,linecolor=red](C)(75,-30){rmark}
\rmark[rdist=1.4,linecolor=green](C)
\end{gpicture}



Nodes2

\begin{gpicture}
\gasset{Nadjust=w,Nadjustdist=3,Nh=8}
\node(D)(0,0){framed}
\node[Nframe=n,fillcolor=yellow](D)(25,0){filled}
\node[fillcolor=yellow](D)(50,0){both}
\node[fillcolor=yellow,linecolor=green](D)(75,0){\textcolor{red}{red}}

\node[linewidth=0.5](E)(0,-15){Thick}
\node[linewidth=1,linegray=0.8](E)(25,-15){Gray}
\node[dash={1.5}0](E)(50,-15){Dash}
\node[dash={4 1 1 1}0,linecolor=red](E)(75,-15){More dash}

\rpnode[polyangle=90,Nmarks=i,iangle=-90](F)(0,-30)(3,7){3}
\rpnode[Nmarks=f](F)(25,-30)(4,7){4}
\rpnode[polyangle=90,Nmarks=f,fangle=18](F)(50,-30)(5,7){5}
\rpnode[arcradius=2,Nmarks=r](F)(75,-30)(6,7){6}
\end{gpicture}



NodeLabels

\begin{gpicture}
{\gasset{Nfill=y,Nw=2,Nh=2,ExtNL=y,NLdist=1.5}
\node(A)(0,0){$a$}
\node[NLangle=-90](B)(10,0){$b$}
\drawedge(A,B){}\drawloop[loopdiam=5](B){}
}
\gasset{ExtNL=n,NLdist=10}
\node[Nh=24,Nw=24,Nmr=12](B)(40,0){}
\nodelabel[NLangle= 0](B){3}
\nodelabel[NLangle= 30](B){2}
\nodelabel[NLangle= 60](B){1}
\nodelabel[NLangle= 90](B){12}
\nodelabel[NLangle=120](B){11}
\nodelabel[NLangle=150](B){10}
\nodelabel[NLangle=180](B){9}
\nodelabel[NLangle=210](B){8}
\nodelabel[NLangle=240](B){7}
\nodelabel[NLangle=270](B){6}
\nodelabel[NLangle=300](B){5}
\nodelabel[NLangle=330](B){4}

\node[Nh=20,Nw=20,Nmr=10](D)(75,0){}
\gasset{ExtNL=y,NLdist=1,AHnb=0,ilength=-2}
\nodelabel[NLangle= 0](D){3} \imark[iangle= 0](D)
\nodelabel[NLangle= 30](D){2} \imark[iangle= 30](D)
\nodelabel[NLangle= 60](D){1} \imark[iangle= 60](D)
\nodelabel[NLangle= 90](D){12} \imark[iangle= 90](D)
\nodelabel[NLangle=120](D){11} \imark[iangle=120](D)
\nodelabel[NLangle=150](D){10} \imark[iangle=150](D)
\nodelabel[NLangle=180](D){9} \imark[iangle=180](D)
\nodelabel[NLangle=210](D){8} \imark[iangle=210](D)
\nodelabel[NLangle=240](D){7} \imark[iangle=240](D)
\nodelabel[NLangle=270](D){6} \imark[iangle=270](D)
\nodelabel[NLangle=300](D){5} \imark[iangle=300](D)
\nodelabel[NLangle=330](D){4} \imark[iangle=330](D)
\end{gpicture}

Commands for edges (work in progress)

Examples for \drawedge, \drawloop, \drawqbedge, \drawqbpedge, \drawqcedge, \drawcbpedge

Edges1

\begin{gpicture}
\gasset{Nadjust=wh,Nadjustdist=2,loopdiam=6}
\node[Nmarks=i,iangle=200,fillcolor=yellow](A)(-20,0){initial}
\node[Nmarks=f,Nmr=0,fillgray=0.85,dash={1}0](B)(20,0){final}
\node[Nmarks=r,Nmr=3,linecolor=green](C)(60,0){$\left(
\begin{array}{ccc} 2 & 1 & 0 \\ -1 & 0 & 1 \\ 0 & -1 & 2 \end{array}\right)$}
\rmark[linecolor=green,rdist=1.4](C)

\drawedge[ELside=r,ELpos=35](A,B){straight}
\drawedge[curvedepth=5,linecolor=red](A,B){\textcolor{blue!50!white}{curved}}
\drawedge[curvedepth=-15,ELdist=2,dash={1.5}0](A,B){far}
\drawloop[ELpos=75,ELdist=-1,loopangle=150, dash={0.2 0.5}0](A){clockwise}
\drawloop[ELpos=70,loopangle=-90,loopwidth=3](A){$b\mid 10$}
\drawloop[loopCW=n,ELside=r](B){counter-CW}
\drawqbpedge[ELside=r,dash={4 1 1 1}0](B,-90,C,210){qbpedge}
\drawloop[ELside=r,loopangle=-90,loopwidth=5](C){$a$}
\end{gpicture}



BezierEdges

\begin{gpicture}
\node(1)(10,0){1}
\gasset{loopangle=-90,loopheight=10}
\drawloop[loopwidth=4](1){}
\drawloop[loopwidth=8](1){}
\drawloop[loopwidth=12](1){-90}
\gasset{loopwidth=4}
\drawloop[loopheight=4,loopangle=80](1){80}
\drawloop[loopheight=8,loopangle=140](1){140}
\drawloop[loopheight=12,loopangle=200](1){200}
\node(A)(40,0){$A$}
\drawcbpedge[ELpos=40,ELdist=0](1,35,20,A,-145,20){cbpedge}
\drawline[linecolor=green](10,0)(26.4,11.5)
\drawline[linecolor=green](40,0)(23.6,-11.5)
\node(B)(70,0){$B$}
\drawqbedge(A,40,25,B){qbedge}
\drawline[linecolor=green,AHnb=0](40,0)(40,25)(70,0)
\drawcbpedge[linecolor=red,ELside=r](A,-45,20,B,-45,30){cbpedge}
\drawline[linecolor=red](40,0)(54.14,-14.14)
\drawline[linecolor=red](70,0)(91.21,-21.21)
\node(C)(90,0){$C$}
\drawcbedge[linecolor=blue](B,50,30,C,110,30){cbedge}
\drawline[linecolor=blue](70,0)(50,30)
\drawline[linecolor=blue](90,0)(110,30)
\drawqbpedge[linecolor=green](B,45,C,90){qbpedge}
\drawline[linecolor=green,AHnb=0](70,0)(90,20)(90,0)
\gasset{ELside=r}
\drawloop[loopdiam=12](C){12}
\drawloop[loopdiam=8,loopangle=0](C){8}
\drawloop[loopdiam=6,loopangle=-90](C){6}
\end{gpicture}



Lines and curves

Examples for \drawline and \drawcurve

Lines and curves

\begin{gpicture}
\gasset{AHnb=0}
\put(2,3){\unitlength=8mm
\drawline(0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
\drawcurve[linecolor=red](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
}
\put(7,5){ \unitlength=8mm
\drawline[linecolor=blue,arcradius=.2](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
}
\put(55,16){\unitlength=1.5mm
\drawline(-10,-10)(10,10)(-10,10)(10,-10)
\drawcurve[linecolor=red,ATnb=3,AHnb=4](-10,-10)(10,10)(-10,10)(10,-10)
}
\put(100,19){\unitlength=20mm
\drawline(0.95,0.3)(-0.59,-0.8)(0,1)(0.59,-0.8)(-0.95,0.3)
\drawcurve[linecolor=red,AHnb=1](0.95,0.3)(-0.59,-0.8)(0,1)(0.59,-0.8)(-0.95,0.3)
}
\end{gpicture}

Polygons and closed curves

Examples for \drawpolygon and \drawccurve

Polygons and closed curves

\begin{gpicture}
\put(3,3){ \unitlength=8mm
\drawpolygon[fillcolor=green,Nframe=n,arcradius=.3](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
\drawpolygon(0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
\drawccurve[linecolor=red](0,0)(0,2)(1,3)(0,4)(2,4)(2,2)(4,0)(2,0)(1,1)
}
\put(55,20){ \unitlength=1.5mm
\drawpolygon[fillcolor=green,Nframe=n,arcradius=2](-10,-10)(10,10)(-10,10)(10,-10)
\drawpolygon(-10,-10)(10,10)(-10,10)(10,-10)
\drawccurve[linecolor=red](-10,-10)(10,10)(-10,10)(10,-10)
}
\put(100,19){ \unitlength=20mm
\drawccurve[fillcolor=yellow,linecolor=red](0,1)(0.59,-0.8)(-0.95,0.3)(0.95,0.3)(-0.59,-0.8)
\drawpolygon(0,1)(0.59,-0.8)(-0.95,0.3)(0.95,0.3)(-0.59,-0.8)
}
\end{gpicture}

Circles and arcs

Examples for \drawcircle and \drawarc

Circles and arcs of circles

\begin{gpicture}[name=circles-arcs]
\drawcircle[Nfill=y,fillcolor=blue](0,0,40)
\drawcircle[Nfill=y,fillcolor=white](0,0,30)
\drawcircle[Nfill=y,fillcolor=red](0,0,20)
\drawcircle[Nfill=y,fillcolor=yellow](0,0,10)
\drawarc[linecolor=black](50,0,20,0,45)
\drawarc[arcPie=y,linecolor=blue](50,0,20,-50,-15)
\drawarc[fillcolor=red,linecolor=red](50,0,20,90,190)
\drawarc[arcPie=y,fillcolor=yellow,linecolor=yellow](50,0,20,200,250)
\drawarc[arcPie=y,linecolor=blue](100,0,20,-15,-50)
\end{gpicture}

Rectangles, ovals and regular polygons

Examples for \drawrect, \drawoval and \drawrpolygon

Rectangles, ovals and regular polygons

\begin{gpicture}
\drawrpolygon[polyangle=90,fillcolor=blue](0,0)(3,8)
\drawrpolygon[fillcolor=green](20,0)(4,7)
\drawrpolygon[polyangle=18,arcradius=5](40,0)(5,7)
\drawrpolygon(60,0)(8,7)
\drawrpolygon(60,0)(8,6)
\drawrpolygon(60,0)(8,5)
\drawrect[Nfill=y,fillcolor=yellow](75,-5,95,5)
\drawrect[arcradius=3,dash={1.2}0](77,-4,93,4)
\drawoval(115,0,20,10,3)
\drawoval[Nfill=y,fillcolor=green](115,0,15,8,5)
\drawoval[Nfill=y,fillcolor=red](115,0,10,4,0)
\end{gpicture}

Bézier curves and snake lines

Examples for \drawqbezier, \drawcbezier and \drawsnake

Bézier curves and snake lines

\begin{gpicture}
\gasset{AHnb=0}
\drawline[linecolor=green](0,0)(-5,15)(20,0)
\drawqbezier(0,0,-5,15,20,0)
\drawline[linecolor=green](0,-2)(10,-12)(20,-2)
\drawqbezier[linecolor=blue,AHnb=2](0,-2,10,-12,20,-2)
\gasset{AHnb=1}
\drawline[linecolor=green](25,0)(15,10)
\drawline[linecolor=green](25,0)(35,10)
\drawcbezier[linecolor=red](25,0,15,10,35,10,25,0)
\drawline[linecolor=green](30,0)(40,0)
\drawline[linecolor=green](50,15)(40,15)
\drawcbezier[AHnb=0,dash={1.5}0](30,0,40,0,40,15,50,15)
\drawline[linecolor=green](70,10)(90,0)
\drawline[linecolor=green](70,-10)(50,0)
\drawcbezier[linecolor=blue](70,10,90,0,50,0,70,-10)

\drawsnake[linecolor=red,snakeh=.8,snakew=.8](100,10)(120,10)
\drawsnake[linecolor=blue,snakeh=2,snakew=1](100,0)(120,0)
\drawsnake[linecolor=green,snakeh=3.5,snakew=1.9](100,-10)(120,-10)
\end{gpicture}


More examples

The documentation above already contains many examples. Some more examples are given in the files below:

Known problems and (hopefully) solutions

Feedback

I hope you will find gastex helpful. Let me know if you have any problem or suggestion to improve gastex.

History since version 2.0

Version 3.1: (2021/10/21)

Fixed a bug that appeared with TeXLive 2021 when compiling gastex pictures with option pdflatex=true.
More precisely, gastex calls the package auto-pst-pdf to generate the pdf picture from the postscript code, this in turn calls ps2pdf resulting in a ghostscript error
%%%% WARNING: Transparency operations ignored - need to use -dALLOWPSTRANSPARENCY
Error: /undefined in .setopacityalpha
...
The fix is to give the option pspdf={-dALLOWPSTRANSPARENCY} when loading auto-pst-pdf.

Version 3.0: (2013/10/01)

Many changes in this release.

Version 2.9: (2010/09/23)

As suggested by Jean Berstel, it is now possible to set independently the width and the height of a loop with the two new parameters loopwidth and loopheight. The parameter loopdiam simply sets loopwidth and loopheight to the same value. See the example here.
\gasset{loopdiam=4}
\drawloop(A){}
\drawloop[loopdiam=12](B){}
\drawloop[loopwidth=4,loopheight=6](C){}

Version 2.8: (2006/11/26)

Packaged for CTAN.

Version 2.7: (2004/05/02)

gastex is now compatible with the xcolor package which allows very useful color expressions such as red!50!blue!60!white.

Version 2.6: (2004/04/23)

Improved precision of some computations.

Version 2.5: (2004/04/17)

The horizontal shifts that one gets sometimes (e.g. with overlays in presentations) should no more occur provided \nullfont is used inside the picture environment:
\begin{picture}(100,35)(-50,0)\nullfont
...
\end{picture}
\selectfont is automatically used by gastex for node or edge labels.
I found this solution looking in the package pgf (portable graphics format) by Till Tantau.
I also recommend his excellent beamer package for laptop presentations.

Version 2.4: (2003/08/12)

All these macros use gasset parameters and in particular: Nframe, Nfill, linecolor, fillcolor, dash, ... Uncompatibility: The macro \drawline was introduced in version 2.1 to draw a line between two points. The new version allows to draw a line defined by an arbitrary number of points but the syntax is different. It was \drawline(x1,y1,x2,y2) and it is now \drawline(x1,y1)(x2,y2).

Version 2.3: (2002/05/05)

Version 2.2: (2002/01/03)

Version 2.1:

Version 2.01:

Remarks

About LSV