6 min read

A practical guide for using BiBteX and natbib

After submitting a paper to International Conference on Spatial Cognition and using their LaTeX template, I made a decision I’ve been tempted to make for a long time: to never again submit a paper to a journal or conference using Microsoft Word, at least not as the first/sole author. Using LaTeX is generally much more efficient once the work has been put in up front, and the academic writing environment of Emacs + LaTeX + BibTex + org-ref1 works awesome for me. After years of submitting to mainstream-ish geography journals that lack a LaTeX template and force you to submit in Word, I’ve decided it’s high time to value workflow preferences over finding the perfect audience for my work. Coincidentally, I’ve found that my research interests have shifted in tandem with my preference for tools, so it’s all probably for the best in the long run.

Enter the problem

The paper I submitted to Spatial Cognition was a short position paper with relatively simple in-text citations, and the \cite command, producing an parenthesized (Author, Year) sufficed in every case. The manuscript I’m writing now has more complex citations where the author’s name is mentioned directly in the text or the parenthesized citation requires a prenote such as “e.g., Goodchild, 1992” or “(see Miller, 2015 for an example).”

Using natbib is pretty easy if you have some familiarity with LaTeX and have heard of or seen a .bib file (go to almost any journal’s website and there will be an option to export article citations to .bib), but I’ve had to piece information together from various help sources to get entire manuscripts – with citations and a reference list – working properly. So this post will serve as a simple yet hopefully comprehensive source for using LaTeX in:

  • Creating in-text citations in a variety of different circumstances
  • Generating a bibliography from the in-text citations
  • Rendering a .pdf from LaTeX (not as straightforward when using BibTex)
  • Avoiding the bulk of features from the behemoth of the whole 5GB TeX Live distribution.

What you need

Here’s what you will need:

  • A LaTeX editor and engine; web-based programs like Overleaf should be fine
  • A BibTex file (.bib) with references, though this can be created within your document if don’t keep one already.
  • A LaTeX template from a journal; I’m using the one from the International Journal of Geographic Information Science (link to journal, link to template)

The process

  • Download and unzip a LaTeX template from a journal (use this if you just want to follow along).
  • Look for a line that reads \usepackage{natbib} in the .tex file. If it’s present, these instructions will most likely work.
  • Add the following lines to the end of the document, just before \end{document}:
\bibliographystyle{tfv}
\bibliography{/path/to/bibtex/file.bib}

Where “tfv” is replaced by the name of the prefix of file name with the extension .bst and /path/to/bibtex/file.bib is the actual path to your BibTex file, obviously. For example, in my case, there is a file called tfv.bst in the journal’s unzipped template which contains code to generate the bibliography based on your BibTex file, so I simply insert tfv.

Next, you can start referencing sources from your BibTex file in the body of the paper. If using natbib and writing a paper with fairly standard citations, variants on \citep (“p” for parentheses) and \citet (“t” for text) will likely cover what you need. The other examples below include \citeyearpar, which produces the year in parentheses (so if the journal requires the author’s name, you will have insert it manually) and a prenote via square brackets: \citep[prenote here][postnote here]{Author2020}. If one set of square brackets is omitted, LaTeX will assume you want a prenote, not a postnote.

Citation examples

  • Abductive reasoning has a meaningful place in data-driven geography \citep{Miller2015}.

  • \citet{Haffner2020} advocates against using single subheadings but uses them anyway.

  • Wickham's \citeyearpar{Wickham2014} paper contains solid suggestions for data preparation.

  • Location-based social media is a common data source for geographers \citep[e.g.,][]{Zook2014,Fekete2015}

  • Zelinsky \citeyearpar[][, p. 13]{Zelinsky1980} notes, "....why is it that the British, alone among all the nations of the world do not bother to announce their identity on postage stamps?"

Produce:

  • Abductive reasoning has a meaningful place in data-driven geography (Miller and Goodchild 2015).

  • Haffner (2020) advocates against using single subheadings but uses them anyway.

  • Wickham’s (2014) paper contains solid suggestions for data preparation.

  • Location-based social media is a common data source for geographers (e.g., Zook 2014, Fekete 2015).

  • Zelinsky (1980, p. 13) notes, “….why is it that the British, alone among all the nations of the world do not bother to announce their identity on postage stamps?”

Note that my call to Miller2020 is simply a reference to the key of the paper in my BibTex file. E.g.,

@article{Miller2015,
author = {Miller, Harvey J and Goodchild, Michael F},
doi = {10.1007/s10708-014-9602-6},
journal = {GeoJournal},
keywords = {Big data,GIScience,Geographic knowledge discovery,Geographic thought,Spatial statistics,Time geography},
title = {{Data-driven geography}},
volume = {80},
issue = {4},
pages = {449--461},
year = {2015}
}

After rendering the document (more on that in a minute), the reference list will appear as:

  • Fekete, E., 2015. Race and (Online) Sites of Consumption. Geographical Review, 105 (4), 472–491. Available from: http://doi.wiley.com/10.1111/j.1931-0846.2015.12106.x.
  • Haffner, M., 2020. A framework for place-based survey implementation. In: Spatial Cognition XII. Lecture notes in computer science. Springer.
  • Miller, H.J. and Goodchild, M.F., 2015. Data-driven geography. GeoJournal, 80, 449–461.
  • Wickham, H., 2014. Tidy data. Journal of Statistical Software, Articles, 59 (10), 1–23. Available from: https://www.jstatsoft.org/v059/i10.
  • Zelinsky, W., 1980. North america’s vernacular regions. Annals of the Association of American Geographers, 70 (1), 1–16. Available from: http://www.jstor.org/stable/2562821.
  • Zook, M. and Poorthuis, A., 2014. Offline brews and online views: Exploring the geography of beer tweets. Dordrecht, Netherlands: Springer.

Of course, the journal’s template will take care of formatting of both the bibliography and in-text citations. Occasionally I’ll have to go back to my BibTex file and clean something up, but this is infinitely better than manually fixing references at the end of a Word file because once a BibTex entry is solvent, you can cite it infinitely without having to modify it again.

Rendering

You would think that one simple xelatex my-file.tex or pdflatex my-file.tex or lualatex my-file.tex or whatever one-liner you prefer would work to generate the .pdf, but with BibTex it’s not that easy.2 Following this StackOverflow question, I found that this combination works for me:

pdflatex my-file
bibtex my-file
pdflatex my-file
pdflatex my-file
lualatex my-file

where “my-file” is the basename of the file, i.e. file name minus the extension. I put this in a shell script called “render.sh” and call ./render.sh after making it executable or just bash render.sh. I really don’t understand why all this has to happen or why in this order, but it works.

Going forward

Piecing together help from various sources is fine, but of course it’s better to find a comprehensive help resource that doesn’t include vast amounts of unneeded information. In the future, an even more user-friendly word processing framework may emerge (e.g., RMarkdown), but until then, LaTeX is fine. Being in a discipline where very few people use LaTeX, only submitting to journals with a LaTeX template might appear to mean fewer collaborations, but as I’ve changed tools I’ve inevitably found others with similar preferences.

Footnotes


  1. These are not all necessary. I mean, it is the best combination, but you can mix and match as you see fit. ↩︎

  2. Overleaf users might be able to use a one-liner ↩︎