Fix LaTeX figure placement in Overleaf.
Figures in Overleaf float because LaTeX treats them as mobile objects designed to prevent awkward page breaks. When a figure ends up miles away from where you wrote it, you can control its movement using specifiers like [htbp], the [H] parameter, or section barriers.
The short answer: stop using [h] alone because it is too restrictive. Give LaTeX options with [htbp], use [H] from the float package when you need an image locked down, or add \FloatBarrier to keep images inside their sections.
Why LaTeX moves your figures
When you wrap an image in a figure environment, you are creating a float. LaTeX looks at the remaining space on the page, the size of your image, and rules about how much text must remain visible. If your figure does not fit in the space left below your paragraph, LaTeX pushes it to the top of the next page and keeps filling your current page with text.
This algorithm prevents huge ugly gaps at the bottom of pages, but it often drives writers crazy when an image appears three sections past where it is discussed. Understanding the placement letters lets you guide the algorithm instead of fighting it.
The five placement specifiers
| Specifier | Meaning | Behavior |
|---|---|---|
| h | Here | Approximately where it appears in source text, if room permits. |
| t | Top | At the top of the current or next page. |
| b | Bottom | At the bottom of the current or next page. |
| p | Page | On a dedicated page containing only floats and no body text. |
| ! | Override | Ignores internal height and count rules to force placement. |
Five ways to fix misplaced figures
Use [htbp] instead of just [h]
Writing \begin{figure}[h] gives LaTeX only one chance. If the figure cannot fit right there, LaTeX rejects it and starts pushing it down the document. Giving it four options lets it place the image cleanly on the same page or the next one.
\begin{figure}[htbp] \centering \includegraphics[width=0.8\linewidth]{chart.pdf} \caption{A flexible figure that fits where space allows.} \label{fig:chart} \end{figure}Lock a figure in place with [H]
When a journal or assignment format demands an image right between two specific paragraphs, load the float package in your preamble and use capital [H]. This turns the figure into a static block, though it can leave blank white gaps at the bottom of pages.
\usepackage{float} ... \begin{figure}[H] \centering \includegraphics{diagram.pdf} \caption{Locked to this exact spot.} \end{figure}
Writing for the float algorithm
The most sustainable fix for floating issues is referencing rather than anchoring. Academic readers follow numbers, not physical page locations. Write \ref{fig:results} in your text and let LaTeX put the image wherever the page break looks best.
If you use Subfigures or place two images side by side, wrap each one in a \begin{subfigure} environment inside a single main figure block. Always place your \label command directly after your \caption command; putting the label first breaks cross-references and outputs a question mark in your compiled PDF.
Questions
Why does Overleaf put my figure at the end of the document?
When a figure is too large to fit in the remaining space of the current page and you specified only [h], LaTeX tries to push it forward. If subsequent pages fill up just as quickly, the figure drifts all the way to the end of the chapter or into the bibliography. Adding [htbp] or using [H] solves this.
What is the difference between [h] and [H] in LaTeX?
Lowercase [h] is a suggestion; LaTeX treats it as a preference but can override it if space is tight. Capital [H] comes from the float package and is a strict command to place the figure right here and nowhere else.
How do I keep figures inside their own section in Overleaf?
Try your own paper in Texeno.
Start free, upload a project as a .zip and press Recompile. Upgrade when you need longer compiles.
Start writing