[Tex/LaTex] Matrix with rows and columns labeled

matrices

It is trivial to make matrices like so:

\begin {pmatrix} s & t & a \\ c & k & x \\ cha & n & ge \end {pmatrix}

It is not so trivial to impose labels on the rows and columns as done in page 410 here. I would like to do this. For example, the matrix in 11.6:

enter image description here


Note: I am aware of this thread but this is not what I'm looking for.

Best Answer

Here are three different option using \bordermatrix, kbordermatrix and blkarray:

enter image description here

\documentclass{article}
\usepackage{amsmath,kbordermatrix,blkarray}

\renewcommand{\kbldelim}{(}
\renewcommand{\kbrdelim}{)}

\begin{document}
\[
  \mathbf{P} = 
    \bordermatrix{ & H & Y & D \cr
      H & .8 & .2 & .0 \cr
      Y & .3 & .4 & .3 \cr
      D & .2 & .1 & .7 } \qquad
  \mathbf{P} = 
    \kbordermatrix{ & H & Y & D \\
      H & .8 & .2 & .0 \\
      Y & .3 & .4 & .3 \\
      D & .2 & .1 & .7 } \qquad
  \mathbf{P} = 
    \begin{blockarray}{cccc}
        & H & Y & D \\
      \begin{block}{c(ccc)}
        H & .8 & .2 & .0 \\
        Y & .3 & .4 & .3 \\
        D & .2 & .1 & .7 \\
      \end{block}
    \end{blockarray}
\]

\end{document}
Related Question