16

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.

1

2 Answers 2

26

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}
1
0

The package nicematrix has tools to address that kind of problem.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\NiceMatrixOptions
  {
    code-for-first-col = \scriptstyle ,
    code-for-first-row = \scriptstyle 
  }

\[
\mathbf{P} = 
\begin{pNiceMatrix}[first-col,first-row]
  & H  & Y  & D \\
H & .8 & .2 & .0 \\
Y & .3 & .4 & .3 \\
D & .2 & .1 & .7 \\
\end{pNiceMatrix}
\]

\end{document}

Output of the above code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .