当连续两次引用同一个名称时,使用 biblatex-apa 进行完全链接引用的代码会出现问题

当连续两次引用同一个名称时,使用 biblatex-apa 进行完全链接引用的代码会出现问题

我遇到了一个非常具体的问题。使用biberhyperref,我试图使用作者的名字作为hyperref参考(不仅仅是年份),这与bibtex/类似natbib。总的来说,我认为它看起来相当不错,但在尝试连续两次引用同一位作者时会出现问题: 在此处输入图片描述

当两次引用同一个作者时,我希望得到与 4) 相同的输出,但使用\parenciteor\textcite代替\citeauthorand then \citeyear

生成上述输出的代码:

\documentclass{scrartcl}
\usepackage[backend=biber, style=apa]{biblatex}
\addbibresource{Bib.bib}
\usepackage{hyperref}
\usepackage{xcolor}
\hypersetup{
    colorlinks,
    linkcolor={red!50!black},
    citecolor={blue!50!black},
    urlcolor={blue!80!black}
}

\input{biberhyperlink.tex}

\begin{document}

1) First citations \parencite{Meltzer.Richard.1981} work quite nicely \parencite{Facchini.2018}.

2) However, when citing one author \parencite{Meltzer.Richard.1981} a second time in a row \parencite{Meltzer.Richard.1983}, it does not.

3) \textcite{Meltzer.Richard.1981} and \textcite{Meltzer.Richard.1983} does not work properly either.

4) \citeauthor{Meltzer.Richard.1981} (\citeyear{Meltzer.Richard.1981}) and \citeauthor{Meltzer.Richard.1983} (\citeyear{Meltzer.Richard.1983}) would work as a workaround.

\end{document}

文件biberhyperlink.tex定义了修改的函数。我从其他 tex stackexchange 问题中获取了它们(超链接名称与 biblatex 作者年份使用 \citeauthor 时在 biblatex 中超链接作者姓名) 如下所示。我猜想其中有一个错误,但我自己无法弄清楚:

% https://tex.stackexchange.com/questions/1687/hyperlink-name-with-biblatex-authoryear

\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
    \printtext[bibhyperref]{\usebibmacro{citeyear}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
  \printtext[bibhyperref]{ \usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\textcite}
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{textcite}}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}%
   \multicitedelim}
  {\usebibmacro{textcite:postnote}}

% https://tex.stackexchange.com/questions/75902/hyperlinking-author-names-in-biblatex-when-using-citeauthor
\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

为了复制目的,这是我的bib文件Bib.bib

@article{Facchini.2018,
 author = {Facchini, Francois},
 year = {2018},
 title = {{What Are the Determinants of Public Spending? An Overview of the Literature}}
}
@article{Meltzer.Richard.1981,
 author = {Meltzer, Allan H. and Richard, Scott F.},
 year = {1981},
 title = {{A Rational Theory of the Size of Government}}
}
@article{Meltzer.Richard.1983,
 author = {Meltzer, Allan H. and Richard, Scott F.},
 year = {1983},
 title = {{Tests of a Rational Theory of the Size of Government}}
}

如果这个问题没有解决方案,我将不得不使用 4) 中显示的解决方法,但显然,我更喜欢更简单的解决方案。

答案1

代码来自超链接名称与 biblatex 作者年份是为 编写的style=authoryear,。它根本不能与biblatex-apa一起使用style=apa,

biblatex-apa建议采用以下方法BibLaTeX 颜色和链接仅显示年份,不显示其余引文此答案之前包含一个 MWE,其中包含 v9.14 的代码biblatex-apa。为了避免传播过时的代码,我决定在此处将其删除。请参阅BibLaTeX 颜色和链接仅显示年份,不显示其余引文对于 MWE。

相关内容