How to Add a Hyperlink in LaTeX
Load \usepackage{hyperref} and write \href{https://example.com}{link text} for a link with your own text, or \url{https://example.com} to print the address itself. With hyperref loaded, \ref, \cite and the table of contents also become clickable.
hyperref commands
- Text mode, no math preview
\usepackage{hyperref}Load in the preamble, normally as one of the last packages.
\href{https://example.com}{text}Clickable text pointing to a URL.
- Text mode, no math preview
\url{https://example.com}Print the URL in monospace and make it clickable; breaks at / and similar.
- Text mode, no math preview
\href{mailto:name@example.com}{Email me}Link that opens the reader's email program.
- Text mode, no math preview
\autoref{sec:intro}Internal link with the name added: "Section 2".
- Text mode, no math preview
\hyperref[sec:intro]{this part}Internal link with your own text to a
\label. - Text mode, no math preview
\hypersetup{colorlinks=true, urlcolor=blue}Colored link text instead of boxes.
- Text mode, no math preview
\usepackage[hidelinks]{hyperref}Links stay clickable but show no box or color.
Try it live
Change the formula and the preview redraws as you type. Copy the LaTeX, download a PNG or SVG, copy it for Word, or use Edit here on any example below to load it.
Hyperlinks examples
Each result below is drawn from the LaTeX under it. Copy the code, edit it on this page, or open it in the full editor.
Linked formula
LaTeX\href{https://en.wikipedia.org/wiki/Euler_identity}{e^{i\pi} + 1 = 0}MathJax can link any part of a formula with
\href; click the preview to try it.Linked word inside a formula
LaTeXx \in \href{https://en.wikipedia.org/wiki/Real_number}{\mathbb{R}}Linked text label
LaTeX\href{https://www.overleaf.com/learn}{\text{Overleaf guides}}Link on a symbol
LaTeX\href{https://en.wikipedia.org/wiki/Nabla_symbol}{\nabla} fLink in a sum
LaTeX\sum_{n=1}^{\infty} \href{https://en.wikipedia.org/wiki/Basel_problem}{\frac{1}{n^2}} = \frac{\pi^2}{6}
In a LaTeX document
These commands work in the text of a .tex document (Overleaf, TeX Live, MiKTeX), not inside math. The box on the right shows what the compiled PDF looks like.
Link with custom text
LaTeX\documentclass{article} \usepackage{hyperref} \begin{document} Read the \href{https://www.latex-project.org/help/documentation/}{LaTeX documentation}. \end{document}Compiled resultRead the LaTeX documentation.
Printed URL
LaTeXSource: \url{https://ctan.org/pkg/hyperref}Compiled resultSource: https://ctan.org/pkg/hyperref
Link to a section
LaTeX\section{Method}\label{sec:method} ... As shown in \autoref{sec:method}, ...Compiled resultAs shown in Section 2, ...
Colored links instead of boxes
LaTeX\usepackage{hyperref} \hypersetup{ colorlinks=true, linkcolor=blue, urlcolor=blue, citecolor=blue }
\href or \url
Use \href{URL}{text} when the reader should see words, and \url{URL} when the address itself must be printed, as in a reference list. \url sets the address in monospace and allows line breaks after characters like / and .; the xurl package lets long URLs break anywhere.
Always give the full address including https://. Without a scheme, hyperref treats the target as a file on disk and the link opens nothing in most PDF viewers.
Internal links and link style
Once hyperref is loaded, every \ref, \eqref, \cite, footnote mark and table-of-contents entry links to its target. \autoref{label} adds the right name ("Figure 3", "Section 2") to the link, and \hyperref[label]{text} links any text.
By default hyperref draws a colored box around links on screen (boxes are not printed). Use \hypersetup{colorlinks=true} for colored text or the hidelinks option for no marking at all.
Common mistakes
Without the package LaTeX stops with "Undefined control sequence".
Instead of\href{https://example.com}{text} (no hyperref)Write\usepackage{hyperref}A link without
https://is read as a local file path and does not open the website.Instead of\href{www.example.com}{text}Write\href{https://www.example.com}{text}hyperref patches many commands, so it generally goes last in the preamble (a few packages, such as cleveref, must come after it).
Instead of\usepackage{hyperref} \usepackage{other-packages}Write\usepackage{other-packages} \usepackage{hyperref}Inside another command's argument,
%and#in a URL can break; escape them with a backslash there.Instead of\footnote{\url{https://example.com/a%20b}}Write\footnote{\url{https://example.com/a\%20b}}
In Overleaf, MathJax and Word
Overleaf and pdfLaTeX
Needs
\usepackage{hyperref}. Overleaf's PDF preview shows the link boxes; they do not appear when printed.\urlalone also works with the lighter url package, but without clickable links.MathJax and KaTeX
MathJax supports
\href{URL}{math}inside formulas, as in the examples above, but not\urlor the internal-link commands. KaTeX supports\hrefand\urlonly when itstrustoption allows links. In Markdown, write links with[text](URL).Microsoft Word
In Word insert a link with Ctrl+K. Links inside LaTeX formulas are not carried over when an equation is pasted into Word.
Hyperlinks in LaTeX: questions
- How do I add a hyperlink in LaTeX?
- Add
\usepackage{hyperref}to the preamble, then write\href{https://example.com}{link text}where the link should appear. - How do I remove the red boxes around links?
- Load hyperref with
\usepackage[hidelinks]{hyperref}for no marking, or use\hypersetup{colorlinks=true}to color the link text instead. - How do I link to a section or figure?
- Put
\label{sec:x}after the section or caption, then use\autoref{sec:x},\ref{sec:x}or\hyperref[sec:x]{text}— all are clickable with hyperref. - What is the difference between \href and \url?
\hrefshows your own link text;\urlprints the address itself in monospace. Both are clickable.- How do I make an email link?
- Use the mailto scheme:
\href{mailto:name@example.com}{name@example.com}.
Related LaTeX reference
- LaTeX Underline: Text and Math\underline for short text and formulas, ulem's \uline and soul's \ul for text that breaks across lines, plus double and wavy lines.
- Bullet Points in LaTeXitemize for bullet points, enumerate for numbered lists, description for terms, plus nesting, custom bullets and spacing.
- Math Mode in LaTeXInline math with $…$ or \(…\), displayed math with \[…\], numbered equation environments, references and \text inside formulas.
- LaTeX equation editorSymbol panel, live preview, and PNG, SVG, MathML or Word export.
- All LaTeX reference pagesSymbols, math structures and text formatting in one list.
Have the formula as a picture?
Paste a screenshot or photo of the equation and get its LaTeX, ready to copy or open in the editor.
Convert an image to LaTeX