GeneralHow to force placing the figure in the given section?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Marek
Posts: 20
Joined: Wed Jan 30, 2008 3:36 pm

How to force placing the figure in the given section?

Post by Marek »

How to force placing the figure anywhere but in the given (sub)section? The figure's option [h] is to strong.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

How to force placing the figure in the given section?

Post by Stefan Kottwitz »

Hi Marek,

the placeins package may be useful.

Stefan
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to force placing the figure in the given section?

Post by localghost »

A \clearpage (or \cleardoublepage) command right after the float environment should do the trick. Replace the [h] option at least with [!ht] or [!hb], because it is overwritten by the compiler anyway (mostly with [!ht], see log file).


Best regards
Thorsten¹
Marek
Posts: 20
Joined: Wed Jan 30, 2008 3:36 pm

Re: How to force placing the figure in the given section?

Post by Marek »

Than you very much for the advices. Unfortunately placeins does not work (I have learned how it works using: http://www.let.rug.nl/alfa/tex/tetex30/ ... aceins.txt). But the ...{figure}[!ht] fully suffices to solve my problem though I have probably not understood the meaning of \clearpage (in Thorsten advice) and simply I did not use it.
I am going to test why placeins does not work.
Thank you both for replies to my question. Marek.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

How to force placing the figure in the given section?

Post by localghost »

Marek wrote:[...] But the ...{figure}[!ht] fully suffices to solve my problem though I have probably not understood the meaning of \clearpage (in Thorsten advice) and simply I did not use it. [...]
The \clear(double)page command forces the output of all float environments defined up to this point.
Marek wrote:[...] I am going to test why placeins does not work. [...]
The package defines the \FloatBarrier command which restricts the floating of these environments. Refer to the package documentation to learn more.
Post Reply