Take the 2-minute tour ×
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.

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?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

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}.
    

    Regular email in red

    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}.
    

    Email address typeset using hyperref's url command

    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}.
    

    Email address using hyperref and mailto: protocol

    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.

share|improve this answer
add comment

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}
share|improve this answer
    
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
add comment

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.