0

I am trying to allow more flexibility to the placement of figure environments.

More specifically, say that a section ends 5cm before the bottom of the page, and ends with a figure environment, which takes up 10cm of the page. The float gets pushed to the next page, and occupies the whole page. Then, the new section starts on the following page.

How can I allow the placement to be more flexible? Ideally, the float should be pushed to the top of the first page not containing a section title. This would render like so:

+-------------+-------------+-------------+
| Lorem ipsum | ยง2 Title    | +---------+ |
| Lorem ipsum |             | |         | |
| Lorem ipsum | Lorem ipsum | +---------+ |
| Lorem ipsum | Lorem ipsum | Fig. Abc    |
| Lorem ipsum | Lorem ipsum |             |
| Lorem ipsum | Lorem ipsum | Lorem ipsum |
|             | Lorem ipsum | Lorem ipsum |
|      1      |      2      |      3      |
+-------------+-------------+-------------+

Here is a MWE producing the un-desired output.

\documentclass{book}

\usepackage{mwe,lipsum}

\let\oldsection\section \renewcommand\section{\clearpage\oldsection}

\begin{document}

\section{Title One}

\lipsum[1-3]

\begin{figure}[ht] \centering \includegraphics{example-image} \caption{Caption} \end{figure}

\section{Title Two}

\lipsum[1-3]

\end{document}

Note that indeed, as David Carlisle suspected, I am using a \clearpage before each section. I would like to keep this behaviour as is.

Anthony
  • 250
  • If the point is make "more flexible floats" in general see this question. Otherwise, there are not enough context to see the true issue and propose concrete solutions. Please make a minimal working example (MWE) and explain what is wrong exactly in that MWE. You can use the lipsum packages to make easily dummy text and the images of the mwe package to simulate your figures. โ€“ Fran Mar 17 '24 at 23:53
  • 1
    why prevent b floats or p floats? also with a standard definiton of section headings I don't see why this should do as you describe and make a page just containing the float as you have removed the p float page option. Unless your \section do \clearpage and flush floats (which is normally something \chapter do but not lower level headings) โ€“ David Carlisle Mar 18 '24 at 00:48
  • please make a small complete example that shows the problem, so people can understand the question, and test answers. โ€“ David Carlisle Mar 18 '24 at 10:31

0 Answers0