chrisphan.com

Producing booklets from the command line

An analog clock reading 10:00 2025-07-28 / 2025-W31-1T22:00:00-05:00 / 0x68883930

Categories: programming, computers, LaTeX

I’m writing this mostly for my own future reference, but perhaps it will be useful to someone else.

Today, I wanted to print out a PDF so that I could turn it into a booklet by folding the pages in half and stapling in the middle. The pages need to be in a different order. Suppose you have a PDF with \(n\) pages, numbered 0 through \(n - 1\). Then the first sheet out of your printer should have pages \(n - 1\) and 0 on one side, and pages 1 and \(n - 2\) on the other. The next sheet should have pages \(n - 3\) and 2 on one side and pages 3 and \(n - 4\) on the other, and so on.

At first, I considered manually rearranging the pages in the macOS Preview app. But this would be time-consuming and I wanted to have a script I could use in the future. I briefly considered writing my own program to achieve this, before thinking to myself “This has to be a solved problem.”

Indeed, it was. After a few seconds using a search engine1, I found a some instructions from a Philadelphia-based zine publisher named Iffy Books. The guide points to the program pdfbook2. This program is included in many TeX distributions and was already on my machine.

When you go to print your booklet, be sure to print double-sided with short-edge binding.

  1. I tend to use the same search engine as alternate-timeline James T. Kirk.