Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using latexdiff to create a pdf that highlights changes between two .tex along with hg diff latex, so as to use with Mercurial.

However, the problem is that the the strikethrough formatting (which makes things much easier to read) seems to break under multiple paragraphs. This was pointed out by this SE question that went unanswered by @levesque.

A workaround was given here by @Keks Dose, suggesting that people put

\providecommand{\DIFadd}[1]{{\protect\color{blue}#1}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\protect\scriptsize{#1}}}

into the preamble of their files. This replaces the strikethrough highlighting with red text in scriptsize. While this seems to work, the problem is that it is not a terribly attractive solution.

Now 2-3 years later after the original question, is there a workaround to using the broken \sout and latexdiff combination? If not, is there a way to better highlight the text?


Here is a minimal example:

Create a file testdiff1.tex

\documentclass{article}

\begin{document}
\section{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet scelerisque diam, at eleifend dolor. Aliquam id neque placerat, posuere quam vitae, vulputate mauris. Morbi eu aliquam quam, ut posuere mauris. Vestibulum sit amet nisl felis. Proin in felis mauris. Etiam sed egestas velit. Donec pellentesque hendrerit lacus, in rhoncus dolor dignissim condimentum. Nullam sagittis tellus a hendrerit interdum. Duis risus est, semper eu feugiat posuere, interdum sit amet ante. Etiam porta enim quis quam imperdiet suscipit. Donec vel egestas quam, sit amet ullamcorper orci.

Vivamus in augue sit amet erat viverra bibendum at at eros. Donec dignissim aliquet mauris, non pellentesque odio luctus eu. Nunc placerat, sem in hendrerit placerat, risus leo aliquet quam, id tincidunt leo augue vel nisl. Phasellus pharetra felis vitae metus laoreet bibendum. Integer vitae ultricies libero. Proin egestas cursus justo. Ut viverra leo non nunc condimentum suscipit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi suscipit malesuada ultricies. Aliquam a tempor lorem, quis varius lorem. Morbi aliquet dignissim est. Nulla et nibh vel ligula consectetur laoreet quis at neque.

Mauris ornare leo vel sem feugiat lacinia. Mauris placerat tortor eget felis pharetra, quis eleifend odio malesuada. Ut non interdum purus. Donec auctor ante sed erat iaculis convallis. Aliquam convallis laoreet erat, et placerat dolor. Nunc condimentum neque dui, eget malesuada orci bibendum eget. Ut a odio interdum, ullamcorper tellus eget, vehicula orci. Sed congue sem non diam tristique, id sagittis ante congue. Praesent sagittis mi vitae ligula faucibus, et pellentesque eros auctor. Nunc erat est, vehicula eu risus in, semper tincidunt augue. Nam eu eleifend felis, quis dictum urna. Vestibulum eget purus vel lectus tempor ultrices sit amet in ligula. Suspendisse et libero a turpis volutpat vestibulum sit amet porttitor dolor. Etiam pellentesque pretium massa, a vehicula mi ullamcorper quis. Morbi eros nunc, semper quis augue porttitor, posuere interdum tellus.

Vestibulum ultrices vel nibh non consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in mollis eros, in iaculis magna. Vestibulum fermentum non sem nec laoreet. Maecenas sit amet sapien metus. Maecenas consectetur gravida ornare. Nam vel risus nec turpis rutrum viverra ut et augue.

Quisque mattis, libero nec dictum pretium, mauris libero interdum erat, eu pulvinar turpis velit ac velit. Phasellus tempor orci quis aliquet tincidunt. Fusce pharetra, lorem a pellentesque pulvinar, ante ipsum pellentesque quam, et porttitor odio orci ut ligula. Donec ullamcorper eros et fringilla sodales. Curabitur faucibus dui sed ipsum tincidunt congue. Maecenas vel egestas mauris. Proin augue nisi, rutrum et consequat nec, fringilla sed lacus. Phasellus vitae vulputate velit. Nunc ut luctus mi. 
\end{document}

Now create a file testdiff2.tex

\documentclass{article}

\begin{document}
\section{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet scelerisque diam, at eleifend dolor. Aliquam id neque placerat, posuere quam vitae, vulputate mauris. Morbi eu aliquam quam, ut posuere mauris. Vestibulum sit amet nisl felis. Proin in felis mauris. Etiam sed egestas velit. Donec pellentesque hendrerit lacus, in rhoncus dolor dignissim condimentum. Nullam sagittis tellus a hendrerit interdum. Duis risus est, semper eu feugiat posuere, interdum sit amet ante. Etiam porta enim quis quam imperdiet suscipit. Donec vel egestas quam, sit amet ullamcorper orci.


Mauris ornare leo vel sem feugiat lacinia. Mauris placerat tortor eget felis pharetra, quis eleifend odio malesuada. Ut non interdum purus. Donec auctor ante sed erat iaculis convallis. Aliquam convallis laoreet erat, et placerat dolor. Nunc erat est, vehicula eu risus in, semper tincidunt augue. Nam eu eleifend felis, quis dictum urna. Vestibulum eget purus vel lectus tempor ultrices sit amet in ligula. Suspendisse et libero a turpis volutpat vestibulum sit amet porttitor dolor. Etiam pellentesque pretium massa, a vehicula mi ullamcorper quis. Morbi eros nunc, semper quis augue porttitor, posuere interdum tellus. Inserting a new sentence here. Quisque nisi nisl, malesuada at convallis ac, condimentum ac nulla. Suspendisse tempus quam id commodo laoreet. Maecenas vitae diam ornare, vehicula est id, ultricies justo. Quisque a felis ipsum. Mauris suscipit tincidunt enim nec auctor. Nam sem ipsum, sodales ut sollicitudin ut, adipiscing at metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut nulla ac lectus malesuada rhoncus. Vestibulum eget felis lacus. Etiam at erat nec est iaculis cursus. 

Vestibulum ultrices vel nibh non consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in mollis eros, in iaculis magna. Vestibulum fermentum non sem nec laoreet. Maecenas sit amet sapien metus. Maecenas consectetur gravida ornare. Nam vel risus nec turpis rutrum viverra ut et augue.

Quisque mattis, libero nec dictum pretium, mauris libero interdum erat, eu pulvinar turpis velit ac velit. Phasellus tempor orci quis aliquet tincidunt. Fusce pharetra, lorem a pellentesque pulvinar, ante ipsum pellentesque quam, et porttitor odio orci ut ligula. Curabitur faucibus dui sed ipsum tincidunt congue. Maecenas vel egestas mauris. Proin augue nisi, rutrum et consequat nec, fringilla sed lacus. Phasellus vitae vulputate velit. Nunc ut luctus mi. 
\end{document}

Call

latexdiff testdiff1.tex testdiff2.tex > diff.tex

The output diff.tex will contain

%DIF 1a1-12
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL testdiff1.tex   Sun Oct 13 18:36:20 2013
%DIF ADD testdiff2.tex   Sun Oct 13 18:36:21 2013
% This is file JFM2esam.tex
 %DIF > 
% first release v1.0, 20th October 1996
 %DIF > 
%       release v1.01, 29th October 1996
 %DIF > 
%       release v1.1, 25th June 1997
 %DIF > 
%       release v2.0, 27th July 2004
 %DIF > 
%   (based on JFMsampl.tex v1.3 for LaTeX2.09)
 %DIF > 
% Copyright (C) 1996, 1997 Cambridge University Press
 %DIF > 
 %DIF > 
%\NeedsTeXFormat{LaTeX2e}
 %DIF > 
 %DIF > 
%\documentclass{jfm}
 %DIF > 
%\usepackage{natbib}
 %DIF > 
%DIF -------
\documentclass{article}

%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\RequirePackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\uwave{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\sout{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}


\section{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet scelerisque diam, at eleifend dolor. Aliquam id neque placerat, posuere quam vitae, vulputate mauris. Morbi eu aliquam quam, ut posuere mauris. Vestibulum sit amet nisl felis. Proin in felis mauris. Etiam sed egestas velit. Donec pellentesque hendrerit lacus, in rhoncus dolor dignissim condimentum. Nullam sagittis tellus a hendrerit interdum. Duis risus est, semper eu feugiat posuere, interdum sit amet ante. Etiam porta enim quis quam imperdiet suscipit. Donec vel egestas quam, sit amet ullamcorper orci.


\DIFdelbegin \DIFdel{Vivamus in augue sit amet erat viverra bibendum at at eros. Donec dignissim aliquet mauris, non pellentesque odio luctus eu. Nunc placerat, sem in hendrerit placerat, risus leo aliquet quam, id tincidunt leo augue vel nisl. Phasellus pharetra felis vitae metus laoreet bibendum. Integer vitae ultricies libero. Proin egestas cursus justo. Ut viverra leo non nunc condimentum suscipit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi suscipit malesuada ultricies. Aliquam a tempor lorem, quis varius lorem. Morbi aliquet dignissim est. Nulla et nibh vel ligula consectetur laoreet quis at neque.

}%DIFDELCMD < 

%DIFDELCMD < %%%
\DIFdelend Mauris ornare leo vel sem feugiat lacinia. Mauris placerat tortor eget felis pharetra, quis eleifend odio malesuada. Ut non interdum purus. Donec auctor ante sed erat iaculis convallis. Aliquam convallis laoreet erat, et placerat dolor. Nunc \DIFdelbegin \DIFdel{condimentum neque dui, eget malesuada orci bibendum eget. Ut a odio interdum, ullamcorper tellus eget, vehicula orci. Sed congue sem non diam tristique, id sagittis ante congue. Praesent sagittis mi vitae ligula faucibus, et pellentesque eros auctor. Nunc }\DIFdelend erat est, vehicula eu risus in, semper tincidunt augue. Nam eu eleifend felis, quis dictum urna. Vestibulum eget purus vel lectus tempor ultrices sit amet in ligula. Suspendisse et libero a turpis volutpat vestibulum sit amet porttitor dolor. Etiam pellentesque pretium massa, a vehicula mi ullamcorper quis. Morbi eros nunc, semper quis augue porttitor, posuere interdum tellus. \DIFaddbegin \DIFadd{Inserting a new sentence here. Quisque nisi nisl, malesuada at convallis ac, condimentum ac nulla. Suspendisse tempus quam id commodo laoreet. Maecenas vitae diam ornare, vehicula est id, ultricies justo. Quisque a felis ipsum. Mauris suscipit tincidunt enim nec auctor. Nam sem ipsum, sodales ut sollicitudin ut, adipiscing at metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut nulla ac lectus malesuada rhoncus. Vestibulum eget felis lacus. Etiam at erat nec est iaculis cursus. 

}\DIFaddend 

Vestibulum ultrices vel nibh non consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in mollis eros, in iaculis magna. Vestibulum fermentum non sem nec laoreet. Maecenas sit amet sapien metus. Maecenas consectetur gravida ornare. Nam vel risus nec turpis rutrum viverra ut et augue.

Quisque mattis, libero nec dictum pretium, mauris libero interdum erat, eu pulvinar turpis velit ac velit. Phasellus tempor orci quis aliquet tincidunt. Fusce pharetra, lorem a pellentesque pulvinar, ante ipsum pellentesque quam, et porttitor odio orci ut ligula\DIFdelbegin \DIFdel{. Donec ullamcorper eros et fringilla sodales}\DIFdelend . Curabitur faucibus dui sed ipsum tincidunt congue. Maecenas vel egestas mauris. Proin augue nisi, rutrum et consequat nec, fringilla sed lacus. Phasellus vitae vulputate velit. Nunc ut luctus mi. 
\end{document}

The error has to do with the blank lines that are inserted prior to the %DIFDELCMD < comments. Once these are removed, then it compiles. If it is not removed, it does not compile.

As it was pointed out in the old thread, how do we fix this without going through things manually?

share|improve this question
    
I suggest trying the soulutf8 from the Oberdiek bundle instead of the unsupported soul package. An added benefit is that soulutf8 is maintained by Heiko Oberdiek, so if there is a problem with the soulutf8 there may be a fix. –  Sveinung Oct 13 '13 at 14:18
    
As noted in an answer to the other question, soul's \st command allows multiple paragraphs in its argument. If it doesn't works for you please update this question with a complete document that shows the problem. –  David Carlisle Oct 13 '13 at 14:44
    
@DavidCarlisle: I've added a minimal example. –  TSGM Oct 13 '13 at 17:42

1 Answer 1

up vote 3 down vote accepted

As indicated in the linked question, I get no errors from soul's and \st command for the strikeout. I just edited the generated file to look like

\usepackage{soul}
%\RequirePA%ackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\ul{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\st{#1}}}   

enter image description here


In full:

\documentclass{article}

\listfiles
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL testdiff.tex    Sun Oct 13 18:46:33 2013
%DIF ADD testdiff2.tex   Sun Oct 13 18:46:18 2013


%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF UNDERLINE PREAMBLE %DIF PREAMBLE
\usepackage{soul}
%\RequirePA%ackage[normalem]{ulem} %DIF PREAMBLE
\RequirePackage{color}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}\ul{#1}}} %DIF PREAMBLE
\providecommand{\DIFdel}[1]{{\protect\color{red}\st{#1}}}                      %DIF PREAMBLE
%DIF SAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddbegin}{} %DIF PREAMBLE
\providecommand{\DIFaddend}{} %DIF PREAMBLE
\providecommand{\DIFdelbegin}{} %DIF PREAMBLE
\providecommand{\DIFdelend}{} %DIF PREAMBLE
%DIF FLOATSAFE PREAMBLE %DIF PREAMBLE
\providecommand{\DIFaddFL}[1]{\DIFadd{#1}} %DIF PREAMBLE
\providecommand{\DIFdelFL}[1]{\DIFdel{#1}} %DIF PREAMBLE
\providecommand{\DIFaddbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFaddendFL}{} %DIF PREAMBLE
\providecommand{\DIFdelbeginFL}{} %DIF PREAMBLE
\providecommand{\DIFdelendFL}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\section{Introduction}


Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin sit amet scelerisque diam, at eleifend dolor. Aliquam id neque placerat, posuere quam vitae, vulputate mauris. Morbi eu aliquam quam, ut posuere mauris. Vestibulum sit amet nisl felis. Proin in felis mauris. Etiam sed egestas velit. Donec pellentesque hendrerit lacus, in rhoncus dolor dignissim condimentum. Nullam sagittis tellus a hendrerit interdum. Duis risus est, semper eu feugiat posuere, interdum sit amet ante. Etiam porta enim quis quam imperdiet suscipit. Donec vel egestas quam, sit amet ullamcorper orci.




\DIFdelbegin \DIFdel{Vivamus in augue sit amet erat viverra bibendum at at eros. Donec dignissim aliquet mauris, non pellentesque odio luctus eu. Nunc placerat, sem in hendrerit placerat, risus leo aliquet quam, id tincidunt leo augue vel nisl. Phasellus pharetra felis vitae metus laoreet bibendum. Integer vitae ultricies libero. Proin egestas cursus justo. Ut viverra leo non nunc condimentum suscipit. Interdum et malesuada fames ac ante ipsum primis in faucibus. Morbi suscipit malesuada ultricies. Aliquam a tempor lorem, quis varius lorem. Morbi aliquet dignissim est. Nulla et nibh vel ligula consectetur laoreet quis at neque.


}%DIFDELCMD < 

%DIFDELCMD < %%%
\DIFdelend Mauris ornare leo vel sem feugiat lacinia. Mauris placerat tortor eget felis pharetra, quis eleifend odio malesuada. Ut non interdum purus. Donec auctor ante sed erat iaculis convallis. Aliquam convallis laoreet erat, et placerat dolor. Nunc \DIFdelbegin \DIFdel{condimentum neque dui, eget malesuada orci bibendum eget. Ut a odio interdum, ullamcorper tellus eget, vehicula orci. Sed congue sem non diam tristique, id sagittis ante congue. Praesent sagittis mi vitae ligula faucibus, et pellentesque eros auctor. Nunc }\DIFdelend erat est, vehicula eu risus in, semper tincidunt augue. Nam eu eleifend felis, quis dictum urna. Vestibulum eget purus vel lectus tempor ultrices sit amet in ligula. Suspendisse et libero a turpis volutpat vestibulum sit amet porttitor dolor. Etiam pellentesque pretium massa, a vehicula mi ullamcorper quis. Morbi eros nunc, semper quis augue porttitor, posuere interdum tellus. \DIFaddbegin \DIFadd{Inserting a new sentence here. Quisque nisi nisl, malesuada at convallis ac, condimentum ac nulla. Suspendisse tempus quam id commodo laoreet. Maecenas vitae diam ornare, vehicula est id, ultricies justo. Quisque a felis ipsum. Mauris suscipit tincidunt enim nec auctor. Nam sem ipsum, sodales ut sollicitudin ut, adipiscing at metus. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ut nulla ac lectus malesuada rhoncus. Vestibulum eget felis lacus. Etiam at erat nec est iaculis cursus. 


}\DIFaddend 

Vestibulum ultrices vel nibh non consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in mollis eros, in iaculis magna. Vestibulum fermentum non sem nec laoreet. Maecenas sit amet sapien metus. Maecenas consectetur gravida ornare. Nam vel risus nec turpis rutrum viverra ut et augue.


Quisque mattis, libero nec dictum pretium, mauris libero interdum erat, eu pulvinar turpis velit ac velit. Phasellus tempor orci quis aliquet tincidunt. Fusce pharetra, lorem a pellentesque pulvinar, ante ipsum pellentesque quam, et porttitor odio orci ut ligula\DIFdelbegin \DIFdel{. Donec ullamcorper eros et fringilla sodales}\DIFdelend . Curabitur faucibus dui sed ipsum tincidunt congue. Maecenas vel egestas mauris. Proin augue nisi, rutrum et consequat nec, fringilla sed lacus. Phasellus vitae vulputate velit. Nunc ut luctus mi. 

\end{document}

where the \listfiles produces:

 *File List*
 article.cls    2007/10/19 v1.4h Standard LaTeX document class
  size10.clo    2007/10/19 v1.4h Standard LaTeX file (size option)
    soul.sty    2003/11/17 v2.4 letterspacing/underlining (mf)
   color.sty    2005/11/14 v1.0j Standard LaTeX Color (DPC)
   color.cfg    2007/01/18 v1.5 color configuration of teTeX/TeXLive
  pdftex.def    2011/05/27 v0.06d Graphics/color for pdfTeX
infwarerr.sty    2010/04/08 v1.3 Providing info/warning/error messages (HO)
 ltxcmds.sty    2011/11/09 v1.22 LaTeX kernel commands for general use (HO)
supp-pdf.mkii
 ***********

If you need math mode as well you could do

\providecommand{\DIFadd}[1]{{\protect\color{blue}%
 \ifmmode#1\else\ul{#1}\fi}} 

which just colours but omits the underline if in math, or

\providecommand{\DIFadd}[1]{{\protect\color{blue}%
\ifmmode\hbox{\ul{{\mbox{$#1$}}}}\else\ul{#1}\fi}}

which underlines but isn't too careful about preserving whether the math was originally in display or subscript mode (it always sets it using inline math style)

It could be made smarter, and it would presumably need doing for the DIFdel variant as well, but either of these work with your test file as amended in the comments.

share|improve this answer
    
I can't seem to get this to work. Can you copy and paste the entire .tex file you're compiling? Even with your edit, mine spits out the error:"Paragraph ended before \UL@word was complete" and "Improper \spacefactor." –  TSGM Oct 13 '13 at 20:24
    
@TSGM answer updated –  David Carlisle Oct 13 '13 at 20:28
    
that seems to compile. Can you do me a favour and add this line to the end of the testdiff2.tex and verify that it doesn't compile? `\begin{equation}A = B\end{equation}' –  TSGM Oct 13 '13 at 20:52
    
@TSGM there you go: That's why we always ask for an example document that demonstrates the problem:-) I'll have a quick look –  David Carlisle Oct 13 '13 at 20:56
    
@TSGM answer updated (again) –  David Carlisle Oct 13 '13 at 21:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.