Matrices in LaTeX

Use pmatrix, bmatrix, and related environments from the amsmath package.

Quick Answer

latex
\usepackage{amsmath}  % in preamble

\[
  A = \begin{pmatrix}
    1 & 2 \\
    3 & 4
  \end{pmatrix}
\]

Matrix Environments

All six matrix environments use the same syntax — they differ only in the delimiters placed around the matrix. All require \usepackage{amsmath}.

EnvironmentDelimiters
matrixNone
pmatrix( )
bmatrix[ ]
Bmatrix{ }
vmatrix| |
Vmatrix‖ ‖
latex
\[
  \begin{matrix}  1 & 0 \\ 0 & 1 \end{matrix}   % no delimiters
  \quad
  \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}  % ( )
  \quad
  \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}  % [ ]
\]

Writing your thesis in LaTeX?

MonsterWriter's LaTeX Workspace gives you real-time PDF preview with no compile limits — at a fraction of Overleaf's price. Works just like Overleaf, costs 11× less.

Try MonsterWriter free

Dots in Matrices

Use dot commands to indicate repeating patterns in large matrices:

CommandMeaning
\cdotsHorizontal dots (centred on the line)
\ldotsHorizontal dots (on the baseline)
\vdotsVertical dots
\ddotsDiagonal dots
latex
\[
  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}
\]

Inline Matrices

For a matrix inside running text, use smallmatrix — it renders at inline size.

latex
The identity matrix $\begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}$
is a special case, but the small variant
$\left(\begin{smallmatrix} 1 & 0 \\ 0 & 1 \end{smallmatrix}\right)$
fits better in running text.

Augmented Matrix

latex
\[
  \left(
    \begin{array}{cc|c}
      1 & 2 & 3 \\
      4 & 5 & 6
    \end{array}
  \right)
\]

Related Topics