0

If a figure is too large for one page and bound with the parameter [H], LaTeX leaves an entire page blank. Using the [p!] placement prevents the empty page but messes up the order. The first page of the result is blank and the figure then appears on the second page. The second figure should be placed before the text "Text after the second figure", but it isn't.
Why would LaTeX leave a page entirely blank? Using [p!] instead of [H] clearly is no real solution. This is the code:

\documentclass[40pt]{scrreprt}
\usepackage{float}

\begin{document}
\begin{figure}[H]
    \caption{This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption.}
\end{figure}
Text after the first figure.
\newpage
\begin{figure}[p!]
    \caption{This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption. This is a really long caption.}
\end{figure}
Text after the second figure.
\end{document}
  • 3
    Because you are telling it to using H. Try reducing the figure to fit in the page and use \begin{figure}[htp]. – Phelype Oleinik Oct 3 at 19:46
  • 1
    The [H] placement specifier is almost always more trouble than it's worth. Learn to live with LaTeX's float placement algorithm and, if you still feel you must override it from time to time, don't use [H]; instead, use [ht!] for smaller table and figure objects and [p!] for full-page objects. – Mico Oct 3 at 19:57
  • 2
    @LukasFun - Your objective, "[t]he figure is to be placed there in the document and not anywhere else", is impossible to achieve if the figure occupies a full page (or even more, as you wrote). No amount of foot-stomping is going to change this fact. As you probably (hopefully?) know, figure environments cannot be broken across pages. The best you can do in such a case is to place the figure on a page by itself, via [p!]. That's also why I recommend you stay away from using the [H] placement specifier: if it "works", [ht!] works at least as well. – Mico Oct 3 at 20:04
  • 1
    Look at the warnings. I bet you have complaints about an overfull box or similar. The figure doesn't really fit but, if starting a new page doesn't help, LaTeX will output it anyway as it can't do any better than that. Note that LaTeX needs it to fit the page - not the paper. Is the figure wider than \textwidth or longer than \textheight? – cfr Oct 3 at 20:46
  • 1
    The trick as @PhelypeOleinik says, is to lie. You tell LaTeX that the figure fits and it will believe you. Just remember that you won't get any warnings in this case, so you have to make sure it really does fit yourself. Alternatively, you can alter the page layout for a page. You'll also want to suppress headers and footers. I generally go for the lying approach (with header and footer suppression) rather than messing around with the layout. – cfr Oct 3 at 21:04
0

As stated in the comments, this is intended to happen. If there is a floating environment that doesn't fit on the page it is supposed to be on, LaTeX places it on the next, even if that leaves a completely empty page.

There is a workaround for this though: To trick LaTeX into believing that the object fits! I was told this should not be used as standard since there will be no warning if anything goes wrong in the process.
But here it is:

To get the object placed exactly where you want it with no weird empty pages in the process, use this:

\parbox[c][\textheight]{\textwidth}{
    The stuff that you want to be 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.