latexdiff is a useful tool to determine changes between different versions of latex files and highlight them in a pdf (similar to MS word does with tracking changes). latexdiff-git is a wrapper around latexdiff optimized for git (and mercurial, but we’ll only look into git here). With it you can specify a latex document file (which is in a git repository) and a commit hash from that repository to look for changes between the file and its version from the specified commit. Same is possible with e.g. specifying two different commit hashes.
Installation (Linux)
- Clone latexdiff-git
git clone git@gitorious.org:git-latexdiff/git-latexdiff.git
- All further steps are stated in the
README
file inside the repository you just cloned:- Ensure you have a
~/.gitconfig
file and that it’s accessible for your user. - Add the following lines to
.git/config
[difftool.latex] cmd = latexdiff "$LOCAL" "$REMOTE" [difftool] prompt = false [alias] ldiff = difftool -t latex
- Change the checked out script file
latexbatchdiff.sh
: search forrevlatexdiffcmd='please define'
and replace it withrevlatexdiffcmd='git ldiff'
- Ensure you have a
- Place latexbatchdiff.sh somewhere in your path (I tend to place it in ~/bin) and make it executable: chmod +x latexbatchdiff.sh
Usage
You can generate a tex file from differences between a latex file and a revision checked into git with (replace GITHASH
and FILE
with your git commit hash and latex file)
latexdiff-git -r GITHASH FILE
Alternatively you can generate the tex file from changes between two specific commits of a latex file:
latexdiff-git -r GITHASH1 -r GITHASH2 FILE
To view changes hightlighted in a pdf:
pdflatex *diff*tex # create pdf highlighting diff evince *diff*pdf # replace evince with your preferred pdf-viewer
