# Problem of duplicate identifier when using bibentry and hyperref

I want to used \bibentryand hyperref in my document. However when I use it as in the sample below I get the error

destination with the same identifier (name{cite.Duhm_AppliedPhysicsLetters_2009}) has been already used, dublicate ignored

I found this work around which works well (commented version in the sample below). However, the bibliography style statto, hyperlinks the title to the respective url, which I would like to keep also in the bibentry (I don't care if there is a hyperlink to the item in the bibliography itself). Is there a solution for this problem, which is not a simple work around which completely ignores the hyperlink?

\begin{filecontents}{mytestbib.bib}

@ARTICLE{Duhm_AppliedPhysicsLetters_2009,
author = {Duhm, Steffen and Salzmann, Ingo and BroÌˆker, Benjamin and Glowatzki,
Hendrik and Johnson, Robert L. and Koch, Norbert},
title = {Interdiffusion of molecular acceptors through organic layers to metal
substrates mimics doping-related energy level shifts},
journal = {Applied Physics Letters},
year = {2009},
volume = {95},
pages = {093305},
doi = {10.1063/1.3213547},
issn = {00036951},
urldate = {2011-11-05}
}

\end{filecontents}
\documentclass{article}
\usepackage{filecontents}
\usepackage{natbib}
\usepackage[pdftex]{hyperref}
\usepackage{fancyhdr}
\usepackage{bibentry}
\makeatother \nobibliography*

\begin{document}

A full in-text cite of
%\begin{NoHyper}\bibentry{Duhm_AppliedPhysicsLetters_2009}\end{NoHyper}.
\bibentry{Duhm_AppliedPhysicsLetters_2009}.

A regular citation  \cite{Duhm_AppliedPhysicsLetters_2009}.

\bibliographystyle{statto}
\bibliography{mytestbib}

\end{document}


You can redefine the \bibentry command so it does not create a hyperref target by adding

\makeatletter
\renewcommand\bibentry[1]{\nocite{#1}{\frenchspacing
\@nameuse{BR@r@#1\@extra@b@citeb}}}
\makeatother


E.g. your example (with natbib options added from your commet so it does not throw an error); the in text ordinary citation now links to the bibliography:

\begin{filecontents}{mytestbib.bib}

@ARTICLE{Duhm_AppliedPhysicsLetters_2009,
author = {Duhm, Steffen and Salzmann, Ingo and BroÌˆker, Benjamin and Glowatzki,
Hendrik and Johnson, Robert L. and Koch, Norbert},
title = {Interdiffusion of molecular acceptors through organic layers to metal
substrates mimics doping-related energy level shifts},
journal = {Applied Physics Letters},
year = {2009},
volume = {95},
pages = {093305},
doi = {10.1063/1.3213547},
issn = {00036951},
urldate = {2011-11-05}
}

\end{filecontents}
\documentclass{article}
\usepackage{filecontents}
\usepackage[square, sort&compress, numbers]{natbib}
\usepackage{fancyhdr}
\usepackage{bibentry}
\usepackage[pdftex]{hyperref}

\nobibliography*

\makeatletter
\renewcommand\bibentry[1]{\nocite{#1}{\frenchspacing
\@nameuse{BR@r@#1\@extra@b@citeb}}}
\makeatother

\begin{document}

A full in-text cite of
\bibentry{Duhm_AppliedPhysicsLetters_2009}.

A regular citation  \cite{Duhm_AppliedPhysicsLetters_2009}.

\bibliographystyle{statto}
\bibliography{mytestbib}

\end{document}


The new definition is just the code from bibentry.sty, i.e.

\newcommand\bibentry[1]{\nocite{#1}{\frenchspacing
\hyper@natanchorstart{#1\@extra@b@citeb}%
\@nameuse{BR@r@#1\@extra@b@citeb}\hyper@natanchorend}}


with the hyperref anchor start/end commands removed.

• I added your solution to my file and it works fine. I seems that using \usepackage[square, sort&compress, numbers]{natbib} (instead of just natbibonly) as I have it in my file gives no error. Could you quickly explain the different elements you use in the solution? – Tanja Oct 30 '13 at 15:05
• @user2758804 natbib options now added to my code. Short explanation of where the command comes from added. – Andrew Swann Oct 30 '13 at 15:22