[Tex/LaTex] pdfpages / pdfbook for odd sizes paper

pdfbookpdfpagespdftex

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.

Diagram of the problem and desired solution

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.

Best Answer

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
\advance\counter by 1
\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}

input file: original book

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}

byproduct of the algorithm

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
\advance\counter by 1
\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}

the final PDF ready to be printed