# Are there any LaTeX packages to compute and render the diff between two text files?

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 :

``````\diff{file1}{file2}
``````

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

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

Does anyone know if such a TeX package exists?

• 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. – Andrey Vihrov Sep 15 '11 at 11:15
• Certainly the simplest if nothing else exists... not the most convenient to use though :-( – Stéphane Péchard Sep 15 '11 at 12:59
• 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 '11 at 13:16
• @Daniel: just did it, thanks for the suggestion – Stéphane Péchard Sep 15 '11 at 13:25
• 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. – Martin Scharrer Sep 15 '11 at 14:30

• 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.) – Torbjørn T. Mar 10 '16 at 14:55
• I don't follow, isn't `latexdiff` a Perl script? How does inputting that help? – Torbjørn T. Mar 10 '16 at 16:28