1 \begin{tikzpicture}[scale=0.66,auto]
3 \pgfmathsetmacro{\lastzeroindex}{1}
6 \pgfmathsetmacro{\spacingx}{1.3}
7 % Amount even boxes are raised
8 \pgfmathsetmacro{\offsety}{0.8}
10 \pgfmathsetmacro{\totalheight}{4 + \offsety} % Height of one sub-picture.
13 \foreach \x in {0, ..., 7}
14 \draw[edge] (\spacingx * \x, 0) -- (\spacingx * \x, \totalheight);
17 \foreach \x in {0, ..., \lastzeroindex}
19 \draw[red box] (2 * \spacingx * \x - .5, 2 + \offsety) rectangle +(1,1);
20 \draw (2 * \spacingx * \x, 2.5 + \offsety) node {$0$};
24 \pgfmathsetmacro{\firstoneindex}{\lastzeroindex+1}
25 \foreach \x in {\firstoneindex, ..., 3}
27 \draw[blue box] (2 * \spacingx * \x - .5, 2 + \offsety) rectangle +(1,1);
28 \draw (2 * \spacingx * \x, 2.5 + \offsety) node {$1$};
32 \foreach \x in {0, ..., 0}
34 \draw[red box] (\spacingx + 2 * \spacingx * \x - .5, 2) rectangle +(1,1);
35 \draw (\spacingx + 2 * \spacingx * \x, 2.5) node {$0$};
39 \foreach \x in {1, ..., 3}
41 \draw[blue box] (\spacingx + 2 * \spacingx * \x - .5, 2) rectangle +(1,1);
42 \draw (\spacingx + 2 * \spacingx * \x, 2.5) node {$1$};
46 \foreach \x in {0, ..., 2}
47 \draw[comp] ( \spacingx + 2 * \spacingx * \x, 1) node[vertex] {}
48 -- (2 * \spacingx + 2 * \spacingx * \x, 1) node[vertex] {};