Latexdiff

From Helpful
Jump to: navigation, search
These are primarily notes
It won't be complete in any sense.
It exists to contain fragments of useful information.
This article/section is a stub — probably a pile of half-sorted notes, is not well-checked so may have incorrect bits. (Feel free to ignore, fix, or tell me)

latexdiff takes two .tex documents, and creates a new one marking up the differences between the two.

See the manual, latexdiff-man.pdf


Style options

Types

Basic markup differences:

  • UNDERLINE: (default) Added text is underlined and blue, discarded text is struck out and red
  • TRADITIONAL: Added text is sans serif, discarded text is mentioned in a footnote
  • CTRADITIONAL: TRADITIONAL plus colors (added is blue)
  • CFONT: Added text is blue and sans-serif, discarded text is red small size.

Ranges with changes can be marked with a bar in the margin in:

  • CHANGEBAR: no markup change, only changebars
  • CULINECHBAR: UNDERLINE + changebars
  • CFONTCHBAR: CFONT + changebars
  • CCHANGEBAR: Added text is blue, and discarded text is red.
  • INVISIBLE: No visible markup (but generic markup commands will still be inserted.

Example:

--type=CFONT
-t CFONT


Subtypes Controls extra markup at begin/end of each change

  • SAFE (default): Nothing
  • MARGIN: uses \marginpar to add symbols in the margin
  • DVIPSCOL: alternative coloring

Example:

--subtype=MARGIN
-s MARGIN


Note that different styles require different packages, including color, ulem, and changebar.


personal preferences

Changebars (and one or two other styling options) work best using dvips (producing postscript), and seem to make trouble in latexpdf (at the time, this may have been fixed now).

...so I went for more basic formatting (CFONT).


I also prefer to hide deleted text, so that changed text flows as it should, while new/changed text is shown highlighted (This does mean that delete-only changes will be invisible, but for revisions of wording I usually don't care).

One way to do this is to add the following in the original document:

\providecommand{\DIFdel}[1]{} %Don't show deleted text

Examples

I keep .tex changes versions in a subversion repository, so I wrote a script to create the diff of the last-my-supervisor-saw and my most recent commit. It roughly consists of:

# mess around in a different directory
mkdir diff
cd diff
 
# Compare the last commited version (HEAD) with version 32 (32 being the last verion I sent in)
svn cat -r HEAD ../doc.tex  > HEAD.tex
svn cat -r 32   ../doc.tex  > last.tex
latexdiff -t CFONT last.tex HEAD.tex > doc.tex
 
# and compile the marked document
latex doc.tex