7

Many MWEs include code like:

\usepackage{float}
% etc
\begin{figure}[H]% or \begin{table}[H]
% figure/table code (e.g. \begin{tabular}...)
% etc

which has the effect of placing the float (figure or table or ...) at that exact position in the document no matter how bad it will look with respect to spurious white space. The effect is to turn the float into a non-float but with the option of adding a caption. Often the question is about an undesired position of the float which is what the [H] option often leads to.

Should the [H] option be used at all?

dexteritas
  • 9,161
Peter Wilson
  • 28,066

2 Answers2

14

[H] is often (perhaps usually) misused but it isn't heinous, and the person who originally came up with the syntax is of course extremely honourable.

As egreg commented below the (non)-question, if an image or table is a non-float it shouldn't need a caption so the markup can be simply tabular or \includegraphics with no surrounding float container so no need for [H]

However there is a use case where H can be useful. It is not really [H] for Here it is [H] for Humans are better at choosing float positions. If you are prepared to take full control, use [H] on all your floats and float them by hand by moving the environment in the source, and if necessary re-writing other parts of the page to help make things fit, then for some documents you can surely get better results. Of course there is a very high maintenance cost to this as any edit invalidates all the positioning and you have to check all the page breaks again, but if you have just spent ten years writing a book, spending a week at the end hand tuning float positions isn't necessarily the wrong thing to do.

Thruston
  • 42,268
David Carlisle
  • 757,742
  • It is opinable that a non-floating object doesn't need a caption, see Christian's and my comments to the OP. – CarLaTeX Jan 13 '19 at 21:06
  • @CarLaTeX yes also of course it depends what you mean by non-float if it is typeset away from its point of reference then it needs a caption whether it moved by latex moving it or by the author putting it in that place. If it is only referenced immediately adjacent to the figure then the use of a caption is more questionable but still not necessarily wrong. – David Carlisle Jan 13 '19 at 21:09
  • I can’t disagree with this answer but must groan audibly whenever my students submit reports with big gaps in their pages because they’ve somehow decided that all figures should be [H]. It’s maddening! (Although I don’t blame the honourable author of the package.) – Will Robertson Jan 14 '19 at 20:50
6

The [H] float option turns the float (figure, table, etc.) effectively into a non-float (although it may have a regular caption) making it appear in the final document where it was put in the LaTeX source. This can then result in much extraneous white space (what happens if the [H] float requires 3 inches vertical space but there is only 2 inches available on the page?).

If you really want a float to be a non-float then don't call it as a float e.g.,

%%% begin{table}% don't use this!
\begin{tabular}
% tabular code

If you need a caption then you can use the caption package. For example

\usepackage{caption}
% etc
\begin{center} % if you want the tabular centered
\begin{tabular}
% etc
\captionof{table}[LoT entry]{Nonfloating table caption}
\label{tab:X}
\end{tabular}
\end{center}
% etc

LaTeX tries very hard to position floats in a pleasing way via the optional float parameters [htbp]. If you think that you can do better then good luck to you.

A comprehensive discussion about floats and what you can do with them is in the 43 page Chapter 6 of Frank Mittelbach and Michael Goossens The LaTeX Companion, Second Edition, Addison Wesley, 2004 (I understand that a Third Edition may be in the offing at some future point). The chapter includes details of how you can adjust the allowable spaces for top (t), bottom (b) and here (h) floats.

The memoir manual (>texdoc memoir) has a Chapter Floats and captions that contains similar information. The Not so Short Introduction to LaTeX2e (> texdoc lshort) also has useful information on the topic.

Following from jfbu's comment I should have remembered that Frank Mittelbach wrote a comprehensive article How to influence the position of float environments like figure and table in LaTeX? It can be accessed, and printed from, [TUGboat, the journal of the TeX User Group]{https://tug.org/TUGboat/tb35-3/tb111mitt-float.pdf}

Peter Wilson
  • 28,066
  • 1
    perhaps worth mentioning https://tex.stackexchange.com/questions/39017/how-to-influence-the-position-of-float-environments-like-figure-and-table-in-lat/39020#39020 in this context... –  Jan 13 '19 at 22:16