algorithm:According to the hyperref documentation, all packages should be loaded before hyperref:
\usepackage{hyperref}
\usepackage[chapter]{algorithm}% eg.
In most cases, therefore, you should load your package before you load hyperref, and hyperref will patch things up so that they work, so you can utilise your (patched) package after loading both:If you do the first, you get this annoying set of warnings:
! pdfTeX warning (ext4): destination with the same identifier (name{page.1}) has been already used, duplicate ignoredIf you do the second, you get an error:
undefined control sequence \theHalgorithmClearly, the first is preferable to the second, but even the first is terribly annoying. Does anyone have any ideas on how this can be fixed ?
Update: It works ! A comment from Iain Murray points out that in the hyperref README, one is told to include the float package BEFORE hyperref , and only then include algorithm (after hyperref).
I have got the algorithm package to work by including it after hyperref, but manually include the float package (which algorithm will normally include for you) before hyperref. This is in the README file of recent versions of hyperref.
ReplyDeleteI have had many problems with hyperref. These were mainly solved by using the latest version and carefully following all the instructions. Warning: this can lead to dependency hell. Once you put a more recent version of some LaTeX package in your ~/texmf directory you may have to grab more recent versions of many others too.
http://www.gatsby.ucl.ac.uk/~iam23/compnotes/latex.html#hyperref
One fix which I found is to use the second strategy and manually define the \theHalgorithms in your latex preamble as
ReplyDelete\newcommand{\theHalgorithm}{\arabic{algorithm}}
http://www.mail-archive.com/lyx-users@lists.lyx.org/msg10118.html
Your solution did not work for me but I found this:
ReplyDeletehttp://users.encs.concordia.ca/~w_jiewen/LaTeX/qa.htm
http://users.encs.concordia.ca/~w_jiewen/LaTeX/algorithmic-fix.sty
I agree with the algorithmic-fix package that Anonymous poster suggested. The new URL is here:
ReplyDeletehttp://www.cs.uwaterloo.ca/~j55wu/LaTeX/qa.htm
I had to combine that and the float/hyperref/algorithm ordering to remove all warnings.
Thanks Lian for the post! Problems are gone!
ReplyDeleteI suggest to use the algorithm2e package instead of algorithm. It also defines an algorithm environment, and the hyperref linking works again.
ReplyDelete