Possible Duplicates:
How do I ensure that figures appear in the section they're associated with?
Keeping tables/figures close to where they are mentioned

How can I force an image in a LaTeX documents to appear in the section in which I declared it?

I don't want that an image about "Section A" to appear in "Section F". :(

I actually include an image with

\caption{3D View of the robotic workspace (in red).}

Try \begin{figure}[!htb]. In nearly all cases it helps.

Explanation of the figure placement parameters:

  • h - Place figure here, if possible
  • t - Place figure at the top of a page
  • b - Place figure at the bottom of a page and
  • ! - Over-ride default LaTeX figure placement (do not use the parameter values).

If that doesn't work then use:


This prevents placing floats before a section.

  • 12
    \usepackage[section]{placeins} doesn't seem to prevent a float from being put after subsections, however. – Nate Nov 25 '14 at 18:15
  • \usepackage[subsection]{placeins} would do that @Nate. Check out further options for placeins. – Midnighter Oct 16 '15 at 13:32
  • 17
    @Midnighter: No. \usepackage[subsection]{placeins} produces LaTeX Error: Unknown option subsection' for package placeins'. However, this answer explains how to redefine \(sub)subsection to include \FloatBarrier. – Jakob Feb 17 '16 at 16:14
  • This answer is awesome – Sudhir Belagali Jun 11 '16 at 13:23
  • 2
    Using \usepackage[section]{placeins} solved for me. – kitsune Mar 15 '19 at 12:05

As Werner commented: the section Moving tables and figures in LaTeX at tex.ac.uk states:

Even if you use the placement specifier [h] (for ‘here’), the figure or table will not be printed ‘here’ if doing so would break the rules; the rules themselves are pretty simple, and are given on page 198, section C.9 of the LaTeX manual.

Use the float package with the [H] specifier. If you comment out the \usepackage{float}, the following MWE results in the figure on the second page, but as is the figure appears between the two paragraphs.

\usepackage{float}% If comment this, figure moves to Page 2

  \caption{caption text}

You should also be using \centering instead of \begin{center}...\end{center} as per should i use center or centering for figures for more details.

  • 8
    using [H] is always not a good idea! – user2478 Oct 24 '11 at 21:19
  • 5
    Why is that? Would you care to elaborate? – jnns Jul 22 '14 at 10:27
  • 1
    @Herbert: I think the above question was intended for you. – Peter Grill Jul 22 '14 at 18:47
  • 1
    @jnns: An image with caption is just like one big box (character) for TeX and for filling the page with text it is easier if TeX can move such big objects to places where it makes sense. Otherwise you can have a lot of whitespace if an image must appear where it was declared. – user2478 Jul 22 '14 at 18:51
  • Latex attempts to minimize whitespace. As more documents are read on screens instead of paper, it makes sense to adjust the rules to make a document easier to read (e.g. by placing floats after the text that discusses them) even if it adds whitespace. – Jim Van Zandt Jun 28 '19 at 18:48

If you don't want your figure to float, don't use a floating environment; you can use, for example, a center environment and (if a caption is needed) the \captionof command provided by the capt-of (or caption) package:

\usepackage{lipsum}% just to generate text for the example

  \captionof{figure}{A non floating figure}


If you want the figure to float, but not passing a \section command. you can use the placeins package and its \FloatBarrier command beyond which floats may not pass. A package option allows you to declare that floats may not pass a \section command, but you can place \FloatBarriers wherever you choose.


You don't mention how tall the float is. This leaves open several reasons, related to LaTeX's float placement parameters, for why the figure is showing up "too late" relative to where you'd like to occur.

Assuming that the figure's total height is no more than 0.5\textheight, you may have a good experience with the following setup, which uses the afterpage package and its command \afterpage:

[code up to the figure of interest]
\begin{figure}[t] % note the use of the "t" placement specifier
\centering % don't use \begin{center} ... \end{center}: it wastes too much space
\caption{3D View of the robotic workspace (in red).}
[remaining code of your document]

The reason I mention the 0.5\textheight consideration is that one of LaTeX's key parameters for placing floats on a page is \floatpagefraction, a fractional number between 0 and 1; by default, it is equal to 0.5 (unless set to a different value by some class or package command). Thus, if your figure is taller than 0.5*\textheight, LaTeX will refuse to place it on a page along with other, i.e., text, material, causing the float to drift all the way back until some forced page break (caused possibly by a \clearpage command) occurs. In such a case, you should probably issue the commands

\renewcommand\floatpagefraction{0.8} %% default value: 0.5
\renewcommand\topfraction{0.8}       %% default value: 0.7

and recompile the document. Of course, if your float's height is, say 85% or 95% of \textheight, you should really be willing to place it on a page of its own (most easily accomplished by choosing the [p] placement specifier).

A comment on the use of the [H] placement specifier that's provided by the float package: While it's true that it sometimes helps with placing an otherwise difficult-to-place-correctly float, using it is really tantamount to treating a symptom rather than finding a cure for the underlying cause of the problems related to placing the float satisfactorily. Before you resort to using it, you should really consider modifying LaTeX's float-placement parameters. That said, I too have experienced cases, with my own papers, where I've resorted to using the [H] specifier after I struck out having tried all other remedies...

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