Skip to content

Instantly share code, notes, and snippets.

@avandeursen
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.
MAKEFILE=$(lastword $(MAKEFILE_LIST))
# 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.
# https://www.apache.org/licenses/LICENSE-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
DOC=bare_conf
# git tag/branch/commit for OLD version.
OLD=submitted-to-icse2017
# git tag/branch/commit for NEW version.
NEW=master
# Git will return to this branch after we're done diffing based on tags
BRANCH=$(NEW)
# The expanded old version.
OLDDOC=expanded-$(OLD)-$(DOC).tex
# The expanded new version.
NEWDOC=expanded-$(NEW)-$(DOC).tex
# The resulting .tex file with diffs included.
DIFFDOC=diffs-$(OLD)-$(NEW)-$(DOC)
# Tool to expand all inputs -- see install make target on how to get it.
EXPAND=perl latexpand
# create diff document between two committed versions.
diffs:
$(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.
expand:
git checkout $(VERSION)
$(EXPAND) $(DOC).tex > expanded-$(VERSION)-$(DOC).tex
install:
wget http://mirrors.ctan.org/support/latexpand/latexpand
# Simply create a pdf for DOC.
latex:
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