Matrices in LaTeX: pmatrix, bmatrix, vmatrix
Inside math, use \begin{pmatrix} ... \end{pmatrix} for a matrix in parentheses, with & between the entries of a row and \\ between rows. bmatrix gives square brackets and vmatrix vertical bars for a determinant.
A first matrix
Matrix environments come from the amsmath package and are used inside math. Entries in a row are separated by &, rows end with \\. Each column is centred.
A 2 by 2 matrix in parentheses
A = \begin{pmatrix}
1 & 2 \\
3 & 4
\end{pmatrix}Brackets
The environment name sets the brackets around the matrix:
| Environment | Brackets | In Scissor LaTeX |
|---|---|---|
matrix | none | Works |
pmatrix | ( ) | Works |
bmatrix | [ ] | Works |
Bmatrix | { } | Works |
vmatrix | | | (determinant) | Works |
Vmatrix | ‖ ‖ (norm) | Works |
smallmatrix | none, small size for inline use | Works |
pmatrix*, bmatrix* (mathtools) | with column alignment | Not supported: the formula is red |
matrix, pmatrix, bmatrix, Bmatrix, vmatrix and Vmatrix
\begin{matrix} a & b \\ c & d \end{matrix} \quad
\begin{pmatrix} a & b \\ c & d \end{pmatrix} \quad
\begin{bmatrix} a & b \\ c & d \end{bmatrix} \quad
\begin{Bmatrix} a & b \\ c & d \end{Bmatrix} \quad
\begin{vmatrix} a & b \\ c & d \end{vmatrix} \quad
\begin{Vmatrix} a & b \\ c & d \end{Vmatrix}A norm can also be written with the double bars around a plain matrix, which gives the same result:
Vmatrix, and double bars around a matrix
\begin{Vmatrix} 3 \\ 4 \end{Vmatrix} = \left\| \begin{matrix} 3 \\ 4 \end{matrix} \right\| = 5Determinants
A determinant is a vmatrix. Write \det for the upright function name.
A determinant
\det \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bcLarge matrices with dots
\cdots (horizontal), \vdots (vertical) and \ddots (diagonal) stand for the entries you leave out.
An m by n matrix with dots
A = \begin{pmatrix}
a_{11} & a_{12} & \cdots & a_{1n} \\
a_{21} & a_{22} & \cdots & a_{2n} \\
\vdots & \vdots & \ddots & \vdots \\
a_{m1} & a_{m2} & \cdots & a_{mn}
\end{pmatrix}Vectors
A column vector is a matrix with one column. For a row vector, write one row.
Column and row vectors, transposed
\mathbf{v} = \begin{pmatrix} 4 \\ 4 \\ 2 \end{pmatrix}, \qquad
\mathbf{w}^\top = \begin{pmatrix} 1 & 0 & -1 \end{pmatrix}, \qquad
\mathbf{w}^\top \mathbf{v} = 2Small matrices in the text
smallmatrix sets a matrix small enough for a line of text. It has no brackets of its own, so add them with \left( and \right).
An inline matrix with smallmatrix
The rotation by 90 degrees is
$R = \left(\begin{smallmatrix} 0 & -1 \\ 1 & 0 \end{smallmatrix}\right)$,
and $R^2 = -I$.array: your own column alignment
The array environment works like tabular, but in math: the argument gives the alignment of each column (l, c, r).
An array with right- and left-aligned columns
\left( \begin{array}{rl}
-44 & x \\
2 & xyz
\end{array} \right)An augmented matrix with a column of bars
\left[ \begin{array}{cccc}
1 & 2 & | & 4 \\
0 & 1 & | & 4
\end{array} \right]What differs from a TeX installation
More on the amsmath page and the mathtools page. The full manuals are at ctan.org/pkg/amsmath and ctan.org/pkg/mathtools.
To build a matrix by clicking instead of typing, use the LaTeX matrix generator; it writes the pmatrix or bmatrix source for you.
Questions and answers
How do I write a matrix with square brackets in LaTeX?
Use \begin{bmatrix} ... \end{bmatrix} inside math, with & between entries and \\ between rows.
How do I write a determinant?
Use vmatrix, which puts vertical bars around the entries: \det \begin{vmatrix} a & b \\ c & d \end{vmatrix}.
How do I write a norm with double bars?
Use \begin{Vmatrix} ... \end{Vmatrix}, or \left\| \begin{matrix} ... \end{matrix} \right\|; both give the same double bars.
Every example on this page is typeset by Scissor LaTeX when the site is built. Last updated 2026-11-06.