TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

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 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:

diff example

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

Does anyone know if such a TeX package exists?

share|improve this question
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. – 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
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 '11 at 13:16
    
@Daniel: just did it, thanks for the suggestion – Stéphane Péchard Sep 15 '11 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. – Martin Scharrer Sep 15 '11 at 14:30

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.

share|improve this answer

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

share|improve this answer
    
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 at 14:55
    
@TorbjørnT Perhaps using \input latexdiff could do this. – A Feldman Mar 10 at 16:23
    
I don't follow, isn't latexdiff a Perl script? How does inputting that help? – Torbjørn T. Mar 10 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 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. – Torbjørn T. Mar 11 at 8:07

Your Answer

 
discard

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.