I have seen a number of articles, questions, and comments over the years that recommend when using floats such as tables, figures with captions, and so on, that the best thing to do is to let LaTeX decide where to place them. This is opposed to using something like say the float package where the user may add tags explicitly forcing where to place the float in question.

Fine. LaTeX, mostly knows what it is doing, so I trust it. Where do I place the code for the floats and figures and tables with respect to the main text code? Does this affect compilation?

An additional but related question, given the answer of a user below, where is it then appropriate to place a figure with respect to the reference to it in the main body of text. For example I write a paragraph in which I reference my figure, is it better to have the figure before the paragraph, after or even break the paragraph.

I realise of course this is highly dependant on how one writes, but I am after bets practice guidelines.

For example if I reference a figure with \ref{MyFigureA}, will LaTeX try and place the figure as close to the reference as possible?

What is the best practice of code placement of floats (figures, tables and the like) with regard to the main text in which it is referenced?


2 Answers 2


This is probably no more than an expanded comment, but it does benefit from experience in juggling floats in TUGboat for (my idea of) best effect. Details of the rules of float placement are given in this question: How to influence the position of float environments like figure and table in LaTeX?, as already suggested in a comment; in case what is written here isn't clear, refer to that, or to the TUGboat article cited therein. This discussion is mostly applicable to single-column pages; full-width floats on multi-column pages have special requirements and depend on whether the columns are defined by a document-class option or the multicol package.

When writing the initial draft, place the floats close to their references. A good starting location is just after the reference. It's best to input the instructions for a float while in vertical mode, i.e., at a paragraph break, with a blank line before and another one after the float. If placement is important for a particular figure, add options as appropriate; [tbp] is the default, and if no explicit options are given, that is how LaTeX will apply them. (If a float is large, and p is omitted from options that are specified, this will result in the large float and all following floats of the same class being deferred until the end of the document.)

Sometimes it's essential that a figure or table appear exactly in a particular place. If this inclusion is small, and there is no question that it won't fit where it is wanted, you might try inserting it in-line using \captionof to provide the caption (requires the caption package). \includegraphics can be inserted as an unnumbered display within \[ ... \], to provide some vertical space above and below. (I don't remember whether \captionof will work within the display, but many small graphics don't require a caption.) \begin{center} ... \end{center} is the equivalent of a display for a table regarding surrounding space.

After the text is essentially complete, compile the document and review the location of the floats. If a float appears on the page following its reference, but there's room on the reference page after the reference (perhaps the reference is at the beginning of a very long paragraph), that float can be moved from after to before the paragraph, with the option [t] or [b] as most appropriate. (Notice that I don't recommend the use of [h] or [H].) If it's really important to squeeze a float onto a page and the available space is only a line short, it may be possible to gain a line with \enlargethispage(1\baselineskip} on the current page or (often preferable) a page or two earlier.

Remember that every adjustment may affect anything that comes later. For that reason, make adjustments one at a time, starting from the beginning; if the document is a book, separate chapters can be be considered independent for this purpose.

Edit: I have to eat my words regarding the use of [h]. I have just received a submission from a regular TUGboat columnist who makes good use of this option. A figure is placed in the middle of a column, just below where it is mentioned but without a formal reference, and indeed between paragraphs. In fact, this is the only way to ensure that a floating object can be placed explicitly in the middle of a page or column. But, again, this is a declaration that is best left for final fine tuning.

  • 1
    Just a minor nitpick about “[htbp] is the default”: this default depends on what document class is in use, and LaTeX's standard classes use [tbp] as default Mar 19, 2020 at 18:54
  • 1
    @PhelypeOleinik -- Urk! Of course you're correct; fixed. Thank you! Mar 19, 2020 at 19:01
  • @barbarabeeton Thank you very much for this wonderfully detailed answer!
    – user27119
    Mar 20, 2020 at 2:13
  • @Q.P. -- Good luck arranging your floats. (If these suggestions work, and you like the result, you might consider accepting the answer by checking it.) Mar 20, 2020 at 3:31
  • @barbarabeeton I absolutely will. I tend to keep my questions open for a few days to attract contributions as much as possible -- hopefully this question will be handy for other less experience LaTeX users!
    – user27119
    Mar 20, 2020 at 13:41

No, the float, well, floats. You tell where you want it with [htbp] (prefer here, top of a page, bottom of a page, extra page; it doesn't force placement). Most of the time, LaTeX does a good job here. You have some control over what you want by placing the float next to the reference in the code (don't worry, it won't e.g. interrupt a paragraph unless there is no better placement). Packages like float allow to force placement, but I'd use that as a last resort once the rest of the document is stable. Forcing a float here might look very ugly if the "here" changes because you deleted a paragraph...

  • Okay, then I obviously misunderstood something. Where would you say the bets place to put figures, before or after the paragraph in which it is referenced, or even within?
    – user27119
    Mar 19, 2020 at 0:56
  • 2
    @Q.P. After. If you put before you might see figures before they are referenced (which is not always desirable), and in the middle is wrong. Mar 19, 2020 at 1:03
  • 1
    @PhelypeOleinik This makes a lot of sense, thanks for the advice!
    – user27119
    Mar 19, 2020 at 1:15
  • @Q.P., in the source, if you move the float around, it affects where it shows up in print (somewhat). So if you'd like the float near it's reference, place it near it's reference in the source.
    – vonbrand
    Mar 19, 2020 at 1:15
  • @vonbrand what I meant was where specifically within the source. And I appreciate this question has no clear boundary conditions, but what does "near" usually mean? After the paragraph of the first reference for example?
    – user27119
    Mar 19, 2020 at 1:17

You must log in to answer this question.

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