How can I create the following result in a cleaner way (means: using relative positions) than in my given code:
- Each rectangle should have a specific (minimum) width.
- Bonus: I would like to use two arrays. One defines the width, the other the text content.
Example code:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\def\bh{0.7} %box height
\def\sepw{1pt} %seperator line width
\def\ta{1}
\def\tb{1.6}
\def\tc{0.9}
\def\td{0.7}
\def\te{1.9}
\draw [line width = \sepw] (0,0) -- (0, 1);
\draw (0,0.5 - 0.5 * \bh ) rectangle (\ta, 0.5 + 0.5 * \bh ) node[pos=.5] {A};
\draw [line width = \sepw] (\ta,0) -- (\ta, 1);
\draw (\ta,0.5 - 0.5 * \bh ) rectangle (\ta+\tb, 0.5 + 0.5 * \bh ) node[pos=.5] {B};
\draw [line width = \sepw] (\ta+\tb,0) -- (\ta+\tb, 1);
\draw (\ta+\tb,0.5 - 0.5 * \bh ) rectangle (\ta+\tb+\tc, 0.5 + 0.5 * \bh ) node[pos=.5] {A};
\draw [line width = \sepw] (\ta+\tb+\tc,0) -- (\ta+\tb+\tc, 1);
\draw (\ta+\tb+\tc,0.5 - 0.5 * \bh ) rectangle (\ta+\tb+\tc+\td, 0.5 + 0.5 * \bh ) node[pos=.5] {A};
\draw [line width = \sepw] (\ta+\tb+\tc+\td,0) -- (\ta+\tb+\tc+\td, 1);
\draw (\ta+\tb+\tc+\td,0.5 - 0.5 * \bh ) rectangle (\ta+\tb+\tc+\td+\te, 0.5 + 0.5 * \bh ) node[pos=.5] {B};
\end{tikzpicture}
\end{document}



chainslibrary? – percusse Mar 01 '16 at 16:10