6

I'm using latexdiff to highlight the differences between two versions of a tex document, using the default style which is UNDERLINE. This style formats added text in blue with a wavy underline, and removed text in red with a strikethough.

I'm interested in formatting the output such that added text is in blue but without the wavy underline (and removed text is in red as before). Is there a command for achieving this? I wasn't able to figure it out from the man page.

Another way would be to modify the CCHANGEBAR style, which formats added text in blue and removed text in red but without the strikethrough, to add the strikethrough to the removed text (my question is how).

  • CFONT is more robust as a basis than CCHANGEBAR, if you don't actually want or need the changebars. – frederik Jun 22 '16 at 15:30
7

There is no standard option to do this, but you can create your own preamble file for latexdiff to replace the highlighting commands. All you need to do after a standard run of latexdiff is to copy the lines latexdiff writes in to the header of the diff file and change those that do not fit your style. In your case the command to change is \DIFadd that by default is

\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE

The wavy underlining is generated by \uwave{...}, so removing this we get

\providecommand{\DIFadd}[1]{{\protect\color{blue}#1}}

A complete preamble file is then

\RequirePackage[normalem]{ulem}
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1}
\providecommand{\DIFadd}[1]{{\protect\color{blue}#1}}
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                    
\providecommand{\DIFaddbegin}{}
\providecommand{\DIFaddend}{}
\providecommand{\DIFdelbegin}{}
\providecommand{\DIFdelend}{}
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}}
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}}
\providecommand{\DIFaddbeginFL}{}
\providecommand{\DIFaddendFL}{}
\providecommand{\DIFdelbeginFL}{}
\providecommand{\DIFdelendFL}{} 

which if you call this preamble.tex can be used by latexdiff via

latexdiff -p preamble.tex old.tex new.tex > diff.tex

With new.tex

\documentclass{article}

\begin{document}

The text now starts with this.

\end{document}

and old.tex

\documentclass{article}

\begin{document}

The text started with this.

\end{document}

this generates a diff.tex that produces

Sample output

0

Another option is to edit the file latexdiff using text editor, change the line from

\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE

to

\providecommand{\DIFadd}[1]{{\protect\color{blue}#1}}

as said above. In this way, no need to create any permeable files.

  • Welcome to TeX.SE. Please explain what a "permeable" file is. – Mico Aug 9 '17 at 12:43
  • I would not recommend modifying package files at all. If one is only interested in the command you mention, \providecommand{\DIFadd}[1]{{\protect\color{blue}#1}} in the preamble is enough. There is no need for extra files, just that one line in the preamble. Changing package files could be problematic depending on the license (IANAL) and those changes will be overwritten if the package is updated. It will also greatly decrease portability of your document because the output will now depend on a changed file that only you have. – moewe Aug 9 '17 at 12:57

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.