软件包 pgfkeys 错误:我不知道密钥‘/tikz/tokens’

软件包 pgfkeys 错误:我不知道密钥‘/tikz/tokens’

我正在尝试使用 tikz 创建一个非常基本的 Petri 网,但一直出现标题中显示的错误。我使用的代码如下。

\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri,positioning}

    \begin{tikzpicture}[node distance=2cm,>=stealth',bend angle=45,auto]

    \tikzstyle{place}=[circle,thick,draw=black!75,minimum size=12mm]
    \tikzstyle{transition}=[rectangle,thick,fill=black,minimum height=10mm,minimum width=2mm,inner ysep=2pt, inner xsep=2pt]

    \begin{scope}
    \node [place,tokens=2,label=left:condition 1] (p1) {};
    \node [place,label=left:condition 2] (p2) [below of=p1] {};
    \node [place,label=left:condition 3] (p3) [below of=p2] {};
    \node [transition,label=right:machine function] (q3) [right of=p2] {}
    edge [pre] node {1} (p1)
    edge [pre] node {2} (p2)
    edge [pre] node {3} (p3);
    \end{scope}

    \end{tikzpicture}

奇怪的是,在我之前的文档中,我使用下面的代码来表示另一个 Petri 网示例,其中包含标记,并且运行良好,但大约一页之后上述代码失败了。任何帮助修复此问题的人都将不胜感激。谢谢!

\usetikzlibrary{arrows,shapes,snakes,automata,backgrounds,petri,positioning}
    \begin{tikzpicture}[node distance=2cm,>=stealth',bend angle=45,auto]

    \tikzstyle{place}=[circle,thick,draw=black!75,minimum size=12mm]
    \tikzstyle{transition}=[rectangle,thick,fill=black,minimum height=10mm,minimum width=2mm,inner ysep=2pt, inner xsep=2pt]


    \begin{scope}
    \node [place,tokens=1,label=above:$p_1$] (p1) {};
    \node [transition, label=above:$q_1$] (q1) [right of=p1] {}
    edge [pre] (p1);
    \node [place,label=above:$p_2$] (p2) [right of=q1] {}
    edge [pre] (q1);
    \node [transition,label=above:$q_2$] (q2) [below of=q1] {}
    edge [pre] (p1)
    edge [post] (p2);
    \node [place,tokens=3,label=above:$p_3$] (p3) [below of=p2] {}
    edge [pre] (q2);
    \node [transition,label=above:$q_3$] (q3) [below right of=p2] {}
    edge [pre] (p2)
    edge [pre] (p3);
    \node [place,tokens=2,label=above:$p_4$] (p4) [right of=q3] {}
    edge [pre] (q3);
    \end{scope}

    \end{tikzpicture}

相关内容