I'm writing some kind of a notebook using \LaTeX. I have a lot of notes. (EDIT: Like, a lot. Almost one per day for the past couple years. They range from very short, single line, notes to very long ones including equations, figures, references, web links, etc.) In order not to recompile all notes whenever I add a new note (EDIT: I used to have a single tex file, but it was becoming too large, and compiling too slow), I now put them into separate folders (EDIT: e.g., YYYY/MM/DD/note.tex), compile only the new ones, and then merge the PDFs together using gs. (EDIT: I'm running "gs -dNOPAUSE -sDEVICE=pdfwrite -sOUTPUTFILE=Notebook.pdf -dBATCH "+full_filenames where I build full_filenames in python using os.walk.)

Everything is pretty smooth, but the merge is pretty slow. Is there a way to rapidly merge many PDFs together? (EDIT: I tried pdftk before, it's definitely faster, but the merged pdf is huge!)

EDIT: Another reason why I split the big notebook into many folders, is that I have a now a small handwriting device, so I also take notes manually now, and I would like to merge all pdfs, from LaTeX and the handwriting software, into a single pdf.

EDIT: Sorry for being sentimental, but thanks for the help guys, I really appreciate!

  • 1
    How are you merging them currently? And what operating system do you use? In Linux, pdftk pdf1 pdf2 ... pdfn cat output final-pdf could be a solution. – Jay Dec 16 '14 at 12:29
  • Have you considered the subfiles package? – darthbith Dec 16 '14 at 12:38
  • 1
    You can also use pdfpages. – user11232 Dec 16 '14 at 12:52
  • Moreover, have you read the whole Topic sub­docs in CTAN?. In general, merge PDF instead of the main document is a bad idea except for some simple notes as you lost most advantages of a main document (common toc, references, counters, headers, index, etc.). – Fran Dec 16 '14 at 18:12
  • @Fran With pdfpages you can set it up so that you at least get a ToC and headers. – cfr Dec 16 '14 at 23:09

As Harish suggested, the pdfpages package seems a good way to do it, when you don't want do use ghostscript.

The example below should give you a start for a main document. I don't know if it's more rapid than the solution you have now, but it's what I'd use.


\title{Some kind of a notebook}


Here is the introduction to \emph{some kind of notebook}.


Here's maybe some text in between.


And here might be some end-notes.

  • This method will only work when all the pages are of same size. If the pdf contains different page sizes then the page sizes will not be as it in the output – Santhosh Sep 15 '20 at 3:50
  • @SanthoshYedidi: No, this also works if the PDFs are of different size. Your PDF viewer should be able to cope with it easily. – Habi Sep 16 '20 at 19:49
  • Its not about pdf viewer, its about pdfpages. Check the documentation By default the first inserted page will be used as a template.This means that all further pages are scaled such that they match within the contour of this first page. – Santhosh Sep 17 '20 at 6:19
  • Sorry, I misunderstood you. Merging differently sized PDFs works, but - as you correctly state from the documentation - that the final output size is the same as the first inserted page. – Habi Sep 18 '20 at 12:21
  • As specified here it might be 'better' to use a non-LaTeX tool to merge differently sized PDFs, my preference is pdftk. – Habi Sep 18 '20 at 12:23

The canonical tool for this task is pdftk, which is available on most Linux distros out ouf the box, on MacOS via MacPorts/fink/homebrew, on Windows via cygwin or as a binary from https://www.pdflabs.com/tools/pdftk-the-pdf-toolkit/.

To concatenate all PDFs from a folder folder just write:

pdftk folder/*.pdf cat output binder.pdf

pdftk is a pretty powerful utility that also supports arbitrary merging (page-wise), encryption and meta-data handling.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.