# tikz node positioning on paths with to-syntax

In tikz you can position a node along a path using at start, midway or pos= syntax. This works fine, when using paths with -- syntax. I have noticed that tikz fails to position nodes correctly, when they use the to[] syntax instead.

Here is a trivial example of this behaviour:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw[thick] (0,2)  -- (5,2) node [midway, anchor=south] {Text} node [at start,anchor=north]{abcd} node [anchor=north,pos=0.8]{xyz};
\draw[thick] (0,0)  to[out=0,in=180] (5,0) node [midway, anchor=south] {Text} node [at start,anchor=north]{abcd} node [anchor=north,pos=0.8]{xyz};
\end{tikzpicture}
\end{document}


Here is what it looks like:

The fact that the second line is a straight line is merely to stress that this is not related to the bending you can achieve with the to syntax. I would not normally use it for a straight line of course.

Is this intended and if yes, what would the best way to achieve the same output with the to syntax?

Just place your nodes before the second coordinates. This is also right with bended lines.

\documentclass[tikz,border=3.14mm]{standalone}

\begin{document}
\begin{tikzpicture}
\draw[thick] (0,2)  -- (5,2) node [midway, anchor=south] {Text} node [at start,anchor=north]{abcd} node [anchor=north,pos=0.8]{xyz};
\draw[thick] (0,0)  to[out=0,in=180]  node [midway, anchor=south] {Text} node [at start,anchor=north]{abcd} node [anchor=north,pos=0.8]{xyz} (5,0);
\end{tikzpicture}
\end{document}


• Yes, I just edited it ^^ May 30 at 9:54