I am trying to draw a complex item (consisting of multiple \nodes) as a cohesive whole using a nested \tikzpicture.
My outermost picture uses a chain, onto which every \node is put.
My inner picture uses a chain as well, but that's supposed to be a different one than the outer chain.
This structure causes an error:
Package pgf Error: No shape named chain-2 is known.
How can I fix that?
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,scopes,shapes.misc}
\begin{document}
\begin{tikzpicture}[start chain,node distance=5mm,
every node/.style={on chain},
connect/.append style={join=by ->},
point/.style={coordinate},
l/.style={draw, rounded rectangle, rounded rectangle right arc=0},
c/.style={draw},
r/.style={draw, rounded rectangle, rounded rectangle left arc=0},
cozy/.style={node distance=0}]
\node [point] {};
\node [connect] (lcr) {\tikz{[start chain, cozy]
\node [l] (l) {L};
\node [c] (c) {C};
\node [r] (r) {R};
}};
\node [point, connect] {};
\end{tikzpicture}
\end{document}
Edit:
I have utilized @Gonzalo Medina's answer (which uses boxes to store the inner tikzpicture) to get rid of the error. Even though it gets me closer to a solution, my actual situation won't be fixed by it, because now latex seems to think \nodes are at a different location than where the're eventually drawn:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,scopes,shapes.misc}
\newsavebox\mybox
\tikzset{
l/.style={draw, rounded rectangle, rounded rectangle right arc=0},
c/.style={draw},
r/.style={draw, rounded rectangle, rounded rectangle left arc=0},
cozy/.style={node distance=0pt}
}
\begin{document}
\savebox\mybox{%
\tikz[start chain,every node/.style={on chain},node distance=-\pgflinewidth]
{
\node [l] (l) {L};
\node [c] (c) {C};
\node [r] (r) {R};
}}
\begin{tikzpicture}[start chain,node distance=5mm,
every node/.style={on chain},
connect/.append style={join=by ->},
point/.style={coordinate},
group/.style={inner sep=0, outer sep=0}]
\node [point] {};
\node [connect, group] (lcr) {\usebox\mybox};
\node [point, connect] {};
{[]
\draw[->] (0,-1) -- (l.south east);
}
\end{tikzpicture}
\end{document}
Maybe I just need to get rid of the chain in my nested picture... or for that matter, the lose the entire nested picture, and stick to a single level of tikz.
tikzpicturesis not a good idea. What is it that you are trying to achieve? See for instance Problem with overlay when a tikzpicture is inside another tikzpicture. – Peter Grill Feb 20 '14 at 17:52\tikzmark, but not sure without seeing a picture of what is desired. See the link in the first comment as to why it isn't a good idea. – Peter Grill Feb 20 '14 at 17:58start chain=outer chainandstart chain=inner chain(→on chain=outer chain,on chain=inner chain), otherwise TikZ might not differentiate between them. If you're justgoing right(the default direction of a chain) you could just use a\matrix(e.g. the\tikzCenterNodesmacro can help here). A matrix is almost a node in itself. Maybe you actually need abranchor something totally different. – Qrrbrbirlbel Nov 25 '22 at 14:41