# handyfloss

## 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}

1. ### Krisztiánsaid

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

2. ### krisztiánsaid

Oh, forgot to mention it was pdflatex.

3. ### Tazabisaid

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. ### Engineersaid

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.

• ### Anonymoussaid

Thanks, this tip solve my 2 days problems!!!

• ### Runesaid

Solved my problem too. I have a deadline this evening, so it was really important to me. Annoying and weird problem, since the url-field is included in my reference-sofware(Jab-ref) and in the entries I downloaded from jstor.org.

• ### Chrissaid

\url{} and the bibtex field url = {} are two different things. There can’t be a \url{} verb in an url = {} field, although it can be in other bibtex fields like howpublished = {} without any problems.

• ### Milo Simpatica (@MiloSimpatica)said

Thanks! It really made my day.

5. ### Mikaëlsaid

! 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ëlsaid

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. ### isilanessaid

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. ### Nicolassaid

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

• ### Erionsaid

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 Bhatsaid

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

• ### Mishozasaid

Yes,

\begin{block} … \end{block}
causes the error by beamer, but

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

Misho

• ### Enthusiastic Studentsaid

I had a similar problem with \caption and \gls

This gives an error:

\begin{figure}[htb]

\caption{Some text \gls{SEM}. Some text}
\end{figure}

This does not

\begin{figure}[htb]

\caption[Some text SEM.]{Some text \gls{SEM}. Some text}
\end{figure}

• ### GreenPatriotsaid

Thanks, man! That was exactly my problem. I don’t know that I would have found it…

• ### Gabriel Matthewssaid

This is the second time I got stung by this one. Thanks.

10. ### Akashsaid

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

11. ### Petersaid

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. ### Jonsaid

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. ### isabelsaid

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?

• ### Joshua Sasmorsaid

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. ### isilanessaid

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. ### Oscarsaid

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

• ### Kmilinsaid

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@nossaid

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

• ### Anonymoussaid

same thing with

\begin{beamerboxesrounded}

use

\begin{beamerboxesrounded}{}

• ### Valjeansaid

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. ### Kaitsaid

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. ### István Jánosisaid

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. ### Jonathansaid

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 :
{}

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. ### isilanessaid

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 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. ### Jonathansaid

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. ### isilanessaid

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

22. ### Rizwan Ahmedsaid

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 Mirassaid

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}{}

\begin{block}

24. ### Hydmegannesaid

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. ### Gabrielsaid

This is funny, this code give the error:

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

But this does not!!

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

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

Cheers!

26. ### isilanessaid

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. ### contributorsaid

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. ### Alexsaid

Oh thank you!

29. ### Nathaniel Virgosaid

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

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

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

U ROCK !

wbg

31. ### Anonymoussaid

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. ### Anonymoussaid

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

33. ### Neerajsaid

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. ### samuelsaid

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

35. ### vinssaid

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

36. ### Anonymoussaid

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 Gussenhovensaid

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. ### asdasdffasdVito Corleonesaid

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

39. ### Anonymoussaid

thanks! You SAVED me some hours!!!

40. ### mobsaid

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

41. ### Anonymoussaid

I forgot the title in a block section

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

42. ### Anonymoussaid

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. ### Anonymoussaid

we must add a title for each block

44. ### Anonymoussaid

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

45. ### Anonymoussaid

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

Thank you!

47. ### Anonymoussaid

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. ### Anonymoussaid

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

49. ### Anonymoussaid

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. ### Stefan Rennick-Egglestonesaid

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 …