Latexdiff
📃 These are primarily notes, intended to be a collection of useful fragments, that will probably never be complete in any sense. |
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.
While this hides what you removed, and cases where you only removed words... (You could make it show a trash icon to catch that, I suppose).
...most cases are additions or changes, in which case I care primarily to mark the places where they happened, and about having the sentence flow as it should.
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 code versioning repository (subversion, but the below is analogous for others), 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