2

I usually try to use latexdiff in a way that the diff result looks exactly as the revised document, just with colored highlights. But this does not always work, for example, when I merge paragraphs. This example illustrates my problem:

old.tex

\documentclass{article}
\begin{document}
    This is text in paragraph 1. This text will be deleted.

    This text here will also be deleted. That text here is in paragraph 2. Finally, everything shall be in one paragraph.
\end{document}

new.tex

\documentclass{article}
\begin{document}
    This is text in paragraph 1. That text here is in paragraph 2. Finally, everything shall be in one paragraph.
\end{document}

Then, I usually do this to show differences while hiding deletions:

echo \newcommand{\DIFdel}[1]{} > diff.tex
latexdiff old.tex new.tex >> diff.tex

But in the above example, this is the result:

\begin{document}
    This is text in paragraph 1. \DIFdelbegin \DIFdel{This text will be deleted.
    }%DIFDELCMD < 

%DIFDELCMD <    %%%
\DIFdel{This text here will also be deleted. }\DIFdelend That text here is in paragraph 2. Finally, everything shall be in one paragraph.
\end{document}

enter image description here

Note that in b.tex, everything is one paragraph, but this is not true in diff.tex. How can I fix that?

Edit: I have noticed that, while the two individual deletions are contained in two separate \DIFdelbegins, they are wrapped in the same \DIFdelbegin...\DIFdelend block. So the diff seems to recognize that this is one big change, and latexdiff does something to split this into two changes, it seems. So maybe there is an option in latexdiff to not do that -- or maybe that would be a useful feature request.

1

This is certainly not a perfect solution, but this one works surprisingly well for me (on Windows):

echo \newcommand{\DIFdel}[1]{} > diff.tex
echo \RequirePackage{verbatim} >> diff.tex
latexdiff -s COLOR --disable-auto-mbox --exclude-textcmd="textit,footnote,section,subsection" --graphics-markup=0 --math-markup=0 old.tex new.tex ^
    | sed "s-\\\DIFdelbegin -\\\begin{comment}-g" ^
    | sed "s-\\\DIFdelend -\\\end{comment}\n-g" ^
    >> diff.tex

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.