3

There is an issue when using the hyperref package, which provides links and bookmarks, together with the float package, which implements changes in float placement in the document.

Loading both has the side effect of making all links generated by hyperref lead to the first page of the document, instead of the appropriate page. The following MWE reproduces the issue:

\documentclass{article}

\usepackage{lipsum}

\usepackage[pdftex,
            bookmarks=true,
            breaklinks,
            pagebackref=true]{hyperref}
\usepackage{bookmark}

\usepackage{float}      
   \restylefloat{figure}
   \restylefloat{table} 


\begin{document}

\lipsum[20-27]

\begin{figure}
\centering
A figure.
\caption{Figure caption}
\label{label}
\end{figure}

\lipsum[3-8]

Link to figure: \ref{label}.
\lipsum[17]

\end{document}

In this example, the label reference leads to the first page, and not to the page where the figure actually is.

I haven't found any mentions to this in either the hyperref or the float documentations.

  • 1
    Loading the float package before hyperref, as suggested in the answer, also seems to eliminate "pdfTeX warning (ext4): destination with the same identifier ... has been already used, duplicate ignored" type errors. – GregH Aug 20 at 14:51
4

The solution to this issue is to load the float package before hyperref, issuing commands that affect floats after loading hyperref:

(...)
\usepackage{float}      

\usepackage[pdftex,
            bookmarks=true,
            breaklinks,
            pagebackref=true]{hyperref}
\usepackage{bookmark}

\restylefloat{figure}
\restylefloat{table} 

(...)

I'm not sure about why this behavior occurs, but I can assume that there is some command redefinition in float that breaks links generated by hyperref.

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.