vitaut
vitaut

Reputation: 55675

How to make a hyperlink navigate to the top of the figure in LaTeX when using hyperref?

I have a LaTeX document with a figure and references to it:

\begin{figure}
...
\caption{...}
\label{fig:1}
\end{figure}

\ref{fig:1}

I use the hyperref package to get hyperlinks in the resulting PDF. However the link to the figure navigates to the caption leaving the figure itself out of the view. How can I make it navigate to the start of the figure instead without moving the caption to the top?

Upvotes: 43

Views: 20658

Answers (3)

user2916497
user2916497

Reputation: 9

\usepackage{hyperref}
\usepackage{caption}

Using this is a better idea than \usepackage[all]{hypcap}.

Upvotes: -1

nbz
nbz

Reputation: 3938

Add this in your preamble

\usepackage{hyperref}
\usepackage[all]{hypcap}    %for going to the top of an image when a figure reference is clicked

Make sure that the \usepackage[all]{hypcap} is written after the hyperref package is imported.

Upvotes: 38

michalko
michalko

Reputation: 456

To previous comment:

\usepackage{hyperref}
\usepackage{caption}

is slightly better than \usepackage[all]{hypcap} because when you use e.g. figure without captions there won't be a compilation problem. The caption package by default sets option

hypcap=true

anchoring hyperlinks to the beginning of an environment.

Upvotes: 34

Related Questions