Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to highlight changes between two versions of a LaTeX document.

I have both my versions in git. Is there an easy way of generating a output document where all changes are highlighted. So the highlighting should be in the output and not in the source.

The whole purpose is to indicate for my supervisor which changes I made so that he can review and approve them quickly.

share|improve this question
3  
Seems like a duplicate of (part of) this question. –  TH. Oct 4 '10 at 8:01
1  
@TH., not really. Showing differences between two versions and version control in general are two different things. At least both can be used without the other. –  Martin Scharrer Jun 22 '11 at 13:17
    
@Martin: Both questions are about using version control in conjunction with LaTeX. In particular displaying differences. "Also, it might be nice to get a PDF showing what was added and removed in a given revision." The answers to that question (and comments to the answers) answer this one as well. Although, as this question is 7 months old and has been answered, I'm not sure why you're bothering to disagree with my comment. –  TH. Jun 23 '11 at 3:09
1  
related: Using latexdiff with git –  Tobias Kienzler Sep 21 '11 at 13:12

4 Answers 4

up vote 9 down vote accepted

  Rewritten answer

Because of the regular structure of typical Latex documents, it's feasible to write a diff-like program that looks at the two Latex source files and creates a compilable Latex diff output where additions and deletions are delineated using macros. With the appropriate macro definitions, you can make these appear as appropriate markup (inline, with changebars) in the compiled diff document.

There are two programs I know of on CTAN that do this, both of which are Perl scripts:

  1. latexdiff, which is the more widely used, and has support for automatic revision acceptance and version control;
  2. texdiff, my preference, which is less sophisticated and I find more predictable. texdiff doesn't try to insert Latex code into the preamble, which means you have to do this yourself, but which means it is more convenient for multifile documents, and for when you want to handle the insert/delete markup yourself.
share|improve this answer
1  
Can you please give reasons why to use it, or a 2 line introduction how to use it? –  Peter Smit Oct 4 '10 at 12:58

A less automated way respect to texdiff is changebar. Use in this way:

...some text
\cbstart
the text you modified
\cbend
some text...
\cbdelete %to put where some text have been deleted

from \cbstart to \cbend a grey bar is displayed near the text. \cbdelete will display a little grey square instead.

share|improve this answer
1  
Oh, this is great! I have been meaning to look up if there is a package that does exactly this. You pre-empted my asking. –  Willie Wong Oct 4 '10 at 17:42

Latexdiff is a nice perl script for this purpose.

share|improve this answer
1  
Can you please give reasons why to use it, or a 2 line introduction how to use it? –  Peter Smit Oct 4 '10 at 12:58
    
See the answer tex.stackexchange.com/questions/161/… –  András Salamon Oct 4 '10 at 16:01

wdiff, like this:

wdiff -w "\fbox{" -x "}" -y "\fbox{\fbox{" -z "}}" ...

share|improve this answer
    
What does this exactly do? –  Peter Smit Oct 4 '10 at 17:19
2  
It puts a box around the words that you deleted, and a double-box around the words you added. But this doesn't work completely well with latex when there are commands involved in the changes, as then the braces may not pair up correctly. See also the documentation for texdiff that Charles mentioned earlier. –  Willie Wong Oct 4 '10 at 17:45
    
if you don't like the box and double box, you can always change \fbox in the above command to something like \colorbox and have it put a colored box around it instead. –  Mica Oct 4 '10 at 19:50
    
latexdiff and texdiff handle word differences but are TeX-aware. –  András Salamon Oct 6 '10 at 9:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.