[texhax] HTML specials with '_' character

Oleg Katsitadze olegkat at gmail.com
Fri Feb 22 05:56:57 CET 2008

On Sun, Feb 17, 2008 at 08:27:54PM +0100, Michael M. Tung wrote:
> \mailto which now works perfectly!

It was only working by coincidence (see below).

> \def\@mailto#1{

Note that in plain TeX, catcode of @ is 12, which means it is not a
valid character in multi-letter command names.  It can only be used
for a single-letter command (\@), and that's exactly what the above
\def defines.  If you put \show\@ after the definition, you'll see:

  > \@=macro:
  mailto#1-> \special {html:<a href="mailto:#1">}{\tt #1} \special {html:</a>} \c
  atcode `\_=8\relax .
  l.9 \show\@

That is, \@ is a macro taking one argument which should be preceded
("delimited on the left") with letters m-a-i-l-t-o.  And this was
perfectly fine until you redefined it here:

> \def\@href#1#2{

Now, \@ is a macro taking two arguments which should be preceded with
letters h-r-e-f, so when we say \@mailto, TeX complains because it
cannot find href following \@.

So, why use @ in macro names?  That's the common trick to make
"hidden" macros, which can't be called by the end user.  For this to
work, you have to temporarily change catcode of @ to 11 ("letter") so
that you can use it to define your hidden macros (this is the part
Reinhard omitted), and when you are done, change the catcode back to
12, to prevent users from calling hidden macros.  Something like:

  <other definitions of (or calling the) hidden macros>

  <user space>


More information about the texhax mailing list