# TikZ: clipping nodes outside current picture

I would like to clip a node that is outside the current picture. (I do this so that I can re-use a relatively complicated TikZ picture that I use several times in different places.) I can't get it to work, however. The MWE is:

\documentclass[10pt]{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\draw[clip] (0,0) circle (1cm);
\end{tikzpicture}

\begin{tikzpicture}
\fill[red] (1,0) circle (1cm);
\end{tikzpicture}

\end{document}


I would like to achieve the same effect as if I had a single tikzpicture environment and moved the fill command just below the draw command:

\begin{tikzpicture}
\draw[clip] (0,0) circle (1cm);
\fill[red] (1,0) circle (1cm);
\end{tikzpicture}


I tried the "remember picture" option without success. If this cannot be made to work, I can refactor my TikZ picture and use the \input command. Thanks for any help.

• So you would like to move the clipped content to different place ? Also you mention nodes but I don't see how they enter the question. – percusse Jan 24 '13 at 12:47
• In the above MWE, I don't define nodes, but in my proper code I define nodes and then try to clip around them. Yes, in a sense I want to move the clipped content to a different place - just for convenience. – user1362373 Jan 25 '13 at 7:47

I'm not sure if this is what you want, but couldn't you just define a command containing the relevent code and then use this where ever you like?

## Code

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{intersections}

\begin{document}

\newcommand{\reusable}%
{   \draw (0,0) circle (1cm+\pgflinewidth/2);
\clip (0,0) circle (1cm);%
}

\begin{tikzpicture}[remember picture]
\reusable
\end{tikzpicture}

\begin{tikzpicture}
\reusable
\fill[red] (1,0) circle (1cm);
\end{tikzpicture}

\end{document}