0

In the MWE below, the 3.65" x 2" figure is placed roughly in the middle of the document. However when the caption is shortened by commenting out \lipsum[1][1-2] and commenting in \lipsum[1][1], the figure is pushed to the end of the document. Why is this and how can the latter behavior be prevented?

\documentclass[550paper]{kdp}

\usepackage{lipsum} \usepackage{graphicx}

\begin{document}

\lipsum[1-3]

\begin{figure}[!p] \includegraphics{TestFig.pdf} \caption{ \lipsum[1][1-2] %\lipsum[1][1] } \end{figure}

\lipsum[1-3]

\end{document}

Zarko
  • 296,517
  • 2
    you can reduce \floatpagefrraction or you could allow the figure to be t note that if floatpagefraction is small latex will issue the float page as soon as it can so after the first small one it will ship a nearly empty page without waiting to see if another one coming later would fit. – David Carlisle Aug 21 '21 at 08:11
  • can you make an example of the problem using a standard class such as article? kdp.cls is not in texlive – David Carlisle Aug 21 '21 at 08:12
  • see https://tex.stackexchange.com/a/39020/2388 for info about \floatpagefraction and floats in general. – Ulrike Fischer Aug 21 '21 at 08:34
  • 1
    The pis mandatory? That way, any possible good position at top, bottom or within the text in pages of text is lost. BTW, we cannot reproduce your problem only because of the unknown class, but also because of the unknown example image. The mwe package provides several examples images, use one of these, setting the width or height of the image to match the size of your own image, and test that the example still show the problem. – Fran Aug 21 '21 at 14:11
  • 1
    \afterpage{\clearpage} (afterpage package) should do the trick. It actually works on columns, not pages. – John Kormylo Aug 21 '21 at 15:25
  • @David @Ulrike @Fran @John Thank you for these ideas. Adding \renewcommand{\floatpagefraction}{0.4} before \begin{document} worked for my MWE. A smaller value than 0.4 can also be used, but do see David's comment. – SapereAude Aug 21 '21 at 19:51
  • @John Adding \usepackage{afterpage} to the preamble and \afterpage{\clearpage} just before \begin{figure}[!p] also works for my MWE. Thanks. – SapereAude Aug 21 '21 at 20:24

2 Answers2

1

The p alternative means "push the float to a separate page, if needed", and an overlarge float will push all that follow to the end. LaTeX tries not to have too much of the page dedicated to floats.

  • Reduce/split the large floats so they fit the page.
  • Reorder text/floats, to get the float to fit into the page. Perhaps rewrite the surrounding text to make it fit, shorten long captions.
  • You should reference them by number, not "the next figure", you can include them early in the source if it helps placing.
  • Consider not using p, there are even (somewhat dirty) ways to force a float to be placed here.
vonbrand
  • 5,473
  • Thanks for attempting an answer. However the problem is not an overly large float, but an overly small float. Additionally, I am seeking a direct and insightful solution of the sort offered in the comments above, rather than alternatives like "Consider not using p,..." – SapereAude Aug 21 '21 at 20:14
  • 2
    @SapereAude, use of the p placement is not intended for small tables. For them you should use some combination of h, t , b. – Zarko Sep 21 '21 at 05:47
0

Try this one, please.

\documentclass[a4paper,14pt]{extreport}

\usepackage{lipsum} \usepackage{graphicx}

\begin{document}

\lipsum[1-3]

\begin{figure}[h!] \includegraphics{example-image-a.pdf} \caption{ \lipsum[1][1-2] %\lipsum[1][1] } \end{figure}

\lipsum[1-3]

\end{document}

WinnieNotThePooh
  • 3,008
  • 1
  • 7
  • 14