Runaway argument

Runaway argument? is the one LaTeX error whose line number is not to be trusted — and sometimes there is no line number at all. Leave off a closing } and TeX goes hunting for it, swallowing your text as it goes, and only cries out once it has swallowed everything it can. What it then reports is not where you made the mistake but where it ran out of room. In exchange, TeX prints back the exact text it swallowed: that is the line right after Runaway argument?, and it is the real map. This page covers how to read that map, why the message names something like ! Paragraph ended before \@sect was complete that you never typed, and how to use \newcommand* as a tripwire on purpose.

Read the runaway text, not the line number

The line after Runaway argument? begins exactly one character after the brace you failed to close. Search your editor for the first few words of that line and you have found the stray {. This is faster and far more reliable than staring at the line number. Below is real log output from an unclosed \textbf{.

terminal
Runaway argument?
{an important point that never closes. Another sentence on the next l\ETC.
! File ended while scanning use of \textbf .
<inserted text>
                \par
<*> t6.tex

Two things there are worth noticing. First, the trailing \ETC. — TeX’s mark that the swallowed text was too long to print and got cut off at the screen width. Second, the last line is not a line number like l.6 but the file name, <*> t6.tex. That form means TeX ran out of input altogether: it read to the end of the file, so the stray { is somewhere far above. A line number appears only when something stopped the runaway partway.

Paragraph ended before ... was complete: a blank line inside a short argument

The message means there is a blank line inside an argument. To TeX a blank line is not whitespace but a token, \par, and \par is not allowed inside a "short" argument — an argument of a macro defined without \long. So if a blank line slips into a \section{...} where you only meant a line break, you get a runaway even though the } is right there.

terminal
Runaway argument?
{A heading that runs on
! Paragraph ended before \@sect was complete.
<to be read again>
                   \par
l.5 and on across a blank line}

You have certainly never typed the name \@sect. In fact \section itself is defined \long and lets a blank line through — it is the internal macro that takes over the work, \@sect, that is not \long (a \show on TeX Live 2024 confirms both). The name in the message is not the command you typed but the internal macro that was actually collecting the argument. Similar unfamiliar names surface around \caption, \footnote and the table of contents. Do not be thrown by them: read the Runaway argument? line instead.

Why \par is forbidden in an argument at all

The restriction is not there to inconvenience you; it was put in deliberately to catch forgotten closing braces. Victor Eijkhout’s TeX by Topic, which ships with TeX Live, says of the rule against \par in arguments that it "is useful … in locating forgotten closing braces", and adds that "the empty line generates a \par, which most of the times means that a closing brace has been forgotten". A short argument, in other words, is a safety catch that stops the runaway early. Without the rule, one dropped { would let TeX silently swallow an entire document and stop with no clue at all.

A small experiment shows how literal the mechanism is. What TeX refuses is the token named \par itself, not the idea of ending a paragraph. \endgraf is an alias that behaves exactly like \par, yet writing it inside a short argument does nothing at all; writing \par in the same place raises ! Paragraph ended before ... was complete on the spot. TeX is simply comparing token names — which is precisely what makes a blank line, an otherwise meaningless piece of whitespace, a reliable signal it can detect.

How this differs from File ended while scanning use of ...

Two different lines can follow Runaway argument?, and they tell you how far the runaway got. Stopped by a blank line partway, you get Paragraph ended before ... was complete; never stopped at all, you get File ended while scanning use of .... A finer clue sits one line below. <to be read again> \par means TeX read a \par that came from a blank line and pushed it back; <inserted text> \par means TeX ran out of input and inserted a \par of its own. The first says the cause is nearby, the second that it is far away.

MessageWhat it meansWhere the log points
Runaway argument?the argument was never finished; the swallowed text always follows on the next linethe start of that next line is just past the unclosed {
Paragraph ended before ... was completea blank line (a \par) got inside a short argumentthe line number of the blank line; the { is a little above it
File ended while scanning use of ...no } ever appeared, right up to the end of the filenot a line number but <*> filename; the { is far above

Using \newcommand* as a deliberate tripwire

\newcommand creates a \long macro; \newcommand* creates a short one. A \show prints \long macro: for the first and a plain macro: for the second. The difference shows up sharply in a runaway. Forget the closing { of a macro defined without the star and TeX strides past blank lines all the way to the end of the file, finishing with ! Emergency stop. and no PDF at all. With the star it halts at the first blank line, names your macro, and the run still completes. That is not a difference of a few log lines; it is the difference between a suspect region of a few dozen lines and the whole document.

latex
% short: the runaway stops at the first blank line, and the run survives
\newcommand*{\keyword}[1]{\textbf{#1}}
%   ! Paragraph ended before \keyword was complete.
%   <to be read again>
%                      \par

% long (the default): the runaway reaches end of file
\newcommand{\keyword}[1]{\textbf{#1}}
%   ! File ended while scanning use of \keyword.
%   ! Emergency stop.

The practical rule is simple: define with \newcommand* any macro whose argument does not need to contain whole paragraphs. Headings, terms, units, short labels — that covers most macros people write. Reserve the unstarred form for macros that are meant to take paragraphs, such as the body of a boxed note. What the star means in itself, and how it relates to \renewcommand, belongs to the "Defining macros" page. And note that putting \verb or a verbatim environment inside an argument breaks in a different way entirely — the reason is on the "Verbatim" page.

How to actually find the missing brace

Search for the beginning of the runaway text first; if that fails, read what is inside it. The swallowed text often contains something that has no business being in an argument, and that tells you the range. If \begin {document} appears inside the runaway text, for instance, the unclosed { is in the preamble — forgetting to close the body of a \newcommand produces exactly that. If \end {document} appears, the runaway reached the end of the document. Once you are in the right neighbourhood, your editor’s brace matching earns its keep: put the cursor on a suspect { and see where its partner lands. When that still is not enough, comment out half the document, recompile, and halve whichever half still errors; a few rounds of that always lands on it.

terminal
Runaway argument?
{Hello \begin {document} Body. \end {document}
! File ended while scanning use of \@argdef.