5.7 Floats

Some typographic elements, such as figures and tables, cannot be broken across pages. They must be typeset outside of the normal flow of text, for instance floating to the top of a later page.

LaTeX can have a number of different classes of floating material. The default is the two classes, figure (see figure) and table (see table), but you can create a new class with the package float.

Within any one float class LaTeX always respects the order, so that the first figure in a document source must be typeset before the second figure. However, LaTeX may mix the classes, so it can happen that while the first table appears in the source before the first figure, it appears in the output after it.

The placement of floats is subject to parameters, given below, that limit the number of floats that can appear at the top of a page, and the bottom, etc. If so many floats are queued that the limits prevent them all from fitting on a page then LaTeX places what it can and defers the rest to the next page. In this way, floats may end up being typeset far from their place in the source. In particular, a float that is big may migrate to the end of the document. In which event, because all floats in a class must appear in sequential order, every following float in that class also appears at the end.

In addition to changing the parameters, for each float you can tweak where the float placement algorithm tries to place it by using its placement argument. The possible values are a sequence of the letters below. The default for both figure and table, in both article and book classes, is tbp.

t

(Top)—at the top of a text page.

b

(Bottom)—at the bottom of a text page. (However, b is not allowed for full-width floats (figure*) with double-column output. To ameliorate this, use the stfloats or dblfloatfix package, but see the discussion at caveats in the FAQ: https://www.texfaq.org/FAQ-2colfloat.

h

(Here)—at the position in the text where the figure environment appears. However, h is not allowed by itself; t is automatically added.

To absolutely force a float to appear “here”, you can \usepackage{float} and use the H specifier which it defines. For further discussion, see the FAQ entry at https://www.texfaq.org/FAQ-figurehere.

p

(Page of floats)—on a separate float page, which is a page containing no text, only floats.

!

Used in addition to one of the above; for this float only, LaTeX ignores the restrictions on both the number of floats that can appear and the relative amounts of float and non-float text on the page. The ! specifier does not mean “put the float here”; see above.

Note: the order in which letters appear in the placement argument does not change the order in which LaTeX tries to place the float; for instance, btp has the same effect as tbp. All that placement does is that if a letter is not present then the algorithm does not try that location. Thus, LaTeX’s default of tbp is to try every location except placing the float where it occurs in the source.

To prevent LaTeX from moving floats to the end of the document or a chapter you can use a \clearpage command to start a new page and insert all pending floats. If a pagebreak is undesirable then you can use the afterpage package and issue \afterpage{\clearpage}. This will wait until the current page is finished and then flush all outstanding floats.

LaTeX can typeset a float before where it appears in the source (although on the same output page) if there is a t specifier in the placement parameter. If this is not desired, and deleting the t is not acceptable as it keeps the float from being placed at the top of the next page, then you can prevent it by either using the flafter package or using the command \suppressfloats[t], which causes floats for the top position on this page to moved to the next page.

Parameters relating to fractions of pages occupied by float and non-float text (change them with \renewcommand{parameter}{decimal between 0 and 1}):

\bottomfraction

The maximum fraction of the page allowed to be occupied by floats at the bottom; default ‘.3’.

\floatpagefraction

The minimum fraction of a float page that must be occupied by floats; default ‘.5’.

\textfraction

Minimum fraction of a page that must be text; if floats take up too much space to preserve this much text, floats will be moved to a different page. The default is ‘.2’.

\topfraction

Maximum fraction at the top of a page that may be occupied before floats; default ‘.7’.

Parameters relating to vertical space around floats (change them with a command of the form \setlength{parameter}{length expression}):

\floatsep

Space between floats at the top or bottom of a page; default ‘12pt plus2pt minus2pt’.

\intextsep

Space above and below a float in the middle of the main text; default ‘12pt plus2pt minus2pt’ for 10 point and 11 point documents, and ‘14pt plus4pt minus4pt’ for 12 point documents.

\textfloatsep

Space between the last (first) float at the top (bottom) of a page; default ‘20pt plus2pt minus4pt’.

Counters relating to the number of floats on a page (change them with a command of the form \setcounter{ctrname}{natural number}):

bottomnumber

Maximum number of floats that can appear at the bottom of a text page; default 1.

dbltopnumber

Maximum number of full-sized floats that can appear at the top of a two-column page; default 2.

topnumber

Maximum number of floats that can appear at the top of a text page; default 2.

totalnumber

Maximum number of floats that can appear on a text page; default 3.

The principal TeX FAQ entry relating to floats https://www.texfaq.org/FAQ-floats contains suggestions for relaxing LaTeX’s default parameters to reduce the problem of floats being pushed to the end. A full explanation of the float placement algorithm is in Frank Mittelbach’s article “How to influence the position of float environments like figure and table in LaTeX?” (https://www.latex-project.org/publications/2014-FMi-TUB-tb111mitt-float-placement.pdf).


Unofficial LaTeX2e reference manual