[Tex/LaTex] hyperref with the backref=page option

back-referencinghyperrefnatbib

I encountered an issue when using the backref=page option of the hyperref package together with the natbib package with the options square,sort&compress,numbers.
If the natbib package compresses a range of references, the middle references does not show the backreference after compiling (latex,bibtex,latex,latex).

See the following short example:

\documentclass{article}  
\usepackage[square,sort&compress,numbers]{natbib}  
\usepackage[backref=page]{hyperref}

\begin{document}  
\cite{foo,bar,hole}

\begin{thebibliography}{ab}  
\bibitem{foo} foo

\bibitem{bar} bar

\bibitem{hole} hole

\end{thebibliography}  
\end{document}

Best Answer

Make the following patch to natbib.sty:

--- natbib.sty.old 2009-07-23 10:44:10.000000000 -0400
+++ natbib.sty  2009-11-01 17:07:53.309765500 -0500
@@ -408,6 +408,7 @@
         \@ifnum{\NAT@nm=\@tempcnta}{%
          \@ifnum{\NAT@merge>\@ne}{}{\NAT@last@yr@mbox}%
         }{%
+           \Hy@backout{\@citeb\@extra@b@citeb}%
           \advance\@tempcnta by\@ne
           \@ifnum{\NAT@nm=\@tempcnta}{%
             \ifx\NAT@last@yr\relax

I have reported this to the authors of hyperref and natbib. Heiko (author of hyperref) wants this to be fixed in natbib, because this is too deeply buried in the natbib code for him to feel comfortable patching it. Patrick (author of natbib) has not responded to my emails....

Related Question