# Tikz arrow part-way along line: fine tuning

The following code draws arrows at a mid point along the line:

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[
mid arrow/.style={
postaction={decorate,decoration={
markings,
mark=at position .5 with {\arrow{latex}}
}}
},
]
\draw[thin,gray,dashed] (0,-1) -- (0,1);
\draw[mid arrow] (-1,0.1) -- (1,0.1);
\draw[mid arrow] (1,-0.1) -- (-1,-0.1);
\end{tikzpicture}
\end{document}


The result is as expected:

Note that the tip of the arrow is the point of reference for where the marking gets placed, which is why the dashed gray line intersects the two tips. (In general, this is what you want: an arrow at the end of the line should have its tip at the end of the line!)

However, I would like these two arrows to be "centered" on the mid-line, such as this:

(I achieved this by adjusting the position of the marking to 0.54, but of course this is a hack that depends on the length of the line.)

Is there some way either to anchor an arrow somewhere other than at its tip, or otherwise tweak the positioning of the mark by, say, 3.2pt (which, in my actual use case, is half the length of the arrow)?

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta}
\begin{document}
\begin{tikzpicture}[
mid arrow/.style={
postaction={decorate,decoration={
markings,
mark=at position .5 with {\arrow{Latex[length=6.4pt, sep=-3.2pt -1]}}
}}
},
]
\draw[thin,gray,dashed] (0,-1) -- (0,1);
\draw[mid arrow] (-1,0.1) -- (1,0.1);
\draw[mid arrow] (1,-0.1) -- (-1,-0.1);
\draw[mid arrow, ultra thick] (-1,-0.4) -- (1,-0.4);
\draw[mid arrow, ultra thick] (1,-0.6) -- (-1,-0.6);
\end{tikzpicture}
\end{document}


Edit: The extra line width shift sep=-3.2pt -1 is wrong - this can be seen when making the arrow red

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{decorations.markings, arrows.meta}
\begin{document}
\begin{tikzpicture}[
mid arrow/.style={
postaction={decorate,decoration={
markings,
mark=at position .5 with {\arrow{Latex[length=6.4pt, sep=-3.2pt, red]}}
}}
},
]
\draw[thin,gray,dashed] (0,-1) -- (0,1);
\draw[thin,gray,dashed, xshift=3.2pt] (0,-1) -- (0,1);
\draw[thin,gray,dashed, xshift=-3.2pt] (0,-1) -- (0,1);
\draw[mid arrow] (-1,0.1) -- (1,0.1);
\draw[mid arrow] (1,-0.1) -- (-1,-0.1);
\draw[mid arrow, ultra thick] (-1,-0.4) -- (1,-0.4);
\draw[mid arrow, ultra thick] (1,-0.6) -- (-1,-0.6);
\end{tikzpicture}
\end{document}


Visually it looks wrong though when the arrows are black:

I guess it will always be needed to do manual adjustments dependent on line width and arrow tip.

• This is dark magic, I'm sure! Thanks so much! Jul 29 at 10:36
• @rbrignall: See edit for correction Jul 29 at 11:27