# partitioned matrix with row and column label

how can I create the following matrix with the array environment? I don't have an idea

What I have got is this

$$\left[ \begin{array}{c|c|c|c} \Pf_{AA} & \Pf_{AB} & \mathbf{0} & \Pf_{A\{\omega\}} \\ \hline \mathbf{0} & \Pf_{BB} & \Pf_{BA} & \Pf_{B\{\omega\}} \\ \hline \mathbf{0} & \mathbf{0} & \I & \mathbf{0} \\ \hline \mathbf{0} & \mathbf{0} & \mathbf{0} & 1 \end{array} \right]$$


But now I want to label the rows and colums

• What is the command \Pf? – Bernard Dec 20 '18 at 13:25
• I have defined \Pf as \mathbf{P}. But this is not so important. I want only to know how to create the above matrix – wayne Dec 20 '18 at 14:04

A solution with bigdelim and arydshln:

\documentclass{book}
\usepackage{array, bigdelim}
\newcommand{\Pf}{\mathbf{P}}
\newcommand{\If}{\mathbf{I}}
\usepackage{arydshln}

\begin{document}

$\setlength{\extrarowheight}{3pt} \begin{array}{@{}cc@{}*{3}{c:}c@{}c} & & \multicolumn{1}{c}{A} & \multicolumn{1}{c}{B} &\multicolumn{1}{c}{ C} & \multicolumn{1}{c}{\{\omega\}} \\ A & \ldelim[{4.5}{0.8em} &\Pf_{AA} & \Pf_{AB} & \mathbf{0} & \Pf_{A\{\omega\}} & \rdelim]{4.5}{1em}\\[0.5ex] \cdashline{3-6} B & & \mathbf{0} & \Pf_{BB} & \Pf_{BA} & \Pf_{B\{\omega\}} \\[0.8ex] \cdashline{3-6} C & & \mathbf{0} & \mathbf{0} & & \mathbf{0} \\[0.5ex] \cdashline{3-6} \{\omega\} & & \mathbf{0} & \mathbf{0} & \mathbf{0} & 1 \end{array}$

\end{document}


• you are the best! – wayne Dec 20 '18 at 15:22

You can also add the first row/column using a new command without interfering with the rest of the array.

\documentclass{article}
\usepackage{arydshln}
\begin{document}

\newcommand{\Pf}{\mathbf{P}}
\newcommand{\UP}[2]{\makebox[0pt]{\smash{\raisebox{1.5em}{$\phantom{#2}#1$}}}#2}
\newcommand{\LF}[1]{\makebox[0pt]{$#1$\hspace{4.5em}}}

$\renewcommand{\arraystretch}{1.3} \left[ \begin{array}{c@{}c:c:c:c} \LF{A} & \UP{A}{\Pf_{AA}} & \UP{B}{\Pf_{AB}} & \UP{C}{\mathbf{0}} & \UP{\{\omega\}}{\Pf_{A\{\omega\}}} \\ \hdashline \LF{B} & \mathbf{0} & \Pf_{BB} & \Pf_{BA} & \Pf_{B\{\omega\}} \\ \hdashline \LF{C} & \mathbf{0} & \mathbf{0} & \mathbf{I} & \mathbf{0} \\ \hdashline \LF{\{\omega\}} & \mathbf{0} & \mathbf{0} & \mathbf{0} & 1 \\ \end{array}\right]$

\end{document}


• Very good answer! – wayne Dec 20 '18 at 16:42