似乎曾经有一个可行的解决方案,但我猜随着 biblatex 的更新,它已经停止工作了:
https://tex.stackexchange.com/a/46469/36836
也许有人能够更新解决方案或建议新的解决方案?
答案1
该答案假设biblatex
版本> = 3.4。
我们必须更改代码以使其符合新的名称格式(参见Biblatex 3.3 名称格式)。此外,我还修改了代码,使用名称哈希,而不是依赖字符串比较。
代码实现了一个新选项nametracker
。如果设置为,context
则将分别跟踪文本和脚注的名称,如果设置为global
(或true
),则不会分别跟踪名称。当然,该选项只能在定义后执行。因此,在 MWE 中,它不能在加载时设置,只能用来设置\ExecuteBibliographyOptions
。
\documentclass[british]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel,csquotes}
\usepackage[style=authoryear, backend=biber]{biblatex}
\addbibresource{biblatex-examples.bib}
\makeatletter
\newrobustcmd*{\cbx@nametracker@global}[1]{%
\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
{}
{\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}
\newrobustcmd*{\cbx@nametracker@context}[1]{%
\iftoggle{blx@footnote}
{\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}
{}
{\listcsxadd{cbx@fseen@names@\the\c@refsection}{#1}}}
{\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}
{}
{\listcsxadd{cbx@bseen@names@\the\c@refsection}{#1}}}}
\newrobustcmd*{\cbx@ifnameseen@global}[1]{%
\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}
\newrobustcmd*{\cbx@ifnameseen@context}[1]{%
\iftoggle{blx@footnote}%
{\xifinlistcs{#1}{cbx@fseen@names@\the\c@refsection}}%
{\xifinlistcs{#1}{cbx@bseen@names@\the\c@refsection}}}
\DeclareBibliographyOption[string]{nametracker}[true]{%
\ifcsdef{blx@opt@nametracker@#1}
{\csuse{blx@opt@nametracker@#1}}
{\blx@err@invopt{nametracker=#1}{}}}
\def\blx@opt@nametracker@global{%
\let\cbx@ifnameseen\cbx@ifnameseen@global
\let\cbx@nametracker\cbx@nametracker@global}
\let\blx@opt@nametracker@true\blx@opt@nametracker@global
\def\blx@opt@nametracker@false{%
\protected\long\def\cbx@ifnameseen##1##2##3{##3}%
\let\cbx@nametracker\relax}
\def\blx@opt@nametracker@context{%
\let\cbx@ifnameseen\cbx@ifnameseen@context
\let\cbx@nametracker\cbx@nametracker@context}
\appto\blx@secinit{%
\ifcsundef{cbx@bseen@names@\the\c@refsection}
{\global\cslet{cbx@bseen@names@\the\c@refsection}\@empty}
{}%
\ifcsundef{cbx@fseen@names@\the\c@refsection}
{\global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
{}}
\InitializeCitationStyle{%
\global\cslet{cbx@bseen@names@\the\c@refsection}\@empty
\global\cslet{cbx@fseen@names@\the\c@refsection}\@empty}
\ExecuteBibliographyOptions{nametracker=context}
\DeclareNameFormat{labelname}{%
\cbx@ifnameseen{\thefield{hash}}
{\ifcase\value{uniquename}%
\usebibmacro{name:family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}%
\or
\ifuseprefix
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefix}
{\namepartsuffixi}}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiveni}
{\namepartprefixi}
{\namepartsuffixi}}%
\or
\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}%
\fi}
{\usebibmacro{name:given-family}
{\namepartfamily}
{\namepartgiven}
{\namepartprefix}
{\namepartsuffix}%
\cbx@nametracker{\thefield{hash}}}%
\usebibmacro{name:andothers}}
\makeatother
\begin{document}
\cite{companion}
\cite{companion}
\cite{knuth:ct:a}
\cite{knuth:ct:b}
\end{document}
给出
米歇尔·古森斯、弗兰克·米特尔巴赫和亚历山大·萨马林 1994 年
Goossens、Mittelbach 和 Samarin 1994
唐纳德·E·克努斯 1984
Knuth 1986