2

I have a formatting requirement for my thesis where all figures must appear after the page they are first mentioned, and separate of any text. If multiple figures are mentioned on the page they can follow on separate pages. So if I mention 3 figures on a page for the first time, the next 3 pages will be the figures. I am having an issue getting this to format correctly. I can't perform a \clearpage because I can not have a page that is mostly empty, the pages must remain full. I have tried \begin{figure}[p!] and while that groups the figures how I want them to, it does not place them on in the correct location.

Clay
  • 29

4 Answers4

5

The flafter package (in the base latex distribution) will prevent floats floating "backwards" to the top of the current page. So if you put the figure source at the point of the first reference to the figure then your requirement should be met.

David Carlisle
  • 757,742
4

\begin{figure}[p!] should work, but you will then have to redefine \floatpagefraction so that small figures can be on a float page of their own (it defines the minimum part of the page that need to be occupied by floats to be allowed to form a float page.)

\documentclass{article}
\usepackage{lipsum}
\renewcommand\floatpagefraction{0} %default 0.5
\begin{document}
abc

\begin{figure}[!p] FIGURE \end{figure}

\lipsum \lipsum \end{document}

Ulrike Fischer
  • 327,261
  • You can also force a figure to take up an entire page using \parbox[c][\textheight][c]{...} or a minipage with the same optional arguments (inside the figure environment). – John Kormylo Jan 11 '21 at 15:02
1

This example does what you ask, but you would have to put it into context in order to say it is a general solution.

\documentclass{article}
\usepackage{lipsum}
\usepackage{afterpage}
\usepackage{color}
\usepackage[demo]{graphicx}
%------------------------------------------------
% Inspired by:
% https://tex.stackexchange.com/a/334993/231952
\usepackage{environ}
\def\afterpagebody#1{%
  \afterpage{%%
    \begin{figure}
    \centering
    #1
    \end{figure}
  \clearpage
}}
\NewEnviron{myfigure}{%%
    \expandafter\afterpagebody\expandafter{\BODY}%%
}
%------------------------------------------------

\begin{document}

\section{A page with one figure}

\lipsum[1] \textcolor{red}{See figure \ref{fig1}}

\begin{myfigure} \includegraphics{test} \caption{}\label{fig1} \end{myfigure}

\lipsum[2-9]

\section{A page with three figures}

\lipsum[11] \textcolor{red}{See figure \ref{fig2}}

\begin{myfigure} \includegraphics{test} \caption{}\label{fig2} \end{myfigure}

\lipsum[11] \textcolor{red}{See figure \ref{fig3}}

\begin{myfigure} \includegraphics{test} \caption{}\label{fig3} \end{myfigure}

\lipsum[11] \textcolor{red}{See figure \ref{fig4}}

\begin{myfigure} \includegraphics{test} \caption{}\label{fig4} \end{myfigure}

\lipsum

\end{document}

Ivan
  • 4,368
  • you shouldn't have to put a float into afterpage. The while point of the floating mechanism is to allow the figure to move. – David Carlisle Jan 10 '21 at 22:49
0

You wrote,

all figures must appear after the page they are first mentioned, and separate of any text. If multiple figures are mentioned on the page they can follow on separate pages. ... I can't perform a \clearpage because I can not have a page that is mostly empty, the pages must remain full.

The afterpage package may be your friend.

\documentclass{article}
\usepackage{afterpage}
\begin{document}

As shown in Figures \ref{fig:xxx}, \ref{fig:yyy}, and \ref{fig:zzz}, \dots % right after the end of this paragraph: \afterpage{% \begin{figure}[p] \caption{xxx} \label{fig:xxx} \end{figure} \clearpage \begin{figure}[p] \caption{xxx} \label{fig:yyy} \end{figure} \clearpage \begin{figure}[p] \caption{xxx} \label{fig:zzz} \end{figure} } % end of scope of \afterpage directive

\dots % remainder of document \end{document}

Mico
  • 506,678