I specify the corners of a rectangle, spanning a certain submatrix of a matrix, and want this rectangle to be a node. The minimal example is:
\documentclass{standalone}
\usepackage{tikz,pgf}
\usetikzlibrary{scopes,arrows,calc,shapes.misc,shapes.arrows,chains,matrix,positioning,decorations.pathmorphing,shapes}
\begin{document}
\newcommand{\bbrect}[2]{\draw (B-#1-2.north west) rectangle (B-#2-2.south east)}
\begin{tikzpicture}
\ttfamily
\matrix (B) [matrix of nodes, ampersand replacement = \&] {
\hline
{0} \& {12}\\
{1} \& {7}\\
{2} \& {2}\\
{3} \& {2}\\
{} \& {2}\\
{} \& {2}\\
{} \& {2}\\
{} \& {2}\\
};
\bbrect{1}{1};
\bbrect{2}{2};
\bbrect{3}{8};
\end{tikzpicture}
\end{document}
How to achieve this?