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 have been using tikz-graph to draw graphs representing two-part protocols. Now I'd like to add comments to some nodes of the graph (multiline text, to the side of the vertex). I'm not sure how to do that. I have been adding labels to vertices and putting them outside with LabelOut, but then I can't do multiline text. This is a toy/minimalistic example:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage{tkz-graph}

\usepackage{graphicx}  
\usepackage[T1]{fontenc}

\begin{document}

\begin{tikzpicture}
  \SetUpEdge[lw = 1.5pt,
             color=black,
             labelstyle = {sloped}]
  \SetVertexNoLabel
  \GraphInit[vstyle=Art]
  \tikzset{EdgeStyle/.style={post}}
  \tikzset{node distance = 6 cm}
  \SetVertexMath

  % Two top symbols, displayed as two invisible
  % vertices with visible labels:
  {\tikzset{VertexStyle/.style = {color=white,text=black}}
    \SetVertexLabel
    \Vertex[L=\alpha]{P}
    \SetVertexLabel
    \Vertex[position={right of=P}, L={\beta}]{X}}

  \tikzset{node distance = 1 cm}
  {\SetVertexLabel
   %%%
   %%% HERE: in the next line the label can't be split in two lines...
   \Vertex[LabelOut,Lpos=180,position={below of=P}, L={the protocol starts here}]{X1}
  }
  \tikzset{node distance = 2 cm}
  \SO(X1){X2}
  \SO(X2){X3}
  \tikzset{node distance = 6 cm}

  \EA(X1){A1}
  \EA(X2){A2}
  \Edge[label={220 ESMTP}](X1)(A1)
  \Edge[label={EHLO client-host}](A1)(X2)
  \Edge[label={250 DSN}](X2)(A2)
  \Edge[label={mail from: email-address}](A2)(X3)
\end{tikzpicture}
\end{document}

What wold be the usual, easy way to do what I'm trying to do?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

I'm the author of this package. The good news are the new versions of tkz-graph and tkz-berge will be on the ctan servers this week (i'm working on the docs actually), the bad news are that I modified some macros. I'm not sure to understand exactly what you want but an answer is that you can put TikZ's code inside you code.

Vertices are nodes so you can add multiple labels if you want with the option label= , if you want adding a text you can use the option text width

something like :

  \SO(P){X1}
  \node[text width=2cm,left=1cm] (X1){the protocol starts here};

Another possibility :

\begin{tikzpicture}
{  \SetVertexNoLabel   
   \Vertex[style={label=60:A}]{A}}
 \SO[Lpos=180,
     LabelOut,
     L= {the protocol starts here},
     style={text width=2cm}](A){B}
 \end{tikzpicture}

But there are other ways to do this. You can use label. In your code you used "position" , it's not very fine because it's a problem to use "scale".

In 12 hours, I will upload the new version of tkz-graph. I the new version node distanceis obsolete, now I added an option unit and a macro \tkzGraphUnit=6 instead of `\tikzset{node distance=6cm}.

share|improve this answer
    
Wow, that's really good news! Thanks a lot for your help. I'll wait for the new version on CTAN then. –  Jay Feb 28 '11 at 10:13
1  
@Jay: you can find the new version of tkz-graph and tkz-berge here : altermundus.com/pages/downloads/index.html and I put some examples for tkz-graph here : altermundus.com/pages/tkz/graph/index.html and for tkz-berge : altermundus.com/pages/tkz/berge/index.html. There is also a document about Named Graphs. You need to wait some days if you want to see these packages on CTAN. –  Alain Matthes Feb 28 '11 at 23:25
    
Thanks a huge lot! :-) –  Jay Mar 1 '11 at 11:00
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.