# Printing a double-sided A5 document on A4 paper

I have a doubled-sided A5 landscape document with the following page order:

As my printer supports only A4 paper, I want to print two of these pages on one portrait A4 paper so that I can cut it in half to get sheets of the original size. In other words, what I need is the following page layout:

(The line separating the two pages is for demonstration purposes only, it is not part of the final result.)

How can I achieve this layout with pdfpages?

The "naive" approach

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages=-,nup=1x2]{a5-document}
\end{document}


yields

so the front and back side of each page are one the same side of the paper, instead of appearing on opposite faces.

At the moment, I'm using the following manual solution, which is quite tedious and error-prone, especially for large documents:

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={1,3,2,4,5,7,6,8,...},nup=1x2]{a5-document}
\end{document}

-
Do you need a latex-solution? I think the using of pdftk in combination with a small script is also possible. –  Marco Daniel Nov 29 '11 at 18:46
Isn't \includepdf[pages=-,signature=4,landscape]{doc} what you're looking for? –  egreg Nov 29 '11 at 18:47
@MarcoDaniel A pdftk solution would also be acceptable. –  diabonas Nov 29 '11 at 19:22
@egreg With \includepdf[pages=-,signature=4,landscape]{doc}, the pages are placed at the correct position. They are, however, shrunk and rotated by 90 degrees (see the attached image). –  diabonas Nov 29 '11 at 19:29
@diabonas: try with \includepdf[pages=-,signature=4]{doc}. I guess it'll work. :) –  Paulo Cereda Nov 29 '11 at 19:42

Here is a way how to do this in ConTeXt:

\setuppagenumbering [location=]

\setuppapersize [A5, landscape] [A4]
\setuparranging [2TOPSIDE]

\starttext
\dorecurse{8}{%
\centerline{\definedfont[Serif at 256pt]\recurselevel}\page}
\stoptext


The result looks like this:

The \setuppapersize command states, that you want to write an A5 landscape document that should be printed on an A4 paper. \setuparranging is used to arrange the pages in the way you wish. Many more schemes are possible.

-
Pretty cool :-) Is there some way to include my existing document (which is written in LaTeX, but not in ConTeXt) with something like pdfpages, or do I have to rewrite it using ConTeXt? –  diabonas Nov 29 '11 at 19:54
You can use \insertpages or e.g. \externalfigure. See include pages from PDF document –  Marco Nov 29 '11 at 20:18
Great! I used \insertpages[a5-document.pdf] and I added \setuplayout[backspace=0pt,topspace=0pt,width=middle,height=middle,location=mid‌​dle,header=0pt,footer=0pt] as described on Imposition to make the included pages full width. Thank you very much! (I'll wait some time before I accept your answer.) –  diabonas Nov 29 '11 at 20:31
BTW: Your code is missing a }. –  diabonas Nov 29 '11 at 20:32
@diabonas It's these dwarfs again! They wander around random poeples' computer and eat innocent braces. Not they also discovered TeX.SE :( –  Marco Nov 29 '11 at 22:53

I was curious about an answer to this question, so a lot of search presented me with this great solution provided by Andreas Matthias, the author of pdfpages, posted in comp.text.tex. Since it has an interesting background, I'll provide the whole text, as it's fantastic.

Marked as community-wiki for obvious reasons. :)

Text from Andreas:

pdfpages imposes the pages such that they should be turned over the long edge (while printing), whereas with psnup they should be turned over the short edge. In Postscript this is called /Tumble which can be set to true or false.

Today all duplex printer should be able to do printing in short edge mode as well as long edge mode. So this shouldn't be a big issue.

However, if you like short edge printing more you can direct pdftex (xetex) to rotate every second page. Here's an example:

\documentclass[a4paper,final]{article}
\usepackage{pdfpages}
\usepackage{ifpdf,ifxetex}
\makeatletter
\ifpdf
\EveryShipout{\ifodd\c@page\else\pdfpageattr{/Rotate 180}\fi}%
\fi
\ifxetex
\EveryShipout{\ifodd\c@page\special{pdf: put @thispage << /Rotate 180 >>}%
\fi
}

\fi
\makeatother

\begin{document}
\includepdf[pages=-, nup=1x2, booklet=true, landscape]{a5.pdf}
\end{document}


[...]

Ciao

Andreas

Note: \EveryShipout is provided by the everyshi package. :)

Thanks to Andreas and this awesome code, I think the following code will help you:

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\usepackage{ifpdf,ifxetex,everyshi}
\makeatletter
\ifpdf
\EveryShipout{\ifodd\c@page\else\pdfpageattr{/Rotate 180}\fi}%
\fi
\ifxetex
\EveryShipout{\ifodd\c@page\special{pdf: put @thispage << /Rotate 180 >>}%
\fi
}

\fi
\makeatother

\begin{document}
\includepdf[pages=-,signature=4,angle=180]{a5-document}
\end{document}


Now I'm sure I know nothing about the ways of the TeX force. :)

-
The trick how to rotate pages is really great! The problem in this context, however, is that the page is rotated as a whole. This leads to a wrong placement of the pages, e.g. page 1 front on page 2 front instead of page 1 front on page 1 back (see the example output). To fix this, one would have to rotate the single A5 pages instead. I think this could be done by selectively rotating the pages of the original a5-document.pdf, but I think I'll go with Marco's answer as it is more straightforward :-) –  diabonas Dec 1 '11 at 20:55