hyperref
Enables interactive cross-references, clickable links, and PDF bookmarks in LaTeX documents, enhancing digital document navigation and accessibility.
Overview
A fundamental package for creating modern, interactive PDF documents from LaTeX source. It automatically converts cross-references, citations, and table of contents entries into clickable links, while also providing tools for creating external hyperlinks and customizing PDF metadata.
- Transforms internal references (\ref, \cite, etc.) into interactive links
- Generates PDF bookmarks for document structure navigation
- Enables customization of link appearance, including colors and border styles
- Supports URL linking and custom PDF metadata (title, author, keywords)
- Essential for electronic publishing, academic papers, and digital documentation
- Integrates seamlessly with most other LaTeX packages and document classes
Getting Started
To use hyperref
, include it in your document preamble:
\documentclass{article}
\usepackage{hyperref}
Typically, hyperref should be loaded last among your packages to avoid conflicts:
\documentclass{article}
% Other packages
\usepackage{graphicx}
\usepackage{amsmath}
% Load hyperref last
\usepackage{hyperref}
You can customize the appearance and behavior of hyperlinks with options:
\documentclass{article}
\usepackage[colorlinks=true, linkcolor=blue, citecolor=green]{hyperref}
Examples
Basic document with hyperlinked cross-references and a clickable table of contents.
\documentclass{article}
\usepackage{hyperref}
\title{Hyperref Example Document}
\author{Author Name}
\date{\today}
\begin{document}
\maketitle
\tableofcontents
\section{Introduction}\label{sec:intro}
This is the introduction section. You can click on references like Section~\ref{sec:example} to jump directly to that section.
\section{Example Section}\label{sec:example}
This section demonstrates hyperref's capabilities. You can also create explicit links like \href{https://www.latex-project.org/}{LaTeX Project Website}.
You can also reference back to Section~\ref{sec:intro}.
\section{PDF Information}
The hyperref package also sets PDF metadata like title, author, and keywords.
\end{document}
Customized hyperlinks with different colors and styles for various link types.
\documentclass{article}
\usepackage[colorlinks=true, linkcolor=blue, citecolor=green, urlcolor=red]{hyperref}
\begin{document}
\section{Customized Hyperlinks}\label{sec:custom}
This example shows how to customize the appearance of different types of hyperlinks:
\begin{itemize}
\item Internal references appear in blue: See Section~\ref{sec:another}.
\item Citations appear in green: As shown in~\cite{sample}.
\item URLs appear in red: \url{https://www.example.com}
\end{itemize}
You can also create a link with custom text using \verb|\href|: \href{https://www.latex-project.org/}{Visit the LaTeX Project}.
\section{Another Section}\label{sec:another}
This is another section that can be referenced.
\begin{thebibliography}{9}
\bibitem{sample} Author, A. \emph{Sample Book Title}. Publisher, 2023.
\end{thebibliography}
\end{document}
Advanced PDF features including bookmarks, metadata, and link options.
\documentclass{article}
\usepackage[pdfauthor={Document Author},
pdftitle={Advanced Hyperref Example},
pdfsubject={LaTeX},
pdfkeywords={hyperref, PDF, LaTeX},
pdfproducer={LaTeX},
pdfcreator={pdfLaTeX},
bookmarks=true,
bookmarksopen=true,
bookmarksnumbered=true,
hidelinks,
pdfstartview=FitH]{hyperref}
\begin{document}
\title{Advanced Hyperref Features}
\author{Document Author}
\date{\today}
\maketitle
\section{PDF Bookmarks}
This document demonstrates advanced PDF features with hyperref.
\subsection{Nested Bookmarks}
The bookmarks panel in your PDF viewer should show a hierarchical structure.
\subsubsection{Deep Nesting}
Bookmarks can be nested to match your document structure.
\section{PDF Metadata}
This document has custom metadata set in the PDF properties:
\begin{itemize}
\item Author: Document Author
\item Title: Advanced Hyperref Example
\item Subject: LaTeX
\item Keywords: hyperref, PDF, LaTeX
\end{itemize}
\section{Link Appearance}
The \texttt{hidelinks} option removes the colored borders and highlighting from links, making them visually identical to regular text while still being clickable.
\end{document}