Identity Matrix in LaTeX

Choose the size and copy the LaTeX for an identity matrix.

Free · Runs in your browser · Your text is never uploaded

A grid of numbers turned into a bracketed LaTeX matrix

The code

A 3×3 identity matrix is \begin{pmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 1 \end{pmatrix} with amsmath loaded.

Shorthand

For large matrices you can write dots instead: put 1 ... 0 and : ⋱ : style entries, or use \ddots by typing ⋱ in a cell.

Other special matrices

Switch the source to zero matrix, all ones or symbolic entries a_{ij}.

Need more options? Open the full LaTeX Matrix Generator.

Related guides

Frequently asked questions

How do I write the identity matrix in LaTeX?

Use a matrix environment with 1 on the diagonal and 0 elsewhere. The generator writes it for any size.

Which package is needed?

amsmath.