使用 biblatex,是否可以用 bibnamedash 或 idem 字符串替换作者列表中的一位作者?

使用 biblatex,是否可以用 bibnamedash 或 idem 字符串替换作者列表中的一位作者?

使用 biblatex,可以在参考书目中用破折号(或“idem”)替换作者。如果有多个作者,并且这些作者中的第一个与之前列出的书籍的作者相同,是否也可以进行这种替换?(这有点难以描述,请参阅所附示例,其中也应替换“Buchautor,Hans-Wilhelm” book3。)

我认为通过定制应该可以实现\DeclareNameFormat,但我不知道如何做。

最小示例:

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{book1,
  author = {Buchautor, Hans-Wilhelm},
  title = {Irgendein Buch},
  location = {Buch am Wald},
  date = {2000}
}
@BOOK{book2,
  author = {Buchautor, Hans-Wilhelm},
  title = {Ein anderes Buch},
  location = {Berlin},
  date = {2001}
}
@BOOK{book3,
  author = {Buchautor, Hans-Wilhelm and Zweitautor, Zoran},
  title = {Noch ein Buch},
  location = {London and New York},
  date = {2010}
}
\end{filecontents}

\usepackage[
style=authortitle,
backend=bibtex8
]{biblatex}
\bibliography{\jobname}

\renewcommand*{\bibnamedash}{%
  \bibstring[\mkbibbold]{idem\thefield{gender}}}

\begin{document}
\nocite{*}

\printbibliography
\end{document}

编辑 15/02/2011 17:14

我应该补充一下,biber 有一个功能请求,它指向了 biblatex。参见此功能请求

编辑 21/06/2011 9:26

现在使用 biblatex 1.4/1.5 可以实现这一点吗?我尝试了一下 uniquename/uniquelist,但无法让它工作。

答案1

可以使用 中的内部列表将当前author/中的主名称editor与先前书目条目的author/进行比较。可以使用 构建这些列表。editoretoolbox\indexnames

一些计数器和对最后条目gender字段的跟踪有助于确保名称正确分隔并使用适当的idem参考书目字符串。

为简单起见,我假设没有截断author/ editor。可以允许截断。但是,由此产生的风格会相当模糊;重复andothers读起来相同,但可能指不同的作者/编辑。

解决方案肯定可以变得更加高效,可能使用一个例程来从给定列表的末尾删除指定数量的元素。它还可以更智能地利用字段中可用的信息gender,无论是来自最后一个条目之前的条目还是来自当前条目。

\documentclass{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[american]{babel}
\usepackage{csquotes}
\usepackage[style=authortitle,% Based on this style
            maxbibnames=99,% Solution assumes no truncation
            backend=biber,% Needed if using hash field
            sorting=nyt,
            abbreviate=false]{biblatex}

\newcounter{bbx:idemcount}
\newcounter{bbx:namecount}

\newbibmacro*{bbx:printlist}[1]{%
  \global\csundef{bbx:namelist}%
  \global\csundef{bbx:checklist}%
  \setcounter{bbx:namecount}{0}%
  \indexnames[bbx:checklist]{#1}%
  \ifcsequal{bbx:checklist}{bbx:idemlist}
    {\ifnumequal{\value{bbx:namecount}-\value{bbx:idemcount}}{1}
       {\let\finalandcomma=\empty}
       {}%
     \printnames[idem:first-last]{#1}}
    {\printnames{#1}}}

\DeclareIndexNameFormat{bbx:checklist}{%
  \addtocounter{bbx:namecount}{1}%
  \listcsxadd{bbx:namelist}{\thefield{hash}}% Or #4 #5 #1 might be sufficient
  \ifnumgreater{\value{listcount}}{\value{bbx:idemcount}}
    {}
    {\listcsxadd{bbx:checklist}{\thefield{hash}}}}

% authortitle uses sortname format - i.e. last-first/first-last
% Use \biblstring \bibxlstring for long idem, irrespective of
% the abbreviate option setting
\DeclareNameFormat{idem:first-last}{%
  \ifnumequal{\value{listcount}}{1}
    {\ifboolexpr{ test {\ifbibxstring{idem\csuse{bbx:idemgender}}}
                  and test {\ifcsdef{bbx:idemgender}} }
       {\bibstring[\mkbibbold]{idem\csuse{bbx:idemgender}}}
       {\ifnumgreater{\value{bbx:idemcount}}{1}
          {\bibstring[\mkbibbold]{idempn}}
          {\bibstring[\mkbibbold]{idemsn}}}}
    {\ifnumgreater{\value{listcount}}{\value{bbx:idemcount}}
       {\iffirstinits
          {\usebibmacro{name:first-last}{#1}{#4}{#5}{#7}}
          {\usebibmacro{name:first-last}{#1}{#3}{#5}{#7}}}
       {}}}

\newbibmacro*{bbx:savelist}{%
  \savefieldcs{gender}{bbx:idemgender}%
  \setcounter{bbx:idemcount}{\value{bbx:namecount}}%
  \csxdef{bbx:idemlist}{\csuse{bbx:namelist}}}

\renewbibmacro*{author}{%
  \ifboolexpr{ test {\ifuseauthor}
               and not test {\ifnameundef{author}} }
    {\usebibmacro{bbx:printlist}{author}%
     \setunit{\addcomma\space}%
     \usebibmacro{bbx:savelist}%
     \usebibmacro{authorstrg}}
    {\global\csundef{bbx:idemlist}%
     \setcounter{bbx:idemcount}{0}}}

\renewbibmacro*{bbx:editor}[1]{%
  \ifboolexpr{ test {\ifuseeditor}
               and not test {\ifnameundef{editor}} }
    {\usebibmacro{bbx:printlist}{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{bbx:savelist}%
     \usebibmacro{#1}%
     \clearname{editor}}
    {\global\csundef{bbx:idemlist}%
     \setcounter{bbx:idemcount}{0}}}

\renewbibmacro*{bbx:translator}[1]{%
  \ifboolexpr{ test {\ifusetranslator}
               and not test {\ifnameundef{translator}} }
    {\usebibmacro{bbx:printlist}{translator}%
     \setunit{\addcomma\space}%
     \usebibmacro{bbx:savelist}%
     \usebibmacro{#1}%
     \clearname{translator}}
    {\global\csundef{bbx:idemlist}%
     \setcounter{bbx:idemcount}{0}}}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@BOOK{book1,
  author = {Buchautor, Emma-Louise},
  gender = {sf},
  title = {First Title},
  date = {2001}}
@BOOK{book2,
  author = {Buchautor, Emma-Louise},
  title = {Same female author},
  date = {2002}}
@BOOK{book3,
  author = {Buchautor, Emma-Louise and van Helsing, Sarah},
  gender = {pf},
  title = {Same first author whose gender is unspecified},
  date = {2003}}
@BOOK{book4,
  author = {Buchautor, Emma-Louise and van Helsing, Sarah and Knuth, Donald E.},
  gender = {pp},
  title = {Same first and second female authors},
  date = {2004}}
@BOOK{book5,
  editor = {Buchautor, Emma-Louise and van Helsing, Sarah and Knuth, Donald E. and Cicero, Marcus Tullius},
  gender = {pp},
  title = {Same leading names of mixed genders},
  date = {2005}}
@BOOK{book6,
  editor = {van Helsing, Abraham},
  title = {Different name},
  date = {2006}}
@BOOK{book7,
  author = {van Helsing, Abraham},
  gender = {sm},
  translator = {van Helsing, Abraham},
  title = {Same male name},
  date = {2007}}
@BOOK{book8,
  editor = {van Helsing, Abraham and Jackson, Tom},
  gender = {pm},
  translator = {Cicero, Marcus Tullius},
  title = {Same first male author},
  date = {2008}}
@BOOK{book9,
  author = {van Helsing, Abraham and Jackson, Tom},
  title = {Same male names},
  date = {2009}}
@BOOK{book10,
  author = {van Helsing, Abraham and Jackson, Tom},
  gender = {pm},
  title = {Same authors of unspecified gender},
  date = {2010}}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

在此处输入图片描述

为了进行比较,这里是在参考书目宏未发生任何变化的情况下生成的相同参考书目authortitle

在此处输入图片描述

答案2

据我所知,这目前还不可能。这是传统 bibtex 格式的一个限制。您无法真正处理作者字段中的个人(当涉及到姓名前缀或性别等内容时,同样的问题也会出现,如果作者字段中有多个作者,则无法为一个作者设置这些前缀或性别)。我知道这将在以后的 biber 版本中得到改进(TODO 中说是 1.3 版)。

编辑:我也不确定你的情况是否真的需要这种行为。只要风格不需要,我就不会这么做。毕竟,破折号是为了表明作者是相同的,但如果有多个作者,作者身份就变了。

相关内容