It's easy to do with pstricks
, as it allows using a usual ams matrix
environment. The relevant entries of the matrix are defined as \rnode
s, and these nodes are connected with \ncbox
es:
\documentclass{article}
\usepackage{amsmath}
\usepackage[table, x11names]{xcolor}
\usepackage{fourier}
\usepackage{pst-node, multido}
\usepackage{auto-pst-pdf}
\begin{document}
\begin{equation*}
\begin{postscript}
\begin{matrix}
\rnode{A1}{1} & -1 & 3 & \rnode{A8}{8} & 10 & -5 \\
2 & 3 & 4 & \rnode{A7}{1} & \rnode{A6}{-2} & 2 \\
\rnode{A2}{5} & 1 & \rnode{A3}{-3} & 2 & 1 & 7 \\
0 & 1 & 0 & 2 & -1 & 4 \\
1 & 0 & \rnode{A4}{1} & 0 & \rnode{A5}{-2} & 3 \\
8 & 1 & 2 & -2 & 1 & 0
\end{matrix}%
\psset{boxsize=1.5ex, boxdepth=1.5ex, nodesep =0.5ex, linestyle=none, fillstyle=solid, fillcolor=VioletRed4, opacity=0.15}
\multido{\i=1+2, \in=2+2}{4}{\ncbox{A\i}{A\in}}
\psset{boxsize=1.2ex, boxdepth=1.2ex, nodesepA=0.95ex, nodesepB=0.2ex}
\multido{\i=2+2, \in=3+2}{2}{\ncbox{A\i}{A\in}}
\ncbox{A7}{A6}
\end{postscript}
\end{equation*}
\end{document}
pmatrix*
environment.