Graphics, Figures & TablesA Petri-net from TikZ & PGF Manual for Version 3.0.1a

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Brunotvs
Posts: 2
Joined: Fri Jul 19, 2019 4:40 am

A Petri-net from TikZ & PGF Manual for Version 3.0.1a

Post by Brunotvs »

I was following the TikZ & PGF Manual for Version 3.0.1a, and when I try the second example from chapter 3 I get an error saying 'Missing \endcsname inserted.' on [11, 1]

My installed pgf version is 3.1.4a and using pdflatex.

Log file attatched

The .tex file (the full code from the example):

\documentclass{paper}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}

\begin{document}
\begin{tikzpicture}
[node distance=1.3cm,on grid,>=stealth’,bend angle=45,auto,
every place/.style= {minimum size=6mm,thick,draw=blue!75,fill=blue!20},
every transition/.style={thick,draw=black!75,fill=black!20},
red place/.style= {place,draw=red!75,fill=red!20},
every label/.style= {red}]

\node [place,tokens=1] (w1) {};
\node [place] (c1) [below=of w1] {};
\node [place] (s) [below=of c1,label=above:$s\le 3$] {};
\node [place] (c2) [below=of s] {};
\node [place,tokens=1] (w2) [below=of c2] {};

\node [transition] (e1) [left=of c1] {}
edge [pre,bend left] (w1)
edge [post,bend right] (s)
edge [post] (c1);
\node [transition] (e2) [left=of c2] {}
edge [pre,bend right] (w2)
edge [post,bend left] (s)
edge [post] (c2);
\node [transition] (l1) [right=of c1] {}
edge [pre] (c1)
edge [pre,bend left] (s)
edge [post,bend right] node[swap] {2} (w1);
\node [transition] (l2) [right=of c2] {}
edge [pre] (c2)
edge [pre,bend right] (s)
edge [post,bend left] node {2} (w2);

\begin{scope}[xshift=6cm]
\node [place,tokens=1] (w1’) {};
\node [place] (c1’) [below=of w1’] {};
\node [red place] (s1’) [below=of c1’,xshift=-5mm]
[label=left:$s$] {};
\node [red place,tokens=3] (s2’) [below=of c1’,xshift=5mm]
[label=right:$\bar s$] {};
\node [place] (c2’) [below=of s1’,xshift=5mm] {};
\node [place,tokens=1] (w2’) [below=of c2’] {};

\node [transition] (e1’) [left=of c1’] {}
edge [pre,bend left] (w1’)
edge [post] (s1’)
edge [pre] (s2’)
edge [post] (c1’);
\node [transition] (e2’) [left=of c2’] {}
edge [pre,bend right] (w2’)
edge [post] (s1’)
edge [pre] (s2’)
edge [post] (c2’);
\node [transition] (l1’) [right=of c1’] {}
edge [pre] (c1’)
edge [pre] (s1’)
edge [post] (s2’)
edge [post,bend right] node[swap] {2} (w1’);
\node [transition] (l2’) [right=of c2’] {}
edge [pre] (c2’)
edge [pre] (s1’)
edge [post] (s2’)
edge [post,bend left] node {2} (w2’);
\end{scope}

\begin{scope}[on background layer]
\node (r1) [fill=black!10,rounded corners,fit=(w1)(w2)(e1)(e2)(l1)(l2)] {};
\node (r2) [fill=black!10,rounded corners,fit=(w1’)(w2’)(e1’)(e2’)(l1’)(l2’)] {};
\end{scope}

\draw [shorten >=1mm,-to,thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(r1) -- (r2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the \textcolor{red}{capacity} by \textcolor{red}{two places}};
\end{tikzpicture}

\end{document}
Attachments
document.log
Log file
(61.26 KiB) Downloaded 176 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX books
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

A Petri-net from TikZ & PGF Manual for Version 3.0.1a

Post by Ijon Tichy »

You've used ’ instead of '. Use the correct character and it should work:
\documentclass{paper}
\usepackage{tikz}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}

\begin{document}
\begin{tikzpicture}
[node distance=1.3cm,on grid,>=stealth',bend angle=45,auto,
every place/.style= {minimum size=6mm,thick,draw=blue!75,fill=blue!20},
every transition/.style={thick,draw=black!75,fill=black!20},
red place/.style= {place,draw=red!75,fill=red!20},
every label/.style= {red}]

\node [place,tokens=1] (w1) {};
\node [place] (c1) [below=of w1] {};
\node [place] (s) [below=of c1,label=above:$s\le 3$] {};
\node [place] (c2) [below=of s] {};
\node [place,tokens=1] (w2) [below=of c2] {};

\node [transition] (e1) [left=of c1] {}
edge [pre,bend left] (w1)
edge [post,bend right] (s)
edge [post] (c1);
\node [transition] (e2) [left=of c2] {}
edge [pre,bend right] (w2)
edge [post,bend left] (s)
edge [post] (c2);
\node [transition] (l1) [right=of c1] {}
edge [pre] (c1)
edge [pre,bend left] (s)
edge [post,bend right] node[swap] {2} (w1);
\node [transition] (l2) [right=of c2] {}
edge [pre] (c2)
edge [pre,bend right] (s)
edge [post,bend left] node {2} (w2);

\begin{scope}[xshift=6cm]
\node [place,tokens=1] (w1') {};
\node [place] (c1') [below=of w1'] {};
\node [red place] (s1') [below=of c1',xshift=-5mm]
[label=left:$s$] {};
\node [red place,tokens=3] (s2') [below=of c1',xshift=5mm]
[label=right:$\bar s$] {};
\node [place] (c2') [below=of s1',xshift=5mm] {};
\node [place,tokens=1] (w2') [below=of c2'] {};

\node [transition] (e1') [left=of c1'] {}
edge [pre,bend left] (w1')
edge [post] (s1')
edge [pre] (s2')
edge [post] (c1');
\node [transition] (e2') [left=of c2'] {}
edge [pre,bend right] (w2')
edge [post] (s1')
edge [pre] (s2')
edge [post] (c2');
\node [transition] (l1') [right=of c1'] {}
edge [pre] (c1')
edge [pre] (s1')
edge [post] (s2')
edge [post,bend right] node[swap] {2} (w1');
\node [transition] (l2') [right=of c2'] {}
edge [pre] (c2')
edge [pre] (s1')
edge [post] (s2')
edge [post,bend left] node {2} (w2');
\end{scope}

\begin{scope}[on background layer]
\node (r1) [fill=black!10,rounded corners,fit=(w1)(w2)(e1)(e2)(l1)(l2)] {};
\node (r2) [fill=black!10,rounded corners,fit=(w1')(w2')(e1')(e2')(l1')(l2')] {};
\end{scope}

\draw [shorten >=1mm,-to,thick,decorate,
decoration={snake,amplitude=.4mm,segment length=2mm,
pre=moveto,pre length=1mm,post length=2mm}]
(r1) -- (r2) node [above=1mm,midway,text width=3cm,align=center]
{replacement of the \textcolor{red}{capacity} by \textcolor{red}{two places}};
\end{tikzpicture}

\end{document}
BTW: In the current manual of TikZ/pgf 3.1.4 the example is in section 3.14, “The Complete Code”.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Brunotvs
Posts: 2
Joined: Fri Jul 19, 2019 4:40 am

A Petri-net from TikZ & PGF Manual for Version 3.0.1a

Post by Brunotvs »

And it worked just fine, thank you sir.
User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

A Petri-net from TikZ & PGF Manual for Version 3.0.1a

Post by Ijon Tichy »

As I understand, you've installed a current version of TikZ/pgf. So you should also have the current manual on your computer. Try, e.g.,
texdoc pgf
in a terminal.

If is is not installed, you should reconfigure the package manager to also install the package manuals. As a workaround you could try the one from CTAN. But it's better to use the manuals of the installed package versions.
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Post Reply