TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to add the word in the line using the bellow code, now the picture is :enter image description here

I want to add the word "p1" in the line between "a" and "b" which looks like:

enter image description here

I try to modify the code to \path [line] (a) -- (b){p1}; but there is an error.

block/.style = {circle, draw,align=center,text width = 0.1cm, inner sep = 0.1cm},
    line/.style = {draw,thick, -latex'},
    node distance=0.9cm and 0.4cm

    % Place nodes
    \node [block] (a) {a};
    \node [block, below left of=a,xshift=-1.0cm, yshift=-0.3cm] (b) {b};
    \node [block, below right of=a,xshift=1.0cm, yshift=-0.3cm] (c) {c};
% Draw edges
\path [line] (a) -- (b);
\path [line] (a) -- (c);

share|improve this question
\path [line] (a) -- node [sloped] {p1} (b) 

it works

share|improve this answer
You can also include pos=0.5 to specify where the node line it should be place. While code snippets are useful in explanations, it is always best to post a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. – Peter Grill Aug 14 '12 at 14:45

Your Answer


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.