1

Why doesn't this code compile?

\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Classic]
\SetGraphUnit{2}
\Vertices{circle}{A,B,C,D}
\Edges(A,B,C,D,A,C)
\SetVertexNoLabel
\AddVertexColor{red}{B,D}
\AddVertexColor{green}{A}
\AddVertexColor{blue}{C}
\end{tikzpicture}
\end{document}
  • 2
    You need to load the correct package from tkz-collection. – Claudio Fiandrino Jul 21 '14 at 14:54
  • I have package tikz – benedito Jul 21 '14 at 14:58
  • 1
    tikz is not enough. You need some of the tkz packages that build upon tikz – daleif Jul 21 '14 at 15:04
  • The commands \GraphInit, \SetGraphUnit, \Vertices and so on are not provided by \usepackage{tikz}, but by another package based on TikZ. Possibly \usepackage{tkz-graph}. – egreg Jul 21 '14 at 15:05
  • 2
    In the future try to include the error message you received at the point the compilation halted. That is useful information that can help others (or maybe even yourself) solve the problem. – Matthew Leingang Jul 21 '14 at 15:46
4

The commands you use are not standard TikZ commands, but rely on an extension of it called tkz-graph.

\documentclass{article}

\usepackage{tkz-graph} % <---- HERE!

\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Classic]
\SetGraphUnit{2}
\Vertices{circle}{A,B,C,D}
\Edges(A,B,C,D,A,C)
\SetVertexNoLabel
\AddVertexColor{red}{B,D}
\AddVertexColor{green}{A}
\AddVertexColor{blue}{C}
\end{tikzpicture}
\end{document}

enter image description here

|improve this answer|||||
5

Using an additional package works. See your code with this package below.

\documentclass{article}
\usepackage{tikz}
\usepackage{tkz-graph} % needed package
\begin{document}
\begin{tikzpicture}
\GraphInit[vstyle=Classic]
\SetGraphUnit{2}
\Vertices{circle}{A,B,C,D}
\Edges(A,B,C,D,A,C)
\SetVertexNoLabel
\AddVertexColor{red}{B,D}
\AddVertexColor{green}{A}
\AddVertexColor{blue}{C}
\end{tikzpicture}
\end{document}

This compiles to the following

Example

A more in depth question using the same package can be found here (also on stackexchange).

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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