Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

TeX gets lost after "! File ended while scanning ..."

3,672 views
Skip to first unread message

Jon Guyer

unread,
Feb 5, 1995, 4:21:31 PM2/5/95
to
While beta-testing OzTeX 1.8, I discovered a (dare I say?) problem. Andrew
Trevorrow has since determined that this lies with TeX, not just OzTeX,
since it occurs in unix implimentations as well. He suggested I post here.

If, in the process of LaTeXing a file, the error "! File ended while
scanning ..." is generated, such as by a missing "}" following
"\end{document":
______

\documentclass{article}
\begin{document}
\end{document
______

the following output is generated:
______

This is TeX, Version 3.1415 (no format preloaded)
**&LaTeX EndedTest.tex
(EndedTest.tex
LaTeX2e <1994/12/01> patch level 1
(:TeX-inputs:LaTeX:article.cls
Document Class: article 1994/12/09 v1.2x Standard LaTeX document class
(:TeX-inputs:LaTeX:size10.clo)) (EndedTest.aux))
Runaway argument?
{document
! File ended while scanning use of \end.
<inserted text>
\par
<*> &LaTeX EndedTest.tex

? e
Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something,
H for help, X to quit.
? h
I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

? x
No pages of output.
Transcript written on EndedTest.log.

Memory allocated: 989006 bytes.
Time elapsed: 14.1 seconds.
______

Despite the "help" suggestion of typing `E' to edit the source, TeX
appears to have no idea where the error occurred and does not transfer to
the editor. Other "Runaway arguments?", like "! Paragraph ended before
..." transfer to the editor properly.

One difference is that "! Paragraph ended before ..." gives a line number
for the context line but "! File ended while scanning ..." does not.

In the case of "\end" it's probably not too hard to find the problem,
especially since "\end{document" seems to be the only one that doesn't
generate a "! Paragraph ended before ...". There are less trivial cases:
an unclosed caption, such as
_______

\begin{table}
\caption{Testing table.
\protect\label{tab-test}
\end{table}
_______

generates:
______

Runaway argument?
{Testing table. \protect \label {tab-test} \end {table} \par \ETC.
! File ended while scanning use of \@xdblarg.
<inserted text>
\par
<*> &LaTeX TableTest.tex

? e
Type <return> to proceed, S to scroll future error messages,
R to run without stopping, Q to run quietly,
I to insert something,
H for help, X to quit.
______

Based on the context line, TeX has some idea where it ran into trouble,
but it doesn't give sufficient information to transfer to the editor.

This may not be high in the Pantheon of Things-To-Work-On, but it does
strike me (and Andrew) as a {\it bona fide} bug in TeX.

Any comment?

--
Jonathan E. Guyer j-g...@nwu.edu

Peter Schmitt

unread,
Feb 6, 1995, 10:59:08 PM2/6/95
to
In article <j-guyer-0502...@dogbert.ms.nwu.edu>

j-g...@nwu.edu (Jon Guyer) writes:

>While beta-testing OzTeX 1.8, I discovered a (dare I say?) problem. Andrew
>Trevorrow has since determined that this lies with TeX, not just OzTeX,
>since it occurs in unix implimentations as well. He suggested I post here.
>If, in the process of LaTeXing a file, the error "! File ended while
>scanning ..." is generated, such as by a missing "}" following
>"\end{document":

>the following output is generated:

>Runaway argument?
>{document
>! File ended while scanning use of \end.
><inserted text>
> \par
><*> &LaTeX EndedTest.tex

>Despite the "help" suggestion of typing `E' to edit the source, TeX
>appears to have no idea where the error occurred and does not transfer to
>the editor. Other "Runaway arguments?", like "! Paragraph ended before
>..." transfer to the editor properly.

This is certainly not a bug, but just the behaviour to expect:
TeX encounters an error *after* the complete file has been read,
so no line number can be given (the <*> indicates that TeX has started
to read from standard input),
therefore `e' cannot return to a specific point of the file.


>In the case of "\end" it's probably not too hard to find the problem,
>especially since "\end{document" seems to be the only one that doesn't
>generate a "! Paragraph ended before ...". There are less trivial cases:

>Based on the context line, TeX has some idea where it ran into trouble,
>but it doesn't give sufficient information to transfer to the editor.

Runaway errors occur when a macro tries to read an argument but does
not find the closing brace or the delimiting tokens (for a delimited
argument). If it is not an outer macro then it stops when a \par is
reached - usually in the mid of the file, therefore having a line
number. If it is an outer macro (supposed to read several paragraphs)
- or it occurs on the last line of the file -
then it reads to the end of the file and no line number is given,
and the error message tells that the whole file has been read.
However, in both cases, the place where the error is detected need not
say much about where its origin is situated. To give some help,
TeX therefore shows the tokens with which the intended argument starts
` {document ' in this case.


>This may not be high in the Pantheon of Things-To-Work-On, but it does
>strike me (and Andrew) as a {\it bona fide} bug in TeX.
>Any comment?

No bug.

Peter

Jon Guyer

unread,
Feb 10, 1995, 7:26:56 PM2/10/95
to
In article <1733EE0D0...@AWIUNI11.EDVZ.UniVie.AC.AT>,
A813...@AWIUNI11.EDVZ.UniVie.AC.AT (Peter Schmitt) wrote:

>In article <j-guyer-0502...@dogbert.ms.nwu.edu>
>j-g...@nwu.edu (Jon Guyer) writes:
>

>>Any comment?
>
>No bug.

O.K. Don't call it a bug. Call it a pain in the butt. I understand _why_
it happens. I'm just saying that TeX's response to this situation could be
_much_ more civilized.

If it were simply a case of TeX reading all of the way to the end of the
file and determining that it was dazed and confused and wanted no more to
do with the file, I'd be happy to agree with you. But TeX isn't
_completely_ dazed and confused. I agree with you that identifying the end
of the file (where TeX became certain that something was wrong) is of no
value to TeX or the user. As you said, however:

>To give some help,
>TeX therefore shows the tokens with which the intended argument starts
>` {document ' in this case.

If it knows this, why doesn't it send me to that point, then? The fact is,
in every instance where I've encountered this problem, the beginning
tokens are a pretty good place to look. I made a point of saying, in the
case I posted before, that tracking down a faulty '\end' is not a problem,
particularly when '\end{document' appears to be the only offender. The
second example I gave, though, is quite a bit more obscure, generating the
error:
___________

Runaway argument?
{Testing table. \protect \label {tab-test} \end {table} \par \ETC.

! File ended while scanning use of \@xdblarg.
<inserted text>
\par
<*> &LaTeX TableTest.tex
___________

It's not nearly so obvious as looking for an '\end' that has the first
token '{document'. O.K., O.K, my trivial example says 'table' or 'tab' in
several places in the context line; so again, this shouldn't be an
enormous amount of work to track down. Now consider:
___________

\begin{table}
\caption{It is clear, to the most casual observer, that TeX's response
to this error is extraordinarily incovenient, to say the least.
\protect\label{tab-Table}
\end{table}
___________

which generates:
__________

Runaway argument?
{It is clear, to the most casual observer, that TeX's response\ETC.
! File ended while scanning use of \@xdblarg.
<inserted text>
\par
<*> &LaTeX TableTest.tex
__________

Any guesses where this might have been generated in a multi-hundred page
document? How many LaTeXers know or care what a '\@xdblarg' is? Sure, I
could search on the context string, but if I'm supposed to do that, why
have an 'E' response to _any_ error? Moreover, when I say 'H', why does
TeX say:
__________

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

__________

I don't know anything about TeX's error handler, but it would appear that
at some point, someone (Knuth?) thought you should be able to edit your
way out of this problem.

So...it may not be a "bug," but it shouldn't (IMO) and needn't be the way it is.

marxmi...@gmail.com

unread,
Mar 28, 2019, 9:58:19 AM3/28/19
to
Em domingo, 5 de fevereiro de 1995 19:21:31 UTC-2, Jon Guyer escreveu:
I already had this problem too. Probably in some part of your text you forgot some "}"

To solve that... I made a copy of the file and inside the file copy I deleted parts of the text and compiled the file. Whenever I did not see an error message I realized that the problem was not there. I did that in my dissertation until find the place that I was missing o "}".

I started in the beggining erasing the rest and so on.

Good Look :)

Nemo

unread,
Mar 31, 2019, 9:24:33 PM3/31/19
to
On 03/28/19 09:58, marxmi...@gmail.com wrote (in part):
[...]
>>
>> Based on the context line, TeX has some idea where it ran into trouble,
>> but it doesn't give sufficient information to transfer to the editor.
>>
[...]
>> Any comment?
>>
>> --
>> Jonathan E. Guyer j-g...@nwu.edu
>
> I already had this problem too. Probably in some part of your text you forgot some "}"
>
> To solve that... I made a copy of the file and inside the file copy I deleted parts of the text and compiled the file. Whenever I did not see an error message I realized that the problem was not there. I did that in my dissertation until find the place that I was missing o "}".
>
> I started in the beggining erasing the rest and so on.

Another possible tool is chktex (https://www.nongnu.org/chktex/), which
checks for unbalanced braces and much more -- essentially lint for LaTeX.

N.

>
> Good Look :)
>

0 new messages