Matrices
rating: +1+x

« All Snippets

Basic Commands

The matrix environment can be used to produce matrices. Entries are separated by the & symbol, and rows are separated by a double-slash \\:

  • \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{matrix} produces
(1)
\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{matrix}

Variations

In general, one can surround the matrix using a \left and a \right command:

  • \left\{\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{matrix}\right) produces
(2)
\begin{align} \left\{\begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{matrix}\right) \end{align}

There is an easier approach, unless you're doing something very unusual. The variations bmatrix, pmatrix, etc. will provide the common outside elements:

  • \begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix} produces $\begin{bmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{bmatrix}$
  • \begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix} produces $\begin{pmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{pmatrix}$
  • \begin{vmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{vmatrix} produces $\begin{vmatrix} 1 & 2 & 3 \\ 4 & 5 & 6 \end{vmatrix}$

Alternatives

The matrix command gives the same result (in size) for both in-line equations and display style equations. One alternative for matrices with two rows is to use the \binom command, together with the space command \: to separate values:

  • \binom{3\:4}{5\:6} produces $\binom{3\:4}{5\:6}$.
Add a New Comment
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License