# tex capacity exceeded when including url in .bib file

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},

}

• Could you please complete your code to make a small document demonstrating the issue? That is much more useful than mere code fragments. – cfr May 4 '14 at 12:41
• If I create a .bib file and add \cite{AhlinTownsend2007} plus \bibliographystyle{agsm}, I don't get any error. However, in general, hyperref should be loaded last, surely after harvard. – egreg May 4 '14 at 12:43
• @cfr here is the complete code – DJJ May 4 '14 at 14:33

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}},


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.

\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}

• @DJJ - I'm not sure what you mean by "the right way" to provide a URL. You certainly don't have to provide the \url instruction. However, if \url is omitted, the URL string will not be typeset as an active hyperlink. Moreover, overfull lines and other bad line break situations may occur if you omit the \url "wrapper", because LaTeX probably has no idea how to break a long URL string across lines. – Mico May 4 '14 at 15:15
• @djj - Thanks for the comment that provides a link to an earlier posting that was also contending with capacity-exceeded problems. However, AFAICT the PhDbiblio-url2 bibliography style (which was used in the earlier posting) and the agsm bibliography style (which is what you use) do not do the same things with the contents of the url field. I'd thus say you're safe using the \url` wrapper macro. – Mico May 4 '14 at 15:22