将LaTeX文档合并为单个PDF文件
项目描述
此工具使用pdfpages包自动将LaTeX文档集合(用于工作论文、会议录等)编译为单个合并的PDF文件。
创建一个 INI文件,指定您的集合名称和部分,并使用latexpages命令行工具构建它。
latexpages将为加速启动每个核心的一个并行排版进程。
由于每个部分都是独立排版,这允许合并无法合并为单个主文档的文档(使用不兼容的包/选项、latex-dvips-ps2pdf 与 pdflatex 等)。
链接
安装
此软件包在 Python 3.7+ 上运行,使用 pip 进行安装
$ pip install latexpages
编译需要 TeX 发行版(例如 TeX Live 或 MikTeX)以及您的系统上可用的 latexmk 或 MikTeX 的 texify 工具。
可选的自动页码(见下文)需要 pdfinfo 命令行工具(包含在 poppler-utils、miktex-poppler-bin、xpdf)或 pdftk 命令行工具(两者均为跨平台可用)。
用法
创建一个包含带有 latexpages 配置的纯文本 INI 文件的工作目录。将所有文档放入与相应 .tex 文件同名的子目录中
collection/ latexpages.ini article1/ article1.tex references.bib article2/ article2.tex ...
注意:目录名不能包含空格。
编辑 INI 文件以配置部分、它们的顺序以及各种其他选项
[make]
name = MY_COLL
directory = _output
[parts]
mainmatter =
article1
article2
以下命令将排版所有部分,将它们的 PDF 复制到输出目录,并将它们合并成一个 PDF。默认情况下,这还会创建一个双面版本
$ latexpages latexpages.ini
请检查源分布中的 示例目录 以获取一个完整的工作示例。
调用
检查 latexpages 命令的用法
$ latexpages --help
usage: latexpages [-h] [--version] [-c {latexmk,texify}] [--keep]
[--only <part>] [--processes <n>]
[filename]
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 latexmk.pl 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)
分页
以下命令遍历所有主文档并更新源中的第一个 \setcounter{page}{<number>} 行的页码,以反映先前编译的 PDF 文档的页数。
$ latexpages-paginate latexpages.ini
请确保系统路径中可用 pdfinfo 命令行工具(poppler/xpdf)或来自 pdftk 的可执行文件。
要使用不同的模式查找 \setcounter 行,请在您的 INI 文件的 paginate 部分中将 update 选项设置为合适的 正则表达式。
[paginate]
update = \\setcounter\{page\}\{(\d+)\}
要同时更新 目录 中的页码,请将相应的部分名称放入您的 INI 文件的 paginate 部分。
目录结构
collection/ latexpages.ini prelims/ prelims.tex article1/ article1.tex ...
配置
[parts]
frontmatter =
prelims
mainmatter =
article1
article2
[paginate]
contents = prelims
默认情况下,latexpages-paginate 会搜索并更新源中的 \startpage{<number>} 行。要使用此作为标记,请在您的目录中定义并使用相应的 LaTeX 命令,例如 \newcommand{\startpage}[1]{#1}。一个完整的示例在 示例目录 中。
要为查找目录行使用不同的模式,请更改“替换”选项中的正则表达式。
[paginate]
replace = \\startpage\{(\d+)\}
检查latexpages-paginate命令的使用
$ latexpages-paginate --help
usage: latexpages-paginate [-h] [--version] [filename]
Computes and updates start page numbers in compiled parts and contents
positional arguments:
filename INI file configuring the parts and paginate 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
高级选项
以下是带有注释的INI文件部分,显示了所有可用配置设置的默认选项。
make部分设置了结果的名称和文件名模板。
[make]
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
parts部分给出了要编译和/或包含的部件的空格分隔列表。
[parts]
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
substitute部分填充用于创建组合文档的模板。默认模板允许设置PDF的元数据。
[substitute]
# options for \usepackage{hyperref}
author = # pdfauthor
title = # pdftitle
subject = # pdfsubject
keywords = # pdfkeywords
template部分允许自定义组合文档的详细内容。
[template]
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
compile部分允许更改编译命令的调用选项。
[compile]
latexmk = -silent # less verbose
texify = --batch --verbose --quiet # halt on error, less verbose
# only used with texify (latexmk calls these automatically)
dvips = -q
ps2pdf =
最后,paginate部分控制latexpages-paginate(见上文)。
[paginate]
update = \\setcounter\{page\}\{(\d+)\} # search/update regex
contents = # part with table of contents
replace = \\startpage\{(\d+)\} # toc line search/update regex
另请参阅
许可证
latexpages遵循MIT许可。
项目详情
下载文件
下载适合您的平台的文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分发
构建分发
latexpages-0.7.2.zip的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 14f4f6a1d22c0d66f07c2ffaa86734e072b7df914aecc7b0968d7dba27a0df0a |
|
MD5 | 12be94c3d9baf2179c34bcd67c8d45e9 |
|
BLAKE2b-256 | d390b7446892ebd7f9803e3b97d6d85809712acc7874cb4b908e4eb56e2f265b |
latexpages-0.7.2-py3-none-any.whl的散列
算法 | 散列摘要 | |
---|---|---|
SHA256 | 2134153a42b35ccec24c8b449db0c263633a3322704dbfffa75b659feadfabae |
|
MD5 | 27f4be43cfc54ce5efec42c4b81a8cbf |
|
BLAKE2b-256 | 3daf359e7ca33d544fe57d26c8c95fd8e320f439b8737f8169a680ee3adfcb8b |