Hi,
I am trying to work out how to do something in Latex for my technical report. I have an appendix at th back which contains code fragements which I reference in the main text. These code fragments are wrapped inside a float I defined called `code'. Currently I have all the code segments one after another in the Latex code, but when compiled it makes a first page of code segments and then subsequent ones appear at the end of the document on their own pages each. I currently have [h] set for each code float. I have tried it with [!h] for all of them but that doesn't fully work either.
Is there any way I can specify to Latex to keep placing floats on a page until full, then start a new page, etc, etc and stop it from pushing them all to the back?
Many thanks in advance!
General ⇒ Page of floats
NEW: TikZ book now 40% off at Amazon.com for a short time.
- localghost
- Site Moderator
- Posts: 9202
- Joined: Fri Feb 02, 2007 12:06 pm
Page of floats
You should always use a combination of parameters like [!ht] or [!hb], because a single [h] is always overwritten by the compiler (mostly with [ht], see log file).
If that alone doesn't help, just insert the \clearpage command after every figure environment. This command forces the output of all floats declared at this point.
Code: Select all
\begin{figure}[!ht]
\centering
…
\caption{A figure}\label{fig:figure}
\end{figure}
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
Board Rules
Avoidable Mistakes
¹ System: TeX Live 2025 (vanilla), TeXworks 0.6.10
-
- Posts: 4
- Joined: Wed May 16, 2007 3:28 pm
Re: Page of floats
Hey,
Thanks for your help. I think I found a work around which is working well for me - I'm just forcing a new page myself. It's quite good because in between two floats on a page I have \vfill so that it looks better on the page.
I didn't know that you're meant to put 2 things always for the float placement - thanks for that tip!
Thanks for your help. I think I found a work around which is working well for me - I'm just forcing a new page myself. It's quite good because in between two floats on a page I have \vfill so that it looks better on the page.
I didn't know that you're meant to put 2 things always for the float placement - thanks for that tip!