I am trying to achieve something like the following:
+---------------------+ +---------------+
| A | | B |
+---------------------+ +---------------+
+---------+
########1######## | C | #####2#####
+---------+
+---+ +---------+ +---------+ +---+ +---+
| D | | E | | F | | G | | H |
+---+ +---------+ +---------+ +---+ +---+
+---+
##3## | I | ###########4########### ##5##
+---+
+---------+ +---------------------+ +---+
| J | | K | | L |
+---------+ +---------------------+ +---+
Here, the hashtags are supposed to represent chunks of empty space. I have looked at this answer, but that solution does not quite fit my needs.
What I would like to do in order to specify my diagram, is design it row-by-row, left-to-right; sequentially listing all the blocks/empty spaces I want to draw.
In order to get the overlap right, I'd like to specify for each block/empty space, which blocks from the previous row it shares vertical space with. How do I do that? Or better yet, how do I get the desired final result?
It would be nice if adding a row that demands sharing vertical space of a narrow block would cause the block to be stretched. Take e.g. the example above; If C by itself would be narrow, having it share vertical space with A and B causes it to be come slightly wider.
Similarly, since #4 shares some of E's vertical space, E has to become wider to accommodate I and part of #4.
And finally, since H, #5 and L share the same vertical space, they should be equally wide.
Perhaps, thinking about this row/column decomposition along the lines of the twitter bootstrap model can help with visualize this problem further.
Update (2013-12-11):
I have made an attempt to follow the suggestion pointing me towards TikZ matrices. Therefor I had to look up how to do column-spanning.
Here's a MWE using that technique:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,matrix,fit}
\makeatletter
\newdimen\multi@col@width
\newdimen\multi@col@margin
\newcount\multi@col@count
\multi@col@width=0pt
\tikzset{
multicol/.code={%
\global\multi@col@count=#1\relax
\global\let\orig@pgfmatrixendcode=\pgfmatrixendcode
\global\let\orig@pgfmatrixemptycode=\pgfmatrixemptycode
\def\pgfmatrixendcode##1{\orig@pgfmatrixendcode%
##1%
\pgfutil@tempdima=\pgf@picmaxx
\global\multi@col@margin=\pgf@picminx
\advance\pgfutil@tempdima by -\pgf@picminx
\divide\pgfutil@tempdima by #1\relax
\global\multi@col@width=\pgfutil@tempdima
\pgf@picmaxx=.5\multi@col@width
\pgf@picminx=-.5\multi@col@width
\global\pgf@picmaxx=\pgf@picmaxx
\global\pgf@picminx=\pgf@picminx
\gdef\multi@adjust@position{%
\setbox\pgf@matrix@cell=\hbox\bgroup
\hfil\hskip-1.5\multi@col@margin
\hfil\hskip-.5\multi@col@width
\box\pgf@matrix@cell
\egroup
}%
\gdef\multi@temp{\aftergroup\multi@adjust@position}%
\aftergroup\multi@temp
}
\gdef\pgfmatrixemptycode{%
\orig@pgfmatrixemptycode
\global\advance\multi@col@count by -1\relax
\global\pgf@picmaxx=.5\multi@col@width
\global\pgf@picminx=-.5\multi@col@width
\ifnum\multi@col@count=1\relax
\global\let\pgfmatrixemptycode=\orig@pgfmatrixemptycode
\fi
}
}
}
\makeatother
\begin{document}
\begin{tikzpicture}{
\matrix[matrix of nodes, nodes={draw}, draw=black] (Layers) {
%row 1
|[multicol=4]| A &&&&|[multicol=3]| B && \\
%row 2
|[multicol=3]| &&&|[multicol=2]| C &&|[multicol=2]| & \\
%row 3
D &|[multicol=2]| E &&|[multicol=2]| F && G & H \\
%row 4
& I &|[multicol=4]| &&& \\
%row 5
|[multicol=2]| J &&|[multicol=4]| K &&&& L \\
};
}
\end{tikzpicture}
\end{document}
However, the result is somewhat dissatisfying (unwanted boxes appear in some of the empty spaces, and boxes around letters are not stretched wide enough):

Despite the dissatisfying result I achieved so far, I tried adapting it into a more visually appealing version (just replace the \begin{tikzpicture}...\end{tikzpicture} part in the MWE):
\begin{tikzpicture}[
base/.style={
rounded corners,
font={\sffamily\bfseries},
align=center,
},
block/.style={
base,
draw=lime,
fill=blue,
font={\sffamily\bfseries\color{white}},
},]{
\matrix[draw=black] (Layers) {
%row 1
|[multicol=4]|
\node[block] (a) {A};
&&&&|[multicol=3]|
\node[block] (b) {B};
&& \\
%row 2
|[multicol=3]| &&&|[multicol=2]|
\node[block] (c) {C};
&&|[multicol=2]| & \\
%row 3
\node[block] (d) {D};
&|[multicol=2]|
\node[block] (e) {E};
&&|[multicol=2]|
\node[block] (f) {F};
&&
\node[block] (g) {G};
&
\node[block] (h) {H};
\\
%row 4
&
\node[block] (i) {I};
&|[multicol=4]| &&& \\
%row 5
|[multicol=2]|
\node[block] (j) {J};
&&|[multicol=4]|
\node[block] (k) {K};
&&&&
\node[block] (l) {L};
\\
};
}
\end{tikzpicture}
This results in the following:

Quite clearly, most of the boxes are not properly stretched to their intended size. How do I fix that?




