Consider the following MWE - let's say it's called test.tex
:
\batchmode %
\ifx\article\undefined %
\documentclass[12pt,journal,onecolumn,twoside,draftcls,letterpaper]{IEEEtran} %
\else %
\documentclass{article} %
\fi
\usepackage{xcolor} % \pagecolor
\pagecolor{yellow!15}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\begin{document}
\lipsum[1-6] HERE1
\begin{figure}[p]
\includegraphics[width=0.9\textwidth,height=0.9\textheight]{demo.png}
\caption{Demo figure One}
\label{fig:one}
\end{figure}
\lipsum[7-9] HERE2
\begin{figure}[p]
\includegraphics[width=0.9\textwidth,height=0.9\textheight]{demo.png}
\caption{Demo figure Two}
\label{fig:two}
\end{figure}
\lipsum[9-13]
\errorstopmode % if in batchmode, this will allow print of just the number of output pages and such
\end{document}
You can compile this using the following bash
one-liner:
for ix in "article" "ieeetran" ; do \
cmd="pdflatex -jobname test-$ix \"\def\\$ix{}\input{test.tex}\""; \
echo "$cmd" ; \
eval "$cmd" ; \
done
... or directly:
pdflatex -jobname test-article "\def\article{}\input{test.tex}"
pdflatex -jobname test-ieeetran "\def\ieeetran{}\input{test.tex}"
This will generate two pdfs - with contents from page 2 to 5 shown below (click for full-size):
So, this is what I want to do: if the first figure (fig:one) is first encountered at page current_page
; then schedule fig:one (as it is a full-page [p]
float) to appear on page current_page+1
; and schedule fig:two to appear on page current_page+3
-- that is, have a page of text between these two floats, so they're both either on even or on odd pages.
Now, here, that clearly happened for test-ieeetran.pdf
, because the start and end of \lipsum[7-9]
happen to be on different pages (as indicated by "HERE1" and "HERE2") - so the algo naturally schedules the floats for the next page after encountering them.
But for test-article.pdf
, that didn't happen, and the floats are right one after another; clearly, that's because the in-between text \lipsum[7-9]
fits entirely on the same page (2); so the algo will encounter both floats on the same page (given that when it encounters them, it defers them for later, and keeps on typesetting text); schedule them both to the next page (3); and seeing they cannot fit both on page 3, it will push fig:two to the page after that (4). I think that because of this (floats seen both on the same page), none of the tricks like \afterpage{\clearpage}
or \FloatBarrier
worked when I experimented with them in this case.
So, to keep the question general: is there a way to schedule floats to appear on specific pages later - regardless of, if the current document class would see them both as on same page, or not?