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.

I found TikZ code for drawing an icosahedron here:

\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\documentclass[a4paper]{amsart}
\usepackage{graphics, tikz, tkz-berge, tkz-graph}
\begin{document}
\begin{figure}
\begin{tikzpicture}
  \begin{scope}[rotate=90]
    \grIcosahedral[form=1,RA=3,RB=1.5]
    \SetUpEdge[color=white,style={double=black,double distance=2pt}]
    \EdgeInGraphLoop{a}{6}
    \EdgeFromOneToSel{a}{b}{0}{1,5}
    \Edges(a2,b1,b3,b5,a4)
    \Edge(a3)(b3)
    \Edges(a1,b1,b5,a5)
    \Edges(a2,b3,a4)
  \end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

The output is:

icosahedron

which is very nice, but I want to label the vertices v_1, v_2, ..., v_12 instead of a's and b's. However, I don't know how to change the code so that the labels will be different. I tried to simply replace all the a's in the code by v's but that gives an error.

share|improve this question
1  
Welcome to TeX.SX. Please complete your example in order to make it compilable. I added the packages tikz, tkz-berge, and tkz-graph but it does not compile. I am happy to help, but can't guess what you are doing. –  LaRiFaRi Jun 4 at 8:23
    
Hi, I'm sorry, I did not realise that. I used graphics, tikz, tkz-berge and tkz-graph. –  Jolien Jun 4 at 8:31
1  
Welcome to TeX.SX! As @LaRiFaRi says, please help us to help you and add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document} –  tohecz Jun 4 at 8:32
    
@Jolien Which documentclass? Which error do you get? I can't compile your code. Do I need other packages than the mentioned? –  LaRiFaRi Jun 4 at 8:48
    
@LaRiFaRi I used \NeedsTeXFormat{LaTeX2e}[1995/06/01] and \documentclass[a4paper]{amsart}. The error is ! Package pgf Error: No shape named v5 is known. –  Jolien Jun 4 at 8:57
add comment

1 Answer 1

up vote 11 down vote accepted

The macro \grIcosahedral is not documented in tkz-berge manual. However all other graphs in the manual behave in a similar way, so it can be deduced what to do to relabel those nodes.

Internally, all generated graphs define node names based on the a0, a1, ..., b0, b1, etc notation. Changing those internal node names is not easy. However, you can easily change which label is displayed in the printed graph for each of those internal names. So, you can tell for example that node a0 has to be labelled $v_1$, or whatever you like.

This is how:

\documentclass[a4paper]{amsart}
\usepackage{graphics, tikz, tkz-berge, tkz-graph}
\begin{document}
\begin{figure}
\begin{tikzpicture}
  \begin{scope}[rotate=90]
    \SetVertexNoLabel   % <--- This avoids that default $a_0$, .. $b_0$ labels show up
    \grIcosahedral[form=1,RA=3,RB=1.5]

    % Following two lines assign labels to a-like and b-like nodes
    % change it as you prefer
    \AssignVertexLabel{a}{$v_0$, $v_1$, $v_2$, $v_3$, $v_4$, $v_5$};
    \AssignVertexLabel{b}{$v_6$, $v_7$, $v_8$, $v_9$, $v_{10}$, $v_{11}$};

    % The remaining code is unchanged
    \SetUpEdge[color=white,style={double=black,double distance=2pt}]
    \EdgeInGraphLoop{a}{6}
    \EdgeFromOneToSel{a}{b}{0}{1,5}
    \Edges(a2,b1,b3,b5,a4)
    \Edge(a3)(b3)
    \Edges(a1,b1,b5,a5)
    \Edges(a2,b3,a4)
  \end{scope}
\end{tikzpicture}
\end{figure}
\end{document}

Result

share|improve this answer
add comment

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.