summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/gastex/gastex-doc.tex
blob: 712f98f22ee3e5e012646360609eb4200c83ac0c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
\documentclass[12pt]{article}
\usepackage{url,xspace}
\usepackage[a4paper,text={16cm,22.7cm},centering]{geometry}

\usepackage[pdflatex,recompilepics=true]{gastex}
\gasset{frame=false,Nw=6,Nh=6,loopdiam=5}

\parindent=0pt
\parskip=1.5ex

\newcommand\GasTeX{\textsf{GasTeX}\xspace}
\newcommand{\leftend}{{\vdash}}
\newcommand{\rightend}{{\dashv}}

\title{\GasTeX: Graphs and Automata Simplified in \TeX}
\author{Paul Gastin \\[1ex]
        LMF, ENS Paris-Saclay \\
        {\small\texttt{paul.gastin@ens-paris-saclay.fr}}}
\date{v3.0}
\begin{document}
\maketitle
\begin{abstract}
  This is a very minimal startup guide including some examples.  
\end{abstract}

\begin{gpicture}[name=gpic:LR-concat,ignore]
  \gasset{Nframe=n}
  \node(ui)(15,3){$u$}
  \node(ui+1)(45,3){$v$}
  \gasset{AHnb=0}
  \drawline(0,2)(0,-31)
  \drawline(30,2)(30,-31)
  \drawline(60,2)(60,-31)
  \gasset{AHnb=1,arcradius=0.8}
  \drawline(0,-1)(20,-1)(20,-3)(5,-3)(5,-5)(30,-5)
  \node(x0)(23,-2){$\rho_0$}
  \drawline[linecolor=red](30,-5)(50,-5)(50,-7)(35,-7)(35,-9)(45,-9)(45,-11)(30,-11)
  \node(x0)(53,-6){\color{red}$\rho_1$}
  \drawline[linecolor=red](30,-11)(20,-11)(20,-13)(25,-13)(25,-15)(18,-15)(18,-17)(30,-17)
  \node(x1)(17,-12){\color{red}$\rho_2$}
  \drawline[linecolor=red](30,-17)(40,-17)(40,-19)(30,-19)
  \node(x2)(43,-18){\color{red}$\rho_3$}
  \drawline[linecolor=red](30,-19)(15,-19)(15,-21)(22,-21)(22,-23)(10,-23)(10,-25)(30,-25)
  \node(x3)(12,-20){\color{red}$\rho_4$}
  \drawline(30,-25)(50,-25)(50,-27)(40,-27)(40,-29)(60,-29)
  \node(x2)(53,-26){$\rho_5$}
  \gasset{Nw=1.6,Nh=1.6,Nfill=y,ExtNL=y,NLdist=.7}
  \node[NLangle=45](p)(0,-1){$p$}
  \node[fillcolor=red,NLangle=45](p1)(30,-5){\color{red}$p_1$}
  \node[fillcolor=red,NLangle=135](p2)(30,-11){\color{red}$p_2$}
  \node[fillcolor=red,NLangle=45](p3)(30,-17){\color{red}$p_3$}
  \node[fillcolor=red,NLangle=-135](p4)(30,-19){\color{red}$p_4$}
  \node[fillcolor=red,NLangle=45](p5)(30,-25){\color{red}$p_5$}
  \node[NLangle=0](q)(60,-29){$q$}
\end{gpicture}
\begin{gpicture}[name=gpic:LL-concat,ignore]
  \gasset{Nframe=n}
  \node(ui)(15,3){$u$}
  \node(ui+1)(45,3){$v$}
  \gasset{AHnb=0}
  \drawline(0,2)(0,-31)
  \drawline(30,2)(30,-31)
  \drawline(60,2)(60,-31)
  \gasset{AHnb=1,arcradius=0.8}
  \drawline(0,-1)(20,-1)(20,-3)(5,-3)(5,-5)(30,-5)
  \node(x0)(23,-2){$\rho_0$}
  \drawline[linecolor=red](30,-5)(50,-5)(50,-7)(35,-7)(35,-9)(45,-9)(45,-11)(30,-11)
  \node(x0)(53,-6){\color{red}$\rho_1$}
  \drawline[linecolor=red](30,-11)(20,-11)(20,-13)(25,-13)(25,-15)(18,-15)(18,-17)(30,-17)
  \node(x1)(17,-12){\color{red}$\rho_2$}
  \drawline[linecolor=red](30,-17)(40,-17)(40,-19)(30,-19)
  \node(x2)(43,-18){\color{red}$\rho_3$}
  \drawline[linecolor=black](30,-19)(15,-19)(15,-21)(22,-21)(22,-23)(10,-23)(10,-25)(15,-25)
  (15,-27)(0,-27)
  \node(x3)(12,-20){\color{black}$\rho_4$}
  \gasset{Nw=1.6,Nh=1.6,Nfill=y,ExtNL=y,NLdist=.7}
  \node[NLangle=45](p)(0,-1){$p$}
  \node[fillcolor=red,NLangle=45](p1)(30,-5){\color{red}$p_1$}
  \node[fillcolor=red,NLangle=135](p2)(30,-11){\color{red}$p_2$}
  \node[fillcolor=red,NLangle=45](p3)(30,-17){\color{red}$p_3$}
  \node[fillcolor=red,NLangle=-135](p4)(30,-19){\color{red}$p_4$}
  \node[NLangle=180](q)(0,-27){$q$}
\end{gpicture}


For the documentation, please see
\url{http://www.lsv.fr/~gastin/gastex/index.html}.

The package consists of two files \verb|gastex.sty| and \verb|gastex.pro|.
\begin{itemize}
  \item \verb|gastex.sty| contains the definition of all \GasTeX macros.
  This file could be in your working folder but it is best placed where \verb|.sty| files are, e.g.,
  
  \verb|.../texmf-dist/tex/latex/gastex/gastex.sty| \\  
  or \\  
  \verb|.../texmf-local/tex/latex/gastex/gastex.sty|

  \item  \verb|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 \verb|.pro| files are, e.g.,
  
  \verb|.../texmf-dist/dvips/gastex/gastex.pro| \\
  or \\  
  \verb|.../texmf-local/dvips/gastex/gastex.pro|
\end{itemize}

This documentation file simply contains a few simple examples on how to make figures with
\GasTeX. It should be compiled with
\begin{quote}
  \verb|pdflatex --shell-escape gastex-doc.tex| \\ 
  or \\
  \verb|pdflatex --enable-write18 gastex-doc.tex|
\end{quote}

The first example below is a 2-way deterministic finite state transducer. It consists of 
a \verb|gpicture| environment which contains the \GasTeX commands for nodes and 
transitions.

\begin{center}
  \begin{gpicture}[name=gpic:2DFT]
    \gasset{Nframe=y,Nw=8,Nh=8,loopdiam=6}
    \unitlength=2.8mm
    \node[Nmarks=i](0)(0,0){$q_0$}
    \node(1)(10,0){$q_1$}
    \node[Nmarks=r](2)(20,0){$q_2$}
    \node(6)(30,0){$q_3$}
    \node(3)(30,-8){$q_4$}
    \node(4)(20,-8){$q_5$}
    \node(5)(10,-8){$q_6$}
    
    \drawloop(0){$\leftend/\varepsilon,+1$}
    \drawloop(1){$a/\varepsilon,+1$}
    \drawloop(2){$\rightend/\varepsilon,+1$}
    \drawloop(6){$a/\varepsilon,+1$}
    \drawloop[loopangle=-90](3){$a/a,-1$}
    \drawloop[loopangle=-90](4){$a/b,-1$}
    \drawloop[loopangle=-90](5){$a/\varepsilon,+1$}
    
    \drawedge(0,1){$b/\varepsilon,+1$}
    \drawedge(1,2){$b/\varepsilon,+1$}
    \drawedge[ELpos=25,ELdist=0,ELside=r](2,3){$b/\varepsilon,-1$}
    \drawedge[ELpos=50](6,3){$b/\varepsilon,-1$}
    \drawedge[ELside=l](3,4){$b/\varepsilon,-1$}
    \drawedge[ELpos=50](4,5){$b/\varepsilon,+1$}
    \drawedge[ELpos=50](5,1){$b/\varepsilon,+1$}
    \drawedge(2,6){$a/\varepsilon,+1$}
  \end{gpicture}
\end{center}

The second one is in Figure~\ref{fig:LR-concat}.  The pictures have been defined at the
beginning of the \LaTeX\ document, with the \verb|name| and \verb|ignore| optional
parameters given to the \verb|gpicture| environment.  These pictures are generated but not
inserted immediately.  Instead, the \verb|\gusepicture| command allows to include each
named picture, possibly multiple times at different places.

All pictures defined in \verb|gpicture| environments are compiled and stored in a file
called \verb|filename-pics.pdf|, one picture per page.  These pictures could be included
in any \LaTeX\ file, possibly another \LaTeX\ file which need not use the \GasTeX package,
simply by using \verb|\includegraphics| as follows:
\begin{quote}
  \verb|\includegraphics[page=2,scale=0.6]{gastex-doc-pics.pdf}|

  \includegraphics[page=2,scale=0.6]{gastex-doc-pics.pdf}
\end{quote}
This is convenient for instance when sending the \LaTeX\ file to \verb|Arxiv| or to an 
editor (journal, proceedings) which does not allow the \verb|--shell-escape| option when 
compiling with \verb|pdflatex|. Actually, \GasTeX does this automatically for you. When 
loading the package, set the \verb|recompilepics| option to \verb|false| as follows:
\begin{quote}
  \verb|\usepackage[pdflatex,recompilepics=false]{gastex}|
\end{quote}
then you may compile without the \verb|--shell-escape| option
\begin{quote}
    \verb|pdflatex gastex-doc.tex| 
\end{quote}
and \GasTeX automatically calls \verb|\includegraphics| to include the pictures that have 
been previously generated and stored in the file \verb|gastex-doc-pics.pdf|.

\begin{figure}[b]
  \centering
  \gusepicture{gpic:LR-concat}
  \hfill
  \gusepicture{gpic:LL-concat}
  \caption{Decomposition of a left-right run and a left-left run over the product $w=uv$.}
  \label{fig:LR-concat}
\end{figure}


\end{document}