我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=true
到biblatex
选项并更改\textcite
为\citet
和更改\parencite
为\citep
会给出正确的输出:
这文档(第 4 节)指出:
以下软件包触发特殊行为:
...
apacite、biblatex
重新定义识别为引用命令的命令。
这是一个错误latexdiff
还是我遗漏了什么?
我很乐意使用这些natbib
命令,但我正在使用来自这个答案在超链接中包含作者姓名。
natbib
编辑:事实证明,使用命令而不是标准命令时,moewe 的代码将作者包含在引文链接中运行良好biblatex
。我不知道它是如何工作的,但它解决了我眼前的问题。
答案1
您可以添加选项--exclude-textcmd=textcite
以强制 latexdiff 正确处理\textcite
命令(从 latexdiff v1.3.2 开始,如果使用 biblatex 包,则此行为将是默认行为)