What's the best way to write e-mail addresses?
Another thing one can to with the hyperref package is to use the href
command
\href{mailto:[email protected]}{[email protected]}
which has the advantage that when clicked-on in an electronic document, it will (ideally) call up the mailer and cue up the e-mail address.
You can also combine the hyperref
and url
approaches to get a working link that is formatted like an URL:
\href{mailto:[email protected]}{\nolinkurl{[email protected]}}
Just to add to Willie's good answer, in terms of the formatting (as the OP seems to be getting at) there isn't a "correct" way. Use \textsf
or \texttt
or whatever looks good for your particular document and use case and font choice. Also try the randtext
package to attempt to obfuscate the email address inside the PDF to make it less susceptible to spammers (but note that — I think — it doesn't play nice with hyperref's \href
).
If you want to "special-case" the @ sign without adding markup to your text, you could write something like this:
\documentclass{article}
\usepackage{color,hyperref}
\catcode`\_=11\relax
\newcommand\email[1]{\_email #1\q_nil}
\def\_email#1@#2\q_nil{%
\href{mailto:#1@#2}{{\emailfont #1\emailampersat #2}}
}
\newcommand\emailfont{\sffamily}
\newcommand\emailampersat{{\color{red}\small@}}
\catcode`\_=8\relax
\begin{document}
\email{[email protected]}
\end{document}
where you get the proper hyperlinking of the email address and you can customise the look of the email by changing \emailfont
and the look of the ampersat (or arrobase, or @) by changing \emailampersat
.