TeX capacity exceeded error
November 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}

Share:
  • Digg
  • Meneame
  • Reddit
  • del.icio.us
  • Technorati
  • Slashdot
  • BarraPunto
Tags: , ,

Related posts

20 Comments »

20 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:

    I had the same error:
    ! 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?

    Then, self-answered with:

    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.

    My answer:

    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.

    Smacking head against table.

    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 #

    To add to the list:

    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 #

    Thanks for your input, kok!

  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}

Trackback URI | Comments RSS

Leave a Reply

Subscribe without commenting

« | »