GeneralPage of floats

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mattjgalloway
Posts: 4
Joined: Wed May 16, 2007 3:28 pm

Page of floats

Post by mattjgalloway »

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!

Recommended reading 2024:

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

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

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

Page of floats

Post by localghost »

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).

Code: Select all

\begin{figure}[!ht]
  \centering
  …
  \caption{A figure}\label{fig:figure}
\end{figure}
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.
mattjgalloway
Posts: 4
Joined: Wed May 16, 2007 3:28 pm

Re: Page of floats

Post by mattjgalloway »

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!
Post Reply