LaTeX error · Environments, lists and tables
LaTeX Error: \begin{itemize} on input line 4 ended by \end{enumerate}.
Quick answer
Every \begin{x} must be closed by \end{x}, and environments must close in the reverse order they were opened. LaTeX reached an \end{enumerate} while the innermost open environment was still itemize, opened on input line 4. Change the \end to the matching name, or add the missing \end for the inner environment before closing the outer one.
The error in the log
This is how the message appears in the .log file (and in the compile output). The line starting with l. is the line number where TeX noticed the problem; the real mistake is there or just before it.
! LaTeX Error: \begin{itemize} on input line 4 ended by \end{enumerate}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.7 \end{enumerate}Why it happens
- A copy-paste or rename left the
\beginand\endwith different names, for example\begin{itemize}closed by\end{enumerate}. - An inner environment was never closed, so the outer
\endarrives first:\begin{figure}with a forgotten\end{center}inside it, or a nested list without its own\end. \begin{document} ended by \end{...}or... ended by \end{document}means something was left open until the very end of the file.- A
\beginor\endwas commented out with%, or a verbatim or listing environment swallowed the closing line.
How to fix it
The message names both ends: the \begin with its input line number and the \end on the l. line. Go to the input line given, follow the environment down and check every nested \begin has its own \end in reverse order.
A consistent indentation makes this obvious: each \end should line up with its \begin.
Broken: reproduces the error
\documentclass{article}
\begin{document}
Steps:
\begin{itemize}
\item Install a TeX distribution
\item Compile the document
\end{enumerate}
\end{document}Try this in Octree — free LaTeX editor with AI, compiles in your browser
Fixed: compiles cleanly
\documentclass{article}
\begin{document}
Steps:
\begin{itemize}
\item Install a TeX distribution
\item Compile the document
\end{itemize}
\end{document}Related errors
- Environment undefined – A
\begin{...}name LaTeX does not know: usually a missing package or a typo. - Perhaps a missing \item – Text inside a list before the first
\item, or an empty bibliography or list. - Too many }'s – A closing brace at the outer level of the document that closes nothing.
- All LaTeX errors and warnings – The full list, grouped by cause
Frequently Asked Questions
What does "\begin{document} ended by \end{itemize}" mean?
There is an \end{itemize} with no matching \begin{itemize} in front of it, so the only open environment is the document itself. Delete the stray \end or add the missing \begin.
What does "\begin{itemize} ended by \end{document}" mean?
A list was opened and never closed, and LaTeX reached the end of the document with it still open. Add \end{itemize} where the list should finish.
Is the line number in the message where the mistake is?
The number after "on input line" is where the unclosed environment began. The l. line at the bottom of the log is where the mismatched \end was found. The mistake is somewhere between the two.
Paste your document into Octree — compile errors get a Fix with AI button
When a compile fails, Octree shows the error next to the line that caused it and offers a one-click fix that you can review before applying. Free, nothing to install.
Fix it in Octree →