7

This question was about a side effect encountered in this answer. One way to avoid this side effect is to not use biber but bibtool -biblatex as stated in this answer.

I'm using biber --tool to automatically remove fields like abstract, review, groups, and file from biblatex entries in .bib files. A side effect of this is that all non-standard-fields¹ seem to be removed as well, which I want to prevent. Here's an minimal example:

This is the entry in the .bib file mybib.bib:

@Thesis{Author_18_TheThesis,
 author           = {Mr Author},
 title            = {The Thesis},
 type             = {Doctoral Dissertation},
 institution      = {Department of Documents, University of Stackexchange},
 year             = {2018},
 abstract         = {This is the abstract.},
 file             = {:author/Author_18_TheThesis.pdf:PDF},
 review           = {This is the review.},
 groups           = {publications},
 ispreprintpublic = {true},
}

And this is the clean-bibfiles.conf configartion file for biber --tool:

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <output_fieldcase>lower</output_fieldcase>
    <output_indent>2</output_indent>
    <output_align>true</output_align>
    <sourcemap>
        <maps datatype="bibtex" map_overwrite="1">
            <map map_overwrite="1">
                <map_step map_field_set="abstract" map_null="1"/>
                <map_step map_field_set="review" map_null="1"/>
                <map_step map_field_set="groups" map_null="1"/>
                <map_step map_field_set="file" map_null="1"/>
            </map>
        </maps>
    </sourcemap>
</config>

Running biber --tool --configfile=clean-bibfiles.conf mybib.bib will produce a mybib_bibertool.bib file that contains this biblatex entry:

@thesis{Author_18_TheThesis,
  author      = {Author, Mr},
  institution = {Department of Documents, University of Stackexchange},
  date        = {2018},
  title       = {The Thesis},
  type        = {Doctoral Dissertation},
}

The non-standard-field ispreprintpublic has been stripped from the entry. To be precise, the groups and review fields would also be stripped even if they would not be in the sourcemap, as both are also non-standard fields or are "borrowed" from the article type, respectively. How to prevent the automatic stripping of such fields when using biber --tool?


¹See e.g. "2.1.1 Regular Types" and "4.2.4.1 Generic Fields" in the biblatex documentation.

  • 3
    I don't think this is possible at the moment without adding these fields to the data model. All unknown fields are dropped. If you need a different behaviour, start a feature request: https://github.com/plk/biber/issues – moewe Feb 12 '18 at 21:49
  • 2
    My solution would be to try BibTool, but of course your other question shows you tried it and that is why you ended up with Biber in the first place. I don't use BibTool, but the manual shows a possibility to define new entry types. And BibTool even has a biblatex mode that already knows @thesis. Run BibTool with bibtool -r biblatex <file.bib> – moewe Feb 12 '18 at 22:03
  • 1
    I've opened the request: https://github.com/plk/biber/issues/211 – gusbrs Feb 12 '18 at 22:13
  • 2
    Ha found, a bit of the docs that describe this. Its in the changes section at the beginning and not in the section describing the tool mode: "Fields which are not defined in the data model described in the default biber-tool.conf are ignored and are neither read nor output. If custom fields are required, they should be defined in the data model by using a custom tool mode config file." This confirms my suspicion that it is indeed not possible without a data model definition. – moewe Feb 12 '18 at 22:15
  • Oh, there it was then. I sort of tried adding the field with a datamodel, but then it only accepts the fields that are there stated, and not these plus the default data model. Which would then require that the full data model is specified in biber-tool.conf. – gusbrs Feb 12 '18 at 22:22
  • You might give bib2bib a try, as described in the linked original question. – Daniel Feb 12 '18 at 23:17
  • 2
  • Copy the default XML configuration file (to find it: biber --tool-config. 2) define a new field in the <fields> element: <field fieldtype="field" datatype="literal">ispreprintpublic</field>. 3) add it to the thesis entryfields: <field>ispreprintpublic</field>. 4) use your new configuration file...
  • – Paul Gaborit Feb 13 '18 at 13:56
  • Perhaps it is worth to link this answer here too: https://tex.stackexchange.com/a/415013/105447. For the record, even though the question and another answer to it are linked in the OP. @PaulGaborit, I wish I had gotten your advice earlier! :) Thanks! – gusbrs Feb 13 '18 at 16:30
  • Seems legit. I think one of you could make a full answer out of the comment above and the details in the first answer to the other question - it might help others running into the same question. – geekoverdose Feb 13 '18 at 17:01
  • I guess a self answer would be fair enough here. It is good that the info is concentrated there. But not to leave this one unattended for, with some short outline and the link, might be a good idea as well. – gusbrs Feb 13 '18 at 18:03
  • 3
    @PaulGaborit solution is correct.The benefits of having a datamodel in tool mode outweigh this sort of problem. You should add unknown fields to the datamodel by copying the default tool-mode config file. Also, you can force biber to report on skipping things unknown to the data model by using the --validate-datamodel option. – PLK Feb 13 '18 at 20:47