BibLaTeX

Also BibTeX if you must

September 29, 2020 — December 23, 2022

Figure 1: How citation management works in LaTeX.

1 BibTeX

Oh, BibTeX. The classic LaTeX-compatible citation system.

None of that faffing about making web-friendly citations is useful if you are working with academics, who don’t regard words on the internet as a real thing. Your words must be behind a paywall where no-one can read them to count as significant. Moreover, they must have been rendered harder to analyse by running them through LaTeX to obfuscate them into a PDF, which probably also entails using BibTeX to do the citation stuff.

Starting from Zotero, I use Better BibTeX to make this less painful. Sometimes one must procedurally handle annoying BibTeX problems from BibTeX files themselves (i.e. the BibTeX file is not in Zotero due to some co-worker finding databases suspect and emasculating).

I sometimes use bibtool for extra cleaning and heinous hacks, e.g. when someone cannot work out whether to spell it “Jürgen” or “J\"{u}rgen”.

BibTeX is ancient and has accreted deep strata of fossilised rules. No one knows how BibTeX works because style files are written in their own special programming language that it is not worth time to learn. But it does usually work if you move slowly, carefully and don’t touch anything, and only sometimes do you spend a WHOLE DAY trying to fix some weird glitch.

Latest zany problem: BibTeX is nondeterministically incompatible with hyperref. The symptom is the following error:

pdfTeX error (ext4):
\pdfendlink ended up in different nesting level than \pdfstartlink.
\AtBegShi@Output ...ipout \box \AtBeginShipoutBox

The solution linked might work.

\usepackage{etoolbox}

\makeatletter
\patchcmd\@combinedblfloats{\box\@outputbox}{\unvbox\@outputbox}{}{%
    \errmessage{\noexpand\@combinedblfloats could not be patched}%
}%
\makeatother

2 BibLaTeX

a.k.a. biber, because the biblatex system is factored into a couple of distinct packages but you more or less need to get the lot to reap benefits. I assume there is a reason for this. It looks similar to BibTeX in that it interacts with LaTeX- documents, but is better in various ways, mostly to do with being modern, e.g. having less baffling misfeatures than BibTeX. It has full unicode support, BibLaTeX is supported in Beamer slides etc. BibLaTeX can, indeed, handle non-English names and URLs, bringing it up to speed with 1999. BibTeX can do some of that but who knows which bits and which bugs to work around to make it go? As such, BibLaTeX steamrolls some of the kinks out of the winding steeplechase of character set errors that is BibTeX. bibLaTeX is notably not better in the ecological sense, in that it is not as widely used by the various technologically moribund conferences/journals to which I might want to submit my paper, because many such organisations believe, presumably, that these accursed foreigners will eventually despair of their disconcerting languages and their filthy habits of smearing diacritical marks all over their names, or even daring to use non-roman scripts to communicate, if only we wait long enough. I often need to use alternate fan-made BibLaTeX styles made by to ape BibTeX for some journal or other, e.g. here is an IEEE-like one. If the journal is steadfastly committed to 1980s technology, I can convert between them using biblatex2bibitem which generates bibtex style citations. Or I can use Alexander Terenin’s hack to shoehorn biblatex into ArXiv and ICML and other locations without editing the style files.

The configuration options are manifold. Here is one set I like:

\usepackage[
style=authoryear,   % author-year style in references
citestyle=authoryear-comp, % compact author-year in cites
autocite=inline,  % parens for citeation
date=year,  % No i don’t care what month
url=false,       % clickable urls in ref, turn off for printing
uniquelist=false,
uniquename=false, % turn off auto-disambiguate
backref=true,     % auto backrefs in ref.
datezeros=true,   % dates with leading zeros
maxcitenames=1, % et al. with two or more authors
%indexing,       % to create an index of persons
sortcites=false,
sorting=nyt,
%defernumbers=true,   % numbers in any bibliography
backend=biber]      % use biber for compiling
{biblatex}
\addbibresource{refs.bib}

These are confusingly documented in the manual, but obvious from the cheat sheet.

The bibliography is actually rendered

\printbibliography

The citation command has fancy options.

\cite[see][page 12]{latexcompanion}

More generally, there is AFAICS no reason not to use the plural version \cites and in fact since \cite makes assumptions about formatting, one should I suppose prefer use \autocites.

\autocites[152-169]{Smith}[252]{Jones}

\autocite also takes multiple arguments, but seems to sort them and doesn’t take page number or other locator arguments:

\autocite{Smith,Jones}  % will be sorted to \autocite{Jones,Smith}

Compare and contrast with the BibTeX config:

\bibliographystyle{unsrt}
\bibliography{refs}

and plainer cite command:

\cite{latexcompanion}

3 pybtex

Pybtex aims to be 100% compatible with BibTeX. It accepts the same command line options, fully supports BibTeX’s .bst styles and produces byte-identical output (if not, please file a bug report).

Additionally,

  • Pybtex is Unicode-aware.
  • Pybtex supports bibliography formats other than BibTeX.
  • It is possible to write formatting styles in Python. As a bonus, Pythonic styles can produce HTML, Markdown and other markup besides the usual LaTeX.

Pybtex also includes a Python API for managing bibliographies from Python.

4 Incoming