# latexdiff: Superb diff tool for LaTeX

I am shepherding a paper for ASPLOS, and the authors kindly sent me a PDF highlighting all changes between the previous version and the next. They used latexdiff. I just used it to see some updates made by a student to a paper, and it is fantastic.

Here’s a sample of what the results look like:

(and no, this is not my paper or the ASPLOS paper).

If you are using a Mac, you can easily install it with MacPorts (just sudo port install latexdiff).

Generally, you will want to invoke latexdiff as follows (assuming you are in the directory with the latest version):

latexdiff --flatten /path/to/old/version/main.tex main.tex > diffs.tex

(the –flatten argument makes latexdiff recursively operate on any included .tex files.)

One trick: if, like me, you break your LaTeX documents into separate files, you need to put the preamble into your main document (it’s also automatically generated by latexdiff, but only for a main document). Reproduced here for your cut-n-paste convenience.

%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE
\RequirePackage[normalem]{ulem}
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}
%DIF SAFE PREAMBLE
\providecommand{\DIFdelbegin}{}
\providecommand{\DIFdelend}{}
%DIF FLOATSAFE PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}}