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.

For arrows I have gone through options like ->, ->>, <-, <<- but havent found one for making the arrowhead appear in the center of the line of the curve (something like ->-) How do I do it in TIkz?

share|improve this question
2  
With the library \usetikzlibrary{decorations.markings} see the pagraph "Arrow Tip Markings" in the pgfmanual or look at some examples in several answers here. –  Alain Matthes Dec 25 '11 at 7:39
    
Not exactly the same, but I asked a question a while ago about drawing an arrow head in the middle of an ellipse: tex.stackexchange.com/questions/1260/… but I have found the syntax a bit unwieldy. –  bryn Dec 25 '11 at 7:57
add comment

2 Answers

up vote 21 down vote accepted

Perhaps you prefer this kind of syntax :

\documentclass{scrartcl}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}
\tikzset{->-/.style={decoration={
  markings,
  mark=at position #1 with {\arrow{>}}},postaction={decorate}}}

\begin{tikzpicture}
 \draw[->-=.5] (0,0) to [bend left] (2,4);
 \draw[->-=.8] (0,0) to [bend right] (2,4);
\end{tikzpicture}

\end{document} 

If you only want an arrow in the middle of a path, you can write

\tikzset{->-/.style={decoration={
  markings,
  mark=at position .5 with {\arrow{>}}},postaction={decorate}}}

And the you just need to write :

 \draw[->-] (0,0) to [bend left] (2,4);

enter image description here

share|improve this answer
1  
Aha, that's a neat syntax! –  percusse Dec 25 '11 at 9:00
add comment

You can define a new line style and decorate it. (as Altermundus commented and also given in this answer)

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}

\tikzset{middlearrow/.style={
        decoration={markings,
            mark= at position 0.5 with {\arrow{#1}} ,
        },
        postaction={decorate}
    }
}

\begin{tikzpicture}
\draw[middlearrow={<}] (0,0) -- (20:2);
\draw[middlearrow={>}] (0,0) -- (40:2);
\draw[middlearrow={|}] (0,0) -- (60:2);
\draw[middlearrow={stealth reversed}] (0,0) -- (80:2);
\draw[middlearrow={latex}] (0,0) arc (50:-40:-1.5);
\end{tikzpicture}
\end{document}

enter image description here

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.