如何在 latexdiff 应用的删除格式中包含已删除章节的章节编号?

如何在 latexdiff 应用的删除格式中包含已删除章节的章节编号?

我有一份文档,已被标记latexdiff并编辑以使其编译。

已删除部分的当前输出与此类似:

删除部分

我如何在删除标记中包含章节编号?也就是说,我希望“1 已删除章节”全部为红色并划掉,而不是“1”为黑色,只有“已删除章节”为红色并划掉。

\documentclass{article}
\usepackage{soul,xcolor,kantlipsum}

%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF CFR PREAMBLE %DIF PREAMBLE
\usepackage[normalem]{ulem} %DIF PREAMBLE
\usepackage{xcolor}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}#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 %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\kant[1]

\DIFdelbegin %DIFDELCMD <

%DIFDELCMD < %%%
\section{\DIFdel{Deleted section}}%DIFAUXCMD
\addtocounter{section}{-1}%DIFAUXCMD
%DIFDELCMD <

\kant[2]

\section{Unchanged section}

\kant[3]

\end{document}

答案1

这里有一份手动版本。但我不知道它是否适合您的工作流程。

\documentclass{article}
\usepackage{soul,xcolor,kantlipsum}

%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF PREAMBLE EXTENSION ADDED BY LATEXDIFF
%DIF CFR PREAMBLE %DIF PREAMBLE
\usepackage[normalem]{ulem} %DIF PREAMBLE
\usepackage{xcolor}\definecolor{RED}{rgb}{1,0,0}\definecolor{BLUE}{rgb}{0,0,1} %DIF PREAMBLE
\providecommand{\DIFadd}[1]{{\protect\color{blue}#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 %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}
\kant[1]

\DIFdelbegin %DIFDELCMD <

\makeatletter
\renewcommand\@seccntformat[1]{\textcolor{red}{\sout{\csname the#1\endcsname\quad}}}
\makeatother
%DIFDELCMD < %%%
\section{\DIFdel{Deleted section}}%DIFAUXCMD
\addtocounter{section}{-1}%DIFAUXCMD
%DIFDELCMD <

\makeatletter
\renewcommand\@seccntformat[1]{\csname the#1\endcsname\quad}
\makeatother

\kant[2]

\section{Unchanged section}

\kant[3]

\end{document}

在此处输入图片描述

相关内容