logo

How to Use Hyperlinks in LaTeX 📂Writing

How to Use Hyperlinks in LaTeX

Code

You can load the hyperref package and use the \href{URL}{text} command. It can be used to wrap text or equations and can be applied even in display mode.

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
    colorlinks=true,
    urlcolor=blue,
}
\begin{document}

unlinked Freshrimpsushi Blog 

linked \href{https://freshrimpsushi.github.io/ko/}{Freshrimpsushi Blog}

The Fourier transform \href{https://freshrimpsushi.github.io/ko/posts/1086/}{$\hat{f}$} is defined as

$$
\href{https://freshrimpsushi.github.io/ko/posts/1086/}{\hat{f}(\xi) = \frac{1}{2\pi}\int_{-\infty}^{\infty} f(x) e^{-i \xi x} dx}
$$

\end{document}

Through \hypersetup, you can also specify the colors for URLs, files, etc. The commands that can be used are as follows.

Link Style Options

OptionDefaultDescription
hyperindextrueMakes the page numbers of index entries hyperlinked.
linktocpagefalseLinks the page numbers rather than the text in the table of contents.
breaklinksfalseAllows links to be broken across lines.
colorlinksfalseSpecifies colors for links and anchors, which will reflect in the printed output.
linkcolorredColor of the normal internal links.
anchorcolorblackColor of the anchor (target) text.
citecolorgreenColor of the bibliography citations.
filecolorcyanColor of the links to local files.
urlcolormagentaColor of the linked URLs.
frenchlinksfalseUses small caps instead of colors for links.

PDF Options

OptionDefaultDescription
bookmarkstrueAcrobat bookmarks are created, which appear in a similar form to the table of contents.
bookmarksopenfalseBookmarks are displayed with all subtrees expanded.
citebordercolor0 1 0Sets the color of the box around citations in RGB format.
filebordercolor0 .5 .5Sets the color of the box around file links in RGB format.
linkbordercolor1 0 0Sets the color of the box around typical links in RGB format.
menubordercolor1 0 0Sets the color of the box around menu links in RGB format.
urlbordercolor0 1 1Sets the color of the box around URL links in RGB format.
pdfpagemodeemptyDetermines how the file opens: possible values are UseThumbs (thumbnails), UseOutlines (bookmarks), FullScreen (fullscreen).
pdftitleSets the document title.
pdfauthorSets the document author.
pdfstartpage1Sets the starting page when opening the PDF file.