# Tikz: Arrowheads in the center

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?

• 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
• A possible duplicate of tex.stackexchange.com/questions/3161/…. – Piotr Migdal Jul 11 '14 at 13:27

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);


• Aha, that's a neat syntax! – percusse Dec 25 '11 at 9:00
• And if you add ->-/.default=0.5 at the first definition, it's practically perfect! Thanks! – Rmano Dec 15 '15 at 11:31
• Is it possible to modify this so that \draw[->-] (0,0) -- (1,0) -- (1,1) -- (0,1) -- cylce; would create a square such that there is an arrowhead on every edge? With the code at hand this unfortunately leads to a path where there is only 1 arrowhead at the middle of the total path length. – Hyperplane Apr 25 '17 at 17:46

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}