Everything you need to add clickable links to LaTeX documents — external URLs, internal cross-references, colored links, PDF bookmarks, and TOC navigation — all powered by the hyperref package.
\usepackage{hyperref}
Setting up hyperref
Add \usepackage{hyperref} to your preamble — ideally as the last package. Passing options inline configures link colours, PDF metadata, and bookmark behaviour all at once.
\documentclass{article}\usepackage[ colorlinks = true, linkcolor = blue, urlcolor = cyan, citecolor = green, pdftitle = {My Document}, pdfauthor = {Author Name}, pdfsubject = {LaTeX tutorial}, bookmarks = true, bookmarksnumbered = true,]{hyperref}\begin{document}\tableofcontents\section{Introduction}\label{sec:intro}This section is clickable in both the PDF bookmark paneland the table of contents.\section{Links}\label{sec:links}See \href{https://formatex.io}{FormaTeX} for live compilation.Internal link back to Section~\ref{sec:intro}.\end{document}
\section{Link commands}
\href, \url, and \hyperref
hyperref provides four main commands for creating links. Each has a distinct purpose — choose the right one for cleaner, more semantic source code.
\href
\href{url}{text}
External or internal URL with custom visible anchor text. The text is what readers see; the URL is the destination.
\url
\url{url}
Renders a URL as-is in monospaced font and makes it clickable. Best for raw addresses in footnotes or references.
\hyperref
\hyperref[label]{text}
Internal cross-reference using a \label. Jumps to the labelled element with custom link text — no URL required.
\autoref
\autoref{label}
Like \ref but automatically prepends the type name (Section, Figure, Table …) based on the environment.
\section{Usage examples}
All four commands in action
The example below shows \href, \url, \hyperref, and a mailto link side by side with minimal preamble.
\documentclass{article}\usepackage{hyperref}\begin{document}% \href{url}{text} — URL with custom anchor textVisit \href{https://formatex.io}{FormaTeX} for online compilation.% \url{url} — raw URL, displayed and linked as-isPackage docs: \url{https://ctan.org/pkg/hyperref}.% \hyperref[label]{text} — internal cross-reference with custom text\hyperref[sec:results]{Jump to the Results section}.% Email address linkQuestions? \href{mailto:[email protected]}{Send us an email}.% Footnote URL (keeps text clean)Documented elsewhere.\footnote{\url{https://example.com/docs}}\section{Results}\label{sec:results}Data analysis and findings.\end{document}
Run this example
\section{Colored links}
Configuring link colors
With colorlinks=true each link type gets its own color key. You can pass any named color from the xcolor package, including custom RGB definitions.
linkcolorblue
Internal links — \ref, \autoref, TOC entries
urlcolorcyan
External URLs — \href and \url
citecolorgreen
Citation links — \cite
filecolormagenta
File links — \href{run:file.pdf}{...}
menucolorred
Acrobat menu links (rare)
anchorcolorblack
Anchor text (rarely customised)
Print-ready output
For documents intended for print, pass hidelinks to suppress all colours and borders while keeping links functional in digital PDFs.
\section{PDF bookmarks}
PDF bookmarks and TOC links
hyperref automatically converts every \section, \subsection, and \caption into a clickable PDF bookmark. The table of contents entries become internal hyperlinks at no extra cost.
bookmarks=true
Generates the PDF bookmark panel (outline). Enabled by default in most hyperref configurations.
bookmarksnumbered=true
Prefixes each bookmark with its section number — keeps the panel consistent with the printed TOC.
pdftitle & pdfauthor
Populate the document metadata shown in PDF viewers and used by search engines for PDF indexing.
\section{Common pitfalls}
Avoid these mistakes
Load hyperref last
hyperref redefines many internal LaTeX commands. Load it after all other packages to avoid conflicts — only cleveref and a few others should follow it.
Special characters in URLs
Characters like %, #, and & are special in LaTeX. Inside \url{} they are handled automatically; inside \href{} you must percent-encode them in the URL argument.
Colored boxes vs colored text
The default hyperref style draws a colored box around links (colorlinks=false). Set colorlinks=true to color only the text — this looks better in print and digital documents.
hyperref and footnotes
Using \footnote{\href{...}{...}} is fine. Avoid \href inside \section{} titles unless you also pass hidelinks to suppress the colored bookmark entry.
\section{FAQ}
Frequently asked questions
Does hyperref work with pdfLaTeX, XeLaTeX, and LuaLaTeX?
How do I remove link colors for print?
Can I use hyperref with BibLaTeX?
Why does my \ref show as ?? in the PDF?
How do I link to an email address?
\section{Related guides}
Keep learning LaTeX
Explore more guides and try every example live in the FormaTeX playground.
We track anonymous usage — page views, feature usage, compilation events — to understand what works and what doesn't. No ads, no personal data, no third-party sharing.