I'm drawing a grid structure using a tabular environment. Some cells are empty, some cells are filled and some cells contain a symbol. Nothing spectacular there.
\documentclass{article}
\usepackage[table]{xcolor}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\setlength{\extrarowheight}{3pt} %for superscripts in tabular
\begin{document}
\newcommand{\xx}{\cellcolor[gray]{0.5}}
\begin{table}[h]
\centering
{\tt
\begin{tabular}{ *{11}{| C{0.4cm}}| }
\hline
N & & \xx & & N & & \xx & & & & \\ \hline
& N & & N & & N & & N & & \xx & \\ \hline
& & & & & & \xx & & & \xx & \xx \\ \hline
\xx & & \xx & & & & & \xx & & & \\ \hline
& & \xx & & & & \xx & & & & \\ \hline
& \xx & & & & \xx & & & & & \\ \hline
& & & & & & \xx & & & & \xx \\ \hline
& & & \xx & \xx & \xx & & & & \xx & \\ \hline
\xx & & & & & & & & & \xx & \\ \hline
\xx & & & & & & & \xx & & \xx & \xx \\ \hline
& \xx & & & & & \xx & \xx & \xx & \xx & \xx \\ \hline
\end{tabular}}
\end{table}
\end{document}
What I'm trying to do, though, is add brackets to group the empty cells in groups of four. I run into a problem when I simply add [ and ] to the contents of the cells: the content does no longer fit the cells and it wraps to a line slightly below the original line (in the process expanding the cell vertically), as the width is set. The bracket would also be centered, as that is default behaviour for my cells.
Does anyone have any suggestion how I can mimic the behaviour as drawn in the following picture? Perhaps some sort of overlay that does not influence the drawing of the table itself? Note that I have no problem with manually inserting the [ and ] in the right places, so there's no need for automatically counting four empty fields.
[
and]
in the end cells themselves is not aesthetically or functionally acceptable?