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
506 stars 72 forks source link

Support for UNDERLINE mode in preamble (useful for abstract) #273

Open smihael opened 1 year ago

smihael commented 1 year ago

As per https://www.researchgate.net/post/How-can-I-track-changes-in-LaTeX-especially-abstractenvironment, one of the issues that might arise from using latediff is that by default it doesn't work with abstract environment, that is used in many journal templates.

In order to enable diff in abstract section one has to use the --append-context2cmd option: latexdiff --append-context2cmd="abstract" old.tex new.tex > diff.tex

However, this often results in compilation issues, since the default visualization mode is UNDERLINE, which uses ulem package for visual markup. The problem is that the compiler wants to pass the abstract also as metadata for the PDF file and of course it's impossible to apply \sout there, much like the problem described here: https://tex.stackexchange.com/questions/268658/in-beamer-how-can-one-have-strikethrough-text-in-the-author-setting-defined-by

A possible workaround is to use CFONT mode, which only changes color (no strike-through or curly underline), but I personally find it confusing.

I suggest to implement a workaround allowing to display visual markup, but pass (or not) plain text to PDF:

\providecommand{\DIFadd}[1]{\protect\cbstart{\protect\color{blue}\texorpdfstring{\uwave{#1}}{#1}}\protect\cbend} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{\protect\cbdelete{\protect\color{red}\texorpdfstring{\sout{#1}}{}}\protect\cbdelete} %DIF PREAMBLE

Credits for the idea go to: https://tex.stackexchange.com/a/268967