参考书目中作者/编辑和标题之间的标点符号

参考书目中作者/编辑和标题之间的标点符号

使用钩子,\labelnamepunct我成功地将第一组作者和后续标题后的句号改为冒号。但是,如下例所示,如果这是一本内页书,则第二个作者-标题组合之间会使用句号作为分隔符。

这个标点符号的钩子是什么?

\documentclass[12pt,a4paper]{article}
\usepackage[T1,T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,russian,german]{babel}  % last language in order will be active

\usepackage[backend=biber,
        bibstyle=authortitle,
        citestyle=authoryear-icomp,
        sorting=nyvt,   % n-umber, y-ear, v-olume, t-itle
        block=space,        % spacing between blocks: values: none (default), space, par, nbpar, ragged
        isbn=false,     % whether the fields isbn/issn/isrn
        url=false,      % affects entry types whose url information is optional
        doi=false,      % digital object identifier
        hyperref=false, % links between cites and bibliography
        ]{biblatex}

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

\usepackage{filecontents}
\begin{filecontents}{onebook.bib}
@inbook{woodward82,
author={Woodward, James B.},
title={The Nose},
subtitle={},
bookauthor={Woodward, Andrea},
booktitle={The Symbolic Art of Gogol},
booksubtitle={Essays on His Short Fiction},
publisher={Slavica},
address={Columbus, Ohio},
year={1982},
pages={63--87},
}
\end{filecontents}
\addbibresource{onebook.bib}

\nocite{*}

\begin{document}

\printbibliography

\end{document}

结果如下所示(“... Andrea”和“The Symbolic ...”之间有一个句号,我希望其中有一个冒号):

上述代码的结果

答案1

至少有两种方法可以解决这个问题。

第一个是重新定义用于bybookauthor打印的宏bookauthor

\renewbibmacro*{bybookauthor}{%
  \ifnamesequal{author}{bookauthor}
    {}
    {\printnames{bookauthor}}%
  \printunit{\labelnamepunct}}

这将插入\labelnamepunct标点符号缓冲区,并一直保留到需要时。因此,此解决方案可能会产生不良副作用,例如,如果不author存在,并且in:bibmacro 被重新定义为不打印任何内容。


所以我们最好寻找其他的东西。

正如往常一样,Enrico Gregorio 的xpatch这个包在这里非常有用。

加载\usepackage{xpatch}

然后,我们修补书目驱动程序以便在该字段存在之后@inbooks使用(不幸的是,我们需要这个测试来防止该解决方案出现上面提到的缺点)。\labelnamepunctbookauthor

\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \newunit\newblock}
  {\usebibmacro{bybookauthor}%
   \ifnameundef{bookauthor}
     {\newunit\newblock}
     {\setunit{\labelnamepunct}\newblock}}
  {}
  {\typeout{failed to patch bibdriver inbook to use \labelnamepunct}}

平均能量损失

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{xpatch}
\usepackage{babel} 

\usepackage[backend=biber,
        bibstyle=authortitle,
        citestyle=authoryear-icomp,
        ]{biblatex}

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

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@inbook{woodward82,
author={Woodward, James B.},
title={The Nose},
bookauthor={Woodward, Andrea},
booktitle={The Symbolic Art of Gogol},
booksubtitle={Essays on His Short Fiction},
publisher={Slavica},
address={Columbus, Ohio},
year={1982},
pages={63--87},
}
\end{filecontents}
\addbibresource{\jobname.bib}


\xpatchbibdriver{inbook}
  {\usebibmacro{bybookauthor}%
   \newunit\newblock}
  {\usebibmacro{bybookauthor}%
   \ifnameundef{bookauthor}
     {\newunit\newblock}
     {\setunit{\labelnamepunct}\newblock}}
  {}
  {\typeout{failed to patch bibdriver inbook to use \labelnamepunct}}
\nocite{*}

\begin{document}

\printbibliography

\end{document}

在此处输入图片描述

相关内容