It appears that TeXStudio has a built-in DIFF feature. For example, one can define the syntax highlighting used for differences in the options dialogue.

But if I have two files to compare, say article.tex and article_old.tex, how do I launch the DIFF mode?

The only way I found is to open article.tex and then use "Show differences between two files" item under "File -> SVN..." and then select "article_old.tex". But this behaves very strangely, for example it only hightlights things that are present in article.tex and not in article_old.tex, but not vice versa. (This seems to be the case simply because only lines that are contained in the currently open file are highlighted, and when more lines are present in the OTHER file, they cannot be hightlighted in the currently open one, simply because they are not there.)

The option "Show differences between two files (relative to original file)" behaves even less comprehensibly.

I was unable to find any documentation of the DIFF feature online, so I am asking here: What do I need to do to just get "normal" DIFF between two files, as one would expect?

  • 2
    A diff between two normal files is not supported. Oct 1 '16 at 12:35

I find the DIFF feature to be working differently from what the OP describes; mine works in a way that does indeed make sense. As I write this, the original question is only 3 months old, but maybe the feature has been added or fixed in that time?

  • UPDATE (1 day later):

    It does seem to visually show the differences between the two documents, but attempts at even simple edits while the DIFF feature is active have lead to unpredicted losses of text in sundry places. Perhaps that is what is meant by the feature being unsupported.

I'm using TeXstudio 2.11.2. My Syntax Highlighting scheme for Diff is the default: pink background with the Strikethrough option checked for diffDelete; green background for diffAdd; yellow background for diffReplace. I haven't installed SlickSVN or anything like it. I just have the default installation of TeXstudio.

When I have an open file and I select "Show differences between two files", then it appears TeXstudio treats the already-opened file as the old one. Therefore, I am going to use the OP's example, but switch the files

The currently opened file is "article_old.tex", and under "File -> SVN -> Show differences between two files" I select "article.tex". What I see in the open document (article_old.tex) is:

  • text that is present here but not in "article.tex" is shown with a pink background and strikethrough text

  • text that is absent in "article_old.tex" but present in "article.tex" is now shown here with a green background

  • some text has a yellow background which I haven't completely figured out; perhaps text that is roughly similar but not identical between the two documents.

  • Hi, OP here. Indeed, I now get the behaviour you describe. // As you describe, I cannot make sense of the yellow highlights. // I have not tested editing. // You are right, the old file needs to be the opened one. This really goes against natural workflows (typically, you are going to have the current version open, since that's the one you are editing, and want to know what has changed relative to the previous version). Jan 13 '17 at 9:44
  • 1
    Text with a yellow background appears to be text that differs in the source file but in ways that don't make any difference for the actual final output — certainly, text which is identical except for line breaks seems to be highlighted yellow.
    – Peter Shor
    Feb 12 '20 at 21:15

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.