I have just made significant revisions to my thesis which has been typeset with ConTeXt. The project file pulls from approximately 20-30 files spread over 8 directories producing a document of 414 pages.

This document is amazingly resistant to normal diffing tools, even if I export the files in an amazingly broken XML export. Is there a diff or wdiff technique that can produce a list of changes and is intelligent enough to detect when whole sections have been moved around?

Is the "best" way simply to wdiff input files and then somehow concatenate those diffs into an output file?

  • What can I say... Are you sure that such a complicated structure is the best possible one? One possible solution might be to pdf2txt the resulting document and diff this one. This might be a better idea after making a special "mode" to eliminate page numbers, headers etc.
    – mbork
    Apr 1, 2012 at 19:42
  • I've tried that with very poor results. I think the answer is, as you note: "Don't" but I'm hoping to be surprised. Apr 1, 2012 at 19:46
  • Although the output here will be typeset with ConTeXt, I don't see how the question relates to TeX. Producing the diff is, as described, not done using TeX or a related tool.
    – Joseph Wright
    Apr 1, 2012 at 20:11
  • Well, part of it is getting diffable output from context or some (unknown?) aspect of context that could do diffing trivially. Apr 1, 2012 at 20:19
  • 2
    Moving sections around confuses any "diff" tool I know. They are simply not built to do this. The easiest thing would be to have each section in a file of its own, and when you have to reorder them, reorder the \include statements in the master document.
    – DevSolar
    Apr 2, 2012 at 10:51

1 Answer 1


There is no way for ConTeXt (or any other TeX macro package or engine) to know you have moved sections around. So unless you added some structure beforehand (by putting things in named buffers or separate input files, for example) the diff output will be large.

The XML export in ConTeXt is indeed using the output order, but comparing the XML output (whether it is good or bad) is not very easy with non-XML tools and besides, it is not quite the input as the link to files and line numbers is lost (same problem with pdf2txt export).

My approach to complex changes tracking in large projects is to use a version control system and/or IDE. But if you cannot do that, I assume pdf2txt is your least crappy option to get something that diff likes, or alternatively use something like xmldiff on ConTeXt's XML export.

  • Does ConTeXt implement something like the changes package for LaTeX? It would be quite useful to be able to track changes manually in certain cases. I love using ConTeXt for legal documents, I can create more easily than in LaTeX the structures of those documents. Just need to be able to track the changes as it would be in LaTeX with a similar tool, that would be great.
    – Aradnix
    Oct 30, 2017 at 20:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.