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.

I have been relying for years on TeX's behavior where, say \if1\fi expands to nothing and \if1\else\fi does the same. In the second case TeX inserts an 'implicit' \relax when it tries to expand \else. I have a 'language-lawyer' type question about it: can this behavior, more or less formally be 'extracted' from the TeXbook? Any reference would be appreciated. Note that I am not interested in the mechanism itself (I found everything I need in 'TeX: the program' a long time ago), just a (more or less) formal reference to it in the TeXbook.

share|improve this question
2  
No, there's no reference to it in the TeXbook. Only in “TeX the program“: look for modules 379, 378, 366 and, especially, 510. You can find the document by doing texdoc tex on a TeX Live distribution. As far as I know, the frozen \relax is inserted also in \if1\fi. –  egreg Apr 2 at 21:46
    
I was afraid of that. As I mentioned above, I am not interested in references other than the TeXbook (I think 'TeX by topic' mentions it, although I am no sure). True about \if1\fi, it is just easier to see why TeX has to do it in the second case. –  alexsh Apr 2 at 22:00
    
It's mentioned in section 12.5.3 of TeX by Topic. I rechecked the TeXbook and I can confirm it's not mentioned. –  egreg Apr 2 at 22:06

1 Answer 1

up vote 19 down vote accepted

The insertion of the “frozen \relax” is not documented in the TeXbook, where \relax appears 57 times, mostly in listings. No mention of this insertion is made in the discussion of conditionals.

The insertion is documented in section 12.5.3 of TeX by Topic:

enter image description here

Of course it's in “TeX the program”: module 510 describes the insertion in incomplete conditionals.

share|improve this answer
2  
This is probably the best answer. I have done the search, as well, and, as I mentioned, I have already found the appropriate portion of 'TeX: the program'. I guess I was looking for an indirect way to 'derive' this from the TeXbook. As an example, The TeXbook does not explicitly define what a 'blank token' is but it does introduce the terminology to describe parameter scanning quite precisely. In contrast, I could not find any hint of 'implicit' (or frozen as you call it) \relax in it. I will wait a bit longer before I mark this as the answer. –  alexsh Apr 3 at 1:27
    
I am marking this as an answer. I found no mentioning of this behavior in the 'Recovery from errors' chapter either. Well, hopefully this is the only flaw in `The TeXbook' :) –  alexsh Apr 7 at 18:52

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.