LaTeX error "Too deeply nested": cause and fix

Error Too deeply nested

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

How to fix it

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}

Open in the editor

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}

Open in the editor

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.

Related pages