Mathematical Typesetting
How to Write Matrices in LaTeX
LaTeX provides several matrix environments with different bracket styles. You'll need the amsmath package.
Matrix Types
Different environments give different brackets:
\usepackage{amsmath}
% No brackets
$\begin{matrix} 1 & 2 \\ 3 & 4 \end{matrix}$
% Parentheses ()
$\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}$
% Square brackets []
$\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}$
% Curly braces {}
$\begin{Bmatrix} 1 & 2 \\ 3 & 4 \end{Bmatrix}$
% Vertical bars |
$\begin{vmatrix} 1 & 2 \\ 3 & 4 \end{vmatrix}$3x3 Matrix Example
Larger matrices work the same way:
$\begin{bmatrix}
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1
\end{bmatrix}$Matrix with Dots
For large matrices, use dots:
$\begin{pmatrix}
a_{11} & \cdots & a_{1n} \\
\vdots & \ddots & \vdots \\
a_{m1} & \cdots & a_{mn}
\end{pmatrix}$💡 Tips
- •Use & to separate columns, \\\\ to separate rows
- •\cdots for horizontal dots, \vdots for vertical, \ddots for diagonal
- •For augmented matrices, use the array environment with | in column spec
Try This in Bibby AI
Write LaTeX faster with AI auto-complete and instant compilation.
Start Writing Free