Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Some of my tikzpicture code won't compile anymore. The following code used to compile (2 years ago), but now I get

"ABD: EveryShipout initializing macros
! Package pgf Error: No shape named B is known.

! Package pgf Error: No shape named B is known.

See the pgf package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.15 \WE(B){A}"

I have installed the latest pgf package, but it doesn't make a difference. Here is the code.

\documentclass[12pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage {amssymb,amsmath,amsfonts,amsthm,verbatim,pgfpict2e}
\usepackage{tikz,tkz-berge}

 \begin{document}


\begin{tikzpicture}[scale=1.4]
\GraphInit[vstyle=Dijkstra]
\tikzset{node distance = 5.25cm}
\tikzstyle{EdgeStyle}= [thick]
\Vertices*{square}{E,D,C,B}
\tikzset{node distance = 2.75cm}
\WE(B){A}
\SO(B){G}
\WE(G){F}
\tikzset{node distance = 3cm}
\SOEA(B){H}

\Edge[label=$20$](A)(B)
\Edge[label=$70$](B)(C)
\Edge[label=$40$](A)(F)
\Edge[label=$30$](F)(G)
\Edge[label=$30$](G)(H)
\Edge[label=$20$](B)(H)
\Edge[label=$50$](H)(D)
\Edge[label=$70$](F)(E)
\Edge[label=$50$](E)(D)
\Edge[label=$50$](G)(D)
\Edge[label=$70$](C)(D)
\end{tikzpicture}
  \end{document}
share|improve this question

1 Answer 1

The problem here is not directly related to pgf, but to the tkz collection by Alain Matthes. I guess he has made updates to this (specifically tkz-graph) that makes your code not work.

You could of course try to find an older version of tkz-graph, but I would rather update the code. I don't know exactly how this was supposed to look, but the code below generates the following output:

enter image description here

The changes I made to the code:

  • \Vertices* to \Vertices. The starred version of the command doesn't seem to do anything, so remove the *.

  • \tikzstyle to \tikzset: The latter is recommended, though the former still works. (Should \tikzset or \tikzstyle be used to define TikZ styles?)

  • \tikzset{node distance = ...} to \SetGraphUnit{}: The former had no effect, but tkz-graph provides the latter that does a similar job I guess. For the \Vertices the unit is added as an optional argument.

  • \usepackage{tkz-berge} to \usepackage{tkz-graph}. The former loads the latter, so this is not a big deal really, but the commands you use are really provided by tkz-graph.

Unrelated note: You shouldn't pass the pdftex option to graphicx, the packages can figure this out for themselves. See e.g. this answer by Martin Scharrer

\documentclass[12pt]{standalone}
\usepackage{tkz-graph}
\begin{document}

\begin{tikzpicture}[scale=1.4]
\GraphInit[vstyle=Dijkstra]
\tikzset{EdgeStyle/.style ={thick}}
\Vertices[unit=5.25cm]{square}{E,D,C,B}
\SetGraphUnit{2.75cm}
\WE(B){A}
\SO(B){G}
\WE(G){F}
\SetGraphUnit{3cm}
\SOEA(B){H}

\Edge[label=$20$](A)(B)
\Edge[label=$70$](B)(C)
\Edge[label=$40$](A)(F)
\Edge[label=$30$](F)(G)
\Edge[label=$30$](G)(H)
\Edge[label=$20$](B)(H)
\Edge[label=$50$](H)(D)
\Edge[label=$70$](F)(E)
\Edge[label=$50$](E)(D)
\Edge[label=$50$](G)(D)
\Edge[label=$70$](C)(D)
\end{tikzpicture}
\end{document}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.