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.

Why does TeX attempt to insert missing tokens? Why doesn't it simply throw up and die?

More importantly, is there any case where this insertion in fact does go unnoticed?

share|improve this question
This answer seems appropriate, especially the part about 'the olden days of computing'. –  jon May 14 '13 at 2:49
Attempting at error recovery is usual in software. –  egreg May 14 '13 at 7:40
@egreg I can agree to that to a point, but TeX seems to be the type of software where things are expected to be exact and as the user intended -- much like the philosophy of C -- "only requiring that [we] state [our] intentions explicitly." It's obvious that error recovery is being attempted here, however, so there must be some realization (success) of this purpose somewhere. –  Sean Allred May 14 '13 at 21:09

2 Answers 2

up vote 8 down vote accepted

Many syntax errors in a (La)TeX document are simple mistakes due to forgetting a $ or a backslash, say a & or $ instead of \& and \$ in text. Other common errors are due to mistyping a command or forgetting a brace.

TeX is quite good in getting back in sync when such errors happen: a misplaced $ or a missing one can be catched and most of the times this suffices to go on in processing the document. Sometimes, though, a missing brace can be disastrous.

Why did Knuth chose to attempt error recovery? You have to remember when TeX was designed: computers were very different at the time and most TeX runs were done as batch jobs: the job was sent to a queue and run when the mainframe computer allocated some time for it. Stopping the run at the first error would have meant ruin the job, while error recovery may catch several typing errors in a single run. Error recovery can be beneficial also in interactive runs: you see the error and the recovery attempt, but in this case you can also insert tokens or delete those that TeX wants to insert.

When processing MWE for questions on the site this can be very beneficial.

share|improve this answer
You also have to consider the computers TeX was written for: Program runs could take hours and had to arranged well in advance. –  Martin Schröder May 14 '13 at 22:40
@MartinSchröder That's what I meant when referring to "batch jobs". But probably you're right: many people never heard about this. ;-) –  egreg May 14 '13 at 22:42

In some situations TeX assumes, that some text is misspelled. Sometimes the expected way of a correction is removing problematic command, sometimes -- adding additional expressions. E.g. if you type only \sin(x), TeX assumes, that you lost a dollar sign, because \sin must appear inside math.

share|improve this answer
But when would such an insertion be beneficial? –  Sean Allred May 14 '13 at 21:00
@SeanAllred As it is remainded e.g. here tex.stackexchange.com/questions/114292/… in 70' computers were about 10^4 times lower then now. Even partial repairing of badly formatted input was useful, saving time and money. –  Przemysław Scherwentke May 14 '13 at 22:22

Your Answer


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.