TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

enter image description here

At the moment, I have this code:




\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;



But I don't know how to continue.

share|improve this question
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
up vote 5 down vote accepted

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):





& \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} \\
\multicolumn{5}{c}{} \\[-1ex]
& 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}} \\


enter image description here

share|improve this answer
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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.