How to merge odd and even pages together in a PDF with LaTeX
A short post to describe my last LaTeX creation: a template file that allows to merge odd and even pages together, considering also the case of the reversed even pages. As usual there is a little edit area that make the process very fast, without requiring any knowledge of LaTeX and if you have a subscription in an online editor like Overleaf you can execute it in your internet browser.
Recently I have bought a multifunction printer that doesn't support the duplex scanning in the automatic document feeder and so I can only scan a single side of a sheet of paper at a time. At the end I have two PDF files that I will have to merge into one.
The first file contains the odd pages and the second one the reversed even pages (or ordered if I arrange again the order before to give them in the scanner, but I hate doing this). As usual there are many software that can help the merging process (look my article Free software to edit PDF for example) but I decided to use LaTeX in this case because I like complicate things for myself!
Requirements
- Out of the box with Overleaf[fn]Overleaf is the new collaborative writing and publishing system developed by the team behind the popular writeLaTeX editor. Overleaf is designed to make the whole process of writing, editing and producing scientific papers much quicker for both authors and publishers. Overleaf: Real-time Collaborative Writing and Publishing Tools with Integrated PDF Preview. Here is my sign up link to Overleaf.[/fn], but a registration is needed in order to upload the PDF files and to edit my template.
- If you want to use it in your computer: LaTeX, an editor and the following packages: mathptmx, moresize, comment, ifthen, and pdfpages (almost standard in a typical LaTeX installation).
How it works
The entire process can be summarized with the two infographics below and the following piece of code that you have to edit in order to get the final merged PDF.
% <---------------------- EDIT THIS AREA ONLY -----------------------------> %% %% Define the file names and the dimension of your PDF %% Put the size in mm %% The typical size of an A4 document is 210x297 mm %% \newcommand\units{mm} % <--- set the units (default mm) \newcommand\fileOdd{odd.pdf} % <--- the PDF that contains odd pages \newcommand\fileEven{even_rev.pdf} % <--- the PDF that contains even pages \newcommand\width{210} % <--- the width size in mm of your PDF \newcommand\height{297} % <--- the height size in mm of your PDF %% %% Are reversed the even pages? \newcommand\reversed{1} % <--- "1" YES, "0" NO %% %% How many pages do you want to process? \newcommand\numberPages{3} % <--- the numbers of pages to process %% % <---------------------- EDIT THIS AREA ONLY ----------------------------->
Editing the area above, you control all the process to merge your two input PDF files.
Download
You can find and download my template in Overleaf and GitHub at these following links:
- Overleaf (read only link): How to merge a PDF split in odd and even pages
Add new comment