## TeX capacity exceeded errorNovember 30th 2006

I am definitely dumb. Well, LaTeX has its part in it, too.

It turns out that all of a sudden, I started having this error when compiling a .tex file:

! TeX capacity exceeded, sorry [input stack size=1500].

After googling for an answer, I found out that the “stack size” limit is defined in the following file:

/usr/share/texmf/web2c/texmf.cnf

However, changing the value made no good: any limit, no matter how large, would be “exceeded”. The reason (after a little more hitting my head against the wall) is that there was an infinite loop in the input .tex (maybe \input{file.tex} inside file.tex, or somesuch). 10 hours (well, 5 minutes, actually) of head-banging later, when I was pretty sure no freaking infinite loop was there, I found the answer:

I had deleted the \end{document} tag!!

Now, yes, how stupid am I? And… how stupid is LaTeX to give that silly error, instead of:

TeX warning: You are too dumb, and forgot an \end{document}

Tags: , ,

### 40 Responses to “TeX capacity exceeded error”

1. Krisztián on 10 Jul 2007 at 0:53 am #

For me “\usepackage{graphicx}” was the bad guy.

2. krisztián on 10 Jul 2007 at 0:56 am #

Oh, forgot to mention it was pdflatex.

3. Tazabi on 01 Oct 2007 at 22:06 pm #

I just had a 2hr hunt for a solution for such a problem and the problem was that I had a \verb in a caption.

4. Engineer on 21 Nov 2007 at 18:04 pm #

OMG I have jsut spent far too long trying to resolve this.

My problem was because of an errant entry in my bibtex file, diss.bib I mistakenly had a url{} element, which apparently shouldn’t be there!

Posting this here to help other googlers!

Original error:
———————————
! TeX capacity exceeded, sorry [input stack size=5000].
\hmode@bgroup ->\leavevmode
\bgroup
l.7

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

5. isilanes on 05 Mar 2008 at 21:15 pm #

Taken from my former blog URL at: http://handyfloss.wordpress.com/2006/11/30/tex-capacity-exceeded-error/

Mikaël said:

! TeX capacity exceeded, sorry [input stack size=5000].
\hmode@bgroup ->\leavevmode
\bgroup
l.7

Apparently it has indeed something to do with the url{} tag in my .bib file. However, I need this entry because I need to be able to reference to certain websites. (bibliography rules at my university require that i refer to the exact urls.)

Any suggestions?

LOL found it. It’s as easy as opening your .bib file in your favorite text/tex-editor, and adding \usepackage{url} at the beginning of the file. Apparently then latex also knows how to read a url as a url within the .bib file.

Thanks for your input, Mikaël. The best part of a blog is learning from comments to one’s posts! :^)

6. Johann on 03 Jul 2008 at 16:03 pm #

The way I got this error was that I forgot the {} for the title of a block environment (using beamer):

%%% error: %%%
\begin{block}

\end{block}

%%% no error: %%%
\begin{block}{}

\end{block}

7. N on 20 Aug 2008 at 1:04 am #

I have a paper that is overdue for a conference and I just got this error. The annoying thing is that I made no more than a minor change to my original tex file and my .bib file and all of a sudden bibtex stopped working with precisely that error. More annoying, I’ve undone those changes and the error persists. It’s enough to push me off of LaTeX, since one of the major reasons why I use it is the ease of bibtex.

Any ideas?

8. N on 20 Aug 2008 at 1:26 am #

OK, for me it also seems to be a URL problem. Unfortunately, I already have \usepackage{url} in the document and in the bibtex file. Any other ideas on how to fix it?

9. isilanes on 21 Aug 2008 at 13:47 pm #

Sorry, N, nothing from the top of my head. If you could post the .tex file I could try to debug it, but I will not be much online, since I’m on vacations until September.

10. John on 28 Aug 2008 at 14:00 pm #

Thanks Johann for your post (beamer and block). Your comment saved my a couple of hours and LOTS of frustration.

11. N on 02 Sep 2008 at 21:19 pm #

Thanks. I ended up stripping all the URL information, and then it worked.

12. TeX capacity exceeded error « handyfloss on 17 Sep 2008 at 10:43 am #

[...] Entry available at: http://handyfloss.net/2006.11/tex-capacity-exceeded-error/ [...]

13. Fernando Rozenblit on 03 Nov 2008 at 19:50 pm #

For me it was a “\begin{block}” that should be “\begin{block}{}”, using beamer.

14. isilanes on 04 Nov 2008 at 16:34 pm #

Thank you all for your comments. Apparently this error can be triggered in many ways. But the bottom line in most/all cases is that it is a stupid error from the user side, yet a simple (syntax) test that the LaTeX compiler doesn’t run. It would be great to have a “pre-processor” that read the .tex file looking for obvious errors such as the above, then warn about them, instead of trying to compile and fail.

15. kok on 26 Mar 2009 at 12:23 pm #

I got this error because I changed the spacing between items

\let\origitemize\itemize
\def\itemize{\origitemize\itemsep-0.5\baselineskip}

As this is a common tip to change the line space within an item environment, others might encounter the same problem.

16. isilanes on 26 Mar 2009 at 13:06 pm #

17. Dai on 15 Nov 2009 at 18:12 pm #

Thanks to Johan for highlighting what, for me, was the problem: always put a pair of curly braces when starting each block, i.e.

\begin{block}{}

18. Dai on 15 Nov 2009 at 18:13 pm #

Should have mentioned that my problems were also encountered with Beamer

19. Luca on 07 May 2010 at 16:23 pm #

Thank you so much Johann, it was the same for me. The problem was a \begin{block} without the required title in Beamer.

20. didietok on 19 May 2010 at 3:20 am #

OMG, how stupid am I? i forgot to write {} after \begin{block}

21. bill on 03 Sep 2010 at 21:51 pm #

I also encountered this error with MiKTeX and TeXnicCenter on Windows 7.
What did the trick for me was to delete the temporary junk files (i.e. all except the .tex and .bib).
Maybe I should also mention, that they were left overs from working on some linux machine…

22. helen on 11 Oct 2010 at 17:56 pm #

I got this error, found this page and spotted I had URLs in my bibtex file, so I deleted them because they weren’t actually necessary for me.

Error didn’t go away. Frustration.

Eventually realised that the .bbl file (that is created when you bibtex something) is not fixed unless you delete it and re-bibtex, as it were.

Deleted it, re-ran bibtex, it worked. Hooray!

23. Michael on 20 Oct 2010 at 12:25 pm #

Don’t know whether anyone has reported this one yet… Using a double-backslash inside a figure caption, instead
of the backslash-newline command, caused the stupid error in my case. As soon as I read the posts in this blog
and knew how to go about finding the culprit, I could identify the erroneous text and then find what was wrong with
it. Needless to say: double-backslash in normal text, outside figure captions, is no problem. Thanks to all who have
posted messages regarding this, because that way the time I wasted looking elsewhere was minimised.

24. cynthia on 06 Nov 2010 at 2:25 am #

My ‘capacity exceeded’ error was courtesy of an extra ‘\end{itemize}’ line

25. Dilip on 22 Feb 2011 at 14:53 pm #

In my case it was an extra \begin{itemize} and \end{itemize}.

26. Andy on 23 Mar 2011 at 10:26 am #

I ran into this problem when I changed the language setting on my thesis to English (Canadian) instead of just English. Luckily I had a backup that I diff’ed to figure it out!

27. First Time Beamer on 19 May 2011 at 14:37 pm #

Worked the same way for me, thanks!

#

Johann on 03 Jul 2008 at 16:03 pm #

The way I got this error was that I forgot the {} for the title of a block environment (using beamer):

%%% error: %%%
\begin{block}

\end{block}

%%% no error: %%%
\begin{block}{}

\end{block}

28. kimsan on 24 May 2011 at 16:26 pm #

I got these error when i added some options to a \begin{axis} like:

\begin{axis}[
legend style={fill=white}
minor tick num=3
]

and forgot to separate them by comma “,” like:

\begin{axis}[
legend style={fill=white}, % <---- a comma!!!
minor tick num=3
]

Hope this helps someone.

29. Andre on 26 May 2011 at 12:31 pm #

———————————
! TeX capacity exceeded, sorry [input stack size=5000].
\hmode@bgroup ->\leavevmode
\bgroup

And I tryed to use the \usepackage{url} on my .bib and doesn’t worked, the only thing it was getting off all the url’s of my bib file…

Well, any other suggestion is welcomed!

30. Andre on 26 May 2011 at 12:49 pm #

ok, I found other solution…
My mendeley and JabRef was made my bib file for me, then the url on .bib file was like:

url = {wwwwwwwww}

Then after read some posts here I noticed that the way of the url was created by this softwares was wrong, then I changed by this: (removing the = )

url{wwwwwwww}

and also using the package \usepackage{url} worked!!!

Thanks a lot guys!

31. Vik on 24 Oct 2011 at 18:42 pm #

Hi guys!

———————————
! TeX capacity exceeded, sorry [input stack size=5000].

And in my case it was the one first mentioned by Johann (to add at least an empty title to the block):

\begin{block}{}

\end{block}

Thank you very much! I saved a lot of time and nerves on this!!!:-)

32. stefan on 01 Feb 2012 at 9:16 am #

mine was due to the \url tag in my bib file.. i used the wikipedia bib generator to generate a nice formatted bib tag.. but apparently latex threw up because of it.

33. mario on 01 Feb 2012 at 22:23 pm #

MY ERROR WAS IN SOME WAY DIFFERENT FROM THE PREVIOUS

TeX capacity exceeded, sorry [input stack size=1500].\select@language {italian}

SOMEONE HAS IDEAS WHAT TO DO ?

34. rob on 15 Feb 2012 at 16:25 pm #

I had the same error using lyx 2.0. The error occurred after I added the enumitem module to an existing beamer file that already had enumerations in it. Probably a conflict between enumerations.

35. Arjan on 19 Jul 2012 at 18:24 pm #

One more way to get this error is using gb4e (for numbered examples and glosses) and bibtex. Using only gb4e gave me no errors, but after adding \cite references it broke. Adding “\noautomath” right after “\usepackage{gb4e}” fixed this (see gb4e manual).

36. ellia on 03 Oct 2012 at 13:14 pm #

Thank you so much for this post!
Even though my problem was not mentioned in the previous comments, they let me now that the reason can be any random syntax error.

In my case, there is a line in my paper: “…with “+” and “-” polarities”,
typed into TeX as: “…with “+” and “-” polarities”, which produced an error.
However, after typing it in as “…with “+” and “\text{–}” polarities” everything works fine.

The simple “-” version worked fine before, and I’m a beginner TeX user, so I don’t know what might be the case here, but anyway – it works now. I thought I’d share yet another possible error trigger for other googlers to check for.

37. Michael on 25 Nov 2012 at 0:32 am #

deleting all url’s, deleting all non-essential files, emptying the recycle bin, and deleting my bibliography after backing it up on my e-mail has solved the problem for me for now.. gotta love computers..

38. Michael on 25 Nov 2012 at 0:34 am #

the backing up bibliography and deleting it was a solution that worked for another innexplicable problem I had.. (changes in the bibliography not being reflected in the document..)

39. antoine on 06 Feb 2013 at 21:32 pm #

quickly, for the record, mine was with lyx and beamer in math mode

I had to replace the ‘ symbol (prime) in math mode by ^{\prime} and it worked..

40. D on 12 Feb 2013 at 13:21 pm #

One more for the record:

There is some issue with the harvard bibstyle and latex2html (related to html.sty). Uninstalling latex2html from the system worked for me.

Subscribe without commenting

• The contents of this blog are under a Creative Commons License.