pdflatex hang after large number of figures

Viewed 2995

I have a script that generates a number of figures and puts them in the appendix of a report, e.g.

Appendix
********

.. figure:: images/generated/image_1.png
.. figure:: images/generated/image_2.png
.. figure:: images/generated/image_3.png
... etc

It looks like after a large number (~50) of images, my pdflatex command will hang, and point to one of the graphics in my .tex file around here

...
\begin(figure)[htbp]
\centering
\noindent\sphinxincludegraphics{{image_49}.png}
\end{figure}

\begin(figure)[htbp]
\centering
\noindent\sphinxincludegraphics{{image_50}.png} <--- here
\end{figure}

\begin(figure)[htbp]
\centering
\noindent\sphinxincludegraphics{{image_51}.png}
\end{figure}
...

When pdflatex fails I can't really figure out what to make from the console output, I get a number of these lines which seem to be good news

<image_48.png, id=451, 411.939pt x 327.3831pt>
File: image_48.png Graphic file (type png)
<use image_48.png>
Package pdftex.def Info: image_48.png  used on input line 1251.
(pdftex.def)             Requested size: 411.93797pt x 327.3823pt.

<image_49.png, id=452, 411.939pt x 327.3831pt>
File: image_49.png Graphic file (type png)     
<use image_49.png>
Package pdftex.def Info: image_49.png  used on input line 1257.
(pdftex.def)             Requested size: 411.93797pt x 327.3823pt.

Then after the last successful image (~50) it starts outputting

! Output loop---100 consecutive dead cycles.
\end@float ...loatpenalty <-\@Mii \penalty -\@Miv
                                                  \@tempdima \prevdepth \vbo...
l.1258 \end{figure}

I've concluded that your \output is awry; it never does a
\shipout, so I'm shipping \box255 out myself. Next time
increase \maxdeadcycles if you want me to be more patient!

[9
! Undefined control sequence.
\reserved@a ->\@nil

l.1258 \end{figure}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

If all I do is reduce the number of figures, it will run and produce a pdf without issue. Is there a hard limit to the number of images a section can have? Is there somewhere else I can look in the build log to narrow down why this is happening?

3 Answers

This seemed to be a combination of a couple things.

The first symptom was essentially an error caused by too many unprocessed floats. The fix for this was to add the following to the babel element of latex_elements

\usepackage[maxfloats=256]{morefloats}

The second symptom was complaining about Output loop---100 consecutive dead cycles. so the fix was simply to increase the number of cycles

\maxdeadcycles=1000

After these two adjustments, the pdflatex command will finish successfully now, even with a large number of figures.

I had this problem and the above suggestions did not work. I was however able to get it to run just fine by inserting subsections which may or may not compatible with your objectives. The script generates code as follows which is then input into another code snippet to preview the generated images, ( I'm generating svg plots from c++, converting to png, and previewing essentially raw data for selection into later plots that go into an actual document not just a collection of images )

\subsection{svghappy2.tyrosine.png}
\begin{figure}[htbp]
\testplot{svghappy2_tyrosine.png}
\caption{svghappy2.tyrosine.png}
\end{figure}

\subsection{svghappy2.valine.png}
\begin{figure}[htbp]
\testplot{svghappy2_valine.png}
\caption{svghappy2.valine.png}
\end{figure}

As the problem arises from the compiler having hard time to set all the images. Splitting between them would help. As @mike-marchywka noted sections may do the trick, but so would other things, such as \pagebreak or \FloatBarrier from placeins

Related