6

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?

  • 4
    Sorry, but TeX-StackExchange is a Q&A site. As it stands, there is no question here, which means this will likely be closed. – Joseph Wright Jan 12 at 21:40
  • 6
    You could make it a question if you ask e.g. "What are the alternatives to [H]?", and then you could add your own answer. There are several examples of such questions with self-answers. – user121799 Jan 12 at 22:01
  • 5
    In my opinion, if something has to be “right there”, then it doesn't need a caption. – egreg Jan 12 at 22:16
  • 4
    @egreg: I disagree. For writing lengthy books or science articles it may be appropiate to have floating figures, but outside of the ivory tower of academia, in 'lower class' teaching, where short work sheets are much more useful and you can not let images etc. float away. They must stay exactly at their position and they do need a caption! – user31729 Jan 12 at 22:34
  • 2
    @ChristianHupfer And I would add that a "right here" table could be referenced later in the document, hence the caption is needed! – CarLaTeX Jan 13 at 8:16
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.

  • 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 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 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 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}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.