Graphics, Figures & Tableshelp at displaing a figure correctly, before subsection

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
apoc
Posts: 2
Joined: Thu Aug 07, 2014 10:19 am

help at displaing a figure correctly, before subsection

Post by apoc »

Hello and thank you for any suggestions, to mention is that I'm working on my first latex document - so noob alert..

I have multiple subsections, one with 3 subsequent figures:

Code: Select all

\subsection{Sometitle 1}
words words words...
3x

Code: Select all

\begin{figure}[h!]
  \centering
    \includegraphics[width=\linewidth]{pics/img}
  \caption{Desc.}
  \label{fig:img}
\end{figure}
then the next subsection

Code: Select all

\subsection{Sometitle 2}
other words other words...

It looks like this:
Image

How do I get the third figure to be displayed on a new page, before the next subsection, but not on an own page?

I appreciate the help!

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

help at displaing a figure correctly, before subsection

Post by Johannes_B »

Using h! as a placement specifier is not recommended and LaTeX will not accept it. It will extend it to ht. There was not enough room left to place the picture on the page, so it was shifted to the next page. But since there was still place for text, LaTeX filled the page.

This is called floating behaviour and is excellent. Economic usage of space.

Bernard made some suggestions in your question you posted at TeX.SX.

To sum it up, do not use a floating environment but a minipage (along with \captionof) instead, use package float and the specifier H to prevent floating. Another possible solution is to use package placeins along with its command \FloatBarrier.

Btw: The best way to represent a problem is to provide a minimal working example. To tell the truth, your pictures are useless.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
apoc
Posts: 2
Joined: Thu Aug 07, 2014 10:19 am

help at displaing a figure correctly, before subsection

Post by apoc »

Hello and thank you for the reply, I didn't expect the same user here :lol:

I tried those suggestions as well as this:

Code: Select all

\begin{minipage}[H]{\linewidth}
\centering
\includegraphics[width=\linewidth]{pics/picture}	
\captionof{figure}{description}
\label{fig:alabel}
\end{minipage}
which again results in a page with three figures, one only half visible due to the end of the page..

It's good that you tell me my picture is nonsense, I'll keep it in mind for future posts, and for the minimal working example it is hard since it's an overwhelming template, with numerous includes and settings.. :?
Post Reply