6

I'm having some issues dealing with figures. It happens that when I have a page with some text and then it comes a figure, with H property, who doesn't fits into the same page as the text, the text itself gets spreaded in that page. here.

Is there a way I can remove theses spaces? What I'd like is that the end of the page would be left blank (even though some people may not think it is the best thing to do). Here is the image with what I would love to have as the output.

Is there any way I can do this?

4

The \raggedbottom declaration makes all pages the height of the text on that page; No extra vertical space is added. Add that to your document preamble and I believe you'll get the behavior you're looking for.

  • The problem is that this produces the ragged behavior on all pages which is often not desired. – Frank Mittelbach May 19 '12 at 12:17
7

I assume you are using a book type of document class because they normally set \flushbottom as the default, which gives you the behavior you are experiencing. So a trivial solution is, of course, to change that setting to \raggedbottom in the preamble of your document (or the class if this is a private class). However, the downside of this approach is that then all pages will show a ragged behavior which, for a book or manual is normally not desired.

As an alternative you can just make the offending pages come out short by using a command like \maybeflushthispage in front of all the places where you may have to break a page short (i.,e., in your case the in front of all figures of type [H]).

\documentclass{book}

\usepackage{lipsum,float}

\setlength\textheight{26\baselineskip}

\newcommand\maybeflushthispage{\vfil\penalty1000\vfilneg}

\begin{document}

\lipsum[1-2]

\maybeflushthispage
\begin{figure}[H] \rule{5pt}{4cm} \end{figure}

One line here \ldots

\maybeflushthispage
\begin{figure}[H] \rule{5pt}{4cm} \end{figure}

\lipsum[1]

\end{document}

If you run this then \maybeflushthispage will flush the page if a break is taken (first page) but will do nothing otherwise (second page):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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