How can I validate the correctness a biblatex
.bib file?
Where validate means checking for:
- Duplicate keys
- Missing mandatory fields
What tools do you use?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityTo validate my .bib
files, I put together a Python script called Biblatex Checker.
It checks for missing fields, provides suggestions for common mistakes when using biblatex
and identifies duplicate IDs.
It's based on BibTeX Check by Fabian Beck, which can be used for BibTeX files.
biber --tool -V bib.bib
. It doesn't complain about missing fields but I didn't try yet to find out how to change it (or in case in can't do it yet to make a feature request).
Apr 26, 2014 at 18:52
-V
in tool mode didn't do anything in 1.8. It does in 1.9 dev version. For example it will report on mandatory fields missing from the default data model (in the tool mode config file). You can add any datamodel constraint you want to the data model (either by biblatex macros or via the biber config file for tool mode). The blx-dm.def
file that comes with biblatex contains the default data model and its mandatory field constraints.
biber --tool -V my.bib
should be a separate answer and, IMHO, the recommended way. I definitely would vote for it.
I use jabref. Install jabref, set it to biblatex
mode. To do this go to Options
→ Preferences
. In the window that opens, selectAdvanced
and check BibLaTeX mode
as shown below.
Then open your .bib
file using jabref. Select the entries to be cleaned up. Under Tools
menu, select cleanup entries
. This window opens:
Now you know what to do :)
For duplicate keys, simply go to Tools
→ Autogenerate BibTeX keys
. It will rewrite the duplicate key with some other name.
abbrv
style.
\c@abbrvpenalty=\count217
. I'll try to find the "error".
Oct 9, 2015 at 8:22
If you are only given the .bib
file, try
biber --tool --validate-datamodel <filename>.bib
If your TeX document uses custom data types, try
biber --validate-datamodel <filename>.bcf
This should check all data sources.
biber --validate-datamodel <texfilebasename>
where <texfilebasename>
is the basename of the .tex
document you are writing at the moment.
.bib
file. Users of custom data models probably already know that biber
can replace 3rd party tools.
biber --tool
did not catch the four obvious errors in @article{sugfridsson, editor = {Sigfridsson, Emma and Ryde, Ulf}, title = {Title}, blournal = {Journal}, }
that --validate-datamodel
reported. So at least for the mandatory field validation --tool
mode alone is not enough. I guess what I'm saying is that your answer would be better if you suggested biber --validate-datamodel --tool <filename>.bib
\documentclass{article}
\begin{document}
\nocite{*}
\bibliographystyle{plain}
\bibliography{mybib}
\end{document}
Run latex
and bibtex
and then look into the logfile of the bibtex
run (<filename>.blg
). It has all warnings.
https://biblatex-linter.herokuapp.com/ provides an online Bibtex linter.
It's an Heroku app (Python/Django). It's open source and MIT licensed. https://github.com/Pezmc/BibLaTeX-Linter.
It's based on https://github.com/Pezmc/BibLaTeX-Check
BibTex Tidy is an open source online tool, I've used it, and personally I found it to be very reliable. It supports formatting and clean up, but also checks duplicate entries, including not just the key but also titles.
The tool's self-description is:
This tool tidies bibtex files by fixing inconsistent whitespace, removing duplicates, removing unwanted fields, and sorting entries.
bibtool
(github) v2.68 has improved its double check (aka check for duplicates):
check.double
has been
generalized. The requirement of double entries to be adjacent
has been dropped. This has the impact that the processing is
slightly slower.and added a new check unique.field
:
unique.field
introduced. With this
resource it is possible to specify additional unique constraints
for fields. If different records have the same value for one of
those fields, then a warning is issued.Ensure you have v2.68 or newer (Homebrew for macOS already provides this version when this answer was written, ie. $ brew upgrade bib-tool
gives you the new version)
❯ bibtool -V
BibTool Vers. 2.68 (C) 1996-2019 Gerd Neugebauer
Following command reports records which share the same $key
❯ bibtool -- 'unique.field {$key}' -o '' unique_field_test.bib
For example, you could also check for duplicate dois.
❯ bibtool -- 'unique.field {doi}' -o '' unique_field_test.bib
I am not sure if this is already possible with bibtool
.