GeneralReferences to figures with hyperref

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
severin
Posts: 2
Joined: Thu May 10, 2007 12:12 pm

References to figures with hyperref

Post by severin »

Hyperref coupled with pdflatex has the nice effect of producing hyperlinks and tags in my pdf-file whenever i use a \ref or \label command. Convenient.

What is not so convenient is this: The hyperlink references the exact place of the \label{fig:XXX}. This works great for makeindex and such, but as long as I have my captions printed below my figures, the result of activating the reference link in the pdf-file is that my Adobe Reader (version 7.0.9 on MS Windows) shows me the caption, and not the figure. Depending on the viewing setup of Adobe Reader (single page, continuous, FitW, FitH) the figure is partially or completely off-screen.

I would like to make the hyperlink show the whole figure. How do I go about this?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
countbela666
Posts: 64
Joined: Thu Apr 26, 2007 2:44 pm

References to figures with hyperref

Post by countbela666 »

Hi,

just put the following code into your preamble (after including hyperref!):

Code: Select all

\usepackage[all]{hypcap}
Regards
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
severin
Posts: 2
Joined: Thu May 10, 2007 12:12 pm

Re: References to figures with hyperref

Post by severin »

Thanks so much.

I noticed that it did not work as expected, though. I use MikTeX 2.5, and I found that I needed to start all my figure environments with \capstart instead og passing the [all] opption to hypercap. This is OK for me, though. It seems to be more flexible, too, as it allows for finer control, i.e. it works better with subfigures.

Cheers.

Now, while I am at it it would be lovely with backreferences too. I am considering wether to put all my figures on a separate page of floats, and then it would be nice to be able to navigate easily back to the place in the text where the figure was referenced.

Any ideas for this?
User avatar
countbela666
Posts: 64
Joined: Thu Apr 26, 2007 2:44 pm

References to figures with hyperref

Post by countbela666 »

There is an option quite easy to implement, which only works if the output PDF is viewed with an Acrobat Viewer. For this purpose hyperref provides the command \Acrobatmenu which allows you to access Acrobat menu options.

The following minimum example implements a solution with the View->Back menu item:

Code: Select all

\documentclass[demo,english]{article}
\usepackage{babel,blindtext,graphicx,hyperref}
\usepackage[all]{hypcap}
\def\demofig{%
  \begin{figure}
    \centering
    \includegraphics{foo}
    \caption{I'm figure \thefigure}
    \Acrobatmenu{GoBack}{(back)}
    \label{fig:\thefigure}
  \end{figure}
}
\begin{document}
  see~\autoref{fig:2}\par
  \Blindtext[5]
  \demofig\demofig\demofig
  \Blindtext[5]
  see~\autoref{fig:1}
\end{document}
Regards
Marcel
Listen to me children of the night, beyond the doors of darkness you will find
a thousand worlds for you to see here, take my hand and follow me...
Post Reply