我正在尝试实现以下风格:
作者,简(2021 年)。“标题”。Susan 编辑(编辑),卷名(系列名称 #),第 22-50 页。大学出版社。
我是所以关闭,但卷标题和系列名称之间出现了一个句点,我不知道如何抑制它。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{filecontents}
\begin{filecontents}{example.bib}
@inCollection{collection,
author = {Author, Jane},
title = {Title},
pages = {22--50},
year = {2021},
booktitle = {Volume title},
editor = {Editor, Susan},
series = {Series Name},
number = {\#},
publisher = {University Press},
}
\end{filecontents}
\usepackage[
backend=biber,
style=authoryear-comp,
]{biblatex}
\usepackage{xpatch}
%% In Editor (ed.), Title
% change : to space for "in:"
\renewcommand*{\intitlepunct}{\space}
% Put editor string in parentheses
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
% Order Editor (ed.)
\renewbibmacro*{byeditor+others}{%
\ifnameundef{editor}
{}
{%
\printnames[byeditor]{editor}
\setunit{\addspace}\usebibmacro{editor+othersstrg}
\clearname{editor}%
\newunit
}%
\setunit{\addcomma\space}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}}
% Place editor before booktitle
\renewbibmacro{in:}{
\printtext{\bibstring{in}\intitlepunct}%
\usebibmacro{byeditor+others}%
\setunit{\addcomma\space}%
\clearname{editor}
}
% Place page numbers after series name
\xpatchbibdriver{incollection}
{\newunit\newblock
\usebibmacro{chapter+pages}}
{}
{}{\typeout{failed to patch bibmacro incollection to remove page macro}}
\xpatchbibdriver{incollection}
{\usebibmacro{series+number}}
{\usebibmacro{series+number}
\newunit\newblock
\usebibmacro{chapter+pages}}
{}{\typeout{failed to patch bibmacro incollection to re-add page macro}}
% Place series name in parentheses
\renewbibmacro*{series+number}{%
\iffieldundef{series}
{}
{\printtext[parens]{%
\printfield{series}%
\setunit*{\space}%
\printfield{number}}
}}
\addbibresource{example.bib}
\begin{document}
\cite{collection}
\printbibliography
\end{document}
答案1
您可以使用 重置标点符号\setunit
。我删除了 inputenc 和 filecontents 包,当前的 latex 中不再需要它们。
\documentclass{article}
\begin{filecontents}[overwrite]{example.bib}
@inCollection{collection,
author = {Author, Jane},
title = {Title},
pages = {22--50},
year = {2021},
booktitle = {Volume title},
editor = {Editor, Susan},
series = {Series Name},
number = {\#},
publisher = {University Press},
}
\end{filecontents}
\usepackage[
backend=biber,
style=authoryear-comp,
]{biblatex}
\usepackage{xpatch}
%% In Editor (ed.), Title
% change : to space for "in:"
\renewcommand*{\intitlepunct}{\space}
% Put editor string in parentheses
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
% Order Editor (ed.)
\renewbibmacro*{byeditor+others}{%
\ifnameundef{editor}
{}
{%
\printnames[byeditor]{editor}
\setunit{\addspace}\usebibmacro{editor+othersstrg}
\clearname{editor}%
\newunit
}%
\setunit{\addcomma\space}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}}
% Place editor before booktitle
\renewbibmacro{in:}{
\printtext{\bibstring{in}\intitlepunct}%
\usebibmacro{byeditor+others}%
\setunit{\addcomma\space}%
\clearname{editor}
}
% Place page numbers after series name
\xpatchbibdriver{incollection}
{\newunit\newblock
\usebibmacro{chapter+pages}}
{}
{}{\typeout{failed to patch bibmacro incollection to remove page macro}}
\xpatchbibdriver{incollection}
{\usebibmacro{series+number}}
{\setunit{\addspace}\usebibmacro{series+number}%<-----------
\newunit\newblock
\usebibmacro{chapter+pages}}
{}{\typeout{failed to patch bibmacro incollection to re-add page macro}}
% Place series name in parentheses
\renewbibmacro*{series+number}{%
\iffieldundef{series}
{}
{\printtext[parens]{%
\printfield{series}%
\setunit*{\space}%
\printfield{number}}
}}
\addbibresource{example.bib}
\begin{document}
\cite{collection}
\printbibliography
\end{document}