How to make clickable links in LaTeX

Setting hyperlinks in LaTeX is easy with the hyperref package. Link to any website or add your email address to any document.


[Open document online]

Adding clickable links to LaTeX documents is very straightforward, you only have to add the hyperref package to your preamble. This package allows you to set links with a description as well as add bare urls to your document.

\documentclass{article} % or any other documentclass

%...

\usepackage{hyperref}

%...

\begin{document}

%...

\end{document}

After setting this up, you're ready to go and add links anywhere to your document. In order to add a link with a description (i.e. making a word clickable), you should use the href command like so:

%...

\begin{document}

This is my link: \href{http://www.latex-tutorial.com}{LaTeX-Tutorial}.

\end{document}

This will lead to the following output in your PDF:

pic1.png

You will notice, that there's a colored box shown around the word. Don't worry, this box is not going to show up in your printed document, but only if you view it on your computer.

If you simply want to embed a bare URL, you should use the url command instead, which usage is even simpler:

%...

\begin{document}

You can also link to bare URLs without an additional description: \url{http://www.latex-tutorial.com}

\end{document}

This will show the following clickable link in your PDF:

pic2.png

If you want to add your email address to your document, so that it automatically opens your readers email program whenever they click on it, you can also use the url package like so:

%...

\begin{document}

My email address is: \href{mailto:claudio.vellage@latex-tutorial.com}{claudio.vellage@latex-tutorial.com}

\end{document}

Usually, using the default settings and color etc are just fine, but these can also be customized if you want to. This can be done using the hypersetup command in your preamble. Since I've never used this feature in any document, I won't explain how to use it, but you can find a more detailed documentation of the hyperref package here, if you're curious.

Summary

  • Add the hyperref package to your preamble
  • Links will show up in a colored box which will be invisible when you print it.
  • Use \href{URL}{DESCRIPTION} to add a link with description
  • Use \url{URL} to add a link without a description
  • Prepend your email address with mailto: to make it clickable and open your mail program.
  • In case you want to customize the appearance, read the documentation on ctan

Next lesson: Lesson 17