I wonder why we need a different syntax for specifying nodes
(and coordinates
) on a path when using the simple --
and the .. controls …
system or the to
operation.
Here’s an example to illustrate the problem:
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\tikzset{every node/.style={fill=white,inner sep=2pt}}
\begin{document}
\begin{tikzpicture}
\draw [thick] (0,0) -- (5,2)
node [pos=0.2] {A}
node [midway] {B};
\end{tikzpicture}
\begin{tikzpicture}
\draw [thick] (0,0) .. controls +(1,2) and +(-2,-1) .. (5,2)
node [pos=0.2] {A}
node [midway] {B};
\end{tikzpicture}
\begin{tikzpicture}% with wrong result
\draw[line width=1pt](0,0) to[out=40, in=160] (5,2)
node [pos=0.2] {A}
node [midway] {B};
\end{tikzpicture}
\begin{tikzpicture}
\draw[line width=1pt](0,0) to[out=40, in=160]
node [pos=0.2] {A}
node [midway] {B} (5,2);
\end{tikzpicture}
\end{document}
When using --
or controls
it is possible to position the node after the second coordinate.
But with to[in=x, out=y]
this won’t work
all nodes go to (0,0)
(not the first coordinate it’s always (0,0)
) an we must gove the nodes before the second coordinate right after the to
operation
I guess this has to do with the way to
works but I wonder why …?
\pgfpointcurveattime
command population. Also as a sidenote, it is now possible to put a node in the middle of an arc with the cvs version of pgf-tikz implemented in March.to
syntax is incredibly powerful and flexible, but as part of that it needs more precise input. Relevant to this question, theto
path is meant to figure out where the nodes go, and this can be done in any way desired (including ignoring thepos
keys). But to do this, theto
path constructor needs to know the nodes on its path at construction time, which (as TikZ works as a parser) is when the target coordinate is read. Hence for the best results, nodes should be specified before the target coordinate, not after.two
or in general including--
,|-
andcontrols
etc.?