6

When should I use a Float for my figures, vs when should I just have them inline?

What in particular does floating them get me? I am assuming it is something to do with ensuring a balance of figures vs text on a page? Eg avoiding 1 line of text with a figure that might be glanced over.

I know for journals with style guides requiring all figures to be at the top of the page, floating is useful then, but is it more generally the preferred way to place a figure?

3
  • 2
    It also avoids (helps avoid) large amounts of white space. If you put a figure inline and there's no room on that page, you'll get a page break and the rest of the page will be empty - even if it only has two lines of text on it. You also need to manage appropriate vertical spacing around the figure appropriately if you put it inline. Otherwise, it will butt right up against the text above and below. And if you want it centred, you need an environment to limit the scope of that, of course. And if you want a caption, you need \captionof. But mostly, it is about getting good page breaks.
    – cfr
    Jul 20, 2017 at 2:39
  • @cfr sounds like an answer. Thanks. I think what it didn't fully comprehend/think through, was the "It will leave a gap if it doesn't fit in." bit. Jul 20, 2017 at 2:41

3 Answers 3

6

The main advantage of floats is indeed avoid large empty spaces at the end of the page because a large image or table does not fit. And when it does, probably left some orphan/widow lines (always unpleasant but after/before an image are really awful).

But is not only that: LaTeX have default rules that you can change or ignore) about the maximum number of floats per page, at top, (at bottom, the ratio text/floats area, etc. For instance, this rules can allow a page only with text and another only with floats, instead of two page with scattered figures and small chunks of texts.

In documents with a reasonable proportions of text and images/tables, with minimal care about the place of floats in source code and the float options, typically these rules obtain a nice balanced layout.

Must-read: How to influence the position of float environments like figure and table in LaTeX?

On the other hand, floats allow numbered captions that can be easily \labeled, \referenced and listed (\listoffigures and \listfoftables). Some packages (caption, captdef, capt-of) allow captions without floats, but you should have a good reason for use this approach, because without floats you could face problems as a page break between the image and the caption, that never happen using a float.

5

If the figure is small enough then you can just insert it in the text exactly where you need it, but what if it falls on e.g. a page break? Are you ok with a float running off the page or a bunch of white space at the bottom of the page? The point of floats is that if they don't fit where you put them then they can appear at e.g. the top of the next page and the rest of the page can be filled out with text.

A similar argument applies if you'd only have one or two lines below the figure or table before the page break: it's ugly and not pleasant to read.

3

Better appearance of the document. In most cases, a figure put as a float will have its location determined depending on certain criteria defined by float package. Such advantage is mostly noticeable when you have a lot of large tables, figures, and equations in close proximity to each other - a situation in which a lot of empty spaces in pages can show up in the output. One other disturbing case is when you have a large figure with only two or three lines under it. For those kinds of figures, it is almost always better to have them alone in a page.

One of the important terms in floating is "float page" which stands for a page that are reserved for floats. These kinds of pages are automatically generated depending on the contents of your documents and some other options that you can fine-tune in your preamble to get the best result for the type of content and the document class you have. These options are:

\renewcommand{\floatpagefraction}{0.5}: minimum fraction of float page that must be occupied by floats, therefore not leaving blank space (default: 0.5)

\renewcommand{\dblfloatpagefraction}{0.5}: minimum fraction of double column float on two column page that must be occupied by floats, therefore not leaving blank space (default: 0.5). Note that increasing this value too much makes it difficult to produce float pages in the first place.

\renewcommand{\textfraction}{0.2}: minimum fraction of normal (nonfloat) page that must be occupied by text (default: 0.2)

\renewcommand{\topfraction}{0.9}: maximum fraction of the top of a page that can be occupied by floats (default: 0.7)

\renewcommand{\dbltopfraction}{0.5}: maximum fraction of the top of double-column page that can be occupied by floats (default: 0.7)

\renewcommand{\bottomfraction}{0.8}: maximum fraction of the bottom of a page that can be occupied by floats (default: 0.3). Note that there is no such command as \dblbottomfraction

You still can force the figure to be in certain place like in using H, but a word of warning: this may sometimes lead to erroneous results where the figure does not appear in the first place!

Another important feature of floating is that you do not only have floated figures, but floated figures and floated tables, which gives a second degree of flexibility in enhancing the document appearance, i.e., it could be better to put figures and tables in float pages rather than only figures.

Some people argue that having the text wrapping around a figure is more visually pleasing, but that depends on the discipline and the kind of document. For instance, in applied sciences and engineering theses and publications, this is not the case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .