handyfloss

Because FLOSS is handy, isn’t it?

TeX capacity exceeded error

Posted by isilanes on November 30, 2006

Blog moved to: handyfloss.net

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

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}

About these ads

79 Responses to “TeX capacity exceeded error”

  1. Krisztián said

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

  2. krisztián said

    Oh, forgot to mention it was pdflatex.

  3. Tazabi said

    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 said

    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. 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?

  6. Mikaël said

    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.

  7. isilanes said

    Note: this blog has moved to http://handyfloss.net. You can follow this post at http://handyfloss.net/2006.11/tex-capacity-exceeded-error/

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

  8. Nicolas said

    It appears that the origin of that flag came from an apostrophe inside an equation, such as E’…

    • Erion said

      I have the same problem with the apostrophe. Did you find a solution around it?
      btw, the apostrophe does not represent transpose in my equations so I cannot simply change it to ^T. Thanks!

  9. Mehul Bhat said

    Use of some aspect of Latex Beamer package gives same error. Just reporting it here in case some one else is head-banging the way i did (thanks to the first post here, i tried to introspect at the silly aspects of Beamer).

    —————————————————-

    The foll gives same stack size error:

    \begin{frame}\frametitle{Frame title}
    \begin{block}
    \begin{center}
    \includegraphics[width=0.90\columnwidth]{test.png}
    \end{center}
    \end{block}
    Some text

    Some more
    \end{frame}

    —————————————————-

    The following does not:

    —————————————————-
    \begin{frame}
    \begin{block}{Block title}
    \begin{center}
    \includegraphics[width=0.90\columnwidth]{test.png}
    \end{center}
    \end{block}
    Some text

    Some more
    \end{frame}

    —————————————————-

    i havent investigated about the exact causes..but the doc compiles now :)

    cheers, Mehul

  10. Akash said

    Haha! I was having the same problem for last 1 hr! Good that I googled it! ;)
    Cheers! (And thanks!)

  11. Peter said

    I had the same cpacity-problem and in my case it also zurned out to be an apostroph inside an equation. The funny thing is that comiplation went well hundrets of times until the error suddenly appeared.
    I use TexnicCenter 7.01 and Miktex 2.7.

    cheers

    Peter

  12. Jon said

    Ha,
    had the same problem with the beamer package and the block environment. This is one of the reasons to love Google and the internet for – instead of looking for an error at all kinds of places for hours I just google it and the problem is solved in a blink of an eye ;)

  13. isabel said

    I also had the problem come up from use of apostrophes in equations. But this only happened when useing the package \hangpara without that package the apostrophes are not a problem.

    The problem is, I need apostrophes in my equations, and would like to use the \hangpara package in my document as well, anys suggestions?

    • I just ran into this problem – I am using TeXShop 2.3.6 and the error appeared to initiate when I typed $E’(x)$. When I commented out the \usepackage{hanging}, everything worked fine!

  14. isilanes said

    Sorry, Isabel, but I never used the hanging package. Maybe if you posted some code I could take a look at it, but I can’t assure I’ll be able to help.

    If you want to post more comments on this entry, please note that this blog has moved to http://handyfloss.net. You can follow this post at http://handyfloss.net/2006.11/tex-capacity-exceeded-error/

  15. Oscar said

    My problem was that, using beamer, i had a slide with a \begin{block} command without a finishing {}, which gave problems when using itemize. In other words

    \begin{block}
    \begin{itemize}
    some stuff
    \end{itemize}
    \end{block}

    gave me problems, but

    \begin{block}{}
    \begin{itemize}
    some stuff
    \end{itemize}
    \end{block}

    worked fine….

    • Kmilin said

      Oscar was right! i tried the empty parentheses after block and it worked! fortunately i hadn’t to try other strange stuff (that makes sense because my presentation didn’t have strange stuff neither) by the way, it’s the strangest error in LaTeX i have seen.

    • J@nos said

      Thanks a lot ! I had exactly the same problem while working on a beamer presentation, now it seems to work fine…

    • Anonymous said

      same thing with

      \begin{beamerboxesrounded}

      use

      \begin{beamerboxesrounded}{}

    • Valjean said

      I also had the \block problem, where I did not choose to put a title in the block. After reading this message board, I changed all apostrophes in my equations to ^{T}’s, since mine did represent transposes, but that didn’t work. I eventually realized it was the block problem. I am also in a pinch, so I’m glad that all of you have shared problems. I’m also glad I’m resourceful. I think probably anybody using LaTeX is probably pretty resourceful, honestly :) We’re a bunch of smartypants.

  16. Kait said

    Oscar, your post saved my life (or at least my thesis presentation!)

    I had the exact same problem with the block environment in beamer, but oddly enough I only had to add the extra parentheses on the last block environment I created; all the rest compile fine without them…

  17. Putting a \label command before \changemargin INSTEAD OF after \changemargin led to an error in question.
    1) Keep your error-free versions safe
    2) Translate often while you can – more or less – remember your last modifications.

  18. Jonathan said

    Hello,

    I’m a new user of LaTeX and I’ve got a problem with a creation of a type of float :

    \DeclareNewFloatType{equation}{placement=h,fileext=loe}
    \floatname{equation}{Equation}

    I created a float Equation in order to make a list of the equations :

    \listof{equation}{List of equations}

    It works when I apply that in a new document but it doesn’t worked with the class I use (thloria). Do you know what could be the problem?

    I’ve got the error :
    ! TeX capacity exceeded, sorry [input stack size=5000].

    I have tried to put {} when I begin the float :
    \begin{equation}{}

    \end{equation}

    but it doesn’t work. I think it’s a problem of class but I don’t know how to repair that…

    If somebody can help me. Thanks.

  19. isilanes said

    Jonathan, I think I can not help you much. Have you tried giving the new type a different name? Maybe there is some conflict with definitions inside thloria. Maybe I am being too obvious, but try the following:

    * thloria without your new type
    * your type without thloria
    * your type with thloria
    * your type with thloria but with a different name

    I understant that so far the results are, respectively: works, works, doesn’t work, didn’t try.

    If the answer to the fourth case is that it works, then you’re done. If the first case doesn’t work, then the problem is not within your type, but within thloria. If the fourth case doesn’t work, start worrying.

  20. Jonathan said

    Thank you Isilanes for your quick answer.

    I’ve try with a different name but it doesn’t work too.

    The problem occurs only when I call ‘listof{equation}{List of equations}’. Without it, I can create the floats. I’ve tried to create some floats with extension of lot and lof (for exemple \DeclareNewFloatType{equation}{placement=h,fileext=lof}) and when I call \listoffigures or \listoftables, it works, I’ve got the list I want with the float of this name. But I need \listoffigures and \listoftables and I want to create a third type of list… :(

    I’ve tried \listof{equation}{List of equations} in an another document without thloria and it works…

    I think I can’t solve this problem… :(

    Thank you

  21. isilanes said

    Sorry, Jonathan, but I can not help you. Maybe the maintainer of thloria can.

  22. Rizwan Ahmed said

    Hi,

    I had a similar problem after I used {\subsection{A_2AB}} to indicate that I wanted 2AB as a subscript (I had already installed the script in the preamble to do this. Latex is strange with subscripts/superscripts in text).

    I had to change this subsection heading to another “non-subscript” version and the document printed!

  23. Oscar Miras said

    If someone could find my answer useful, I forgot to complete \block statement in a Beamer document , because I did not want any caption text on it

    Use:

    \begin{block}{}

    Instead of:

    \begin{block}

  24. Hydmeganne said

    Curses!
    I’m starting to understand why the error messages in LaTeX are so bad – there are a thousand things which might go wrong. I was using the Bibliography style agsm in the Harvard package and I got the famous

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

    each time I compiled; even though I tried every solution mentioned above. So I deleted the \usepackage{harvard} and changed \bibliographystyle{agsm} into \bibliographystyle{plain}.
    This solved the problem temporarily. Until I realized that I need the Harvard packages in order to refer to the urls! OMG.

    I give up.

  25. Gabriel said

    This is funny, this code give the error:

    \begin{alertblock}
    \begin{center}
    $\frac{\kappa}{\alpha}<0$
    \end{center}
    \end{alertblock} \pause

    But this does not!!

    \begin{alertblock}

    \begin{center}
    $\frac{\kappa}{\alpha}<0$
    \end{center}

    \end{alertblock} \pause

    I dont really know whats happening here, but for me, this is enough.
    Hope it helps!

    Cheers!

  26. isilanes said

    One would think that putting “Blog moved to:” in big red letters at the top of the post would hint people into going to that URL for submitting comments.

    Dear readers, I moved to handyfloss.net two years ago, and I still this 2006 post at handyfloss.wordpress.com gets more comments than its counterpart at handyfloss.net. I am so happy that I am getting so much feedback. What I am not so happy with is that the most-commented post in my blog is located at an obsolete URL.

    I understand that finding posts within WordPress.com must be easier than to just stumble upon handyfloss.net, but it would be nice if finding this post at handyfloss.wordpress.com would redirect readers to handyfloss.net, and make them comment there.

    So, again: please note that this blog has moved to http://handyfloss.net. You can follow (and comment) this post at http://handyfloss.net/2006.11/tex-capacity-exceeded-error/

  27. It occurred to me when I accidentally tried to \def \ht which is already defined. It also gave me a “Missing number treated as zero” error

  28. Alex said

    Oh thank you!

  29. btw the reason you get so many replies here (I suspect) is that it’s the top Google result for “TeX capacity exceeded, sorry”.

  30. Daniel Cuneo AKA wannabegeek on 4hv.org said

    ahhhh!!!!!!!!!!!!!!!

    I Just did the SAME thing !!!!! hours later……\end{Document}……missing…

    U ROCK !

    wbg

  31. Anonymous said

    I would recommend making sure you use all the packages that you load, as in my case, I had deleted a section that involved a package and did not remove the \usepackage command, and this caused the problem somehow.

  32. Anonymous said

    In my case, not placing the second mandatory argument in \begin{block}{} (beamer) was the guilty guy.

  33. Neeraj said

    For me was caused by forgetting the braces after a being block as below
    \begin{block}
    SomeText
    \end{block}

    The following is the correct
    \begin{block}{}
    SomeText
    \end{block}

  34. samuel said

    i had the same error as neeraj… why god why couldnt beamer warn me of such error?

  35. vins said

    For me \usepackage{setspace} was the bad guy defined in my thesis.sty file

  36. Anonymous said

    For me, the problem was that I was making a “beamer” slide, and I just started a “block” without title! I mean:
    \begin{block}

    \end{block}
    gives me the error, but:
    \begin{block}{whatever, even empty}

    \end{block}
    solves the error!!!

  37. Carlos Gussenhoven said

    Make sure none of your .eps figure files has an underscore in the filename. That would be a sure way of getting the capacity exceeded messsage.

  38. My problem was that I was using “\and” inside \subtitle{blahblah \and blehbleh}!
    O_____O

  39. Anonymous said

    thanks! You SAVED me some hours!!!

  40. mob said

    Thanks, I had the exact same problem, forgot \end{document} and I’ve just spent one hour looking everywhere, from logs to wikibooks…

  41. Anonymous said

    I forgot the title in a block section

    \begin{block}
    ….
    \end{block}

  42. Anonymous said

    I dont get it, I opened a new document copied and pasted the same content and in one i get that mysterious error (and 47 other errors) and in the other i dont. = S

  43. Anonymous said

    we must add a title for each block

  44. Anonymous said

    Thanks for the help! I had the same problem using the beamer package inside a block without the title!

  45. Anonymous said

    I had forgotten a set of {} behind an unnamed \begin{block}

  46. Anonymous said

    Thank you!

  47. Anonymous said

    same output, but other cause: i work on a german document and i had \”a for ä in my caption tag… without this tag everything was fine

  48. Anonymous said

    In my case it was a pair {} missing after \begin{block} …

  49. Anonymous said

    Try just deleting all other files such as .bbl, .out, .aux and so on and recompile. That did it for me (no idea why). Do NOT delete the .tex actual LaTeX document you are working on or the BIB file.

  50. It’s really useful to have all of these examples of problems – helped me a lot in debugging.
    To contribute my own – I have been using the soul package, specifically the \hl command to highlight some text. Yesterday, I was silly enough to highlight a footnote as follows:

    \hl{\footnote{Hello}} rather than \footnote{\hl{hello}}

    Several hours of debugging followed …

  51. Sr. Cv. said

    I just forgot about {} after a macro call. Your post pointed me to better direction then trying to increase stack size to infinity! Thanks to you I solved this in 5 minutes!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
Follow

Get every new post delivered to your Inbox.

%d bloggers like this: