This version of texdiff is based on the TeXdiff by Robert Maron, available at http://www.robmar.net/TexDiff/. Cengiz GŁnay has provided several fixes to it and added optional parameters as well as documentation. This texdiff is work in progress and only the most common LaTeX usage cases are handled correctly. Feel free to improve and redistribute.

Another tool for diff'ing LaTeX files is latexdiff by Frederik Tilmann.

How it works

texdiff uses wdiff with changes start and end markers. If texdiff would be a bash alias, it would look like this:
  alias texdiff = "wdiff --start-delete='\TLSdel{' --end-delete='}'
                         --start-insert='\TLSins{' --end-insert='}'"
The markers are LaTeX macros, that must be defined in the preamble of LaTeX documents (automatically inserted by texdiff if a \begin{document} is found):


By using "texdiff old.tex new.tex > diff.tex" and running LaTeX over diff.tex, a dvi file is generated with all text only in old.tex in red and striked out, and all text only in new.tex blue and underlined (freely configurable, cf. ulem package). Furthermore, passages with changes are marked at the margin with grey bars by the changebar package (although only after running dvips, in xdvi the bars are one inch too far left to compensate the one inch offset inserted by TeX printer drivers).

Handling LaTeX macros

If LaTeX macros are included in those striked out or underlined passages, the latex run will most likely fail. The source of most problems lies in wdiff tearing apart pairs of braces. Therefore texdiff is a perl skript, that calls wdiff internally and fixes wdiff's output by re-pairing braces again and handling some commonly used LaTeX macros (you can add more macro names in the configuration section of texdiff).