7

I am trying to use latexdiff to compare two .tex files, producing a .pdf with a markup similar to the "track changes" function in Microsoft Word (see https://www.sharelatex.com/blog/2013/02/16/using-latexdiff-for-marking-changes-to-tex-documents.html).

I have downloaded the latexdiff files from CTAN and I have also downloaded Strawberry Perl. I am using MiKTeX to compile my two tex documents.

In the command line (DOS prompt) I have been trying to instruct latexdiff to compare two very simple .tex files: SAMPLE4.tex and SAMPLE5.tex. I have been following the instructions in the USAGE section of the first URL I list here ("...using latexdiff..."), specifically:

"Usage

To compare two documents simply run latexdiff in the command line like so:

latexdiff draft.tex revision.tex > diff.tex"

However, when I enter the following into the command line:

C:\Users\Kathryn\latexdiff SAMPLE4.tex SAMPLE5.tex > diff.tex 

I get the following error message:

Input file SAMPLE$.tex does not exist. at 
C:\Program Files\MiKTeX 2.9\scripts\latexdiff\latexdiff line 513, <DATA> line 20026. 

I suspect the problem is that the computer cannot find the file SAMPLE4.tex and that I need to make SAMPLE4.tex (and presumably also SAMPLE5.tex) available in a directory that I can accurately specify in DOS.

I tried putting my two .tex files in C:\Program Files\MikTeX 2.9\latexdiff but this did not work.

Can anyone here offer me some advice?

5
  • 3
    SAMPLE$.tex or SAMPLE5.tex (the error message you quote uses the former) Mar 14, 2014 at 15:48
  • Crosspost to latex community
    – Johannes_B
    Mar 14, 2014 at 17:57
  • 1
    Check with what david wrote above. Also you can't write in program files directory from vista onwards. Navigate to the folder where your tex files are and then use latexdiff (in dos)
    – user11232
    Mar 14, 2014 at 23:45
  • 1
    Why do you not use the latexdiff already available in MiKTeX? If not included yet you can install it with the Package Manager. Then you have to be in the folder with the two files you want to compare, not in the program folder of latexdiff. I hope you not only downloaded Strawberry Perl, but also installed it. See BTW also MiKTeX and Perl scripts (and one Python script).
    – Speravir
    Mar 15, 2014 at 0:00
  • 2
    And almost forgotten: Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. Note also, that your name automatically appears in the lower right corner of your post.
    – Speravir
    Mar 15, 2014 at 0:03

2 Answers 2

10

I had no issues with this on first attempt and this is what I did. I use MiKTeX on Windows 8.

  1. I used MiKTeX Package Manager (admin) to install latexdiff.

  2. I downloaded and installed Strawberry Perl.

  3. I searched for "cmd" on start menu/window search and saw perl(command line)

I opened perl(command line) and changed directory to the directory where my oldfile.tex and newfile.tex was (both in same folder).

Then I executed latexdiff oldfile.tex newfile.tex > diff.tex on the shell prompt.

It generated a diff.tex file in the same folder which I compiled using MiKTeX to get the diff.pdf file.

4
  • 2
    This process has worked for me time and again. Every time I go looking for how to use latexdiff, I find this post again and it is flawless. Wish I could upvote more than once. Feb 14, 2018 at 21:44
  • This worked for me. Thanks! Dec 4, 2019 at 1:10
  • Same for me, perl (command line) works but not the normal cmd or Power Shell. I have added the latexdiff folder to PATH
    – hydradon
    Jan 21, 2020 at 22:56
  • worked for me on Linux as well
    – Vass
    Sep 24, 2020 at 4:19
3

I just faced the same question. Probably you has moved on, but in case this helps the next person.

Following the steps in https://www.sharelatex.com/blog/2013/02/16/using-latexdiff-for-marking-changes-to-tex-documents.html

  1. Install Perl

  2. Download latexdiff from CTAN

  3. Unzip the latexdiff files and copy them to the Perl > bin folder (default installation in C: drive)"

  4. Then give the file latexdiff the .pl extension. In other words, go into latexdiff folder. Find the file called "latexdiff" and change it so it reads "latexdiff.pl".

  5. Now put your two tex files into the latexdiff folder.

  6. Open command line and go to the latexdiff folder using cd. Your command should look something like this:

cd C:\Perl64\bin\latexdiff

Now it's time to run latexdiff. Run the following line (substituting your own file names):

latexdiff.pl Original.tex Revision.tex > Difference.tex

in the command line.

You should find a Difference.tex file in the latexdiff folder. If you compile this in your favorite latex compiler you will see all of the changes.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .