For the purposes of showing corrections to a PhD thesis, I am using latexdiff to produce a PDF showing the difference between the original and the new version.

My examiner has requested me to not simply colour code the text, but also highlight it. That is, it is not sufficient to have the deleted text in red struck out and the changed text in blue, but on top of it, the deleted text must also be highlighted in a custom colour.

I tried the \hl command provided by the soul package in a custom preamble passed to latexdiff, but this causes so many errors in the document. What would be the correct way to do this? The following is the custompreamble.tex that I tried. I am using lualatex (TL 2018), but I am not sure if this is relevant.


\RequirePackage[normalem]{ulem} %DIF PREAMBLE 
\definecolor{cbreweryellow}{RGB}{255,247,188}  % custom color for highlighting deleted text

\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} \newcommand\hsout[1]{\let\helpcmd\sout\parhelp#1\par\relax\relax}               
    \helpcmd{#1}\ifx\relax#2\else\par\parhelp#2\relax\fi %                                                                 

\providecommand{\DIFdel}[1]{{\color{red}{\hldel{\hsout{#1}}}}} <----- % causes errors  
% \providecommand{\DIFdel}[1]{{\color{red}{\hsout{#1}}}} <---- comment out previous line and uncomment this line to get a working result

%DIF SAFE PREAMBLE                                                                                                        

%DIF IDENTICAL PREAMBLE                                                                                                   

%DIF LISTINGS PREAMBLE                                                                                                    
\lstdefinelanguage{DIFcode}{ %DIF PREAMBLE                                                                                
%DIF DIFCODE_UNDERLINE                                                                                                    
  moredelim=[il][\color{red}\hsout]{\%DIF\ <\ },                                                
  moredelim=[il][\color{blue}]{\%DIF\ >\ }                                                             
} %                                                                                                                         

Here is an example diff.tex file generated (without the lines of the custom preamble above). To make a working document, we need to paste the lines from this custom preamble into the below code, just before the \begin{document} line.



\DIFdelbegin \DIFdel{In this chapter all the necessary information to fully understand the actual application is presented. First, a short overview about the history of multi-touch interfaces is provided. Particular attention is paid to the Microsoft Surface that was used to develop this application. Since the application is used to automatically detect code smells in a software project, the chapter \textit{\nameref{chp:metrics}} explains how code metrics can be used to detect code smells. Finally this chapter addresses how the necessary structural information and code metrics of a software project were retrieved from a web service in order to perform a code smell analysis. }%DIFDELCMD < 

%DIFDELCMD < \FloatBarrier
\section{\DIFdel{The history of multi-touch user interfaces}}
\DIFdel{The user interface is the place where the }\DIFdelend \DIFaddbegin \section{\DIFadd{Motivation}}
\DIFadd{User interfaces are one of the fastest changing areas in software engineering. Not long ago \textit{Command Line Interfaces (CLI)} were the only available input method. \textit{Graphical User Interfaces (GUI)} changed the }\DIFaddend interaction between humans and \DIFdelbegin \DIFdel{machines takes place. Most user interfaces allow bidirectional interactions. This means the user has the possibility to enter input in order to manipulate and control the system and the machine has the possibility to create output to inform the user about the effects of its inputs. The basic goal of all user interfaces is to require minimal input in order to produce the desired output while minimizing the undesired output at the same time.}%DIFDELCMD < \\

How can I achieve the desired effect?

  • Using ulem and soul commands together will imho never work. You would have to define either a special new soul command or try some lua magic. The question is how many hours are you (or someone else) willing to invest in this request? Is is really worth the trouble? Jan 3, 2019 at 9:23
  • @UlrikeFischer alright then. Can the desired effect be achieved with using ulem macros alone without loading soul ? Jan 3, 2019 at 14:59

1 Answer 1


You can try a command like this:

\textwidth 2cm

\reduline{abc abc blub blub bla bla}

enter image description here


You must log in to answer this question.

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