LaTeX error "Environment align undefined": cause and fix
\begin{...} names an environment that neither LaTeX, the class nor a loaded package defines. The matching \end{...} then causes a second error, "\begin{document} ended by \end{align}", which disappears together with the first one.
Why it happens
- The package that defines the environment is not loaded.
alignneedsamsmath,tikzpictureneedstikz,tabularxneedstabularx,lstlistingneedslistings. - The environment name has a typo, for example
\begin{itemise}or\begin{tabel}. - The document class has no such environment.
abstractexists inarticleandreport, but not inbook. - The environment is your own and its
\newenvironmentline is missing or comes after the first use.
How to fix it
- Load the package in the preamble, for example
\usepackage{amsmath}foralign. - Correct the spelling in
\beginand in\end. - Define your own environment in the preamble:
\newenvironment{name}{code at the start}{code at the end}. See Define your own environments in LaTeX.
A document that produces the message
\documentclass{article}
\begin{document}
\begin{align}
a &= b + c
\end{align}
\end{document}The corrected document
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
a &= b + c
\end{align}
\end{document}Both documents were compiled with pdfLaTeX from TeX Live 2023. The first produces the message, the second compiles without an error.
Finding the line in the editor
The editor lists every error and warning of a compile run with file and line. Select an entry and the cursor jumps to that line. See Error list with jump to the line.