清除你提交给arXiv的论文的乳胶代码。
arxiv-latex-cleaner的Python项目详细描述
arxiv_latex_cleaner
这个工具可以让你很容易地清理你的论文的乳胶代码提交
阿尔十四。从一个包含所有代码的文件夹中,例如/path/to/latex/
,它
创建一个新文件夹/path/to/latex_arXiv/
,可以压缩并上载到
阿尔十四。在
示例调用:
arxiv_latex_cleaner /path/to/latex --im_size 500 --images_whitelist='{"images/im.png":2000}'
或者简单地从一个配置文件
^{pr2}$安装:
pip install arxiv-latex-cleaner
:exclamation: arxiv_latex_cleaner is only compatible with Python >=3 :exclamation: |
---|
或者,您可以下载源代码:
git clone https://github.com/google-research/arxiv-latex-cleanercd arxiv-latex-cleaner/python -m arxiv_latex_cleaner --help
并作为命令行程序直接从源代码安装:
python setup.py install
主要特点:
注重隐私
- 删除所有辅助文件(
.aux
,.log
,.out
,等等)。在 - 删除代码中的所有注释(是的,这些注释在arXiv和您身上都是可见的
不希望他们是)。这些还包括
\begin{comment}\end{comment}
和\iffalse\fi
环境。在 - (可选)删除用
commands_to_delete
输入的用户定义命令 (例如\todo{}
,您在结尾处重新定义为空字符串)。在 - (可选)允许您通过
cleaner_config.yaml
文件。在
以尺寸为导向
arXiv提交文件有50MB的限制,因此要使其适合:
- 删除所有未使用的
.tex
文件(那些不在根目录中也不在 {cd12>包含在任何文件中)。在 - 删除所有占用空间的未使用图像(那些实际上不是
包含在任何已使用的
.tex
文件中)。在 - 可选地将所有图像调整为
im_size
像素,以减小 提交。您可以使用将一些图像白名单以跳过全局大小images_whitelist
。在 - 可选地使用ghostscript压缩
.pdf
文件(仅限Linux和Mac)。 您可以使用images_whitelist
。在
TikZ图片源代码隐藏
为了防止上传tikzpicture源代码或原始模拟数据,此 特点:
- 将tikzpicture环境
\begin{tikzpicture} ... \end{tikzpicture}
替换为相应的\includegraphics{EXTERNAL_TIKZ_FOLDER/picture_name.pdf}
。在 - 需要外部编译的TikZ图片作为文件夹中的
.pdf
文件 ^{PGF/TikZ manual在TikZ图片上 外部化。在 - 仅将环境替换为
\tikzsetnextfilename{picture_name}
命令(如\tikzsetnextfilename{picture_name}\begin{tikzpicture} ... \end{tikzpicture}
)其中外部化的picture_name.pdf
文件名 匹配picture_name
。在
基于regex组捕获的更复杂的模式替换
有时在编写代码时使用一组自定义的LaTeX命令是很有用的 一份报纸。为了在arXiv提交时清除它们,你可以简单地将它们还原为 带有正则表达式插入的普通乳胶。在
{"pattern":'(?:\\figcomp{\s*)(?P<first>.*?)\s*}\s*{\s*(?P<second>.*?)\s*}\s*{\s*(?P<third>.*?)\s*}',"insertion":'\parbox[c]{{{second}\linewidth}}{{\includegraphics[width={third}\linewidth]{{figures/{first}}}}}',"description":"Replacefigcomp"}
上面的模式将找到所有\figcomp{path}{w1}{w2}
命令并替换
他们和
\parbox[c]{w1\linewidth}{\includegraphics[width=w2\linewidth]{figures/path}}
。
请注意,插入模板是用
named groups captures
从图案上看。注意,替换是在all之前处理的
\includegraphics
命令被处理,相应的文件路径被处理
复制,确保将所有图形文件复制到清理后的版本。另请参见
cleaner_config.yaml有关如何指定
模式。在
用法:
usage: arxiv_latex_cleaner@v0.1.10 [-h] [--resize_images] [--im_size IM_SIZE]
[--compress_pdf]
[--pdf_im_resolution PDF_IM_RESOLUTION]
[--images_whitelist IMAGES_WHITELIST]
[--commands_to_delete COMMANDS_TO_DELETE [COMMANDS_TO_DELETE ...]]
[--verbose]
[--config CONFIG_PATH]
input_folder
Clean the LaTeX code of your paper to submit to arXiv. Check the README for
more information on the use.
positional arguments:
input_folder Input folder containing the LaTeX code.
optional arguments:
-h, --help show this help message and exit
--resize_images Resize images.
--im_size IM_SIZE Size of the output images (in pixels, longest side).
Fine tune this to get as close to 10MB as possible.
--compress_pdf Compress PDF images using ghostscript (Linux and Mac
only).
--pdf_im_resolution PDF_IM_RESOLUTION
Resolution (in dpi) to which the tool resamples the
PDF images.
--images_whitelist IMAGES_WHITELIST
Images (and PDFs) that won't be resized to the default
resolution,but the one provided here. Value is pixel
for images, and dpi forPDFs, as in --im_size and
--pdf_im_resolution, respectively. Format is a
dictionary as: '{"path/to/im.jpg": 1000}'
--commands_to_delete COMMANDS_TO_DELETE [COMMANDS_TO_DELETE ...]
LaTeX commands that will be deleted. Useful for e.g.
user-defined \todo commands.
--use_external_tikz EXTERNAL_TIKZ_FOLDER
Folder (relative to input folder) containing
externalized TikZ figures in PDF format.
--verbose Enable detailed output.
--config CONFIG_PATH
Read Settings from config file, such as "cleaner_config.yaml"
注意
这不是一个官方支持的Google产品。在
- 项目
标签: