Figure placement in LaTeX (h, t, b, p, H)

The optional argument of figure lists the places LaTeX may use: h (here), t (top of a page), b (bottom) and p (a page with floats only). \begin{figure}[H] from the float package puts the figure exactly where it stands in the source.

Preamble

The snippets on this page need these lines before \begin{document}:

\usepackage{graphicx}
\usepackage{float}
\usepackage{placeins}

Allow several places

[htbp] allows all four places. The order of the letters has no effect; LaTeX tries h first in any case. Without an argument, the article class uses tbp. An added !, as in [!htbp], tells LaTeX to ignore its limits for the number of floats and the share of a page they may cover.

Text before the figure.

\begin{figure}[htbp]
\centering
\includegraphics[width=0.5\textwidth]{image.png}
\caption{The measurement setup}
\end{figure}

Text after the figure.
Result
The compiled example

Put the figure exactly here

With the float package, [H] turns the float off for this figure: it appears between the two paragraphs around it. If the rest of the page is too short, the figure moves to the next page and leaves the rest of this page empty.

Text before the figure.

\begin{figure}[H]
\centering
\includegraphics[width=0.5\textwidth]{image.png}
\caption{The measurement setup}
\end{figure}

Text after the figure.
Result
The compiled example

Keep figures inside their section

\FloatBarrier from the placeins package is a line that no float may cross: figures and tables from the source before it appear before it. Unlike \clearpage, it starts a new page only when floats are still waiting. \usepackage[section]{placeins} sets this barrier before every \section.

\section{Results}
Text of the section.

\begin{figure}[tbp]
\centering
\includegraphics[width=0.5\textwidth]{image.png}
\caption{The measurement setup}
\end{figure}

\FloatBarrier
\section{Discussion}
Text of the next section.
Result
The compiled example

Print all waiting figures

\clearpage ends the page and prints every float that has not been placed yet, on pages of their own if needed. Use it before a new chapter or before the bibliography.

\begin{figure}[tbp]
\centering
\includegraphics[width=0.5\textwidth]{image.png}
\caption{The measurement setup}
\end{figure}

\clearpage
\section{References}
Result
Page 1 of the compiled examplePage 1
Page 2 of the compiled examplePage 2

Pitfalls

Compiled with pdfLaTeX from TeX Live 2023.

Related pages