General ⇒ Dealing with tons of floats
-
- Posts: 6
- Joined: Fri Apr 04, 2008 10:17 pm
Dealing with tons of floats
I'm putting together a report that contains hundreds of tables and figures that I've dumped into Appendices at the end of the document. One appendix, for example, consists only of tables, another only photos with no text between these tables or figures. As expected I'm running into the "too many unprocessed floats" error. Yep, I can *fix* this with a \clearpage but this is very tedious i.e. compile -> error -> insert \clearpage -> compile -> error etc. Another problem with the \clearpage approach is that it breaks the consistency of float placement - sometimes I get two - other times three tables on a page. The {morefloats} package simply delays the errors and I've had no luck with setting the float parameters floatpagefraction, [htbp], [!p], etc. No luck with the {float} package either - unless I'm missing something. The {endfloat} package was interesting in that it dumps all the floats to the end of the document without complaining but not quite what I'm looking for. Does anyone know of a package (or method) that can handle tons of floats as described. TIA.
NEW: TikZ book now 40% off at Amazon.com for a short time.
Dealing with tons of floats
The best thing would be to avoid all those floats (i.e., converting them to simple text elements). If that is impossible, you can try to increase the number of possible floats, using eTeX and a technique similar to morefloats. The following hack places 1000 floats on 268 pages. It needs several minutes to compile, so you will probably choose not to use it if you have so many floats, but for 200 floats, it's still quite fast.
Code: Select all
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\newcount\ExtraInsertCount
\ExtraInsertCount10000
% no checks, we just hope that there are no allocations starting from 10000
\newcommand*\AllocateExtraFloat{%
\advance\ExtraInsertCount1%
\allocationnumber\ExtraInsertCount
\edef\ExtraFloatCommand{\expandafter\noexpand\csname bx@extra@\number\ExtraInsertCount\endcsname}%
\expandafter\mathchardef\ExtraFloatCommand\allocationnumber
\edef\@freelist{\unexpanded\expandafter{\@freelist\@elt}\expandafter\noexpand\ExtraFloatCommand}%
}
\newcommand*\Repeat[2]{%
\ifnum\numexpr#2>0%
#1%
\expandafter\Repeat\expandafter#1\expandafter{\number\numexpr#2-1\expandafter}%
\fi
}
\newcommand*\AllocateExtraFloats{%
\Repeat\AllocateExtraFloat
}
\newcount\LipsumParagraph
\LipsumParagraph0
\newcommand*\PlaceFloat{%
\begin{figure}%
\global\advance\LipsumParagraph1%
\ifnum\LipsumParagraph>149\global\LipsumParagraph1\fi
\lipsum[\LipsumParagraph]%
\caption{\Roman{figure}}%
\end{figure}%
}
\AllocateExtraFloats{1000}
\maxdeadcycles2000
\makeatother
\begin{document}
\Repeat\PlaceFloat{1000}
\end{document}