# Combining \includepdf with {sidewaysfigure} environment

Dear fellow TeXnocrats,

I wonder if it is possible to combine the sidewaysfigure package with \includepdf to the effect that every odd page of a multi-page pdf is turned 90° and every even page turned -90°. I would like to avoid to have to load each page separately.

The current code does not produce any PDFs to be included in the main document:

begin{sidewaysfigure}
\centering
\includepdf[pages=-,width=1.2\textwidth,pagecommand={}]{Back/msappendixprints/kaplain/kaplain}
\end{sidewaysfigure}


By itself, the \includepdf ... segment works fine, but not inside the sidewaysfigure environment.

Help would be appreciated. Kindly!

• Please post a compile document or at least the document code that has this issue – user31729 May 6 '17 at 9:59
• why sidewaysfigure is necessary? you can get what you want without it. – touhami May 6 '17 at 11:00
• No. sidewaysfigure is a one-page float. You can't use if for multipage content. – Ulrike Fischer May 6 '17 at 11:06

Here is a solution. The idea is to define

\newcommand*\side{90}


and then use

\includepdf[pages=-,width=1.2\textwidth,pagecommand={\xdef\side{\the\numexpr-\side\relax}},angle=\side]{myfile}


MWE

\documentclass{book}
\usepackage{pdfpages}

\newcommand*\side{}

\newcommand*\includorientedpdf[1]{%
\ifodd\value{page}%           % or another check like \isodd
\renewcommand*\side{90}%      % or -90
\else
\renewcommand*\side{-90}%
\fi
\includepdf[pages=-,width=1.2\textwidth,pagecommand={\xdef\side{\the\numexpr-\side\relax}},angle=\side]{#1}}

\begin{document}
\includorientedpdf{myfile}
\end{document}