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.

actually it's an easy question, but I could find an answer with Google or the included search on StackExchange ;)

How do I add in the middle of the line a node with Tikz? I want somethink like this:

-------------->
     text

Normally I did it with an additional node at command. If I will resize the the arrow then I need to change the position of the node also.

---------->
   text

Which is not the best way for big things. I try to find something in the manual and didn't find an answer yet.

Thanks.

Best regards.

share|improve this question
    
Good question. But I think you have a missing "not" in your first sentence! –  Matthew Leingang May 2 '11 at 2:20
add comment

2 Answers

up vote 15 down vote accepted

You could also use the midway-option

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
    \draw [->] (0,0) -- (5,0) node [midway, below] {Text};
    \draw [->] (0,1) -- (5,1) node [near end, below] {Text};
    \draw [->] (0,2) -- (5,2) node [pos=0.62, below] {Text};
    \draw [->] (0,3) -- (5,3) node [pos=0.2, below] {Text};
\end{tikzpicture}
\end{document}

gives

result of the given example

See the tikz manual section 16.8 “Placing Nodes on a Line or Curve Explicitly”

share|improve this answer
    
Thanks. I was blind....I also found out that my version of tikz+manual is not the last one. –  PateToni May 3 '11 at 22:01
    
@PateToni Nor problem … –  Tobi May 4 '11 at 9:09
add comment

You can use the node construct without the at specifier:

\documentclass{article}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
  \draw[->] (0,0) --  node[label= below:text] {} (2,0);
  \draw[->] (0,1) --  node[label= below:text] {} (3,1);
\end{tikzpicture}

\end{document}

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.