22

I'm writing a two sided document (it will be printed as a book) and I've got two figures which takes up a whole page each. These two figures are related so I want them to be side by side in the resulting book, i.e. figure1 should be placed on an even page and figure2 should be placed on the following (odd) page.

Is there any way I can automatically achieve this?

This is how I'd like the resulting pages in the book to be:

|p2--------||p3--------|
|          ||          |
| Fig1     || Fig2     |
|          ||          |
|          ||          |
|(caption) ||(caption) |
|----------||----------|
Martin Scharrer
  • 262,582
Paul
  • 1,749

1 Answers1

20

This can be done using \afterpage similar to my more complex solution shown in How to include a picture over two pages, left part on left side, right on right (for books)?. Because the \afterpage code is processed directly after a page is written the page counter can be used directly without going over page labels as done by the ifoddpage package.

\documentclass{article}

\usepackage{afterpage}
\usepackage{mwe}% for the example only

\begin{document}

\blindtext\blindtext\blindtext
\blindtext\blindtext\blindtext

\afterpage{%
    \clearpage% flush all other floats
    \ifodd\value{page}
    %\else% uncomment this else to get odd/even instead of even/odd
        \expandafter\afterpage% put it on the next page if this one is odd
    \fi
    {%
    \begin{figure}[p]
        \includegraphics[width=\textwidth,height=.9\textheight]{example-image-a}%
        \caption{First image}\label{fig:first}
    \end{figure}
    \clearpage
    \begin{figure}[p]
        \includegraphics[width=\textwidth,height=.9\textheight]{example-image-b}%
        \caption{Second image}\label{fig:second}
    \end{figure}
    \clearpage
    }%
}

\blindtext\blindtext\blindtext
\blindtext\blindtext\blindtext

\end{document}

Result

Martin Scharrer
  • 262,582
  • 1
    Thank you very much, that is perfect! As pointed out in earlier comments it should start on an even page. I removed the line "\else" and it does as expected. – Paul May 13 '12 at 15:01
  • @Paul: Wonderful. I updated my answer to reflect this. – Martin Scharrer May 13 '12 at 15:07
  • 3
    Unfortunately, Martin's solution does not always work. As is stated in the afterpage package documentation, the command \afterpage can and will get confused when there are many floats around. Any ideas on how to make Martin's solution more robust? (feel free to add this as a comment to Martin's answer) – Herwig Peters Mar 04 '13 at 00:43