# How do I produce matrices?

This is my work. I did exactly what my tutorial said, but the latex simply doesn't work....What have I done wrong? It's extremely frustrating...

\documentclass{article}
\begin{document}
\begin{matrix}
1&0\\
0&1
\end{matrix}
\end{document}

• Welcome! Please provide some compilable code, i.e. an MWE, not just a screenshot.
– user121799
Jan 25, 2018 at 17:09

\documentclass{article}
\usepackage{amsmath}
\begin{document}
Matrices require appropriate packages, e.g.\ \texttt{amsmath}, and math
environments.
$\begin{matrix} 1 & 0\\ 0 & 1 \end{matrix}\quad\text{vs.}\quad \begin{pmatrix} 1 & 0\\ 0 & 1 \end{pmatrix}$
If you don't like to load \texttt{amsmath}, you can get matrices with arrays.
$\begin{array}{cc} 1 & 0\\ 0 & 1 \end{array}\quad\mbox{vs.}\quad \left(\begin{array}{cc} 1 & 0\\ 0 & 1 \end{array}\right)$
As you can see, this requires you to specify the columns.

If you want to number them, use some numbered math environment like
\texttt{equation} or \texttt{align}.
$$\begin{pmatrix} -1 & 0\\ 0 & -1 \end{pmatrix}\cdot \begin{pmatrix} -1 & 0\\ 0 & -1 \end{pmatrix}~=~ \begin{pmatrix} 1 & 0\\ 0 & 1 \end{pmatrix}\;,$$
\begin{align}
\begin{pmatrix}
-1 & 0\\
0 & -1
\end{pmatrix}\cdot \begin{pmatrix}
-1 & 0\\
0 & -1
\end{pmatrix}&~=~
\begin{pmatrix}
1 & 0\\
0 & 1
\end{pmatrix} \\
&~=~
\begin{pmatrix}
1 & 0\\
0 & 1
\end{pmatrix}^{-1}\;.
\end{align}

• And it needs to be in a math environment: so it's either in \$ or between $ and $. Jan 25, 2018 at 17:16