How to compare two TeX codes and mark differences with color

Update (2016-04-10)

An add-on for running latexdiff from within WinEdt is available: latexdiff.

If you want, you can revert the changes in MainMenu.ini and Toolbar.ini and install the add-on.


Original answer

This is a simple way to have a button in WinEdt 7 (this one works in v7 only) to run latexdiff.

  1. Show the "Options Interface" (Options -> Options Interface)

    enter image description here

  2. Double-click the "Main Menu" item (MainMenu.ini gets opened)

  3. Just before the line

      ITEM="Compile"
    

    add the following lines

      ITEM="LaTeXdiff"
        CAPTION="&LaTeXdiff"
        CONFIG_FILTER="Default;MiKTeX;TeX Live"
        IMAGE="CompareDocs"
        SAVE_INPUT=1
        MACRO=`WinExe('','cmd.exe /C latexdiff old_%n.tex %n.tex > new_%n.tex','%p','',011100);Open("new_%n.tex");`
        SHORTCUT="16452::Ctrl+D"
    
  4. Press Shift+Ctrl+F9

  5. Now (in the "Options Interface") double-click the "Toolbar" item (Toolbar.ini gets opened)

  6. Just before the line

      BUTTON="Compile"
    

    add the following line

      BUTTON="LaTeXdiff"
    
  7. Press Shift+Ctrl+F9


That's it. Now you have a toolbar button

enter image description here

a menu item in the "Accessories" menu

enter image description here

and a shortcut (Ctrl+D) to run latexdiff.


How to use it

Suppose you are working on a file foo.tex. Save the old version as old_foo.tex. Make the changes you need in foo.tex and make sure that foo.tex is the file in the main window.

At this point, choose one of the above methods to run latexdiff. A resulting file new_foo.tex will get opened.


For this purpose I use program winmerge on windows.

You can load both file to be compared and each difference is marked. You can change in winmerge the code, copy from one file to the other and so on. Please see the shown screenshots on the web page http://winmerge.org/?lang=en.

From the homepage (follow the link above):

WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.