Debian Codegraph @

texmf-dist/doc/latex/pstring/pstring-doc.tex

raw
1 % Speed-up the compilation with LatexDaemon!!! (http://william.famille-blum.org/software/latexdaemon)
2 \input{pstring-doc.pre}
3 %
4
5 \author{William Blum}
6 \title{The pstring package}
7 \begin{document}
8 \maketitle
9 \begin{abstract}
10 This is a short documentation for the pstring package for Latex. This package allows you to
11 typeset justified sequences, also called pointing strings.
12 The latest version of the package can be downloaded from \url{http://william.famille-blum.org/software/latex/index.html}.
13
14 \begin{codeexample}[width=5cm]
15 \Pstr[0.65cm]{ \psi = (n){q^0} \ (n4-n,60){q^1} \ (n5-n4){q^2}
16 \ (n8-n){q^1} \ (n9-n8){q^2} \ (n10-n){q^3} }.
17 \end{codeexample}
18 \end{abstract}
19
20 \section{Use and syntax}
21
22 From version 0.3, pstring can use either PSTricks or PGF as a rendering engine. To specify which one
23 you want, use the option \verb|pstricks| or \verb|pgf| when you load the pstring package. For instance to use PGF you must type:
24 \begin{codeexample}[code only]
25 \usepackage{pstring}[pgf]
26 \end{codeexample}
27 If no option is specified then by default \verb|pgf| is selected if you are running pdflatex
28 and \verb|pstricks| is selected if you are running latex.
29
30 You can specifies other options with the following commands:
31 \begin{command}{\pstrSetLabelStyle\{style\}}
32 Change the style used to typeset labels on arrows.
33 \end{command}
34 \begin{command}{\pstrSetArrowColor\{color\}}
35 Change the color used to typeset arrows.
36 \end{command}
37 \begin{command}{\pstrSetArrowLineWidth\{size\}}
38 Change the arrows line width.
39 \end{command}
40 \begin{command}{\pstrSetArrowLineStyle\{style\}}
41 Change the arrows line style. Valid styles are: \verb|none|, \verb|dashed|, \verb|dotted| and \verb|solid|.
42 \end{command}
43 The default options are as follows:
44 \begin{codeexample}[code only]
45 \pstrSetLabelStyle{\color{blue} \tiny}
46 \pstrSetArrowColor{orange}
47 \pstrSetArrowLineWidth{0.3pt}
48 \pstrSetArrowLineStyle{solid}
49 \end{codeexample}
50
51 \subsection{The succinct syntax}
52 The syntax for creating a pointing string is as follows:
53 \begin{command}{\Pstr[raiseamount][nodesep]\{stringspecification\}}
54 \begin{itemize}
55 \item \verb|raiseamount| (optional) is the size by which you want
56 to raise the box containing the sequence. In
57 PSTricks mode, the bounding box is not computed automatically therefore
58 it is necessary to specify this value by hand. Using the PGF mode
59 however, this value is ignored since the bounding box
60 is computed automatically,
61 \item \verb|nodesep| (optional) is the vertical distance between
62 the nodes and the links.
63 \item \verb|stringspecification| contains commands describing the nodes
64 of the string.
65 This parameter can contain normal text and latex commands (with some restriction, see section \ref{subsec:altsyntax}).
66 Nodes that have link associated to them, or which have a link pointing to them
67 must be specified with the node specification syntax described hereunder.\end{itemize}
68 \end{command}
69
70 The syntax for creating nodes is as follows.
71 If the node has no link associated to it then you just use
72 the syntax \verb|(nodename){content of the node}| where \verb|nodename| is a name that you give to the node and \verb|content| is the text you want to write inside the node.
73
74 If there is a link attached to the node then you use
75 the syntax
76 \begin{verbatim}
77 (targetnode-nodename,angle:label){content}
78 \end{verbatim}
79 where
80 \begin{itemize}
81 \item \verb|nodename| is a name that you give to the node,
82 \item \verb|targetnode| is the name of the node where the link must point to,
83 \item \verb|angle| (optional) specifies the angle between the horizontal line and the line
84 tangent to the arrow representing the link at the top of the node,
85 \item \verb|label| (optional) is a text to be printed out on top of the link,
86 \item \verb|content| is the content of the node.
87 \end{itemize}
88
89 The arguments \verb|angle| and \verb|label| are optional. When the angle is not specified it is set to a default value of 45 (degrees).
90
91 Here is an example:
92 \begin{codeexample}[width=7cm]
93 \Pstr[20pt]{
94 t = \lambda\cdot (app){@} \cdot (ly){\lambda y}
95 \ldots (y-ly,35:1){y} \cdot
96 (lx-app,38:1){\lambda \overline{x}}
97 \ldots (x-lx,30:i){x_i} \cdot
98 (leta-y,40:i){\lambda \overline{\eta_i}} {\ldots}
99 }.
100 \end{codeexample}
101
102
103 \subsection{Alternative syntax}
104 \label{subsec:altsyntax}
105 You can use an alternative syntax to specify sequences. For instance the previous example
106 can also be defined as follows:
107 \begin{codeexample}[width=7cm]
108 \pstr[0.7cm]{
109 \nd t = \lambda \cdot (app){@}
110 \nd \cdot (ly){\lambda y}
111 \nd \ldots (y-ly,35:1) {y}
112 \nd \cdot (lx-app,38:1){\lambda \overline{x}}
113 \nd \ldots (x-lx,30:i){x_i}
114 \nd \cdot (letay-y,40:i){\lambda \overline{\eta_i}}
115 \txt{\ldots} }.
116 \end{codeexample}
117 Although this syntax is more cumbersome than the succinct one, it permits to typeset sequences that are not definable with the succinct syntax. The following example is such an example:
118 \ifLoadPSengine
119 \begin{codeexample}[width=6cm]
120 $\pstr[0.7cm][1pt]{ s = \underbrace{\cdots\ \nd(r){r^O}
121 \cdots }_{s'}\ \nd(n){n^P}
122 \ \underbrace{\cdots\ \nd(a-r,35){a}^P \cdots }_{u}
123 \ \nd(m-n,30){m}^O }$.
124 \end{codeexample}
125 \else
126 \vskip 10pt
127 [Sorry, you need to compile the documentation with latex in order to view this example]
128 \vskip 10pt
129 \fi
130
131 {\bf Important note:}
132 The previous example can only be done using the pstricks engine and using the long syntax. This is due to the use of the
133 latex command \verb|\overbrace| which embraces several nodes inside the sequence.
134 This cannot be handled in the PGF rendering mode due to the impossibility to create nodes outside of a PGF environment.
135 It may be possible to fix this problem by using the overlay feature of PGF/Tikz, however overlays seem to work only
136 within Tikz environment and not in standard PGF ones. Also overlays have the disadvantage to require two latex compilations in order to resolve node name references, and moreover they work only with pdflatex (not with latex).
137
138 \subsubsection{Adding more links}
139 It is possible to create additional links starting from a same node:
140 \begin{codeexample}[width=6cm]
141 \pstr[0.6cm]{\ldots \nd(r){r}
142 \nd\ldots (l1){\lambda \overline{\xi}_1}
143 \nd\ldots (l2){\lambda \overline{\xi}_2 }
144 \nd\ldots (n-r,45){n}
145 \arrow{n}{l1}{45}{}{blue}{dotted}
146 \arrow{n}{l2}{45}{}{blue}{dotted}
147 }.
148 \end{codeexample}
149 The syntax for arrow creation is:
150 \begin{command}{\arrow\{source\}\{target\}\{angle\}\{label\}\{linecolor\}\{linestyle\}}
151 \begin{itemize}
152 \item \verb|source| is the name of the source node,
153 \item \verb|target| is the name of the target node,
154 \item \verb|angle| is the arrow angle,
155 \item \verb|label| is a text to be printed out on top of the link,
156 \item \verb|linecolor| is the color to be used to draw the link,
157 \item \verb|linestyle| is a line style used to draw the arrow. Valid styles are: \verb|none|, \verb|dashed|, \verb|dotted| and \verb|solid|.
158 \end{itemize}
159 \end{command}
160
161
162
163 \section{Examples}
164
165 \subsection{A sequence with more links}
166 \begin{codeexample}[width=7cm]
167 \Pstr[1cm][2pt]{
168 t_2 = (n){\lambda f z} \ (n2){@}
169 \ (n3-n2,60){\lambda g x} \ (n4-n){f^{[1]}}
170 \ (n5-n4){\lambda^{[2]}} \ (n6-n3){x}
171 \ (n7-n2,35){\lambda^{[3]}} \ (n8-n,35){f^{[4]}}
172 \ (n9-n8,45){\lambda^{[5]}} \ (n10-n,35){z} }.
173 \end{codeexample}
174
175
176 \subsection{Elevation of the links}
177 A second optional parameter can be passed to \verb|\pstr| in order to elevate the links in the sequence as follows:
178 \begin{codeexample}[width=5cm]
179 $\begin{array}{rclrcl}
180 \mbox{First line} &=& \parbox[t]{8cm}{there should be enough space between the
181 bottom of this line and the arc of the next line.} \\
182 s &=& \Pstr[28pt][10pt]{ s \cdot (m){m} \cdot \ldots \cdot (lmd-m,40)
183 {\lambda\overline{\xi}} }
184 \quad \mbox{ the arc is elevated using the raise option of pstr.}
185 \end{array}$
186 \end{codeexample}
187
188 \subsection{Two sequences on the same line}
189 \begin{codeexample}[width=7cm]
190 \Pstr[0.8cm]{
191 t = (n){\lambda f z}\ (n2){@} \ (n3-n2,60){\lambda g x} \ (n4-n,45){f^{[1]}}
192 \ (n5-n4,45){\lambda^{[2]}} \ (n6-n3,45){x} \ (n7-n2,35){\lambda^{[3]}}
193 \ (n8-n,35){f^{[4]}} \ (n9-n8,45){\lambda^{[5]}} \ (n10-n,35){z}
194 }
195 \qquad
196 \Pstr[0.9cm]{
197 t\upharpoonright r = (n){\lambda f z} \ (n4-n,50){f}^{[1]}
198 \ (n5-n4,60){\lambda}^{[2]} \ (n8-n,45){f}^{[4]}
199 \ (n9-n8,60){\lambda}^{[5]} \ (n10-n,40){z}}
200 \end{codeexample}
201
202 \subsection{Sequences containing parenthesis}
203 If you insert text containing parenthesis '(' and ')' between two nodes then you must surround
204 the text with curly braces otherwise \verb|pstr| will interpret it as a node specification:
205 \begin{codeexample}[width=7.1cm]
206 \Pstr[0.8cm]{ {\psi_M(t\upharpoonright r) =\ }
207 (n){q^0}\ (n4-n,60){q^1}\ (n5-n4,60){q^2}
208 \ (n8-n,45){q^1}\ (n9-n8,60){q^2}
209 \ (n10-n,38){q^3} \in [\![ M ]\!] \ .}
210 \end{codeexample}
211
212 \subsection{Example taken from an article}
213 %\begin{codeexample}[width=4cm]
214 \newcommand{\oview}[1]{\llcorner #1 \lrcorner}
215 {\bf (InputVar)} If $t_1 \cdot x \cdot t_2$ is a traversal with
216 $x \in N_{var}^{\upharpoonright r}$ and $?(t_1 \cdot x \cdot
217 t_2)=?(t_1) \cdot x$ then so is \Pstr[0.4cm]{t_1 \cdot (m){x} \cdot t_2 \cdot (n-m,38:i){n}} for all
218 $\lambda$-node $n$ whose parent occurs in $\oview{t_1 \cdot x}$, $n$
219 pointing to some occurrence of its parent node in $\oview{t_1 \cdot x}$.
220
221 \noindent {\bf (Copycat$^@$)}
222 If \Pstr{t \cdot (app){@} \cdot (lz-app,60:0){\lambda \overline{z}} \ldots (lzv-lz,60:v){v}_{\lambda \overline{z}} } is a traversal then so is
223 \Pstr[0.6cm]{t \cdot (app){@} \cdot (lz-app,60){\lambda
224 \overline{z}} \ldots (lzv-lz,60:v){v}_{\lambda \overline{z}} \cdot
225 (appv-app,45:v){v}_@}.
226
227 \noindent {\bf (Copycat$^\lambda$)}
228 If \Pstr[0.4cm]{t \cdot \lambda \overline{\xi} \cdot (x){x} \ldots (xv-x,50:v){v}_x}
229 is a traversal then so is \Pstr[0.6cm]{t \cdot (lmd){\lambda
230 \overline{\xi}} \cdot (x){x} \ldots (xv-x,50:v){v}_x \cdot
231 (lmdv-lmd,30:v){v}_{\lambda \overline{\xi}} }.
232
233 \noindent {\bf (Copycat$^{var}$)}
234 If \Pstr[0.4cm]{t \cdot y \cdot (lmd){\lambda \overline{\xi}}
235 \ldots (lmdv-lmd,50:v){v}_{\lambda \overline{\xi}} } is a traversal
236 for some variable $y$ not in $N_{var}^{\upharpoonright r}$ then so
237 is \Pstr[0.6cm]{t \cdot (y){y} \cdot (lmd){\lambda \overline{\xi}}
238 \ldots (lmdv-lmd,30:v){v}_{\lambda \overline{\xi}} \cdot
239 (vy-y,50:v){v}_y }.
240 %\end{codeexample}
241 \end{document}