Matrix in LaTeX
Matrices are built with environments from the amsmath package. Separate columns with & and rows with a double backslash \\. The environment name decides the brackets: pmatrix gives round ones, bmatrix square ones and vmatrix the vertical bars of a determinant.
Round brackets
\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}Determinant
\det A = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bcn × n matrix
\begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{n1} & \cdots & a_{nn} \end{bmatrix}Common mistakes
- No amsmath package in the preamble: pmatrix and bmatrix fail with "Environment undefined".
- Building a matrix with tabular: spacing and brackets do not adapt to math mode.
See also
Don't want to memorize commands?
Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.