I'm using the flafter
package to prevent floats from appearing before their positions in the LaTeX source code.
When I put a float just after a section title and the section starts at the beginning of the page, sometimes the float appears above the section title, on the top of the page, while it should appear under the section title.
In the example below:
- by uncommenting
paragraph2
the float will be under the section title (as expected); - by commenting
paragraph2
the float will be above the section title (at the top of the page).
I'd like to put the float under the section title in both cases.
\documentclass{article}
\usepackage{mwe}
\usepackage{flafter}
\begin{document}
\blindtext[4]
paragraph1
%paragraph2
\section{My section}
\begin{figure}[htb]
\includegraphics{example-image-a}
\end{figure}
\blindtext
\end{document}