Package: latexpages
This tool automates compiling LaTeX document collections (for working papers,
proceedings, etc.) into a single combined PDF file using thepdfpagespackage.Create anINI filegiving the name and parts of your collection and build
it with thelatexpagescommand-line utility.latexpageswill 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.).LinksGitHub:https://github.com/xflr6/latexpagesPyPI:https://pypi.org/project/latexpages/Issue Tracker:https://github.com/xflr6/latexpages/issuesDownload:https://pypi.org/project/latexpages/#filesInstallationThis package runs under Python 3.7+, usepipto install:$pipinstalllatexpagesThe compilation requires a TeX distribution (e.g.TeX LiveorMikTeX) and
eitherlatexmkor MikTeX’stexifyutility being available on your system.The optional automatic page numbering (see below) requires either thepdfinfocommand-line utility (included inpoppler-utils,miktex-poppler-bin,xpdf), or thepdftkcommand-line utility (both
available cross-platform).UsageCreate 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.texfile:collection/
    latexpages.ini
    article1/
        article1.tex
        references.bib
    article2/
        article2.tex
        ...Note: the directory names cannot contain spaces.Edit the INI file to configure the parts, their order and various other
options:[make]name=MY_COLLdirectory=_output[parts]mainmatter=article1article2The 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:$latexpageslatexpages.iniCheck theexample directoryin the source distribution for a working
complete example.InvocationCheck the usage of thelatexpagescommand:$latexpages--helpusage:latexpages[-h][--version][-c{latexmk,texify}][--keep][--only<part>][--processes<n>][filename]CompilesandcombinesLaTeXdocsintoasinglePDFfilepositionalarguments:filenameINIfileconfiguringthepartsandoutputoptions(default:latexpages.iniinthecurrentdirectory)optionalarguments:-h,--helpshowthishelpmessageandexit--versionshowprogram'sversionnumberandexit-c{latexmk,texify}uselatexmk.plortexify(default:guessfromplatform)--keepkeepcombinationdocument(s)andtheirauxiliaryfiles--only<part>compilethegivenpartwithoutcombining--processes<n>numberofparallelprocesses(default:onepercore)PaginationThe following command goes trough all main documents andupdates the page
numberin the first\setcounter{page}{<number>}line of the source
according to the page count of the preceding documents’ compiled PDFs.$latexpages-paginatelatexpages.iniMake sure either thepdfinfocommand-line tool (poppler/xpdf) or thepdftkexecutable frompdftkis available on your systems’ path.To use a different pattern for finding the\setcounterlines, set theupdateoption in thepaginatesection of your INI file to a suitableregular expression.[paginate]update=\\setcounter\{page\}\{(\d+)\}To also update the page numbers in yourtable of contents, put the
corresponding part name in thepaginatesection of your INI file.Directory structure:collection/
    latexpages.ini
    prelims/
        prelims.tex
    article1/
        article1.tex
        ...Configuration:[parts]frontmatter=prelimsmainmatter=article1article2[paginate]contents=prelimsBy default,latexpages-paginatewill search and update\startpage{<number>}lines in the source. To use this as marker, define and
use a corresponding LaTeX-command in your table of contents, e.g.\newcommand{\startpage}[1]{#1}. A complete example is in theexample
directoryTo use a different pattern for finding the table of contents lines, change
theregular expressionin thereplaceoption.[paginate]replace=\\startpage\{(\d+)\}Check the usage of thelatexpages-paginatecommand:$latexpages-paginate--helpusage:latexpages-paginate[-h][--version][filename]Computesandupdatesstartpagenumbersincompiledpartsandcontentspositionalarguments:filenameINIfileconfiguringthepartsandpaginateoptions(default:latexpages.iniinthecurrentdirectory)optionalarguments:-h,--helpshowthishelpmessageandexit--versionshowprogram'sversionnumberandexitAdvanced optionsBelow are annotated INI file sections showing thedefault optionsfor all
available configuration settings.Themakesection sets thenamesand file nametemplatesfor the
results:[make]name=COLL# name of the resulting PDF filedirectory=_output# directory to copy/put the resultstwo_up=__%(name)s_2up# name of the 2-up version PDF filemake_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 groupfrontmatter=_%%(name)s_%%(part)smainmatter=%%(name)s_%%(index1)02d_%%(part)sextras=%(frontmatter)sThepartssection givesspace-delimitedlists of parts to compile
and/or include:[parts]frontmatter=# include at the beginning, roman page numberingmainmatter=# include after frontmatter, arabic page numberingextras=# 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 areafirst_to_front=falseThesubstitutesection fills the template that is used to create the
combination document. With the default template, this allows to set the PDFmeta data:[substitute]# options for \usepackage{hyperref}author=# pdfauthortitle=# pdftitlesubject=# pdfsubjectkeywords=# pdfkeywordsThetemplatesection allows to customize the details of thecombination
document:[template]filename=# use a custom templatefilename_two_up=# different template for 2-up versionclass=scrartcl# use this documentclass# documentclass options for combination and 2-up versionoptions=paper=a5options_two_up=paper=a4,landscape# includepdfmerge options for combination and 2-up versioninclude=fitpaperinclude_two_up=nup=2x1,openrightThecompilesection allows to change theinvocation optionsof the
compilation commands used.[compile]latexmk=-silent# less verbosetexify=--batch --verbose --quiet# halt on error, less verbose# only used with texify (latexmk calls these automatically)dvips=-qps2pdf=Finally, thepaginatesection controlslatexpages-paginate(see above).[paginate]update=\\setcounter\{page\}\{(\d+)\}# search/update regexcontents=# part with table of contentsreplace=\\startpage\{(\d+)\}# toc line search/update regexSee alsohttps://www.ctan.org/topic/compilationhttps://www.ctan.org/topic/confprochttps://www.ctan.org/pkg/pdfpageshttps://www.ctan.org/pkg/confprochttp://go.warwick.ac.uk/pdfjamhttp://community.coherentpdf.comhttps://github.com/JacksonLLee/cls-proceedingsLicenselatexpagesis distributed under theMIT license.