Skip to content

Email Links in LaTeX-Generated PDFs

File this under “Easy To Do in LaTeX If You Know What You Are Doing”. Nothing to brag about, but it took some time to hit upon a solution, so I thought I would share. The url package helps to correctly typeset urls and email addresses—increasingly common in letters, CVs, and bibliographies. When used in conjunction with the hyperref package, the \url command will produce a clickable link that will launch the url in your default browser. Cool. But what about emails. You might try:

\url{john.doe@gmail.com}

But this will just launch john.doe@gmail.com in your browser. The trick is to use the \href command. The command

\href{URL}{text}

will make text into a clickable link that will launch URL in your default browser. So what we need is:

\href{mailto:john.doe@gmail.com}{john.doe@gmail.com}

Easy to do if you know what you are doing.

{ 2 } Comments

  1. quinntaylor | March 12, 2008 at 7:02 pm | Permalink

    Thanks for the tip, I was looking all over for a good way to accomplish this!

    One way I found to make this even better (especially if using this more than once) is to use a LaTeX command to create the link for you:

      \newcommand{\mailto}[1]{\href{mailto:#1}{#1}}
    

    This means you only have to type mailto{john.doe@gmail.com}. Not only does this reduce extraneous typing, but it helps avoid bad links caused by miss-typing or changing the address in one of the sets of braces.

  2. Mark Eli Kalderon | March 12, 2008 at 9:49 pm | Permalink

    Thanks, Quinn. You are absolutely right. One should automate wherever possible.

Post a Comment

You must be logged in to post a comment.
FireStats icon Powered by FireStats