[Tex/LaTex] File ended wile scanning use of \harvardurl. \bibliography{thesis_references}

compilation errorpreamble

I have compilation errors in my document which seem to be very similar to this question. The error message:

"File ended wile scanning use of \harvardurl. \bibliography{thesis_references}

The problem is with my preamble – might be conflicting packages. The full preamble is getting quite chunky now but these are the components which I think are relevant to the problem:

\usepackage{url}
\usepackage{hyperref}

%% use harvard style referencing
\bibliographystyle{agsm}

%% redefine uarvardurl command as in texexchange anwer
\renewcommand{\harvardurl}[1]{\textbf{URL:} \url{#1}}

\begin{document}
    \bibliography{thesis_references}
\end{document}

The problem doesn't occur if I delete my bbl file and change the referencing style to abbrvnat. Any ideas what's going on?

Best Answer

It is hard to say without seeing the bib file and the used packages, but it looks like there are special characters in a URL, most likely a %.

You probably use the natbib package instead of harvard. Then you can fix this by allowing \url to change the catcodes while reading it's argument. Just change your \harvardurl command to

\renewcommand{\harvardurl}{\textbf{URL:} \url}
Related Question