latexdiff icon indicating copy to clipboard operation
latexdiff copied to clipboard

Support for UNDERLINE mode in preamble (useful for abstract)

Open smihael opened this issue 2 years ago • 0 comments

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

smihael avatar Sep 28 '22 18:09 smihael