我正在为一本期刊准备书目,要求是书名(出版商)针对书籍、收藏等。我有以下代码(MWE):
\documentclass{article}
\usepackage[natbib,maxbibnames=99,uniquename=false,uniquelist=false,useprefix=true,style=ext-authoryear,innamebeforetitle=true]{biblatex}
\usepackage{xpatch}
%% FORMATTING OF THE REFERENCES SECTION
% This starts from "authoryear" style, makes changes
% Comma instead of period to separate fields
\renewcommand*{\newunitpunct}{\addcomma\space}
% Remove "pp."
\DeclareFieldFormat{pages}{#1}
% Remove quotes around title
\DeclareFieldFormat[article,unpublished,inbook,incollection]{title}{#1}
% Remove parentheses around year
\DeclareFieldFormat{biblabeldate}{#1}
\DeclareDelimFormat[bib]{nameyeardelim}{\addcomma\space}
% Remove "In: " for articles; "in" without colon for inbook/incollection
\renewbibmacro*{in:}{%
\ifentrytype{article}
{}
{\setunit{\space}%
\printtext{%
\addcomma\addspace\bibstring{in}\addspace}}}
% Only output volume, no number
\renewbibmacro*{volume+number+eid}{%
\ifentrytype{article}
{\printfield{volume}%
\setunit{\addcomma\space}%
\printfield{eid}}
{}}
% Put parentheses around publisher
\renewbibmacro*{publisher+location+date}{%
\printtext[parens]{% ADDED
\printlist{location}%
\iflistundef{publisher}
{\setunit*{\addcomma\space}}
{\setunit*{\addcolon\space}}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}%
}
\newunit}
% Colon after editors
\DeclareFieldFormat{editortype}{#1:}
% Remove comma after booktitle
\begin{filecontents}{\jobname.bib}
@incollection{AuthorA,
title = {A paper that didn't get published in a real journal},
publisher = {Publisher},
year = {2001},
author = {First Last},
booktitle = {Book Title},
editor = {Albert Editor and Bob Editor}
}
@Article{AuthorB,
author = {Author One and Author Two and Author Three},
title = {A paper that did},
journal = {Journal Name},
year = {2002},
volume = {99},
number = {9},
pages = {31--60},
}
@Unpublished{AuthorC,
Title = {A paper that didn't get published at all},
Author = {Author Three and Author One and Author Four and Author Five},
Note = {Working paper},
Year = {2003}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
This is the story of \citet{AuthorA}, whose bibliography item had an extra comma after \emph{Book Title}, but also of \citet{AuthorB}, and of course of \citet{AuthorC}.
\printbibliography
\end{document}
我想删除第一个书目项目中“书名”和“(出版商)”之间的逗号。我尝试了所有方法:
- 我尝试重新定义 booktitle 宏(没有任何反应)
- 我尝试了这里指出的 xpatch 技术Biblatex Incollection:书名后的逗号(我的乳胶错误在代码本身中提供了“失败”消息)
请帮忙!
答案1
如果添加括号,则可以通过直接插入括号来\printtext[parens]{<stuff>}
轻松强制将前面的标点符号变为空格。这是因为标点符号缓冲区仅在遇到后才会使用和清除。\setunit{\addspace}%
\printtext
\printtext
我还简化了代码中的其他一些内容
我们可以放弃 bibmacro 的重新定义,
in:
转而采用biblatex-ext
的articlein=false,
选项以及 的重新定义\intitlepunct
。为了摆脱
number
期刊文章,我们不需要重新定义 bibmacrovolume+number+eid
(这会阻止一些biblatex-ext
标点符号命令工作),我们可以使用源映射摆脱数字。innametitledelim
编辑器名称后面的冒号比字段格式中的冒号更合适editortype
。总而言之,不再需要
xpatch
这些修改。
所以我们最终得到
\documentclass{article}
\usepackage[
style=ext-authoryear,
maxbibnames=99, uniquename=false, uniquelist=false, useprefix=true,
articlein=false,
innamebeforetitle=true,
natbib,
]{biblatex}
\renewcommand*{\newunitpunct}{\addcomma\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat[article,unpublished,inbook,incollection]{title}{#1}
\DeclareFieldFormat{biblabeldate}{#1}
\DeclareDelimFormat[bib]{nameyeardelim}{\addcomma\space}
\renewcommand*{\intitlepunct}{\addspace}
\DeclareDelimFormat[bib]{innametitledelim}{\addcolon\space}
\DeclareSourcemap{
\maps[datatype = bibtex]{
\map{
\pertype{article}
\step[fieldset=number, null]
}
}
}
\renewbibmacro*{publisher+location+date}{%
\setunit{\addspace}%
\printtext[parens]{% ADDED
\printlist{location}%
\iflistundef{publisher}
{\setunit*{\addcomma\space}}
{\setunit*{\addcolon\space}}%
\printlist{publisher}%
\setunit*{\addcomma\space}%
\usebibmacro{date}}%
\newunit}
\begin{filecontents}{\jobname.bib}
@incollection{AuthorA,
title = {A paper that didn't get published in a real journal},
publisher = {Publisher},
year = {2001},
author = {First Last},
booktitle = {Book Title},
editor = {Albert Editor and Bob Editor},
}
@Article{AuthorB,
author = {Author One and Author Two and Author Three},
title = {A paper that did},
journal = {Journal Name},
year = {2002},
volume = {99},
number = {9},
pages = {31--60},
}
@Unpublished{AuthorC,
Title = {A paper that didn't get published at all},
Author = {Author Three and Author One and Author Four and Author Five},
Note = {Working paper},
Year = {2003}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
This is the story of \citet{AuthorA},
whose bibliography item had an extra comma after \emph{Book Title},
but also of \citet{AuthorB}, and of course of \citet{AuthorC}.
\printbibliography
\end{document}
答案2
您可能会看到以下解决方案:
- 一个不雅的黑客,或者
- 对许多标点符号问题提出了精彩而通用的解决方案,同时对 BibLaTeX 的工作方式提出了深刻的批评。
控制块和单元之间标点符号的一般方法是更改\newunitpunct
。在我的日记中,金融杂志,除了一个字段外,其他所有字段都是用逗号分隔的,所以最初我认为设置
\renewcommand*{\newunitpunct}{\addcomma\space}
然后删除逗号。
然而,移除逗号对于我这样的学术写作者来说几乎是不可能的(尤其是有问题的逗号,它似乎位于两个“块”之间)。相反,中和宏要简单得多,\newunitpunct
如下所示:
\renewcommand*{\newunitpunct}{\addspace}
然后逐项添加逗号、括号和其他可能需要的标点符号。例如,在我的例子中,
% Remove quotes around title and add comma after
\DeclareFieldFormat[article,unpublished,inbook,incollection]{title}{#1,}
% Remove parentheses around year and add comma before and after
\DeclareFieldFormat{biblabeldate}{#1,}
\DeclareDelimFormat[bib]{nameyeardelim}{\addcomma\space}
结果如下: