Skip to content

Instantly share code, notes, and snippets.

@dariusf
Last active August 3, 2023 06:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dariusf/c539c364209b084eb19996596d55272d to your computer and use it in GitHub Desktop.
Save dariusf/c539c364209b084eb19996596d55272d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# This is safe to run in your paper directory, as it creates a copy of the files.
# to be uploaded in the $dest directory below.
# It assumes latexmk is used, and latexmk outputs go into a _build directory.
set -e
# build, as we need the bbl file
latexmk
dest=_build/arxiv
mkdir -p "$dest"
scrub() {
perl -p0e "s/\\\\begin\\{comment\\}.*\\\\end\\{comment\\}//se" < "$1" | perl -pe 's/(^|[^\\])%.*/\1%/' > "$2"
}
for file in *.tex; do
if [ -f "$file" ]; then
echo "$file scrubbed"
filename=$(basename "$file")
dest_file="$dest/$filename"
scrub "$file" "$dest_file"
fi
done
# don't include bib
cp {*.cls,latexmkrc,_build/main.bbl} "$dest"
(cd $dest && tar -czvf archive.tar.gz *)
mv $dest/archive.tar.gz .
echo "upload this:"
ls archive.tar.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment