summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/petri-nets/pndoc.tex
blob: 17692ae8674ef6a21876b4db0ae1b07b34f2506d (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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
% This file is part of the Petri-nets packages. See file README for
% copyright notice.

\documentclass[11pt]{article}

\usepackage{pnets}

\catcode`\|=\active
\def|{\verb|}

%%
%%

\begin{document}

\title{Petri-nets packages}
\author{Franck Pommereau (pommereau@univ-paris12.fr)}
\date{Last update: \pnversion}
\maketitle

\begin{abstract}\noindent
This paper describes Petri-nets, a set of \TeX/\LaTeX{} packages about
Petri nets and related models. One package allows to draw Petri-nets
in PostScript or PDF documents. One other defines macros related to
PBC, M-nets and \bpn{} models. A last package just gathers together
the two previous.
\end{abstract}

\begin{small}
\tableofcontents
\end{small}

%%
%%

\section{Introduction}

Petri-nets is a set of packages I use to write my papers about Petri
nets and related models (essentially: PBC, M-nets and \bpn). It
features three packages: one for drawing net, one other which defines
additional macros for textual purpose (like \bpn's logo) and a last
one for both possibilities. The first package as been designed with a
precise goal: saving me a lot of work when I have to draw nets. This
goal explains some choices I did: typesetting labels in math mode by
default, ending commands with the line, etc. I feel this results in an
intuitive and high-level way to define Petri nets, but if you have
ideas to improve this, don't hesitate to contact me. The text command
package is more classical and if it saves also a lot of typing, its
main goal is to ensure uniformity in the notations.

All these packages may evolve and grow up and if you (or I) feel that
a feature is missing, you can send me an e-mail explaining your needs
(\TeX{} code is welcome too). Notice I don't pretend being a
specialist in Petri nets and I'm only used to work on three or four
models; so I may ignore particular things in particular models. This
may explain some missing features.

If you wish to be notified of the updates of these packages, just send
me an email with your request at {\it pommereau@univ-paris12.fr}.

%%
%%

\subsection{Installation}

The last version of the package may be downloaded at {\it http:/\slash
www.univ-paris12.fr\slash lacl\slash pommereau\slash
petrinets.tar.gz\/}, a copy should be available on {\it CTAN\slash
macros\slash generic\slash petri-nets}; the distribution contains the
following files:

\begin{itemize}
\item |pnets.tex| is the main \TeX{} package;
\item |pnets.sty| is its \LaTeX{} counterpart;
\item |pndraw.tex| and |pndraw.sty| are the \TeX{} and \LaTeX{}
      sub-packages for drawing nets;
\item |pntext.tex| and |pntext.sty| are the \TeX{} and \LaTeX{}
      sub-packages for text commands;
\item |pnversion.tex| defines macro |\pnversion|;
\item |pndoc.ps| and |pndoc.tex| are the present paper and its source;
\item |COPYING| is the text of the GNU GPL;
\item |Changelog| collects all changes done to Petri-nets;
\item |README| is a short introduction text;
\item |pn2pdf| a Perl script used to produce PDF files with pdf\LaTeX.
\end{itemize}

In order to have Petri-nets working, you need to copy files |pnets.*|,
|pndraw.*| and |pntext.*| in a place where \TeX{} will be able to find
them. This can be somewhere in the default search path (see your local
\TeX{} documentation) or in a directory included in your |TEXINPUT|
environment variable.

Packages from Petri-nets have been developed and tested with
te\TeX-0.9 for Linux. \TeX{} packages should work with any \TeX{}
version greater than or equal to 3 (my version is 3.14159). \LaTeX{}
packages have been designed for \LaTeX$2_\varepsilon$ so you may
experiment troubles with an older version.

In order to typeset symbols for classical sets of numbers (\setN,
\setR, etc.) Petri-nets uses fonts from AMS. So you must have package
|amsfonts| installed for \LaTeX{} or fonts |bbm| for \TeX{} (I think
these conditions are more or less equivalent).

The drawing basis are provided by package PSTricks, my version is
PST97 but I used only macros described in the manual of version 0.93a
so I hope it should work with it.

Using PSTricks has an important consequence: actual drawings are done
in PostScript, so, you may not see them directly from the DVI viewer
(at least not correctly); additionally, you must use a PostScript
driver in order to produce your final document (for example, dvips
works well). Support for producing PDF documents with pdf{\LaTeX} is
provided (see section~\ref{sec:pdf}).

PSTricks conflicts with packages |graphics| and |graphicx|, Petri-nets
thus inherits this conflict. If you wish to use them together, you
should first load package |pstcol|, then Petri-nets and at last,
|graphics| or |graphicx|. The following is quoted from PSTricks'
|README|:

\begin{quote}
To use the standard `|color|' package (which is available both for
plain \TeX{} and \LaTeX) with PSTricks, you must load the `|pstcol|'
extra package written by David Carlisle, which interface the two
packages, loading them in the right order, and overriding some small
parts of PSTricks to allow it to use the `|color|' package system for
specifying color.  We {\it strongly\/} recommend that you use this way
today.

\LaTeX{} users must also take care that the `|pstcol|' package is
required in place of the `|pstricks|' one if the `|graphics|' or
`|graphicx|' package is also loaded.
\end{quote}

If you wish to produce PDF files using pdf{\LaTeX}, you also need to
copy the script |pn2pdf| in a directory from which it can be executed.
This script requires a working Perl with the package |Digest::MD5|
installed. Moreover, the script calls the following programs: |latex|,
|dvips| and |epstopdf| which must be installed on your system (there
should be not problem for the first two).

You can test your installation by recompiling the present manual which
is written in \LaTeX. If it compiles successfully, this means
Petri-nets and also PSTricks have been found by \TeX. If one file is
not found, \TeX{} will complain, giving the file name. Then, running
dvips will ensure that the PostScript headers of PSTricks can be
found.

If you successfully use Petri-nets under another configuration, feel
free to send me an e-mail at {\it pommereau@univ-paris12.fr}. You may
also send bug reports or comments, they are welcome. Of course, bug
fixes are welcome too.

%%
%%

\subsection{Loading the packages}

From \TeX, you load the package with |\input pnets|, from \LaTeX, you
should put |\usepackage{pnets}| in your document preamble. Since you
may want to use only the drawing macros, you can use |\input pndraw|
or from \LaTeX: |\usepackage{pndraw}|. Similarly, in order to load
only text commands, you can use |\input pntext| or
|\usepackage{pntext}|.

Both packages define a macro |\pnversion| which gives the date of the
last update of the package. The date is given as a triple of numbers
of the form |year-month-day|.

%%
%%

\subsection{Things to do, known bugs and problems}

In order to draw additional labels at the right position, |pndraw| has
to perform some time consuming floating point computing. I plane in
the future to perform this directly in PostScript, in order to speed-up
\TeX{} compilation stage.

Only transitions are allowed to change their size according to their
inner label, it may be nice to have this feature for the other
nodes. But it's may be a little bit difficult or quite ugly for some
nodes.

I also could add looping arcs. This is useless for Petri nets but it
would allow one to use the packages for other purposes, like drawing
automata.

The script |pn2pdf| does not handle documents spread over multiple
files: if a picture is created in a file which is included, it will be
ignored.

In a late future, I'd like to make the package independent of
PSTricks, so it would be more portable (but less powerful).

%%
%%

\subsection{Legal stuff}

Petri-nets is \copyright{}opyright 1999--2001 Franck Pommereau ({\it
pommereau@univ-paris12.fr\/}).

This program is free software; you can redistribute it and/or modify
it under the terms of the {\it GNU General Public License\/} as
published by the Free Software Foundation; either version 2 of the
License, or any later version (see file |COPYING|).

This program is distributed in the hope that it will be useful, but
{\it without any warranty\/}; without even the implied warranty of
{\it merchantability\/} or {\it fitness for a particular purpose}.
See the {\it GNU General Public License\/} for more details.

You should have received a copy of the {\it GNU General Public
License\/} along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA

%%
%%

\subsection{Contributors}

I am very grateful to all the persons who contributed to my work, in
particular:

\begin{quote}
Denis Girou,
Hanna Klaudel,
Andr\'e Steenveld.
\end{quote}

%%
%%

\section{Text commands: package {\tt pntext}}

This section lists the commands defined in package |pntext|, they are
all available from \TeX{} as from \LaTeX.

\paragraph{Math sets.}
%
Command |\mathset{A}| produces symbol \mathset{A} (and of course it
works for any text). Shortcuts are defined: |\setN| for |\mathset{N}|
and similarly for |\setZ|, |\setQ|, |\setR| and |\setC|.

\paragraph{Status of places.}
%
Commands |\iplace|, |\eplace| and |\xplace| produce respectively
characters \iplace, \eplace{} and \xplace. Command |\placestatus{n}|
typesets character \placestatus{n} (in the case you would like a new
place type).

\paragraph{Operators for communication.}
%
Synchronization operator (\sy) is available through command |\sy|, in
math mode, this command is surrounded by additional white space as
usual for binary operators. Similar operators are |\rs| for
restriction and |\tie| for asynchronous links. Scoping is available
with commands |\lscope| and |\rscope| which produce respectively a
left and a right double bracket, you may also use |\scope{A}{N}| to
produce \scope{A}{N}.

If you use |\lscope| (resp. |\rscope|) without the corresponding
|\rscope| (resp. |\lscope|) in the same equation or array cell, \TeX{}
will complain about some missing |\right| (resp. |\left|). In order to
close (resp. open) a scope without drawing the bracket, you may use
macro |\Rscope| (resp. |\Lscope|).

\paragraph{Choice.}
%
Choice operator \choice{} is produced with command |\choice|. In math
mode, it behaves like any binary operator.

\paragraph{\bpn.}
%
The logo of \bpn{} is typeset using command |\bpn|. A \bpn{} keyword
(say \bpnkw{program}) is typeset with |\bpnkw{program}| and for a
non-terminal in the syntax (say \bpnnt{scope}) you may use
|\bpnnt{scope}|. Function \mnet{} is defined as |\mnet|.

\paragraph{Sets of values and variables.}
%
\Var{} and \Val{} are typeset using commands |\Var| and |\Val|. They
are better to use than directly the text they typeset because they
adjust their spacing in math mode: compare ``$Var$'' with ``$\Var$''.

\paragraph{To be continued\dots}

%%
%%

\section{Drawing nets: package {\tt pndraw}}

%%
%%

\subsection{Some words about PSTricks}

Reading PSTricks manual could be a good idea, but if you don't want,
you should know a few things about it in order to use Petri-nets
successfully.

In PSTricks, any point is designated by two coordinates in a grid,
centered on a reference point which has coordinates $(0,0)$.
Figure~\ref{axis} shows an example.

\begin{figure}[t]
\begin{center}
\begin{petrinet}(-1.5,-1.5)(5.5,3.5)
\pst\psgrid[subgriddiv=1,griddots=10](-1,-1)(5,3)
\pst\psline{->}(0,-1.5)(0,3.5)
\pst\psline{->}(-1.5,0)(5.5,0)
\pst\psdot(4,2)
\pst\rput[br](4,2){$(4,2)$}
\pst\psdot(0,0)
\pst\rput[br](0,0){$(0,0)$}
\pst\psdot(2.5,-.5)
\pst\rput[l](2.5,-.5){$\,(2.5,-.5)$}
\end{petrinet}
\end{center}
\caption{The Cartesian coordinate system.}
\label{axis}
\end{figure}

The distance from the origin $(0,0)$ to a point $(x,y)$ depends on
three parameters. |units| is a global scale, if |unit=1.2cm|, $(4,2)$
becomes an abbreviation for $(4 \times 1.2\hbox{ cm}, 2 \times
1.2\hbox{ cm})$. There's also |xunit| and |yunit| which act
respectively only on horizontal or vertical scale; for example, if
|xunit=20pt| and |yunit=1in|, $(4,2)$ stands for $(4 \times 20\hbox{
pt}, 2 \times 1\hbox{ in})$. As you can see on these short examples,
|unit|, |xunit| and |yunit| can be affected any value which is a valid
\TeX{} |dimen| (or \LaTeX{} length).

The default value for all these three parameters is 1~cm; to change
it, you can use the |\psset| command as in |\psset{unit=.5cm}| or in a
combined way as in |\psset{xunit=1cm,yunit=2cm}|.

Since coordinates are formed as a comma separated couple of numbers,
you {\it must not\/} use comma as decimal separator here: |(4.5,2.3)|
is correct but |(4,5,2,3)| is not.

Sometime you'll be asked to give an angle value as a macro
parameter. In Petri-nets, angles are measured in degrees; they can be
given as a numerical value or with a one/two letter(s) code as shown
on figure~\ref{angles}. Of course, when you specify an angle by its
numerical value, you can use any number, even negative, and not only
one of the eight values shown on figure~\ref{angles}.

\begin{figure}[t]
\begin{center}
\begin{petrinet}[unit=2cm](-2,-1.3)(2,1.3)
\pst\pscircle(0,0){1}%
{\count0=0 %
 \loop %
 \ifnum\count0<360 %
   \uput{.95}[\the\count0]{\the\count0}(0,0){\bf--}%
   \advance\count0 by 45 %
 \repeat}
\pst\uput{1.1}[0](0,0){$0=r$}
\pst\uput{1.1}[45](0,0){$45=tr/rt$}
\pst\uput{1.1}[90](0,0){$90=t$}
\pst\uput{1.1}[135](0,0){$135=tl/lt$}
\pst\uput{1.1}[180](0,0){$180=l$}
\pst\uput{1.1}[225](0,0){$225=bl/lb$}
\pst\uput{1.1}[270](0,0){$270=b$}
\pst\uput{1.1}[315](0,0){$315=br/rb$}
\end{petrinet}
\caption{Translation from angle values to letter code. $r$ is for {\it
right}, $t$ for {\it top}, $l$ for {\it left\/} and $b$ for {\it
bottom}.}
\label{angles}
\end{center}
\end{figure}

Macro |\psset| is the way to change PSTricks default parameters, it
takes one argument which is a comma-separated list of |name=value|
pairs. For example, |pndraw.tex| itself uses:
\begin{verbatim}
\psset{linewidth=.5pt,
       doublesep=.5pt,
       labelsep=2pt}
\end{verbatim}

As you can see, blank spaces before a |name| are ignored. You already
know how to change units, some additional |name|s should be useful for
Petri-nets:

\begin{itemize}
\item |linewidth| is the default width for {\it any\/} line drawn by
      PSTricks;
\item |doubleline| can be |true| or |false|, when set to |true|, any
      line drawn is doubled;
\item |doublesep| is the distance between the two lines of a doubled
      line;
\item |labelsep| is the distance between an arc and its label(s);
\item |linecolor| is the color used to draw lines, it can be, for
      example, |black|, |darkgray|, |gray|, |lightgray|, |white|,
      |red|, |blue|, |green|, |cyan|, |magenta| or |yellow|;
\item |fillcolor| is the color used to fill shapes; you can use for it
      the same colors as for |linecolor|.
\end{itemize}

PSTricks recognizes many other parameters and you should refer to its
manual for all details.

%%
%%

\subsection{Beginning and ending nets}

To begin a net, just type |\beginnet| for \TeX{} or |\begin{petrinet}|
under \LaTeX; both this commands are expecting two pairs of
coordinates to give the bottom-left and upper-right extrema of the
net.

For example, |\begin{petrinet}(-1,-2)(5,3)| starts a net which should
extend in the rectangular area, which we call the {\it bounding box},
delimited by $(-1,-2)$ at the lower left corner and $(5,3)$ at the
upper right. These coordinates are sensible to current |unit|, |xunit|
and |yunit| values.

The real effect of these two pairs is to fix the size of the bounding
box which carry the drawn net (it is actually a |\hbox| in horizontal
mode but who cares?). If some stuff in the net extends outside of the
declared bounding box, it will be outside and that's all. In other
words, the bounding box announced just reserves room for the net and
the drawing itself is invisible to \TeX. This allows you to lies on
the real dimension of your drawings: you can declare a bigger or a
smaller bounding box, if you want more or less white space around your
nets.

Before to give bounding box coordinates for a net, you can give
optional parameters inside square brackets. These parameters are
interpreted as PSTricks options which are applied to the following net
and stay local to it. For example, if we have |unit=1cm| before
starting a net, command |\begin{petrinet}[unit=2cm](0,0)(1,1)| starts
a net with |unit=2cm| for its bounding box and any coordinate given
inside the net. But as the net ends, the old value |unit=1cm| is
restored.

In order to have bounding boxes drawn in your nets: you may use
command |\showbb|, optionally followed by bracketed options. For
figure~\ref{fig:nodes example}, I added |\showbb| at the beginning of
the net. The starred version of |\showbb| fills its background and so,
command |\showbb*[fillcolor=red]| draws a filled red rectangle over
the bounding box.

To end the drawing, you should use |\endnet| or |\end{petrinet}| (did
you guess?). All macros between these two ones are interpreted as
PSTricks or Petri-nets commands. From now, we call a {\it net\/} all
the stuff inclosed between |\begin{petrinet}| and |\end{petrinet}| (if
you use \LaTeX). One point has to be remembered: inside a net, the end
of line has a special meaning because it is used to end most
Petri-nets drawing commands. So if you want to use commands on several
lines, you have to end every line but the last with a comment
(|%|). Also notice that if you call |\psset| command inside a net, its
effect will remain local to this particular net.

If you wish something to be done every time a net begins, you may set
token list |\everynet| to what you want to be inserted between command
|\begin{petrinet}| and your drawing commands. For example, with
|\everynet={\small}|, all the following nets will be set in small
types.

Except for beginning and ending nets, all the macros in the following
are the same under \TeX{} or \LaTeX.

%%
%%

\subsection{Drawing nodes}

The available node shapes are places, transitions, modules, sources
and stores, see figure~\ref{fig:nodes} for their looking. They are
produced from macros |\place|, |\trans|, |\module|, |\source| and
|\store| respectively. Their size is controlled with dimensions
|\placesize|, |\transsize|, |\modulesize|, |\sourcesize| and
|\storesize| respectively. For instance, |\transsize=8mm| sets the
size of transitions to |8mm|, |\nodessize{5mm}| sets the size of {\it
all\/} nodes to |5mm|.

\begin{figure}
\begin{center}
\begin{petrinet}[xunit=2cm](-.5,-.5)(4.5,1)
\place{place}(0,0) p
\label"{t}place\strut
\trans{trans}(1,0) t
\label"{t}transition\strut
\module{module}(2,0) m
\label"{t}module\strut
\source{source}(3,0) s
\label"{t}source\strut
\store{store}(4,0) labels are ignored for stores
\label"{t}store\strut
\end{petrinet}
\end{center}
\caption{The nodes available in Petri-nets.}
\label{fig:nodes}
\end{figure}

Adding a node is made using command ``node\{name\}$(x,y)$label''
where:
%
\begin{itemize}
\item ``node'' is one of the above node commands;
\item ``name'' is the name of this node which must be unique for a
      given net (if not, the new node overwrites the old one). This
      name is case sensitive and should not contain any special
      characters (as |$|, |\|, etc.); %$
\item ``$(x,y)$'' are the coordinates of the node's center;
\item ``label'' is the text to typeset inside the node, it
       extends until the end of the line. This label is silently
       discarded for sources.
\end{itemize}

For instance, the nodes in figure~\ref{fig:nodes} where set with
commands:
%
\begin{verbatim}
\place{place}(0,0) p
\trans{trans}(1,0) t
\module{module}(2,0) m
\source{source}(3,0) s
\store{store}(4,0) labels are ignored for stores
\end{verbatim}

By default, labels are typeset in math mode, if you wish a label
typeset in text mode, add option |"| after the node command. Notice
that any space after the coordinates of the node is part of the label,
it has no importance in math mode but in text mode it leads to a label
which starts with a white space. Option |=| sets double-line mode and
so the node is drawn with doubled lines. Option |!| sets the line
width to 2pt so the node appears thicker than usually. PSTricks
options may be given between square brackets, for instance adding
|[linecolor=red,linewidth=1pt]| leads to a red node with 1pt lines.

For transitions, an additional option |*| may be used in order to have
the boundaries of the transition fitted to the label typeset
inside. By default, the size of the nodes is fixed and the label
overlaps outside if too long, for transitions, with option |*|, the
size is just fine.

\subsubsection{Additional labels}

You can add additional labels to a node. Each label is typeset using
macro |\label|%
%
\footnote{For \LaTeX, this means that the well known cross-referencing
{\tt\string\label} macro is not available inside a {\tt petrinet}
environment. But outside, it works as usual.}
%
which has two arguments: the first is an angle indication and the
second, which extends until the end of the line, is the text to
typeset. The angle indication is a numeric value or a code as
explained earlier. Option |"| explained above is also available for
additional labels (and should be given just after |\label|).

Before I give an example, let me explain a useful parameter for
typesetting label: the token list |\everylabel| is expanded before any
label is typeset. For example, command |\everylabel={\scriptstyle}|
leads to typeset all labels in script style. This works for really any
label, not only for nodes labels. If |\everylabel| is set inside a
net, its effect will remain local to this net.

The figure~\ref{fig:nodes example} has been typeset using the
following commands:
%
\begin{verbatim}
\begin {petrinet}[xunit=2cm](-.5,-.5)(2.5,.5)
\showbb
\place{p1}(0,0) \bullet
\trans*"{t}(1,0)~transition~
  \label"{70}more text
\place!{p2}(2,0) i
  \label{r} \iplace.\left\{     % I can type multi-line
    {\textstyle 1, 2, 3 \atop   % labels, thanks to comments.
     \textstyle 4, 5, 6} \right\}
\end {petrinet}
\end{verbatim}

\begin{figure}
\begin{center}
\begin{petrinet}[xunit=2cm](-.5,-.5)(2.5,.5)
\showbb
\place{p1}(0,0) \bullet
\trans*"{t}(1,0)~transition~
  \label"{70}more text
\place!{p2}(2,0) i
  \label{r} \iplace.\left\{     % I can type multi-line
    {\textstyle 1, 2, 3 \atop   % labels, thanks to comments.
     \textstyle 4, 5, 6} \right\}
\end{petrinet}
\caption{Nodes example. (In the PDF, the outside of the bounding box
         is cropped, see section~\ref{sec:pdf}.) }
\label{fig:nodes example}
\end{center}
\end{figure}

You may notice that the net is not well centered, it extends more on
the right (compare with the caption, which is correctly
centered). This is because I declared a bounding box of $(-.5,-.5)$ to
$(2.5,.5)$ while in fact, the label on place $i$ extends on the right,
outside the bounding box (macro |\showbb| make it visible).

%%
%%

\subsubsection{Free text}

Another kind of node is unboxed text. Macro |\text| is similar to
places and transitions macros but it just typesets the given text,
centered on the given coordinates. Like for other nodes, the text is
typeset in math mode and it can be added labels around with macro
|\label| (which takes care of text's bounding box).

This macro knows only option |"| which has the usual meaning.

%%
%%

\subsection{Linking nodes}

You can draw links between two arbitrary nodes. The package won't
check if requested links are valid from Petri nets point of
view. Basically, macro |\link| has three parameters: the name of the
starting node, that of the ending node and then text to typeset on the
link (which extends until the end of the line). You can add optional
parameters, before the first node name:
%
\begin{itemize}
\item options inside square brackets are PSTricks options, as usual;
\item a real number, between 0 and 1, enclosed in angle brackets ({\it
      e.g.}, |<.3>|) can be used to specify the position of the label,
      between starting and ending nodes. Value 0 stands for ``on
      starting node'' while 1 means ``on ending node''; the default
      value is $.5$ ({\it i.e.}, at the middle of the link);
\item characters |^|, |_| or |*| may be used to specify the side of
      the link where the label is typeset. For an link which extends
      from the left to the right, |^| means ``above'', |_| means
      ``below'' and |*| is for ``over''. If nothing is specified, the
      label is placed above the link;
\item options |"|, |=| and |!| have their usual meanings;
\item arrowheads and such can be specified between two |/| signs.
      The available values are shown in figure~\ref{fig:arrows},
      default is no arrow.
\end{itemize}

\begin{figure}
\begin{center}
\begin{petrinet}[yunit=6mm](-.6,-.3)(8,15.3)
\pst\catcode`\|=12
\text{caption}(3,15)\rlap{none (default)}
  \text"{t}(0,15){\tt -}
  \text{l}(1,15)
  \text{r}(2,15)
  \link/-/{l}{r}
\text{caption}(3,14)\rlap{arrowheads}
  \text"{t}(0,14){\tt <->}
  \text{l}(1,14)
  \text{r}(2,14)
  \link/<->/{l}{r}
\text{caption}(3,13)\rlap{reverse arrowheads}
  \text"{t}(0,13){\tt >-<}
  \text{l}(1,13)
  \text{r}(2,13)
  \link/>-</{l}{r}
\text{caption}(3,12)\rlap{double arrowheads}
  \text"{t}(0,12){\tt <{}<->{}>}
  \text{l}(1,12)
  \text{r}(2,12)
  \link/<<->>/{l}{r}
\text{caption}(3,11)\rlap{reverse double arrowheads}
  \text"{t}(0,11){\tt >{}>-<{}<}
  \text{l}(1,11)
  \text{r}(2,11)
  \link/>>-<</{l}{r}
\text{caption}(3,10)\rlap{T-bar flush to endpoints}
  \text"{t}(0,10){\tt |-|}
  \text{l}(1,10)
  \text{r}(2,10)
  \link/|-|/{l}{r}
\text{caption}(3,9)\rlap{T-bar centred on endpoints}
  \text"{t}(0,9){\tt |*-|*}
  \text{l}(1,9)
  \text{r}(2,9)
  \link/|*-|*/{l}{r}
\text{caption}(3,8)\rlap{square brackets}
  \text"{t}(0,8){\tt [-]}
  \text{l}(1,8)
  \text{r}(2,8)
  \link/[-]/{l}{r}
\text{caption}(3,7)\rlap{rounded brackets}
  \text"{t}(0,7){\tt (-)}
  \text{l}(1,7)
  \text{r}(2,7)
  \link/(-)/{l}{r}
\text{caption}(3,6)\rlap{circles centred on endpoints}
  \text"{t}(0,6){\tt o-o}
  \text{l}(1,6)
  \text{r}(2,6)
  \link/o-o/{l}{r}
\text{caption}(3,5)\rlap{circles flush to endpoints}
  \text"{t}(0,5){\tt oo-oo}
  \text{l}(1,5)
  \text{r}(2,5)
  \link/oo-oo/{l}{r}
\text{caption}(3,4)\rlap{disks centred on endpoints}
  \text"{t}(0,4){\tt *-*}
  \text{l}(1,4)
  \text{r}(2,4)
  \link/*-*/{l}{r}
\text{caption}(3,3)\rlap{disks flush to endpoints}
  \text"{t}(0,3){\tt **-**}
  \text{l}(1,3)
  \text{r}(2,3)
  \link/**-**/{l}{r}
\text{caption}(3,2)\rlap{extended rounded ends}
  \text"{t}(0,2){\tt c-c}
  \text{l}(1,2)
  \text{r}(2,2)
  \link/c-c/{l}{r}
\text{caption}(3,1)\rlap{flush rounded ends}
  \text"{t}(0,1){\tt cc-cc}
  \text{l}(1,1)
  \text{r}(2,1)
  \link/cc-cc/{l}{r}
\text{caption}(3,0)\rlap{extended square ends}
  \text"{t}(0,0){\tt C-C}
  \text{l}(1,0)
  \text{r}(2,0)
  \link/C-C/{l}{r}
\end{petrinet}
\end{center}
\caption{The different types of links termination. They can be freely
mixed.}
\label{fig:arrows}
\end{figure}

The order in which you use these options has no importance, provided
all options are given before the starting node. Additionally, if you
use contradicting options, the last used overrides any previous. For
instance, the two following lines are equivalent:

|\link_[linecolor=gray,linewidth=5pt]*<.2>^[linewidth=1pt]|

|\link^<.2>[linecolor=gray,linewidth=1pt]|.

To draw curved links, you should use PSTricks' |arcangle| option which
is an angle in degrees, measuring the deviation from a straight line
between nodes, at the start and at the end of the link. Try, it's
easy.

To change the arrowhead appearance, you must change PSTricks'
parameters |arrowsize|, |arrowlength| and |arrowinset|. Petri-nets
uses the following:
%
\begin{verbatim}
\psset{arrowsize=3pt 3,
       arrowlength=1.4,
       arrowinset=.4}
\end{verbatim}
%
I wont explain how it works, just try, it's easy too. (Or read
PSTricks manual, all details are given.)

%%
%%

\subsubsection{Additional labels}

Like for nodes, links can be added more labels. As usual, this is made
with macro |\label|, but here, its syntax is like for macro |\link|,
except you must not specify starting and ending nodes (but links
options are available).

%%
%%

\subsubsection{Arcs}

Since links are almost always draw with a single arrowhead at the end
(and then called {\it arcs\/}), a shortcut is provided: macro |\arc|
may be used instead of |\link/->/|.

%%
%%

\section{Tips, tricks and troubleshooting}

\paragraph{Error messages.}
%
Sometimes, you'll get an error message such as:

\begin{verbatim}
! Argument of \net:place:draw has an extra }.
<inserted text> 
                \par 
l.785 \place{i3}(2,0) i_3
                         
? 
\end{verbatim}

This usually means that the error was just before the line for which
\TeX{} complains (here line 785 which is correct). And usually, this
error is an omission of one of the arguments of a drawing macro.

Another kind of message occurs quite often:

\begin{verbatim}
PSTricks error.  See User's Guide for further information.
                 Type  H <return>  for immediate help.
! Graphics parameter `rcangle' not defined..
\@pstrickserr ... immediate help.}\errmessage {#1}
                                                  \endgroup 
l.794 \arc[rcangle=30]
                      {ab2}{i3} \bullet
? 
\end{verbatim}

This is because on line 794, you misspelled word ``arcangle'', giving
``rcangle'' instead. This error is detected by PSTricks since
bracketed arguments are sent verbatim to its macros.

In general, since package |pndraw| uses a lot of tricks in order to
read arguments of commands, you should not trust too much error
messages: just look at the line indicated in the message and seek for
a mistake in the lines before this one. (Actually, this advice can be
used for almost any error message issued by \LaTeX\dots)

\paragraph{Drawing commands on multiple lines.}
%
Inside a net, label arguments are delimited by the end of the line. To
type an argument which extends on more than one line, you should end
each line but the last with a comment~|%|.

\paragraph{Empty node.}
%
If you want to draw ``floating'' arcs, {\it i.e.}, arcs wich are not
attached to a place or a transition, you just have to anchor them on
empty texts: the following net is depicted in figure~\ref{empty text}.

\begin{verbatim}
\begin {petrinet}(0,0)(2,0)
\text{from}(0,0)
\text{to}(2,0)
\arc{from}{to}
\end {petrinet}
\end{verbatim}

\begin{figure}[t]
\begin{center}
\begin{petrinet}(-.2,-.2)(2.2,.2)
\text{from}(0,0)
\text{to}(2,0)
\arc{from}{to}
\end{petrinet}
\end{center}
\caption{An arc anchored on empty texts}
\label{empty text}
\end{figure}

\paragraph{Text mode labels.}
%
Take care of the interactions between |\everylabel| and option |"|
which asks a label to be typset in text mode. For example, setting
|\everylabel{\scriptstyle}| leads to an error every time a text mode
label is typeset because |\scriptstyle| is a math command. So you
should prefer the long but safe form:
|\everylabel{\ifmmode\scriptstyle\fi}| which switches to script-style
only if math mode is set.

\paragraph{Labels at the wrong position.}
%
If the additional labels you add to a node appear centered on it
instead of outside, this may come from the way you visualize your
document. DVI viewers usually do not interpret correctly all of the
PostScript commands used by PSTricks. Trying a PostScript viewer
(GhostView is certainly a good choice) may solve your problem.

\paragraph{To be continued\dots}

%%
%%

\section{Producing PDF documents}
\label{sec:pdf}

The LaTeX version of |pndraw| provides support for pdf{\LaTeX} through
the Perl script pn2pdf included in the archive. The usage is quite
automated, even completely if you run |pdflatex| with the option
|--shell|. If you don't want to enable this option, run first 
``|pn2pdf document|'' (assuming your file is called |document.tex|)
and then run |pdflatex|. Using option |--shell| simply allows
|pdflatex| to run |pn2pdf| for you.

\relax|pn2pdf| produces a file named |document-fig|$i$|.pdf| for each
environment |petrinet| found in |document.tex|, where $i$ is 1 for the
first found, 2 for the second one, and so on. These files are
automatically included during the compilation. A file |document.sum|
is also produced in order to remember some information which is used
to avoid recreating |-fig|$i$|.pdf| files if not necessary.

There is several important things you should notice:
%
\begin{enumerate}
\item Everything outside of the bounding box of a Petri nets is
      cropped during the creation of the PDF figure. So, take care to
      check how your picture is rendered (using |\showbb| for
      instance).
\item If you want to use PSTricks commands, you should prefix them
      with |\pst| so they will be properly handled by pdf\LaTeX. If
      you don't use |\pst|, a helpless error message will be issued.
\item Since each picture is rendered separately, all what you define
      in the document has no effect on the figure (except for the
      material given before |\begin{document}| which is always used).
      You must consider that each picture is a separate document.
\item Only one pass of {\LaTeX} is made on each figure. If you need to
      several passes, use |pn2pdf| with options |-f| and |-k|.
\item The script |pn2pdf| will generate a picture for each |petrinet|
      environment found in the document, even if it is included, for
      instance in a |verbatim| environment. This is why, in this
      document, examples are typeset |\begin {petrinet}| $\cdots$
      |\end {petrinet}| in order to avoid the creation of a picture.
\item Notice that {\LaTeX} and {pdf\LaTeX} do not produce identical
      rendering of the same document. However, Petri-nets pictures
      should be the same since they are always made by \LaTeX.
\end{enumerate}

To conclude, here is a summary of the options accepted by |pn2pdf| if
you have to run it yourself:
%
\begin{description}
\item{{\tt -k}, {\tt --keep}} don't delete the temporary files.
\item{{\tt -c}, {\tt --clean}} delete these files.
\item{{\tt -f}, {\tt --force}} recreate pictures even if their source
did not change.
\item{{\tt -h}, {\tt --help}} print this help.
\end{description}
%
You may produce pictures for several documents, in this case, each
option applies to all the document given subsequently (in this case,
|-c| may be useful to override the use of |-k|).

%%
%%

\newpage
\appendix

\section{Reference pages}

\subsection{Text commands: package {\tt pntext}}

\begin{center}
\begin{tabular}{l@{\qquad}l}
|\bpn| & \bpn \\
|\bpnkw{key-word}| & \bpnkw{key-word} \\
|\bpnnt{non-terminal}| & \bpnnt{non-terminal} \\
|\choice| & \choice \\
|\eplace| & \eplace \\
|\iplace| & \iplace \\
|\lscope| & $\lscope\Rscope$ \\
|\Lscope| & invisible version of |\lscope| \\
|\mathset{A}| & \mathset{A} \\
|\mnet| & \mnet \\
|\placestatus{d}| & \placestatus{d} \\
|\pnversion| & \pnversion{} (current version) \\
|\rs| & \rs \\
|\rscope| & $\Lscope\rscope$ \\
|\Rscope| & invisible version of |\rscope| \\
|\scope{a}{N}| & $\scope{a}{N}$ \\
|\setC| & \setC \\
|\setN| & \setN \\
|\setQ| & \setQ \\
|\setR| & \setR \\
|\setZ| & \setZ \\
|\sy| & \sy \\
|\tie| & \tie \\
|\Val| & \Val \\
|\Var| & \Var \\
|\xplace| & \xplace \\
\end{tabular}
\end{center}

\subsection{Drawing command: package {\tt pndraw}}

\def\n{$\hookleftarrow$}
\def\<{$\displaystyle\big\langle$}
\def\>{$\displaystyle\big\rangle$}
\newenvironment{options}{\\[5pt]\begin{tabular}{@{\qquad}ll}}{\end{tabular}}

The parts placed between \<angle brackets\> are the optional ones, the
others are mandatory. Symbol \n{} denotes the end of the line.

\begin{itemize}
\item |\arc|\<|^_*"=![|options|]<|pos|>|\>|{|node1|}{|node2|}|\<label\>\n\\
Draws a labelled arc between node1 and node2.
\begin{options}
|^| & label above the arc \\
|_| & label below the arc \\
|*| & label on the arc \\
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
|<|pos|>| & position of the label ($0 \leq {}$pos${}\leq 1$) \\
\end{options}
%
\item |\beginnet|\<|[|options|]|\>$(x_1,y_1)(x_2,y_2)$\n\\
      |\begin{petrinet}|\<|[|options|]|\>$(x_1,y_1)(x_2,y_2)$\n\\
Begins a net whose bounding box is defined by $(x_1,y_1)$ as
bottom left corner and $(x_2,y_2)$ at top right corner.
\begin{options}
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\endnet|\\
      |\end{petrinet}|\\
Ends a net.
%
\item |\everylabel={|\<tokens\>|}|\\
Expands tokens each time a label is typeset.
%
\item |\everynet={|\<tokens\>|}|\\
Expands tokens each time a net is started.
%
\item |\label|\<|"{|pos|}|label\>\n\\
Draws an additional node label.
\begin{options}
|"| & label in text mode \\
|{|pos|}| & position of the label, an angle (in degrees) \\
          & or a corner code (t,l,b,r,tl,tr,bl,br) \\
\end{options}
%
\item |\link|\<|^_*"=![|options|]<|pos|>/|arrow|/|\>|{|node1|}{|node2|}|\<label\>\n\\
Draws a labelled link between node1 and node2.
\begin{options}
|^| & label above the arc \\
|_| & label below the arc \\
|*| & label on the arc \\
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
|<|pos|>| & position of the label ($0 \leq {}$pos${}\leq 1$) \\
|/|arrow|/| & arrows specifications \\
\end{options}
%
\item |\module|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws a labelled module centered on $(x,y)$.
\begin{options}
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\modulesize=|dimen\\
Sets the size of the modules.
%
\item |\nodessize{|dimen|}|\\
Sets the size of all nodes.
%
\item |\place|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws a labelled place centered on $(x,y)$.
\begin{options}
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\placesize=|dimen\\
Sets the size of the places.
%
\item |\psset{|name|=|value\<|,...|\>|}|\\
Sets PSTricks options.
\begin{options}
|arcangle=|angle & angle at the ends of links \\
|arrowinset=|real & size of arrowheads insets \\
|arrowlength=|real & length of arrowheads \\
|arrowsize=|dim integer & size of arrowheads \\
|doubleline=|boolean & double lines on/off \\
|doublesep=|dim & distance between double lines \\
|fillcolor=|color & background color \\
|labelsep=|dim & distance between labels and nodes \\
|linecolor=|color & lines color \\
|linewidth=|dim & lines thickness \\
|unit=|dim & global scale \\
|xunit=|dim & horizontal scale \\
|yunit=|dim & vertical scale\\
\end{options}
%
\item |\showbb|\<|*[|options|]|\>\n\\
Draws the bounding box of a net.
\begin{options}
|*| & background filled \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\source|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws a labelled source centered on $(x,y)$.
\begin{options}
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\sourcesize=|dimen\\
Sets the size of sources.
%
\item |\store|\<|"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws a labelled store centered on $(x,y)$.
\begin{options}
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\storesize=|dimen\\
Sets the size of stores.
%
\item |\text|\<|"|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws an unboxed labelled node centered on $(x,y)$.
\begin{options}
|"| & label in text mode \\
\end{options}
%
\item |\trans|\<|*"=![|options|]|\>|{|name|}|$(x,y)$\<label\>\n\\
Draws a labelled transition centered on $(x,y)$.
\begin{options}
|*| & automatic size \\
|"| & label in text mode \\
|=| & double line \\
|!| & thick line \\
|[|options|]| & PSTricks options \\
\end{options}
%
\item |\transsize=|dimen\\
Sets the size of transitions.
\end{itemize}

\end{document}