Consider the following
\tikzset{
myline/.style={to path={(\tikztostart) -- (\tikztotarget)}}
}
and
\draw (0,0) edge[myline] (1,1) edge[myline] (2,0);
Now, it seems like \tikztostart does not reset on the second edge command, and remains to be (0,0)?
More specifically, at the second "call" to edge, I thought \tikztostart would have the value (1,1) and not (2,0).
Is there e.g. an alternative control sequence to \tikztostart that would make this work?
Feel free to specify and edit the question title
Runnable example code:
\documentclass[tikz,margin=10pt]{standalone}
\usepackage{tikz}
\tikzset{
myline/.style={to path={(\tikztostart) -- (\tikztotarget)}}
}
\begin{document}
\begin{tikzpicture}
% With edges
\begin{scope}[shift={(0,1)}]
\draw (0,0) edge[myline] (1,1) edge[myline] (2,0);
\node[below] at (1,0){With \texttt{edge}s};
\end{scope}
% With --, which gives "expected" results
\begin{scope}[shift={(0,-1)}]
\draw (0,0) -- (1,1) -- (2,0);
\node[below] at (1,0){With \texttt{--} (expected)};
\end{scope}
\end{tikzpicture}
\end{document}
Result:



toinstead ofedgeand read page 253 of the manual. – Henri Menke May 28 '19 at 11:12every edge/.append code = {% \global\let\currenttarget\tikztotarget % save \tikztotarget in a global variable \pgfkeysalso{append after command={(\currenttarget)}}}. However, if you explain what you are really up to, there might be nicer way. (I guess you are looking forshow path constructionwith which you can change the line style during the path.) – May 28 '19 at 13:18