2

I have two floats. I would like to place them on top of two pages facing each other in a double sided document.

The following example works well already, however, it does not allow text under the floats.

Does anyone have an idea on how to solve this, so that there will also be text under the floats?

\documentclass{book}
\usepackage[margin=1in]{geometry}
\newcommand\smallrectangle{\rule{12cm}{12cm}}
\usepackage{lipsum}                         % filler text
\usepackage{afterpage}

\begin{document}
\lipsum[1-5]
\hrule % to indicate start of "afterpage" material

\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}[t!]
\centering
\smallrectangle
\caption{First (verso) figure}
\end{figure}
\clearpage

\begin{figure}[t!]
\centering
\smallrectangle
\caption{Second (recto) figure}
\end{figure}
\clearpage % force-flush the second figure as well
} 
}

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

\end{document} 

1 Answer 1

1

Why clear the page after the first image? If you don't then all is well.

\documentclass{book}
\usepackage[margin=1in]{geometry}
\newcommand\smallrectangle{\rule{12cm}{12cm}}
\usepackage{lipsum}                         % filler text
\usepackage{afterpage}

\begin{document}
    \lipsum[1-5]
    \hrule % to indicate start of "afterpage" material

    \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}[t!]
                \centering
                \smallrectangle
                \caption{First (verso) figure}
            \end{figure}




            \begin{figure}[t!]
                \centering
                \smallrectangle
                \caption{Second (recto) figure}
            \end{figure}
             % force-flush the second figure as well
        } 
    }

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

\end{document} 
1
  • Yes, you are quite right. I forgot to comment that out. Also this is not a good MWE because it does not replicate the error I get (text overlaps on the first page). I have been working for hours on a MWE on this issue now, but I can't really get break it down...
    – Mil
    Commented Aug 19, 2016 at 6:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .