[Tex/LaTex] Avoid showing all figures at the end of the text by setting \topfraction to a value larger than 1.0

floats

Jakob's LaTeX tricks read:

Be careful not to make \floatpagefraction larger than \topfraction, then you risk to produce a figure that can neither go on the top of a text page, nor on a page by itself. If that happens, the figure and all later figures will be postponed until next time a \clearpage is executed (typically at the end of a chapter or the end of the document). This will also happen if a figure is too large to fit on a page.

I had once the problem that after a certain figure all following figures were shown at the end of the document. My expectation is that I could avoid this by setting \topfraction to a large value. Is this a safe setting, or is this likely to break something? (I don't care if the float goes beyond page margins in this case.)

Best Answer

The statements made in those tips are only partially correct and in my opinion should not be taken too seriously.

Correct is:

  • if a figure is larger than a full page then LaTeX changes the size of the figure to be \textheight (or rather make it appear so to the algorithm, the actual size is not changed) and gives a warning about this. So it will not prevent the float from fitting on a float page.

  • if floatpagefraction is larger than \topfraction then indeed a single float that has size between the two values can't be placed neither in the top area nor will it fit onto a float page without another float coming along (or a \clearpage). So in documents that have very few floats it might pose an issue. On the other hand, for many document scenarios such a setting can be quite sensible to avoid half empty float pages, especially in cases where the typical float sizes are small.

  • setting \topfraction to something larger than 1 (as suggested in the title of the question) does not make sense. In fact it doesn't even make sense to put it larger than (1-\textpagefraction). Otherwise you have inconsistent settings and that may potentially result in strange reactions from the algorithm.

A general comment here is that there aren't settings that can work well in all scenarios. The default settings used in the standard LaTeX classes (article, report, book) is trying to get the floats out reasonably fast at the cost of allowing half-empty float pages. For good layout that is rather loose, so adjusting it is often called for. In a final document one then may have to overwrite those setting on individual floats by using !-notation so that a float can move into a certain area even if the settings normally would prevent it.

As David said: a more extensive explanation on how the algorithm works is given in How to influence the position of float environments like figure and table in LaTeX?

Related Question