在准备会议摘要时,通常会遇到页数限制问题。我想删除某些字段,但这应该依赖于其他字段。我已经知道如何删除系列字段。这是在下面的 MWE 中完成的。但当出版商是剑桥大学出版社或牛津大学出版社时,我想删除地址字段。能够根据 bibtex 类型删除某些字段也会很有帮助。例如,文章的编号。
\documentclass{scrartcl}
\begin{filecontents}{ref.bib}
@book{Ramchand2008,
address={Cambridge},
series={Cambridge Studies in Linguistics},
number= 116,
title={Verb Meaning and the Lexicon: {A} {F}irst {P}hase {S}yntax},
publisher={Cambridge University Press},
author={Ramchand, Gillian Catriona},
chapter = {10},
year={2008},
collection={Cambridge Studies in Linguistics 116},
DOI={10.1017/CBO9780511486319}
}
\end{filecontents}
\usepackage[
natbib=true,
style=langsci-unified,
url = false,
doi = false,
backend = biber
]{biblatex}
\addbibresource{ref.bib}
\DeclareFieldInputHandler{chapter}{%
\def\NewValue{}}
\DeclareFieldInputHandler{series}{%
\def\NewValue{}}
\begin{document}
\nocite{*}
\printbibliography
\end{document}
答案1
字段删除发生在从文件(由 Biber 生成)\DeclareFieldInputHandler
读取数据的早期阶段。读取字段的顺序无法保证,因此您无法在此时做出明智的决定,无论某个字段是否存在。这意味着不适合有条件地抑制字段。biblatex
.bbl
\DeclareFieldInputHandler
因此我可能会在这里使用 Biber 源映射。源映射的优点是它们可以访问所有条目数据(如文件中所示.bib
),甚至可以使用正则表达式,这对于“... University Press”来说非常方便。
\documentclass{scrartcl}
\usepackage[
backend=biber,
style=langsci-unified,
url=false,
doi=false,
]{biblatex}
\DeclareSourcemap{
\maps[datatype=bibtex]{
\map{
\step[fieldsource=publisher,
match=\regexp{\A(Cambridge|Oxford)\s+University\s+Press\Z},
final]
\step[fieldset=location, null]
\step[fieldset=address, null]
}
\map{
\step[fieldset=chapter, null]
\step[fieldset=series, null]
}
\map{
\pertype{article}
\step[fieldset=number, null]
}
}
}
\begin{filecontents}{\jobname.bib}
@book{Ramchand2008,
address = {Cambridge},
series = {Cambridge Studies in Linguistics},
number = 116,
title = {Verb Meaning and the Lexicon: A First Phase Syntax},
publisher = {Cambridge University Press},
author = {Ramchand, Gillian Catriona},
chapter = {10},
year = {2008},
collection = {Cambridge Studies in Linguistics 116},
DOI = {10.1017/CBO9780511486319}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\begin{document}
\nocite{*}
\printbibliography
\end{document}