I am writing a small package containing macros I intend to use regularly. Among those macros, I have \mailto
with the following definition:
\@ifpackageloaded{hyperref}{%
\def\mailto#1{%
\href{mailto:#1}{\nolinkurl{#1}}%
}%
}{%
\def\maitlo#1{%
\url{#1}%
}%
}
What I want to do is redefine @
and .
to active characters, so that xxx@yyy.zzz
is turned into xxx<at>yyy<dot>zzz
. I've tried the following:
\def\mailto#1{%
\begingroup
\catcode`@=13
\catcode`.=13
\def@{$\langle$at$\rangle$}
\def.{$\langle$dot$\rangle$}
\url{#1}
\endgroup
}
But I get a:
! Undefined control sequence.
\mailto ...e `@=\active \catcode `.=\active \def@
{$\langle $at$\rangle $} \...
l.XXX \mailto{xxx@yyy.zzz}
Why?