# Tex capacity exceeded, sorry [input stack size = 5000]

This is the error I am getting since I have added some new references to my .bib file. I think is more than a filled stack. Any ideas? references.bib

It was requested a minimum working example but I am working on a template and it was quite difficult for me cut it out. This is my complete structure. The master document is thesis.tex and the problem is raised only under related_work chapter. If you have the time to look at it, I would highly appreciate it. Here is the complete document.

• The BIB file looks fine to me. Please add a minimal working example (MWE) that generates this problem with this BIB file. – Martin Scharrer Jul 27 '11 at 17:04
• There is no related_work chapter in your very non-minimal example (which compiles without error). – Lev Bishop Jul 28 '11 at 0:03
• @ShinTakezou @Martin it looks like when i am changing \bibliographystyle{Latex/Classes/PhDbiblio-url2} to another class like \bibliographystyle{Latex/Classes/PhDbiblio-case} the problem is getting resolved. – Chris-Top Jul 28 '11 at 13:12
• even with url2, I can't reproduce the error. It goes fine for me. – ShinTakezou Jul 28 '11 at 18:43
• It compiles fine for me, too. My stack size is set to 5000. What TeX distribution do you use? – Jan Hlavacek Jul 30 '11 at 4:24

It seems that the PhDbiblio-url2 bibliography style does not want the url field to contain \url{...}. It takes care of the url formating itself, enclosing the contents of the url field in \href{...}.

If you have something like

url = {\url{http://example.com/}};


in you .bib file, the PhDbiblio-url2 style translates that into

\href{\url{http://example.com/}}


which creates an infinite loop in the hyperref package.

The proper way to include url in the bibliography, when using this style, is just

url = {http://example.com};

• I found also url = "\url{example.com}"; making the error too. Just correct it as well using ctrl+F buttons. – Mike22LFC Jul 17 '17 at 5:48

Not a useful general answer, but a specific case in Beamer:

A \begin{block} statement (without a name option) will cause this error. The correct format is \begin{block}{Block title}, or \begin{block}{} if you want no title.

• very useful indeed..! – alekhine Jul 21 '15 at 15:43
• This is the right answer – Amir Apr 17 '16 at 18:32
• @Amir: No, it is quite specifically the wrong answer for the question, since the question is not about beamer. – naught101 Apr 18 '16 at 5:40
• @naught101 but if you have the beamer problem, google the error, you end up here, so it IS a VERY useful answer (: – drevicko Jul 25 '16 at 11:33
• @drevicko: useful: yes, right: no :) – naught101 Jul 26 '16 at 1:34

I found the solution: there was a conflict between hyperref and frenchle, so I got it fixed by replacing \usepackage{frenchle} by \usepackage[french]{babel}.

• Please note that this very general error can occur for a wide variety of reasons. While switching from frenchle to the standard babel package (which is indeed very recommendable) removed the error in your document, it doesn't mean that it is a general solution. – Martin Scharrer Jan 24 '12 at 10:28

There's a config file where some numbers about "memory" TeX uses are written, I have it into /etc/texmf/texmf.cnf; you may need to change some value and regenerate formats.

stack_size = 5000        % simultaneous input sources


Of course the problem may arise from a bug in TeX macros you're using, that consumes all the stack; so we need more information.

EDIT

If you want to edit that file, avoid editing /etc/texmf/texmf.cnf as always in configuration files. Instead edit the specific file in /etc/texmf/texmf.d/ - on Ubuntu currently /etc/texmf/texmf.d/95NonPath.cnf.

After editing the file you have to execute update-texmf to rewrite the configuration file.

EDIT2

Often it happens you can't have access to /etc or other system directories, so you need your own cnf file (and TeX tree). This link talks about it.

• Changing the stack size won't fix it. It's always some TeX macro. – Martin Scharrer Jul 27 '11 at 20:48
• The stack_size threw another error on a param_size, it didn't fix it as mentioned. – Chris-Top Jul 27 '11 at 21:31
• @Martin not at all. It will fix it, if it's not a bug but a real need of some complex macro. Once I needed it to do some heavy tricks. If it wouldn't be so, setting another value for stack_size, like 100, wouldn't cause problems. – ShinTakezou Jul 28 '11 at 5:07
• @Chris-Top we need investigate better your work; I've seen you put a link, unfortunately it is blocked by job websense, so I'll take a look later (very later) – ShinTakezou Jul 28 '11 at 5:10
• ... so later that I've forgot... anyway about the EDIT, the best way should be to set up things so that a common user has no to edit files in /etc at all, since common users usually can't edit them unless there's an admin flaw. – ShinTakezou Jun 13 '12 at 5:34

Another answer which only applies to Beamer:

Somehow beamer doesn't like the ' in formulas. That means if I write $t'$ I get the error, whereas $t^\prime$ works. I'm not sure if this only happens under certain conditions -- just mentioning it here since it's another possible source of this error.

I think the correct answer is to find an MWE.

In my case, the error message pointed to the \maketitle command, which was of no help. I found I could eliminate the entire body of the document and still got the error. I eventually traced the problem to the use of \thanks{} within \author{}, which is supported by article and several other document classes, but not acmart and amsart. The class documentation says to use \authornote{} instead, and outside \author{}.

In my case, the error was caused by typing documentclass[article] instead of documentclass{article}