完全隐藏 latexdiff 中的删除

完全隐藏 latexdiff 中的删除

我通常会尝试使用latexdiff一种方式,使差异结果看起来与修订后的文档完全一样,只是带有彩色突出显示。但这并不总是有效,例如,当我合并段落时。此示例说明了我的问题:

旧文本

\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}

新特克斯

\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}

然后,我通常这样做来显示差异并隐藏删除:

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

但在上面的例子中,结果如下:

\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}

在此处输入图片描述

请注意,在 b.tex 中,所有内容都是一个段落,但在 diff.tex 中情况并非如此。我该如何解决这个问题?

编辑:我注意到,虽然两个单独的删除包含在两个单独的\DIFdelbegins 中,但它们被包装在同一个\DIFdelbegin...\DIFdelend块中。因此,diff似乎认识到这是一个很大的变化,并latexdiff采取了一些措施将其拆分为两个变化。所以也许有一个选项可以latexdiff不这样做——或者这可能是一个有用的功能请求。

答案1

这当然不是一个完美的解决方案,但对我来说这个解决方案效果出奇的好(在 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

相关内容