Biblatex 中有太多亚里士多德、太多阿威罗西和太多分号:我怎样才能让 \citeauthor 的行为更像 \textcite?

Biblatex 中有太多亚里士多德、太多阿威罗西和太多分号:我怎样才能让 \citeauthor 的行为更像 \textcite?

Biblatex 提供了\textcite\citeauthor以及其他命令,用于在文档正文中引用资源。

但是,与不同\textcite,它\citeauthor的行为并不像我预期的那样。可能它的行为也不像以前那样,但我对此不确定。

请考虑以下示例:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex}
\bibliography{biblatex-examples}
\begin{document}

\verb|\Textcite| and \verb|\textcite| behave as expected:

\Textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Textcite{averroes/bland,averroes/hannes} and \textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\verb|\Citeauthor| and \verb|\citeauthor| do not behave as expected\footnote{By me.}:

\Citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Citeauthor{averroes/bland,averroes/hannes} and \citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\printbibliography
\end{document}

我希望\citeauthor使用 时,它会合并同一作者的多个参考文献,就像\textcite使用 时一样。然而,这并没有发生:

<code>\textcite</code> 与 <code>\citeauthor</code> (默认样式)

如果我使用authoryear-comp,情况会变得更糟:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[style=authoryear-comp,backend=biber]{biblatex}
\bibliography{biblatex-examples}
\begin{document}

\verb|\Textcite| and \verb|\textcite| behave as expected:

\Textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Textcite{averroes/bland,averroes/hannes} and \textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\verb|\Citeauthor| and \verb|\citeauthor| do not behave as expected\footnote{By me.}:

\Citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Citeauthor{averroes/bland,averroes/hannes} and \citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\printbibliography
\end{document}

我本以为这里的多位作者的名字应该用逗号隔开,但这里却使用了分号。现在,在括号引用中这样做是完全可以的,也是意料之中的,但在文本流中这样做并不合适。

<code>\textcite</code> 与 <code>\citeauthor</code> (<code>authoryear-comp</code>)

当然,在这个特殊情况下,使用分号只会带来问题,因为作者的名字意外重复。不过,我可能想要类似

\Citeauthor{aristotle:poetics,averroes/bland} ate the soup.

分号

如果 Biblatex 在我应该使用 的地方使用逗号and,我可以理解,但使用分号就太荒谬了。

这是预期的行为吗?我倾向于将其视为错误,但据我所知,这是一个值得珍惜的功能!

无论如何,阻止它的最佳方法是什么?考虑到这种有问题的模式可能感染的不仅仅是\citeauthor,我想知道最通用的解决方案是什么。

答案1

如果sortcites启用按名称排序的样式,我们实际上可以很快

\newbibmacro*{citeauthor}{%
  \ifnameundef{labelname}
    {\usebibmacro{cite:reinit}}
    {\iffieldequals{namehash}{\cbx@lasthash}
       {}
       {\printnames{labelname}%
        \savefield{namehash}{\cbx@lasthash}}}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \usebibmacro{citeauthor}}
  {\setunit{\addcomma\space}}
  {\usebibmacro{postnote}}

我们只记住姓氏,如果当前名字与姓氏相同,则不会打印当前名字。

请注意此定义如何使用\setunit{\addcomma\space}而不是\multicitedelim因为这可能会给出分号,这取决于您的风格。

在 MWE 中,有额外的代码可以运行不支持的样式cite:init,并且cite:reinit

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber,style=numeric,style=authoryear-icomp]{biblatex}
\bibliography{biblatex-examples}

\makeatletter
\providebibmacro*{cite:reinit}{%
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}
\providebibmacro*{cite:init}{\usebibmacro{cite:reinit}}

\newbibmacro*{citeauthor}{%
  \ifnameundef{labelname}
    {\usebibmacro{cite:reinit}}
    {\iffieldequals{namehash}{\cbx@lasthash}
       {}
       {\printnames{labelname}%
        \savefield{namehash}{\cbx@lasthash}}}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \usebibmacro{citeauthor}}
  {\setunit{\addcomma\space}}
  {\usebibmacro{postnote}}
\makeatother

\begin{document}

\verb|\Textcite| and \verb|\textcite| behave as expected:

\Textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Parencite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Textcite{averroes/bland,averroes/hannes} and \textcite{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\verb|\Citeauthor| and \verb|\citeauthor| do not behave as expected\footnote{By me.}:

\Citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} once took a bath.

\Citeauthor{averroes/bland,averroes/hannes} and \citeauthor{aristotle:poetics,aristotle:physics,aristotle:rhetoric} opened the tin of soup together.

\Citeauthor{averroes/bland,knuth:ct:a,averroes/hannes}

\printbibliography
\end{document}

示例输出


为了好玩,这里有一个基于 的解决方案\textcite,允许使用\textcitedelim。 它的主要优点是您可以使用\iffinalcitedelim将最后一项用“and”分隔开。

\providebibmacro*{cite:reinit}{%
  \global\undef\cbx@lasthash
  \global\undef\cbx@lastyear}
\providebibmacro*{cite:init}{\usebibmacro{cite:reinit}}

\newbibmacro*{citeauthor}{%
  \ifnameundef{labelname}
    {\usebibmacro{cite:reinit}}
    {\iffieldequals{namehash}{\cbx@lasthash}
        {}
        {\printnames{labelname}%
         \stepcounter{textcitecount}%
         \savefield{namehash}{\cbx@lasthash}}}%
  \setunit{\textcitedelim}}   

\DeclareCiteCommand{\cbx@citeauthor}
  {\usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citeauthor}}
  {}
  {\usebibmacro{postnote}}

\providerobustcmd{\cbx@textcite@init}[2]{%
  \setcounter{textcitetotal}{0}%
  \setcounter{textcitecount}{0}%
  \def\cbx@savedcites{#1}#2\cbx@savedcites\empty}

\DeclareCiteCommand{\citeauthor}[\cbx@textcite@init\cbx@citeauthor]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{cite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}

\DeclareDelimcontextAlias{cbx@citeauthor}{textcite}

这应该适用于大多数风格,因为它\provide的命令具有可能不可用的合理默认值。

你可能需要

\renewcommand*{\iffinalcitedelim}{%
  \ifnumequal{\value{textcitecount}}{\value{textcitetotal}-1}}

但是大多数标准.cbx样式都将其作为默认样式。

相关内容