# How to create a labelled matrix in LaTeX?

• LaTeX
• rwinston

#### rwinston

Hi

does anybody know how to create a labelled matrix in LaTeX? By which I mean something like this:
a b
a [ 1 0 ]
b [ 0 1 ]

Where the inner elements are within the braces, but there are tabular label elements for the rows and columns (a and b). Cant get it too look right!

Cheers

Hi rwinston,

If you don't mind parenthesis instead of braces you can use bordermatrix from plain TeX:

$$\bordermatrix{&a_1&a_2& a_3 \cr b_1 & 1 & 2 & 3 \cr b_2 & 2 & 3 & 4 \cr b_3 & 3 & 4 & 5 \cr}$$

$$\bordermatrix{&a_1&a_2\cr b_1 & 1 & 2 \cr b_2 & 2 & 3 \cr}$$

$$\bordermatrix{&a_1&a_2 \cr b_1 & 1 & 2 \cr b_2 & 2 & 3 \cr b_3 & 3 & 4 \cr}$$

There is also a newer kbordermatrix package that you can use that gives more options (such as being able to change the delimiters).

Thanks! Thats exactly what I need!

## 1. How do I create a labelled matrix in LaTeX?

To create a labelled matrix in LaTeX, you will need to use the \begin{matrix} and \end{matrix} commands. Inside these commands, you can input your matrix elements and use the & symbol to separate columns and \\ to separate rows. To add labels to the matrix, you can use the \label{} and \ref{} commands.

## 2. Can I customize the appearance of my labelled matrix in LaTeX?

Yes, you can customize the appearance of your labelled matrix in LaTeX using various commands. For example, you can use \renewcommand{\arraystretch}{1.5} to increase the spacing between rows, or \setlength{\arraycolsep}{5pt} to adjust the spacing between columns. You can also use \begin{pmatrix} and \end{pmatrix} to create a matrix with parentheses instead of brackets.

## 3. How can I add mathematical symbols and equations to my labelled matrix in LaTeX?

You can add mathematical symbols and equations to your labelled matrix in LaTeX by using the appropriate commands. For example, you can use \alpha to add the symbol for alpha or \frac{}{} to create a fraction. You can also use the \begin{align*} and \end{align*} commands to add equations to your matrix.

## 4. Can I add colors to my labelled matrix in LaTeX?

Yes, you can add colors to your labelled matrix in LaTeX by using the \usepackage{color} command and then using the \color{} command to specify a color for your matrix elements. You can also use the \cellcolor{} command to specify a color for a specific cell in your matrix.

## 5. How do I reference a specific cell in my labelled matrix in LaTeX?

You can reference a specific cell in your labelled matrix in LaTeX by using the \ref{} command and specifying the label of the cell. You can also use the \eqref{} command to add parentheses around the reference number. Additionally, you can use the \cline{} command to add horizontal lines to your matrix and visually indicate the cell you are referencing.