LaTeX forum ⇒ GeneralDealing with tons of floats

LaTeX specific issues not fitting into one of the other forums of this category.
Andre Smit
Posts: 6
Joined: Fri Apr 04, 2008 10:17 pm

Dealing with tons of floats

Postby Andre Smit » Tue Nov 11, 2008 3:23 pm

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.

Link:
BBcode:
HTML:
Hide post links
Show post links

phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Postby phi » Tue Nov 11, 2008 8:18 pm

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.
  1. \documentclass{article}
  2.  
  3. \usepackage{lipsum}
  4.  
  5.  
  6. \makeatletter
  7.  
  8. \newcount\ExtraInsertCount
  9. \ExtraInsertCount10000
  10.  
  11. % no checks, we just hope that there are no allocations starting from 10000
  12. \newcommand*\AllocateExtraFloat{%
  13. \advance\ExtraInsertCount1%
  14. \allocationnumber\ExtraInsertCount
  15. \edef\ExtraFloatCommand{\expandafter\noexpand\csname bx@extra@\number\ExtraInsertCount\endcsname}%
  16. \expandafter\mathchardef\ExtraFloatCommand\allocationnumber
  17. \edef\@freelist{\unexpanded\expandafter{\@freelist\@elt}\expandafter\noexpand\ExtraFloatCommand}%
  18. }
  19.  
  20. \newcommand*\Repeat[2]{%
  21. \ifnum\numexpr#2>0%
  22. #1%
  23. \expandafter\Repeat\expandafter#1\expandafter{\number\numexpr#2-1\expandafter}%
  24. \fi
  25. }
  26.  
  27. \newcommand*\AllocateExtraFloats{%
  28. \Repeat\AllocateExtraFloat
  29. }
  30.  
  31. \newcount\LipsumParagraph
  32. \LipsumParagraph0
  33.  
  34. \newcommand*\PlaceFloat{%
  35. \begin{figure}%
  36. \global\advance\LipsumParagraph1%
  37. \ifnum\LipsumParagraph>149\global\LipsumParagraph1\fi
  38. \lipsum[\LipsumParagraph]%
  39. \caption{\Roman{figure}}%
  40. \end{figure}%
  41. }
  42.  
  43. \AllocateExtraFloats{1000}
  44.  
  45. \maxdeadcycles2000
  46.  
  47. \makeatother
  48.  
  49.  
  50. \begin{document}
  51.  
  52. \Repeat\PlaceFloat{1000}
  53.  
  54. \end{document}

Link:
BBcode:
HTML:
Hide post links
Show post links


Return to “General”

Who is online

Users browsing this forum: No registered users and 8 guests