LaTeX error "TeX capacity exceeded, sorry [input stack size=10000]": cause and fix

Error TeX capacity exceeded, sorry [input stack size=10000]

TeX ran out of one of its internal memory areas and stopped; no PDF is written. The square brackets name the area. The usual reason is not a large document but a command that calls itself without end.

Why it happens

How to fix it

A document that produces the message

\documentclass{article}
\renewcommand{\thesection}{\thesection.}
\begin{document}
\section{Introduction}
Text.
\end{document}

Open in the editor

The corrected document

\documentclass{article}
\renewcommand{\thesection}{\arabic{section}.}
\begin{document}
\section{Introduction}
Text.
\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