5

Does the control symbol obtained by following the escape character by return (\<return>, catcode 0 then catcode 5) behave like the control space character (\<space>, catcode 0 then catcode 10)? It seems to:

\TeX\ blah

typesets the same way

 \TeX\
 blah

does. But I can't justify this behavior by tracing through the lexing process as described in the texbook. What exactly is tex doing here?

  • 4
    Recall that trailing spaces and tabs are removed from the line and that the \endlinechar is added, so what TeX sees is <backslash><endlinechar>. – egreg Dec 1 '17 at 17:52
9

There's this in plain.tex

\def\^^M{\ } % control <return> = control <space>
\def\^^I{\ } % same for <tab>
  • To convince oneself that this is what is happening, one can add \def\^^M{something else} and see the results. – ShreevatsaR Dec 1 '17 at 18:54
  • So it seems that the lexing map from nonletters (characters not of catcode 11) to control symbols isn't one-to-one. Are there any other instances of different strings \<nonletter> being lexed to the same control symbol other than <nonletter> = <return>, <space>, <tab>? – fmg Dec 1 '17 at 19:29
  • 2
    @fmg I don't understand your comment. There are other different nonletters \!, \,, etc. you mean if there's another case in which two non-letters end up expanding to the same thing? I don't think there's any other case, but you could do \def\.{\,} and \. would end up expanding to the same as \,. I'm not sure I understand what you are asking. – Manuel Dec 1 '17 at 19:40
  • 1
    @fmg Precisely, this is not “naturally occuring”, Knuth defined \<return> and \<tab> to expand to \<space>. It's as if he defined \def\a{\ } \def\b{\ } \def\c{\ } all three macros \a, \b, \c, would expand to \ but by no means it's “natural”. – Manuel Dec 1 '17 at 20:00
  • 1
    I wonder if there's a reason why this isn't \let\^^M=\ % ... plain.tex is usually so careful about conserving memory. – zwol Dec 1 '17 at 23:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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