04 May 2020

… in which we discuss how to format your bibliography in tex.

One thing which surprised me as an assistant professor was the constant demand for an updated CV. And when you write this CV you may want to include details on students, joint authorship etc. I am imputing reasons, but I am sure this is behand the cry for help from Davis:

The end result of this post will look like

Here we have

  1. Different lists of publications
  2. Highlighting names using both boldface, dagger and asterix.

This post will detail a solution to this problem using Latex and biblatex. Historically, Bibtex was developed to handle bibliographies. In the bibtex-workflow, you have a .bib file which details the biblographic entry, and additional code for specifying the layout of the entry. We now have an alternative called biblatex which is easier to customize. Because you might end up using Google a bit, here is a quick description of the operational difference between Bibtex and biblatex:

Bibtex: here you use a few commands inside your .tex file together with something called a .bst file which details how bibliography details are being typeset. Whenever you need to switch format, you essentially need to find a new .bst file. These files are hard to construct yourself, partly because they have tons of details on arcane settings. This setup has been nice for journals (they can just supply their custom .bst file and no-one needs to think about anything), but has been hard for people like assistant professors who wants to play with things.

When you use Bibtex, your cv.tex file looks like this

\begin{document}
\bibliography{papers}
\bibliographystyle{IEEEtran}
\end{document}

This tells us to use papers.bib with the IEEEtran .bst file. Many people use the natbib package for typesetting citations. Technically, this is about handling the [1] produced by a \cite{} command.

biblatex: for biblatex, there is no longer a need for .bst files. Instead, you can fully custom most (all) of the typesetting. You need to load a package and set (sometimes very long) settings

\usepackage[backend=biber,style=authoryear,sorting=nyt,
	natbib=true,maxbibnames=99,firstinits=true,uniquename=false]{biblatex}
\addbibresource{papers.bib}

\begin{document}
\printbibliography[title=Bibliography]
\end{document}

the \addbibresource tells us to look for a specific .bib file. See how the \printbibliography can be customized by the title option. The options to the biblatex package can be very long; in this example I am citing using a (Hansen 2019) construction. Switch to style=numeric for the numeric style common in CVs.

Historically, I have been using Bibtex. One easy solution to many problems is to include code directly into the bib file, like

  author = {\textbf{Hansen}, \textbf{Kasper D.}}

This works, but everytime you want to do something different you need to modify the .bib file. If you go down this path, and you’re an R user, the excellent ‘bibtex R package allows you to read and manipulate .bib files.

The solution, using biblatex

We will use two new custom fields in the a bib file: “keywords” and “author annotations”. An example is easy

@article{compartments,
  author =	 {Fortin, Jean-Philippe and Hansen, Kasper D},
  title =	 ,
  year =	 {2015},
  journal =	 {Genome Biology},
  volume =	 {16},
  pages =	 {180},
  doi =		 {10.1186/s13059-015-0741-y},
  keywords =	 {peerjournal},
  author+an =	 {1=highlight; 2=highlight}
}

Focus on the keywords and the author+an fields.

How to print parts of a bib file

The keywords field enable you to only print part of the bibliography, specifically the ones with a specified keyword. Example:

\nocite{*}

\defbibnote{mynote}{$^*$ indicates equal contributions\\ $^\dagger$ indicates corresponding author(s)
   (if not the senior author)\\ \textbf{boldface} indicates a member of my lab \\}

\printbibliography[title=Journal Articles (peer reviewed),keyword=peerjournal,prenote=mynote]

\printbibliography[title={Journal Articles, Consortia member (peer reviewed)},keyword=peerconsortia]

The mynote typesets a note (before the bibliography). Then I print two sections, one for standard journal articles and one for consortia articles.

How to highlight authors

I use 3 kinds of highlight: boldface for myself or my students. And then asterix and dagger for joint first or corresponding author. A more complicated author+an is

  author+an =	 {1=first; 2=first; 3=first,corresponding; 4=highlight; 12=highlight;
                  13=corresponding}

Note how each author is a number (that’s a pain, I am not sure that can be circumvented), each author is separated by ; and each type of highlight is separated by ,. This code gives each author a tag. To get the required highlight you need to tell biblatex what to do with the tag.

Without further ado I give you the following preamble

\renewcommand*{\mkbibnamegiven}[1]{
\ifitemannotation{highlight}
{\textbf{#1}}
{#1}}
\renewcommand*{\mkbibnamefamily}[1]{
\ifitemannotation{highlight}
  {\textbf{#1}}
  {#1}%
\ifitemannotation{first}
  {\textsuperscript{*}}
  {}%
\ifitemannotation{corresponding}
  {$^\dagger$}
  {}%
}%%

This is a bit complicated. It’s because I want to highlight both Kasper D (my “given” name) and Hansen (my “family” name) in boldface, but the asterix and dagger only needs to go in the family name.

More fluff

For my CV, this is how I construct the full entry

\usepackage[backend=biber,
           bibstyle=numeric,sorting=ydnt,sortcites=true,natbib=true,defernumbers=true,
           maxbibnames=99,giveninits=true,uniquename=false]{biblatex}

All of it

Some comments

For completeness, I am describing what sections I have in my CV bibliography. Some of these sections are specified by my institution who wants peer reviewed material separated from non-peer reviewed material (the guidelines discuss opinion pieces, books etc). Following the golden principle of “if you take a shit, it goes on your CV” of US academic institutions, I have the following sections

  • Journal Articles (peer reviewed)
  • Journal Articles, Consortia member (peer reviewed)},keyword=peerconsortia]
  • Preprints (not peer reviewed)
  • Books, Theses, Editorials, Abandoned Preprints (not peer reviewed)
  • Preprints, subsequently published (not peer reviewed)

So yes, I include published preprints (in their own section) with the note = {Preprint. Published in Genome Biology 2019}.