1

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}
1
  • 1
    $\begin{matrix}...\end{matrix}$ should do!
    – user31729
    Commented Oct 25, 2015 at 22:23

1 Answer 1

2

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{equation}
\begin{bmatrix}  
a & b & c \\
d & e & f
\end{bmatrix} &\neq 
\begin{Bmatrix}  
a & b & c \\
d & e & f
\end{Bmatrix}
\end{equation}


\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .