Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In a chapter with many figures, I'm having trouble to get the floats to be interlaced with the text. To quote http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions:

Authors sometimes have many floats occurring in rapid succession, which raises the problem of how they are supposed to fit on the page and still leave room for text. In this case, LaTeX stacks them all up and prints them together if possible, or leaves them to the end of the chapter in protest. The skill is to space them out within your text so that they intrude neither on the thread of your argument or discussion, nor on the visual balance of the typeset pages.

I somehow feel this can't be the point, to have to manually spread the figures within the source file so that LaTeX will feel compelled to produce a visually pleasing result (if I felt that's how a typesetting software should work I'd be using Word). Why can't I just take a bunch of floats and tell LaTeX: "You take these and put them somewhere in this chapter. I know you can do it!"

I produced a MWE that shows that neither putting text before nor after a bunch of figures will help.

\documentclass{article}
\usepackage{mwe}
\begin{document}
\blindtext\par\blindtext\par\blindtext\par\blindtext\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par

\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{A figure.}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{A figure.}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{A figure.}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{A figure.}
\end{figure}

\begin{figure}
\centering
\includegraphics[width=\linewidth]{example-image-a}
\caption{A figure.}
\end{figure}
\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par\blindtext\par
\end{document}

texttexttextfigurefigurefiguretexttexttext

I know I could just use \begin{figure}[t] and would get what I want but, again, it can hardly be the point of floats to force them into a certain position. I am willing to let LaTeX put floats on a float page or at the bottom or whereever, as long as it at least tries to achieve a decent result. Mixing text and figure on one page and not on the others doesn't make any sense in any typography universe that I can conceive.

share|improve this question
    
If you leave width=\linewidth out, LaTeX creates float pages with two floats in it. (Apparently two floats are too high for one page.) You can also set \renewcommand*{\floatpagefraction}{0.6} and pages with floats need at least to cover 60% of the page; they will all places like the first one. See How to influence the position of float environments like figure and table in LaTeX? –  Qrrbrbirlbel Feb 25 '13 at 14:54
    
try \renewcommand*\floatpagefraction{0.7} and \renewcommand*\topfraction{0.7} –  tohecz Feb 25 '13 at 14:59
    
@Qrrbrbirlbel Ok, that link needs a more thorough studying by my side but isn't changing \floatpagefraction just another way to specifically forbid some behavior that might not be all wrong just to get this (minimal) example right? Just like [t]? Why do I even have to convince LaTeX that it shan't put floats on a page of its own when in at least one case it thought so itself and mixed the float with text? This can't be about tuning parameters I gather from that behaviour. –  Christian Feb 25 '13 at 15:04
1  
Page breaking in TeX is considered at each break (unlike linebreaking which is optimised over a paragraph) mostly because of the memory constraints at the time the system was devised. On the first break latex has enough text and a float to make a t float. It then has not got enough text to make a text page (as the rest of the text has not been seen) but it does have some pending floats which are bigger than half a page so allowed to make a float page so it does that. It chooses the best option available at that point it doesn't hold things back in case some more text comes along later. –  David Carlisle Feb 25 '13 at 16:04
    
@DavidCarlisle Ok, this explains that and why the LaTeX page breaking algorithm is basically just bad in some circumstances and needs to be helped along, either by manually interweaving text and floats or by tweaking some parameters to fit the document at hand. Mind if I copy together the things you said in the comments into your answer so that I can accept it? –  Christian Feb 25 '13 at 17:56

1 Answer 1

up vote 11 down vote accepted

Page breaking in TeX is considered at each break (unlike linebreaking which is optimised over a paragraph) mostly because of the memory constraints at the time the system was devised. On the first break LaTeX has enough text and a float to make a t float. It then has not got enough text to make a text page (as the rest of the text has not been seen) but it does have some pending floats which are bigger than half a page so allowed to make a float page so it does that. It chooses the best option available at that point – it doesn't hold things back in case some more text comes along later.

Since global optimisation for page breaks is not possible, your only choice is to force TeX to hold floats back until more text is available. Adding this to the preamble

\renewcommand\floatpagefraction{.75}
\makeatletter\def\fps@figure{htbp}\makeatother

Tips the balance away from float pages. The first line says a float page should be three quarters full (making float pages less likely) and the second adds h to the list of default float areas (making text floats more likely).

enter image description here

One of the downsides is, of course, that it becomes more likely that floats are held back until TeX reaches a float barrier and then has to dump them heedlessly. Another drawback is that actually aesthetically pleasing solutions might be prevented.

share|improve this answer
    
So the second line changes this preference? That would be great I guess. I still don't understand though why the first page in my example is set differently than the others. –  Christian Feb 25 '13 at 15:12
    
well they both change it, the first says a float page should be three quarters full (making float pages less likely) and the second adds h to the list of default float areas (making text floats more likely). Do you mean the first float in your question or in my answer? in yours it is a t float, then at the natural page break all the pending floats could be made p as they were over half a page (the default setting of floatpagefraction) so latex made float pages, not as a \clearpage emergency measure, just as that was its best choice consistent with the parameters. –  David Carlisle Feb 25 '13 at 15:45
1  
@DavidCarlisle Fiddling with float placement parameters can alliviate this particular example in which figures can fit with text in the same page, but I think the OP poses a valid general problem. If we have a sequence of "full page figures", can we tell latex we want them "evenly scattered" among pages? Or at least, not to put two "big figures" in two succesive pages? –  JLDiaz Feb 25 '13 at 16:02
    
@JLDiaz As I just explained in a comment on the question tex has a state of the art (still) linebreaking algorithm which optimises over a paragraph. The page breaker in tex in general and latex float positioning in particular, just considers one page at a time and ships out a page as soon as possible (ie as soon as any page can be made meeting the constraints) to consider two consecutive pages you need two pages in memory which was a scary prospect in 1982:-) –  David Carlisle Feb 25 '13 at 16:10
    
@DavidCarlisle but (AFAIK) when a "too big" float is found, LaTeX stores it in some kind of list, and also all subsequent floats. Then, when a \clearpage is found (typically at the end of the chapter), all pending floats in the list are dump. What I was asking was, is it possible to dump only one of those floats, and wait to the next-to-the-next page to dump the following, etc.. This would not require to maintain two pages in memory, would it? –  JLDiaz Feb 25 '13 at 16:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.