0

I'm now reading the source code of LaTeX.

In the definition of verbatim environment (\@verbatim, exactly), there is something like

\everypar \expandafter{\the\everypar \unpenalty}

What does this \expandafter do?

I only know that \expandafter can delay expansion like

\expandafter\def\csname test-cmd\endcsname

But what will happen if the token after \expandafter is a }?

stone-zeng
  • 2,710
  • Have a look at https://tex.stackexchange.com/q/451/100689 – Michael Fraiman Aug 23 '17 at 06:44
  • 1
    \everypar is a token list register, so you need to delay the expansion of the brace in order to append material to it. You find detailed explanations here (about \everypar) and here (about \expandafter{). – campa Aug 23 '17 at 06:57
  • Dupe of one or both of those? – Joseph Wright Aug 23 '17 at 07:15
  • @campa Still not fully understand. Why this assignment must be ended with an explicit }? – stone-zeng Aug 23 '17 at 09:31
  • A token list \foo is usually assigned by \foo{some token list}. The opening brace so to say "starts" the assignment mechanism. Here we want to append something to the token list, so we need to freeze the assignment mechanism until the token list is expanded. The closing brace is of course necessary in order to mark the end of the assignment. – campa Aug 23 '17 at 09:55
  • I noticed that even \everypar=\bgroup Hello\egroup will raise an error. Is it a mechanism on TeX level? – stone-zeng Aug 23 '17 at 10:06
  • @Stone-Zeng (I've seen your comment by chance: you have to ping with @name) The closing brace must be explicit. – campa Aug 23 '17 at 13:46

0 Answers0