I want to make a matrix which has multiple nodes in a single matrix cell. These nodes should be centered to each other. I managed to make this work by using a nested tikz environment like so:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[auto, semithick]
\tikzstyle{block} = [rectangle, draw,
minimum width=5em, text centered, rounded corners, minimum
height=4em]
\matrix[matrix of nodes, row sep = 2em,
nodes={anchor=center}
] (mx2){
% First row:
label1
&
\node{\tikz{
\node[block](n1){node1};
\node[block, right=of n1](n2){node2};
}};
\\
% Second row:
label2
&
\node{\tikz{
\node[block] (n3)
{node 3};
\node[block] (n4) [right=of n3]
{node 4};
\node[block] (n5) [right=of n4]
{node 5};
}};
\\
};
\draw (n1) -- (n4); % this fails
\end{tikzpicture}
\end{document}

Now connecting these nodes is impossible because of the nested tikz environments. I have tried to get a similar image using the fit library, but I did not manage to make it work. Can any of you help me out?
Thank you in advance.




!character in the front. We will fix it for you until you get enough rep points to do it. – percusse Apr 25 '12 at 10:43