2

This question is kind of close: pdfpages rotate odd pages 180º but, what I'm trying to achieve is different: I actually want 4 pages per page, i.e. nup=2x2, but I want the top two to be rotated 180 degrees.

I've read the documentation of pdfpages, but there doesn't seem to be a way to apply transformation to individual pages. I also tried to include pages one-by-one, and then rotate the ones I need, but, unfortunately, pdfpages puts them each on its own page, and I don't see a way to override this behavior.

The example layout I'm trying to achieve (for a booklet that is 8 pages long, printed on two sides):

| 1 | 8 |
|---|---|
| 4 | 5 |

| 3 | 6 |
|---|---|
| 2 | 7 |

Pages 1, 8, 3, 6 need to be rotated 180 degrees.

(Unfortunately, my printer doesn't allow me specifying this kind of layout in the settings dialog, so I need to craft this by hand).

PS. I tagged this "graphics" because another approach I tried was to use includegraphics, but I couldn't figure out a way to extract pages from the PDF I have.

Here's my minimal example:

\documentclass{article}
\usepackage{pdfpages}
\begin{document}

%% signature=8,landscape
\includepdf[pages={1-8},nup=2x2]{booklet.pdf}

\end{document}

booklet.pdf can be any PDF with at least 8 pages.

PPS. The resulting page needs to be a portrait: it is first folded on the long side, and then on the short side, but the order of folding can be changed, if you want to make it horizontal.


I kind of almost made it work like this:

\documentclass{article}
\usepackage{graphicx}
\usepackage[a4paper, margin=0pt]{geometry}

\begin{document}

\begin{picture}(595,842)(18,0)
  \put(0,842){\includegraphics[page=1,angle=180]{booklet.pdf}}
  \put(298,842){\includegraphics[page=8,angle=180]{booklet.pdf}}
  \put(0,0){\includegraphics[page=4]{booklet.pdf}}
  \put(298,0){\includegraphics[page=5]{booklet.pdf}}
\end{picture}

\end{document}

Things I don't understand is: why do I need to move the picture 18 points to the left, in order for it to fit the paper exactly.

  • 1
    have you tried \noindent\begin{picture}... – user4686 Sep 28 '18 at 13:46
  • @jfbu yeah, that was it! – wvxvw Sep 28 '18 at 13:49
  • should'nt it be 845, not 842? recall that TeX points are smaller than postscript point – user4686 Sep 28 '18 at 13:50
  • @jfbu hm... that I wouldn't know. I don't know which points Google uses when it translates between centimeters and points... Once I'm on some computer with Adobe Pagemaker / QuarkXPress, I'll know a definitive answer. – wvxvw Sep 28 '18 at 13:52
  • 1
    This is probably is due to 842bp being 845.15749pt and the actual page height being 845.04684pt (TeX rounding). In a4paper the paperheight in Postscript points is not 842 but about 841.88975bp. It fits with \begin{picture}(298,841.89) and before that \setlength{\unitlength}{1bp}. Better would be to use TeX points probably. – user4686 Sep 28 '18 at 14:03
2

No need for picture, just pack them in. (I used test5 instead of booklet.)

\documentclass{article}
\usepackage{graphicx}
\usepackage[a4paper, margin=0pt]{geometry}
\parindent=0pt
\lineskip=0pt

\newcommand{\filename}{test5}

\begin{document}
  \includegraphics[page=1,angle=180,scale=0.5]{\filename}%
  \includegraphics[page=8,angle=180,scale=0.5]{\filename}\\
  \includegraphics[page=4,scale=0.5]{\filename}%
  \includegraphics[page=5,scale=0.5]{\filename}
\end{document}

You can also use the following. The minipage prevents a pagebreak.

\documentclass{article}
\usepackage{graphicx}
\usepackage[a4paper, margin=0pt]{geometry}
\parindent=0pt
\lineskip=0pt

\newcommand{\filename}{test5}

\begin{document}
\begin{minipage}{\textwidth}
  \includegraphics[page=1,width=0.5\textwidth,height=0.5\textheight,angle=180]{\filename}%
  \includegraphics[page=8,width=0.5\textwidth,height=0.5\textheight,angle=180]{\filename}
  \includegraphics[page=4,width=0.5\textwidth,height=0.5\textheight]{\filename}%
  \includegraphics[page=5,width=0.5\textwidth,height=0.5\textheight]{\filename}
\end{minipage}
\end{document}
2

I'm not quite sure I correctly understood the wanted layout, but here a suggestion:

\documentclass[[a4paper]{article}
\usepackage{pdfpages,expl3}

\ExplSyntaxOn
\makeatletter 
\newcommand\myangle{
 \bool_if:nTF 
  {
   \int_compare_p:n { \AM@page = 1 } ||
   \int_compare_p:n { \AM@page = 8 } ||
   \int_compare_p:n { \AM@page = 3 } ||
   \int_compare_p:n { \AM@page = 6 } 
  }
  { 180 }
  {  0  }
 } 
\ExplSyntaxOff
\begin{document}


\includepdf[pages={1,8,4,5,3,6,2,7}, % order
            nup=2x2,
            angle=\myangle]{example-image-a4-numbered}

\end{document}

enter image description here

  • Thanks, this is cool, a bit too advanced for me though. – wvxvw Sep 28 '18 at 17:45

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.