# Hyperref with pagebackref requires manual escaping of percentage signs in URLs

URLs in bibliography items with a %20 (to represent a space) work fine with the package hyperref as long as the option pagebackref is not used. If it is used, Latex fails with:

xxx.bbl:xx: Paragraph ended before \BR@@bibitem was complete,


ie, the percentage sign is not automatically escaped and thus the URL field is not properly terminated. Escaping it in the .bib file with a backslash solves the issue but requires manual work every time I generate a new .bib file.

Is there another way to solve this problem?

MWE:

\RequirePackage{filecontents}
\begin{filecontents}{\jobname.bib}
@MISC{refID,
title="title",
url = {http://www.somesite.com/8%20report}
}
\end{filecontents}
\documentclass{article}
\usepackage[pagebackref=true]{hyperref}
\begin{document}
\cite{refID}
\bibliography{\jobname}
\bibliographystyle{IEEEtran}
\end{document}


With backref active, the entire bibliography record in the .bbl file is read as an argument, so the category code tricks made by \url don't work.

However, the IEEEtran bib style provides the hook \BIBdecl that's executed at the start of the bibliography; use it to make % into a printable character. The produced .bbl file shouldn't have comments after \BIBdecl, at least as far as I can see.

\begin{filecontents*}{\jobname.bib}
@MISC{refID,
title="title",
url = {http://www.somesite.com/8%20report}
}
\end{filecontents*}
\documentclass{article}
\usepackage[pagebackref=true]{hyperref}

\newcommand{\BIBdecl}{\catcode\%=12 }

\begin{document}
\cite{refID}
\bibliography{\jobname}
\bibliographystyle{IEEEtran}
\end{document}
`

• Works great, should this work with every bibliography style that has the following lines: "\providecommand{\BIBdecl}{\relax}" write$newline$ "\BIBdecl" write$newline$ – noirdesir Oct 24 '13 at 16:16