Using the delimiters seen before, you can already create matrices. Or, rather, things that look somewhat like a matrix.

But let’s never forget the semantics and use a proper matrix environment for this. It looks better and you can read your TeX file and immediately know what is supposed to represent a matrix (and what isn’t).

The environments below all roughly do the same—create a matrix—but have subtle differences that might simplify your life. They all follow the general table syntax.

1\begin{matrixType}
2    row 1, number 1 && row 1, number n \\
3    % … \\
4    row m, number 1 && row m, number n 
5\end{matrixType}

Each row is terminated by a newline (two backslashes) and each column by an ampersand.

Plain Matrix

The matrix environment creates a matrix with everything lined up correctly, but nothing around it to signal it’s a matrix. This is useful, for instance, for creating a submatrix within a matrix.

1\[
2    \begin{matrix}
3        0 & 1 & 2 \\
4        3 & 4 & 5 \\
5        6 & 7 & 8
6    \end{matrix}
7\]
Code left > output right
Code left > output right

Surrounded Matrices

One of the following environments can be used if you want a certain kind of delimiter surrounding your matrix:

EnvironmentDescription
bmatrixBrackets around the matrix (usual notation)
BmatrixBraces around the matrix
pmatrixParentheses around the matrix
vmatrixVertical bars around the matrix (used to represent the determinant)
VmatrixDouble vertical-bars around the matrix
1\[
2    \begin{bmatrix}
3        0 & 1 & 2\
4        3 & 4 & 5\
5        6 & 7 & 8
6    \end{bmatrix}
7\]
Code left > output right
Code left > output right

Inline Matrices

To use a matrix inline—so that the flow of text is not disrupted—use the smallmatrix environment.

This, however, only creates a smaller plain matrix. You need to add delimiters yourself. And the matrix can’t be too large to begin with.

1This matrix, $\begin{smallmatrix} a & 0\0 & b \end{smallmatrix}$, is inline.
Code left > output right
Code left > output right
Support me and this website!

Want to support me?

Buy one of my projects. You get something nice, I get something nice.

Donate through a popular platform using the link below.

Simply giving feedback or spreading the word is also worth a lot.