As this might turn out to be an XY problem, I will try to give as much additional information as possible. But to start with, my question is:
- Question (Y): How can I make
biber
(in tool mode) create a.bib
file based on a.bcf
file and using another.bib
file as data source than the one specified in the.bcf
file?
Question and Background (X):
Recently, I started to use JabRef for bibliography management. On the one hand, the fact that it uses .bib
as database format is very handy, but on the other hand there are some drawbacks:
- All meta information is contained in that
.bib
file, including file references, personal comments and database specific configuration. For some reasons (I think they don't matter here) I want to use a "clean".bib
file for my projects, containing only the relevant bibliographical data. As a consequence, I need to create a "reduced" version of the database.bib
file which leads to the next point: - JabRef has no option to add custom BibTeX export filters. Of course, it is possible to export a subset of the bibliography in BibTeX format but this does not solve the issue of having configuration data and personal fields in the new file. I know that the latter issue could by solved with JabRef's "Set/clear/rename fields" feature but this is only a partial solution and very cumbersome when it needs to be done repeatedly.
- I would prefer to have only references that are actually used in a project's
.bib
file. That means I need to create a.bib
file containing only the cited references of a bigger.bib
file.
The Goal
So what I want is:
- Manage my bibliography in JabRef.
- Write a LaTeX document using
biblatex
withbiber
. - Generate a
.bib
file containing only the references cited in the document as a subset of my JabRef database. - (Remove all fields containing superfluous information from that smaller
.bib
file. This is not part of the current question; I only mentioned it above as one of the reasons why I want to do all this.)
What I have so far
Basically, I found three different approaches to my problem:
- Approach 1: Use
bibtool
to reduce the.bib
file. Problem:bibtool
is not designed to be used with BibLaTeX/biber, see Using BibTool with BibLaTeX, again. - Approach 2: Use JabRef's feature "New subdatabase based on AUX file". Again, this is not compatible with
biber
. - Approach 3: Use
biber
in tool mode.
Approach 3 almost did the trick. The following command takes all references cited in paper.tex
and writes them to paper_biber.bib
:
biber --output_format=bibtex --output_resolve paper.bcf
However, recall that I want to have two .bib
files: A reduced file (paper_biber.bib
) automatically created from the .bcf
file and besides a master/database file master.bib
containing all my references.
That means, in paper.tex
I have a line like \addbibresource{paper_biber.bib}
. Accordingly, biber
writes the following into paper.bcf
<bcf:bibdata section="0">
<bcf:datasource type="file" datatype="bibtex">paper_biber.bib</bcf:datasource>
</bcf:bibdata>
and when I run biber --output_format=bibtex --output_resolve paper.bcf
, biber
looks for the data of the references from paper.bcf
in paper_biber.bib
. But this is the wrong file. I need biber
to look for the data of the references from paper.bcf
in master.bib
.
When I manually edit paper.bfc
and replace paper_biber.bib
by master.bib
<bcf:bibdata section="0">
<bcf:datasource type="file" datatype="bibtex">master.bib</bcf:datasource>
</bcf:bibdata>
I get exactly the desired result, namely paper_biber.bib
containing all the entries from master.bib
that are referenced in paper.bcf
.
Unfortunately, manually editing paper.bcf
is not very convenient and difficult to automate. This brings me back to the original question:
How can I make
biber
(in tool mode) create a.bib
file based on a.bcf
file and using another.bib
file as data source than the one specified in the.bcf
file?
I tried to find an appropriate command line option in the biber
manual and in biber --help
but could not find anything useful.
I suppose that I could use a biber.conf
file which, according to the manual, should overrule any settings in the .bcf
file but I have no clue what I have to write in that file. I tried the following with no effect:
<?xml version="1.0" encoding="UTF-8"?>
<config>
<!-- SECTION 0 -->
<bibdata section="0">
<datasource type="file" datatype="bibtex">master.bib</datasource>
</bibdata>
</config>