[Tex/LaTex] Printing only one bib file

beamerbiblatex

Hi I am using biblatex with beamer. I want to add 2 bib files using \addbibresource, cite entries from both bib files so that they show up on the page where I am citing them. However, in the final references using \printbibliography, I would like to show entries from only one bib file. How can I do that?

Best Answer

biblatex's sourcemap feature has the \perdatasource restriction, so we can restrict certain mapping action to a particular .bib file.

Let's say we have to files \jobname-one.bib and \jobname-two.bib; we want to be able to cite from all files, but only citations from the first file (\jobname-one.bib) are to appear in the bibliography.

We simply let Biber add the keyword nobib to all the entries in \jobname-two.bib via

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

If the entry already has a keyword, nobib will be appended to the list. This will lead to entries with no keywords having the keywords {,nobib} (that is, one empty keyword), this is not very elegant, but I have yet to see any problems arise from that fact.

Making sure only the first bibliography is printed is as easy as

\printbibliography[notkeyword={nobib}]

The complete code

\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}

enter image description here


One could of course add a keyword inbib for those entries to appear in the bibliography

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

and print only those

\printbibliography[keyword={inbib}]