嘿,我必须使用 Tikz 说明一些网络,第一个在 tikz 中看起来像这样:
\usetikzlibrary{arrows,automata}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2cm,
semithick]
%\tikzstyle{every state}=[fill=red,draw=none,text=white]
\node[state] (A) {$A$};
\node[state] (C) [below right of=A] {$C$};
\node[state] (B) [below left of=C] {$B$};
\node[state] (D) [right of=C] {$D$};
\node[state] (E) [above right of=D] {$E$};
\node[state] (F) [below right of=D] {$F$};
\path (A) edge node {a} (C)
edge node {a} (E)
(B) edge node {b} (C)
edge node {b} (F)
(C) edge node {a + b} (D)
(D) edge node {a + b} (E)
edge node {a + b} (F);
\end{tikzpicture}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End:
一个非常简单的蝴蝶网络,如果我只用这个 Tikzpicture 进行编译,则没有问题。但是,如果我添加另一个 Tizpicture,例如一个简单的 hub-by-hub 网络:
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=2cm,
semithick]
%\tikzstyle{every state}=[fill=red,draw=none,text=white]
\node[state] (A) {$E$};
\node[state] (B) [right of=A] {$X$};
\node[state] (C) [right of=B] {$X$};
\node[state] (D) [right of=C] {$D$};
\path (A) edge node {} (B)
(B) edge node {} (C)
(C) edge node {} (D);
\end{tikzpicture}
我开始收到这个错误:
! Package pgfkeys Error: I do not know the key '/tikz/state' and I am going to
ignore it. Perhaps you misspelled it.
我根本不知道哪里出了问题,希望有人能帮助我
答案1
\usetikzlibrary{arrows,automata}
可能在其中一个图片文件中本地加载,而第二个图片文件看不到automata
库。将库加载行移至前言应该可以解决这个问题。