Skip to content

Instantly share code, notes, and snippets.

Last active January 25, 2018 08:03
Show Gist options
  • Save avandeursen/db8c394e7d283893badd to your computer and use it in GitHub Desktop.
Save avandeursen/db8c394e7d283893badd to your computer and use it in GitHub Desktop.
Track-changes-like rendered diff for latex documents from two git versions.
# Simple set of make targets to create an msword-track-changes like
# diff for tex, based on two versions committed in git.
# Copyright (c) Arie van Deursen, 2014.
# Distributed under Apache License Version 2.0.
# Note: Either this Makefile should be the same in both the OLD and the NEW version,
# or it should not be committed into git.
# Use at your own risk
# Set the variables below and invoke with
# $ make -f diffs.make
# or set parameters on the command line with
# $ make -f diffs.make NEW=... OLD=... DOC=... diffs
# Name of the file top level file to be diffed, wihout its .tex extension
# git tag/branch/commit for OLD version.
# git tag/branch/commit for NEW version.
# Git will return to this branch after we're done diffing based on tags
# The expanded old version.
# The expanded new version.
# The resulting .tex file with diffs included.
# Tool to expand all inputs -- see install make target on how to get it.
EXPAND=perl latexpand
# create diff document between two committed versions.
$(MAKE) -f $(MAKEFILE) VERSION=$(OLD) expand;
$(MAKE) -f $(MAKEFILE) VERSION=$(NEW) expand;
latexdiff $(OLDDOC) $(NEWDOC) > $(DIFFDOC).tex;
$(MAKE) -f $(MAKEFILE) DOC=$(DIFFDOC) latex;
git checkout $(BRANCH)
# Create an self-contained latex file for VERSION from git.
git checkout $(VERSION)
$(EXPAND) $(DOC).tex > expanded-$(VERSION)-$(DOC).tex
# Simply create a pdf for DOC.
pdflatex $(DOC); \
bibtex $(DOC); \
pdflatex $(DOC); \
pdflatex $(DOC);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment