Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When trying to write an e-mail address, there are always problems with the @ sign.

Solutions I've seen suggested are using some verbatim environment (more difficult in footnotes) and using a math-mode @.

What is the correct way to do this?

share|improve this question
Additionally you can redefine the arrobase (@) to be a different font and/or size. Thats why I do for my resume to make it really pop! – ajray Jul 27 '10 at 21:20

7 Answers

up vote 34 down vote accepted

Another thing one can to with the hyperref package is to use the href command

\href{mailto:me@example.com}{me@example.com}

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.

share|improve this answer
12  
I often define an \email command that expands to your \href, automatically prepending the mailto: part. – Damien Pollet Jul 27 '10 at 7:53
4  
Good idea. One small caveat is that <code>\email</code> is already defined in certain document classes (for example <code>amsart</code>). – Willie Wong Jul 27 '10 at 13:45

You can also combine the hyperref and url approaches to get a working link that is formatted like an URL:

\href{mailto:me@example.com}{\nolinkurl{me@example.com}}
share|improve this answer

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{foobar@gmail.com}
\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.

share|improve this answer

You can define \at command in the preamble:

\newcommand{\at}{\makeatletter @\makeatother}

and then use it as follows within the document:

myemail\at gmail.com
share|improve this answer

There are a number of things that you can try:

(with the hyperref package):

\url{email address}

or more simply (for monospace font):

\texttt{email address}

share|improve this answer
2  
You don't want to use \url because it will attempt to create a hyperlink to an actual URL with the email address you supply. See Caramdir's answer for a better solution. – Will Robertson Aug 18 '10 at 10:10

I don't think that there is a unique correct way to handle this. As another answer says, you can use hyperref. But, the url package can also be used to render email addresses:

\documentclass{article}

\usepackage{url}

\begin{document}

\url{me@example.com}

\end{document}
share|improve this answer
You don't want to use \url because it will attempt to create a hyperlink to an actual URL with the email address you supply. See Caramdir's answer for a better solution. – Will Robertson Aug 18 '10 at 10:11
@WillRobertson: You sure about that? Note that this was \url from the url package, not from hyperref. – vanden Aug 18 '10 at 15:10
2  
Oops; I meant only if you load hyperref as well -- it will transparently replace \url with the hyperlinked one. The point is that \url is not semantically designed for email addresses. – Will Robertson Aug 19 '10 at 3:32

For the @ character I prefer the \MVAt command from the marvosym package, since the cmss @ looks so different from other fonts I'm used to. For the full address I use the hyperref formatting suggested by Willie.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.