程序包 pgf 错误:没有已知的名为 X 的形状

程序包 pgf 错误:没有已知的名为 X 的形状

我无法编译此文档:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes,arrows,shapes}
\begin{document}
\begin{tikzpicture}[>=latex',line join=bevel,]

  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (140.1bp,19bp) node {310e} edge [loop below]  ();
  \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
  \pgfsetstrokecolor{strokecol}
  \draw (28bp,55.424bp) node {311r} edge [loop left]  ();

%

%%circles around nodes
%31-, 310e and 311r
%fail here
\draw (311r) -- (310e);
\end{tikzpicture}
\end{document}
%

当我添加最后一个绘制命令时,它失败了Package pgf Error: No shape named 311r is known.,另一个命令用“310e”代替“311r”。我只需要能够以节点为锚点绘制线条。有人能告诉我我做错了什么吗?

答案1

正如评论中所说,你必须命名节点,这意味着你需要做的就是

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{snakes,arrows,shapes}
\begin{document}
    \begin{tikzpicture}[>=latex',line join=bevel,]

    \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
    \pgfsetstrokecolor{strokecol}
    \draw (140.1bp,19bp) node(310e) {310e} edge [loop below]  ();
    \definecolor{strokecol}{rgb}{0.0,0.0,0.0};
    \pgfsetstrokecolor{strokecol}
    \draw (28bp,55.424bp) node(311r) {311r} edge [loop left]  ();

    %%circles around nodes
    %31-, 310e and 311r
    %fail here
    \draw (311r) -- (310e);
    \end{tikzpicture}
\end{document}

无论如何,您的代码看起来很有趣,因为没有必要pgfsetstrokecolordefinecolor并且位置准确。您确定需要它们吗?也许\usetikzlibrary{positioning}会对您有所帮助(16.5.3 高级放置选项在里面tikz/pgf手动的)。

相关内容