ftilmann / latexdiff

Compares two latex files and marks up significant differences between them. Releases on www.ctan.org and mirrors
GNU General Public License v3.0
514 stars 72 forks source link

latexdiff prints commands before preamble #163

Open hughjonesd opened 5 years ago

hughjonesd commented 5 years ago

diff.txt bar-newauthor-rmd.txt bar-rmd.txt

The latexdiff (version 1.3.0) output from diffing the attached files fails to compile with pdflatex. This seems to be because the command prints difdel and difadd commands before defining them. See the attached diff.tex . These are outputs from standard Rmarkdown files, that's why I haven't simplified them. I have tried various exclude-safecmd options but nothing seems to stop latexdiff messing with author, title etc.

ftilmann commented 5 years ago

Normally it works to use \DIF commands even in \title, \author, even if they are only defined later, for example this file in the test suite has a similar structure but compiles fine. titlediffTest2-diff-1.3.0.txt The reason is that these do not actually get executed until the \maketitle gets executed. In your example it is obviously different, but I could not figure out which package is responsible. In any case these commands in the preamble, whose content is marked up are in the list context2cmd

latexdiff --replace-context2cmd="none" should suppress this (none is just an arbitrary word as it does not take an empty argument (a minor bug, I guess). I have not tested this, so let me know if this works.

hughjonesd commented 5 years ago

Actually, if I run raw latexdiff, then run pdflatex, it stops with "Undefined control sequence", but if I then hit R to make it run in nonstopmode, it produces a pdf output. I am not sure if there is a different pdflatex command that would avoid the stoppage.

Using --replace-context2cmd="none" indeed fixes this, thanks.