How can I redistribute floats towards the top of the page?

I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like

\let\oldfoot\footnote \renewcommand{\footnote}[1]{\oldfoot{#1\medskip{}}}
\let\oldcap\caption \renewcommand{\caption}[1]{\oldcap{#1\medskip{}}}


but still get floats running off the bottom of the page, even though there's plenty of marginal space and I've tried things like

\renewcommand{\topfraction}{0.9}
\renewcommand{\bottomfraction}{0.2}
\setcounter{topnumber}{4}
\setcounter{bottomnumber}{1}
\setcounter{totalnumber}{5}


Are there general, document-wide, settings or redefinitions I can use to redistribute floats "upward" in the margin, into the abundant free space there?

Any document with the structure

\documentclass[]{tufte-handout}
\title{This is just the title}
\begin{document}
%Enough text to put a "here" sidetone near the bottom of the page
\footnote{Some text that gets close to the bottom of the page.}
%A bit of text
\footnote{Another good-sized chunk of text}
\end{document}


will do result in marginal material that flows off the page, e.g.:

\documentclass[]{tufte-handout}
\title{This is just the title}
\begin{document}
I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like. I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like\footnote{I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like}
I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general cotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional\footnote{I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like} collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like\footnote{I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things like}
I'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisions between floats, as well as floats that run off the bottom of the page. I've been able to eliminate collisions with things likeI'm using Tufte classes and am trying to gain some general control over the distribution of floats (including Tufte's implementation of citations and footnotes) on my pages. Without intervening, I get occasional collisio
More body text.
\end{document}


And the following is typical of pages that produce collisions between marginal material:

\documentclass[]{tufte-handout}
\usepackage{amsmath}
\begin{document}
Some text in front of some math:%
\footnote{The team also relied on images that amateur astronomers had been gathering of a large, transient storm called the South Equatorial Disturbance. This visual record dates back to 1999, when members of the community spotted the most recent recurrence of the storm just south of Jupiter's equator. Analysis of these images revealed the dynamics of this storm and its impact on the chevrons. The team now thinks this storm, together with the Great Red Spot, accounts for many of the differences noted between the jet streams and Rossby waves on the two sides of Jupiter's equator.%
}
\begin{align}
a & \approx0\tag{B1}\label{D:B1}\\
b & \approx0\tag{B2}\label{D:B2}\\
c & \approx1\tag{B3}\label{D:B3}
\end{align}
\footnote{Some other text that should not be colliding with the text above.%
}which allows him to take The team also relied on images that amateur astronomers had been gathering of a large, transient storm called the South Equatorial Disturbance. This visual record dates back to 1999, when members of the community spotted the most recent recurrence of the storm just south of Jupiter's equator. Analysis of these images revealed the dynamics of this storm and its impact on the chevrons. The team now thinks this storm, together with the Great Red Spot, accounts for many of the differences noted between the jet streams and Rossby waves on the two sides of Jupiter's equator.Like Earth, Jupiter has several fast-moving jet streams that circle the globe. Earth's strongest and best known jet streams are those near the north and south poles; as these winds blow west to east, they take the scenic route, wandering north and south. What sets these jet streams on their meandering paths -- and sometimes makes them blast Florida and other warm places with frigid air -- are their encounters with slow-moving waves in Earth's atmosphere, called Rossby waves.Crucial to the study was the complementary information that the team was able to retrieve from the detailed spacecraft images and the more complete visual record provided by amateur astronomers. The team also relied on images that amateur astronomers had been gathering of a large, transient storm called the South Equatorial Disturbance. This visual record dates back to 1999, when members of the community spotted the most recent recurrence of the storm just south of Jupiter's equator. Analysis of these images revealed the dynamics of this storm and its impact on the chevrons. The team now thinks this storm, together with the Great Red Spot, accounts for many of the differences noted between the jet streams and Rossby waves on the two sides of Jupiter's equator.

For example, the high resolution of the spacecraft images made it possible to establish the top speed of the jet stream's wind, and then the amateur astronomers involved in the study looked through the ground-based images to find variations in the wind speed.%
\footnote{I will elaborate on some consequences of this particular scenario later.%
} For all of these reasons we can no longer take the observer density'' of an average simulation,
$\frac{a}{b}$
More text here that says nothing but is just to fill space:%
}
$\frac{a}{b}$

\end{document}

-
I guess that without Minimal non-Working Example this is really hard to solve. One possible problem might be that the floats occupy a space that they don't reserve (i.e. they claim to be e.g. 5 cm high but in fact they are 10 cm, causing them to overlap). –  tohecz Mar 13 '12 at 22:03
When you refer to “floats that run off the bottom of the page,” do you mean captions or the float contents themselves? Can you provide an example that demonstrates the problem? –  godbyk Mar 13 '12 at 22:21
@godbyk: Example added. –  raxacoricofallapatorius Mar 13 '12 at 22:22
Do you want the sidenotes to always start at the top, and fill in the right margin, essentially as a second column, or do you want them to try to be like marginpars, anchored to their marker, but only ripple upwards if space is tight at the bottom of the page? (The latter is harder to do, I think). –  David Carlisle Mar 13 '12 at 23:10
Oh yes, exactly. tug.org/TUGboat/tb31-2/tb98hicks.pdf describes exactly the two approaches mentioned in the comment above. Glad someone has already implemented it! –  David Carlisle Mar 14 '12 at 19:59

The contents of the float itself (figure, table, listing, etc.) should never run off the page. Unfortunately, captions can sometimes run off the end of the page. The reason is that we fool LaTeX into thinking that the captions have a height of 0 pt so that it it allows the body text to align nicely with the bottom of the float contents and the caption to flow down the margin.

There are a few different options available for repositioning sidenotes, captions, and margin floats.

Sidenotes can take an optional vertical offset parameter. A negative value moves the sidenote up the page; a positive value moves it down the page. (See page 22 in the sample book for more details.)

\sidenote[][-3\baselineskip}{My sidenote text...} % moves the sidenote up three lines


Margin floats use the same offset parameter:

\begin{marginfigure}[1.0in]% moves the margin figure down 1 inch
% ...
\end{marginfigure}


Captions can be aligned with the float contents at either the top or bottom (p. 25):

\begin{figure}[t]
\includegraphics{mypic}
\setfloatalignment{t}% forces caption to be aligned with the top of the float contents
\caption{This figure is at the top of the page.}
\end{figure}


The captions can also be offset in the same way as the sidenotes (pp. 23–24):

\caption[][-5\baselineskip]{This caption is moved up by five lines.}


Typically, I write the entire document first, placing the floats in their logical positions within the source code. As one of the final steps in the editing process (after all the text has been proofread and arranged), I'll adjust the position of the floats, captions, sidenotes, and other marginal material manually.

I adjust the float positions first by specifying the desired float position specifiers (t, b, h, p, !) and by moving the float code around in the file until LaTeX positions it where I want it.

After the floats have been adjusted, I'll adjust the caption alignments (with \setfloatalignment). I top-align all the captions except for floats that are at the bottom of the page—I bottom-align those captions.

Finally, I'll add manual offsets to any captions, sidenotes, margin notes, margin floats, etc. that are overlapping or falling off the bottom of the page.

-
Yes, but I'm looking for a general solution that doesn't require manual positioning. –  raxacoricofallapatorius Mar 13 '12 at 23:14
Ah, well, I think there are two separate issues you'll have to tackle then: (1) captions, and (2) sidenotes/marginnotes. To address (1), you could under the vertical smashing that Tufte-LaTeX does to the captions, but this will cause the float's vertical height to be the max of the float contents and the caption height. As for (2), I suspect this is a bug in the Tufte-LaTeX code, but haven't been able to chase it down yet. The normal LaTeX mechanism for \marginpars should prevent them from overflowing the page—I appear to have broken this mechanism with my definitions of \sidenote. –  godbyk Mar 13 '12 at 23:18
Another alternative to explore is Stephen Hicks' marginfix package. It allows all \marginpars to shift around to make room for each other. The downside to this approach is that you lose the alignment of the note with the main text where the note is referenced. –  godbyk Mar 13 '12 at 23:20
Thanks, I'll give marginfix a try. I'll also try some manual positioning. Your strategy (to do some fine tuning at the end) makes sense, and seems unavoidable. The problem I have with that is that I use LyX, and have no (bearable) way of adding the positioning options to individual floats. –  raxacoricofallapatorius Mar 13 '12 at 23:27
With the help of morefloats, marginfix does a pretty good job. The only problem I have is that in my actual document, I've made the title fullwidth, and that causes the floats to shift off to the right. Any thoughts on how to patch that would be much appreciated! –  raxacoricofallapatorius Mar 13 '12 at 23:39
show 1 more comment