GasTeX: Graphs and Automata Simplified in TeX
Documentation
version 3.0
Last update: March 19, 2021
Remark:
Version 3.0 of GasTeX is available
here
on
CTAN since 2021/03/19.
For a quick startup guide with some examples, see
gastexdoc.tex and the resulting
gastexdoc.pdf.
The last version of GasTeX is always available here. It consists of the following two files.
Usage
\usepackage{gastex}
\usepackage[options]{gastex}
Package options
Thanks to the packages
pstpdf
and
autopstpdf
, GasTeX
is now fully compatible with pdflatex. This feature is controlled with two
options
pdflatex
and
recompilepics
as explained below.
 pdflatex
Set this option to true (default) if the latex file is compiled with pdflatex.
\usepackage[pdflatex]{gastex} or
\usepackage[pdflatex=true]{gastex}
Omit this option or set it to false if the latex file is compiled with latex+dvips(+ps2pdf).
\usepackage{gastex} or
\usepackage[pdflatex=false]{gastex}
 recompilepics
Only with pdflatex
The package pstpdf
includes pictures directly from the file
<jobname>pics.pdf, allowing the compilation with pdflatex. When
pictures have changed, the file <jobname>pics.pdf should be
regenerated. This is controlled with the recompilepics
option.
\usepackage[pdflatex,recompilepics={false,true,auto}]{gastex}
\usepackage[pdflatex,recompilepics]{gastex}
The possible values for option recompilepics
are:
 "auto" (default): md5 checksums of gpicture's source code are computed and saved to file <jobname>md5.txt.
If this file exists, new checksums are compared with old ones to check if pictures have changed.
If this is the case a warning occurs saying that <jobname>.tex needs to be recompiled
and next compilation will use "true" mode (see below) to regenerate <jobname>pics.pdf.
Otherwise, mode "false" (see below) is used and pictures are simply included from <jobname>pics.pdf.
 "true": the file <jobname>pics.pdf is (re)generated
immediately, even if pictures did not change and the file
<jobname>pics.pdf is still up to date.
Useful when pictures are intensively modified.
 "false": pictures are simply included from <jobname>pics.pdf with \includegraphics.
Even if pictures have changed in the source file, you still get the old pictures from <jobname>pics.pdf.
Remarks:
 autopstpdf options
Only with pdflatex
Other options are passed to the package autopstpdf
. Two such
options are described below. See the documentation of
autopstpdf.sty
for more details.
 runs=2
\usepackage[pdflatex,recompilepics,runs=2]{gastex}
If a picture contains references with \ref{} then latex should be run
twice when the file <jobname>pics.pdf is generated.
 crop=off
\usepackage[pdflatex,recompilepics,crop=off]{gastex}
By default, autopstpdf
crops a picture to its actual size
(using the option notightpage
of pstpdf
), ignoring
the dimensions given to the environment gpicture
. In most cases this is fine, but
if you want the dimensions given to gpicture
to be used for
the bounding box, you should set option crop
to off.
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).
 gpicture
\begin{gpicture}[options]
...
\end{gpicture}
or
\begin{gpicture}[options](width,height)
...
\end{gpicture}
or
\begin{gpicture}[options](width,height)(x offset,y offset)
...
\end{gpicture}
The (x offset,y offset) arguments are optional and default to (0,0) if omitted.
The (width,height) arguments are optional and default to (10,10) if omitted.
The (width,height)(x offset,y offset) arguments are similar to those of the LaTeX picture environment.
The picture defines a TeX box whose size is (width,height) given in \unitlength.
The coordinates of the lower left corner of this box are given by (x offset,y offset) in \unitlength.
Remark: If pdflatex is used without
the option crop=off
given to the package
autopstpdf
then the arguments (width,height)(x offset,y
offset) are ignored and the TeX box containing the picture is
automatically adjusted to the actual contents of the picture.
The possible options are frame
, name
and ignore
as described below.
\begin{gpicture}[frame,name=loop,ignore]
...
\end{gpicture}
The options name
and ignore
are only meaningful when compiling with pdflatex.
 frame={true,false} default is true.
Adds a frame around the picture.
 name=<picname>
Gives a name to the picture so that it may be used later with \gusepicture{<picname>}.
 ignore={true,false} default is true.
Only with pdflatex
The picture is generated in <jobname>pics.pdf but not included. It
should be named and included later with \gusepicture{<picname>}.
 gusepicture
Only with pdflatex
\gusepicture[options]{<picname>}
Includes picture <picname> which must have been created and named
with a gpicture environment.
This is convenient to include the same picture several times or to add
\includegraphics options such as clip
, viewport
,
scale
, etc. See examples in gastexgusepicture below.
\gusepicture[viewport=0 5 88 90,clip]{loop}
\gusepicture[viewport=0 5 332 127,scale=0.85]{lessdfs}
Remark:
The option clip
does not work if we add it to the option list
of gpicture
.
This is a problem with pstpdf
that I do not understand, hence I cannot fix.
A solution is to use ignore
in the option of gpicture and then define the
viewport
and clip
as options of \gusepicture (see above).
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}


Each drawing command has a name, some optional parameters, and some
mandatory arguments:
\commandname[optional parameters]<mandatory arguments>

linegray=<decimal number between 0 and 1>
:
Gray level used to draw edges, lines, curves, etc. 0=black
, 1=white
.

fillgray=<decimal number between 0 and 1>
:
Gray level used to fill nodes, circles, polygons, etc. 0=black
, 1=white
.

linecolor=<color value>
:
Color used to draw edges, lines, curves, etc.
color value
should be as specified by the
xcolor
package. For instance, blue
or
red
or green!40!yellow
, etc.

fillcolor=<color value>
:
Color used to fill nodes, circles, polygons, etc.

linewidth=<decimal number>
:
Width in \unitlength
used to draw edges, lines, curves, etc.

dash={pattern}{offset}
:
Set the dash pattern used when drawing edges, lines, curves, etc.
pattern
is a list of decimal numbers indicating lengths in
\unitlength
alternately of dashes and spaces.
The list of lenghts is used circularly.
offset
is a decimal number indicating in
\unitlength
when the pattern starts.
dash={}{0} 
continuous path 
dash={1.5}{0} 
dashs of length 1.5 and empty spaces of length 1.5 
dash={0.2 0.5}{0} 
looks like a sequence of dots 
dash={4 1 1 1}{0} 
alternation of long and short dashs 
dash={1.5}{1.5} 
we start with the empty space and not the dash 
dash={4}{2} 
we start in the middle of the first dash 

\node
: Define and draw a node.
\node(NodeName)(x,y){NodeLabel}
\node[parameter=value,...](NodeName)(x,y){NodeLabel}
NodeName
(string) is the name of the node, to be used with edges,
loops, etc.
x,y
(decimal numbers) define the coordinates in
\unitlength
of the center of the node.
NodeLabel
(any LATEX text, including math, array, etc.) is
the label of the node. Leave empty if no label.

\rpnode
: Define and draw a node whose shape is a regular polygon.
\rpnode(NodeName)(x,y)(n,r){NodeLabel}
\rpnode[parameter=value,...](NodeName)(x,y)(n,r){NodeLabel}
Similar to the \node
macro with two additional arguments:
n
(natural number) number of sides of the regular polygon.
r
(decimal number) is the radius in \unitlength
of the circle containing the polygon.

\imark
: Add an ingoing arrow to mark an initial node.
\imark(NodeName)
\imark[parameter=value,...](NodeName)
NodeName
(string) is the name of the node, which should
have been defined with \node
or \rpnode
.

\fmark
: Add an outgoing arrow to mark a final node.
\fmark(NodeName)
\fmark[parameter=value,...](NodeName)
NodeName
(string) is the name of the node, which should
have been defined with \node
or \rpnode
.

\rmark
: Add a second line to mark a repeated node.
\rmark(NodeName)
\rmark[parameter=value,...](NodeName)
NodeName
(string) is the name of the node, which should
have been defined with \node
or \rpnode
.

\nodelabel
: Add a label to the node.
\nodelabel(NodeName){NodeLabel}
\nodelabel[parameter=value,...](NodeName){NodeLabel}
NodeName
(string) is the name of the node, which should
have been defined with \node
or \rpnode
.
NodeLabel
(any LATEX text, including math, array, etc.) is
the label of the node. Leave empty if no label.
Examples for \node, \rpnode, \imark, \fmark, \rmark, \nodelabel
\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}
\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}
\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}

\drawedge
: Draw an edge between two nodes.
\drawedge(startingNode,endingNode){EdgeLabel}
\drawedge[parameter=value,...](startingNode,endingNode){EdgeLabel}
startingNode
(string) is the name of the source node,
which should have been defined with \node
or \rpnode
.
endingNode
(string) is the name of the target node,
which should have been defined with \node
or \rpnode
.
EdgeLabel
(any LATEX text, including math, array, etc.) is
the label of the edge. Leave empty if no label.

\drawloop
: Draw a loop on a node following a cubic Bézier curve.
\drawloop(NodeName){EdgeLabel}
\drawloop[parameter=value,...](NodeName){EdgeLabel}
NodeName
(string) is the name of the node,
which should have been defined with \node
or \rpnode
.
EdgeLabel
is as for the \drawedge
command above.

\drawqbedge
: Draw an edge between two nodes following a quadratic Bézier curve.
\drawqbedge(startingNode,x,y,endingNode){EdgeLabel}
\drawqbedge[parameter=value,...](startingNode,x,y,endingNode){EdgeLabel}
startingNode, endingNode, EdgeLabel
are as for the
\drawedge
command above.
x,y
(decimal numbers) define in \unitlength
the
coordinates of the intermediate control point of the quadratic Bézier curve.

\drawqbpedge
: Draw an edge between two nodes following a quadratic Bézier curve.
\drawqbpedge(startingNode,sa,endingNode,ea){EdgeLabel}
\drawqbpedge[parameter=value,...](startingNode,sa,endingNode,ea){EdgeLabel}
startingNode, endingNode, EdgeLabel
are as for the
\drawedge
command above.
sa,ea
(decimal numbers) define the angles in degree of the
edge at the source and target node.
The intersection of the lines defined by (startingNode,sa)
and (endingNode,ea)
is the intermediary control point of the
quadratic Bézier curve.

\drawcbedge
: Draw an edge between two nodes following a cubic Bézier curve.
\drawcbedge(startingNode,xs,ys,endingNode,xe,ye){EdgeLabel}
\drawcbedge[parameter=value,...](startingNode,xs,ys,endingNode,xe,ye){EdgeLabel}
startingNode, endingNode, EdgeLabel
are as for the
\drawedge
command above.
xs,ys,xe,ye
(decimal numbers) define in \unitlength
the coordinates of the two intermediate control points of the cubic Bézier curve.

\drawcbpedge
: Draw an edge between two nodes following a cubic Bézier curve.
\drawcbpedge(startingNode,sa,sr,endingNode,ea,er){EdgeLabel}
\drawcbpedge[parameter=value,...](startingNode,sa,sr,endingNode,ea,er){EdgeLabel}
startingNode, endingNode, EdgeLabel
are as for the
\drawedge
command above.
sa,sr
(decimal numbers) define the polar coordinates
relative to startingNode
of the first control point (angle
sa
in degree and radius sr
in \unitlength
.
ea,er
(decimal numbers) define the polar coordinates
relative to endingNode
of the second control point (angle
sa
in degree and radius sr
in \unitlength
.
Examples for \drawedge, \drawloop, \drawqbedge, \drawqbpedge, \drawqcedge, \drawcbpedge
\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){counterCW}
\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}
\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}

\drawline
: Draw a broken line defined by n points (n>1).
\drawline(x1,y1)...(xn,yn)
\drawline[parameter=value,...](x1,y1)...(xn,yn)
x1,y1,...,xn,yn
(decimal numbers) define the coordinates
in \unitlength
of the control points.
Depending on the parameters, the line may have arrowhead(s), arrowtail(s), color, ...

\drawcurve
: Draw a curve defined by n points (n>1).
\drawcurve(x1,y1)...(xn,yn)
\drawcurve[parameter=value,...](x1,y1)...(xn,yn)
x1,y1,...,xn,yn
(decimal numbers) define the coordinates
in \unitlength
of the control points.
Between each pair of consecutive points, we use a cubic Bezier curve.
The control points of the cubic Bezier curves are determined so that the
whole curve is continuously differentiable and the tangent at each point
is orthogonal to the bisector at this point.
Depending on the parameters, the line may have arrowhead(s), arrowtail(s), color, ...
Examples for \drawline
and \drawcurve
\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}

\drawpolygon
: Draw a polygon defined by n points (n>1).
\drawpolygon(x1,y1)...(xn,yn)
\drawpolygon[parameter=value,...](x1,y1)...(xn,yn)
x1,y1,...,xn,yn
(decimal numbers) define the coordinates
in \unitlength
of the control points.
Depending on the parameters, the polygon may be framed and/or filled.

\drawccurve
: Draw a closed curve defined by n points (n>1).
\drawccurve(x1,y1)...(xn,yn)
\drawccurve[parameter=value,...](x1,y1)...(xn,yn)
x1,y1,...,xn,yn
(decimal numbers) define the coordinates
in \unitlength
of the control points.
Between each pair of consecutive points, we use a cubic Bezier curve.
The control points of the cubic Bezier curves are determined so that the
whole curve is continuously differentiable and the tangent at each point
is orthogonal to the bisector at this point.
Depending on the parameters, the polygon may be framed and/or filled.
Examples for \drawpolygon
and \drawccurve
\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}

\drawcircle
: Draw a circle.
\drawcircle(x,y,d)
\drawcircle[parameter=value,...](x,y,d)
x,y,d
(decimal numbers) define the coordinates
in \unitlength
of the center of the circle and its diameter.
Depending on the parameters, the circle may be framed and/or filled.

\drawarc
: Draw an arc of a circle.
\drawarc(x,y,r,a,b)
\drawarc[parameter=value,...](x,y,r,a,b)
x,y,r
(decimal numbers) define the coordinates
in \unitlength
of the center of the arc of circle and its radius.
a,b
(decimal numbers) define in degree
the starting/ending angle of the arc of circle.
Depending on the parameters, the arc of circle may be framed and/or filled.
Examples for \drawcircle
and \drawarc
\begin{gpicture}[name=circlesarcs]
\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}

\drawrect
: Draw a rectangle.
\drawrect(x0,y0,x1,y1)
\drawrect[parameter=value,...](x0,y0,x1,y1)
x0,y0,x1,y1
(decimal numbers) define in
\unitlength
the coordinates of the lowerleft and
upperright points of the rectangle.
Depending on the parameters, the rectangle may be framed and/or filled.

\drawoval
: Draw an oval.
\drawoval(x,y,w,h,mr)
\drawoval[parameter=value,...](x,y,w,h,mr)
x,y,w,h,mr
(decimal numbers) define in
\unitlength
the coordinates of the center of the oval, its
width and height, and the maximal radius of the rounded corners.
The oval is simply a rectangle with rounded corners, setting
mr=0
results in a classical rectangle.
Depending on the parameters, the rectangle may be framed and/or filled.

\drawrpolygon
: Draw a regular polygon
\drawrpolygon(x,y)(n,r)
\drawrpolygon[parameter=value,...](x,y)(n,r)
x,y,r
(decimal numbers) define in \unitlength
the coordinates of the center of the polygon and its radius.
n
(natural number) is the number of sides of the polygon.
Depending on the parameters, the polygon may be framed and/or filled.
Examples for \drawrect, \drawoval
and \drawrpolygon
\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}

\drawqbezier
: Draw a quadratic Bézier curve.
\drawqbezier(x0,y0,x1,y1,x2,y2)
\drawqbezier[parameter=value,...](x0,y0,x1,y1,x2,y2)
x0,y0,x1,y1,x2,y2
(decimal numbers) define in
\unitlength
the coordinates of the starting point, the
intermediate control point, and the final point of the quadratic Bézier
curve.

\drawcbezier
: Draw a cubic Bézier curve.
\drawcbezier(x0,y0,x1,y1,x2,y2,x3,y3)
\drawcbezier[parameter=value,...](x0,y0,x1,y1,x2,y2,x3,y3)
x0,y0,x1,y1,x2,y2,x3,y3
(decimal numbers) define in
\unitlength
the coordinates of the starting point, the two
intermediate control points, and the final point of the cubic Bézier
curve.

\drawsnake
: Draw a line with snake waves between two points.
\drawsnake(x1,y1)(x2,y2)
\drawsnake[parameter=value,...](x1,y1)(x2,y2)
x1,y1,x2,y2
(decimal numbers) define in
\unitlength
the coordinates of the starting and ending points.
Examples for \drawqbezier, \drawcbezier
and \drawsnake
\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}
The documentation above already contains many examples. Some more examples
are given in the files below:

gastexexamples.tex and gastexexamples.pdf give some examples to
learn gastex and to test your installation

gastexgusepicture.tex and gastexgusepicture.pdf show how to
compile gastex pictures with pdflatex

gastexbeamer.tex and gastexbeamer.pdf show how gastex may be
used with beamer in
order to produce very nice animated slides.
WARNING: If a frame consists only of a gpicture with overlays, when compiling
with pdflatex you may get the first overlay only. I don't know why and guess
it is a problem either with autopstpdf or with beamer.
SOLUTION: add a command outside the gpicture which forces the generation of
all overlays, e.g., \pause[6]
Feedback
I hope you will find gastex helpful. Let me know if you have any
problem or suggestion to improve gastex.
Version 3.0: (2013/10/01)
Many changes in this release.

Compatibility with pdflatex using
autopstpdf
(See
above).

gpicture and gusepicture (See above).

New command to draw an arc of circle or a pie
(See gastexexamples.tex)
\drawarc[linecolor=black](0,10,20,0,45)
\drawarc[arcPie=y,linecolor=blue](0,10,20,50,15)

New command to draw a snaky line
(See gastexexamples.tex)
\drawsnake[linecolor=red,snakeh=.8,snakew=.8](20,15.5)(20,8.5)
\drawsnake[linecolor=red,snakeh=.8,snakew=.8](0,7.5)(0,0.5)
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)
 added the macro \rpnode to allow nodes
whose shape is a regular polygon defined by its radius, its number of
sides and an angle for the first point.
 added the possibility to have arrows at the
tail of edges and lines. For this, the following new parameters are
provided:
ATnb, ATdist, ATangle, ATlength, ATLength
 added the macro \drawpolygon to draw a
polygon defined by a list of points.
 added the macro \drawrpolygon to draw a
regular polygon defined by its radius, its number of sides and an angle
for the first point.
 added the macro \drawline to draw a broken
line defined by n points.
 added the parameter "arcradius" in order to
have arcs instead of sharp angles for
polygons and broken lines.
The default is arcradius=0 for sharp angles.
 added the macro \drawcurve to draw a
continuous curve going through n points.
 added the macro \drawccurve to draw a
continuous closed curve going through n points.
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)
 Added the parameter ELdistC (y or n)
allowing to specify whether the distance (ELdist) is between the center
(y) of the label and the edge or between the side (n) of the label and
the edge. The behaviour of previous gastex versions corresponds to the
setting (n) which is therefore the default.
 Added the macro \drawqbpedge allowing to specify the auxiliary
point of a quadratic Bézier curve with two angles instead of the
absolute coordinates required by \drawqbedge.
 Added parameters sxo, syo, exo, eyo (offsets in \unitlength).
They define offsets for the virtual starting and ending points of an
edge with respect to the centers of the starting and ending nodes.
 Improved drawing for arrowheads (in gastex.pro). First, the
direction of the arrowhead is better for curved edges. Second, when
several arrowheads are drawn they follow the curve. Previously, they
followed the tangent at the ending point of the edge which was bad for
curved edges.
Version 2.2: (2002/01/03)
 Added the options slide and paper to the package.
In order to get the default settings for
slides, use
\usepackage[slide]{gastex}
The default settings for papers is obtained with
\usepackage[paper]{gastex}
or
\usepackage{gastex}
 Added new option loopCW to define whether
loops are in clockwise direction or not.
 Fix a TeX error (Arithmetic overflow) that
occurred when using \drawedge(A,B){} with two nodes A and B having the
same coordinates.
Now, in this case, an error message is issued
in the log and the macro \drawedge(A,B){} is ignored.
Version 2.1:
 New macros to draw directly circles,
rectanges, ovals, lines and bezier curves.
\drawcircle, \drawrect, \drawoval,
\drawline, \drawqbezier, \drawcbezier
All these macros uses gasset options and in
particular:
Nframe, Nfill, linecolor, fillcolor, dash,
AHnb, etc...
 Compatibility mode for pspictpg up to v0.6
 Fix the bug which occured sometimes when using
Nw=0,Nh=0.
Version 2.01:
 Fix an error that occured in v2.0 when
using Nfill=y without defining previously fillgray or fillcolor.
The following default setting has been added.
\gasset{fillgray=0,Nfill=n} % Not filled but black if filled
Remarks

Version 2.0 of gastex has been completely rewritten and is
much more powerful than version 1.0. You need to use a compatible mode
if you wish to use old pictures with this new version. See the files gastex.sty and exgastex.tex
to learn more about this compatibility.

The perl script GasTeX1to2.pl
allows you to translate most gastex 1.0 pictures to gastex 2.0 syntax.
Just use this perl script as a filter on your file.

gastex mainly generates postscript so the pictures cannot be seen with a
dvipreviewer. One should use a postscript printer or a postscript
previewer (which usually allows also to print on nonpostscript printers).
 I have only tested gastex with dvips.
 If you have problems with colors try adding the option dvips when
calling the package color: \usepackage[usenames,dvips]{color}. It may
not be the default in all systems.
 In case you need the old version, it is still available here .
Known problems
and (hopefully) solutions
 overlays with beamer and pdflatex (2012/08/21):
If a frame consists only of a gpicture with overlays, when compiling
with pdflatex you may get the first overlay only. I don't know why and guess
it is a problem either with autopstpdf or with beamer.
Solution: add a command outside the gpicture which forces the generation of
all overlays, e.g., \pause[6]
 gasset and tabular (2000/10/27):
Using gasset inside a tabular or an array produces an error.
The reason is that I'm using the "&" symbol as a marker in order to
process gasset options.
Solution: Include the whole picture inside an mbox.
\begin{tabular}{c}
\mbox{\begin{picture}(10,20)(5,5)
\gasset{ELdist=0}
\node(A)(0,0){1}\drawloop(A){$a$}
\end{picture}}
\end{tabular}
 GasTeX and German (1999/10/21):
Frank Goertzen has reported that
when using gastex together with german an error may occur when running
dvips if the german package is loaded first.
Solution: load gastex before german:
\usepackage{gastex}
\usepackage{german}
I have no idea concerning the cause of this error.