[texhax] HTML specials with '_' character
Michael M. Tung
michael.m.tung at gmail.com
Mon Feb 25 13:00:54 CET 2008
Dear Oleg,
many thanks! Your detailed reply resolved my last problems.
Best, Mike
Oleg Katsitadze [olegkat at gmail.com] wrote:
> 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:
>
> \catcode`@=11
> \def\@mailto#1{...}
> <other definitions of (or calling the) hidden macros>
> \catcode`@=12
>
> <user space>
>
> HTH,
> Oleg
--
-------------------------------------------------------------------------
Dr. Michael M. Tung Email: mtung at mat.upv.es
Departamento de Matemática Aplicada michael.m.tung at gmail.com
Universidad Politécnica de Valencia Phone: +34 96 3877000 x88287
Inst. de Matemática Multidisciplinar +34 96 38-79777
Edificio 8-G, 2º piso IM: ICQ96423950
Camino de Vera, s/n https://talos.tlc.upv.es
46022 Valencia (Spain)
-------------------------------------------------------------------------
PGP Public Key http://personales.upv.es/mictun/mtung_pubkey.pgp
-------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://tug.org/pipermail/texhax/attachments/20080225/439d95d7/attachment.bin
More information about the texhax
mailing list