Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

latexdiff -- a user report

94 views
Skip to first unread message

Jon A. Solworth

unread,
Jul 28, 2004, 10:08:45 PM7/28/04
to
I tried latexdiff today, which takes two tex files and produces
a diff tex file with markup of additions and deletions relative to the
two files. It is very, very nice---hats off to the developer,
Frederik Tilmann.

It worked perfectly (the first such tool I've tried for
this purpose that worked robustly). As someone who does a lot of
writing and a lot of editing of other's writing, this is a very
much needed and appreciated tool.

The version of latexdiff I'm using was recently put on CTAN.

Jon

Robin Fairbairns

unread,
Jul 29, 2004, 12:38:00 PM7/29/04
to
"Jon A. Solworth" <solw...@RemoveThisNow.cs.uic.edu> writes:
> I tried latexdiff today, which takes two tex files and produces
>a diff tex file with markup of additions and deletions relative to the
>two files. It is very, very nice---hats off to the developer,
>Frederik Tilmann.
>
> It worked perfectly (the first such tool I've tried for
>this purpose that worked robustly). As someone who does a lot of
>writing and a lot of editing of other's writing, this is a very
>much needed and appreciated tool.

thanks: confirms my instinctive view, from reading the documentation,
that this is one that _has_ to be mentioned in the faq. it's one of
those questions (clear indication of changes) that's been bubbling to
the surface several times a year, for years...
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge

ptk

unread,
Jul 30, 2004, 12:01:05 AM7/30/04
to
On 2004-07-28 21:08:45 -0500, "Jon A. Solworth"
<solw...@RemoveThisNow.cs.uic.edu> said:

Thanks

Michael Friendly

unread,
Jul 30, 2004, 4:54:13 PM7/30/04
to

There's also ldiff
#!/usr/bin/python
# Copyright (C) 2002 Dekel Tsur <dek...@tau.ac.il>

that seems to work similarly (and very well), and also compiles the
diff.tex file for you


--
Michael Friendly Email: frie...@yorku.ca
Professor, Psychology Dept.
York University Voice: 416 736-5115 x66249 Fax: 416 736-5814
4700 Keele Street http://www.math.yorku.ca/SCS/friendly.html
Toronto, ONT M3J 1P3 CANADA

Robin Fairbairns

unread,
Jul 30, 2004, 6:41:16 PM7/30/04
to
Michael Friendly <frie...@yorku.ca> writes:
>There's also ldiff
>#!/usr/bin/python
># Copyright (C) 2002 Dekel Tsur <dek...@tau.ac.il>
>
>that seems to work similarly (and very well), and also compiles the
>diff.tex file for you

the difference being, of course, that the author of ldiff just wrote
it, while the author of latexdiff brought it to the attention of latex
users by putting it on ctan. since latexdiff seems to work, i (for
one) can't be bothered to search for ldiff

Jon A. Solworth

unread,
Jul 31, 2004, 12:17:54 AM7/31/04
to
Robin Fairbairns wrote:
> Michael Friendly <frie...@yorku.ca> writes:
>
>>There's also ldiff
>>#!/usr/bin/python
>># Copyright (C) 2002 Dekel Tsur <dek...@tau.ac.il>
>>
>>that seems to work similarly (and very well), and also compiles the
>>diff.tex file for you
>
>
> the difference being, of course, that the author of ldiff just wrote
> it, while the author of latexdiff brought it to the attention of latex
> users by putting it on ctan. since latexdiff seems to work, i (for
> one) can't be bothered to search for ldiff

Well, I took a quick look. From what I can see, latexdiff looks
better:

1. it can use pdflatex
2. it looks at individual words rather then using change bars
3. its documented

Jon

Michael Friendly

unread,
Aug 3, 2004, 9:48:05 AM8/3/04
to F J Tilmann

In one test, I found that a new file that contains an \input{}
not in the old file appears to marked up correctly in the diff
file, but for some reason the insertion (about two pages) is
not marked up as an insertion after latexing the diff file.

i.e., I get
\DIFaddbegin \input{phillips}

\DIFaddend \section{Enhancements}
but the contents of phillips.tex should all be marked as new.

It is also very slow compared to ldiff, but otherwise does a
somewhat better job of detecting differences.

-Michael

Jon A. Solworth

unread,
Aug 3, 2004, 12:35:47 PM8/3/04
to
Michael Friendly wrote:
>
> In one test, I found that a new file that contains an \input{}
> not in the old file appears to marked up correctly in the diff
> file, but for some reason the insertion (about two pages) is
> not marked up as an insertion after latexing the diff file.
>
> i.e., I get
> \DIFaddbegin \input{phillips}
>
> \DIFaddend \section{Enhancements}
> but the contents of phillips.tex should all be marked as new.
>
> It is also very slow compared to ldiff, but otherwise does a
> somewhat better job of detecting differences.
>
> -Michael
>

Yes, you have to run each file separately for latexdiff.
I'm very happy that there are two competing packages, latexdiff and
ldiff, since this will spur the respective developers to make improvements.

Interesting that latexdiff does a better job of detecting
differences since ldiff appears to be written by a researcher in
string matching. Is this just because the granularity of reporting
(changebars vs. underlining) is finer in latexdiff?

Jon

Frederik Tilmann

unread,
Aug 4, 2004, 6:37:02 AM8/4/04
to
Michael Friendly wrote:
> Jon A. Solworth wrote:
>
>> I tried latexdiff today, which takes two tex files and produces
>> a diff tex file with markup of additions and deletions relative to the
>> two files. It is very, very nice---hats off to the developer,
>> Frederik Tilmann.
>>
>> It worked perfectly (the first such tool I've tried for
>> this purpose that worked robustly). As someone who does a lot of
>> writing and a lot of editing of other's writing, this is a very
>> much needed and appreciated tool.
>>
>> The version of latexdiff I'm using was recently put on CTAN.
>>
>> Jon
>
>
> In one test, I found that a new file that contains an \input{}
> not in the old file appears to marked up correctly in the diff
> file, but for some reason the insertion (about two pages) is
> not marked up as an insertion after latexing the diff file.
>
> i.e., I get
> \DIFaddbegin \input{phillips}
>
> \DIFaddend \section{Enhancements}
> but the contents of phillips.tex should all be marked as new.
>
> It is also very slow compared to ldiff, but otherwise does a
> somewhat better job of detecting differences.
>
> -Michael
>
>

To do this properly latexdiff would have to go and modify philipps.tex
which would not generally be desirable (but might be an idea for an
option in a future version, recursing through all included files).
There is a workaround, alas not fully satisfactory:

With the default settings latexdiff will not generate visual markup for
\DIFaddbegin and \DIFaddend commands. The COLOR subtype was originally
designed to add color with \DIFaddbegin and \DIFaddend but except for
very short texts leads to stack overflow (dvips) or color bleeds out of
its intended range (pdflatex). The package dvipscol.sty
(http://www.ctan.org/tex-archive/macros/latex/contrib/oberdiek/dvipscol.sty)
appears to fix this problem for dvips at least. To use it in latexdiff:

cat > my-latexdiff-preamble.tex <<EOF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\color{blue}\uline{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\color{red}\sout{#1}}}
%DIF PREAMBLE
%DIF MODIFIED COLOR PREAMBLE %DIF PREAMBLE
%Note: only works with dvips %DIF PREAMBLE
\RequirePackage{dvipscol}
\providecommand{\DIFaddbegin}{\nogroupcolor{blue}} %DIF PREAMBLE
\providecommand{\DIFaddend}{\nogroupcolor{black}} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{\nogroupcolor{red}} %DIF PREAMBLE
\providecommand{\DIFdelend}{\nogroupcolor{black}} %DIF PREAMBLE
%DIF IDENTICAL PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{\DIFaddbegin} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{\DIFaddend} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{\DIFdelbegin} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{\DIFdelend} %DIF PREAMBLE
EOF

latexdiff -p my-latexdiff-preamble.tex -t UNDERLINE old.tex new.tex >
diff.tex
latex diff.tex
dvips diff.tex

The included file should now be blue but will not be underlined like the
rest of the added text. In the next version I will include the dvipscol
markup as one of the built-in options, but you can easily do it
yourself; look at the very end of latexdiff for definition of the
various markup-style options - latexdiff does a string comparison to
pick out the right one.

Speed:
Yes, latexdiff is pretty slow. On a 4-year old PC (800Mhz) it took me
about a minute differencing a typical research journal article (10000
words) with maybe 10% changed. As the differencing will generally not
have to be carried out frequently I consider this to be acceptable,
Because of the word level differencing, the time will grow
super-linearly with document length, though, so differencing a whole
book or thesis is probably not feasible (I have no sample book
available). The best I can recommend for now is splitting into chapters
and differencing them separately.

Frederik

Jon A. Solworth

unread,
Aug 4, 2004, 12:27:04 PM8/4/04
to
Frederik Tilmann wrote:
> Speed:
> Yes, latexdiff is pretty slow. On a 4-year old PC (800Mhz) it took me
> about a minute differencing a typical research journal article (10000
> words) with maybe 10% changed. As the differencing will generally not
> have to be carried out frequently I consider this to be acceptable,
> Because of the word level differencing, the time will grow
> super-linearly with document length, though, so differencing a whole
> book or thesis is probably not feasible (I have no sample book
> available). The best I can recommend for now is splitting into chapters
> and differencing them separately.
>
> Frederik
>

I'm using it on a book, currently about 300 pages written using memoir.
I am going through a heavy editing pass, and am at about page 150. It
too 2:10 seconds cpu time, 2:48 elapse time to latexdiff the whole book
(2GHz computer).

It does not seem reasonable to keep a book all in one file.
In addition to defeating the superlinear cost, I have also written a
makefile which latexdiffs only that which has changed. Given that,
the overhead is negligible.

Jon

0 new messages