Resurchify LaTeX Guide
Resurchify

Hyperlinks in LaTeX


This tutorial teaches how to add/set/create hyperlinks into your LaTeX document. With the help of hyperlinks, you can make your items/text/images clickable in $\LaTeX$.

Table of Contents

  1. Introduction
  2. How to add/set hyperlinks in LaTeX
  3. Embed/Include a bare URL
  4. Adding email address
  5. How to change LaTeX hyperlink color
  6. Summary

Introduction


With the help of hyperlinks, you can make your items/text/images clickable in LaTeX. It is very easy and straight forward to use and setup hyperlinks in LaTeX document.

It is generally useful when the output format of your LaTeX code is PDF so that one can click on an item and simply follow it. This feature is achieved using a package named hyperref. It is very easy and straight forward to use and set up hyperlinks in LaTeX document.



Steps to make clickable links are as follows:

  1. Include hyperref package into your document preamble using the command \usepackage{hyperref}. hyperref package will enable you to add links with the description of your choice as well as to set URLs into your LaTeX document.

    1
    2
    3
    4
    5
    6
    \documentclass{article}  
    \usepackage{hyperref}
    
    \begin{document}
    Testing Hyperlinks in this document.
    \end{document}
    

  2. After adding the package hyperref, you can add or set the hyperlinks anywhere in your document by using the command \href. Look at the below example to understand the usage:

    1
    2
    3
    4
    5
    6
    7
    \documentclass{article}  
    \usepackage{hyperref}
    
    \begin{document}
    Testing Hyperlinks in this document. 
    This is my first hyper link:  \href{http://www.resurchify.com}{Click Here}
    \end{document}
    

    The above example will produce the following output:

Note: You might see a colored box surrounding your hyperlinked text. This color box is visible only on your computer (Just to highlight that it is a hyperlink). However, it will not appear in your printed copy of the document. So, just ignore it.

Embed/Include a bare URL


In order to include the bare/plain URL into your LaTeX document you need to use the \url command. Check the below example:

1
2
3
4
5
\begin{document}

Adding bare/plain URLs without any additional description: \url{http://www.resurchify.com}

\end{document}

The above example will produce the following output:


Adding email address


In order to add an email address in your LaTeX document, you need to use \href command along with the mailto attribute. Look at the below example to understand:

1
2
3
4
5
\begin{document}

This is my email address: \href{mailto:abc@xyz.com}{abc@xyz.com}

\end{document}

Whenever the user clicks on the email id (Here, abc@xyz.com), it will be automatically opened in the default email software or program.

Changing LaTeX Hyperlink Color

Generally, default color and other settings are OK. However, if you wish to change these default settings like hyperlink color, you have to use \hypersetup command in your document preamble.

Summary

  1. Include the hyperref package in the document preamble.
  2. Make use of \href{Url} command for adding a hyperlink without its description.
  3. Make use of \href{Url}{Description} command for adding hyperlink or Url along with its description.
  4. Append your email id with mailto:, if you want default email software should open up when the user clicks on it.
  5. For changing the color of hyperlink or any default setting, you can use \hypersetup package.

Powered by www.resurchify.com