Skip to content

Instantly share code, notes, and snippets.

@smorad
Created January 6, 2021 18:24
Show Gist options
  • Save smorad/d0e574430c4b9da5bd3818041e54fe7f to your computer and use it in GitHub Desktop.
Save smorad/d0e574430c4b9da5bd3818041e54fe7f to your computer and use it in GitHub Desktop.
set -e
set -x
zipfile=$1
wdir='latex_arxiv'
unzip $zipfile -d $wdir
pushd $wdir
svgs=$(find . -name *.svg | sed 's/.svg//')
epses=$(find . -name *.eps | sed 's/.eps//')
# Convert images
for s in $svgs; do
if [ ! -f $s.pdf ]; then
cairosvg $s.svg -o $s.pdf
rm $s.svg
fi
done
for e in $epses; do
if [ ! -f $e.pdf ]; then
convert $e.eps $e.pdf
rm $e.eps
fi
done
# Remove svg calls
texs=$(find . -name '*.tex')
sed -i 's/includesvg/includegraphics/' $texs
sed -i 's/\.svg/.pdf/' $texs
# Remove eps calls
sed -i 's/\.eps/.pdf/' $texs
popd
zip -r $wdir $wdir/*
echo "Results in $wdir"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment