Label rows of a matrix by characters
You can use the blkarray
package:
\documentclass[12pt]{report}
\usepackage{blkarray}
\usepackage{amsmath}
\begin{document}
\[
\begin{blockarray}{cccccc}
a & b & c & d & e \\
\begin{block}{(ccccc)c}
1 & 1 & 1 & 1 & 1 & f \\
0 & 1 & 0 & 0 & 1 & g \\
0 & 0 & 1 & 0 & 1 & h \\
0 & 0 & 0 & 1 & 1 & i \\
0 & 0 & 0 & 0 & 1 & j \\
\end{block}
\end{blockarray}
\]
\end{document}
Here is an option using kbordermatrix
:
\documentclass{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\usepackage{kbordermatrix}% http://www.hss.caltech.edu/~kcb/TeX/kbordermatrix.sty
\begin{document}
\[
\begin{array}{l@{{}={}}c}
\text{Mat}_{\varphi\text{ to }M} & \left(\begin{array}{@{}ccccc@{}}
1 & 1 & 1 & 1 & 1 \\
0 & 1 & 0 & 0 & 1 \\
0 & 0 & 1 & 0 & 1 \\
0 & 0 & 0 & 1 & 1 \\
0 & 0 & 0 & 0 & 1
\end{array}\right)
\end{array}
\]
\renewcommand{\kbldelim}{(}% Left delimiter
\renewcommand{\kbrdelim}{)}% Right delimiter
\[
\text{Mat}_{\varphi\text{ to }M} = \kbordermatrix{
& c_1 & c_2 & c_3 & c_4 & c_5 \\
r_1 & 1 & 1 & 1 & 1 & 1 \\
r_2 & 0 & 1 & 0 & 0 & 1 \\
r_3 & 0 & 0 & 1 & 0 & 1 \\
r_4 & 0 & 0 & 0 & 1 & 1 \\
r_5 & 0 & 0 & 0 & 0 & 1
}
\]
\end{document}
For more options and styles, including the usage of \bordermatrix
, see Where is the \matrix
command?
I'll add a variant with blockarray
, with footnote size text as column and row headings (answer to another, duplicate question):
\documentclass{article}
\usepackage{mathtools}
\usepackage{blkarray, bigstrut} %
\begin{document}
\begin{equation*}
\mathbf{S}=
\begin{blockarray}{*{5}{c} l}
\begin{block}{*{5}{>{$\footnotesize}c<{$}} l}
Rose & Teal & Plum & Sand & Peach & \\
\end{block}
\begin{block}{[*{5}{c}]>{$\footnotesize}l<{$}}
0 & 9 & 8 & 0 & 7 \bigstrut[t]& small \\
3 & 5 & 6 & 5 & 1 & medium \\
1 & 0 & 0 & 3 & 2 & large \\
\end{block}
\end{blockarray}
\end{equation*}
\end{document}