7

I have two .bib files, and I would like to get two separate bibliography sections, each of them containing references from one file. More precisely, I have mine.bib and external.bib, and I would like the entries from mine.bib to go in a section "List of publications" and the ones from external.bib to go to "External bibliography".

Using biblatex, I found a lot of ways to get several bibliography sources (\addbibresource) and several bibliography sections (essentially, call \printbibliography several times with different parameters), but I can't find a way to filter according to the bibliography source.

biblatex seems the best candidate, but I'm not tied to it so any answer using another tool would be welcome.

The use-case is to write an activity report where my list of publications has to be separate (because it is evaluated as such), but where I could also \cite other people's paper.

Thanks in advance.

7
  • 2
    You can restrict refsection to one bib. But you can use the perdatasource to add e.g. a keyword to the entries of one bib. See tex.stackexchange.com/a/166018/2388 Mar 17, 2017 at 14:19
  • 1
    Thanks for the link. The solution pointed to seems a bit complicated compared to the problem I have, but it does work :-). Mar 17, 2017 at 15:29
  • Would you say your question is a duplicate then? Or would you like an answer that is more specific to your problem? In that case I would really appreciate a more in-depth explanation of your exact situation and what you are trying to do.
    – moewe
    Mar 17, 2017 at 16:08
  • It's not exactly a duplicate as the other question is about showing the bibliography for only one .bib file, but getting two sections is a rather straightforward extension of it. Mar 17, 2017 at 16:57
  • @moewe ^^ You have mail.
    – cfr
    Mar 18, 2017 at 2:55

1 Answer 1

5

(Answer adapted from Printing only one bib file. Thanks to @moewe for the original answer and @Ulrike Fischer for pointing it to me.)

One solution is:

  • Add a keyword to each entry coming from a given file
  • Filter on this keyword when printing the bibliography

This solution requires biber and won't work with a plain bibtex.

A complete example:

\documentclass{article}
\usepackage{filecontents}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[backend=biber]{biblatex}
\usepackage{hyperref}

\begin{filecontents*}{self.bib}
@book{mine1,
  author      = {Myself},
  title       = {My first paper},
}
@book{mine2,
  author        = {Myself and My Coauthor},
  title         = {My second paper},
}
\end{filecontents*}
\begin{filecontents*}{external.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{self.bib}
\addbibresource{external.bib}

% Add the keyword "self" to everything coming from self.bib.
\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map[overwrite]{
      \perdatasource{self.bib}
      \step[fieldset=keywords, fieldvalue={,self}, append]
    }
  }
}

\begin{document}
  I wrote several papers like \cite{mine1} and \cite{mine2} and other
  people did too \cite{Dijk:Numbering,priest:IntNonClassLogic}.

  % Disable automatic title for \printbibliography, we'll display it
  % ourselves.
  \defbibheading{bibliography}[\refname]{}

  \section{List of publications}
  \printbibliography[keyword={self}]

  \section{External bibliography}
  \printbibliography[notkeyword={self}]
\end{document}

The resulting PDF file:

enter image description here

1
  • You can even filter publications by author dynamically as in tex.stackexchange.com/q/286471/35864 You may also want to check out the defernumbers option (at least for your MWE).
    – moewe
    Mar 18, 2017 at 13:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .