I'd like to have a tikzpicture (actually several) appear inside a node of another tikzpicture. I already know that I can use savebox for that, the problem is: When I change the fontsize of a node inside of this nested picture it causes TeX to exceed its stack size, giving the following error:
TeX capacity exceeded, sorry [input stack size=5000].
It works if I leave the font size at normal, so that seems to be the root of the problem. However, as I do want the text in the node to be smaller, that's not a solution... I've searched for an hour now to find a solution, but am pretty much stuck. Increasing the stack size to 50000 didn't work, neither did putting extra braces anywhere. Does anyone have an idea why this eats all of my save stack?
MWE:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
\node (1) {$x$};
\newsavebox\MyBox
\begin{lrbox}{\MyBox}
\begin{tikzpicture}
\node (1) {\scriptsize $y$};
\end{tikzpicture}
\end{lrbox}
\node[right=of 1] (2) {\usebox\MyBox};
\end{tikzpicture}
\end{document}
As said, it works fine, if I remove the \scriptsize. I do know of course, that the MWE can be done differently (read: without the savebox), the thing I actually want to do however would require a lot of rewriting to be done differently, so I'd prefer to find a solution to this problem...
\newsaveboxdeclaration in the preamble and the construction of the box outside the maintikzpicture. Naming the same two nodes in distinct pictures doesn't seem a good idea. – egreg Sep 04 '13 at 09:31tikzpictures is generally bad (see How to avoid nesting of tikzpicture? and related questions). Besides the answers given there, one can always use the keys: How can I draw a TikZ element multiple times against a shaded background? is an example. – Claudio Fiandrino Sep 04 '13 at 10:25