Skip to content

Float placement in LaTeX

March 27, 2008

I’ve been plagued by misplaced figures in a paper I’m writing, but fortunately I just figured out how to solve it and I want to write it down (here) so I don’t forget.

The problem involves a LaTeX document with sections and subsections. In one of the subsections I want to place a LARGE table (an instance of \begin{sidewaystable} … \end{sidewaystable}). However, no matter what parameters I give to the figure environment, LaTeX always decides to push the table’s appearance until sometime after the start of the next section (sometimes even to the very end of the document, right in the middle of the bibliography in fact!)

So basically I want to tell LaTeX that, no matter what, you should place the figure before the start of the next section. There should be a command to do this right?

\clearpage

This tells LaTeX to place all outstanding floats, on their own page if necessary, before continuing to the next page. So putting this after the table in question and before the start of the next section works perfectly.

Actually, now that I think about it, I’m not sure I know why this works in my document because the if I remove the table, the beginning of the next subsection starts in the middle of a page. So in principle, \clearpage could have the effect of putting the table on the first page after the start of said subsection.

Oh well..

(update — Thanks to Piet van Oostrum)

Advertisements
One Comment
  1. Hi Bruno,

    to force floats to be output before a new section placeins could be used:

    \usepackage[section]{placeins}

    And btw. the afterpage package is useful sometimes too:

    \afterpage{\clearpage}

    The current page would be finished first avoiding too much remaining free space at the end of the page.

    Stefan

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: