# Highlighted Matrix with brackets

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

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.

-
Welcome to TeX.sx! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. –  Jubobs Apr 16 '13 at 15:53
possible duplicate of tex.stackexchange.com/questions/108009/… –  Jubobs Apr 16 '13 at 15:57
here's another possible duplicate: How to Specify two level row and column labels of a matrix by braces? –  barbara beeton Apr 16 '13 at 16:04
And here it is another idea. –  Manuel Apr 16 '13 at 16:04

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}


-
since there's a (small) gap between the vertical parentheses and the matrix outline, a similar gap between the horizontal braces and the outline would look a bit nicer. –  barbara beeton Apr 16 '13 at 17:03
@barbarabeeton yes, you're right; I've now added some space (using a new optional argument, the user can increase it even more). Does it look better now? –  Gonzalo Medina Apr 16 '13 at 17:11
yes, it definitely looks better now. (apologies for being a fussbudget. as someone has observed, i've "caught the editor disease".) –  barbara beeton Apr 16 '13 at 17:27
@barbarabeeton no need to apologize (at least not to me). On the contrary, I've always seen your suggestions as really valuable and I am thankful that you care for the details in answers. –  Gonzalo Medina Apr 16 '13 at 17:31
It's perfect! Thank you! –  user29133 Apr 17 '13 at 8:10