清除你提交给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产品。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
JFrame中的Java多线程   java Servlet异常映射   java无法从输出流读取   swing Java带来的小程序GUI问题   java什么原因导致错误“'void'类型此处不允许”以及如何修复它?   Java选择器select(长)与selectNow的区别   java自定义arraylist<mygames>获得不同   java Icepdf注释让页面消失   java反向整数数组   java I在生成同步“无法解析配置的所有依赖项”时遇到此错误:app:debugRuntimeClasspath   多个虚拟机上的java线程访问单个DB实例上的表,有时会导致性能低下和异常   swing更改Java中的默认按钮,使其看起来“更好”   java慢速MQ主题订阅。并行化不能提高性能   java运行Boggle Solver需要一个多小时。我的代码怎么了?   数据库中的java循环与应用程序中的java循环   正则表达式匹配${123…456}并在Java中提取2个数字?   java如何制作我们软件的试用版   Java内存参数计算   从另一个类调用方法时出现java问题