hypcap
Fixes hyperlink anchoring behavior for floating elements by ensuring links point to the start of figures and tables rather than their captions.
Overview
Addresses a crucial hyperlink navigation issue in LaTeX documents containing figures, tables, and other floating elements. When using hyperlinks to reference floats, the default behavior often leads users to the caption rather than the content itself, which can be disorienting.
- Provides the
\capstart
command for precise control over link anchor placement. - Offers automatic anchor adjustment through package options for common float environments.
- Particularly valuable in documents with numerous figures and cross-references, such as technical documentation, research papers, and textbooks.
- Seamlessly integrates with the hyperref package to enhance document navigation and accessibility.
Getting Started
To use hypcap
, include it in your document preamble:
\documentclass{article}
\usepackage{hyperref} % Required dependency
\usepackage{hypcap}
You can also enable automatic insertion of \capstart at the beginning of float environments:
\documentclass{article}
\usepackage{hyperref} % Required dependency
\usepackage[all]{hypcap} % Automatically insert \capstart in all float environments
Examples
Basic usage of hypcap to adjust hyperlink anchors in figures.
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[all]{hypcap}
\begin{document}
\section{Introduction}
As shown in Figure~\ref{fig:example}, the hyperlink will now jump to the beginning of the figure rather than to the caption.
\begin{figure}[htbp]
\centering
\rule{8cm}{6cm} % This creates a black rectangle as a placeholder for an image
\caption{An example figure. When using the hypcap package with the 'all' option, clicking on a hyperlink to this figure will take you to the top of the figure rather than to this caption.}
\label{fig:example}
\end{figure}
\end{document}
Manual placement of \capstart for specific control over hyperlink anchors.
\documentclass{article}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage{hypcap}
\begin{document}
\section{Introduction}
Refer to Figure~\ref{fig:example1} and Figure~\ref{fig:example2} to see the difference in hyperlink behavior.
\begin{figure}[htbp]
\centering
\capstart % Manually place the anchor point here
\rule{8cm}{6cm} % Placeholder for an image
\caption{First example figure with manually placed \texttt{\string\capstart}.}
\label{fig:example1}
\end{figure}
\begin{figure}[htbp]
\centering
\rule{8cm}{6cm} % Placeholder for an image
\caption{Second example figure without \texttt{\string\capstart}. Hyperlinks will anchor to this caption.}
\label{fig:example2}
\end{figure}
\end{document}