I was just wondering if anyone knows of a ConTeXt equivalent to latexdiff?

For those not familiar with latexdiff: it is a Perl script that marks up differences between 2 latex files. It is included with many LaTeX distributions.

It is used as follows:

$ latexdiff old.tex new.tex > diff.tex

Then when you compile the output diff.tex, it shows added text in blue, and deleted text in red strikethrough. E.g., http://haakoh.at.ifi.uio.no/latexdiff/

Does anyone knows of a ConTeXt tool that achieves something similar?

If not, can anyone offer any pointers on how the latexdiff Perl script might be leveraged/ported to a "contextdiff" equivalent?

  • 2
    Could you expand your question as to how exactly the tool you mention works differently from common diff? Context users might not be familiar with Latex specific programs. Oct 30, 2012 at 12:24

2 Answers 2


Try texdiff. It should work with ConTeXt.

  • Thanks, that's exactly what i was looking for. In my answer below I outline the ConTeXt pre-amble i used to get texdiff working similarly to latexdiff. Oct 31, 2012 at 10:09

@user21568 is right, texdiff works with ConTeXt.

However while the texdiff doco lists an example preamble for LaTeX, it doesn't offer any advice for ConTeXt.

So for the benefit of anyone else interested in using texdiff with ConTeXt, here is a preamble that i have found useful:

% Define a blue underline bar for insertions
\definebar[insbar][color=blue, offset=-0.4, continue=yes]

% Define a red strikethrough bar for deletions
\definebar[delbar][color=red, offset=0.5, continue=yes]

% Define the insertion macro. Note the inmargin marker.

% Define the deletion macro.

% Override ConTeXt protect command to do nothing.
% This might have undesired consequences for advanced ConTeXt users?

Note the redefinition of protect: this is a workaround of the fact that the protect commands that texdiff generates do not compile under ConTeXt - it seems that this command has different usage in ConTeXt than in LaTeX.

  • 1
    \protect reinstates the common catcodes, see its definition. Generally it is not safe to redefine but if you do make sure you don’t load any modules after that. You could try replacing the \protect calls in the generated code (but not in Context code) with \unexpanded or \normalprotected). Oct 31, 2012 at 10:56

You must log in to answer this question.

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