LaTeX Error: \begin{<a>} on input line <n> ended by \end{<b>}
An environment is closed by the wrong \end: a misspelled \end, environments closed in the wrong order, or a missing \end{…} further up.
Help centre › LaTeX errors › Braces and environments · Error: the build stops or the output is wrong
What the log says
! LaTeX Error: \begin{itemize} on input line 3 ended by \end{enumerate}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \end{enumerate}What it means
Environments must close in the reverse order they opened, each \begin{x} with its own \end{x}. LaTeX reached an \end{b} while the innermost open environment was a, opened on the input line the message names. The two numbers bracket the problem: the \begin on input line <n> and the \end on l.<n>.
Causes and fixes
Most common first. Each example is a complete document; the first fails with this message, the second is the same document fixed.
1. The \end names a different environment than the \begin
A list changed from itemize to enumerate, or a table* closed with \end{table}, or a typo. Make the \end name match the \begin exactly, star included.
\documentclass{article}
\begin{document}
\begin{itemize}
\item First
\item Second
\end{enumerate}
\end{document}\documentclass{article}
\begin{document}
\begin{itemize}
\item First
\item Second
\end{itemize}
\end{document}2. Nested environments are closed in the wrong order
The inner environment has to close before the outer one: \begin{figure} \begin{center} … \end{center} \end{figure}, not the other way round. Indenting each level makes the order visible.
\documentclass{article}
\begin{document}
\begin{figure}
\begin{center}
\rule{3cm}{2cm}
\caption{A sample.}
\end{figure}
\end{center}
\end{document}\documentclass{article}
\begin{document}
\begin{figure}
\begin{center}
\rule{3cm}{2cm}
\caption{A sample.}
\end{center}
\end{figure}
\end{document}3. An environment is never closed
When the \end in the message is \end{document}, an environment opened on the named input line was never closed. Add its \end{…} where it should stop.
\documentclass{article}
\begin{document}
\begin{quote}
A quoted passage.
The discussion continues here.
\end{document}\documentclass{article}
\begin{document}
\begin{quote}
A quoted passage.
\end{quote}
The discussion continues here.
\end{document}4. A command defined to open an environment is used without its partner
Shorthands such as \newcommand{\bi}{\begin{itemize}} hide the \begin. Search for the macro as well as for the environment name, and make sure every opening command has its closing one.
In Manulyx
The editor shows the error beside the \end that does not match, with an explanation.
Write in Manulyx for free · Journal templates
More in braces and environments
- Extra }, or forgotten $.A closing brace } has no matching {. Count the braces on the reported line, or look for a $ that closes maths inside a {…} group.
- Missing } inserted.A { group was still open when maths or a table cell ended. Close the brace before the $ or & that ends it.
- Runaway argument?A command's argument was never closed, so TeX read on to the end of a paragraph or of the file. Add the missing } after the argument.
- Paragraph ended before \<name> was complete.A blank line (paragraph break) appeared inside an argument or maths environment that cannot contain one, often because a } or \end{…} is missing.
Every example on this page was compiled with pdfLaTeX to check that it fails and is fixed as described. All LaTeX errors