How to create blocks matrix?

\documentclass{article}
\begin{document}
\[
  \left(\begin{array}{@{}ccc|cc@{}}
    a_{11} & a_{12} & a_{13} & b_{11} & b_{12} \\
    a_{21} & a_{22} & a_{23} & b_{21} & b_{22} \\\hline
    c_{11} & c_{12} & c_{13} & d_{11} & d_{12} \\
    c_{21} & c_{22} & c_{23} & d_{21} & d_{22} \\
    c_{31} & c_{32} & c_{33} & d_{31} & d_{32} 
  \end{array}\right)
\]
\end{document}

Here is a way to highlight blocks in a matrix environment easily with pstricks without increasing the column widths: adding pnodes (empty nodes) at the relevant places and defines \psframes from pairs of nodes.

\documentclass[svgnames]{article}
\usepackage{mathtools}
\usepackage{pst-node}%

\begin{document}

\[ A = \begin{pmatrix}
   M_{11} & M_{12}\\\
M_{21} & M_{22}
 \end{pmatrix}
  =
 \begin{pspicture}
 $ \begin{pmatrix}
    \pnode[-0.3ex, 1.5ex]{A}
    a_{11} & a_{12} & a_{13} & b_{11} & b_{12} \\
    a_{21} & a_{22} & a_{23} & b_{21} & b_{22} \\
    c_{11} & c_{12} &
    c_{13} \pnode[1.4ex, -0.8ex]{C} & d_{11} & d_{12} \\
    c_{21} & c_{22} & c_{23} & d_{21} & d_{22} \\
    c_{31} & c_{32} & c_{33} & d_{31} & d_{32}\pnode[0.2ex, -0.6ex]{D}\,
  \end{pmatrix} $
\psset{linecolor = IndianRed}
\psframe(A)(C)
\psset{dimen = inner}\psframe(C)(D)
\end{pspicture}
\]

\end{document}

enter image description here

Tags:

Matrices