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'm trying to draw a graph using tkz-berge, where many of the vertices might display the same value, is there a way I can do this?

Here is my code:

\begin{figure}[h]
\centering
\begin{tikzpicture}[scale=0.75,transform shape]
  \tikzstyle{LabelStyle}=[fill=white,sloped]
  \Vertex[x=0,y=0]{A}
  \Vertex[x=-2,y=-1]{B}
  \Vertex[x=2,y=-1]{C}
  \tikzstyle{EdgeStyle}=[post]
  \Edge[](A)(B)
  \Edge[](A)(C)
\end{tikzpicture}
\caption{\label{fig:typical}Cool graph}
\end{figure}

But instead of B<-A->C (is what this graph looks like), I'd like it to be, for example, something like B<-A->B. So basically I guess what I'm asking is, can I have the name of the vertex in the code be different from what is actually displayed on the screen (like a "label")?

P.S. I don't have enough reputation to create the tag 'tkz-berge', but there is a 'tkz-graph' tag. I can't tell if that package is different or an alternate name of berge, but it seems to be very similar, so tagging as that.

share|improve this question
add comment

1 Answer 1

up vote 7 down vote accepted

Use the L= option for \Vertex to have a different label:

\documentclass{article}
\usepackage{tkz-berge}
\usepackage{lipsum}

\begin{document}

\begin{figure}
\centering
\begin{tikzpicture}[scale=0.75,transform shape]
  \tikzstyle{LabelStyle}=[fill=white,sloped]
  \Vertex[x=0,y=0]{A}
  \Vertex[x=-2,y=-1]{B}
  \Vertex[x=2,y=-1,L=B]{C}
  \tikzstyle{EdgeStyle}=[post]
  \Edge[](A)(B)
  \Edge[](A)(C)
\end{tikzpicture}
\caption{\label{fig:typical}Cool graph}
\end{figure}

\end{document}

enter image description here

As a side note, don't use the too restrictive placement specifier [h].

share|improve this answer
    
That's exactly what I was looking for! Will look into the [h] as well, thanks. –  mindthief Oct 23 '12 at 1:47
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.