To expand the applications of the following framework used to answer TikZ : Drawing a Triangular Block Matrix, an option using the tikz matrix
and fit
library, through matrix coordinate names to highlight using a simple style of line; whatever the kind of document you are working on, you can include it using the graphicx package
, with all the advantages that it has, as I explain in Scaling different components of tikzpicture together. creating a separate tex document with the standalone
document class.
RESULT:

MWE:
\documentclass[tikz,border=14pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,decorations.pathreplacing,fit,backgrounds}
\begin{document}
\begin{tikzpicture}[
%Global config
>=latex,
line width=1pt,
%Styles
Brace/.style={
decorate,
decoration={
brace,
raise=-7pt
}
},
Matrix/.style={
matrix of nodes,
text height=2.5ex,
text depth=0.75ex,
text width=3.25ex,
align=center,
%left delimiter=\{,
%right delimiter=\},
column sep=5pt,
row sep=5pt,
%nodes={draw=black!10}, % Uncoment to see the square nodes.
nodes in empty cells,
},
DA/.style={
fill,
opacity=0.2,
rounded corners,
inner sep=-3pt,
line width=1pt,
},
DL/.style={
left delimiter=[,
right delimiter=],
inner sep=-2pt,
},
DG/.style={
line cap= round,
line width =15pt,
opacity=0.2,
}
]
\matrix[Matrix] at (0,0) (M){ % Matrix contents
& 1 & 2 & 3 & 4 & 5 & 6 \\
1 & 0 & 1 & 0 & 0 & 0 & 0\\
2 & 0 & 0 & 1 & 0 & 1 & 0\\
3 & 0 & 0 & 0 & 1 & 0 & 0\\
4 & 0 & 0 & 0 & 0 & 0 & 0\\
5 & 1 & 0 & 0 & 0 & 0 & 1\\
6 & 0 & 1 & 0 & 0 & 0 & 0\\
S & 1 & 2 & 2 & 2 & 2 & \\
};
\matrix[Matrix] at (10,0) (M1){ % Matrix contents
& 1 & 2 & 3 & 4 & 5 & 6 \\
1 & 0 & 1 & 0 & 0 & 0 & 0\\
2 & 0 & 0 & 1 & 0 & 1 & 0\\
3 & 0 & 0 & 0 & 1 & 0 & 0\\
4 & 0 & 0 & 0 & 0 & 0 & 0\\
5 & 1 & 0 & 0 & 0 & 0 & 1\\
6 & 0 & 1 & 0 & 0 & 0 & 0\\
S & 1 & 2 & 2 & 2 & 2 & \\
};
\begin{scope}[on background layer]
%FOR MATRIX M
%To delimit internal braces
\node[DL,fit=(M-2-2)(M-7-6)](subM-1){};
%To delimit internal area groups
\node[DA,blue,fit=(M-3-2)(M-5-4)](subM-2){};
\node[DA,green,fit=(M-6-4)(M-7-6)](subM-3){};
% For line sectors
\draw[DG,red](M-2-2.center) --(M-6-6.center);
\draw[DG,orange](M-1-7.center) --(M-7-7.center);
\draw[DG,black](M-8-1.center) --(M-8-6.center);
%FOR MATRIX M1
%To delimit internal braces
\node[DL,fit=(M1-1-1)(M1-8-7)](subM1-1){};
\node[DL,fit=(M1-7-2)(M1-7-3)](subM1-2){};
%To delimit internal area groups
\node[DA,red,fit=(M1-3-1)(M1-5-4)](subM1-3){};
\node[DA,green,fit=(M1-6-4)(M1-7-6)](subM1-4){};
% For line sectors
\draw[DG,red](M1-2-2.center) --(M1-6-6.center);
\draw[DG,orange](M1-1-7.center) --(M1-7-7.center);
\draw[DG,black](M1-8-1.center) --(M1-8-6.center);
% You can connect Sub groups.
\draw[->,line width=5pt,red,opacity=0.2] (subM-2) -- (subM1-3) ;
\draw[->,line width=5pt,red,opacity=0.2] (subM1-3.south) -| (subM1-2) ;
\end{scope}
\end{tikzpicture}
\end{document}
UPDATE: Integration in Beamer document class.
ISSUES: MAtrix command ampersand has incompatibilities, solution taken from tikz matrix undefined control sequence, using tikz config option ampersand replacement=\&
.
MWE:
% PROCESADOR ARARA V3.0
% arara: pdflatex: {synctex: yes, action: nonstopmode}
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix,shapes,decorations.pathreplacing,fit,backgrounds}
\begin{document}
\begin{frame}
\frametitle{Example}
\centering
\begin{figure}[H]
\tikzset{
%Global config
>=latex,
font=\small,
line width=1pt,
%Styles
Brace/.style={
decorate,
decoration={
brace,
raise=-7pt
}
},
Matrix/.style={
matrix of nodes,
text height=8pt,
text depth=0pt,
text width=8pt,
align=center,
%left delimiter=\{,
%right delimiter=\},
column sep=0pt,
row sep=0pt,
%nodes={draw=black!10}, % Uncoment to see the square nodes.
nodes in empty cells,
},
DA/.style={
fill,
opacity=0.2,
rounded corners,
inner sep=-3pt,
line width=1pt,
},
DL/.style={
left delimiter=[,
right delimiter=],
inner sep=-2pt,
},
DG/.style={
line cap= round,
line width =15pt,
opacity=0.2,
}
}
\begin{tikzpicture}[ampersand replacement=\&]
\matrix[Matrix] at (0,0) (M){ % Matrix contents
\& 1 \& 2 \& 3 \& 4 \& 5 \& 6 \\
1 \& 0 \& 1 \& 0 \& 0 \& 0 \& 0\\
2 \& 0 \& 0 \& 1 \& 0 \& 1 \& 0\\
3 \& 0 \& 0 \& 0 \& 1 \& 0 \& 0\\
4 \& 0 \& 0 \& 0 \& 0 \& 0 \& 0\\
5 \& 1 \& 0 \& 0 \& 0 \& 0 \& 1\\
6 \& 0 \& 1 \& 0 \& 0 \& 0 \& 0\\
S \& 1 \& 2 \& 2 \& 2 \& 2 \& \\
};
\matrix[Matrix] at (5,0) (M1){ % Matrix contents
\& 1 \& 2 \& 3 \& 4 \& 5 \& 6 \\
1 \& 0 \& 1 \& 0 \& 0 \& 0 \& 0\\
2 \& 0 \& 0 \& 1 \& 0 \& 1 \& 0\\
3 \& 0 \& 0 \& 0 \& 1 \& 0 \& 0\\
4 \& 0 \& 0 \& 0 \& 0 \& 0 \& 0\\
5 \& 1 \& 0 \& 0 \& 0 \& 0 \& 1\\
6 \& 0 \& 1 \& 0 \& 0 \& 0 \& 0\\
S \& 1 \& 2 \& 2 \& 2 \& 2 \& \\
};
\begin{scope}[on background layer,transform canvas={scale=.5}]
%FOR MATRIX M
%To delimit internal braces
\node[DL,fit=(M-2-2)(M-7-6)](subM-1){};
%To delimit internal area groups
\node[DA,blue,fit=(M-3-2)(M-5-4)](subM-2){};
\node[DA,green,fit=(M-6-4)(M-7-6)](subM-3){};
% For line sectors
\draw[DG,red](M-2-2.center) --(M-6-6.center);
\draw[DG,orange](M-1-7.center) --(M-7-7.center);
\draw[DG,black](M-8-1.center) --(M-8-6.center);
%FOR MATRIX M1
%To delimit internal braces
\node[DL,fit=(M1-1-1)(M1-8-7)](subM1-1){};
\node[DL,fit=(M1-7-2)(M1-7-3)](subM1-2){};
%To delimit internal area groups
\node[DA,red,fit=(M1-3-1)(M1-5-4)](subM1-3){};
\node[DA,green,fit=(M1-6-4)(M1-7-6)](subM1-4){};
% For line sectors
\draw[DG,red](M1-2-2.center) --(M1-6-6.center);
\draw[DG,orange](M1-1-7.center) --(M1-7-7.center);
\draw[DG,black](M1-8-1.center) --(M1-8-6.center);
% You can connect Sub groups.
\draw[->,line width=3pt,red,opacity=0.2] (subM-2) -- (subM1-3) ;
\draw[->,line width=3pt,red,opacity=0.2] (subM1-3.south) -| (subM1-2) ;
\end{scope}
\end{tikzpicture}\\
\caption{Example}
\end{figure}
\end{frame}
\end{document}
RESULT:

\alert
command, are you aware of that?