2

I read a great post by Frank Mittelbach on how floats work, but I still have a problem: Is there a way to empty the float holding queue, thus placing all figures/tables ect at a certain point. Namely I would like a function that works as follows:

\section{1} 
figure 1
figure 2
\emptyFloatQueue
\section{2}
figure 3
table 1
\emptyFloatQueue
\section{3}
...

The \emptyFloatQueue function should ensure that all floats are typeset before any subsequent lines. Thus figure 1 and figure 2 MUST appear before section 2 and figure 3 and table 1 MUST appear before section 3 etc. It doesn't matter where the floats are placed, as long as they are placed before their respective subsequent sections.

Any help is appreciated

EDIT:

  • If there are no floats in the queue I don't want behavior to change.
  • I would like the floats to be placed as normally as possible (not separately on a float page, but inline along with the text)
  • 3
    \clearpage ?? (As that answer says.) – cfr Jun 08 '15 at 01:07
  • Is there a way to avoid the page break? If there are no floats in the queue I dont want the behavior to change. And I don't want the floats to appear on their own float pages, I would like them to be typeset as normal (in top or bottom area with the text) – Toke Faurby Jun 08 '15 at 01:14
  • \afterpage{\clearpage} waits until the top of a new page to execute. That is about as normal as it gets. – John Kormylo Jun 08 '15 at 01:28
  • 1
    You can't avoid them going to float pages. If there are floats in the queue, it is because LaTeX has not been able to place them in preferred locations. Without a minimal example, it is hard to say. But unless you are overriding the defaults, you have a limited set of options: relax the restrictions on placing the floats at the top or bottom (either globally or for specific floats) or allow them to be placed on float pages. I don't see that there are any other options. – cfr Jun 08 '15 at 01:39

1 Answers1

2

The \FloatBar­rier command from the placeins package seems to do the trick.

The documentation states;

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