biblatex、标点符号和空白字段

biblatex、标点符号和空白字段

我在 biblatex 和标点符号方面遇到了一个小问题,比如当一个字段(比如作者)可能为空时。当定义了作者时,我想插入一个逗号而不是句号,但是即使作者为空,我也无法插入逗号。

所以我有

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}  
\usepackage[american,italian]{babel}
\usepackage[italian]{babel}
\usepackage[babel,italian=guillemets]{csquotes}

\usepackage[style=mario-standard,defernumbers=true,sorting=ynt,maxbibnames=99]{biblatex}
\addbibresource{min.bib}

\begin{document}
\noindent 
\cite{*}

\defbibnote{A}{Group A}
\defbibnote{B}{Group B}

\newrefcontext[labelprefix={A-}]
\printbibliography[prenote={A}, keyword=A] 
\newrefcontext[labelprefix={B-}]
\printbibliography[prenote={B}, keyword=B] 
\end{document}

min.bib 文件是

@Book{AAA,
%author = {NO Author},
label = {MM},
title = {aaa},
publisher = {book pub},
location = {myTown},
year = {2020},
 keywords = {A}
}

@Book{BBB,
author = {mario myself},
title = {bbb},
publisher = {book pub},
location = {myTown},
year = {2020},
 keywords = {B}
}

我使用自定义的 .bbx 文件,其中\DeclareBibliographyDriver{book}定义为:

\DeclareBibliographyDriver{book}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\labelnamepunct}\newblock
  \usebibmacro{maintitle+title}%
  \iffieldundef{note}{
    \newunit\newblock}{
    \printfield{note}
    }
  \newunit
  \printlist{language}
  \newunit\newblock
  \usebibmacro{byauthor}
  \newunit\newblock
  \usebibmacro{byeditor+others}
  \newunit\newblock
  \printfield{howpublished}%
  \setunit{\bibpagerefpunct}\subtitlepunct\newblock
  \printfield{edition}%
  \newunit
  \iffieldundef{maintitle}
    {\printfield{volume}%
     \printfield{part}}
    {}%
  \newunit
  \printfield{volumes}%
  \newunit\newblock
  \usebibmacro{series+number}%
  \newunit\newblock
  \usebibmacro{publisher+location+date}%
  \newunit\newblock
  \usebibmacro{chapter+pages}%
  \newunit
  \printfield{pagetotal}%
  \newunit\newblock
  \iftoggle{bbx:isbn}
    {\printfield{isbn}}
    {}%
  \newunit\newblock
  \usebibmacro{doi+eprint+url}%
  \newunit\newblock
  \usebibmacro{addendum+pubstate}%
  \setunit{\bibpagerefpunct}\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \iftoggle{bbx:related}
    {\usebibmacro{related:init}%
     \usebibmacro{related}}
    {}
  \usebibmacro{finentry}}

问题是:\DeclareBibliographyDriver{book}如果作者已定义,如何破解才能在作者后获得逗号。谢谢。

在此处输入图片描述

答案1

biblatex有标点符号跟踪器,以确保在不需要时不打印标点符号(例如,如果字段缺失/为空)。您可以在§4.11.7中阅读有关标点符号跟踪器的内容使用标点符号追踪器和第4.7节标点和间距biblatex文档

对于这个特定的问题,标点符号存在于一个专门的宏中,因此

\renewcommand*{\labelnamepunct}{\addcomma\space}

應該足够了。

您可以将此更改限制为@book

\renewcommand*{\labelnamepunct}{%
  \ifentrytype{book}
    {\addcomma‌​\space}
    {\newunitpunc‌​t}}

\setunit{\labelnamepunct}\newblock或者将行\DeclareBibliographyDriver{book}改为

\setunit{\addcomma‌​\space}\newblock

相关内容