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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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. – phg Oct 30 '12 at 12:24
Thanks, i followed your suggestion. – Zorzal Zilba Oct 30 '12 at 23:38
up vote 2 down vote accepted

Try texdiff. It should work with ConTeXt.

share|improve this answer
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. – Zorzal Zilba Oct 31 '12 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.

share|improve this answer
\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). – phg Oct 31 '12 at 10:56

Your Answer


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.