Latexdiff 和 biblatex 引用命令

Latexdiff 和 biblatex 引用命令

latexdiff在使用biblatex引用命令\parencite和时遇到了麻烦\textcite

old.tex

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.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"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
\begin{document}

\textcite{greenwade93} is the best article on \LaTeX \parencite{goossens93}.

\printbibliography

\end{document}

new.tex

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.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"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
\begin{document}

\textcite{goossens93} is the best book on \LaTeX \parencite{greenwade93}.

\printbibliography

\end{document}

跑步latexdiff old.tex new.tex > diff.tex可得:

\documentclass[a4paper]{article}
%DIF LATEXDIFF DIFFERENCE FILE
%DIF DEL old.tex   Sun Jul 26 18:28:46 2020
%DIF ADD new.tex   Sun Jul 26 18:28:55 2020
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{bibliography.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"
}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
    publisher = "Addison-Wesley",
    address   = "Reading, Massachusetts"
}
\end{filecontents}
\usepackage[style=apa,backend=biber]{biblatex}
\addbibresource{bibliography.bib}
%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}

\textcite{\DIFdelbegin \DIFdel{greenwade93}\DIFdelend \DIFaddbegin \DIFadd{goossens93}\DIFaddend } is the best \DIFdelbegin \DIFdel{article }\DIFdelend \DIFaddbegin \DIFadd{book }\DIFaddend on \LaTeX \DIFdelbegin %DIFDELCMD < \parencite{goossens93}%%%
\DIFdelend \DIFaddbegin \parencite{greenwade93}\DIFaddend .

\printbibliography

\end{document}

编译后pdflatex结果为:

在此处输入图片描述

问题在于latexdiff将标记命令放在\textcite命令中,这显然不起作用。添加natbib=truebiblatex选项并更改\textcite\citet和更改\parencite\citep会给出正确的输出: 在此处输入图片描述

文档(第 4 节)指出:

以下软件包触发特殊行为:
...
apacite、biblatex
重新定义识别为引用命令的命令。

这是一个错误latexdiff还是我遗漏了什么?

我很乐意使用这些natbib命令,但我正在使用来自这个答案在超链接中包含作者姓名。

natbib编辑:事实证明,使用命令而不是标准命令时,moewe 的代码将作者包含在引文链接中运行良好biblatex。我不知道它是如何工作的,但它解决了我眼前的问题。

答案1

您可以添加选项--exclude-textcmd=textcite以强制 latexdiff 正确处理\textcite命令(从 latexdiff v1.3.2 开始,如果使用 biblatex 包,则此行为将是默认行为)

相关内容