Skip to content

Instantly share code, notes, and snippets.

@chi-feng
Created May 10, 2023 01:52
Show Gist options
  • Save chi-feng/eaafa9db9984de07ac45b61af47af8fe to your computer and use it in GitHub Desktop.
Save chi-feng/eaafa9db9984de07ac45b61af47af8fe to your computer and use it in GitHub Desktop.
prepare latex project for arxiv
#!/bin/bash
# use \listfiles in preamble to get a list of included files
rm -rf arxiv_tmp
mkdir -p arxiv_tmp
# copy files to temp folder
rsync -av --files-from=list-of-files.txt . arxiv_tmp/
for f in `find arxiv_tmp/ -name "*.tex"`
do
echo "Processing $f"
# remove comments
latexpand --empty-comments $f > "${f}_stripped"
# strip lines that start with %
sed -i '/^\s*%/d' "${f}_stripped"
# squeeze multiple blank lines into single blank lines
# cat -s "${f}_stripped" | sponge "${f}_stripped"
mv "${f}_stripped" $f
done
# create tarball for upload to arxiv
tar -cvf arxiv.tar -C arxiv_tmp .
rm -rf arxiv_tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment