6

I'm trying to create a booklet with pdfpages. So far it's working, but I would like to tweak the page orientation to put all the spreads/pages "straight" (rotate odd pages 180º). I've tried different pdfpages options but nothing did the trick.

Right now I have this:

\documentclass[a4paper,landscape]{article}

\usepackage{pdfpages}

\begin{document}
    \includepdf[nup=2x1,pages=-,booklet,noautoscale,frame]{phi.pdf}
\end{document}

This is what I want to achieve:

Rotate odd images 180º

5

Here is a suggestion using a file step1.tex as intermediate file.

\documentclass[landscape]{article}
\usepackage{pgffor}
\usepackage{etoolbox}
\usepackage{pdfpages}

\usepackage{filecontents}
\begin{filecontents*}{\jobname-step1.tex}
\documentclass[a4paper,landscape]{article}
\usepackage{pdfpages}
\begin{document}
    \includepdf[nup=2x1,pages=-,booklet,noautoscale,frame]{phi.pdf}
\end{document}
\end{filecontents*}

\immediate\write18{pdflatex \jobname-step1}% compiles \jobname-step1.tex

\begin{document}
\pdfximage{\jobname-step1.pdf}% counts pages in \jobname-step1.pdf
\foreach \p in {1,...,\the\pdflastximagepages}{%
  \ifnumodd{\p}%
    {\includepdf[pages=\p,angle=180]{\jobname-step1}}%
    {\includepdf[pages=\p]{\jobname-step1}}%
}
\end{document}

Note that pdflatex --shell-escape is needed. Or you have to comment the line \immediate... and compile the file \jobname-step1 separatly.

0

Another solution is to make a local copy of pdfpages.sty and comment the following line:

\ifAM@sigrotate angle=180,\fi

(originally it has leading spaces).

You can also modify the pdfpages.sty (making, say, mypdfpages.sty) adding an option, which disables the line.

  • 1
    Welcome, it is never a good idea to chenge other peoples files. – Johannes_B Apr 23 '17 at 9:49
  • I meant a local copy. The only drawback is that the position of the odd pages is incorrect for double side printing. Another solution is rotating 180º of odd page in Adobe Acrobat or similar software, then the result is perfect. – Mike Golub Apr 25 '17 at 2:56
0

Here is a solution without any intermediate file nor patch to pdfpages.sty....

\documentclass[a4paper,landscape]{article}
\usepackage{pdfpages}
\usepackage{pgffor}
\usepackage{etoolbox}
\newcommand\mybooklet[2][]{
  \pdfximage{#2}% counts pages in ODF
  \pgfmathtruncatemacro\totalpages{\the\pdflastximagepages}
  \pgfmathtruncatemacro\halfpages{ceil(\totalpages/2)}%
  \ifnumodd{\totalpages}{%
    \includepdf[pages={{},1},nup=2x1,#1]{#2}%
    \foreach \pfirst[evaluate=\pfirst as \plast using int(\totalpages+2-\pfirst)]
    in {2,...,\halfpages}{%
      \ifnumodd{\pfirst}%
      {\includepdf[pages={\plast,\pfirst},nup=2x1,#1]{#2}}%
      {\includepdf[pages={\pfirst,\plast},nup=2x1,#1]{#2}}%
    }%
  }{%
    \foreach \pfirst[evaluate=\pfirst as \plast using int(\totalpages+1-\pfirst)]
    in {1,...,\halfpages}{%
      \ifnumodd{\pfirst}%
      {\includepdf[pages={\plast,\pfirst},nup=2x1,#1]{#2}}%
      {\includepdf[pages={\pfirst,\plast},nup=2x1,#1]{#2}}%
    }%
  }%
}
\begin{document}
\mybooklet[frame,noautoscale]{phi.pdf}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.