| 1 |
% This file is part of the Petri-nets packages. See file README for |
| 2 |
% copyright notice. |
| 3 |
|
| 4 |
\documentclass[11pt]{article} |
| 5 |
|
| 6 |
\usepackage{pnets} |
| 7 |
|
| 8 |
\catcode`\|=\active |
| 9 |
\def|{\verb|} |
| 10 |
|
| 11 |
%% |
| 12 |
%% |
| 13 |
|
| 14 |
\begin{document} |
| 15 |
|
| 16 |
\title{Petri-nets packages} |
| 17 |
\author{Franck Pommereau ([email protected])} |
| 18 |
\date{Last update: \pnversion} |
| 19 |
\maketitle |
| 20 |
|
| 21 |
\begin{abstract}\noindent |
| 22 |
This paper describes Petri-nets, a set of \TeX/\LaTeX{} packages about |
| 23 |
Petri nets and related models. One package allows to draw Petri-nets |
| 24 |
in PostScript or PDF documents. One other defines macros related to |
| 25 |
PBC, M-nets and \bpn{} models. A last package just gathers together |
| 26 |
the two previous. |
| 27 |
\end{abstract} |
| 28 |
|
| 29 |
\begin{small} |
| 30 |
\tableofcontents |
| 31 |
\end{small} |
| 32 |
|
| 33 |
%% |
| 34 |
%% |
| 35 |
|
| 36 |
\section{Introduction} |
| 37 |
|
| 38 |
Petri-nets is a set of packages which I use to write my papers about |
| 39 |
Petri nets and related models (essentially: PBC, M-nets and \bpn). It |
| 40 |
features three packages: one for drawing net, one other which defines |
| 41 |
additional macros for textual purpose (like the name ``\bpn'') and a |
| 42 |
last one for both purposes. The first package has been designed with a |
| 43 |
precise goal: saving me a lot of work when I have to draw nets. This |
| 44 |
goal explains some choices I did: typesetting labels in math mode by |
| 45 |
default, ending commands with the line, etc. I feel this results in an |
| 46 |
intuitive and high-level way to define Petri nets, but if you have |
| 47 |
ideas to improve this, don't hesitate to contact me. The text command |
| 48 |
package is more classical and if it saves also a lot of typing, its |
| 49 |
main goal is to ensure uniform notations. |
| 50 |
|
| 51 |
All these packages may evolve and grow up and if you (or I) feel that |
| 52 |
a feature is missing, you can send me an e-mail explaining your needs |
| 53 |
(\TeX{} code is welcome too). Notice that I don't pretend being a |
| 54 |
specialist in Petri nets and I'm only used to work on three or four |
| 55 |
models; so I may ignore particular things in particular models. This |
| 56 |
may explain some missing features. |
| 57 |
|
| 58 |
%% |
| 59 |
%% |
| 60 |
|
| 61 |
\subsection{Installation} |
| 62 |
|
| 63 |
The last version of the package may be downloaded on the web at the |
| 64 |
URL {\it http:/\slash www.univ-paris12.fr\slash lacl\slash |
| 65 |
pommereau\slash petrinets.tar.gz\/}, a copy should be available on |
| 66 |
{\it CTAN\slash macros\slash generic\slash petri-nets}; the |
| 67 |
distribution contains the following files: |
| 68 |
|
| 69 |
\begin{itemize} |
| 70 |
\item |pnets.tex| is the main \TeX{} package; |
| 71 |
\item |pnets.sty| is its \LaTeX{} counterpart; |
| 72 |
\item |pndraw.tex| and |pndraw.sty| are the \TeX{} and \LaTeX{} |
| 73 |
sub-packages for drawing nets; |
| 74 |
\item |pntext.tex| and |pntext.sty| are the \TeX{} and \LaTeX{} |
| 75 |
sub-packages for text commands; |
| 76 |
\item |pnversion.tex| defines macro |\pnversion|; |
| 77 |
\item |pndoc.ps|, |pndoc.pdf| and |pndoc.tex| are the present paper |
| 78 |
and its source; |
| 79 |
\item |COPYING| is the text of the GNU GPL; |
| 80 |
\item |ChangeLog| collects all changes done to Petri-nets; |
| 81 |
\item |README| is a short introduction text; |
| 82 |
\item |pn2pdf| is a Perl script used to produce PDF files with |
| 83 |
pdf\LaTeX. |
| 84 |
\end{itemize} |
| 85 |
|
| 86 |
In order to have Petri-nets working, you need to copy files |pnets.*|, |
| 87 |
|pndraw.*|, |pntext.*| and |pnversion.tex| in a place where \TeX{} |
| 88 |
will be able to find them. This can be somewhere in the default search |
| 89 |
path (see your local \TeX{} documentation) or in a directory included |
| 90 |
in your |TEXINPUT| environment variable. |
| 91 |
|
| 92 |
Packages from Petri-nets have been developed and tested with |
| 93 |
te\TeX-1.0.2 for Linux. \TeX{} packages should work with any \TeX{} |
| 94 |
version greater than or equal to 3 (my version is 3.14159, Web2C |
| 95 |
7.3.7). \LaTeX{} packages have been designed for \LaTeX$2_\varepsilon$ |
| 96 |
so you may experiment troubles with an older version. |
| 97 |
|
| 98 |
In order to typeset symbols for classical sets of numbers (\setN, |
| 99 |
\setR, etc.) Petri-nets uses fonts from AMS. So you must have package |
| 100 |
|amsfonts| installed for \LaTeX{} or fonts |bbm| for \TeX{} (I think |
| 101 |
these conditions are more or less equivalent). |
| 102 |
|
| 103 |
The drawing basis are provided by package PSTricks, my version is |
| 104 |
PST97 but I used only macros described in the manual of version 0.93a |
| 105 |
so I hope it should work with it. |
| 106 |
|
| 107 |
Using PSTricks has an important consequence: actual drawings are done |
| 108 |
in PostScript, so, you may not see them directly from the DVI viewer |
| 109 |
(at least not correctly); additionally, you must use a PostScript |
| 110 |
driver in order to produce your final document (for example, dvips |
| 111 |
works well). Some support to produce PDF documents with pdf{\LaTeX} is |
| 112 |
provided (see section~\ref{sec:pdf}). |
| 113 |
|
| 114 |
PSTricks conflicts with packages |color|, |graphics| and |graphicx|, |
| 115 |
Petri-nets thus inherits this conflict. If you wish to use them |
| 116 |
together, you should first load package |pstcol|, then Petri-nets and |
| 117 |
at last, |color|, |graphics| or |graphicx|. The following is quoted |
| 118 |
from PSTricks' |README|: |
| 119 |
|
| 120 |
\begin{quote} |
| 121 |
To use the standard `|color|' package (which is available both for |
| 122 |
plain \TeX{} and \LaTeX) with PSTricks, you must load the `|pstcol|' |
| 123 |
extra package written by David Carlisle, which interface the two |
| 124 |
packages, loading them in the right order, and overriding some small |
| 125 |
parts of PSTricks to allow it to use the `|color|' package system for |
| 126 |
specifying color. We {\it strongly\/} recommend that you use this way |
| 127 |
today. |
| 128 |
|
| 129 |
\LaTeX{} users must also take care that the `|pstcol|' package is |
| 130 |
required in place of the `|pstricks|' one if the `|graphics|' or |
| 131 |
`|graphicx|' package is also loaded. |
| 132 |
\end{quote} |
| 133 |
|
| 134 |
If you wish to produce PDF files using pdf{\LaTeX}, you also need to |
| 135 |
copy the script |pn2pdf| in a directory from which it can be executed. |
| 136 |
This script requires a working Perl with the packages |Digest::MD5| |
| 137 |
and |Getopt::Long| installed. Moreover, the script calls the following |
| 138 |
programs: |latex|, |dvips| and |epstopdf| which must be installed on |
| 139 |
your system (there should be not problem for the first two). In order |
| 140 |
to include the PDF pictures, the package |graphicx| is used (in this |
| 141 |
case, it does not lead to any conflict since PSTricks is not loaded |
| 142 |
when running pdf\LaTeX). Finally, the package |ifpdf| is used to |
| 143 |
detect whether a document is compiled using \LaTeX{} or pdf\LaTeX. |
| 144 |
This package should be thus installed. |
| 145 |
|
| 146 |
You can test your installation by recompiling the present manual which |
| 147 |
is written in \LaTeX. If it compiles successfully, this means that |
| 148 |
Petri-nets and PSTricks have been found by \TeX. If one file is not |
| 149 |
found, \TeX{} will complain, giving the file name. Then, running dvips |
| 150 |
will ensure that the PostScript headers of PSTricks can be found. You |
| 151 |
may also test the PDF support by producing the PDF version of this |
| 152 |
manual, see section~\ref{sec:pdf} for the way to proceed. |
| 153 |
|
| 154 |
If you successfully use Petri-nets under another configuration, feel |
| 155 |
free to send me an e-mail at {\it [email protected]}. You may |
| 156 |
also send bug reports or comments, they are welcome. Of course, bug |
| 157 |
fixes are welcome too. |
| 158 |
|
| 159 |
%% |
| 160 |
%% |
| 161 |
|
| 162 |
\subsection{Loading the packages} |
| 163 |
|
| 164 |
From \TeX, you can load the package with |\input pnets|, from \LaTeX, |
| 165 |
you should put |\usepackage{pnets}| in the preamble of your document. |
| 166 |
Since you may want to use only the drawing macros, you can use |
| 167 |
|\input pndraw| or from \LaTeX: |\usepackage{pndraw}|. Similarly, in |
| 168 |
order to load only text commands, you can use |\input pntext| or |
| 169 |
|\usepackage{pntext}|. |
| 170 |
|
| 171 |
Both packages define a macro |\pnversion| which gives the date of the |
| 172 |
last update of the package. The date is given as a triple of numbers |
| 173 |
of the form |year-month-day|. |
| 174 |
|
| 175 |
%% |
| 176 |
%% |
| 177 |
|
| 178 |
\subsection{Things to do, known bugs and problems} |
| 179 |
|
| 180 |
In order to draw additional labels at the right position, |pndraw| has |
| 181 |
to perform some time consuming floating point computing. I plane in |
| 182 |
the future to perform this directly in PostScript, in order to speed-up |
| 183 |
\TeX{} compilation stage. |
| 184 |
|
| 185 |
Only transitions are allowed to change their size according to their |
| 186 |
inner label, it may be nice to have this feature for the other |
| 187 |
nodes. But it's may be a little bit difficult or quite ugly for some |
| 188 |
nodes. |
| 189 |
|
| 190 |
I also could add looping arcs. This is useless for Petri nets but it |
| 191 |
would allow one to use the packages for other purposes, like drawing |
| 192 |
automata. |
| 193 |
|
| 194 |
The PDf pictures are clipped to the bounding box of the corresponding |
| 195 |
net. I've seen on the newsgroups that there exists a solution, but it |
| 196 |
was written in German which I can't read. |
| 197 |
|
| 198 |
When one looks at a PDF document using Acrobat Reader, small blur |
| 199 |
points appear at the top-right and bottom-left corners of the Petri |
| 200 |
nets. This comes from two white points added in order to force dvips |
| 201 |
to produce the right bounding box when a net is generated alone in an |
| 202 |
EPS file. So, this is a bug of Acrobat Reader rather than one of |
| 203 |
Petri-nets. |
| 204 |
|
| 205 |
In a late future, I'd like to make the package independent of |
| 206 |
PSTricks, so it would be more portable (but maybe less powerful). |
| 207 |
|
| 208 |
%% |
| 209 |
%% |
| 210 |
|
| 211 |
\subsection{Legal stuff} |
| 212 |
|
| 213 |
Petri-nets is {\copyright} 2002 Franck Pommereau ({\it |
| 214 |
[email protected]\/}). |
| 215 |
|
| 216 |
This program is free software; you can redistribute it and/or modify |
| 217 |
it under the terms of the {\it GNU General Public License\/} as |
| 218 |
published by the Free Software Foundation; either version 2 of the |
| 219 |
License, or any later version (see file |COPYING|). |
| 220 |
|
| 221 |
This program is distributed in the hope that it will be useful, but |
| 222 |
{\it without any warranty\/}; without even the implied warranty of |
| 223 |
{\it merchantability\/} or {\it fitness for a particular purpose}. |
| 224 |
See the {\it GNU General Public License\/} for more details. |
| 225 |
|
| 226 |
You should have received a copy of the {\it GNU General Public |
| 227 |
License\/} along with this program; if not, write to the Free Software |
| 228 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
| 229 |
USA |
| 230 |
|
| 231 |
%% |
| 232 |
%% |
| 233 |
|
| 234 |
\subsection{Contributors} |
| 235 |
|
| 236 |
I am very grateful to all the persons who contributed to my work, in |
| 237 |
particular: |
| 238 |
|
| 239 |
\begin{quote} |
| 240 |
Denis Girou, |
| 241 |
Hanna Klaudel, |
| 242 |
Andr\'e Steenveld. |
| 243 |
\end{quote} |
| 244 |
|
| 245 |
%% |
| 246 |
%% |
| 247 |
|
| 248 |
\section{Text commands: package {\tt pntext}} |
| 249 |
|
| 250 |
This section lists the commands defined in package |pntext|, they are |
| 251 |
all available from \TeX{} as well as from \LaTeX. |
| 252 |
|
| 253 |
\paragraph{Math sets.} |
| 254 |
% |
| 255 |
Command |\mathset{A}| produces symbol \mathset{A} (and of course it |
| 256 |
works for any text). Shortcuts are defined: |\setN| for |\mathset{N}| |
| 257 |
and similarly for |\setZ|, |\setQ|, |\setR| and |\setC|. |
| 258 |
|
| 259 |
\paragraph{Status of places.} |
| 260 |
% |
| 261 |
Commands |\iplace|, |\eplace| and |\xplace| produce respectively |
| 262 |
characters \iplace, \eplace{} and \xplace. Command |\placestatus{n}| |
| 263 |
typesets character \placestatus{n} (in the case you would like a new |
| 264 |
place type). |
| 265 |
|
| 266 |
\paragraph{Operators for communication.} |
| 267 |
% |
| 268 |
Synchronization operator (\sy) is available through command |\sy|, in |
| 269 |
math mode, this command is surrounded by additional white space as |
| 270 |
usual for binary operators. Similar operators are |\rs| for |
| 271 |
restriction and |\tie| for asynchronous links. Scoping is available |
| 272 |
with commands |\lscope| and |\rscope| which produce respectively a |
| 273 |
left and a right double bracket, you may also use |\scope{A}{N}| to |
| 274 |
produce \scope{A}{N}. |
| 275 |
|
| 276 |
If you use |\lscope| (resp. |\rscope|) without the corresponding |
| 277 |
|\rscope| (resp. |\lscope|) in the same equation or array cell, \TeX{} |
| 278 |
will complain about some missing |\right| (resp. |\left|). In order to |
| 279 |
close (resp. open) a scope without drawing the bracket, you may use |
| 280 |
macro |\Rscope| (resp. |\Lscope|). |
| 281 |
|
| 282 |
\paragraph{Choice.} |
| 283 |
% |
| 284 |
Choice operator \choice{} is produced with command |\choice|. In math |
| 285 |
mode, it behaves like any binary operator. |
| 286 |
|
| 287 |
\paragraph{\bpn.} |
| 288 |
% |
| 289 |
The logo of \bpn{} is typeset using command |\bpn|. A \bpn{} keyword |
| 290 |
(say \bpnkw{program}) is typeset with |\bpnkw{program}| and for a |
| 291 |
non-terminal in the syntax (say \bpnnt{scope}) you may use |
| 292 |
|\bpnnt{scope}|. Function \mnet{} is defined as |\mnet|. |
| 293 |
|
| 294 |
\paragraph{Sets of values and variables.} |
| 295 |
% |
| 296 |
\Var{} and \Val{} are typeset using commands |\Var| and |\Val|. They |
| 297 |
are better to use than directly the text they typeset because they |
| 298 |
adjust their spacing in math mode: compare ``$Var$'' with ``$\Var$''. |
| 299 |
|
| 300 |
\paragraph{To be continued\dots} |
| 301 |
|
| 302 |
%% |
| 303 |
%% |
| 304 |
|
| 305 |
\section{Drawing nets: package {\tt pndraw}} |
| 306 |
|
| 307 |
%% |
| 308 |
%% |
| 309 |
|
| 310 |
\subsection{Some words about PSTricks} |
| 311 |
|
| 312 |
Reading PSTricks manual could be a good idea, but if you don't want |
| 313 |
to, you should know a few things about it in order to use Petri-nets |
| 314 |
successfully. |
| 315 |
|
| 316 |
In PSTricks, any point is designated by two coordinates in a grid, |
| 317 |
centered on a reference point which has coordinates $(0,0)$. The |
| 318 |
figure~\ref{axis} shows an example. |
| 319 |
|
| 320 |
\begin{figure}[t] |
| 321 |
\begin{center} |
| 322 |
\begin{petrinet}(-1.5,-1.5)(5.5,3.5) |
| 323 |
\pst\psgrid[subgriddiv=1,griddots=10](-1,-1)(5,3) |
| 324 |
\pst\psline{->}(0,-1.5)(0,3.5) |
| 325 |
\pst\psline{->}(-1.5,0)(5.5,0) |
| 326 |
\pst\psdot(4,2) |
| 327 |
\pst\rput[br](4,2){$(4,2)$} |
| 328 |
\pst\psdot(0,0) |
| 329 |
\pst\rput[br](0,0){$(0,0)$} |
| 330 |
\pst\psdot(2.5,-.5) |
| 331 |
\pst\rput[l](2.5,-.5){$\,(2.5,-.5)$} |
| 332 |
\end{petrinet} |
| 333 |
\end{center} |
| 334 |
\caption{The Cartesian coordinate system.} |
| 335 |
\label{axis} |
| 336 |
\end{figure} |
| 337 |
|
| 338 |
The distance from the origin $(0,0)$ to a point $(x,y)$ depends on |
| 339 |
three parameters. |units| is a global scale, if |unit=1.2cm|, $(4,2)$ |
| 340 |
becomes an abbreviation for $(4 \times 1.2\hbox{ cm}, 2 \times |
| 341 |
1.2\hbox{ cm})$. There's also |xunit| and |yunit| which act |
| 342 |
respectively only on horizontal or vertical scale; for example, if |
| 343 |
|xunit=20pt| and |yunit=1in|, $(4,2)$ stands for $(4 \times 20\hbox{ |
| 344 |
pt}, 2 \times 1\hbox{ in})$. As you can see on these short examples, |
| 345 |
|unit|, |xunit| and |yunit| can be affected any value which is a valid |
| 346 |
\TeX{} |dimen| (or \LaTeX{} length). |
| 347 |
|
| 348 |
The default value for all these three parameters is 1~cm; to change |
| 349 |
it, you can use the |\psset| command as in |\psset{unit=.5cm}| or in a |
| 350 |
combined way as in |\psset{xunit=1cm,yunit=2cm}|. |
| 351 |
|
| 352 |
Since coordinates are formed as a comma separated couple of numbers, |
| 353 |
you {\it must not\/} use comma as decimal separator here: |(4.5,2.3)| |
| 354 |
is correct but |(4,5,2,3)| is not. |
| 355 |
|
| 356 |
Sometime you'll be asked to give an angle value as a macro parameter. |
| 357 |
In Petri-nets, angles are measured in degrees; they can be given as a |
| 358 |
numerical value or with a one/two letter(s) code as shown in the |
| 359 |
figure~\ref{angles}. Of course, when you specify an angle by its |
| 360 |
numerical value, you can use any number, even negative, and not only |
| 361 |
one of the eight values shown on figure~\ref{angles}. |
| 362 |
|
| 363 |
\begin{figure}[t] |
| 364 |
\begin{center} |
| 365 |
\begin{petrinet}[unit=2cm](-2,-1.3)(2,1.3) |
| 366 |
\pst\pscircle(0,0){1}% |
| 367 |
{\count0=0 % |
| 368 |
\loop % |
| 369 |
\ifnum\count0<360 % |
| 370 |
\uput{.95}[\the\count0]{\the\count0}(0,0){\bf--}% |
| 371 |
\advance\count0 by 45 % |
| 372 |
\repeat} |
| 373 |
\pst\uput{1.1}[0](0,0){$0=r$} |
| 374 |
\pst\uput{1.1}[45](0,0){$45=tr/rt$} |
| 375 |
\pst\uput{1.1}[90](0,0){$90=t$} |
| 376 |
\pst\uput{1.1}[135](0,0){$135=tl/lt$} |
| 377 |
\pst\uput{1.1}[180](0,0){$180=l$} |
| 378 |
\pst\uput{1.1}[225](0,0){$225=bl/lb$} |
| 379 |
\pst\uput{1.1}[270](0,0){$270=b$} |
| 380 |
\pst\uput{1.1}[315](0,0){$315=br/rb$} |
| 381 |
\end{petrinet} |
| 382 |
\caption{Translation from angle values to letter code. $r$ is for {\it |
| 383 |
right}, $t$ for {\it top}, $l$ for {\it left\/} and $b$ for {\it |
| 384 |
bottom}.} |
| 385 |
\label{angles} |
| 386 |
\end{center} |
| 387 |
\end{figure} |
| 388 |
|
| 389 |
The macro |\psset| is used to change PSTricks default parameters, it |
| 390 |
takes one argument which is a comma-separated list of |name=value| |
| 391 |
pairs. For example, |pndraw.tex| itself uses: |
| 392 |
% |
| 393 |
\begin{verbatim} |
| 394 |
\psset{linewidth=.5pt, |
| 395 |
doublesep=.5pt, |
| 396 |
labelsep=2pt} |
| 397 |
\end{verbatim} |
| 398 |
|
| 399 |
As you can see, blank spaces before a |name| are ignored. You already |
| 400 |
know how to change units, some additional |name|s should be useful for |
| 401 |
Petri-nets: |
| 402 |
|
| 403 |
\begin{itemize} |
| 404 |
\item |linewidth| is the default width for {\it any\/} line drawn by |
| 405 |
PSTricks; |
| 406 |
\item |doubleline| can be |true| or |false|, when set to |true|, any |
| 407 |
line drawn is doubled; |
| 408 |
\item |doublesep| is the distance between the two lines of a doubled |
| 409 |
line; |
| 410 |
\item |labelsep| is the distance between an arc and its label(s); |
| 411 |
\item |linecolor| is the color used to draw lines, it can be, for |
| 412 |
example, |black|, |darkgray|, |gray|, |lightgray|, |white|, |
| 413 |
|red|, |blue|, |green|, |cyan|, |magenta| or |yellow|; |
| 414 |
\item |fillcolor| is the color used to fill shapes; you can use for it |
| 415 |
the same colors as for |linecolor|. |
| 416 |
\end{itemize} |
| 417 |
|
| 418 |
PSTricks recognizes many other parameters and you should refer to its |
| 419 |
manual for all the details. |
| 420 |
|
| 421 |
%% |
| 422 |
%% |
| 423 |
|
| 424 |
\subsection{Beginning and ending nets} |
| 425 |
|
| 426 |
To begin a net, just type |\beginnet| for \TeX{} or |\begin{petrinet}| |
| 427 |
under \LaTeX; both this commands are expecting two pairs of |
| 428 |
coordinates to give the bottom-left and up-right extrema of the net. |
| 429 |
|
| 430 |
For example, |\begin{petrinet}(-1,-2)(5,3)| starts a net which should |
| 431 |
extend in the rectangular area, which we call the {\it bounding box}, |
| 432 |
delimited by $(-1,-2)$ at the lower left corner and $(5,3)$ at the |
| 433 |
upper right. These coordinates are sensitive to current values of |
| 434 |
|unit|, |xunit| and |yunit|. |
| 435 |
|
| 436 |
The real effect of these two pairs is to fix the size of the bounding |
| 437 |
box which carry the net drawn (it is actually a |\hbox| set in |
| 438 |
horizontal mode but who cares?). If some parts of the net extends |
| 439 |
outside of the declared bounding box, it will be drawn outside and |
| 440 |
that's all. In other words, the bounding box announced just reserves |
| 441 |
room for the net and the drawing itself is invisible to \TeX. This |
| 442 |
allows you to lies about the real dimension of your drawings: you can |
| 443 |
declare a bigger or a smaller bounding box, if you want more or less |
| 444 |
white space around your nets. This behaviour is different when running |
| 445 |
pdf\LaTeX, see the section~\ref{sec:pdf} for details. |
| 446 |
|
| 447 |
Before to give the coordinates of the bounding box for a net, you can |
| 448 |
give optional parameters inside square brackets. These parameters are |
| 449 |
interpreted as PSTricks options which are applied to the following net |
| 450 |
and stay local to it. For example, if we have |unit=1cm| before |
| 451 |
starting a net, command |\begin{petrinet}[unit=2cm](0,0)(1,1)| starts |
| 452 |
a net with |unit=2cm| for its bounding box and any coordinate given |
| 453 |
inside the net. But as the net ends, the previous value of |unit| is |
| 454 |
restored. |
| 455 |
|
| 456 |
In order to have bounding boxes drawn in your nets: you may use |
| 457 |
command |\showbb|, optionally followed by bracketed options. For the |
| 458 |
figure~\ref{fig:nodes example}, I added |\showbb| at the beginning of |
| 459 |
the net. The starred version of |\showbb| fills the background and so, |
| 460 |
command |\showbb*[fillcolor=red]| draws a filled red rectangle over |
| 461 |
the bounding box. |
| 462 |
|
| 463 |
To end the drawing, you should use |\endnet| or |\end{petrinet}| (did |
| 464 |
you guess?). All macros between these two ones are interpreted as |
| 465 |
PSTricks or Petri-nets commands. In the following, we call a {\it |
| 466 |
net\/} all the stuff inclosed between |\begin{petrinet}| and |
| 467 |
|\end{petrinet}| (if you use \LaTeX). One point has to be remembered: |
| 468 |
inside a net, the end of line has a special meaning because it is used |
| 469 |
to end most Petri-nets drawing commands. So if you want to use |
| 470 |
commands spread over several lines, you have to end every line but the |
| 471 |
last with a comment (|%|). Also notice that if you call the |\psset| |
| 472 |
command inside a net, its effect will remain local to this particular |
| 473 |
net. |
| 474 |
|
| 475 |
If you wish something to be done every time a net begins, you may set |
| 476 |
token list |\everynet| to what you want to be inserted between command |
| 477 |
|\begin{petrinet}| and your drawing commands. For example, with |
| 478 |
|\everynet={\small}|, all the following nets will be set in small |
| 479 |
types. |
| 480 |
|
| 481 |
Except for beginning and ending nets, all the macros are the same |
| 482 |
under \TeX{} or \LaTeX. |
| 483 |
|
| 484 |
%% |
| 485 |
%% |
| 486 |
|
| 487 |
\subsection{Drawing nodes} |
| 488 |
|
| 489 |
The available node shapes are places, transitions, modules, sources |
| 490 |
and stores, which are drawn in figure~\ref{fig:nodes}. They are |
| 491 |
produced with the macros |\place|, |\trans|, |\module|, |\source| and |
| 492 |
|\store| respectively. Their size is controlled with the dimensions |
| 493 |
|\placesize|, |\transsize|, |\modulesize|, |\sourcesize| and |
| 494 |
|\storesize| respectively. For instance, |\transsize=8mm| sets the |
| 495 |
size of transitions to |8mm|; |\nodessize{5mm}| sets the size of {\it |
| 496 |
all\/} the nodes to |5mm|. |
| 497 |
|
| 498 |
\begin{figure} |
| 499 |
\begin{center} |
| 500 |
\begin{petrinet}[xunit=2cm](-.5,-.5)(4.5,1) |
| 501 |
\place{place}(0,0) p |
| 502 |
\label"{t}place\strut |
| 503 |
\trans{trans}(1,0) t |
| 504 |
\label"{t}transition\strut |
| 505 |
\module{module}(2,0) m |
| 506 |
\label"{t}module\strut |
| 507 |
\source{source}(3,0) s |
| 508 |
\label"{t}source\strut |
| 509 |
\store{store}(4,0) labels are ignored for stores |
| 510 |
\label"{t}store\strut |
| 511 |
\end{petrinet} |
| 512 |
\end{center} |
| 513 |
\caption{The nodes available in Petri-nets.} |
| 514 |
\label{fig:nodes} |
| 515 |
\end{figure} |
| 516 |
|
| 517 |
Creating a node is possible using the command |
| 518 |
``node\{name\}$(x,y)$label'' where: |
| 519 |
% |
| 520 |
\begin{itemize} |
| 521 |
\item ``node'' is one of the above node commands; |
| 522 |
\item ``name'' is the name of this node which should be unique for a |
| 523 |
given net (if not, the new node overwrites the old one). This |
| 524 |
name is case sensitive and should not contain any special |
| 525 |
characters (as |$|, |\|, etc.); %$ |
| 526 |
\item ``$(x,y)$'' are the coordinates of the node's center; |
| 527 |
\item ``label'' is the text to typeset inside the node, it |
| 528 |
extends until the end of the line. This label is silently |
| 529 |
discarded for stores. |
| 530 |
\end{itemize} |
| 531 |
|
| 532 |
For instance, the nodes in figure~\ref{fig:nodes} where drawn with the |
| 533 |
commands: |
| 534 |
% |
| 535 |
\begin{verbatim} |
| 536 |
\place{place}(0,0) p |
| 537 |
\trans{trans}(1,0) t |
| 538 |
\module{module}(2,0) m |
| 539 |
\source{source}(3,0) s |
| 540 |
\store{store}(4,0) labels are ignored for stores |
| 541 |
\end{verbatim} |
| 542 |
|
| 543 |
By default, labels are typeset in math mode, if you wish a label |
| 544 |
typeset in text mode, add option |"| after the node command. Notice |
| 545 |
that any space after the coordinates of the node is part of the label, |
| 546 |
it has no importance in math mode but in text mode it leads to a label |
| 547 |
which starts with a white space. Option |=| sets double-line mode and |
| 548 |
so the node is drawn with doubled lines. Option |!| sets the line |
| 549 |
width to 2pt so the node appears thicker than usually. PSTricks |
| 550 |
options may be given between square brackets, for instance adding |
| 551 |
|[linecolor=red,linewidth=1pt]| leads to a red node with 1pt lines. |
| 552 |
|
| 553 |
For transitions, an additional option |*| may be used in order to have |
| 554 |
the boundaries of the transition adjusted to the label typeset inside. |
| 555 |
By default, the size of a node is fixed and the label overlaps outside |
| 556 |
if too long, for transitions with option |*|, the size is just fine. |
| 557 |
|
| 558 |
\subsubsection{Additional labels} |
| 559 |
|
| 560 |
You can give additional outer labels to a node. Each label is typeset |
| 561 |
using the macro% |
| 562 |
% |
| 563 |
\footnote{For \LaTeX, this means that the well known cross-referencing |
| 564 |
macro {\tt\string\label} is not available inside a {\tt petrinet} |
| 565 |
environment. But outside, it works as usual.} |
| 566 |
% |
| 567 |
|\label| which has two arguments: the first is an angle indication and |
| 568 |
the second, which extends until the end of the line, is the text to |
| 569 |
typeset. The angle indication is a numeric value or a code as |
| 570 |
explained earlier. Option |"| explained above is also available for |
| 571 |
additional labels (and should be given just after |\label|). |
| 572 |
|
| 573 |
Before I give an example, let me explain a useful parameter for |
| 574 |
typesetting label: the token list |\everylabel| is expanded before any |
| 575 |
label is typeset. For example, command |\everylabel={\scriptstyle}| |
| 576 |
leads to typeset all the following labels in script style. This works |
| 577 |
for really any label, not only for nodes labels. If |\everylabel| is |
| 578 |
set inside a net, its effect will remain local to this net. |
| 579 |
|
| 580 |
The figure~\ref{fig:nodes example} has been typeset using the |
| 581 |
following commands: |
| 582 |
% |
| 583 |
\begin{verbatim} |
| 584 |
\begin{petrinet}[xunit=2cm](-.5,-.5)(2.5,.5) |
| 585 |
\showbb |
| 586 |
\place{p1}(0,0) \bullet |
| 587 |
\trans*="{t}(1,0)~transition~ |
| 588 |
\label"{70}more text |
| 589 |
\place!{p2}(2,0) |
| 590 |
\label{r} \left\{ % I can type multi-line |
| 591 |
{\textstyle 1, 2, 3 \atop % labels, thanks to comments. |
| 592 |
\textstyle 4, 5, 6} \right\} |
| 593 |
\end{petrinet} |
| 594 |
\end{verbatim} |
| 595 |
|
| 596 |
\begin{figure} |
| 597 |
\begin{center} |
| 598 |
\begin{petrinet}[xunit=2cm](-.5,-.5)(2.5,.5) |
| 599 |
\showbb |
| 600 |
\place{p1}(0,0) \bullet |
| 601 |
\trans*="{t}(1,0)~transition~ |
| 602 |
\label"{70}more text |
| 603 |
\place!{p2}(2,0) |
| 604 |
\label{r} \left\{ % I can type multi-line |
| 605 |
{\textstyle 1, 2, 3 \atop % labels, thanks to comments. |
| 606 |
\textstyle 4, 5, 6} \right\} |
| 607 |
\end{petrinet} |
| 608 |
\caption{Example of nodes. In the PDF, nets is clipped to its bounding |
| 609 |
box, see section~\ref{sec:pdf}. } |
| 610 |
\label{fig:nodes example} |
| 611 |
\end{center} |
| 612 |
\end{figure} |
| 613 |
|
| 614 |
You may notice that the net is not well centered, it extends more on |
| 615 |
the right. This is because I declared a bounding box of $(-.5,-.5)$ to |
| 616 |
$(2.5,.5)$ while in fact, the label of the right-most place extends on |
| 617 |
the right, outside of the bounding box (which is made visible by the |
| 618 |
macro |\showbb|). |
| 619 |
|
| 620 |
%% |
| 621 |
%% |
| 622 |
|
| 623 |
\subsubsection{Free text} |
| 624 |
|
| 625 |
Another kind of node is unboxed text. The macro |\text| is similar to |
| 626 |
|\trans*| but without border. Like for other nodes, the text is |
| 627 |
typeset in math mode and it can be added outer labels with the macro |
| 628 |
|\label|. |
| 629 |
|
| 630 |
This macro knows only the option |"| which has the usual meaning. |
| 631 |
|
| 632 |
%% |
| 633 |
%% |
| 634 |
|
| 635 |
\subsection{Linking nodes} |
| 636 |
|
| 637 |
You can draw links between two arbitrary nodes. The package won't |
| 638 |
check if requested links are valid from Petri nets point of view, so |
| 639 |
you can draw an arc between two places for instance. Basically, macro |
| 640 |
|\link| has three parameters: the name of the starting node, that of |
| 641 |
the ending node, and the text to typeset on the link (which extends |
| 642 |
until the end of the line). You can add optional parameters, before |
| 643 |
the first node name: |
| 644 |
% |
| 645 |
\begin{itemize} |
| 646 |
\item options inside square brackets are PSTricks options, as usual; |
| 647 |
\item a real number, between 0 and 1, enclosed in angle brackets ({\it |
| 648 |
e.g.}, |<.3>|) can be used to specify the position of the label, |
| 649 |
between starting and ending nodes. Value 0 stands for ``on |
| 650 |
the starting node'' while 1 means ``on the ending node''; the |
| 651 |
default value is $.5$ ({\it i.e.}, on the middle of the link); |
| 652 |
\item the characters |^|, |_| or |*| may be used to specify the side of |
| 653 |
the link where the label is typeset. For an link which extends |
| 654 |
from the left to the right, |^| means ``above'', |_| means |
| 655 |
``below'' and |*| means ``over''. If nothing is specified, the |
| 656 |
label is placed above the link; |
| 657 |
\item the options |"|, |=| and |!| have their usual meanings; |
| 658 |
\item arrowheads and such can be specified between two signs |/|. |
| 659 |
The available values are shown in the figure~\ref{fig:arrows}, |
| 660 |
default is no arrow. |
| 661 |
\end{itemize} |
| 662 |
|
| 663 |
\begin{figure} |
| 664 |
\begin{center} |
| 665 |
\catcode`\|=12 |
| 666 |
\begin{petrinet}[yunit=6mm](-.6,-.3)(8,15.3) |
| 667 |
\pst\catcode`\|=12 |
| 668 |
\text{caption}(3,15)\rlap{none (default)} |
| 669 |
\text"{t}(0,15){\tt -} |
| 670 |
\text{l}(1,15) |
| 671 |
\text{r}(2,15) |
| 672 |
\link/-/{l}{r} |
| 673 |
\text{caption}(3,14)\rlap{arrowheads} |
| 674 |
\text"{t}(0,14){\tt <->} |
| 675 |
\text{l}(1,14) |
| 676 |
\text{r}(2,14) |
| 677 |
\link/<->/{l}{r} |
| 678 |
\text{caption}(3,13)\rlap{reverse arrowheads} |
| 679 |
\text"{t}(0,13){\tt >-<} |
| 680 |
\text{l}(1,13) |
| 681 |
\text{r}(2,13) |
| 682 |
\link/>-</{l}{r} |
| 683 |
\text{caption}(3,12)\rlap{double arrowheads} |
| 684 |
\text"{t}(0,12){\tt <{}<->{}>} |
| 685 |
\text{l}(1,12) |
| 686 |
\text{r}(2,12) |
| 687 |
\link/<<->>/{l}{r} |
| 688 |
\text{caption}(3,11)\rlap{reverse double arrowheads} |
| 689 |
\text"{t}(0,11){\tt >{}>-<{}<} |
| 690 |
\text{l}(1,11) |
| 691 |
\text{r}(2,11) |
| 692 |
\link/>>-<</{l}{r} |
| 693 |
\text{caption}(3,10)\rlap{T-bar flush to endpoints} |
| 694 |
\text"{t}(0,10){\tt |-|} |
| 695 |
\text{l}(1,10) |
| 696 |
\text{r}(2,10) |
| 697 |
\link/|-|/{l}{r} |
| 698 |
\text{caption}(3,9)\rlap{T-bar centred on endpoints} |
| 699 |
\text"{t}(0,9){\tt |*-|*} |
| 700 |
\text{l}(1,9) |
| 701 |
\text{r}(2,9) |
| 702 |
\link/|*-|*/{l}{r} |
| 703 |
\text{caption}(3,8)\rlap{square brackets} |
| 704 |
\text"{t}(0,8){\tt [-]} |
| 705 |
\text{l}(1,8) |
| 706 |
\text{r}(2,8) |
| 707 |
\link/[-]/{l}{r} |
| 708 |
\text{caption}(3,7)\rlap{rounded brackets} |
| 709 |
\text"{t}(0,7){\tt (-)} |
| 710 |
\text{l}(1,7) |
| 711 |
\text{r}(2,7) |
| 712 |
\link/(-)/{l}{r} |
| 713 |
\text{caption}(3,6)\rlap{circles centred on endpoints} |
| 714 |
\text"{t}(0,6){\tt o-o} |
| 715 |
\text{l}(1,6) |
| 716 |
\text{r}(2,6) |
| 717 |
\link/o-o/{l}{r} |
| 718 |
\text{caption}(3,5)\rlap{circles flush to endpoints} |
| 719 |
\text"{t}(0,5){\tt oo-oo} |
| 720 |
\text{l}(1,5) |
| 721 |
\text{r}(2,5) |
| 722 |
\link/oo-oo/{l}{r} |
| 723 |
\text{caption}(3,4)\rlap{disks centred on endpoints} |
| 724 |
\text"{t}(0,4){\tt *-*} |
| 725 |
\text{l}(1,4) |
| 726 |
\text{r}(2,4) |
| 727 |
\link/*-*/{l}{r} |
| 728 |
\text{caption}(3,3)\rlap{disks flush to endpoints} |
| 729 |
\text"{t}(0,3){\tt **-**} |
| 730 |
\text{l}(1,3) |
| 731 |
\text{r}(2,3) |
| 732 |
\link/**-**/{l}{r} |
| 733 |
\text{caption}(3,2)\rlap{extended rounded ends} |
| 734 |
\text"{t}(0,2){\tt c-c} |
| 735 |
\text{l}(1,2) |
| 736 |
\text{r}(2,2) |
| 737 |
\link/c-c/{l}{r} |
| 738 |
\text{caption}(3,1)\rlap{flush rounded ends} |
| 739 |
\text"{t}(0,1){\tt cc-cc} |
| 740 |
\text{l}(1,1) |
| 741 |
\text{r}(2,1) |
| 742 |
\link/cc-cc/{l}{r} |
| 743 |
\text{caption}(3,0)\rlap{extended square ends} |
| 744 |
\text"{t}(0,0){\tt C-C} |
| 745 |
\text{l}(1,0) |
| 746 |
\text{r}(2,0) |
| 747 |
\link/C-C/{l}{r} |
| 748 |
\end{petrinet} |
| 749 |
\end{center} |
| 750 |
\caption{The different types of links termination. They can be freely |
| 751 |
mixed.} |
| 752 |
\label{fig:arrows} |
| 753 |
\end{figure} |
| 754 |
|
| 755 |
The order in which you use these options has no importance, provided |
| 756 |
that all options are given before the starting node. Additionally, if |
| 757 |
you use contradicting options, only the last used is taken into |
| 758 |
account. For instance, the two following lines are equivalent: |
| 759 |
|
| 760 |
|\link_[linecolor=gray,linewidth=5pt]*<.2>^[linewidth=1pt]| |
| 761 |
|
| 762 |
|\link^<.2>[linecolor=gray,linewidth=1pt]|. |
| 763 |
|
| 764 |
To draw curved links, you should use PSTricks' |arcangle| option which |
| 765 |
is an angle in degrees (you cannot use a letter code here), measuring |
| 766 |
the deviation from a straight line between nodes, at the starting and |
| 767 |
at the ending of the link. Try, it's easy. |
| 768 |
|
| 769 |
To change the appearance of the arrowhead, you must change PSTricks' |
| 770 |
parameters |arrowsize|, |arrowlength| and |arrowinset|. Petri-nets |
| 771 |
uses the following: |
| 772 |
% |
| 773 |
\begin{verbatim} |
| 774 |
\psset{arrowlength=1.4, |
| 775 |
arrowinset=0, |
| 776 |
arrowsize=2pt 2} |
| 777 |
\end{verbatim} |
| 778 |
% |
| 779 |
I wont explain how it works, just try, it's easy too. (Or read the |
| 780 |
manual of PSTricks where all the details are given.) |
| 781 |
|
| 782 |
%% |
| 783 |
%% |
| 784 |
|
| 785 |
\subsubsection{Additional labels} |
| 786 |
|
| 787 |
Like for nodes, links can be added more labels. This is also made with |
| 788 |
the macro |\label|, but here, its syntax is like for the macro |
| 789 |
|\link|, except that you must not specify the starting and ending |
| 790 |
nodes (but the options of |\link| are available). |
| 791 |
|
| 792 |
%% |
| 793 |
%% |
| 794 |
|
| 795 |
\subsubsection{Arcs} |
| 796 |
|
| 797 |
Since links are almost always draw with a single arrowhead at the end |
| 798 |
(and then called {\it arcs\/}), a shortcut is provided: the macro |
| 799 |
|\arc| may be used instead of |\link/->/|. |
| 800 |
|
| 801 |
%% |
| 802 |
%% |
| 803 |
|
| 804 |
\section{Tips, tricks and troubleshooting} |
| 805 |
|
| 806 |
\paragraph{Nets as macro arguments.} |
| 807 |
% |
| 808 |
If you try to define a net inside the argument of a macro, you will |
| 809 |
have an error. For instance, the code |
| 810 |
% |
| 811 |
\begin{verbatim} |
| 812 |
\centerline{\begin{petrinet}(0,0)(1,1) |
| 813 |
\place{p}(0,0) p |
| 814 |
\trans{t}(1,1) t |
| 815 |
\arc{p}{t} |
| 816 |
\arc{t}{p} |
| 817 |
\end{petrinet}} |
| 818 |
\end{verbatim} |
| 819 |
% |
| 820 |
produces an error such as: |
| 821 |
% |
| 822 |
\begin{verbatim} |
| 823 |
! Argument of \net:place:draw has an extra }. |
| 824 |
<inserted text> |
| 825 |
\par |
| 826 |
l.11 \end{petrinet}} |
| 827 |
\end{verbatim} |
| 828 |
|
| 829 |
The reason is that the macro |\centerline| reads all the net and treat |
| 830 |
the end of lines as spaces. Similar things occur with the other |
| 831 |
characters which are considered in a special way inside nets. The |
| 832 |
right way to produce the desired effect is to use the macro |
| 833 |
|\savenet|: |
| 834 |
% |
| 835 |
\begin{verbatim} |
| 836 |
\savenet |
| 837 |
\begin{petrinet}(0,0)(1,1) |
| 838 |
\place{p}(0,0) p |
| 839 |
\trans{t}(1,1) t |
| 840 |
\arc{p}{t} |
| 841 |
\arc{t}{p} |
| 842 |
\end{petrinet} |
| 843 |
\centerline{\shownet} |
| 844 |
\end{verbatim} |
| 845 |
% |
| 846 |
the form |\savenet\begin{petrinet}| works as well and from plain |
| 847 |
{\TeX} you should use the form |\savenet\beginnet|. After one |
| 848 |
|\savenet| you may even use |\shownet| several times in order to |
| 849 |
duplicate the saved net. |
| 850 |
|
| 851 |
\paragraph{Error messages.} |
| 852 |
% |
| 853 |
Sometimes, you'll get an error message such as: |
| 854 |
|
| 855 |
\begin{verbatim} |
| 856 |
! Argument of \net:place:draw has an extra }. |
| 857 |
<inserted text> |
| 858 |
\par |
| 859 |
l.785 \place{i3}(2,0) i_3 |
| 860 |
|
| 861 |
? |
| 862 |
\end{verbatim} |
| 863 |
|
| 864 |
This usually means that the error was just before the line for which |
| 865 |
\TeX{} complains (here line 785 which is correct). And usually, this |
| 866 |
error is an omission of one of the arguments of a drawing macro. |
| 867 |
|
| 868 |
Another kind of message occurs quite often: |
| 869 |
|
| 870 |
\begin{verbatim} |
| 871 |
PSTricks error. See User's Guide for further information. |
| 872 |
Type H <return> for immediate help. |
| 873 |
! Graphics parameter `rcangle' not defined.. |
| 874 |
\@pstrickserr ... immediate help.}\errmessage {#1} |
| 875 |
\endgroup |
| 876 |
l.794 \arc[rcangle=30] |
| 877 |
{ab2}{i3} \bullet |
| 878 |
? |
| 879 |
\end{verbatim} |
| 880 |
|
| 881 |
This is because on line 794, you misspelled the word ``arcangle'', |
| 882 |
giving ``rcangle'' instead. This error is detected by PSTricks since |
| 883 |
bracketed arguments are sent verbatim to it. |
| 884 |
|
| 885 |
In general, since the package |pndraw| uses a lot of tricks in order |
| 886 |
to read the arguments of the commands, you should not trust too much |
| 887 |
the error messages: just look at the line indicated in the message and |
| 888 |
seek for a mistake in it or in the lines before. (Actually, this |
| 889 |
advice can be used for almost any error message issued by \LaTeX\dots) |
| 890 |
|
| 891 |
\paragraph{Drawing commands on multiple lines.} |
| 892 |
% |
| 893 |
Inside a net, label arguments are delimited by the end of the line. To |
| 894 |
type an argument which extends on more than one line, you should end |
| 895 |
each line but the last with a comment~|%|. |
| 896 |
|
| 897 |
\paragraph{Empty node.} |
| 898 |
% |
| 899 |
If you want to draw ``floating'' arcs, {\it i.e.}, arcs wich are not |
| 900 |
attached to a place or a transition, you just can anchor them on empty |
| 901 |
texts: the following net is depicted in the figure~\ref{empty text}. |
| 902 |
|
| 903 |
\begin{verbatim} |
| 904 |
\begin{petrinet}(0,0)(2,0) |
| 905 |
\text{from}(0,0) |
| 906 |
\text{to}(2,0) |
| 907 |
\arc{from}{to} |
| 908 |
\end{petrinet} |
| 909 |
\end{verbatim} |
| 910 |
|
| 911 |
\begin{figure}[t] |
| 912 |
\begin{center} |
| 913 |
\begin{petrinet}(-.2,-.2)(2.2,.2) |
| 914 |
\text{from}(0,0) |
| 915 |
\text{to}(2,0) |
| 916 |
\arc{from}{to} |
| 917 |
\end{petrinet} |
| 918 |
\end{center} |
| 919 |
\caption{An arc anchored on empty texts} |
| 920 |
\label{empty text} |
| 921 |
\end{figure} |
| 922 |
|
| 923 |
\paragraph{Text mode labels.} |
| 924 |
% |
| 925 |
Take care of the interaction between |\everylabel| and the option |"| |
| 926 |
which typesets a label in text mode. For example, setting |
| 927 |
|\everylabel{\scriptstyle}| leads to an error every time a text mode |
| 928 |
label is typeset because |\scriptstyle| is a math command. So you |
| 929 |
should prefer the longer but safer form: |\everylabel{\ifmmode|\hskip |
| 930 |
0pt|\scriptstyle|\hskip 0pt|\else|\hskip 0pt|\scriptsize|\hskip |
| 931 |
0pt|\fi}|. |
| 932 |
|
| 933 |
\paragraph{Labels at the wrong position.} |
| 934 |
% |
| 935 |
If the additional labels of a node appear centered on it instead of |
| 936 |
outside, this may come from the way you visualize your document. DVI |
| 937 |
viewers usually do not interpret correctly all of the PostScript |
| 938 |
commands used by PSTricks. Trying a PostScript viewer (GhostView is |
| 939 |
certainly a good choice) may solve your problem. |
| 940 |
|
| 941 |
\paragraph{To be continued\dots} |
| 942 |
|
| 943 |
%% |
| 944 |
%% |
| 945 |
|
| 946 |
\section{Producing PDF documents} |
| 947 |
\label{sec:pdf} |
| 948 |
|
| 949 |
The {\LaTeX} version of |pndraw| provides some support for pdf{\LaTeX} |
| 950 |
through the Perl script |pn2pdf| included in the archive. The usage is |
| 951 |
quite automated, even completely if you run |pdflatex| with the option |
| 952 |
|--shell|. If you don't want to enable this option, run first |
| 953 |
|pdflatex|, then run |pn2pdf| |-b| |document| (assuming your file is |
| 954 |
called |document.tex|) and finally run |pdflatex| again.\footnote{This |
| 955 |
process was different in the previous version of the package!} Using |
| 956 |
the option |--shell| simply allows |pdflatex| to run |pn2pdf| for you. |
| 957 |
|
| 958 |
Several files are produced by these different runs. You may never see |
| 959 |
most of them since they are deleted when the become useless. {\it Take |
| 960 |
care that none of your files uses one of these names otherwise it will |
| 961 |
be overwrote or deleted!} |
| 962 |
% |
| 963 |
\begin{itemize} |
| 964 |
\item |document.sum| is used to remember some information in order |
| 965 |
to avoid recreating pictures if not necessary. |
| 966 |
\item |document.|$d$ is created and deleted for test purpose when the |
| 967 |
option |--shell| has been used, $d$ is the date when |pdflatex| |
| 968 |
was started, as produced by the macros |
| 969 |
|\the\year\the\month\the\day\the\time| (in the current document, |
| 970 |
it leads to \the\year\the\month\the\day\the\time). |
| 971 |
\item |document.bpn| is created when |pdflatex| is run without the |
| 972 |
option |--shell|, it contains the directives for producing the |
| 973 |
figures with |pn2pdf -b|. |
| 974 |
\item |document.pre| is used by |pn2pdf| in order to remember the |
| 975 |
commands (like |\psset|) issued outside of |petrinets| |
| 976 |
environments. |
| 977 |
\item |document-fig|$n$|.pn|, |document-fig|$n$|.tex|, |
| 978 |
|document-fig|$n$|.aux|,\\ |document-fig|$n$|.dvi|, |
| 979 |
|document-fig|$n$|.log|, |document-fig|$n$|.eps| are created |
| 980 |
during the generation of |document-fig|$n$|.pdf| which contains |
| 981 |
the rendering of the $n$th net of the document. |
| 982 |
\end{itemize} |
| 983 |
% |
| 984 |
The files |document-fig|$n$|.pdf| should not be deleted before the |
| 985 |
final document is produced since they are included from |pdflatex|. If |
| 986 |
they are not found, a warning is issued during the compilation. |
| 987 |
|
| 988 |
There is several important things you should notice: |
| 989 |
% |
| 990 |
\begin{enumerate} |
| 991 |
\item Everything outside of the bounding box of a net is |
| 992 |
cropped during the creation of the PDF picture. So, take care to |
| 993 |
check how your picture is rendered (using |\showbb| for |
| 994 |
instance). |
| 995 |
\item Only one pass of {\LaTeX} is made on each figure. If you need to |
| 996 |
several passes, you may run |pn2pdf| manually, with the options |
| 997 |
|-f| and |-k| (see below). |
| 998 |
\item {\LaTeX} and {pdf\LaTeX} do not always produce identical |
| 999 |
rendering of the same document. However, Petri-nets pictures |
| 1000 |
should be the same since they are always typeset by \LaTeX. |
| 1001 |
\end{enumerate} |
| 1002 |
|
| 1003 |
To conclude, here is a summary of the ways to run |pn2pdf|: |
| 1004 |
% |
| 1005 |
\begin{itemize} |
| 1006 |
\item |pn2pdf document-fig|$n$|.pn|\\ |
| 1007 |
generate |pn2pdf document-fig|$n$|.pdf| |
| 1008 |
\item the option |-f| or |--force| may be used to force the creation |
| 1009 |
of PDF files even if their source did not change. |
| 1010 |
\item |pn2pdf -t FILES| or |pn2pdf --test FILES|\\ |
| 1011 |
used by {pdf\LaTeX} in order to check is the option |--shell| |
| 1012 |
was used or not. |
| 1013 |
\item |pn2pdf -b document| or |pn2pdf --batch document|\\ |
| 1014 |
reads the file |document.bpn| in order to produce the figures. |
| 1015 |
\item |pn2pdf -d FILES| or |pn2pdf --delete FILES|\\ |
| 1016 |
deletes |FILES| (which may be patterns like |*.aux|), this is |
| 1017 |
use by |pdflatex| in order to remove some temporary files. |
| 1018 |
\item the option |-k| or |--keep| prevents |pn2pdf| from deleting the |
| 1019 |
temporary files. |
| 1020 |
\item the option |-h| or |--help| prints a short help and exit. |
| 1021 |
\end{itemize} |
| 1022 |
|
| 1023 |
%% |
| 1024 |
%% |
| 1025 |
|
| 1026 |
\newpage |
| 1027 |
\appendix |
| 1028 |
|
| 1029 |
\section{Reference pages} |
| 1030 |
|
| 1031 |
\subsection{Text commands: package {\tt pntext}} |
| 1032 |
|
| 1033 |
\begin{center} |
| 1034 |
\begin{tabular}{l@{\qquad}l} |
| 1035 |
|\bpn| & \bpn \\ |
| 1036 |
|\bpnkw{key-word}| & \bpnkw{key-word} \\ |
| 1037 |
|\bpnnt{non-terminal}| & \bpnnt{non-terminal} \\ |
| 1038 |
|\choice| & \choice \\ |
| 1039 |
|\eplace| & \eplace \\ |
| 1040 |
|\iplace| & \iplace \\ |
| 1041 |
|\lscope| & $\lscope\Rscope$ \\ |
| 1042 |
|\Lscope| & invisible version of |\lscope| \\ |
| 1043 |
|\mathset{A}| & \mathset{A} \\ |
| 1044 |
|\mnet| & \mnet \\ |
| 1045 |
|\placestatus{d}| & \placestatus{d} \\ |
| 1046 |
|\pnversion| & \pnversion{} (current version) \\ |
| 1047 |
|\rs| & \rs \\ |
| 1048 |
|\rscope| & $\Lscope\rscope$ \\ |
| 1049 |
|\Rscope| & invisible version of |\rscope| \\ |
| 1050 |
|\scope{a}{N}| & $\scope{a}{N}$ \\ |
| 1051 |
|\setC| & \setC \\ |
| 1052 |
|\setN| & \setN \\ |
| 1053 |
|\setQ| & \setQ \\ |
| 1054 |
|\setR| & \setR \\ |
| 1055 |
|\setZ| & \setZ \\ |
| 1056 |
|\sy| & \sy \\ |
| 1057 |
|\tie| & \tie \\ |
| 1058 |
|\Val| & \Val \\ |
| 1059 |
|\Var| & \Var \\ |
| 1060 |
|\xplace| & \xplace \\ |
| 1061 |
\end{tabular} |
| 1062 |
\end{center} |
| 1063 |
|
| 1064 |
\subsection{Drawing command: package {\tt pndraw}} |
| 1065 |
|
| 1066 |
\def\n{$\hookleftarrow$} |
| 1067 |
\def\<{$\displaystyle\big\langle$} |
| 1068 |
\def\>{$\displaystyle\big\rangle$} |
| 1069 |
\newenvironment{options}{\\[5pt]\begin{tabular}{@{\qquad}ll}}{\end{tabular}} |
| 1070 |
|
| 1071 |
The parts placed between angle brackets \<$\cdots$\> are the optional |
| 1072 |
ones, the others are mandatory. Symbol \n{} denotes the end of the |
| 1073 |
line. |
| 1074 |
|
| 1075 |
\begin{itemize} |
| 1076 |
\item |\arc|\<|^_*"=![|options|]<|pos|>|\>|{|node1|}{|node2|}|\<label\>\n\\ |
| 1077 |
Draws a labelled arc between node1 and node2. |
| 1078 |
\begin{options} |
| 1079 |
|^| & label above the arc (default)\\ |
| 1080 |
|_| & label below the arc \\ |
| 1081 |
|*| & label over the arc \\ |
| 1082 |
|"| & label in text mode \\ |
| 1083 |
|=| & double line \\ |
| 1084 |
|!| & thick line \\ |
| 1085 |
|[|options|]| & PSTricks options \\ |
| 1086 |
|<|pos|>| & position of the label ($0 \leq {}$pos${}\leq 1$) \\ |
| 1087 |
\end{options} |
| 1088 |
% |
| 1089 |
\item |\beginnet|\<|[|options|]|\>$(x_1,y_1)(x_2,y_2)$\n\\ |
| 1090 |
|\begin{petrinet}|\<|[|options|]|\>$(x_1,y_1)(x_2,y_2)$\n\\ |
| 1091 |
Begins a net whose bounding box is defined by $(x_1,y_1)$ as |
| 1092 |
bottom left corner and $(x_2,y_2)$ at top right corner. |
| 1093 |
\begin{options} |
| 1094 |
|[|options|]| & PSTricks options \\ |
| 1095 |
\end{options} |
| 1096 |
% |
| 1097 |
\item |\endnet|\\ |
| 1098 |
|\end{petrinet}|\\ |
| 1099 |
Ends a net. |
| 1100 |
% |
| 1101 |
\item |\everylabel={|\<tokens\>|}|\\ |
| 1102 |
Expands tokens each time a label is typeset. |
| 1103 |
% |
| 1104 |
\item |\everynet={|\<tokens\>|}|\\ |
| 1105 |
Expands tokens each time a net is started. |
| 1106 |
% |
| 1107 |
\item |\label|\<|"{|pos|}|label\>\n\\ |
| 1108 |
|\label|\<|"<|pos|>|label\>\n\\ |
| 1109 |
Draws an additional label for a node (first line) or a link (second |
| 1110 |
line). |
| 1111 |
\begin{options} |
| 1112 |
|"| & label in text mode \\ |
| 1113 |
|{|pos|}| & position of the label, an angle (in degrees) \\ |
| 1114 |
& or a corner code (t,l,b,r,tl,tr,bl,br) \\ |
| 1115 |
|<|pos|>| & position of the label ($0 \leq$ pos $\leq 1$)\\ |
| 1116 |
\end{options} |
| 1117 |
% |
| 1118 |
\item |\link|\<|^_*"=![|options|]<|pos|>/|arrow|/|\>|{|node1|}{|node2|}|\<label\>\n\\ |
| 1119 |
Draws a labelled link between node1 and node2. |
| 1120 |
\begin{options} |
| 1121 |
|^| & label above the arc (default) \\ |
| 1122 |
|_| & label below the arc \\ |
| 1123 |
|*| & label over the arc \\ |
| 1124 |
|"| & label in text mode \\ |
| 1125 |
|=| & double line \\ |
| 1126 |
|!| & thick line \\ |
| 1127 |
|[|options|]| & PSTricks options \\ |
| 1128 |
|<|pos|>| & position of the label ($0 \leq {}$pos${}\leq 1$) \\ |
| 1129 |
|/|arrow|/| & arrows specifications (see the figure~\ref{fig:arrows} \\ |
| 1130 |
\end{options} |
| 1131 |
% |
| 1132 |
\item |\module|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\ |
| 1133 |
Draws a labelled module centered on $(x,y)$. |
| 1134 |
\begin{options} |
| 1135 |
|"| & label in text mode \\ |
| 1136 |
|=| & double line \\ |
| 1137 |
|!| & thick line \\ |
| 1138 |
|[|options|]| & PSTricks options \\ |
| 1139 |
\end{options} |
| 1140 |
% |
| 1141 |
\item |\modulesize=|dimen\\ |
| 1142 |
Sets the size of the modules. |
| 1143 |
% |
| 1144 |
\item |\nodessize{|dimen|}|\\ |
| 1145 |
Sets the size of all nodes. |
| 1146 |
% |
| 1147 |
\item |\place|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\ |
| 1148 |
Draws a labelled place centered on $(x,y)$. |
| 1149 |
\begin{options} |
| 1150 |
|"| & label in text mode \\ |
| 1151 |
|=| & double line \\ |
| 1152 |
|!| & thick line \\ |
| 1153 |
|[|options|]| & PSTricks options \\ |
| 1154 |
\end{options} |
| 1155 |
% |
| 1156 |
\item |\placesize=|dimen\\ |
| 1157 |
Sets the size of the places. |
| 1158 |
% |
| 1159 |
\item |\psset{|name|=|value\<|,...|\>|}|\\ |
| 1160 |
Sets PSTricks options. |
| 1161 |
\begin{options} |
| 1162 |
|arcangle=|angle & angle at the ends of links \\ |
| 1163 |
|arrowinset=|real & size of arrowheads insets \\ |
| 1164 |
|arrowlength=|real & length of arrowheads \\ |
| 1165 |
|arrowsize=|dim integer & size of arrowheads \\ |
| 1166 |
|doubleline=|boolean & double lines on/off \\ |
| 1167 |
|doublesep=|dim & distance between double lines \\ |
| 1168 |
|fillcolor=|color & background color \\ |
| 1169 |
|labelsep=|dim & distance between labels and nodes \\ |
| 1170 |
|linecolor=|color & lines color \\ |
| 1171 |
|linewidth=|dim & lines thickness \\ |
| 1172 |
|unit=|dim & global scale \\ |
| 1173 |
|xunit=|dim & horizontal scale \\ |
| 1174 |
|yunit=|dim & vertical scale\\ |
| 1175 |
\end{options} |
| 1176 |
% |
| 1177 |
\item |\savenet|\\ |
| 1178 |
Just before the beginning of a net: saves it without displaying it. |
| 1179 |
% |
| 1180 |
\item |\showbb|\<|*[|options|]|\>\n\\ |
| 1181 |
Draws the bounding box of a net. |
| 1182 |
\begin{options} |
| 1183 |
|*| & background filled \\ |
| 1184 |
|[|options|]| & PSTricks options \\ |
| 1185 |
\end{options} |
| 1186 |
% |
| 1187 |
\item |\shownet|\\ |
| 1188 |
Displays the last net saved by |\savenet|. |
| 1189 |
% |
| 1190 |
\item |\source|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\ |
| 1191 |
Draws a labelled source centered on $(x,y)$. |
| 1192 |
\begin{options} |
| 1193 |
|"| & label in text mode \\ |
| 1194 |
|=| & double line \\ |
| 1195 |
|!| & thick line \\ |
| 1196 |
|[|options|]| & PSTricks options \\ |
| 1197 |
\end{options} |
| 1198 |
% |
| 1199 |
\item |\sourcesize=|dimen\\ |
| 1200 |
Sets the size of sources. |
| 1201 |
% |
| 1202 |
\item |\store|\<|"=![|options|]|\>|{|name|}|$(x,y)$\n\\ |
| 1203 |
Draws a store centered on $(x,y)$. |
| 1204 |
\begin{options} |
| 1205 |
|"| & label in text mode \\ |
| 1206 |
|=| & double line \\ |
| 1207 |
|!| & thick line \\ |
| 1208 |
|[|options|]| & PSTricks options \\ |
| 1209 |
\end{options} |
| 1210 |
% |
| 1211 |
\item |\storesize=|dimen\\ |
| 1212 |
Sets the size of stores. |
| 1213 |
% |
| 1214 |
\item |\text|\<|"|\>|{|name|}|$(x,y)$\<label\>\n\\ |
| 1215 |
Draws an unboxed labelled node centered on $(x,y)$. |
| 1216 |
\begin{options} |
| 1217 |
|"| & label in text mode \\ |
| 1218 |
\end{options} |
| 1219 |
% |
| 1220 |
\item |\trans|\<|*"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\ |
| 1221 |
Draws a labelled transition centered on $(x,y)$. |
| 1222 |
\begin{options} |
| 1223 |
|*| & automatic size \\ |
| 1224 |
|"| & label in text mode \\ |
| 1225 |
|=| & double line \\ |
| 1226 |
|!| & thick line \\ |
| 1227 |
|[|options|]| & PSTricks options \\ |
| 1228 |
\end{options} |
| 1229 |
% |
| 1230 |
\item |\transsize=|dimen\\ |
| 1231 |
Sets the size of transitions. |
| 1232 |
\end{itemize} |
| 1233 |
|
| 1234 |
\end{document} |