[texhax] HTML specials with '_' character

Eduardo M KALINOWSKI ekalin at gmail.com
Sun Feb 17 14:26:22 CET 2008

Michael M. Tung wrote:
> Hi!
> I have problems with my following macro in plain TeX
> \def\mailto#1{
>   \special{html:<a href="mailto:#1">}%
>           {\tt #1}
>   \special{html:</a>}
> 	 }
> which creates a hyperlink for mailing in the final PDF
> file. For standard emails with letters and '@' it works
> fine. However such things as
>   \mailto{test_user at yahoo.com}
> creates an error requiring math mode for '_'.  Defining
>   \catcode`\_=11
> outside the macro fixes this (but affects the entire file).
> But I would like to use this within the macro having limited
> scope. However, putting \catcode... into the macro doesn't
> seem to have any effect.
> How can I use \catcode inside the macro definition?

If my understanding of TeX internals is right, then if the macro has one 
argument, by the time it is executed the argument has already been read, 
and thus changing catcodes will not help. So it is necessary to change 
catcode and then read the argument. This requires a macro with no 
arguments that changes the catcode and calls another one that will 
actually fetch the argument and do something useful with it.

Unfortunately I cannot provide actual code, we will have to wait for a 
TeX wizard for further help.

Tudo vale a pena quando a alma não é pequena.
                -- Fernando Pessoa

ekalin at gmail.com

More information about the texhax mailing list