views:

199

answers:

3

So I have a Latex file with some plots. However there's a problem with the figure floats in the image. I have a picture right before a page break, and latex pushes the to big plot down to the next. Fine enough. But then it decides to go smart and push up the section after the plot, to the free space that was left when the picture was pushed down. The result is as you understand pretty confusing, if you are discussing plots.

Here is some code

\subsection{Part A2.1.6}
 The Xsi2-distrubution with h=40 and 1\% significance gives 63.7(22.2) which 
 is significantly smaller than both Ljung-Box applied to the linear and 
 quadratic residuals, from which we can conclude that the residuals are not iid, 
 and that the linear and quadratic models are not as good as wanted. 
\begin{figure}[h!]
\hspace*{-2.5cm}
    \centering
    \includegraphics[scale=0.40]{plot7_MEGAPLOT.png}
    \hspace*{-2.5cm}
    \vspace*{-0.5cm}
    \caption{Plot of raw and deseasonalized dat}
\end{figure} 
\\
\section{Part A2.2}
\subsection{Part A2.2.1}
The main qualitative difference between the plots/roots is that we have an 
converging oscillating function for the complex roots while the real values 
gives us a weakly oscillating converging function.
+1  A: 

This is quite normal. If there is not enough space for a figure, then the space shouldn't be left blank; it should be filled with whatever text comes next in the document. (You don't see quarter-empty pages in professionally published books, for example.)

If you don't want the figures to float, then you can use [H], but I don't recommend it because as you've discovered it leaves lots of blank space.

My recommendation to everyone using floats is to not give them a placement argument at all (the default is [tbp]) or use [htbp] and let LaTeX put things where it likes. Getting good spacing once the document is finished is as much a problem of tweaking the surrounding material as it is playing with the float parameters.


By the way, no discussion of how LaTeX handles floats is complete without a link to Robin Fairbairn's FAQ entry on the subject.

Will Robertson
+1  A: 

It sounds like you might need the placeins package to prevent floats crossing a section barrier.

I've summarised this and most of the other solutions for handling float placements here.

Rob Hyndman
A: 

What you don't say is what you expect to see. If the plot is too big for "here", then LaTeX has to put it on the next page (or a page of floats). That leaves some space which, as Will says, should be filled with something. What effect are you hoping to see?

Joseph Wright