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}.
| Environment | Delimiters |
|---|---|
| matrix | None |
| 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 freeDots in Matrices
Use dot commands to indicate repeating patterns in large matrices:
| Command | Meaning |
|---|---|
| \cdots | Horizontal dots (centred on the line) |
| \ldots | Horizontal dots (on the baseline) |
| \vdots | Vertical dots |
| \ddots | Diagonal 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
More LaTeX Topics
Bold TextItalic TextUnderline TextStrikethroughFont SizeText ColorText AlignmentHyperlinksSectionsTable of ContentsNew PageNew LineMarginsLine SpacingPage NumbersHeaders & FootersMinipageTablesFigures & ImagesListsEquationsFractionsSquare RootSubscript & SuperscriptSummationIntegralGreek LettersArrowsTilde (~)Delta (δ, Δ)Hash (#)BibliographyCross-ReferencesFootnotes