This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Combine LaTeX docs into a single PDF

Project Description

This tool automates compiling LaTeX document collections (for working papers, proceedings, etc.) into a single combined PDF file using the pdfpages package.

Create an INI file giving the name and parts of your collection and build it with the latexpages command-line utility.

latexpages will start one parallel typesetting process per core for speedup.

As each part is typeset independently, this allows to combine documents that cannot be merged into a single master-document (use of incompatible packages/options, latex-dvips-ps2pdf vs. pdflatex, etc.).


This package runs under Python 2.7 and 3.3+, use pip to install:

$ pip install latexpages

The compilation requires a TeX distribution (e.g. TeX Live or MikTeX) and either latexmk or MikTeX’s texify utility being available on your system.

The optional automatic page numbering (see below) requires either the pdfinfo command-line utility (included in poppler-utils, miktex-poppler-bin, xpdf), or the pdftk command-line utility (both available cross-platform).


Create a working directory holding your plain-text INI file with the latexpages configuration. Put all your documents into subdirectories with the same name as the corresponding .tex file:


Note: the directory names cannot contain spaces.

Edit the INI file to configure the parts, their order and various other options:

name = MY_COLL
directory = _output

mainmatter =

The following will typeset all parts, copy their PDFs to the output directory, and combine them into a single PDF. By default, this also creates a 2-up version:

$ latexpages latexpages.ini

Check the example directory in the source distribution for a working complete example.


Check the usage of the latexpages command:

$ latexpages --help
usage: latexpages [-h] [--version] [-c {latexmk,texify}] [--keep]
                  [--only <part>] [--processes <n>]

Compiles and combines LaTeX docs into a single PDF file

positional arguments:
  filename             INI file configuring the parts and output options
                       (default: latexpages.ini in the current directory)

optional arguments:
  -h, --help           show this help message and exit
  --version            show program's version number and exit
  -c {latexmk,texify}  use or texify (default: guess from platform)
  --keep               keep combination document(s) and their auxiliary files
  --only <part>        compile the given part without combining
  --processes <n>      number of parallel processes (default: one per core)

Advanced options

Below are annotated INI file sections showing the default options for all available configuration settings.

The make section sets the names and file name templates for the results:

name = COLL              # name of the resulting PDF file
directory = _output      # directory to copy/put the results

two_up = __%(name)s_2up  # name of the 2-up version PDF file
make_two_up = true       # create a 2-up version (yes/no)

# templates for the name of the copied part PDF files for each
# of the three possible groups (frontmatter, mainmatter, extras)
# available substitutions:
#   (note that the percent-sign must be doubled here)
#   %%(name)s    name of the result file (see above)
#   %%(part)s    name of the part directory/filename
#   %%(index0)d  zero-based index inside group
#   %%(index1)d  one-based index inside group

frontmatter = _%%(name)s_%%(part)s
mainmatter = %%(name)s_%%(index1)02d_%%(part)s
extras = %(frontmatter)s

The parts section gives space-delimited lists of parts to compile and/or include:

frontmatter =  # include at the beginning, roman page numbering
mainmatter =   # include after frontmatter, arabic page numbering
extras =       # compile and copy only (e.g. a separate cover page)

use_dvips =    # use latex -> dvips -> ps2pdf for these parts
               # instead of pdflatex (e.g. pstricks usage)

# pull the first mainmatter part into the roman page numbering area
first_to_front = false

The substitute section fills the template that is used to create the combination document. With the default template, this allows to set the PDF meta data:

# options for \usepackage{hyperref}
author =       # pdfauthor
title =        # pdftitle
subject =      # pdfsubject
keywords =     # pdfkeywords

The template section allows to customize the details of the combination document:

filename =         # use a custom template
filename_two_up =  # different template for 2-up version

class = scrartcl   # use this documentclass

# documentclass options for combination and 2-up version
options = paper=a5
options_two_up = paper=a4,landscape

# includepdfmerge options for combination and 2-up version
include = fitpaper
include_two_up = nup=2x1,openright

The compile section allows to change the invocation options of the compilation commands used.

latexmk = -silent                   # less verbose

texify = --batch --verbose --quiet  # halt on error, less verbose
# only used with texify (latexmk calls these automatically)
dvips = -q
ps2pdf =

Finally, the paginate section controls latexpages-paginate (see above).

update = \\setcounter\{page\}\{(\d+)\}  # search/update regex
contents =                              # part with table of contents
replace = \\startpage\{(\d+)\}          # toc line search/update regex


latexpages is distributed under the MIT license.

Release History

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
latexpages-0.6.2-py2.py3-none-any.whl (23.0 kB) Copy SHA256 Checksum SHA256 2.7 Wheel Mar 25, 2017 (34.7 kB) Copy SHA256 Checksum SHA256 Source Mar 25, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting