I am trying to make figures like the following:

I need flexible code that will scale well for more complex figures with many more rectangles (but the minimal example is as above).
This is my beginner's solution using \usetikzlibrary{positioning}:
\begin{tikzpicture}
\node[draw,rectangle,minimum width=7cm,minimum height=1.2cm] (n1) {(1)};
\node[draw,rectangle,minimum width=4cm,minimum height=0.9cm,above=0 of n1.north west,anchor=south west,node distance=0] (n21) {(2,1)};
\node[draw,rectangle,minimum width=3cm,minimum height=0.9cm,right=0 of n21.east,anchor=west,node distance=0] (n22) {(2,2)};
\end{tikzpicture}
Several issues here:
- Separator lines between adjacent rectangles get drawn twice (visible when zooming close)
- I have to take care manually that 4+3=7 so the widths add up. I would prefer a solution where I only indicate the relative position of vertical separators, i.e., 4/7=0.571
- I need to indicate the
minimum heightfor each rectangle on the same line - The extensive use of positioning keys and anchors makes the code cumbersome
I am aware of Nested rectangles with different widths. However I need the rectangles to be nodes (not paths) because I need to fit text into them.
In the TikZ manual I didn't find any builtin method that would allow me to do exactly this. So I'd be thankful for indications on how to improve this code.



tikz? Why not just atabular? – Werner Apr 08 '15 at 20:40tabular– jens Apr 08 '15 at 20:47chains. Looks nice but doesn't fully serve my purpose. Mostly because you don't manually control the width of each rectangle. Instead, each rectangle gets a width commensurate to its text content, and the last one (labeled "next") is stretched to match the right border. – jens Apr 09 '15 at 13:18