# Huge citation list with natbib

I have a huge \cite{} for my references with around 6000 entries.

This doesn't go well when compiling.

On Windows it complains there are more than 2000 entries.

On Linux it complains about missing }:

! Missing } inserted.
<inserted text>
}
l.31429 \end{thebibliography}


I checked the bib file with WinEdt and all brackets are balanced. I had stack_size = 5000 under Linux, but have the same message when increasing to stack_size = 50000.

How can I cite everybody correctly?

• you have 6000 entries in a single \cite???? why???? 4 would be considered a lot. – David Carlisle Aug 17 '16 at 19:23
• If you are trying to force all the entries in a bib file into the bibliography you can use \nocite{*} – David Carlisle Aug 17 '16 at 19:24
• You typed a 0 too much, but yes, this is a lot (hence the huge). These are reference for a huge data set compiling thousands of publications. – Togh Aug 17 '16 at 19:25
• If I wanted to refer to the british library, I'd refer to the library not have a list of a few million entries. What is your reader supposed to do with such a list? – David Carlisle Aug 17 '16 at 19:28
• It seems completely pointless to me what is the reader supposed to do with that information? however I know conventions differ in different disciplines. Returning to the problem i assume the problem is that the generated bbl file is mal formed as bibtex died, so increasing tex's stack size will not help (normally each item is typeset separately so a long bibliography has no extra stack usage) you could try using biber I suppose. – David Carlisle Aug 17 '16 at 19:33

There are several aspects in solving this issue:

1. Having a stack_size big enough. The default is around 2000, here I needed something greater than 6000.

Under Ubuntu I had to add stack_size = 10000 inside /usr/share/texlive/texmf.cnf then run texhash, both need root rights.

(Windows and Linux instructions here)

2. Having a good bib file. Check about non escaped characters like &, \$ and % or escaped closing brackets: \}. This is also good to check if you have the right number of opening and closing brackets. You may also have a look here.

3. The key \cite{6000 entries} doesn't seem to handle that many entries (never finish, but maybe I did not wait long enough, but several hours is not something that suits my requirements). Maybe related to the sort&compress option I'm using. A solution is to use \nocite{6000 entries}. This changes the display, but at least it completes in a reasonable time.

As @David Carlisle suggested, an alternative would be to use biber as it doesn't have that much limitations.