Mathematical Expressions
Document Structure
Matrices and Arrays in LaTeX
LaTeX provides several environments for creating matrices and arrays. This guide covers the different types of matrices, their syntax, and advanced formatting options.
Basic Matrix Types
LaTeX offers various matrix environments, each with different delimiters:
matrix Environment (no delimiters)
\egin{matrix} a & b \\ c & d \end{matrix}
pmatrix Environment (parentheses)
\egin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}
bmatrix Environment (square brackets)
\egin{bmatrix} x & y \\ z & w \end{bmatrix}
vmatrix Environment (vertical bars)
\egin{vmatrix} a & b \\ c & d \end{vmatrix}
Quick Tools for Creating LaTeX Matrices
Need to create a matrix quickly?
Use our Matrix Generator to instantly create various types of matrices including identity, diagonal, and custom matrices with different delimiters.
Open Matrix Generator
Matrix with Alignment
You can control column alignment using the array environment:
\egin{array}{lcr} \ ext{left} & \ ext{center} & \ ext{right} \\ 1 & 2 & 3 \\ 4 & 5 & 6 \end{array}
The {lcr}
specifies left, center, and right alignment for each column.
Augmented Matrices
For systems of equations, you can create augmented matrices using the array environment:
\left[\begin{array}{cc|c} 1 & 2 & 3 \\ 4 & 5 & 6 \end{array}\right]
The vertical line in {cc|c}
creates the augmentation line.
Small Matrices
For inline matrices, use the smallmatrix environment:
A = \egin{pmatrix*}[r] -1 & 2 \\ 3 & -4 \end{pmatrix*}
Advanced Matrix Features
Dots in Matrices
\egin{pmatrix} 1 & \cdots & n \\ \dots & \ddots & \dots \\ m & \cdots & mn \end{pmatrix}
Nested Matrices
\egin{bmatrix} A & \egin{bmatrix} x \\ y \end{bmatrix} \\ 0 & 1 \end{bmatrix}
Matrix with Text
\egin{pmatrix} \ ext{row 1} & x_1 \\ \ ext{row 2} & x_2 \end{pmatrix}
Best Practices
- Use
\begin{array}
when you need precise control over column alignment - Use
\begin{pmatrix}
or\begin{bmatrix}
for standard matrices - Use
\begin{smallmatrix}
for inline matrices to maintain proper line spacing - Use
\vdots
,\ddots
, and\cdots
for professional-looking ellipses
Remember to include \usepackage{amsmath}
in your document preamble to access these matrix environments.