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 add text captions on edges but I can't make it work.

\begin{tikzpicture}[shorten >=1pt,-]

\tikzstyle{vertex}=[circle,fill=black!25,minimum size=17pt,inner sep=0pt]                   
\foreach \name/\angle/\text in {P-0/234/0, P-1/162/1, 
                                P-2/90/2, P-3/18/3, P-4/-54/4}
  \node[vertex,xshift=6cm,yshift=.5cm] (\name) at (\angle:1.5cm) {$\text$};

\foreach \from/\to in {0/4, 4/1,1/2,2/4,0/3}
 { 
  \draw (P-\from) -- (P-\to);
 }
\end{tikzpicture}

Could someone help me? Thanks!

share|improve this question
    
What do you want on the edge? –  Leo Liu Jan 7 '11 at 12:44
    
For example text: "e_1" and so on –  MartyIX Jan 7 '11 at 12:48
    
It's good that you mark your code block. It's even better if you indent by just 4 spaces (and use only a bit of further indentation). –  Hendrik Vogt Jan 7 '11 at 12:58
    
@Hendrik: I had the code indented with more spaces and I was looking for a way how to "unintend" the block of text when asking the question? Or do I need to do that in an external text editor? –  MartyIX Jan 7 '11 at 13:14
    
You had a lot of tab stops in it. The best way is to insert the code without any extra indentation (and without any tab stops); then highlight the code and click the "code" button (with "101010" on it). –  Hendrik Vogt Jan 7 '11 at 13:30
add comment

1 Answer

up vote 4 down vote accepted

For example, \draw (P-\from) -- node {\from\ to \to} (P-\to); And you can use more options to change the style:

\draw (P-\from) -- node[auto,sloped,font=\footnotesize] {\from\ to \to} (P-\to);
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.