Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion plainTeX newb: troubles with \catcode ... why doesn't this work?

Received: by 10.216.241.9 with SMTP id f9mr915145wer.5.1344414952192;
        Wed, 08 Aug 2012 01:35:52 -0700 (PDT)
Path: n2ni23664042win.0!nntp.google.com!volia.net!news2.volia.net!feed-A.news.volia.net!news.musoftware.de!wum.musoftware.de!news.albasani.net!.POSTED!not-for-mail
From: Ulrich  D i e z <eu_angel...@web.de>
Newsgroups: comp.text.tex
Subject: Re: plainTeX newb: troubles with \catcode ... why doesn't this work?
Date: Wed, 8 Aug 2012 09:33:58 +0200
Organization: -
Lines: 88
Message-ID: <jvt8d3$9j9$1@news.albasani.net>
References: <80840890-aac4-4a4d-94dc-cfe9baf7d883@c25g2000yqa.googlegroups.com>
 <50220b31$0$6150$426a34cc@news.free.fr>
Mime-Version: 1.0
X-Trace: news.albasani.net k93r1naMkK5Ho7n6Dhe6f1iwz+6W5TUKSvtNrmV8vvLu+7gD6vsaQyzlyOAjfNCyj9pyeBQzLijffwSaKM2vaQ==
NNTP-Posting-Date: Wed, 8 Aug 2012 08:35:51 +0000 (UTC)
Injection-Info: news.albasani.net; logging-data="5xiDxW5tp/GthhGvXwTaW+I9n8fthOhQ1yx+ralXL2UTYq5ahGcmbZp3Dq8f+/zZ7BYFwB0Li3oNKGfbNu6aZE+fL0jjWzoLFh2TPLo8ui/Pf5vM+hO7Lk6X3UaMXnJV"; mail-complaints-to="ab...@albasani.net"
Cancel-Lock: sha1:DkewYF+sv2/8aC8GvxTrZN5fmMA=
Content-Type: text/plain;
	charset="UTF-8"
Content-Transfer-Encoding: 8bit

zappathustra wrote:

> eds <edstuck...@gmail.com> a écrit:

>> In attempting this macro, I found that I'm also not clear on the
>> differences between `\^^M  and ^^M.  If possible, can someone educate
>> me on the difference?

>^^M is a character like any other; `\^^M is an example of the `\<char>
>construction used to denote a character code.

^^M is a character-token.
\^^M is a control-sequence-token whose name consists of only
one character, the ^^M-character (ASCII13=Return).

[ Whether that one-letter-control-sequence-token is to be
considered a control-word or a control-symbol depends on
the current catcode of the ^^M-character. If it is 11, then
\^^M is a control-word, otherwise it is a control-symbol.

When reading/tokenizing, then usually spaces behind
control-words are ignored, spaces behind control-symbols
are not ignored.
When unexpanded-writing to console or external file, then
usually a trailing space is attached to a control-word but
is not attached to a control-symbol.]

You can use both single character-tokens and
one-letter-control-sequence-tokens for denoting the
alphabetic-constant of a number while with numbers
the alphabetic-constant-notation is always introduced
by a leading ` .
E.g.,
\number65 (decimal digit notation)
\number`A (alphabetic constant by means of character)
\number`\A (alphabetic constant by means of one letter control-sequence)
\the\catcode65
\the\catcode`A
\the\catcode`\A

In expansion-contexts (e.g., \edef) you need to take care of
expandable control-sequences and expandable
active-characters not getting expanded in a way which
later affects the resuling numeral-value.

In your special case I suggest:

\edef\restoreCRCC{\catcode\number`\^^M=\the\catcode`\^^M }

or

\edef\restoreCRCC{\catcode`\noexpand\^^M=\the\catcode`\^^M }

or

\edef\restoreCRCC{\catcode13=\the\catcode13 }

...


By the way:

\edef\restoreCRCC{\catcode`^^M=\the\catcode`\^^M }

does not work because at reading/tokenizing-time
the first ^^M will be recognized as a character (not a token yet)
of catcode 5 (end of line), not as a control-sequence.

A crucial point in this case is that in any case TeX throws away
any other information that remain on the current line when
it encounters such an end of line character. In this case
anything behind the first ^^M will be dropped yielding that
the definition of \restoreCRCC is not complete.

Another crucial point in this case is that characters of
catcode 5 either yield space-tokens or character-tokens
or are simply dropped depending on the status of TeX'
reading-apparatus.

In the following case you get a space-token for the first ^^M
as TeX is in state M (mid-line) at the time of tokenizing that ^^M:

\edef\restoreCRCC{\catcode`^^M
=\the\catcode`\^^M }
\show\restoreCRCC
\bye

Ulrich