biblatex:仅在书中删除最后一位作者后的逗号

biblatex:仅在书中删除最后一位作者后的逗号

我使用的是 biblatex,带有 biber 后端和 chem-acs 样式。对于期刊和论文集,作者列表会打印在标题后面;但是,对于书籍和书籍章节,最后一位作者后面有一个逗号。我想去掉那个多余的逗号。

有关 MWE,请参见下文。

到目前为止,我读了一些类似问题的解决方案。删除最后一位作者后的逗号需要删除最后一位作者后的逗号(仅限)似乎可以处理手动创建的.bst 文件,并且我想使用 chem-acs 样式。

在问题中使用 biblatex、字母表的作者后使用冒号 (:) 代替句号 (.),一个很好的解决方案是

\renewcommand{\labelnamepunct}{\addcolon\space}

然而,这似乎只适用于期刊,而不适用于我的“有问题的”书籍类型。

一个解决方案似乎是完全重新定义书籍的书目驱动程序,但我想绕过这一点,因为我只想删除一个逗号。

我查看了该chem-acs.bbx文件,发现了以下定义:

\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{maintitle+title}%
(...)
}

我注意到,如果我注释掉行\setunit{\labelnamepunct}\newblock,逗号会保留。所以我认为它是在 bibmacro 中的某个地方定义的author/translator+others。但是,我不知道如何以合理的方式重新定义该宏,而且据我所知,也不可能只为除 journal 以外的类型重新定义它。

这里是 MWE:

.tex 文件:

\documentclass{standalone}

\usepackage[style=chem-acs,articletitle,chaptertitle,backend=biber]{biblatex}
\addbibresource{mwe.bib}

\begin{document}

  Some journals: \cite{Agrafiotis2000,Agrafiotis2003}
  A book, chapter, and inproceeding: \cite{Ozgur2005,Alpaydin2010,Joachims1999}

  \printbibliography

\end{document}

.bib 文件:

@INPROCEEDINGS{Ozgur2005,
  author = {{\"O}zg{\"u}r, Arzucan and {\"O}zg{\"u}r, Levent and G{\"u}ng{\"o}r,
Tunga},
  title = {{Text Categorization with Class-Based and Corpus-Based Keyword Selection}},
  booktitle = {Proceedings of the 20th International Conference on Computer and
Information Sciences},
  year = {2005},
  pages = {606-615},
}

@ARTICLE{Agrafiotis2000,
  author = {Dimitris K. Agrafiotis and Victor S. Lobanov},
  title = {{Nonlinear Mapping Networks}},
  journal = {Journal of Chemical Information and Computer Sciences},
  year = {2000},
  volume = {40},
  number = {6},
  pages = {1356-1362},
}

@ARTICLE{Agrafiotis2003,
  author = {Dimitris K. Agrafiotis and Huafeng Xu},
  title = {{A Geodesic Framework for Analyzing Molecular Similarities}},
  journal = {Journal of Chemical Information and Computer Sciences},
  year = {2003},
  volume = {43},
  number = {2},
  pages = {475-484},
}

@BOOK{Alpaydin2010,
  title = {{Introduction to Machine Learning}},
  publisher = {MIT Press},
  year = {2010},
  author = {Ethem Alpaydin},
  edition = {2nd},
}

@INBOOK{Joachims1999,
  chapter = {{Making Large-Scale Support Vector Machine Learning Practical}},
  pages = {169-184},
  title = {{Advances in Kernel Methods}},
  publisher = {MIT Press},
  year = {1999},
  editor = {Sch{\"o}lkopf, Bernhard and Burges, Christopher J. C. and Smola,
Alexander J.},
  author = {Joachims, Thorsten},
}

输出:参考文献 (4) 和 (5) 在作者后包含逗号

答案1

chem-acs样式中,\newunitpunct宏被定义为\addcomma\addspace,因此每当您启动一个新单元时,您都会得到一个逗号。对于book条目,单元由 bibmacro 启动,maintitle+title而对于inbook条目,单元由驱动程序本身启动。虽然您可以全局设置\newunitpunct,但这会对整个地方产生影响。相反,我会使用xpatch包来更本地化地修补 bibmacro 和驱动程序,并用于\setunit本地控制标点符号。

\xpatchbibmacro{maintitle+title}{\newunit\newblock}{\newunit\setunit{\addspace}\newblock}{}{}
\xpatchbibdriver{inbook}{\usebibmacro{byauthor}\newunit}{\usebibmacro{byauthor}\newunit\setunit{\addspace}}{}{}

答案2

您可能想尝试以下步骤。

和似乎bibdriver不太适合这项任务,因为inbookincollectioninproceedings\labelnamepunct因为不是直接插入在 之前title,但在其他字段之前。

\usebibmacro{author/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit
  \iftoggle{bbx:chaptertitle}
    {\usebibmacro{title}}
    {}%

将以下几行添加到你的序言中。首先,我们更新maintitle+title

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
      {}
      {\usebibmacro{maintitle}}%
      %\newunit\newblock%<-- we comment this
    }%
  \usebibmacro{title}%
  \newunit
}

\newcommand{\patchcomma}[1]{%
  \xpatchbibdriver{#1}
    {\usebibmacro{title}}
    {\setunit{\labelnamepunct}\newblock\usebibmacro{title}}
    {\typeout{patched macro (#1)}}{\typeout{failed to patch macro (#1)}}
}
\patchcomma{inbook}\patchcomma{incollection}

因此我们修补s 以直接在 之前driver包含。\labelnamepuncttitle

数学家协会

\documentclass{article}
\usepackage[style=chem-acs,articletitle,chaptertitle,backend=biber]{biblatex}
\usepackage{filecontents}
\usepackage{xpatch}
\addbibresource{\jobname.bib}
\begin{filecontents*}{\jobname.bib}
@INPROCEEDINGS{Ozgur2005,
  author = {{\"O}zg{\"u}r, Arzucan and {\"O}zg{\"u}r, Levent and G{\"u}ng{\"o}r,
Tunga},
  title = {{Text Categorization with Class-Based and Corpus-Based Keyword Selection}},
  booktitle = {Proceedings of the 20th International Conference on Computer and
Information Sciences},
  year = {2005},
  pages = {606-615},
}

@ARTICLE{Agrafiotis2000,
  author = {Dimitris K. Agrafiotis and Victor S. Lobanov},
  title = {{Nonlinear Mapping Networks}},
  journal = {Journal of Chemical Information and Computer Sciences},
  year = {2000},
  volume = {40},
  number = {6},
  pages = {1356-1362},
}

@ARTICLE{Agrafiotis2003,
  author = {Dimitris K. Agrafiotis and Huafeng Xu},
  title = {{A Geodesic Framework for Analyzing Molecular Similarities}},
  journal = {Journal of Chemical Information and Computer Sciences},
  year = {2003},
  volume = {43},
  number = {2},
  pages = {475-484},
}

@BOOK{Alpaydin2010,
  title = {Introduction to Machine Learning},
  publisher = {MIT Press},
  year = {2010},
  author = {Ethem Alpaydin},
  edition = {2nd},
}

@INBOOK{Joachims1999,
  title = {{Making Large-Scale Support Vector Machine Learning Practical}},
  pages = {169-184},
  booktitle = {{Advances in Kernel Methods}},
  booksubtitle = {Support Vector Learning},
  publisher = {MIT Press},
  year = {1999},
  editor = {Sch{\"o}lkopf, Bernhard and Burges, Christopher J. C. and Smola,
Alexander J.},
  author = {Joachims, Thorsten},
}
\end{filecontents*}

\renewbibmacro*{maintitle+title}{%
  \iffieldsequal{maintitle}{title}
    {\clearfield{maintitle}%
     \clearfield{mainsubtitle}%
     \clearfield{maintitleaddon}}
    {\iffieldundef{maintitle}
      {}
      {\usebibmacro{maintitle}}%
      %\newunit\newblock
    }%
  \usebibmacro{title}%
  \newunit
}

\newcommand{\patchcomma}[1]{%
  \xpatchbibdriver{#1}
    {\usebibmacro{title}}
    {\setunit{\labelnamepunct}\newblock\usebibmacro{title}}
    {\typeout{patched macro (#1)}}{\typeout{failed to patch macro (#1)}}
}
\patchcomma{inbook}\patchcomma{incollection}
\begin{document}

  Some journals: \cite{Agrafiotis2000,Agrafiotis2003}
  A book, chapter, and inproceeding: \cite{Ozgur2005,Alpaydin2010,Joachims1999}

  \printbibliography

\end{document}

产量

在此处输入图片描述

相关内容