All guides

Matrix in LaTeX

Updated:

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}
(1234)\begin{pmatrix} 1 & 2 \\ 3 & 4 \end{pmatrix}

Copying this from handwritten notes? Snap a photo of the page and CamteX turns the formulas into LaTeX. Try it free

Determinant

\det A = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc
det⁡A=∣abcd∣=ad−bc\det A = \begin{vmatrix} a & b \\ c & d \end{vmatrix} = ad - bc

n × n matrix

\begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{n1} & \cdots & a_{nn} \end{bmatrix}
[a11⋯a1n⋮⋱⋮an1⋯ann]\begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & \ddots & \vdots \\ a_{n1} & \cdots & a_{nn} \end{bmatrix}

Don't want to type it by hand? LaTeX matrix generator

Common mistakes

See also

Don't want to memorize commands?

Draw a formula or paste a screenshot, and CamteX turns it into ready LaTeX.

Try it free