Home > Misc > latexdiff-git: highlight changes between revisions of latex files managed in git

latexdiff-git: highlight changes between revisions of latex files managed in git

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)

  1. Clone latexdiff-git
    git clone git@gitorious.org:git-latexdiff/git-latexdiff.git
    
  2. All further steps are stated in the README file inside the repository you just cloned:
    1. Ensure you have a ~/.gitconfig file and that it’s accessible for your user.
    2. Add the following lines to .git/config
      [difftool.latex]
       cmd = latexdiff "$LOCAL" "$REMOTE"
      [difftool]
       prompt = false
      [alias]
       ldiff = difftool -t latex
      
    3. Change the checked out script file latexbatchdiff.sh: search for revlatexdiffcmd='please define' and replace it with revlatexdiffcmd='git ldiff'
  3. 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
Categories: Misc Tags: , , , , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: