I wish to create tikzpicture environments inside a node of another tikzpicture.
The problem I encouter is that styles are inherited by the inner tikzpicture.
How can I screen of the inner tikzpicture form the outer one? Or is this impossible?
The following minimal example illustrates the problem:
\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
% wanted: square centered on line
\begin{tikzpicture}
\draw (0,0) -- (0,1);
\node[fill] at (0,.5) {};
\end{tikzpicture}
% got: square to the right of line
\begin{tikzpicture}[red]
\node[fill] (O) {};
\node[right=of O] {% <- this 'right of' is inherited; how to avoid?
\begin{tikzpicture}
\draw (0,0) -- (0,1);
\node[fill] at (0,.5) {};
\end{tikzpicture}
};
\end{tikzpicture}
\end{document}
Best Answer
In this specific case you can use
anchor=center
to restore the default positioning. Theright
etc. settings modify the used anchor.In the general case if you want to avoid any settings to affect the sub-
tikzpicture
I would store it into a savebox before the maintikzpicture
and insert that box: