Trying with TikZ to have a figure surrounded by braces above and below, the result is quite ugly: braces as well as node besides look poorly rendered, as it there was a problem in their rasterization.
Here is the code:
\documentclass{scrartcl}
\usepackage{xcolor}
\usepackage{ifthen}
\usepackage{intcalc}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro{\nlength}{12}
\pgfmathsetmacro{\mlength}{4}
\foreach \i in {-1,...,\nlength} {
\pgfmathsetmacro{\end}{\i + 1.2};
\pgfmathsetmacro{\mid}{\i + 0.6};
\newcommand\drawColor{black}
\newcommand\fillColor{white}
\newcommand\elementClass{B}
\ifthenelse
{\equal{\intcalcMod{\i}{\nlength}}{0}}
{%
\renewcommand\drawColor{red!80!white}
\renewcommand\fillColor{red!80!white}
\renewcommand\elementClass{I}
}%
{\ifthenelse%
{\equal{\intcalcMod{\i}{\mlength}}{0}}
{
\renewcommand\drawColor{red!40!white}
\renewcommand\fillColor{red!40!white}
\renewcommand\elementClass{P}
}{}%
}
\draw[\drawColor,fill=\fillColor] (\i, 0) -- (\end, 1) -- (\end, -1) -- (\i, -2) -- (\i, 0);
\node at (\mid, -0.6) {\elementClass};
\draw[decorate, decoration={brace, amplitude=10pt, raise=5pt}] (0.6, 1) -- (\nlength, 1) node [rectangle, draw=black, midway, yshift=1cm, font=\small] {$N = \nlength$};
\draw[decorate, decoration={brace, amplitude=10pt, raise=5pt, mirror}] (0.6, -2) -- (\mlength, -2) node [rectangle, draw=black, midway, yshift=-1cm, font=\small] {$M = \mlength$};
}
\end{tikzpicture}
\end{document}
I've made lots of other figures with the same configuration without any problem.

