Master LaTeX matrices and arrays. Learn pmatrix, bmatrix, determinants, block matrices, and advanced layouts with visual examples.
\usepackage{amsmath}
. Some advanced features require additional packages like array
or mathtools
.Related topics: Mathematical equations | Table creation | Mathematical symbolsamsmath
package, each with different delimiters:
Environment | Delimiters | Common Use | Example |
---|---|---|---|
matrix | None | Building block for custom delimiters | Basic array |
pmatrix | ( ) | General matrices, transformations | Linear algebra |
bmatrix | [ ] | General matrices, data tables | Numerical data |
Bmatrix | Set notation, systems | Set theory | |
vmatrix | | | | Determinants | det(A) |
Vmatrix | || || | Norms, magnitudes | ||v|| |
&
to separate columns\\
to end rows\\
after the last row$...$
or \[...\]
)array
environment provides the most flexibility for creating custom matrix-like structures:
center | right | left |
a + b | 12.34 | xyz |
c | 5.6 | pqrs |
1 | 2 | 3 | 4 |
5 | 6 | 7 | 8 |
x | = | 2y + 3z |
2x − y | = | 7 |
x + 3y | = | 4z − 1 |
Specifier | Alignment | Description | |
---|---|---|---|
l | Left | Left-aligned column | |
c | Center | Centered column | |
r | Right | Right-aligned column | |
p{width} | Paragraph | Fixed width with text wrapping | |
` | ` | — | Vertical line between columns |
@{text} | — | Custom separator (replaces default spacing) | |
*{n}{spec} | — | Repeat specifier n times |
A | B |
C | D |
|
| ||||||
g h | i |
1 | 2 | 3 | 6 |
4 | 5 | 6 | 15 |
7 | 8 | 9 | 24 |
1 | 2 | −1 | 3 |
2 | −1 | 3 | 7 |
−1 | 3 | 2 | 0 |
1 | 2 | −1 | 3 |
0 | −5 | 5 | 1 |
−1 | 3 | 2 | 0 |
smallmatrix
environment:
Col 1 | Col 2 | Col 3 | |
Row 1 | a₁₁ | a₁₂ | a₁₃ |
Row 2 | a₂₁ | a₂₂ | a₂₃ |
Row 3 | a₃₁ | a₃₂ | a₃₃ |
X | Y | Z | |
X | 1.00 | 0.85 | 0.42 |
Y | 0.85 | 1.00 | 0.67 |
Z | 0.42 | 0.67 | 1.00 |
My matrix delimiters are too small
\left
and \right
with array:pmatrix
which handle this automatically.Alignment issues in matrices
array
with explicit alignment: {rrr}
for right-alignedsiunitx
package with S
columns\phantom{}
for consistent widthsMatrix too wide for page
\small
or \footnotesize
before the matrixbmatrix*}[r]
from mathtools
for right-aligned entriesarray
environment with custom column spacingSpacing between matrix elements
vmatrix
for determinants, pmatrix
for general matricessmallmatrix
for inline matrices\,
or \:
for better readability when neededPackage | Purpose | Key Features |
---|---|---|
amsmath | Basic matrix environments | All standard matrix types |
mathtools | Extended matrix features | Starred versions, more options |
array | Custom column types | Full control over layout |
siunitx | Numeric alignment | Decimal alignment in matrices |
blkarray | Block arrays | Labels and blocks |
nicematrix | Enhanced matrices | Many advanced features |