I have the following code which prints some images labelled by _{1,3,5...,37}.png. The following code works just fine.

\foreach \x in {1,3,5,7,9,11,13,15,17,19,21,23,25}
    \caption{First Neighbours Distribution}

However, if I extend the \x range, let's say {1,3,5,7,9,11,13,15,17,19,21,23,25,27}, then I get a bunch of errors:

! LaTeX Error: Too many unprocessed floats.

Where's is the error?

  • Something's up with your code: you don't use \x inside the loop. Also, can you make it a complete LaTeX document so that it can be compiled? I.e. start with \documentclass and end with \end{document}. Cheers. May 29, 2014 at 13:55
  • break the loop into 2 loops and flush the unprocessed floats in between the two loops. May 29, 2014 at 13:57
  • Related: tex.stackexchange.com/questions/46512/…
    – egreg
    May 29, 2014 at 14:06
  • As the message says: you have to many floats (figure environments) in a row. If the [h] indicates that you actually don't want them to float: Use minipages + \captionof instead. Why did you put your graphic in an array? May 29, 2014 at 14:07
  • 1
    This doesn't have anything to do with possible limitations of \foreach. The problem is that the images (floats) are being "collected" for typesetting until there is too many of them, perhaps because they're comparatively big in terms of the text block. Could you describe a little more about the actual image sizes? Also, inside the figure environment, just use \centering\includegraphics[..]{...}\caption{..}\label{..}, nothing more.
    – Werner
    May 29, 2014 at 14:07

1 Answer 1


Using [h] makes the float almost impossible to place so makes running out of unprocessed float space almost inevitable. LaTex will have warned about each one and changed them to ht but htp is better.

But here you do not want the tables to float at all.



then use [H] which makes a non-floating table.

  • Thanks, that worked but I have to admit I don't quite understand why it didn't worked and why it works now May 29, 2014 at 14:18
  • 1
    @cacosomoza H makes the table environment into a minipage essentially, it never moves and it is immediately added to the page, so the pending float list that you filled is not used at all. Normally a table goes into a pending list and is added to the main document flow when latex finds a good spot, but h means not top of page, not bottom of page, not on a float page, so it is almost impossible to find a good spot so latex holds them back hoping to find a page that works when none will until you reach the end of document or fill the float queue May 29, 2014 at 14:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .