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.

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}
share|improve this question
2  
You need to load the correct package from tkz-collection. –  Claudio Fiandrino Jul 21 at 14:54
    
I have package tikz –  benedito Jul 21 at 14:58
1  
tikz is not enough. You need some of the tkz packages that build upon tikz –  daleif Jul 21 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 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 at 15:46

2 Answers 2

up vote 4 down vote accepted

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

share|improve this answer

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).

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.