Here is the story for me to compose my PhD thesis that is organised in Github and texted using LaTeX. The problem is how to track the changing when the thesis is changed using Git. This is pretty much similar with the modification tracking mechanism in Microsoft’s word. The difficult point here is that the whole thesis is stored in Github. The tools such as ‘texdiff’ and ‘latexdiff’ work on the two distinct files stored in the hard disk. In other to show differences of a file between two different versions, Git’s difftool should be employed.
Therefore, required tools are:
- git-difftool
- latexdiff (texdiff requires wdiff installed. However no wdiff installed in my Mac)
The main idea is that, using git-difftool and latexdiff tools to produce new tex files with tracked modification information into a temporary directory, which are included in a new ‘report.tex’ file to produce a tracked pdf thesis. (The new ‘report.tex’ file should be renamed)
The following steps demonstrate how to produce tracked pdf file after the thesis is changed:
- Configuration of git-difftool: git-difftool is supposed to invoke GUI comparison tool for a file between its two versions. Now, I want to bypass GUI tool’s invocation to a script that produces tex file with tracking information into a temporary directory.
- Configuration of latexdiff: latexdiff inserts some comment tags into tex files. However, these tags is undefined. Therefore, the preamble should be inserted into the main tex file: %DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}} %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF - Create a new version ‘report.tex’ file:
- Produce PDF file with tracked modification information:
Problems:
The first problem is the configuration of latexdiff. I used dmath to represent mathematic equations. However, latexdiff recognises only equation and displaymath tags. I have to make a new config file to include dmath into the environment variable “MATHENV” in order to prevent compile errors. I have tried to use a configuration file. But it failed. So I just put this configuration information as a option in latexdiff command. Then it worked.