[texhax] Some puzzling TeX (\@sptoken)
Heiko Oberdiek
heiko.oberdiek at googlemail.com
Tue May 31 21:14:19 CEST 2011
On Tue, May 31, 2011 at 08:50:28PM +0200, Uwe Lueck wrote:
> Continuing puzzles about latex.ltx's \@sptoken,
>
> http://tug.org/mailman/htdig/texhax/2011-February/016809.html
>
> -- guess what happens with
>
> \makeatletter \let\atest\@sptoken \show\atest \stop
>
> and why ...
The syntax of \let contains optional spaces, therefore \@sptoken
that is an (implicite) space is ignored and you get:
\let\atest\show
\atest\stop
Probably you want:
\let\atest= \@sptoken
\show\atest
\stop
> Von: "Stephen Hicks" <sdh33 at cornell.edu>
> Gesendet: 17.02.2011 01:50:44
> An: "Rod Harries" <rod at harries.net.nz>
> Betreff: Re: [texhax] Some puzzling TeX
>
> >*\let\@sptoken= %
> >
> >*\relax
> >
> >*\show\@sptoken
> >> \@sptoken=\relax.
> ><*> \show\@sptoken
One optional space after the equals sign.
> >*\def\:{\let\@sptoken= } \: %
> >
> >*\show\@sptoken
> >> \@sptoken=blank space .
> ><*> \show\@sptoken
Spaces are not ignored after one letter commands,
if the letter isn't a letter. ;-)
> >What's happening here? It turns out that spaces are particularly
> >tricky in TeX. I don't have my TeXBook on me right now, but the way
> >the \let primitive is defined, it allows an optional "=" in between
> >the token it's assigning to and the token it's assigning from. This
> >optional "=" may be surrounded by any number of spaces. So when you
> >simply say "\let\@sptoken= %" it's still waiting for the token to
> >assign to \@sptoken, and the next non-space it encounters will be it
> >(hence the \relax on the next line).
TeX only eats one optional space after "=" in a \let assigment.
Yours sincerely
Heiko Oberdiek
More information about the texhax
mailing list