[Tex/LaTex] Highlighted Matrix with brackets

bracketshighlightingmatrices

I would like to produce the matrix as shown in this figure:

enter image description here

At the moment, I have this code:

 \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}

\matrix[matrix of math nodes,left delimiter = (,right delimiter = ),row sep=10pt,column sep = 10pt] (m) {
cpf_{11} & cpf_{12} & cpf_{13} & cpf_{14} \\ 
  cpf_{21} & cpf_{22} & cpf_{23} & cpf_{24}  \\
  cpf_{31} & cpf_{32} & cpf_{33} & cpf_{34}  \\
  cpf_{41} & cpf_{42} & cpf_{43} & cpf_{44}  \\};

\draw (m-1-1.north west) -- (m-2-1.south west) -- (m-2-2.south east) -- (m-1-2.north east) -- cycle;
\draw (m-1-3.north west) -- (m-2-3.south west) -- (m-2-4.south east) -- (m-1-4.north east) -- cycle;
\draw (m-3-1.north west) -- (m-4-1.south west) -- (m-4-2.south east) -- (m-3-2.north east) -- cycle;
\draw (m-3-3.north west) -- (m-4-3.south west) -- (m-4-4.south east) -- (m-3-4.north east) -- cycle;


\end{tikzpicture}

\end{document}

But I don't know how to continue.

Best Answer

Here's one TikZ-free possibility; the arydshln package was used to draw the dashed lines; \overmat and \undermat place overbraces and underbraces with text next to the selected entries (the optional argument for \overmat and \undermat allows to increase the vertical space between the entries and the braces):

\documentclass{article}      
\usepackage{arydshln}
\usepackage{amsmath}

\newcommand\undermat[3][0pt]{%
  \makebox[0pt][l]{$\smash{\underbrace{\phantom{%
    \begin{matrix}\phantom{\rule{0pt}{#1}}#3\end{matrix}}}_{\text{#2}}}$}#3}

\newcommand\overmat[3][0pt]{%
  \makebox[0pt][l]{$\smash{\overbrace{\phantom{%
    \begin{matrix}\phantom{\rule{0pt}{#1}}#3\end{matrix}}}^{\text{#2}}}$}#3}

\begin{document}

\[
\renewcommand\arraystretch{1.2}
\left(
\begin{array}{@{}c:cc:c:cc:c@{}}
\cdashline{2-3}\cdashline{5-6}
& \overmat[15pt]{Area I}{cpf_{11} & cpf_{12}} && \overmat[15pt]{\parbox{1.5cm}{\centering\scriptsize Area I to \\
Area II}}{cpf_{13} & cpf_{14}} & \\
\\
& cpf_{11} & cpf_{12} && cpf_{13} & cpf_{14} \\
\cdashline{2-3}\cdashline{5-6}
\multicolumn{5}{c}{} \\[-1ex]
\cdashline{2-3}\cdashline{5-6}
& cpf_{11} & cpf_{12} && cpf_{13} & cpf_{14} \\
& \undermat[15pt]{\parbox{1.5cm}{\centering\scriptsize Area II \\ to Area I}
}{cpf_{11} & cpf_{12}} && \undermat[15pt]{Area II}{cpf_{13} & cpf_{14}} \\
\cdashline{2-3}\cdashline{5-6}
\end{array}
\right)
\]

\end{document}

enter image description here

Related Question