Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to get LaTeX to link to the top of a figure rather than to its caption?

Tags:

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.

like image 456
celestialorb Avatar asked Jul 14 '11 14:07

celestialorb


People also ask

How do you put the caption of a figure at the top in LaTeX?

Caption. It is usually beneficial to include caption to your images. To do so, simply use the command \caption{'text'} either below or above your figure (usually below for images and above for tables).

How do you link a figure in LaTeX?

Links to a web address or email can added to a LaTeX file using the \url command to display the actual link or \href to use a hidden link and show a word/sentence instead. There are two commands in the example that generate a link in the final document: \href{http://www.overleaf.com}{Something Linky}

How do I fix the position of an image in LaTeX?

You can control the position of an image using options for the figure environment, e.g. the [h!] in the example below tells LaTeX to put the figure exactly where it appears in the text, instead of letting it 'float' to a particular place in the document.


1 Answers

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.

like image 79
McBeth Avatar answered Oct 01 '22 03:10

McBeth