2

Consider this example:

\documentclass{report}
%\usepackage{float}                                                                                                                                                                                         
\usepackage{lipsum}
\usepackage{graphicx}
\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother
\begin{document}
\lipsum[1-5]

\begin{figure}[htb]
  \centering
  \includegraphics[height=0.8\textheight, width=0.8\textwidth]{example-image-a}
\end{figure}

\begin{figure}[htb]
  \centering
  \includegraphics{example-image-c}
\end{figure}

\end{document}

The output is:

enter image description here

I have followed How to place a float at the top of a floats-only page? to force the "C" image to top of page. However, I do not want this setting to affect the "A" image. How can I force floats to top of page selectively?

At some point I would be interested to unset this setting for subsequent floats. I am checking @DavidCarlisle 's answer and trying to unset this setting using \clearpage:

\documentclass{report}
%\usepackage{float}                                                                                                                                                                                         
\usepackage{lipsum}
\usepackage{graphicx}

\begin{document}
\lipsum[1-5]

\begin{figure}[htbp]
  \centering
  \includegraphics[height=0.8\textheight, width=0.8\textwidth]{example-image-a}
\end{figure}
\clearpage
  \makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{figure}[htbp]
  \centering
  \includegraphics{example-image-c}
\end{figure}
\clearpage

\begin{figure}[htbp]
  \centering
  \includegraphics{example-image-b}
\end{figure}

\end{document}

From the output it can be seen that I have been unsuccessful at unsetting the setting for the "B" image:

enter image description here

What is wrong?

Viesturs
  • 7,895
  • you are preventing float pages by omitting p from the optional argument so the figures can not be positioned at all, then finally at the end of the document they are all forced on to float pages via \clearpage as an emergency fix to stop them being lost. If you want them on float pages why use [htb] which is designed to prevent that? – David Carlisle Apr 20 '19 at 19:55
  • @DavidCarlisle, I observed that using p caused creation of pages for a single image. Instead I want my document to be more compact with text wrapping images. – Viesturs Apr 20 '19 at 19:58
  • You are specifying unachievable constraints so forcing all the floats to the end of the document. – David Carlisle Apr 20 '19 at 20:00
  • @DavidCarlisle I am more pleased with floats forced to the end rather than a float floating alone on an entire page. – Viesturs Apr 20 '19 at 20:01
  • But this entire question is about float pages that have just floats not text. – David Carlisle Apr 20 '19 at 20:02
  • I don't see that you are "unsuccessfull" at resetting it, there is no resetting at all, you set fp@top to 0pt force a float to be set with that via \clearpage then never set it back so naturally it applies for the rest of the document. – David Carlisle Apr 23 '19 at 08:43

1 Answers1

2

You can change \@fptop at any point to change the way float pages are set out, but all the pages handled by a single \clearpage will use the same layout. As you are using the optional argument to prevent any setting of the figures they are all going to the end and being forced by the implicit \clearpage at \end{document} so to use different setting, use \clearpage after the float A then set \@fptop to 0pt before float C is handled.

\documentclass{report}
%\usepackage{float}                                                                                                                                                                                         
\usepackage{lipsum}
\usepackage{graphicx}

\begin{document}
\lipsum[1-5]

\begin{figure}[tb]
  \centering
  \includegraphics[height=0.8\textheight, width=0.8\textwidth]{example-image-a}
\end{figure}
\clearpage
\makeatletter
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{figure}[tb]
  \centering
  \includegraphics{example-image-c}
\end{figure}
\clearpage
\makeatletter
\setlength{\@fptop}{0pt plus 1fil}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother

\begin{figure}[tb]
  \centering
  \includegraphics{example-image-b}
\end{figure}

\end{document}

enter image description here

David Carlisle
  • 757,742