如果不包含特定文本,如何排除打印特定的 bibtex 字段?

如果不包含特定文本,如何排除打印特定的 bibtex 字段?

我看了这里但我无法使其适应我的情况。

我希望仅在字段指示原始出版日期的情况下biblatex在 bib 条目末尾打印该字段,但当字段指示该作品是重印本时不打印(或就此而言在任何其他情况下)。请考虑以下 MWE。addendumOriginal work published \dddd\

\RequirePackage{filecontents}

\begin{filecontents*}{mybib.bib}
@book{test1,
    address = {Cambridge, {MA}},
    title = {The structural transformation of the public sphere: {An} inquiry into a category of bourgeois society},
    publisher = {MIT {Press}},
    author = {Habermas, Jürgen},
    translator = {Burger, Thomas and Lawrence, Frederick},
    year = {1989},
    addendum = {Original work published 1962}
}
@incollection{test2,
    address = {Cambridge, {MA}},
    title = {Deliberation and democratic legitimacy},
    booktitle = {Deliberative democracy: {Essays} on reason and politics},
    publisher = {MIT {Press}},
    author = {Cohen, Joshua},
    editor = {Bohman, James and Rehg, William},
    year = {1997},
    addendum = {Reprinted from {Hamlin} 1989 pp.17-34},
    pages = {67--91}
}
\end{filecontents*}

\documentclass{article}


% Set the values for the bibliography
\usepackage[
    style=apa,
    backend=biber,
    isbn=false,
    url=false,
    doi=false,
    eprint=false,
    hyperref=true,
    backref=false,
    firstinits=false,
]{biblatex}

% Recommended for biblatex
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{xpatch}

% Set language
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\addbibresource{mybib.bib}

\begin{document}

\cite{test1}
\cite{test2}

\printbibliography
\end{document}

我得到的是

输出

但我想避免addendum在第一个条目中打印,就像这样

输出

答案1

使用biblatex+biber源映射可以使 bibtex 字段的内容无效

对于问题中的情况,下面的代码可以解决问题(可以相应地调整正则表达式)

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=addendum, match=\regexp{[R|r]eprint.*},
            fieldset=addendum, null]
    }
  }
}

相关内容