Avoid figure above section title [duplicate]

I am generally happy with where LaTeX puts the various figures in my document, except when it puts them on top of the title of its own section. This is particularly annoying if the section starts on a new page. How can you avoid that?

I know that you can use the option \begin{figure}[b] to make LaTeX put the figure at the bottom of a page, but firstly this often leads to all figures being clumped together at the end of the section and secondly I don't mind if the figures are on top of a page unless they come before the section title. I am sure there is an easy answer for that, right?

• How about \begin{figure}[h]? Without an MWE it might be difficult to help you directly, but you should have a look at Figure/table positioning for general solutions. – Runar Dec 30 '15 at 15:25
• Well, I don't need the figure to be at this position. If I used \begin{figure}[h] I'd need to do this on most of my figures, but I prefer if they are positioned where they match best except before the section title. I was hopint that there is a global option/package that avoids this kind of positioning. – Dietmar Haba Dec 30 '15 at 15:32
• add \usepackage{flafter} then latex will never float images backwards to before their point in the source. – David Carlisle Dec 30 '15 at 15:37
• Thanks for your quick answers. While \usepackage{flafter} again does more than I wanted, it works fine for me and does the job. Thanks a lot! – Dietmar Haba Dec 30 '15 at 15:46
• For future reference, I've found that just setting the first figure after the section starts with \begin{figure}[h] sadly is the only solution that avoids using flafter. This is only needed in the first figure in my experience; the following ones never float before the first. While not as automatic as flafter, it's generally not much work to just put [h] for the first figure of each section. – Pepe Mandioca Feb 10 '20 at 6:18

Using \usepackage{flafter} avoids that figures are floated before they were defined, which did the job in my case.