# strange figure floats [duplicate]

I don't understand why my figure floats to the "wrong places". For example:

  \documentclass[12pt,a4paper,oneside]{book}
\usepackage{graphicx}

\begin{document}

\section{My section}
\begin{figure}[htbp!]
\centering
\includegraphics[width=16.6cm]{figure.png}
\caption{My caption}
\end{figure}

\end{document}


The problem is that the figure appears before the section name, and not after it, like I want it to be... How can I correct this?

-

## marked as duplicate by Martin Scharrer♦Feb 20 '13 at 6:12

Try \begin{figure}[bp!]. The h (here) and t (top) might push your figure upwards. Or don't use floats at all, if you want to insert the figure at a very specific location. –  Count Zero Feb 19 '13 at 20:20
For an in-depth explanation of LaTeX's float-placement algorithm, see tex.stackexchange.com/a/39020/5001. For your specific example, you may wish to load the float package and then use the [H] ("really, really Here!") location specifier. Be forewarned, though, that if there's not enough space to place the figure right below the sectioning header, you'll be left with a big white gap below the header as the figure will have to be placed at the top of the next page. –  Mico Feb 19 '13 at 20:24
usually the h (here) option works rather fine without the other options. within a section, i got only once a minor problem when using 2 figures with only a couple of lines between them (within a 5 page paper). according to the inital problem, a simple removing of multiple options ([htbp!]) can made the trick. –  mnemonic Feb 20 '13 at 4:27
How to control the position of floats (figure, table, etc.) has already been discussed extensively (Actually they are one of the most frequent asked questions). All answers below where already given there (some multiple times), so I'm closing this question now as a duplicate. If the duplicate I linked doesn't help you (further) than have a look a the general question we created for this topic How to influence the position of float environments like figure and table in LaTeX?. –  Martin Scharrer Feb 20 '13 at 6:15

\usepackage{flafter}


which is part of the core LaTeX distribution. That changes the meaning of the t option so that it allows the top of subsequent pages but not the current page, so that a float never moves backwards.

-

You could use the placeins package. It provides the command \FloatBarrier:

Placeins.sty keeps floats ‘in their place’, preventing them from floating past a \FloatBarrier command into another section. To use it, declare \usepackage{placeins} and insert \FloatBarrier at places that floats should not move past, perhaps at every \section.

Option: [section]

A more convenient way to stop floats at section boundaries is to change the definition of \section to include \FloatBarrier, either at the beginning, before \@startsection, or in the ‘style’ specification (see The LATEX Companion, section 2.2.2; or 2.3 in the 1st ed). If you specify \usepackage[section]{placeins}, then the \section command will be redefined with \FloatBarrier inserted at the beginning.

Options: [above] [below]

Something you may not like is that, by default, \FloatBarrier is very strict, and will (try to) prevent a float from appearing above the start of the current section or below the start of the next section, even though the float is still on the same page as its intended section. Each restriction can be relaxed separately by using the [above] and [below] package options: [above] allows floats to appear above their section, if on the same page; [below] allows below.

(quoted form the package documentation)

-