Latex: When Algorithms and Hyperref hate each other

When using algorithms in Latex and trying to use hyperref to produce automatic links in the references that one uses in LaTeX documents one usually finds out that although the references are printed correctly, the links for algorithms don’t work (usually pointing to the first page in the document). If you investigate the messages of the output you usually find:

pdfTeX warning (dest): name{algorithm.1} has been referenced
but does not exist, replaced by a fixed one

Well, the problem is that for some reason hyperref doesn’t work correctly with the algorithm and float packages. The trick to solve this is to push the use of hyperref package down the most in the preamble (without breaking anything) and then put the float package before hyperref and algorithm package after hyperref like in the example below:

...
\usepackage{float} % Before hyperref
\usepackage{hyperref} 
\usepackage{algorithm} % After hyperref
\begin{document}
...

This seems to solve the problem, and there are other situations where one might want to be careful with the order we load packages.

Does this solve the problem for you?

Latex Tip: back references in bibliography

Latex

When writing long texts, articles or you know… thesis, in latex I find very useful to have automatic links between references and the entries that show up in the bibliography. That is easily accomplished by using the hyperref package in the preamble of the latex document by including the package hyperref

\usepackage{hyperref}

Now, this is cool, but sometimes I’m seeing a reference on the bibliography and I’d just like to know where it was used in the text so I could check what I wrote about it quickly. But this normally involves a search box and it is a pain. It would be easier if you just included backlinks at the end of each reference with the pages where that reference was used.

The hyperref package allows that by setting the option pagebackref=true on the package options. Now you just have to use

\usepackage[pagebackref=true]{hyperref}

and it will give you those nice links at the end of each reference, back to the pages where you first inserted them.

If only bibliographic styles for major publications would be like that! The solution is to remove the option after writing, but even so it is a nice productivity feature to have while writing.