仅打印一个 bib 文件

仅打印一个 bib 文件

你好,我正在使用 biblatex 和 beamer。我想使用 添加 2 个 bib 文件\addbibresource,引用这两个 bib 文件中的条目,以便它们显示在我引用它们的页面上。但是,在使用 的最终参考文献中\printbibliography,我想仅显示一个 bib 文件中的条目。我该怎么做?

答案1

biblatex的sourcemap功能有\perdatasource限制,所以我们可以限制某些映射动作到特定的.bib文件。

假设我们有两个文件\jobname-one.bib\jobname-two.bib;我们希望能够引用所有文件,但只有来自第一个文件(\jobname-one.bib)的引用才会出现在参考书目中。

我们只需让 Biber 将关键字添加到vianobib中的所有条目中\jobname-two.bib

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \perdatasource{\jobname-two.bib}
      \step[fieldset=keywords, fieldvalue={,nobib}, append]
    }
  }
}

如果条目已经有一个关键字,nobib将被附加到列表中。这将导致没有keywords 的条目具有关键字{,nobib}(即一个空的keyword),这不太优雅,但我还没有看到由此引起的任何问题。

确保只打印第一个参考书目很简单

\printbibliography[notkeyword={nobib}]

完整代码

\documentclass[british]{scrartcl}
\usepackage{filecontents}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}
\usepackage{filecontents}
\usepackage[style=verbose, backend=biber]{biblatex}
\usepackage{hyperref}

\begin{filecontents*}{\jobname-one.bib}
@book{Lin:MaMaDif,
  author      = {Carl E. Linderholm},
  title       = {Mathematics Made Difficult},
  year        = {1971},
  publisher   = {Wolfe},
  location    = {London},
  isbn        = {0-7234-0415-1},
  gender      = {sm},
  keywords    = {satire},
}
@book{Carroll:Snark,
  author        = {Lewis Carroll},
  title         = {The Hunting of the Snark},
  subtitle      = {An Agony in Eight Fits},
  date          = {1876},
  publisher     = {Macmillan},
  location      = {London},
  gender        = {sm},
  url           = {https://archive.org/details/huntingofsnarkan00carruoft},
  urldate       = {2013-08-22},
  keywords      = {satire,fun},
}
\end{filecontents*}
\begin{filecontents*}{\jobname-two.bib}
@online{Dijk:Numbering,
  author        = {Edsger W. Dijkstra},
  title         = {Why numbering should start at zero},
  editor        = {Kevin Hely},
  date          = {1982-08-11},
  url           = {https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html},
  urldate       = {2013-08-19},
  gender        = {sm},
  keywords      = {numbering},
}
@book{priest:IntNonClassLogic,
  title         = {An Introduction to Non-Classical Logic},
  subtitle      = {From If to Is},
  author        = {Graham Priest},
  edition       = {2},
  year          = {2012},
  isbn          = {978-0-521-67026-5},
  publisher     = {Cambridge University Press},
  location      = {Cambridge},
}
\end{filecontents*}

\addbibresource{\jobname-one.bib}
\addbibresource{\jobname-two.bib}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \perdatasource{\jobname-two.bib}
      \step[fieldset=keywords, fieldvalue={,nobib}, append]
    }
  }
}

\begin{document}
  \cite{Lin:MaMaDif}

  \cite{Carroll:Snark}

  \cite{Dijk:Numbering}

  \cite{priest:IntNonClassLogic}

  \printbibliography[notkeyword={nobib}]
\end{document}

在此处输入图片描述


当然,你可以为这些条目添加关键字,inbib使其出现在参考书目中

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \perdatasource{\jobname-one.bib}
      \step[fieldset=keywords, fieldvalue={,inbib}, append]
    }
  }
}

并仅打印那些

\printbibliography[keyword={inbib}]

相关内容