# pdfpages / pdfbook for odd sizes paper

I have a book typeset with pages of 105mm x 180mm

This needs to made into a booklet, in signatures, such that it prints on A4 portrait paper, with the original book pages side by side. (i.e. 105mm + 105mm = 210mm, so it should fit)

If I use pdfpages (or the pdfbook shell script) I get them laid out side by side on landscape paper. If I tell it no-landscape, it puts them above one another, in such a way that rotating them with angle=90 doesn't help.

I need them laid out side by side on portrait paper because of paper-grain in the printing.

No combination of angle=90, landscape=true or false, or noautoscale with an explicit output papersize seems to work.

It seems like pdfpages, looks at the output paper size when signature is set, and decides to use either 2x1 or 1x2 for its nup, in such a way you can't override it.

So is this possible, without manually calculating the signature solution and just explicitly importing the content page by page?

NB: I don't care if the resulting PDF is portrait or landscape, because that is trivial to rotate when printing, I care about the relative orientation of the logical pages relative to the physical page.

I'm using two or even more steps with the pdfpages package to get a printable PDF. Let me demonstrate it on a simple example.

• First, let's prepare a 105x180 mm book with 16 pages, an original format. This is the input PDF file (*latex mal-a5.tex). Remove frame parameter in the real production.
• Second, we convert the obtained PDF file to a new one, landscape orientation, A4, signature = number of pages in PDF (*latex mal-a5toa4.tex). This is a byproduct. In production, we could get number of pages in the PDF file automatically. You can find examples here at TeX.SX (see e.g. https://tex.stackexchange.com/a/180947/48028 and https://tex.stackexchange.com/a/179247/48028, I used \pdfximage and \pdflastximagepages in pdflatex+lualatex and \XeTeXpdfpagecount in xelatex).
• Last, let's convert that new PDF file, simple rotation according to odd/even pages, portrait orientation, A4 (*latex mal-a4slides.tex). Let me hope it helps a bit. This should be the PDF file suitable for printing (portrait, two-side and long-edge printing).

I'm enclosing all three TeX files and a preview of the PDF files.

This is the mal-a5.tex file:

% *latex mal-a5.tex (twice)
\documentclass{article}
\paperwidth=105mm
\pdfpagewidth=\paperwidth
\paperheight=180mm
\pdfpageheight=\paperheight
\usepackage{tikz}

\begin{document}
\newcount\counter
\counter=0
\loop
\newpage
\begin{tikzpicture}[remember picture, overlay]
\node[font=\bfseries\Huge\sffamily, scale=10] at (current page) {\the\counter};
\end{tikzpicture}
\ifnum\counter<16\repeat
\end{document}


This is a byproduct, the mal-a5toa4.tex file:

% *latex mal-a5toa4.tex
\documentclass[a4paper,landscape]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[pages={-},noautoscale,signature=16,frame]{mal-a5.pdf}
\end{document}


This is the last file, the mal-a4sides.tex file.

% *latex mal-a4sides.tex
\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\newcount\counter \counter=0
\loop
\ifodd\counter
\includepdf[pages={\the\counter},noautoscale,angle=180]{mal-a5toa4.pdf}
\else
\includepdf[pages={\the\counter},noautoscale]{mal-a5toa4.pdf}
\fi
\ifnum\counter<8\repeat
\end{document}


• I can't see the difference between the two last files – touhami Mar 28 '15 at 8:47
• The paper is rotated (from landscape to portrait). If I didn't misread something in your question, this should be the wanted format. – Malipivo Mar 28 '15 at 8:51
• thanks i am not de OP. My english is bad but i think he want 105+105=210 here you still have 105+105<290 – touhami Mar 28 '15 at 9:02
• @touhami You are right, that's probably not the wanted output as my example fits the paper. I will wait for more details from the OP and rethink it. For now, I'm adding the noautoscale parameter to the middle TeX file. – Malipivo Mar 28 '15 at 9:08
• @Ian I gave it one more try. :-) – Malipivo Mar 28 '15 at 14:59

You can do just the signatures reordering using pdfbook. Note that this program is different and independent from pdfbook from the pdfjam package (and I'm one of its authors, and current maintainer.)

After you've used pdfbook to reorder the pages, I think you should be able to use pdfpages with options nup=2x1,landscape=false to generate the final PDF.

• My next step if there was no easy answer was to write a little script to do the signature-aware reordering, and then use nup as you say, so thank you, I think this looks like it will be the way forward, but I'll see if the other answer gets a one-shot result before accepting. – Ian Mar 28 '15 at 14:27

Malipivo's answer is a general one, using the pdfpages package.

You can also use the command line. Here's a solution

$pdfbook --short-edge --noautoscale true document.pdf$ pdfjam --noautoscale=true --no-landscape=true --suffix out document-book.pdf


The first command makes the booklet. The second then just imposes the booklet pages without scaling into the center of portrait pages.

### Note on Short vs. Long Edge

The --short-edge parameter to the first command requires the easyshi package. If you don't have this, and omit it, then the temporary booklet is configured for long-edge duplex (which is probably what you'd want if you were printing it at that stage), but then the change to portrait makes that into short-edge duplex (you may have an option for this in your printer driver, or you can do it manually, so you can probably print it that way, even though it is less common). Setting it so that the initial booklet is made short-edge duplex, means the final output is long-edge, as you'd expect.