7

How can I draw a previously named path in TikZ?

\documentclass[tikz]{standalone}
\usetikzlibrary{intersections}

\begin{document} \begin{tikzpicture}

\path[name path=mypath] (0,0) -- (5,5);

%\draw[use path=mypath]; % This does not work

%\path[mypath, draw]; % This does not work

\end{tikzpicture}
\end{document}

The answer given here has a macro for use path option. Is there a solution within TikZ?

berkus
  • 1,168

1 Answers1

10

It is just wrong syntax. After you name a path via [save path], you can recall it with [use path].

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\path[save path=\mypath] (0,0) -- (5,5);
\draw[use path=\mypath]; % This works now
\end{tikzpicture}   
\end{document}

The key [name path] of the library intersections has totally different use. The keys [name path] and [save path] can be combined. See Section 14.22 in pgfmanual for more details.

enter image description here

Black Mild
  • 17,569