LaTex Citations and Bibliography with Author-Name Pattern

For many days I messed around with LaTeX Bibliographies and Citations and finally got it working. What I wanted to implement were citations with the following pattern:

Java is a turing-complete programming language (Author, Year, p. 42).

Furthermore, I needed the fields URL, DOI and the last date of visit for online sources to be listed in my bibliography, as well as Journal details for articles. After a lot of hours I got it working, and I hope I can save you guys some time with this blog post.

In my first attempts, I used the natbib package in combination with various bibliography styles. One which didn’t produce errors and was quite close to what I wanted was the achicago style. However, the details in the bibliography were missing. There is also a tool with which you can create your own bibliography styles, but that took a lot of time to configure (by answering a lot of questions and typing in choices) and resulted in weired citations, where the year and some random digits preceded the author… Next, I tried the amsrefs package, but also with no success.

Finally, I found the right package: biblatex ๐Ÿ™‚ It has a lot of options to configure your bibliography and citation behaviour. I will describe the options I used. More details can be found in the reference.

  • citestye=apa: Defines the style of citations (in the document). Apa is an author-year based style with a comma between author and year. Unfortunately, when more than n authors are given, the apa style does not support the et al. abbreviation. At least the package options minnames and maxnames to configure this did not work for me. If you want et al. abbreviations, you must specify authoryear here (but this will also remove the ocmma between author and year).
  • bibstyle=authoryear: Basic author-year based configuration for the bibliography listing at the end of your document.
  • url: indicates that URLs are listed in the bibliography
  • doi: causes biblatex to print DOIs of articles
  • dashed=false: When two references of the same author(s) are listed, in the second one the author(s) is replaced with a dash by default. This flag deactivates that.

For biblatex your .bib file has to be referenced with another command than with natbib or amsrefs. It is named \addbibresource and has to be in the preamble. Note that the .bib extension has to be included. The whole header code looks like this:


Now, the right citation command has to be used in your document. For the kind of citations I like it is not \cite, but \parencite (cite with parenthesis). To add specific pages in the citation, it has to be prepended to the curly braces:


Note that I used a non-breakable space (~) which will be kept together with the page number. Otherwise, ugly line breaks can occur in your document.

To print your bibliography, simply use the command


Ok, that’s how it works if no problems occur. If it’s already working for you, be happy ๐Ÿ˜‰ Here are some of the problems I had to deal with:

  1. Lots of error messages complaining about citations that can not be resolved (solution: clear the temp folder, maybe there is some old stuff in there confusing the compilers)
  2. Instead of Author and Year, the title of the referenced sources is displayed (solution: this happens when bibtex is used to create the bibliography files, but biber is configured as backend for biblatex (which is the default). I solved this by executing biber thesis manually at the command line)
  3. Errors because of non-UTF-8 characters in the input (solution: Check your .bib file for non-standard characters such as German Umlauts or French accents. They need to be escaped. For example: รค -> {\”a}, รฉ -> {\’e}.
  4. Last visit date for online sources was not displayed (solution: I used the field lastchecked in the .bib file, but the right one is urldate, which is not displayed on the JabRef GUI. The date must be entered in the format yyyy-mm-dd!)
  5. Long book titles in the bibliography were underlined and overflowed the page, no line break was inserted (solution: Solved by adding \usepackage[normalem]{ulem} in the preamble)
  6. The abbreviation et al. was not printed in the document for sources with more than n authors (specified with the package option maxnames or maxcitenames). When I changed the package option citestyle from apa to authoryear it finally worked.

Puh, what a ride…I hope you guys will benefit from this!