带有简写的书的不同名称格式

带有简写的书的不同名称格式

我正在 biblatex 中根据 authoryear 设置自己的 bbx 文件,并希望它在书籍有简写时以另一种名称格式输出作者。通常它应该输出例如“Albert E.”,所以我定义了

\DeclareNameAlias{sortname}{first-last}
\DeclareNameFormat{first-last}{%
  \iffirstinits
    {\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
    {\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}%
  \usebibmacro{name:andothers}
}

对于使用简写的书籍,应该输出“Albert Einstein”等缩写,而不缩写姓氏。我该如何实现这一点?

梅威瑟:

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}

\usepackage[backend=biber,style=authoryear-icomp,]{biblatex}
\begin{filecontents}{lit.bib}
@book{regular,
title = {Book's title},
author = {Lastname, Firstname},
location = {The City},
publisher = {Publisher},
date = {2005},
}
@book{withshorthand,
shorthand = {short},
title = {Book's title},
author = {Lastname2, Firstname2},
location = {The City},
publisher = {Publisher},
date = {2005},
}
\end{filecontents}
\addbibresource{lit.bib}

\DeclareNameAlias{sortname}{first-last}
\DeclareNameFormat{first-last}{%
  \iffirstinits
    {\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
    {\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}%
  \usebibmacro{name:andothers}}

\begin{document}
some\parencite{regular} text\parencite{withshorthand}
\printbibliography
\end{document}

输出:

MWE 输出

由于它有简写,第二个参考书目条目应该有“Firstname2 Lastname2”,不是像 #1 这样的正常条目一样缩写作者的姓氏。

答案1

您可以在声明中使用标准字段测试,例如:

\DeclareNameFormat{first-last}{%
  \iffirstinits
    {\usebibmacro{name:first-last}{#2}{#4}{#5}{#7}}
    {\iffieldundef{shorthand}
     {\usebibmacro{name:first-last}{#2}{#3}{#5}{#7}}
     {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}%
  \usebibmacro{name:andothers}}

正如评论中提到的,此定义不适用于 biblatex 3.3。其中 \DeclareNameFormat 具有不同的语法。

相关内容