Take the 2-minute tour ×

I wish to draw arrows not necessarily at the end of the line, nor in the middle. I would also like to write a node directly above (or below, or to the right, ...) the arrow.

I saw this question, but it doesn't answer all my questions - first of all, it puts the arrow in the middle of the line. I know I can modify that by playing with mark=at position 0.5, but it's very possible that I'd like a certain position in one line, and a different in the other, i.e. use \draw[mystyle 0.5] for the middle, \draw[mystyle 0.75] for having it three-quarters way through etc.. In addition it doesn't solve the nodes issue.

Can anyone give me a hand please?

share|improve this question
Do you mean arrowheads instead of arrows? –  percusse Dec 16 '11 at 23:42
I suppose, yes - I mean the little triangles with no third edge. –  Jon Dec 16 '11 at 23:49
Is this close to your goal? \usetikzlibrary{decorations.markings,arrows} \begin{tikzpicture}[decoration={ markings, mark=at position 0.4 with {\arrow{>},\node[sloped,transform shape,above] {A};} } ] \draw[postaction={decorate}] (0,0) -- (1,2) ; \end{tikzpicture} –  percusse Dec 17 '11 at 0:10
Well, it's close in the sense that the text does appear next to the arrowhead. It's not precisely what I'm looking for because (1) it sets it as default, i.e. if I just use \draw and two points I get that, (2) it sets the text (as "A") and (3) I have no control on the position of the arrow. Thank you! –  Jon Dec 17 '11 at 0:38
Thanks for the quick reply! The thing is, that once you set the decoration right after the \begin{tikzpicture}, it is final - I can no longer change the value 0.4, nor the text - or can I? Anyway, if I indeed do as you suggested in (1), it works - I can set pretty much whatever I want for every arrow. The only problem is that it is a bit long - but I'll live with that... P.S. is it possible to have two or more arrowheads (and draw only on top of one of them)? –  Jon Dec 17 '11 at 0:54

1 Answer 1

up vote 10 down vote accepted

Based on our discussion I think the following style definition does the trick.


nodewitharrow/.style 2 args={                
                        mark=at position {#1} with { 
                                    \node[transform shape,above] {#2};

\draw[nodewitharrow={0.6}{Node text},nodewitharrow={0.2}{Second}] (0,0) -- (4,3) ;
\draw[nodewitharrow={0.75}{\tiny Tiny}] (0,0) (4,0) arc (0:60:2);

enter image description here

Note that you can apply more than once. If you want to change orientation of the text, you can further define a third argument for extra node options e.g. selecting above,below,right, left etc.

share|improve this answer
That's perfect for me. Thanks! –  Jon Dec 17 '11 at 1:21

Your Answer


