任意字段上的 biblatex 过滤器

任意字段上的 biblatex 过滤器

我们维护一个 bibtex 文件,其中包含我们小组的所有出版物。我们使用注释字段将出版物分成几组,例如期刊论文或者其他论文. 这使得条目看起来如下:

@article{something_2011,
    Author = {Author, Some and Other, An},
    Title = {Here be dragons},
    Journal = {Whatever journal},
    Pages = {123-234},
    Volume = {1},
    Year = {2000},
    Annote = {Other Peer Reviewed Paper}
}

然后我们得到一个如下所示的 tex 文件:

\documentclass{article}
\usepackage{fontspec}
\usepackage{biblatex}

\addbibresource{author1_Books.bib}
\addbibresource{author1_OtherPeerReviewedPapers.bib}
\addbibresource{author1_OtherPapers.bib}
\addbibresource{author1_JournalPapers.bib}

\begin{document}
  \nocite{*}
  \printbibliography[title={Books}]
  \printbibliography[title={Other Peer Reviewed Papers}]
  \printbibliography[title={Other Papers}]
  \printbibliography[title={Journal Papers}]
\end{document}

上述 tex 文件将所有出版物打印到所有四个书目中。因此,我们想使用注释字段的内容对条目进行分组。但 biblatex 仅根据段、类型、子类型、类别、关键字或这些的组合进行过滤,而不根据任意字段进行过滤。biblatex 是否可以根据注释字段进行过滤?

答案1

请注意,annote是的别名annotation,因此答案使用annotation

你可以bibcheck用几乎任意的逻辑创建 s。参见 §3.7.9书目过滤和检查biblatex手动的bibcheck将包含丢弃特定条目的特殊指令\skipentry,将显示所有未到达的条目\skipentry。(因此,您无需明确说明biblatex您想要哪些条目,只需标记那些您不想要的条目即可。)

\iffieldequalstr可以检查字段内容。把它们放在一起,你可以使用

\defbibcheck{annotebar}{\iffieldequalstr{annotation}{bar}{}{\skipentry}}
\defbibcheck{annotefoo}{\iffieldequalstr{annotation}{foo}{}{\skipentry}}

仅获取分别annotation等于bar和的那些条目foo

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage[bibencoding=auto,backend=biber,babel=other]{biblatex}

\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@book{Bara2006,
  address = {New York},
  author = {Bara, Judith},
  publisher = {Routledge},
  title = {English Citation entry},
  year = {2006},
  annote = {foo},
}
@book{Bara2007,
  address = {New York},
  author = {Bara, Judith},
  publisher = {Routledge},
  title = {Another English Citation entry},
  year = {2007},
  annote = {bar},
}
\end{filecontents*}

\addbibresource{\jobname.bib}

\defbibcheck{annotebar}{\iffieldequalstr{annotation}{bar}{}{\skipentry}}
\defbibcheck{annotefoo}{\iffieldequalstr{annotation}{foo}{}{\skipentry}}

\begin{document}
\parencite{Bara2006,Bara2007}
\printbibliography[check=annotebar]
\printbibliography[check=annotefoo]
\end{document}

答案2

以下是使用过滤器和类别的解决方案biblatex

在此处输入图片描述

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@article{aaa,
    Author = {Aaa, John and Other, An},
    Title = {Here be dragons},
    Journal = {Whatever journal},
    Pages = {123-234},
    Volume = {1},
    Year = {2000},
    Annote = {Journal Papers}
}
@article{bbb,
    Author = {Bbb, Alexandra},
    Title = {Dunjeon \& Dragons},
    Journal = {A journal},
    Pages = {12-24},
    Volume = {1},
    Year = {2001},
    Annote = {Other Papers}
}
@article{ccc,
    Author = {Ccc, Jules},
    Title = {A small title},
    Journal = {A book},
    Pages = {1023-1026},
    Volume = {2},
    Year = {2016},
    Annote = {Books}
}
\end{filecontents*}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\DeclareBibliographyCategory{Books}
\DeclareBibliographyCategory{JournalPapers}
\DeclareBibliographyCategory{OtherPapers}
\DeclareIndexFieldFormat{Books}{%
  \ifstrequal{Books}{#1}
  {\addtocategory{Books}{\thefield{entrykey}}}
  {
    \ifstrequal{Journal Papers}{#1}
    {\addtocategory{JournalPapers}{\thefield{entrykey}}}
    {
      \ifstrequal{Other Papers}{#1}
      {\addtocategory{OtherPapers}{\thefield{entrykey}}}
      {}
    }
  }
}
\AtDataInput{\indexfield[Books]{annotation}}

\begin{document}
\nocite{*}
\printbibliography[category=Books,title={Books}]
\printbibliography[category=JournalPapers,title={Journal Papers}]
\printbibliography[category=OtherPapers,title={Other Papers}]
\end{document}

相关内容