42

Every now and then a question/answer with a float environment with option H appears, and every time someone points out that this option should not be used.

However, I haven't found a specific post about this topic.

Therefore, once and for all, can someone clearly explain:

  1. why H should not be used
  2. what are all the possible alternatives (htbp, no float at all, etc.).

I know there is How to influence the position of float environments like figure and table in LaTeX?, but it's too broad and detailed, this question is more focused upon the H option, and I'm searching for a practical answer for beginners.

\documentclass{article}
\usepackage{mwe}
\usepackage{graphicx}
\usepackage{float}
\usepackage{caption}

\begin{document}
    \blindtext
    \begin{table}[H]
        \centering
        \caption{A Table}
        \begin{tabular}{ccc}
            A & B & C \\
            1 & 2 & 3 \\
        \end{tabular}
    \end{table}
    \blindtext
    \begin{figure}[H]
        \centering
        \includegraphics{example-image-a}
        \caption{A Figure}
    \end{figure}
    \blindtext
\end{document}
  • 7
    The H option actually disables the floating – Steven B. Segletes May 19 '17 at 18:58
  • 1
    @StevenB.Segletes I know it (see the first words of this answer of mine: tex.stackexchange.com/a/367156/101651), I'd like to have an expert answer about the topic that can be linked every time one have to explain it to a new user. – CarLaTeX May 19 '17 at 19:05
  • 2
    The 'H' option comes from the float package, which hasn't been updated since 2001 and has issues. – Martin Schröder May 19 '17 at 23:17
  • I think, a better question would be: When/Where/Under which circumstances should I allow figures/tables to float and when/where not? German TeXwelt has such a question: texwelt.de/wissen/fragen/3427/…, but only one short answer. – Schweinebacke May 20 '17 at 14:47
  • 2
    My opinion is that, in some limited situations, a “float” with an [H] position specifier can be acceptable, and could even be the best solution; but of course, what you should absolutely avoid is to use the h position specifier by itself. – GuM May 20 '17 at 16:47
8

This a more conceptual than technical answer to explain why not, that need the context of previous questions:

Why the captions and pages are almost always numbered?

Well, there are two possible answers. Because ...

1) The stupid habit of numbering everything for no reason.

2) This help to the reader when you write references as "see figure 3 on page 5", for instance. Hoping we are rationals, let choose the second, but ...

Why these text references to numbered captions help to the reader?

Because often the figures and tables are far away from their context, that is, when some passage make this figure or table relevant.

Then, why not put the figures and tables exactly when is relevant, in a ""see next figure:" style, with the float with [H] just in the place of the text reference?

I agree completely with Ulrike that referencing plots in this way, then use [H] have sense, and there are texts and texts. but IMHO at least in formal texts (thesis, scientific journals, etc.) this way should be avoided by several reasons:

1) Because always disrupt the narrative.

Specially if there are a caption in the middle of text. Any good essay could have tables and figures supporting the meaning of the text with additional information, but the text alone should be fully understandable without this supplement. It should be the reader who will have to decide if he needs stop the lecture in this moment to scrutinize a graphic to collect more information about you have wrote, (or worse, clarify what are you explaining) or before read the whole article, or after. At least in scientific journals, the philosophy behind is the same that prescribing the use of abstracts, keywords and self-explicative captions: help to the reader. Options t,b and p are always better in this sense.

2) Because very often is not possible stuck tables and figures to relevant text.

One table could be relevant for several passages of different pages. On the other hand, only one passage could be enough explanation for several tables and figures that must be in different pages. Obviously the solution is not make duplicates of a table each time that worth mention it, or make introductory paragraphs for each figure, but make cross-references.

The other two have been pointed by David but I want insist on it:

3) Because can disrupt also the layout.

This is most important technical disadvantage IMHO. If some non floating box does not fit at the end of the page, this imply a premature page break leaving an huge, ugly and baffling space ("What next figure? there are nothing below" or "Why there are no more text? It is the end of the section?", etc. ). A float with [!ht] probably will go away from their context nearly the same but without ruin the previous page layout. If you are unsure if the float will fit or not [!ht]

4) Because forcing floats positions probably can cause troubles in another floats.

Typical questions "why my float go to the end of the document?" are caused by the obsession of control float positions. As more flexibility you left, more near will be the floats of the original surrounding text and better balance between amount of text and floats per page without having to move manually the float positions.

  • 2
    This is pretty much against a picture is worth thousand words mantra. Sometimes there is nothing clearer than a picture and a paragraph attached to it. This sounds like justifying TeX's stupid shortcomings (optimize per page being one) that were valid in 1980s but not in 2017. – percusse Jun 4 '17 at 20:28
  • I've accepted yours because it is the closest to what I had in mind and sum up David's and Ulrike's ones. – CarLaTeX Jun 4 '17 at 20:29
  • @percusee I strongly disagree that well placed floats with good cross-references are against the value of the pictures. I am not justifying anything except what anyone can still see in 2017 in most journals indexed in JCR or scientific books, with or without LaTeX. This argumentum ad populum have any logic grounds behind it? I think so. I understand that this is not applicable to other texts like an art magazine or cookbook , but I suspect that LaTeX users are greatly biased to academic texts. – Fran Jun 4 '17 at 21:53
  • @Fran you pinged percusee instead of percusse. I agree with you. – CarLaTeX Jun 6 '17 at 2:51
  • 1
    What I mean is that TeX had not been this archaic with its optimization scheme (mainly shipout), we wouldn't have this problem and H would work more or less the same way users would wanted it. But now it is just blind and the job that it does is only perfect per page not section wise. Sometimes you must have the picture at the same page. You cannot argue that statistically it shouldn't. – percusse Jun 6 '17 at 17:28
43

[H] makes the figure not float so

\begin[figure}[H]
...
\caption{..}
\end{figure}

is (with just minor edge case and spacing differences) the same as

\begin{minipage}{\columnwidth}
...
\captionof{figure}{...}
\end{minipage}

The choice of either of the above is just a matter of personal preference. Either is fine.

So the choice isn't really the H option it is float or not float.

A common question after using a non-float is why is there ugly white space. The easy (but not that helpful) answer to that is that the reason latex moves floats is to avoid bad white space at page breaks so by using a non-float then by design you are choosing bad spacing rather than accept floating figures.

That is half-true but the other aspect is that there are limits on latex's ability to find good float positions and for some documents an optimal positioning of the floats can only currently be achieved by positioning the figures by hand. This is of course a fragile process, any edit to the document might mean that the position of figures has to be manually changed to fit the new page breaking, however if you have spent three years writing a thesis, spending a week manually positioning the figures is not necessarily a wrong thing to do, however if you can tune the automatic float placement to get an acceptable layout, that is probably a better option in most cases.

  • 3
    On a side note for large documents: Using something like a "float barrrier" (forgot which package it was) helps a lot when manual placement is needed, as it can confine figures to Sections/Chapters which makes a mix of automatic and manual placement possible. Generally LaTeX is bad when one has to arrange mangy figures and little text and works very well when there is more text with comparatively fewer figures. – DetlevCM May 21 '17 at 11:30
  • 2
    The \FloatBarrier macro is from the placins package. Note the capitals in the macro name. Indeed it is a good solution which both preserves a decent layout and prevents that floats are placed in a totally unrelated part of the document. – jlinkels May 24 '17 at 12:22
27

The option H disables floating (but allows captions) so the question can be reworded to "Why should I let figures and tables float?".

A lot of people have difficulties to adjust to the concept of floating. They write "as can be seen in the following tabular .." and so don't like it if the tabular floats away. Also it can be quite painful to have to go constantly to another page to check the content of a table or figure referenced in the text. So imho the wish to avoid floating is quite understandable.

On the other side: tables (and figures) are often referenced in various parts of a text, so there is often no natural position for the table anyway. Tables in the middle of the text can interrupt and disturb the reading. Large (non-floating) objects can make it difficult to avoid pages with lots of white spaces -- something most people don't like either.

I wouldn't say that one shouldn't use H -- I have seen texts, where is was the best option: e.g. lots of short paragraphs which described a specific plot. But one should carefully weight the pros and cons and not forget technical details like the numbering order.

Addition

The option H can be very useful while drafting or adjusting a document when set as default (with \renewcommand*{\fps@figure}{H}. One can then see where the floats are (more or less) meant to be and better judge how it affects the layout when they are not allowed to float.

  • I personally change my desire for floats based on the structure of the text. If the figures/tables are bulky or not needed to be together with the main text, let them float. If they are small tables to list a few numbers just explained in text or a small figure visualising a thing, it feels a bit wrong to have them get moved a page or two away from their origin. As you said, some people aren't used to floats. I handed in a thesis where the corrector got confused by the floats, he commented on all of them. So I strive to use floats only when it is really the best solution. – lblb May 19 '17 at 23:05
13
+100

Ok, I will try answering this.


Since it will be long, here a TL;DR:

  1. H is usually wrong because it's basically the same as not using a floating environment (so why use one), and because does not give a chance to LaTeX to achieve a good (calculated) page break.

  2. The default alternative is tbp ie \begin{table}[tbp] is the same as \begin{table}. tbp means that the table is placed whichever LaTeX considers best among the top of the page, the bottom of the page and on a page composed only of floats. This is usually best

  3. One could add also the h (to tbp) to make LaTeX consider to place the float exactly where it's declared (if feasible and with good results) sometimes it's useful. Eg. one could say \begin{figure}[htbp]

  4. One can also reduce the options, with the caveat that LaTeX could possibly not find a good placement (and send all the floats to the end). This is nevertheless sometimes good for fine tuning, eg begin{table}[tb]. The less the alternatives, the riskier (in terms of page composition) the pagebreaking is.


Now with the answer:

Basically the TeX related systems are good in make typographic choices, and especially they are usually better in those than the average beginner.

The choices regard paging, paragraph making and float positioning; they're all intertwined. LaTeX may not be the best at page breaking, which can require some manual adjusting, but the result is, in my opinion, pretty decent and way better than what a beginner with no typographic background can achieve (I remark that this is my opinion).

Nevertheless, one has to understand that the float position can be influenced by many things (e.g. references to it, how much of the page it occupies) and it is considered more elegant and less obtrusive to have a figure or table at the top or bottom of the page or on a page of its own. In fact it does not disrupt the "reading flow" and makes the text uniform. Using floating environments usually gives both the text and the floats the space they deserve to be enhanced without reducing the space of the other one. A table in the middle of the text or something like that tends to disturb the "natural greyness" of the text, for example, which some typographers (e.g. Jan Tschichold) consider the most important thing about the text.

So usually it's best to give the float some space and keep it separate, as an easy-to-use reference (if one wants to look at it - nothing is mandatory), but an unobtrusive one.

LaTeX tries and places the floats in a way that give the "best" composition (it has a concept of badness in making pages, and tries to make it the least possible). Sometimes many runs of LaTeX are necessary to "stabilize" the positioning of the floats.

The H option never gives LaTeX a chance to determine the best badness possible, but forces it to put the float immediately where it's declared. That is almost always wrong, because no effort is made to make the pages better.

The default option is tbp which is "try at the top, or at the bottom or on another page". It gives the best flexibility and usually it's the best choice. Sometimes one can add the h letter to try and position the float where it's declared, but what I stated above still applies, and it is usually not a great choice, although sometimes it allows LaTeX to make a good paging. Reducing the alternatives can force LaTeX to put the figures at the end of the chapter/article, due to lack of places where to put them.

I feel almost always the best choice is the default one: any adjustment should help LaTeX achieve a better composition and pagebreaking, and not force LaTeX to follow our arbitrary demands. Also, I feel that this reduces the amount of manual adjusting needed to fine tune the document and overcome the problems in LaTeX pagination.

  • @Schweinebacke thanks, I edited it and made my remarks about it. – Moriambar May 19 '17 at 19:20
  • 8
    While it is true that is better to let large objects float, it is not true that "TeX (or LaTeX) is good in make typographic choices" here. TeX is very good regarding paragraph and line breaking but not regarding page breaking. See e.g. zeeba.tv/media/conferences/tug-2016/0102-Frank-Mittelbach – Ulrike Fischer May 19 '17 at 19:39
  • @UlrikeFischer I've seen it (fantastic). What I'm arguing is that TeX system are usually better in typography than the average beginner. I will change the wording, thanks – Moriambar May 19 '17 at 19:45
  • 1
    @Moriambar For the reputationless task man :) – user36296 Jun 4 '17 at 19:46

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.