Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
How to influence the position of float environments like figure and table in LaTeX?

I have two sections in my document: sectionA and sectionB. The code for the document is something like this:

\begin{document}
\section{sectionA}

    some text

    \begin{figure}
        \centering
        \includegraphics[scale=0.3]{pic.ps}
        \caption{caption}
    \end{figure}

    some more text

\section{sectionB}

    even more text

\end{document}

However, sectionB is showing BEFORE the figure is displayed. In practice sectionA contains more text and is almost a full page, so I'm guessing LaTeX is placing the figure on the other page, seeing some empty space after sectionA and placing sectionB there.

How can I fix this? I would rather have B start after my figure, regardless of its size.

I've already tried \begin{figure}[h!]

share|improve this question
add comment

marked as duplicate by Roelof Spijker, Seamus, qubyte, cmhughes, percusse Mar 22 '12 at 15:13

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 2 down vote accepted

The placeins package http://ctan.org/pkg/placeins defines a \FloatBarrier command that keeps floats within sections. (It avoids forcing a \clearpage if possible.)

As noted by @RoelofSpijker in comments, if you use [section] option when loading the package, it automatically adds a barrier to each section.

share|improve this answer
    
perhaps add that you can load the package with the section option to solve this specific issue? –  Roelof Spijker Mar 22 '12 at 13:59
add comment

\clearpage places all as-yet unplaced floats (including figures).

share|improve this answer
add comment

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