[Tex/LaTex] tex capacity exceeded when including url in .bib file

bibtex

When I include url in the .bib file latex throws the error:
Tex capacity exceeded, sorry[save size=5000]

Do you have any idea why?
Below I paste the package I use and one reference

\documentclass[english]{article}
\usepackage[utf8]{inputenc} %write accent without the \ [' ` ^] 
\usepackage{lmodern,textcomp} % + the above package use euro directly
\usepackage{babel}
\usepackage{harvard}
\bibliographystyle{agsm}
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage[margin=1.5in]{geometry}
%\usepackage{times}

\begin{document}

as in \cite{AhlinTownsend2007}, blah, blah blah...
\cite{DufloBanerjee2013}

\bibliography{test}

\end{document}

and the test.bib file

@article {AhlinTownsend2007,
author = {Ahlin, Christian and Townsend, Robert M.},
title = {Using Repayment Data to Test Across Models of Joint Liability Lending*},
journal = {The Economic Journal},
volume = {117},
publisher = {Blackwell Publishing Ltd},
number = {517},
pages = {F11-F51},
issn = {1468-0297},
doi = {10.1111/j.1468-0297.2007.02014.x},
url = {http://dx.doi.org/10.1111/j.1468-0297.2007.02014.x},
year = {2007},
}

@techreport{DufloBanerjee2013,
title={The miracle of microfinance? Evidence from a randomized evaluation},
author={Duflo, Esther and Banerjee, Abhijit and Glennerster, Rachel and Kinnan, Cynthia G},
year={2013},
institution={National Bureau of Economic Research},

}

Best Answer

I'm afraid I also cannot replicate the capacity-exceedance error you're reporting.

However, I have two suggestions -- both motivated by the fact that you're using the hyperref package -- which may be useful. Moreover, one of these suggestions involves using natbib instead of harvard. With this change, the capacity-exceedance error may also disappear on its own.

  • If you want a URL string to be an active hyperlink that users can click on, you should write the url field as

    url = {\url{http://dx.doi.org/10.1111/j.1468-0297.2007.02014.x}},
    

    instead of as

    url = {http://dx.doi.org/10.1111/j.1468-0297.2007.02014.x},
    
  • If you want the citation callouts in the body of the document to become hyperlinks to the corresponding entries in the bibliography, don't load the harvard citation management package. Instead, load the natbib citation management package and the auxiliary har2nat package. Since you're using the agsm bibliography style, which is part of the harvard package, it's necessary to load har2nat, as it provides macros that "translate" some of the harvard-specific macros into forms that natbib can process. (When switching from harvard to natbib/har2nat, it's generally necessary to delete all auxiliary files that were created during an earlier compilation run.)

In the example below, note that the natbib package is loaded with the option longnamesfirst in order to replicate the feature of the harvard package that the names of all authors should be provided the first time a given entry is cited. (Subsequent callouts to a given entry are typeset as FirstAuthor et al..) Separately, observe that one should encase the word Evidence in curly braces in order to keep it from being converted to all-lowercase.

enter image description here

\documentclass[english]{article}
\usepackage{filecontents} % make this a self-contained example
\begin{filecontents*}{test.bib} 
@article {AhlinTownsend2007,
  author = {Ahlin, Christian and Townsend, Robert M.},
  title = {Using Repayment Data to Test Across Models of Joint Liability Lending},
  journal = {The Economic Journal},
  volume = {117},
  publisher = {Blackwell Publishing Ltd},
  number = {517},
  pages = {F11-F51},
  issn = {1468-0297},
  doi = {10.1111/j.1468-0297.2007.02014.x},
  url = {\url{http://dx.doi.org/10.1111/j.1468-0297.2007.02014.x}},
  year = {2007},
}
@techreport{DufloBanerjee2013,
  title={The miracle of microfinance? {Evidence} from a randomized evaluation},
  author={Duflo, Esther and Banerjee, Abhijit and Glennerster, Rachel and Kinnan, Cynthia G},
  year={2013},
  institution={National Bureau of Economic Research},
}
\end{filecontents*}
\usepackage[margin=1.5in]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{lmodern,textcomp} 
\usepackage{babel}
%%%\usepackage{harvard} 
\usepackage[longnamesfirst]{natbib} 
\usepackage{har2nat}                % emulate harvard-type macros for natbib
\bibliographystyle{agsm} % agsm is part of the "harvard" package
\usepackage{amsmath}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage[colorlinks=true,citecolor=blue]{hyperref}

\begin{document}
\dots as in \cite{AhlinTownsend2007}, blah, blah blah\dots
\cite{DufloBanerjee2013}

\bibliography{test}
\end{document}
Related Question