# [Tex/LaTex] Telling TikZ to continue the previously-drawn path with a line-to operation

tikz-pgf

This question seems quite simple, so I feel a bit sheepish about asking it, but I've spent quite a while scouring both this site and the manual without any success, so here goes…

I found that

\draw (0,0) -- (1,0);
\draw (1,0) -- (1,1);


does not produce the same result as

\draw (0,0) -- (1,0);
\draw  -- (1,1);


and this surprises me. I would have thought that, in the second case, the path would begin where the previous path ended. That is my expectation based on Section 14.2 of the manual, concerning "The Line-To Operation" which says:

The line-to operation extends the current path from the current point in a straight line to the given
coordinate. The "current point" is the endpoint of the previous drawing operation or the point specified
by a prior move-to operation.

You use two minus signs followed by a coordinate in round brackets.

However, I'm clearly missing something. But what? Perhaps a clue is provided by the answer from Loop Space to
Saving and reusing/combining paths in TikZ? that states:

TikZ does not blank the current soft path when it starts, so when a command such as \draw starts up then it simply appends its stuff to whatever was there already. This is usually the empty path because whenever a path is used (ie rendered) then the current soft path is set to "empty". But it needn't be. [emphasis mine]

I suspect that is related to what I'm observing here, but considering how simple my question is, the suggested solution there feels far more technical that I'd expect to be necessary. In some sense, my question is just:

How can I tell TikZ to begin a path from the end of a path that has already been drawn?

To clarify, the fact that two separate "draw" commands are mentioned in my question above is essential. That is, I realize that

\draw (0,0) -- (1,0) -- (1,1);


would produce the desired result, but the question, again deals with continuing a path that has already been drawn. I have rephrased the question above to try to make this more clear.

As percusse points out, after a path is used, it is forgotten and is no longer the "current path". However, the intersections library provides a key to name a path and save it so can be "remembered". In the following a from end of path key is defined which can be used to start a new path from the last point of the end of a remembered (i.e., named) path.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{intersections}
\tikzset{%
from end of path/.style={
insert path={
\pgfextra{%
\expandafter\pgfprocesspathextractpoints%
\csname tikz@intersect@path@name@#1\endcsname%
\pgfpointlastonpath%
\pgfgetlastxy\lastx\lasty
}
(\lastx,\lasty)
}}}

\begin{document}
\begin{tikzpicture}
\draw [name path=A] (0,0) -- (1,1);
\draw [red, from end of path=A, name path=B] arc (180:0:1);
\draw [green, from end of path=B, name path=C] -- ++(0,-1);
\draw [blue, from end of path=C] .. controls ++(0,-1) and ++(0,-2) .. (0,0);
\end{tikzpicture}
\end{document}