GasTeX: Graphs and Automata Simplified in TeX
version 2.9b6
Last update: May 11, 2011
Thanks to the package auto-pst-pdf, GasTeX is now fully compatible with pdflatex.
To use this feature, a new option "pst-pdf" has been added to the package gastex:
\usepackage[pst-pdf=md5]{gastex}
The default (inactive) value is "off" in order to get backward compatibility: compilation with latex+dvips(+ps2pdf).
There are 4 active values: "md5 (recommended), auto, on, draft" which are described in the example file
ex-gastex-pstpdf.tex.
When using an active mode, the latex file should be compiled with pdflatex using the --shell-escape option.
Moreover, the new "gpicture" environment should be used for gastex pictures (instead of the classical "picture" environment of latex).
One may safely replace all picture environments with gpicture, even when using latex+dvips(+ps2pdf).
There are a few useful options to the gpicture environment which are also described in the example file
ex-gastex-pstpdf.tex.
New in version 2.9b1 (23/09/2010)
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){}
There is no real documentation for gastex. The best is to learn by
examples (see below).
See also the file
gastex.sty where all macros are documented.
GasTeX is a set of LaTeX macros which allow to draw very easily
graphs, automata, nets, diagrams, etc... under the picture environment
of LaTeX. A picture with gastex basically consists of nodes and edges.
Here are a few examples of pictures that are easily defined with
gastex.
and a whole lot of
automata
examples by Jean-Éric Pin.
Version 2.8 of GasTeX is available here
on CTAN since the end of 2006.
So it should be available by default on your system unless your TeX
installation is really old.
The new version 2.9bx should be available on CTAN soon.
Meanwhile, you may download the necessary files below.
- gastex.sty which contains the
definition of all the TeX macros (this file could be in your working
folder or where others .sty files are),
- gastex.pro which contains all the
postscript procedures (this file could be in your working folder but it
is best placed where the tex.pro file is),
- gastex.ps which is just a readable
version of gastex.pro. This file is not needed. It is only provided for
those who want to have a look at the postscript procedures.
- ex-gastex.tex some examples to
learn gastex and to test your installation
-
ex-gastex-pstpdf.tex shows how to
compile gastex pictures with pdflatex
-
ex-gastex-beamer.tex shows how gastex
may be used with beamer in order to
produce very nice animated slides. You have to compile the file through
latex-dvips-ps2pdf (not pdflatex).
- JasTeX
(outdated and not maintained)
the long-awaited graphical interface in Java
for GasTeX.
It was developped for GasTeX 2.3 and has no tools to draw the new
macros (polygons, curves, ...) introduced in GasTeX 2.4.
Here is a modified version by
Pierre Moro. It is compatible with java 1.4 and 1.5 and it complies to
the new syntax of \drawline.
Feedback
I hope you will find gastex helpful. Let me know if you have any
problem or suggestion to improve gastex.
If you are using gastex, I'd like to know it so please send me an email
and if you wish I'll let you know about new versions if any (I don't
intend to spend much time in the near future).
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 Bezier 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 ex-gastex.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
- 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}
- Zero width or height (2000/03/07): A postscript error may
occur when using Nw=0,Nh=0.
Solution: Use a small value instead of 0, e.g. Nw=0.1,Nh=0.1
Fixed in version 2.1
- 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.