Using LaTex diff with Git and SVN
May 31, 2021
Working with multiple co-authors and keeping track of changes is an essential and admittedly annoying task, but
svn have made the job bearable.
And to a CLI nerd like me, sometimes figuring out the correct incantation to convince
git to do your bidding can feel positively relaxing (and a way to procrastinate).
As part of reviews, rewrites, presentations and discussions, it is often necessary to go over the text that has changed from an old version to the current version. Looking through
git diff is not that enjoyable for most people.
It is easier to show a friendly typeset LaTeX pdf so that everyone can immediately see what has changed and visually identify the part in the document they have read/written.
To do this, the handy
latexdiff command available with most TeX distributions comes to the rescue.
Which generates output like the figure below (image from overleaf).
To create color-coded diffs from any two files you can use
latexdiff the following (i.e., lines changed/deleted/inserted)
latexdiff old_version.tex new_version.tex > version_diff.tex
If you are using
git there is a handy shortcut to create a diff from a previous commit.
latexdiff-vc --git root.tex -r <commit-hash> latexdiff-vc --svn root.tex -r <revision-hash>
Ther are several problems that can emege in generating the diff and then compiling to pdf especially equations. To ingore changes in equations you may set
latexdiff-vc --git --math-markup=off ABM_Bonus_ACS.tex -r 9c837e31a2