How-to

How to Force a Figure or Table Position in LaTeX

The fix

To place a figure or table exactly where you wrote it, load \usepackage{float} and use \begin{figure}[H] with a capital H. For softer control, \begin{figure}[htbp] tells LaTeX to try here, then top, bottom, and a floats page. [H] forces the spot but can leave whitespace, so use it only where placement really matters.

Not sure it worked on your document? Paste it into LetX and compile it, free and in the browser.

Why it happens

figure and table are floats. LaTeX moves them to avoid ugly page breaks, so they may not sit where you typed them. The optional [..] argument is a preference, not a command: h = here, t = top, b = bottom, p = floats page. Plain [h] is only a hint; [H] from the float package is the true "exactly here".

Example

\usepackage{graphicx}
\usepackage{float}

% Exactly here:
\begin{figure}[H]
  \centering
  \includegraphics[width=.6\textwidth]{plot}
  \caption{Pinned in place}
\end{figure}

% Softer preference (what LaTeX recommends):
\begin{figure}[htbp] ... \end{figure}

Frequently asked questions

I get "Unknown float option `H`".

You used [H] without the float package. Add \usepackage{float} to your preamble. It defines the capital-H specifier.

What is the difference between [h], [!h] and [H]?

[h] is a weak "here if convenient"; [!h] tells LaTeX to try harder by relaxing its spacing rules; [H] (float package) forces the exact spot with no floating at all.

My figures pile up at the end of the document.

Too many un-placeable floats queue up. Use [htbp] instead of [h], add a \clearpage where appropriate, or pin key figures with [H].

Related LaTeX fixes

Browse all LaTeX problems & fixes, or start with the LaTeX guide.

Learn the topic properly

Try the fix in LetX

Open the editor, paste your code, and compile in seconds to see the error clear. Free, in your browser.

Open LetX Free