[Tex/LaTex] LaTeX doesn’t recognize \end{array}

arraysmatrices

Following code

... \begin{align}
\begin{array}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}...

results in numerous errors:

 - Argument of \array has an extra }   (line 0)
 - Missing $ inserted \end{align}
 - Missing \endgroup inserted \end{align} 
 - Extra }, or forgotten $ \end{align} 
 - \begin{align} on input line 101 ended by \end{array}. \end{align} 
 - Misplaced alignment tab character & \end{align}   (2x, same line) 
 - Misplaced \omit \end{align} 
 - Misplaced \cr \end{align}
 - Misplaced alignment tab character & \end{align} (2x)
 - Misplaced \cr \end{align} 
 - Extra }, or forgotten $ \end{align} (2x)
 - Missing number, treated as zero \end{align}
 - Illegal unit of measure (pt inserted) \end{align}
 - Missing number, treated as zero (3x, line 0)
 - Missing $ inserted \end{align} 
 - Display math should end with $$ (line 0)
 - Missing $ inserted \end{align}
 - Missing \endgroup inserted \end{align}
 - Extra }, or forgotten $ \end{align} 
 - Missing $ inserted \end{align} 
 - Too many }'s \end{align} 
 - \begin{document} ended by \end{array}. (line 0) 
 - Misplaced \noalign \end{align} (2x)
 -  Too many }'s \end{align}
 - \begin{document} ended by \end{align}. \end{align} 
 - Display math should end with $$ (line 0)

Of course code without this compiles just fine.

All errors are at line 109 (\end{align}), except those at line 0.

Matrix environment (examples) also compiles with errors, but fewer. These are:

 - Paragraph ended before \array was complete I've inserted a
   begin-math/end-math symbol since I think

 - Missing \right. inserted I've inserted something that you may have
   forgotten.

 - Missing \endgroup inserted

I'm using TexStudio on Ubuntu. I also tried with Geany but it throws the same errors.

Best Answer

You need to specify the array format; for example:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\begin{align}
\begin{array}{ccc}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

enter image description here

Some new information has been given in the comments; the problem comes from using the arrayjob and amsmath packages simultaneously, as this example shows:

\documentclass{article}
\usepackage{arrayjob}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{array}{ccc}
1 & 2 & 3 \\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

Processing the above document triggers the error

! Argument of \array has an extra }.
<inserted text> 
                \par 
l.12 \end{align}

The conflict comes from the macro name \array used by arrayjob which conflicts with macros in amsmath; the arrayjobx package (which is an improved version of arrayjob) solves this issue using the macro \arrayx instead. Thus, in order to prevent the conflict between the packages arrayjob and amsmath, use arrayjobx instead of arrayjob:

\documentclass{article}
\usepackage{arrayjobx}
\usepackage{amsmath}

\begin{document}

\begin{align}
\begin{array}{ccc}
1 & 2 & 3\\
1 & 2 & 3
\end{array}
\end{align}

\end{document}

I am aware that there's no point in using array inside align as I did in my answer; if the only intent is to get a displayed (numbered) expression, the equation environment would be a better choice; if no display number is needed, then \[...\] is enough. I kept the original align just in the hope that the OP's actual expression deserves its use.