# Error when trying to define matrix

I'm trying to define a matrix:

\begin{matrix}
a & b & c \\
d & e & f
\end{matrix}


But I'm keep getting this error:

! Missing $inserted.<inserted text>$ \begin{matrix}
! Missing $inserted.<inserted text>$ \end{matrix}

• $\begin{matrix}...\end{matrix}$ should do!
– user31729
Oct 25 '15 at 22:23

The matrix environment must be used in math mode, i.e. use $\begin{matrix}...\end{matrix}$ or within one of the various math-environments such as equation or align etc.

\documentclass{article}

\usepackage{mathtools}% Only needed for pmatrix etc.

\begin{document}

$\begin{matrix} a & b & c \\ d & e & f \end{matrix}$

$\begin{pmatrix} a & b & c \\ d & e & f \end{pmatrix}$

$$\begin{bmatrix} a & b & c \\ d & e & f \end{bmatrix} &\neq \begin{Bmatrix} a & b & c \\ d & e & f \end{Bmatrix}$$

\end{document}