What it means
TeX keeps several internal tables with sizes fixed when the distribution is set up: one for the macros it is in the middle of expanding, one for open groups, one for command names, one for macro definitions and the boxes being built, and others. When one fills up, TeX stops at once. This is a fatal error: the build ends and no PDF is written.
The words in square brackets name the table, and the number is its size. The numbers below are the TeX Live 2026 defaults for pdfLaTeX.
input stack size=10000: too many macros expanding inside one another. Almost always a command that calls itself.grouping levels=255: more than 255 groups open at once, from{or\begingroup. Usually a command that calls itself inside braces.save size=200000: too many local changes waiting to be undone at the end of one group, usually from a long loop that runs inside a group.main memory size=5000000: no room left for macro definitions and the material being built. A macro that grows without end, or a very large figure.number of strings,pool sizeandhash size: no room for more command names and strings, usually from a loop that creates a new name on every pass.buffer size: the buffer that holds the line TeX is reading filled up. A line in a file that is too long usually produces a different message in TeX Live,! Unable to read an entire line---bufsize=200000., which goes to the terminal and not to the log. Break the line into several.
The log line
This small file triggers the error. The second definition was meant to add text to \term, but it calls \term itself:
\documentclass{article}
\newcommand{\term}{effect size}
\renewcommand{\term}{\term\ (ES)}
\begin{document}
The \term{} is large.
\end{document}
Compiled with pdfLaTeX (TeX Live 2026), it writes this to the .log file:
! TeX capacity exceeded, sorry [input stack size=10000].
\term ->\term
\ (ES)
l.5 The \term
{} is large.
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.
Here is how much of TeX's memory you used:
427 strings out of 468979
8157 string characters out of 5454369
438367 words of memory out of 5000000
29654 multiletter control sequences out of 15000+600000
628489 words of font info for 40 fonts, out of 8000000 for 9000
36 hyphenation exceptions out of 8191
10000i,0n,38p,154b,36s stack positions out of 10000i,1000n,20000p,200000b,200000s
! ==> Fatal error occurred, no output PDF file produced!
The line after the message shows the macro TeX was expanding, \term, and its definition split at the point TeX had reached: just after the \term at the start. Each \term starts another one before it finishes, so the stack of unfinished macros grows until it holds 10,000. The l.5 line is the first use in the document. The memory summary that follows shows which table is full: here 10000i out of 10000i, the input stack.
To try a fix without touching your project, save the example as a .tex file and compile it online with the LaTeX to PDF tool.
Why it happens
The causes below are in order of likelihood. Each has a before and an after you can compare with your own source.
1. A command is redefined in terms of itself
Inside \renewcommand, the name always means the new definition, so the command calls itself forever. To extend a command, save a copy of the original under another name first and call the copy. \NewCommandCopy copies any command; for a command without an optional argument, \let\oldterm\term does the same.
Before
\newcommand{\term}{effect size}
\renewcommand{\term}{\term\ (ES)}
After
\newcommand{\term}{effect size}
\NewCommandCopy{\oldterm}{\term}
\renewcommand{\term}{\oldterm\ (ES)}
2. The same mistake inside braces or a group
When the self-call sits inside braces, or inside a command such as \textit that opens a group, TeX runs out of group levels first and the bracket says grouping levels=255. The command named in the log can then be an internal LaTeX one, such as \maybe@load@fontshape, because it was the one opening the group. The fix is the same as for cause 1.
Before
\renewcommand{\term}{\textit{\term}}
% ! TeX capacity exceeded, sorry [grouping levels=255].
After
\NewCommandCopy{\oldterm}{\term}
\renewcommand{\term}{\textit{\oldterm}}
3. A loop that never ends or makes too much
A loop whose end condition is never met, or that defines a new command name on every pass with \csname, runs out of strings, names or save space. Check the end condition, and store data in fewer names.
Before
\loop\advance\n by 1 \expandafter\def\csname item\the\n\endcsname{x}\ifnum\n<2000000 \repeat
% ! TeX capacity exceeded, sorry [number of strings=468979].
After
\loop\advance\n by 1 \expandafter\def\csname item\the\n\endcsname{x}\ifnum\n<200 \repeat
4. A macro that grows without end
A definition that adds to itself on every expansion fills main memory, especially inside \edef, which expands everything at once. Give the macro a way to stop.
Before
\def\a{x\a}
\edef\b{\a}
% ! TeX capacity exceeded, sorry [main memory size=5000000].
After
\def\a{x}
\edef\b{\a}
5. A very large TikZ or pgfplots figure
A plot with many thousands of points can fill main memory in pdfLaTeX even when nothing is wrong with the code. Plot fewer points with pgfplots' each nth point key, externalize the figure so it is built once as its own PDF, or compile with LuaLaTeX, which allocates memory as it needs it. Externalizing needs shell escape, the -shell-escape option to pdflatex.
Before
\usepackage{pgfplots}
% a plot of 200,000 data points
After
\usepackage{pgfplots}
\usetikzlibrary{external}
\tikzexternalize
% compile with: pdflatex -shell-escape main.tex
Raising the limits
The sizes come from texmf.cnf, and they can be raised. That is rarely the right fix. A command that calls itself fills any size, so the error only takes longer to arrive. A changed texmf.cnf also applies only to your own computer, so co-authors and a journal's build system still fail on the same file. Raise a limit only when you know the document is large and nothing in it repeats without end.
How to find the line
Read the line just below the message first. It names the macro TeX was expanding and shows where in its definition TeX had got to. If it is your own command, look at its definition. If it is an internal LaTeX command, look at the l. line for the command of yours that started it.
When you run pdflatex in a terminal without -interaction=nonstopmode, TeX stops at the error and prints a ? prompt. Press Return to carry on past the error, type x to quit, or type h for TeX's own help text, which is the paragraph you see after the l. line in the log. Editors run TeX in non-stop mode, so you get the log and never see the prompt.
What each editor shows:
- ModernTex: when a build fails, the Build button shows the error count and the last good PDF stays on screen. The Build Results panel lists each error, warning and note in plain language, Compile › Next Issue steps through them, and Raw Log shows the full LaTeX log. See ModernTex.
- Overleaf: the logs panel, opened with the button next to Recompile, lists each error and warning with its file and line, and the editor marks the line in the gutter. The unprocessed log is at the bottom of that panel.
- TeXShop: the console window shows the log as it is written and stops at the error. Goto Error moves the source window to the line. TeXShop's default pdfLaTeX command includes
--file-line-error, so the message starts with the file and line instead of!:./main.tex:5: TeX capacity exceeded, sorry [input stack size=10000].
Related errors
- Too many }'s / Missing } inserted: braces that do not pair up, a common reason a group is never closed.
- Runaway argument: another error where TeX reads on far past the mistake.
- Undefined control sequence: what you get when a renamed copy such as
\oldtermis used before it is defined.