This small script helps you to prepare a LaTeX project for publication e.g. on ArXiv or in a journal. The script is able to do the things you usually do manually before submission:
- Clean up: removes files that are not necessary for the project (e.g. outdated graphics, draft
.texfiles, etc.) - png -> jpg conversion: reduces size to satisfy size limits of the submissions
- flattening: creates a single
.texdocument by expanding\inputand similar macros; copies graphics from subdirs and edit their path in.texdoc.
Disclaimer: The result can be not perfect, so check diff files carefully.
But the script mostly works well.
latexmkmkjobtexmflatexpandpython3.6huepy:pip install huepyglob2:pip install glob2
On Ubuntu, one can install the first three via: sudo apt-get install texlive-extra-utils latexmk.
usage: main.py [-h] --project-dir PROJECT_DIR --main-file MAIN_FILE --save-dir
SAVE_DIR [--remove-redundant-files] [--remove-comments]
[--flatten] [--convert-to-jpg] [--quality QUALITY] [--debug]
optional arguments:
-h, --help show this help message and exit
--project-dir PROJECT_DIR
--main-file MAIN_FILE
--save-dir SAVE_DIR Where to save the processed project.
--remove-redundant-files
Clean up redundant files
--remove-comments Remove comments within the .tex files.
--flatten Converts the project to a one without any folders.
--convert-to-jpg Convert image files to jpg.
--quality QUALITY Conversion quality.
--debug Do not suppress the intermediate output.
Basically you do it like this:
python tex-publishing-util.py --project-dir path/to/dir --main-file main.tex --save-dir out --remove-redundant-files --remove-comments --flatten --convert-to-jpgTested only on Ubuntu 16.04, will most likely do not work on Windows without editing (PR is welcome).