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 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.

\usetikzlibrary{shapes,arrows,positioning}
   \usepackage{wrapfig}
  \usepackage{graphicx}
   \resizebox{.4\textwidth}{!}{\begin{tikzpicture}[
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);

\end{tikzpicture}}
share|improve this question

1 Answer 1

\path [line] (a) -- node [sloped] {p1} (b) 

it works

share|improve this answer
4  
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

 
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.