A blog by Rob J Hyndman 

Twitter Gplus RSS

Tracking changes in LaTeX files

Published on 20 August 2008

When I write a paper, it usu­ally goes through many ver­sions before being sub­mit­ted to a jour­nal. I keep track of the dif­fer­ent ver­sions by renam­ing the file when I’m about to make major changes, or when I receive a new ver­sion from a coau­thor. The files are named file1.tex, file2.tex, etc. where “file” is replaced by some­thing more meaningful.

It is often use­ful to be able to com­pare ver­sions to see what changes have been made, espe­cially when work­ing with coau­thors. It is pos­si­ble to use text com­par­i­son soft­ware such as Com­pare It!, but LaTeX files often have insignif­i­cant changes due to line wrap­ping which make no dif­fer­ence to the out­put, and there is no point in iden­ti­fy­ing these changes.

I recently dis­cov­ered a great solu­tion which finds real LaTeX changes and ignores changes due to line wrap­ping. It is LaTeXd­iff.The good news is that Mik­TeX users already have it, although you prob­a­bly don’t realise it.

To use it, you need both Mik­TeX and Perl installed on your com­puter. I’ll assume you already have Mik­TeX. If you cre­ate R pack­ages for Win­dows, you will also have Perl. Oth­er­wise, one sim­ple way to get Perl is to install Rtools.

The sim­plest way to pro­ceed once Perl is installed, is to use the fol­low­ing com­mand (from a DOS prompt)

latexdiff-so file1.tex file2.tex > diff.tex

If you are using Mik­TeX, then the latexdiff-so com­mand should work from any DOS prompt. Then just process the file diff.tex as you nor­mally do (prob­a­bly in WinEdt).


Related Posts:


 
Tags: ,
2 Comments  comments 
  • Ein Staunen­der

    Did you ever con­sid­ered to use a Revi­sion con­trol sys­tem instead of copy­ing the file and adding a num­ber? At first, this may look a lit­tle bit exag­ger­ated, but it gives you the whole power of an RCS. As an win­dows user, you may have a look at TortoiseGit …

    Besides, I’m happy with KDiff for com­par­ing files (although I use also windows).

    • http://robjhyndman.com Rob J Hyndman

      Yes, I’ve tried a cou­ple of revi­sion con­trol sys­tems includ­ing Tor­tois­eSVN. How­ever, it seems like overkill for some­thing like this.