![矩阵中定义的节点出现“包 pgf 错误:没有已知形状”](https://linux22.com/image/334818/%E7%9F%A9%E9%98%B5%E4%B8%AD%E5%AE%9A%E4%B9%89%E7%9A%84%E8%8A%82%E7%82%B9%E5%87%BA%E7%8E%B0%E2%80%9C%E5%8C%85%20pgf%20%E9%94%99%E8%AF%AF%EF%BC%9A%E6%B2%A1%E6%9C%89%E5%B7%B2%E7%9F%A5%E5%BD%A2%E7%8A%B6%E2%80%9D%20.png)
在我的本地系统上,\graph 无法识别 \matrix 定义的节点
\documentclass{article} % say
\usepackage{tikz}
\usetikzlibrary{calc,intersections,through,backgrounds}
\usetikzlibrary{arrows,decorations.pathmorphing,backgrounds,positioning,fit,petri}
\usetikzlibrary{shapes.misc}
\usetikzlibrary{graphs}
% \usetikzlibrary{graphs.standard}
% \usetikzlibrary{graphdrawing}
\begin{document}
\begin{tikzpicture} [scale=1,
skip_loop/.style={
to path={-- ++(0,#1) -| (\tikztotarget)}},
hv_path/.style={
to path={-| (\tikztotarget)}},
vh_path/.style={
to path={|- (\tikztotarget)}},
nonterminal/.style={
rectangle,
minimum size=6mm,
very thick,
draw=red!50!black!50,
top color=white,
bottom color=red!50!black!20,
font=\itshape},
terminal/.style={
rectangle,minimum size=6mm, rounded corners=3mm,
very thick,draw=black!50,
top color=white,bottom color=black!20,
font=\ttfamily},
point/.style={
circle,inner sep=0pt,minimum size=2pt,fill=red}
]
\matrix[row sep=2mm,column sep=2mm] {
% First row:
& & & & & & & & & & & \node (plus) [terminal] {+}; \\
% Second row:
\node (p1) [point] {}; & \node (ui1) [nonterminal] {unsigned integer}; &
\node (p2) [point] {}; & \node (dot) [terminal] {.}; &
\node (p3) [point] {}; & \node (digit) [terminal] {digit}; &
\node (p4) [point] {}; & \node (p5) [point] {}; &
\node (p6) [point] {}; & \node (e) [terminal] {E}; &
\node (p7) [point] {}; & &
\node (p8) [point] {}; & \node (ui2) [nonterminal] {unsigned integer}; &
\node (p9) [point] {}; & \node (p10) [point] {}; &\\
% Third row:
& & & & & & & & & & & \node (minus) [terminal] {-}; \\
};
\graph {
% (p4) ->[skip_loop=-5mm] (p3);
% (p2) ->[skip_loop=5mm] (p6);
(p1) -> (ui1) -- (p2) -> (dot) -- (p3) -> (digit) -- (p4)
-- (p5) -- (p6) -> (e) -- (p7) -- (p8) -> (ui2) -- (p9) -> (p10);
(p4) ->[skip_loop=-5mm] (p3);
(p2) ->[skip_loop=5mm] (p5);
(p6) ->[skip_loop=-11mm] (p9);
(p7) ->[vh_path] (plus) -> [hv_path] (p8);
(p7) ->[vh_path] (minus) -> [hv_path] (p8);
};
\end{tikzpicture}
\end{document}
该代码在 sharelatex.com 上运行良好,但在我的系统上却出现错误:
./4_graphs.tex:119: Package pgf Error: No shape named (p1 is known. [ }]
./4_graphs.tex:119: Package tikz Error: Giving up on this path. Did you forget a semicolon?. [ }]
./4_graphs.tex:119: Package pgf Error: No shape named (ui1 is known. [ }]
./4_graphs.tex:119: Package tikz Error: Giving up on this path. Did you forget a semicolon?. [ }]
./4_graphs.tex:119: Package pgf Error: No shape named (p2 is known. [ }]
./4_graphs.tex:119: Package tikz Error: Giving up on this path. Did you forget a semicolon?. [ }]
... ... ... ...
... ... ... ...
... ... ... ...
./4_graphs.tex:119: Package pgfkeys Error: I do not know the key '/tikz/graphs/vh_path' and I am going to ignore it. Perhaps you misspelled it. [ }]
./4_graphs.tex:119: Package pgf Error: No shape named (p7 is known. [ }]
./4_graphs.tex:119: Package tikz Error: Giving up on this path. Did you forget a semicolon?. [ }]
./4_graphs.tex:119: Package pgfkeys Error: I do not know the key '/tikz/graphs/hv_path' and I am going to ignore it. Perhaps you misspelled it. [ }]
./4_graphs.tex:119: Package pgf Error: No shape named (minus is known. [ }]
./4_graphs.tex:119: Package tikz Error: Giving up on this path. Did you forget a semicolon?. [ }]
是版本问题吗?我在 ubuntu 14.10 上使用的是默认安装(ver 2013.20140215-1)。