Last active
April 17, 2016 02:25
-
-
Save arthurd2/1503e7e368f9eca25b77 to your computer and use it in GitHub Desktop.
Easy integration with GIT and Latexdiff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TMPDIR=$(mktemp -d /tmp/git-latexdiff.XXXXXX) | |
ORIDIR=`pwd` | |
TEX=$1 | |
VER=$2 | |
if [ -z "$2" ];then | |
VER='HEAD' | |
fi | |
if [ -z "$1" ];then | |
TEX=`grep 'begin{document}' *.tex | grep -m 1 begin | cut -d\: -f1` | |
fi | |
git clone . "$TMPDIR/" | |
cd "$TMPDIR" | |
git checkout $VER | |
latexdiff --config="PICTUREENV=(?:picture|algorithm|eqnarray|comment|tikzpicture|DIFnomarkup)[\w\d*@]*" --flatten "$TEX" "$ORIDIR/$TEX" > diff.tex | |
latex -interaction=nonstopmode diff.tex &> /dev/null | |
bibtex diff.aux | |
latex -interaction=nonstopmode diff.tex &> /dev/null | |
pdflatex -interaction=nonstopmode diff.tex &> /dev/null | |
evince diff.pdf | |
rm -rf $TMPDIR | |
echo | |
echo "$0 $TEX $VER" | |
echo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, it was very useful. I ran into a problem with the variable name
TMPDIR
, since that name is used by Ghostscript (which in my TeX files is called byepstopdf
). Ghostscript was throwing an error about being unable to write a temporary file during the EPS to PDF conversion process. It took me awhile to figure out what the problem was, so I thought it might be worth sharing that info.