[Tex/LaTex] Package pgf Error: No shape named X is known

errorsnodestikz-pgf

I can't get this document to compile:

\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}
%

It fails when I add that last draw command, saying Package pgf Error: No shape named 311r is known., and another with "310e" instead of "311r". I just need to be able to draw lines with nodes as the anchors. Can anyone tell me what I am doing wrong?

Best Answer

As said in comments you have to name the nodes, this means all you need to is

\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}

Anyway, your code looks interesting, because of the unnecessary pgfsetstrokecolor, definecolor and the exact positions. Are you sure you need them? Maybe \usetikzlibrary{positioning} will help you (16.5.3 Advanced Placement Options in the tikz/pgf manual).