7

Let us look at dirty trick #3 in appendix D of TeXbook.

The following code produces space of category 12:

\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\def\setupverbatim{\tt
  \obeylines
  \obeyspaces
  \uncatcodespecials
}
\def\listing#1{\par\begingroup\setupverbatim\input#1 \endgroup}
\listing{\jobname.tex}
\bye

This changes category of space to 13:

\def\uncatcodespecials{\def\do##1{\catcode`##1=12 }\dospecials}
\def\setupverbatim{\tt
  \obeylines
  \uncatcodespecials
  \obeyspaces
}
\def\listing#1{\par\begingroup\setupverbatim\input#1 \endgroup}
\listing{\jobname.tex}
\bye

From this we conclude that placing \uncatcodespecials after changing catcode changes it back to category 12, but placing \uncatcodespecials before changing catcode, does not influence it.

On the contrary, \obeylines stays in effect no matter where we put \uncatcodespecials - before or after it. How is \obeylines different from \obeyspaces?

7

In plain.tex:

% Here is a list of the characters that have been specially catcoded:
\def\dospecials{\do\ \do\\\do\{\do\}\do\$\do\&%
  \do\#\do\^\do\^^K\do\_\do\^^A\do\%\do\~}
% (not counting ascii null, tab, linefeed, formfeed, return, delete)
% Each symbol in the list is preceded by \do, which can be defined
% if you want to do something to every item in the list.

On the other hand, \obeylines does

\catcode`\^^M\active \let^^M\par

where the definition is done with ^^M active, for \let^^M\par to work.

The answer to your question is thus that the \dospecials invoked by your \uncatcodespecials does not change \catcode13, hence has no impact on the action of \obeylines even if issued after it. On the other hand it does change \catcode32 hence cancels \obeyspaces (which does \catcode`\ \active) if issued after it.

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.