I have some .bib
files, some of them have 1000 lines.
To be sure that they are working well I always use this test MWE (package filecontents
and sample .bib
file added only for a running MWE; delete it and use your own .bib
file please):
\RequirePackage{filecontents} % loading package filecontents
% writing file \jobname.bib, for example mb-bibtex.bib.
\begin{filecontents*}{\jobname.bib}
@Book{adams,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994},
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}
}
@Article{Mathetitle,
author = {Mezzacapo, F. and Cirac, J. I.},
title = {Ground-state properties of the spin-$\frac{1}{2}$ antiferromagnetic Heisenberg
model on the triangular lattice: a variational study based on
entangled-plaquette states.},
year = {2010},
journal = {New. J. Phys.},
number = {12},
issn = {103039},
}
\end{filecontents*}
\documentclass{article}
\usepackage[numbers]{natbib} % bibliography style
\usepackage[colorlinks]{hyperref} % better urls in bibliography
\begin{document}
Test the complete \texttt{.bib} file: \nocite{*}.
\bibliographystyle{plainnat} % needs package natbib
\bibliography{\jobname} % uses \jobname.bib, according to \jobname.tex
\end{document}
The sample file includes two errors: key adams
you will find twice (that gives an error) and in the Mathetitle
there is an field missing (that gives a warning).
The MWE is build to test a .bib
file with BibTeX. You have to choose your used bib style (my example uses package natbib
with numbers
). So this MWE shows you the resulting errors and warnings for the given .bib
with BibTeX and perhaps resulting tex
errors.
That is my way to be sure there is no bib
error or tex
error in the .bib
file.
I solved my issues of compatibility between the BibTex file exported from Zotero and BibLatex. I recap the solution here.
Apparently BibLatex is much more sensible than BibTex when it comes to reading a BibTex file...
To export correctly the bibliography from Zotero and then into a Tex document via BibLatex I used this BibTeX Export Translator (modified by Robin Wilson) with two important tweaks:
1) On line 11 of the translator script you need to set "exportNotes": true,
to "exportNotes": false,
(of course just in case you have added notes to your Zotero items, e.g. you extract annotations from PDFs). This will avoid BibLatex crashing on too long fields.
2) On line 2256 you need to tell the translator to avoid adding a comma after each bibliography item (the comma will result in BibLatex giving a warning on the first line of each entry excluding the first...) changing this line: Zotero.write((first ? "" : ",\n\n") + "@"+type+"{"+citekey);
with this line: Zotero.write((first ? "" : "\n\n") + "@"+type+"{"+citekey);
Another possible source of problems of the BibTeX Export Translator could be the character encoding. In my translator I kept as in source file "exportCharset": "ISO-8859-1",
on line 10. I tried to change it to UTF-8 but it created another class of issues, not with BibLatex (it run without errors) but with Latex,
[1{/usr/local/texlive/2013/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./bib/price2012.tex [2]
! Undefined control sequence.
<to be read again> \edef \blx@tempa {193\x
{FFFD}\x {FFFD}\x {FFFD}219}
l.8 \printbibliography[heading=subbibliography]
for each refsection. It also messed with the "pages" field of some items, outputting:
Andrea B. Hollingshead. “Information suppression and status persistence in group decision making the effects of communication media”. In: Human Communication Research 23.2 (1996), 193fffdfffdfffd219.
I then switched back to "exportCharset": "ISO-8859-1",
and both BibLatex and Latex run without warnings or errors. The PDF output was correct:
Andrea B. Hollingshead. “Information suppression and status persistence in group decision making the effects of communication media”. In: Human Communication Research 23.2 (1996), 193–219.
and I also get correct output with the umlaut of Habermas:
EDIT: The problem with the page field was probably due by a odd "-" character that you sometimes get to separate the 2 page numbers when you download the citation from the Internet.
Best Answer
To 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.