3

I have a few figures which must be shown rotated in landscape orientation. For that I use \begin{sidewaysfigure} instead of \begin{figure}. But now I found in my text there is a problem between the interaction of sidewaysfigure and hyperref. While figure numbering is correct both in the caption and the main text, clicking on the cross reference in the text is associated with wrong figures (a few numbers back).

EDIT: The following reproduces the problem for me:

\documentclass[a4paper]{book}
\usepackage{caption}
\usepackage{rotating}
\usepackage[pdftex]{hyperref}
\usepackage[figure,table]{hypcap}   % corrects the hyper-anchor of figures/tables

\begin{document}

First: Fig.~\ref{fig:first}. Second: Fig.~\ref{fig:second}.
Third: Fig.~\ref{fig:third}. Fourth: Fig.~\ref{fig:fourth}.

\begin{figure}
\includegraphics[width=1\textwidth]{figures/zelle148_IMG_1903m.jpg}
\caption{First}\label{fig:first}
\end{figure}

\begin{figure}
\includegraphics[width=1\textwidth]{figures/zelle148_IMG_1903m.jpg}
\caption{Second}\label{fig:second}
\end{figure}

\begin{figure}
\includegraphics[width=1\textwidth]{figures/zelle148_IMG_1903m.jpg}
\caption{Third}\label{fig:third}
\end{figure}

\begin{sidewaysfigure}
\includegraphics[width=1\textwidth]{figures/zelle148_IMG_1903m.jpg}
\caption{Foruth}\label{fig:fourth}
\end{sidewaysfigure}

\end{document}

If I remove the hypcap package, the problem disappears. This is odd as the comment precisely reads "corrects the hyper-anchor of figures/tables"...


I have found a very similar question which is not really answered. Some info from the console when rendering:

This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)

LaTeX2e <2009/09/24>

When I add \listfiles as suggested in the other post, I get the following entries:

rotating.sty    2009/03/28 v2.16a rotated objects in LaTeX
hyperref.sty    2011/04/17 v6.82g Hypertext links for LaTeX
hobsub-hyperref.sty    2011/04/23 v1.4 Bundle oberdiek, subset hyperref (HO)
 hycolor.sty    2011/01/30 v1.7 Color options of hyperref/bookmark (HO)
  pd1enc.def    2011/04/17 v6.82g Hyperref: PDFDocEncoding definition (HO)
hyperref.cfg    2002/06/06 v1.2 hyperref configuration of TeXLive
 hpdftex.def    2011/04/17 v6.82g Hyperref driver for pdfTeX
  hypcap.sty    2011/02/16 v1.11 Adjusting anchors of captions (HO)
  • 1
    Can you please give us a compilable code to play with? If you use package caption use option hypcap=true instead of package hypcap. See documentation of caption. Have you considered to update your TeX distribution? Current is TeX Live 2013, you have 2011 ... – Mensch Nov 2 '13 at 17:47
4

Package hypcap is a little bit outdated.

In the documentation of package caption you can find the description of the new option hypcap=true or hypcap to get the functionality of old package hypcap.

Because you are using package caption do not use package hypcap. Please see the documentation of package caption for more informations.

Edit:

Your given MWE will work with the small changes I made (I used package MWE for the example images, added option hypcap and commented package hypcap):

\documentclass[a4paper]{book}
\usepackage[hypcap=true]{caption}  % <==============
\usepackage{rotating}
\usepackage[pdftex]{hyperref}
%\usepackage[figure,table]{hypcap}   % corrects the hyper-anchor of figures/tables % <==============

\begin{document}

First: Fig.~\ref{fig:first}. Second: Fig.~\ref{fig:second}.
Third: Fig.~\ref{fig:third}. Fourth: Fig.~\ref{fig:fourth}.

\begin{figure}
\includegraphics[width=1\textwidth]{example-image-a.jpg} % <==============
\caption{First}\label{fig:first}
\end{figure}

\begin{figure}
\includegraphics[width=1\textwidth]{example-image-a.jpg} % <==============
\caption{Second}\label{fig:second}
\end{figure}

\begin{figure}
\includegraphics[width=1\textwidth]{example-image-a.jpg} % <==============
\caption{Third}\label{fig:third}
\end{figure}

\begin{sidewaysfigure}
\includegraphics[width=1\textwidth]{example-image-a.jpg} % <==============
\caption{Foruth}\label{fig:fourth}
\end{sidewaysfigure}

\end{document}
  • 1
    Thanks! I managed also to update the question to have a reproducible example. – Emit Taste Nov 2 '13 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.