Latex + Bibtex: Bibliographies

Latex offers many capabilities that are difficult or impossible to do using other software. One such is Latex’s ability to work with Bibtex, reference management software, to create a self-consistent bibliography. The seemless integration of Bibtex and Latex make the referencing and citation process extremely easy.

Bibtex database

In order to do referencing seamlessly in Latex, it is necessary to create a database containing the works that you wish to cite in your documentation. The beauty of separating the bibliography out into a separate file as opposed to including references within the document itself is that you can maintain a single database for all of your documentation.

Each entry in your bibtex database is defined using keywords and linked to a bibliography label. For example, consider the following entry:

@ARTICLE{pawlowski_params,
   author = {{Pawlowski}, D.~J. and {Ridley}, A.~J.},
    title = "{Quantifying the effect of thermospheric parameterization in a global model}",
  journal = {Journal of Atmospheric and Solar-Terrestrial Physics},
 keywords = {Thermosphere, Global climate model, Parameterization},
     year = 2009,
    month = dec,
   volume = 71,
    pages = {2017-2026},
      doi = {10.1016/j.jastp.2009.09.007},
   adsurl = {http://adsabs.harvard.edu/abs/2009JASTP..71.2017P},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

This entry is labeled as “pawlowski_params” and all of the relevant information about the article is specified. Keywords such as “author”, “journal”, and “year”, etc. contain the necessary information to properly populate the reference. Simply put, including a reference in a document is as simple as adding all of your references to your database using the above format, saving that database (latex requires the .bib extension on your bibliography database, so you might call your file “mybib.bib” or something), and making sure that your project has access to this file. For those that use overleaf.com, this means uploading that database to your project on overleaf.

Since bibtex is such a widely used piece of software, most reference management programs have the ability to export citations in this format. This means that if you have a reference that you want to cite, you can almost always export the bibtex entry or otherwise copy it directly from whatever software you use to find and read documents (e.g. Mendeley Desktop, EndNote, SciRef, Zotero to name a few) and paste it into your bibtex database. Further, common literature databases, including Google Scholar, also have the ability to export the bibtex entry for documents that you find within. All of this means that adding entries to your database can be handled by software so you don’t have to manually type in the relevant information.

Connecting Bibtex to Latex

Armed with a populated bibtex database, the only thing to do is to tell Latex that you want to include a bibliography, specify a bibliography style, and cite some documents. This is all accomplished with a few commands added to your Latex document.

Natbib

There are many bibliography styling options available and if you are submitting an article to a journal or other publication there is probably a style that the publisher requires. I require my students to use the natbib package by including \usepackage{natbib} in the preamble of the latex document. This provides two easy to use commands for adding citations and formats the citations and references in the manner that I prefer.

The bibliography

To include a bibliography in your latex document, use two commands at the end of your document (but before the \end{document}):

\bibliography{databasename}
\bibliographystyle{stylename}

where “databasename” is the name of your bibtex database (e.g. mybib.bib) and “stylename” is the appropriate style. I suggest plainnat which comes with the natbib package.

Citing a reference

Now that latex knows about your database, you simply need to add citations to your latex document. Natbib provides two citation commands: \citep{} for parenthetical citations and citet{} for textual citations.

Parenthetical citations are those that are not meant to be read as part of the text. For example, the following text:

In a previous study, it was demonstrated that uncertainty in specification
of the thermal conductivity can result in extremely different circulation
patterns in the atmosphere \citep{pawlowski_params}.

will result in the following citation:

... circulation patterns in the atmosphere [Pawlowski and Ridley, 2009].

The citation is fully enclosed in brackets. Alternatively, I could structure the text slightly differently to use a textual citation:

\citet{pawlowski_params} show that uncertainty in specification
of the thermal conductivity can result in extremely different circulation
patterns in the atmosphere.

which will result in the following citation:

Pawlowski and Ridley [2009] show that uncertainty...

Note that in both citation styles, the appropriate bibtex entry label was used as the argument to the citation command.

When either citation command is called, Latex notes the entry that was used, creates the citation inline with the text as appropriate and also adds an entry to the References section. No other work is required to ensure that there is a connection between the citation and the reference and at no point to we have to manually populate the references section itself. Latex handles all of that automatically.

Summary

To summarize, the steps to add the ability to cite and reference other works in your document are:

  1. Create a bibtex database and populate it with the entries that you want to cite.
  2. Add that database to your project (e.g. the folder that contains your latex document).
  3. In your Latex document, add the bibliography and styling using the \bibliography and \bibliographystyle commands. Be sure to add Latex packages as necessary (.e.g \usepackage{natbib}).
  4. Cite the referenced works using the relevant \cite command (.e.g \citet or \citep).