# Reuse tikz picture in another tikz picture [duplicate]

I have a TikZ picture

\begin{tikzpicture}[scale=0.5]
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\end{tikzpicture}


which makes a small ball.

Is it possible to reuse this shape in another tikz picture?

I have another tikz picture in which I use

\draw[fill=yellow!30, fill opacity=0.5,text opacity=1] (B) circle (0.7cm) node[right] {$A$};


Instead of circle I want my small custom ball. How is that possible?

## marked as duplicate by Malipivo, Heiko Oberdiek, Guido, Andrew Swann, Claudio FiandrinoApr 13 '14 at 12:51

Unrecommended way

There are several ways, this one puts tikzpicture environment to another tikzpicture environment with help of a \node.

%! *latex mal-tikz-tikz.tex
\documentclass[a4paper]{article}
\pagestyle{empty}
\usepackage{tikz}
\begin{document}
\def\malpic{%
\begin{tikzpicture}[scale=0.5]
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\node[fill=yellow!30, fill opacity=0.5,text opacity=1] at (B) {\malpic} node[right] {$A$};

• I was quite happy when I found this solution in older versions of TikZ. It is fair enough when dealing with TikZ v3 where pic and external library have been introduced. I'm marking my answer as unrecommended. – Malipivo Apr 13 '14 at 12:25
• Have a look at this thread. I answered using a new scope with custom options for the embedding picture. The thread also covers the usage of the pic. Link – moospit Apr 13 '14 at 12:41