0

I run Windows 7, 64bit.
In order to produce a new .tex file with the differences between two versions of the same document, following the online tutorial https://www.youtube.com/watch?v=IAWEywCx9hQ, I have created a latexdiff macro in Tex Studio with the script as exactly shown in this answer, https://tex.stackexchange.com/a/464270/228739, which is

%SCRIPT

var cf = app.getCurrentFileName();

var ld = new String(cf);
ld=ld.substring(0,ld.lastIndexOf("/"));

information("old version");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec();
var fold=new String();
fold=fileChooser.fileName();
fold=fold.substring(fold.lastIndexOf("/")+1);

information("new version");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec();
var fnew=new String();
fnew=fileChooser.fileName();
fnew=fnew.substring(fnew.lastIndexOf("/")+1);

information("diff file by Chas");
fileChooser.setDir(ld);
fileChooser.setFilter("TeX files (*.tex)");
fileChooser.exec(fout);
var fout=new String();
fout=fileChooser.fileName();
fout=fout.substring(fout.lastIndexOf("/")+1);

ldfout = ld+"\\"+fout;

var cmdstr = new String();
cmdstr = "latexdiff-so "+fold+" "+fnew+" > /dev/null";
var proc = system("cmd /C "+cmdstr,ld);
proc.waitForFinished();
writeFile(ldfout, proc.readAllStandardOutputStr());
app.load(ldfout); // load diff file
buildManager.runCommand("txs:///quick", ldfout);

delete(cmdstr);
delete(dialog);
delete(fold);
delete(fnew);
delete(fout);
delete(ld);
delete(ldfout);

I was able to run the latexdiff TexStudio macro successfully, using the example files of the video tutorial (extremely simple files). So it appears that the basic installation setup ((Active)Perl, latexdiff in MikTek) is ok. It appears that the macro requires for the files to be open in order to run successfully.

BUT, I have been totally unsuccessful in getting it to run using my own .tex files, which are of \documentclass{article}, with math, figures, tables and references in them. Both the "initial" version and the "revised" .tex files, when compiled produce only "overfull / underful \hbox" log-comments, and the message is "process exited normally". On their own, they compile ok and are built and viewed in .pdf ok also.

But when I try to run the latexdiff TexStudio macro with my files it immediately aborts with the message

! Emergency stop. <*> "./trackchanges.tex"

*** (job aborted, no legal \end found)"

"Trackchanges.tex" is the name of the totally empty .tex file that should be filled by the latexdiff script, and it was filled correctly when I used the example files of the tutorial. But never with my own .tex files.

Question: Is there any general knowledge as why this may be happening, or it is something that I have to think of as too file-specific, having to do with some incompatibility between the preamble/whateverelse in my files, and the script above?

1 Answer 1

0

I was not able to solve this. But the same files that could not be processed through the TexStudio macro, were processed just fine by running the latexdiff command from Command Prompt. This means that the installation is ok (MikTex and Active Perl), and something in the script was fatally sensitive to something in my files.

To run latexdiff from Command Promprt, the only requirement is that both the initial file and the revised file are in the same folder. Once one goes there (using the archaic language of DOS), then one just types

latexdiff initial.tex revised.tex > trackchanges.tex

where "initial", "revised" and "trackchanges" are stand-ins for the actual filenames.

Note that the "trackchanges.tex" file is not to be created beforehand - the latexdiff command creates it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .