# version 3.0

Last update: Jul. 11, 2014
Remark: The new version of pgf (e.g., from TeXLive-2014) is not compatible with auto-pst-pdf (on which GasTeX rely when compiling with pdflatex). The problem occurs during the auxiliary latex compilation needed by pst-pdf. The package pgf should not be loaded during this auxiliary latex compilation. The (temporary) solution is to avoid loading the package using ifpdf.
\usepackage{ifpdf}
\ifpdf
\usepackage{pgf}
\usepackage{tikz}
\usepackage{todonotes}
\fi
The problem is more serious if you are using beamer since it loads pgf automatically. My solution is to revert to TeXLive-2013. This should be easy if you did not remove the old distribution. On a mac, go to preferences -> TeX Distribution.

The last version of GasTeX is always available here. It consists of the following two files.
• gastex.sty which contains the definition of all GasTeX macros.
This file could be in your working folder but it is best placed where .sty files are, e.g.,
.../texmf-dist/tex/latex/gastex/gastex.sty
or
.../texmf-local/tex/latex/gastex/gastex.sty
• gastex.pro which contains all the postscript procedures used to actually draw the pictures.
This file could be in your working folder but it is best placed where .pro files are, e.g.,
.../texmf-dist/dvips/gastex/gastex.pro
or
.../texmf-local/dvips/gastex/gastex.pro

Remark: 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 should be available on CTAN soon. Meanwhile, you should download the necessary files above.

## 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.

• 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 pst-pdf 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 re-compiled and next compilation will use "true" mode (see below) to re-generate <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:
• When recompilepics is set to auto or true, the package auto-pst-pdf.sty is loaded and it requires the file <jobname>.tex to be compiled with pdflatex using the --shell-escape (or --enable-write18) option:
pdflatex --shell-escape <jobname>.tex
pdflatex --enable-write18 <jobname>.tex
If you are running LaTeX with TeXShop, you may add the option --shell-escape in the preferences -> Engine -> pdfTeX -> latex, e.g.,
pdflatex --shell-escape --output-format pdf
• When sending a final version of a paper to be published in a journal or some conference proceedings which will compile the files with pdflatex, option recompilepics should be set to false and the file <jobname>-pics.pdf should be sent together with <jobname>.tex.
Indeed, the --shell-escape option is never used by publishers since it would allow your latex file to execute arbitrary shell commands.
• The package auto-pst-pdf automates the generation of the file <jobname>-pics.pdf. One may also do it manually by following the pst-pdf instructions:
latex <jobname>.tex
dvips -o <jobname>-pics.ps <jobname>.dvi
ps2pdf <jobname>-pics.ps
• auto-pst-pdf options Only with pdflatex
Other options are passed to the package auto-pst-pdf. Two such options are described below. See the documentation of auto-pst-pdf.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, auto-pst-pdf crops a picture to its actual size (using the option notightpage of pst-pdf), 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.

## 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).

• 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 auto-pst-pdf 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 gastex-gusepicture below.
\gusepicture[viewport=0 5 88 90,clip]{loop}
\gusepicture[viewport=0 5 332 127,scale=0.85]{lessdfs}

## Examples

There is no real documentation for the macros provided by GasTeX.
The best is to learn by examples (see below).
• gastex-examples.tex and gastex-examples.pdf give some examples to learn gastex and to test your installation
• gastex-gusepicture.tex and gastex-gusepicture.pdf show how to compile gastex pictures with pdflatex
• gastex-beamer.tex and gastex-beamer.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 auto-pst-pdf 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.
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).

## History since version 2.0

### Version 3.0: (2013/10/01)

Many changes in this release.
• Compatibility with pdflatex using auto-pst-pdf (See above).
• gpicture and gusepicture (See above).
• New command to draw an arc of circle or a pie (See ex-gastex.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 ex-gastex.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 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 problemsand (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 auto-pst-pdf 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.