# Controlling figure and table placement in LaTeX

It can be frustrating trying to get your figures and tables to appear where you want them in a LaTeX document. Sometimes, they just seem to float off onto another page of their own accord. Here is a collection of tools and ideas that help you get control of those pesky floats.

Use the placement options: h, t, b and p. For example

 \begin{figure}[htb]

causes LaTeX to try to fit the float “here”, or at the “top” of the current page (or the next page), or at the “bottom” of the current page (or the next page). If “p” is specified, it will allow the float to take a whole page to itself. You can’t specify only “h” as that is too restrictive, and LaTeX will automatically change it to “ht”. The default setting is “tbp”.

One of the reasons that the floats won’t go where you want them is that there are a lot of constraints on where they can go. The main ones are

 Counter Default topnumber maximum number of floats at top of page 2 bottomnumber maximum number of floats at bottom of page 1 totalnumber maximum number of floats on a page 3 Command \topfraction maximum fraction of page for floats at top 0.7 \bottomfraction maximum fraction of page for floats at bottom 0.3 \textfraction minimum fraction of page for text 0.2 \floatpagefraction minimum fraction of floatpage that should have floats 0.5

These can all be changed individually. But it is often easier to add ! before the placement options, thus forcing LaTeX to ignore most of these contraints. For example, I often use

 \begin{figure}[!htb]

If you want to change the defaults, the following values give reasonable results:


The \clearpage command starts a new page and inserts all floats that have not yet appeared before continuing. This can leave a bad page break, so a useful alternative is to use the afterpage package, and then insert

 \afterpage{\clearpage}

which will put all the floats at the end of the current page.

A very useful package is placeins. This provides the command \FloatBarrier which causes all unprocessed floats to be processed at that point, but does not start a new page unless it is necessary. To keep floats in the sections in which they were included, use

 \usepackage[section]{placeins}

This silently puts a \FloatBarrier command before each section. There are other options explained in the placeins documentation.

Another useful package is flafter. This causes floats to always appear after their placement in the document.

If you really don’t want LaTeX to move your float at all, then use the float package with the command \restylefloat{figure} in the preamble. This allows you to specify [H] as the position parameter which means “Here and only Here”. However, this often gives bad page breaks.

### Related Posts:

• Thanks a lot for this helpful overview, Rob!

• Xin

I have a problem. For two column article, is there a simple way to put a cross-column figure at the top of current page? it seems to me that latex will always put it in the next page.

• According to the multicol package user guide, this is not possible. I guess you could move the figure* environment earlier in the document so it floats forward to where you want it.

• Souvikmetia

Hi Rob, I am facing a problem related to the Table adjustment. I have table code which make the table(big table) to contain in one page, but when i want to give it a definite position, instead of placed in the given position, it goes to couple of page later. How can i solve it?

• Nan Qu

I recently found the environment of minipage is very handy when inserting figures and tables.

Hi Rob, can I ask a question in R plotting?
Does R facilitate filling the area under a curve?

Thanks!

• Use the polygon() function.

• Pingback: Controlling figure and table placement in LaTeX « Idyawati's Blog()

• Sometimes I used minipage since I can’t really control the *exact* position of the figure/tables, even using htb

• Tom3ld

Awesome, thanks so much

• Cuneyt Ertal

This what I searching for a long time. Thank you so much.

• Chris

I have 5 figures in a row and text beforehand and afterwards. Now I want the text beforehand, then the 5 figures and then the text afterwards. I tried /floatbarrier – but it puts the last figure on a seperate page before starting with the next text.
What am I doing wrong?

• Henry

Very useful, Thanks a lot!

• Rob

Thanks for the usefull and comprehensive overview!!

• Jithin

Great tips. Thanks a lot.

• Pingback: Research tips – Controlling figure and table placement in LaTeX « Rearchitecting()

• Joseeek

wow works great in texshop

• alek

dude was that frustrating… lifesaver <3 great work

• Dimas

In case anyone had the same problem I had and ended up here, to place multi-column floats (like begin{figure*}[b] end{figure*}) in the bottom of multicolumn text, you need to use the package dblfloatfix.

• Nav

Worked beautifully! Thanks for this

• Alex Gerdom

THANK YOU! The specifications for my thesis formatting specify that figures and tables should appear alone on the page after they first mentioned in the text. After quite a lot of googling, your recommendation for FloatBarrier ended up being just what I needed. So thank you!

[My final solution in case anyone finds this in a Google search]
In order to get floats placed alone and vertically centered on the page after they are first mentioned in the text. I am including in my preamble:

usepackage[section]{placeins}
usepackage{afterpage}

and placing in the text:

afterpage{
begin{figure}[p]
<>
end{figure}
FloatBarrier
}

• Philipp

Thank you. big help!