LaTeX error "Too deeply nested": cause and fix
Lists are nested deeper than the document class allows. In the standard classes itemize and enumerate each go 4 levels deep, and all list environments together go 6 levels deep.
Why it happens
- A fifth
itemizeis opened inside four others, or a fifthenumerateinside four others. - An
\end{itemize}is missing, so the next list opens inside the previous one and not after it. - Other list environments count as levels too. Seven nested
quoteenvironments produce the same error.
How to fix it
- Check that every
\begin{itemize}has its\end{itemize}. - Restructure the content: 5 levels are hard to follow on paper. A subsection or a table often replaces the outer levels.
- If you need the depth, load
enumitem, raise the limit with\setlistdepth{9}and\renewlist{itemize}{itemize}{9}, and set a label for the new levels with\setlist[itemize]{label=\textbullet}.
A document that produces the message
\documentclass{article}
\begin{document}
\begin{itemize}\item Level 1
\begin{itemize}\item Level 2
\begin{itemize}\item Level 3
\begin{itemize}\item Level 4
\begin{itemize}\item Level 5
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}The corrected document
\documentclass{article}
\usepackage{enumitem}
\setlistdepth{9}
\renewlist{itemize}{itemize}{9}
\setlist[itemize]{label=\textbullet}
\begin{document}
\begin{itemize}\item Level 1
\begin{itemize}\item Level 2
\begin{itemize}\item Level 3
\begin{itemize}\item Level 4
\begin{itemize}\item Level 5
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\end{itemize}
\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.