[Tex/LaTex] Removing double entries from hyperref’s pagebackref

back-referencingbibliographieshyperref

When using hyperref's pagebackref, the same page is listed multiple times, if the reference appears on that particular page more than once.

e.g.:

A. Hindle, M. Godfrey, and R. Holt. Software process recovery using
recovered unified process views. In Software Maintenance (ICSM), 2010
IEEE International Conference on, pages 1–10. IEEE, 2010. doi:
10.1109/ICSM.2010.5609670. (pages 3, 3, 6, 6, 6, 6).

How do I remove double entries from the list?

SIDENOTE:

As you might have spotted, I applied a "page"/"pages" addition (from here) which comes down to:

\renewcommand*{\backreflastsep}{, }
\renewcommand*{\backreftwosep}{, }
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
  \ifcase #1 %
    No citations.% use \relax if you do not want the "No citations" message
  \or
    (page #4).%
  \else
    (pages #4).%
  \fi%
}

Without this addition, citations also appear multiple times.

Best Answer

Simply replace #4 with #2 in your redefinition of the \backrefalt macro: As the backref manual explains, \backrefalt takes four arguments:

  1. Number of citations without dupes.
  2. Back references list without dupes.
  3. Number of all citations (with dupes).
  4. Back reference list with all entries (with dupes).

So #2 is exactly what you need.

Minimal test case:

\documentclass{article}

\begin{filecontents*}{bibliography.bib}
@INPROCEEDINGS{5609670, 
 author={Hindle, A. and Godfrey, M.W. and Holt, R.C.}, 
 booktitle={Software Maintenance (ICSM), 2010 IEEE International Conference on}, 
 title={Software process recovery using Recovered Unified Process Views}, 
 year={2010}, 
 month={sept.}, 
 volume={}, 
 number={}, 
 pages={1 -10}, 
 doi={10.1109/ICSM.2010.5609670}, 
 ISSN={1063-6773},}
\end{filecontents*}

\usepackage[pagebackref]{hyperref}

\renewcommand*{\backreflastsep}{, }
\renewcommand*{\backreftwosep}{, }
\renewcommand*{\backref}[1]{}
\renewcommand*{\backrefalt}[4]{%
  \ifcase #1 %
    No citations.% use \relax if you do not want the "No citations" message
  \or
    (page #2).%
  \else
    (pages #2).%
  \fi%
}

\begin{document}
\null\clearpage
\null\clearpage
\cite{5609670}\cite{5609670}\clearpage
\null\clearpage
\null\clearpage
\cite{5609670}\cite{5609670}\cite{5609670}\cite{5609670}\clearpage

\bibliographystyle{plain}
\bibliography{bibliography}
\end{document}

output result

Related Question