# Position two floats on opposing pages [duplicate]

I have some big body of text with a figure within it, and another figure that requires a full float page (I use \begin{figure}[p]).

The two figures relate to one another, and should really be viewed at once.

Luckily, the document will be produced double-sided.

Can I guarantee that the two floats will face one another (that is be on opposing left- and right- pages) and forbid LaTeX from positioning them back-to-back or even farther apart (so that you annoyingly have to turn a page back and forth to look at both figures)?

## marked as duplicate by krlmlr, Mico, Svend Tveskæg, Seamus, John KormyloMar 7 '16 at 18:01

• Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – jub0bs Mar 23 '13 at 23:40

You can simplify your life -- or, at least, your typesetting chores -- in your case by using the afterpage package and its \afterpage command, as is shown in the example code below. The only thing that isn't automated fully is this: you need to ensure manually that the two floats are placed on even/odd pages rather than odd/even pages.

\documentclass{book}
\usepackage[margin=1in]{geometry}
\newcommand\bigrectangle{\rule{12cm}{20cm}} % dummy "figure"
\usepackage{lipsum}                         % filler text
\usepackage{afterpage}
\begin{document}
\lipsum[1-5]
\hrule % to indicate start of "afterpage" material

% be sure the following material is placed on a "recto" (odd-numbered) page:
\afterpage{%
\clearpage % flush any pending floats

\begin{figure}[p]
\centering
\bigrectangle
\caption{First (verso) figure}
\end{figure}
\clearpage

\begin{figure}[p]
\centering
\bigrectangle
\caption{Second (recto) figure}
\end{figure}
\clearpage % force-flush the second figure as well
} % end of "afterpage" material

\lipsum[6-15]  % more filler text: fill rest of p. 1, then continue on p. 4

\end{document}


** Addendum**: If you want only one of the two floats to take up an entire page, while the second float should be top-aligned and allow some text below it, you could proceed as follows:

• First, insert an instruction such as

\renewcommand\topfraction{0.9}


in the preamble. The default value of this parameter is 0.7; this may cause difficulties should the smaller of the two figure take up, say, 72% of the available text height.

• Second, use code along the following lines (where it's assumed that \smallrectangle is defined as \rule{12cm}{8cm}; obviously, you'll need to replace that with an actual graph...):

\afterpage{%
\begin{figure}[p]
\centering
\bigrectangle
\caption{First (verso) figure}
\end{figure}
\clearpage % flush the first float

\begin{figure}[t!]
\centering
\smallrectangle
\caption{Second (recto) figure}
\end{figure}
} % end of "afterpage" material

• This is almost what I want! Imagine though in the preamble there were \newcommand\smallrectangle{\rule{12cm}{8cm}} and one of the two figures were \smallrectangle (and had [tbp] as the float option). Then it looks really silly without the text flowing around it! – evanb Mar 24 '13 at 14:43
• @evanb - Please see the addendum I've just posted. – Mico Mar 24 '13 at 17:20
• thank you so much! I didn't know about \afterpage, and a quick googling of "latex afterpage verso" led me to this similar discussion on comp.text.tex, which presents a similar solution, but also points to the dpfloat package. – evanb Mar 24 '13 at 19:15
• @evanb - Thanks for this pointer to the dpfloat package; I wasn't even aware of its existence. – Mico Mar 24 '13 at 19:49

If you put the two floats together in the source, LaTeX won't drift them apart as if the conditions are right for the first to be placed on a float page, the second will be put on a float page before latex starts looking for more text.

However you can't, using the standard tools, control whether the first comes on an odd or even page. It's possible to patch the output routine to control that, but generally doing that is a bit fragile, depending on what other packages you have loaded, and so it is usually simpler to wait until the document is almost done, and then just move the pair of floats forwards or backwards in the source to make them appear on a spread.

OK so this redefines things such that p floats can only appear on even pages, but ph floats have no restrictions so if you have p followed by ph they should float to the next spread (pages 4/5 here)

\documentclass[twoside]{article}

\gdef\floatpagefraction{\ifodd\count0 1.5\else .5\fi}

\makeatletter
\def\@ytryfc #1{%
\begingroup
\gdef\@flsucceed{\@elt #1}%
\global\let\@flfail\@empty
\@tempdima\ht #1%
\let\@elt\@ztryfc
\@trylist
\ifodd\count#1\@fpmin\z@\fi
\ifdim \@tempdima >\@fpmin
\else
\@cons\@failedlist #1%
\fi
\endgroup
\let\@elt\@gobble
\fi}
\makeatother

\def\a{One two three four five six seven eight nine ten. }
\def\b{\a\a Red yellow blue green black white. }
\def\c{\b\b\a\a\a\b\par\b\b\a\a\a\b\b\b\b\b}

\begin{document}

titlepage\thispagestyle{empty}
\clearpage
\pagenumbering{roman}

\c\c\c\c
\begin{figure}[p]
\rule{3pt}{.7\textheight}LLL
\write20{L: \thepage}
\end{figure}
\begin{figure}[ph]
R\rule{3pt}{.7\textheight}
\write20{R: \thepage}
\end{figure}
\c\a\a\c\c\c\c\c

\end{document}

• Hi David! As Mico and I discuss in the other solution, the dpfloat package actually does exactly what I ask! I actually have a question about your answer, though: Is it generally allowed to set quantities like \floatpagefraction with a function (and not a hard-set value)? This seems very useful. – evanb Mar 24 '13 at 20:00
• @evanb I just looked at the dpfloat package: it is doing the same as this except arranging the hooks differently. The floatpagefraction definition was because I hoped to not hook into any output routine internals but while that worked for getting the first on an even page I couldn't then get the second on an odd page without the internal definition anyway. Is it allowed? well I did check every use of floatpagefraction in the core distribution and all such uses work for an expandable definition. Of course timing is crucial because these things don't always get expanded when you expect – David Carlisle Mar 24 '13 at 20:28