![参考书目中作者/编辑和标题之间的标点符号](https://linux22.com/image/288379/%E5%8F%82%E8%80%83%E4%B9%A6%E7%9B%AE%E4%B8%AD%E4%BD%9C%E8%80%85%2F%E7%BC%96%E8%BE%91%E5%92%8C%E6%A0%87%E9%A2%98%E4%B9%8B%E9%97%B4%E7%9A%84%E6%A0%87%E7%82%B9%E7%AC%A6%E5%8F%B7.png)
使用钩子,\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
使用(不幸的是,我们需要这个测试来防止该解决方案出现上面提到的缺点)。\labelnamepunct
bookauthor
\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}