Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

This question is purely academic. TeXing a file containing

\valign{\halign#\cr!

causes an ! Emergency stop. error. Is that the shortest code which produces a fatal error in TeX?

share|improve this question
2  
You got me; I tried for ten minutes and couldn't find anything, so I'll upvote :) –  Ryan Reich Oct 14 '11 at 1:21
    
most, if not all (haven't tested yet), answers here depend on the extensions of e-tex, which has been compiled into the tex engine of tex live for several years now. this one doesn't -- it produces the same error message when processed with ` Version 3.14159 [PD VMS 3.6]. so here's the challenge: produce shorter code that results in emergency stop` with knuth's original tex engine. no prizes, just glory. (and see my comments on the answers.) –  barbara beeton Jun 15 '12 at 13:50
add comment

4 Answers

up vote 23 down vote accepted
\def\a{a\a}\a

EDIT: Shorter version, as suggested by Bruno:

\def~{~~}~

This gives I can't go on meeting you like this:

\halign{#&&#\cr\multispan{300}}

And this gives This can't happen:

\halign{#&&#\cr\multispan{300}\cr}
share|improve this answer
1  
Good idea. That doesn't cause Emergency stop., but TeX capacity exceeded, sorry [main memory size=...]. And you can shorten that by 3 characters using the fact that ~ is active by default in TeX. I suspect that This can't happen. is harder to achieve :). –  Bruno Le Floch Oct 14 '11 at 22:27
    
I was not very clear in my question, so it was a little bit tricky to decide which answer to accept. I am choosing this answer, because it is the only one that genuinely crashes TeX when run in errorstopmode. Other solutions go to batchmode (or nonstopmode) and can thus crash TeX much more easily (e.g., with an empty file). –  Bruno Le Floch Oct 19 '11 at 21:08
1  
@LevBishop -- congratulations! this is the first "simple" code i've ever seen that reliably produces This can't happen. unfortunately, it depends on extensions added by e-tex. i'm still looking for an example that will reliably produce This can't happen. with knuth's unextended engine. although such an example will probably not result in changes to the tex engine, it would definitely result in wider recognition and "glory" of a sort. –  barbara beeton Jun 15 '12 at 13:24
    
@LevBishop -- the code with \a, on an unextended tex, results in TeX capacity exceeded, sorry [main memory size=327145], and the code with the tildes results in TeX capacity exceeded, sorry [input stack size=200]. (this has already been pointed out by Bruno Le Floch.) both tested on Version 3.14159 [PD VMS 3.6]. nice try, but i claim this isn't a valid winner. –  barbara beeton Jun 15 '12 at 13:54
    
@barbarabeeton are you sure that my This can't happen example requires e-tex? I see that the same code path is present in my "Computers & Typesetting/B: TeX:The Program" book (which describes version 3.14159), in section 798 (with the comment {this can happen, but won't}). I don't have Version 3.14159 [PD VMS 3.6] but with Version 3.1415926 (MiKTeX 2.9 64-bit) which doesn't seem to understand e-tex primitives such as \eTeXversion it still gives This can't happen. I do agree that no changes to the TeX engine are required here, though :) –  Lev Bishop Jun 15 '12 at 15:33
show 2 more comments

A file just consisting of ^H (IIRC the only character with catcode invalid by default in LaTeX) will do it:

[1 1016] ~/temp % echo -e '\b' | latex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)
**entering extended mode
! Text line contains an invalid character.
<*> ^^H

? 
! Emergency stop.
<*> ^^H

No pages of output.
Transcript written on texput.log.
[1 1017] ~/temp %
share|improve this answer
3  
The hole-in-one of code golf. :-D –  DevSolar Oct 14 '11 at 7:17
    
But why is ^H the only such character? –  You Oct 14 '11 at 7:29
2  
@You: I'm not actually sure it is; but ^H is the backspace character and if you find explicit backspace characters in your text file, something's wrong with your terminal and/od editor :) –  Ulrich Schwarz Oct 14 '11 at 9:02
4  
Many characters are invalid in LaTeX (try \newcount\foo\loop\message{\the\catcode\foo}\advance\foo1\iftrue\repeat). I think the key reason why this crashes TeX is that somehow it is called in batch mode (e.g., putting an invalid character in a file and running TeX on it will simply prompt you for more material). Thus, echo "" | latex also crashes, with a different error message. –  Bruno Le Floch Oct 14 '11 at 22:25
2  
but this requires a response to the ? prompt. the original challenge was to create a tex file that stops all by itself, no intervention. –  barbara beeton Jun 15 '12 at 14:08
show 1 more comment

Another short way of making TeX blow up is to have a file named +.tex consisting of

\input+

Then +.tex inputs itself, and TeX sadly stops with the error

! TeX capacity exceeded, sorry [text input levels=15].
share|improve this answer
add comment
{

Here's the log:

This is TeX, Version 3.1415926 (TeX Live 2011) (format=tex 2011.8.28)  14 OCT 2011 11:17
**short
(./short.tex)
! Emergency stop.
<*> short

*** (job aborted, no legal \end found)

No pages of output.

If running with -interaction=batchmode is allowed then I win: just try

touch inexistent.tex
tex -interaction=batchmode inexistent

and you'll get

This is TeX, Version 3.1415926 (TeX Live 2011) (format=tex 2011.8.28)  14 OCT 2011 11:25
**inexistent.tex
(./inexistent.tex)
! Emergency stop.
<*> inexistent.tex

*** (job aborted, no legal \end found)

No pages of output.

The output of the shell to check:

> ls -l inexistent.tex 
-rw-r--r--  1 enricomb  staff  0 Oct 14 11:25 inexistent.tex
share|improve this answer
1  
I think your first example is also run in batchmode, because simply doing tex short.tex leaves me with TeX prompting me for more data. I think that -interaction=batchmode should be counted towards the number of characters :). –  Bruno Le Floch Oct 14 '11 at 22:19
2  
@BrunoLeFloch The { example works also in nonstopmode. But you're right: skimming through "TeX, the program" tells that the only fatal errors in errorstopmode are of the "interwoven alignment" kind. –  egreg Oct 14 '11 at 22:35
    
@egreg -- run with unextended tex, this hangs with a * prompt waiting for a response. i'm not sure how to specify \nonstopmode on a vms installation except by putting the command in the tex file, but when that's done, it does result in emergency stop. –  barbara beeton Jun 15 '12 at 14:05
    
@barbarabeeton Do you still use a TeX on a VMS system? Sorry, but I can't test it, as my last experience on VMS was in 1993. :) Maybe TEX /N or something? –  egreg Jun 15 '12 at 14:08
    
@egreg -- there are still a few "legacy" projects run on a vms system (e.g. annual reminders to members to update their membership information, uses tex because names and addresses contain accented letters, and the front end to the membership database is still on vms but probably not for more than another year), but book and journal production have been on unix/linux since about 2000. (production systems change slowly.) it's the only non-extended tex i have easily accessible, so took advantage of it for testing/wasting time. i think e-tex was made the default in tex live in the mid-2000s –  barbara beeton Jun 15 '12 at 15:03
show 2 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.