Latexdiff 和 \textcquote

Latexdiff 和 \textcquote

这可能是latexdiff引用,但我想弄清楚事情的真相。

考虑old.tex

\documentclass{article}

\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
\end{filecontents}
\begin{document}

\textcquote[p.~342]{greenwade93}{Hi}.
\bibliographystyle{plainnat}
\bibliography{\jobname} 
\end{document}

new.tex

\documentclass{article}

\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
\end{filecontents}
\begin{document}

Test % That's the only change.
\bibliographystyle{plainnat}
\bibliography{\jobname} 
\end{document}

然后latexdiff old.tex new.tex > diff.tex产生

\documentclass{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old.tex   Wed Jul 15 11:16:30 2020
%DIF ADD new.tex   Wed Jul 15 11:16:21 2020

\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@article{greenwade93,
    author  = "George D. Greenwade",
    title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
    year    = "1993",
    journal = "TUGBoat",
    volume  = "14",
    number  = "3",
    pages   = "342--351"
}
\end{filecontents}
%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
\providecommand{\DIFmodbegin}{} %DIF PREAMBLE
\providecommand{\DIFmodend}{} %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 LISTINGS PREAMBLE %DIF PREAMBLE
\RequirePackage{listings} %DIF PREAMBLE
\RequirePackage{color} %DIF PREAMBLE
\lstdefinelanguage{DIFcode}{ %DIF PREAMBLE
%DIF DIFCODE_UNDERLINE %DIF PREAMBLE
  moredelim=[il][\color{red}\sout]{\%DIF\ <\ }, %DIF PREAMBLE
  moredelim=[il][\color{blue}\uwave]{\%DIF\ >\ } %DIF PREAMBLE
} %DIF PREAMBLE
\lstdefinestyle{DIFverbatimstyle}{ %DIF PREAMBLE
    language=DIFcode, %DIF PREAMBLE
    basicstyle=\ttfamily, %DIF PREAMBLE
    columns=fullflexible, %DIF PREAMBLE
    keepspaces=true %DIF PREAMBLE
} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim}{\lstset{style=DIFverbatimstyle}}{} %DIF PREAMBLE
\lstnewenvironment{DIFverbatim*}{\lstset{style=DIFverbatimstyle,showspaces=true}}{} %DIF PREAMBLE
%DIF END PREAMBLE EXTENSION ADDED BY LATEXDIFF

\begin{document}

\DIFdelbegin \DIFdel{\textcquote[p.~342]{greenwade93}{Hi}.
}\DIFdelend \DIFaddbegin \DIFadd{Test %DIF >  That's the only change.
}\DIFaddend \bibliographystyle{plainnat}
\bibliography{\jobname} 
\end{document}

无法编译。返回的错误消息是

! Extra }, or forgotten \endgroup.
\UL@stop ...z@ \else \UL@putbox \fi \else \egroup 
                                                  \egroup \UL@putbox \fi \if...
l.60 }
      \DIFdelend \DIFaddbegin \DIFadd{Test %DIF >  That's the only change.
? 

我经历过Latexdiff 手册根本找不到我的例子有什么问题……

答案1

您正在使用 ulem 包中的 \sout 来删除,这非常脆弱,无法处理任意输入。这在这里简直爆炸了:

\documentclass{article}
\usepackage{ulem}
\usepackage{csquotes}
\begin{document}
\sout{\textcquote[p.~342]{greenwade93}{Hi}}
\end{document}

使用 lualatex,你可以使用 lua-ul 包,它可以轻松处理以下命令:

\documentclass{article}
\usepackage{lua-ul}
\let\sout\strikeThrough
\usepackage{csquotes}
\begin{document}
\sout{\textcquote[p.~342]{greenwade93}{Hi}}
\end{document}

在此处输入图片描述

相关内容