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
Option | Default | Description |
---|---|---|
hyperindex | true | Makes the page numbers of index entries hyperlinked. |
linktocpage | false | Links the page numbers rather than the text in the table of contents. |
breaklinks | false | Allows links to be broken across lines. |
colorlinks | false | Specifies colors for links and anchors, which will reflect in the printed output. |
linkcolor | red | Color of the normal internal links. |
anchorcolor | black | Color of the anchor (target) text. |
citecolor | green | Color of the bibliography citations. |
filecolor | cyan | Color of the links to local files. |
urlcolor | magenta | Color of the linked URLs. |
frenchlinks | false | Uses small caps instead of colors for links. |
PDF Options
Option | Default | Description |
---|---|---|
bookmarks | true | Acrobat bookmarks are created, which appear in a similar form to the table of contents. |
bookmarksopen | false | Bookmarks are displayed with all subtrees expanded. |
citebordercolor | 0 1 0 | Sets the color of the box around citations in RGB format. |
filebordercolor | 0 .5 .5 | Sets the color of the box around file links in RGB format. |
linkbordercolor | 1 0 0 | Sets the color of the box around typical links in RGB format. |
menubordercolor | 1 0 0 | Sets the color of the box around menu links in RGB format. |
urlbordercolor | 0 1 1 | Sets the color of the box around URL links in RGB format. |
pdfpagemode | empty | Determines how the file opens: possible values are UseThumbs (thumbnails), UseOutlines (bookmarks), FullScreen (fullscreen). |
pdftitle | Sets the document title. | |
pdfauthor | Sets the document author. | |
pdfstartpage | 1 | Sets the starting page when opening the PDF file. |