# How to get email to show in color when typed in text?

In LaTeX's article documentclass, how do I (using hyperref, if I understood right) get email links to show in color (say, red) when I type them in the middle of a paragraph?

-

## 2 Answers

Depending on your preference, you could do any one of the following:

1. If you just want to typeset it in colour, without any linking capabilities, you could use

\usepackage{xcolor}% http://ctan.org/pkg/xcolor
...
My email address is {\color{red} who@cares.com}.


Note the scoping of the \color{...} by putting it within { }, otherwise all the text following the command will be typeset in red. Compiling this may cause some unwanted linking of @cares.com, while leaving who unlinked.

2. The hyperref package does allow linking through a number of commands. You're probably interested in using the \url{...} command, since it takes care of the tricky @ that has to be escaped in order to be typeset. It will also take care of breaking the email address (or url) across lines, if needed.

\usepackage[%
colorlinks=true,%
urlcolor=red%
]{hyperref}% http://ctan.org/pkg/hyperref
...
My email address is \url{who@cares.com}.


This is also not entire accurate if you want to hyperlink to an email (via a mailto protocol).

3. Using hyperref's \href{<url>}{<text>} provides the correct action:

\usepackage[%
colorlinks=true,%
urlcolor=red%
]{hyperref}% http://ctan.org/pkg/hyperref
...
My email address is \href{mailto:who@cares.com}{who@cares.com}.


You can also typeset the email address in a different shape using, say, \texttt{who@cares.com}. Then it will be typeset similarly to that of option 2.

-

You can use the options colorlinks=true and urlcolor=<color>:

\documentclass{article}
\usepackage{xcolor}
\usepackage[colorlinks=true,urlcolor=olive]{hyperref}

\begin{document}

\url{gmedina@tex.stackexchange}

\href{gmedina@tex.stackexchange}{gm-email}

\end{document}

-
Ah, there's my mistake. I just typed the email in text (PDF reader recognized it as a link nevertheless). I didn't put in \url or \href{...} – Rook Aug 28 '11 at 2:28