21

In my TeX file I have the following code:

\begin{figure}[H]
    \begin{center}
        \includegraphics[width=5in]{screens/main.png}
        \caption{\label{fig:MainScreen} Screenshot of the main screen of TADA.}
    \end{center}
\end{figure}

However, when I reference the figure earlier on in my document:

...in Figure \ref{fig:MainScreen}.

...if I click on the reference in Preview (Mac) it takes me to where the \label command is (which is below the actual image in the figure). That is, the document is scrolled to where the caption is at the top of the page, which is somewhat annoying if I'm trying to look at the figure itself.

My question to you is, can I get LaTeX to create a reference to the top of the figure while keeping the \caption command at the bottom? For stylistic purposes I must keep the caption below the figure.

My only thought was to move the \label command to before the \includegraphics command, but apparently \caption has to come before \label for the referencing to work correctly.

tshepang
  • 12,111
  • 21
  • 91
  • 136
celestialorb
  • 1,901
  • 7
  • 29
  • 50
  • 1
    just a quick somewhat unrelated comment; I believe it's generally preferable to use `\centering` instead of the `center` environment as it tends to add bit of extra vertical space that can be unwanted – Sam Mason Oct 14 '13 at 12:19
  • 3
    Possible duplicate of [How to make a hyperlink navigate to the top of the figure in LaTeX when using hyperref?](http://stackoverflow.com/questions/4023925/how-to-make-a-hyperlink-navigate-to-the-top-of-the-figure-in-latex-when-using-hy) – antoine Oct 06 '15 at 01:08

1 Answers1

26

Have a look at the hypcap package documentation (CTAN is your friend: http://www.ctan.org/), but as a quick summary you should be able to simply put

\usepackage[all]{hypcap}

somewhere after you load hyperref and it will just work.

McBeth
  • 1,177
  • 8
  • 12