1

A couple of years ago, someone posted (https://tex.stackexchange.com/a/53366/2966) claiming

After scanning a book 2-up, you can use pdfpages and ifthen to split the pages in two and reassemble 1-up.

I have a PDF document “printed” 2-up, so that on each ANSI-A (8½″×11″) page there are two 5½″×8½″ pages I’d like to extract. How do I go about this?

I can do this manually by writing

\documentclass{minimal}
\usepackage[
  papersize={5.5in,8.5in},
  margin=0pt, ignoreall,
  ]{geometry}
\setlength{\parindent}{0pt}
\usepackage{pdfpages,graphicx}
\begin{document}
\includegraphics[viewport= 0 0 396 612, page=1]{two-up.pdf}
\includegraphics[viewport= 396 0 792 612, page=1]{two-up.pdf}
\includegraphics[viewport= 0 0 396 612, page=2]{two-up.pdf}
\includegraphics[viewport= 396 0 792 612, page=2]{two-up.pdf}
% etc.
\end{document}

but this is repetitive and error-prone. Is there a way to do this automatically for the entire book?

  • 1
    You can achieve this using the viewport option of the includegraphics command of the graphicx package. – JPi Feb 24 '19 at 10:54

1 Answers1

0

A loop is all that was needed, and the loop can even be initialized with the number of pages in the source document:

% …
\begin{document}
\count 254 = 1
\loop
  \includegraphics[viewport= 0 0 396 612, page=\count 254]{two-up.pdf}
  \includegraphics[viewport= 396 0 792 612, page=\count 254]{two-up.pdf}
\ifnum \count 254 < 100 %%% maximum page number
   \advance \count 254 by 1
\repeat
\end{document}

Thank you to Philip Taylor on the TeXhax mailing list.