I look for a TeX package that could do the following, or anything close. I image the simpler use case as giving two text files of any kind as parameters :


and this command would compute a diff over these files and include into the produced document a visual rendering like:

diff example

with maybe the line number or any other useful information about it.

Does anyone know if such a TeX package exists?

  • 4
    The simplest way would be to run diff on the files and use listings to include the result. You would have to define your own syntax highlighting scheme. Sep 15, 2011 at 11:15
  • Certainly the simplest if nothing else exists... not the most convenient to use though :-( Sep 15, 2011 at 12:59
  • 3
    The question title is misleading in a way that the question seems to be off topic. You might want to rephrase it so that your intent becomes more clear (somewhat in the direction of "Are there any LaTeX packages to compute/typeset the diff between two files?")
    – Daniel
    Sep 15, 2011 at 13:16
  • @Daniel: just did it, thanks for the suggestion Sep 15, 2011 at 13:25
  • 3
    Coding a diff tool in TeX would be overkill and not required. The only thing you could expect is a formatting package for the result of a diff output. Even for this an external tool might be better suited. Sep 15, 2011 at 14:30

2 Answers 2


I would recommend external tools and implement them using shortcuts, scripts ... You can use Winmerge for it on windows. Similar tools exist for linux/unix.


There now is a latexdiff package. An interesting way of using latexdiff is Zaphod which combines change tracking in git with latexdiff markup.

  • This isn't exactly what was asked for. latexdiff creates a new .tex file that shows the diff between two other .tex files, while the OP wanted to take two files of any type (e.g. C code, log files, config files), and print the diff of those in his LaTeX document. (There is in fact a deleted answer mentioning latexdiff already, which is visible to everyone with >10k rep.) Mar 10, 2016 at 14:55
  • @TorbjørnT Perhaps using \input latexdiff could do this.
    – A Feldman
    Mar 10, 2016 at 16:23
  • I don't follow, isn't latexdiff a Perl script? How does inputting that help? Mar 10, 2016 at 16:28
  • @TorbjørnT I thought you could use \input in any latex file to input the text of any text based file as if typed into the .tex file by hand. My thought would be to \input{file.txt} as the body of one .tex file and to \input{file2.txt} as the body of a second .tex file and then use latexdiff to compare the two. I think there is a "flatten" option for latexdiff that might make this possible.
    – A Feldman
    Mar 10, 2016 at 16:33
  • I sort of see what you mean, and I realize I completely misunderstood you before. Anyways, a general solution will likely also have to take care of special characters (&, _, ^ etc.), so some work might be needed, if it works at all. If you could make an example it would certainly improve your answer. Mar 11, 2016 at 8:07

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.