Miskatonic University Press

Basic citations in Org (Part 2)

citations emacs

Numeric style in citation but not bibliography

In Part 1 we took a citation in its simplest form, using the default basic citation processor, then ran through all its possible styles and variants, and made a bibliography to go with it. It all worked—the in-text citation or footnote led to the right entry in the bibliography—except for the numeric style. That generated a number, but there was no number in the bibliography to match. We’ll start here by recreating the problem.

As before, we’ll use this Basic.bib file:

@book{friends,
  title = {​{​{LaTeX}​​} and Friends},
  author = {van Dongen, M.R.C.},
  date = {2012},
  location = {Berlin},
  publisher = {Springer},
  doi = {10.1007/978-3-642-23816-1},
  isbn = {978-3-642-23816-1}
}

Set the file basic.org to this, where the /nb in the citation object means the numeric style will be used.

#+options: title:nil author:nil date:nil toc:nil num:nil

#+bibliography: Basic.bib

"Most scholarly works have citations and a bibliography or reference
section," wrote a computer scientist [cite/nb:@friends].

* Bibliography

#+print_bibliography:

Exporting that to a PDF (C-c C-e l p) gives this:

Citation number does not match bibliography
Citation number does not match bibliography

The citation is “(1)” but there’s no matching numbered entry in the bibliography. How do we fix that? With the cite_export keyword.

cite_export

In basic.org we already have two keywords: bibliography (to specify where to look for bibliographic metadata) and print_bibliography (to tell Org to print the bibliography). Now we introduce the third: cite_export.

cite_export specifies three things: citation processor, bibliography style and citation style. The format is:

#+cite_export: citation-processor bibliography-style citation-style

If any of them is left out, the relevant default is used. If you don’t set cite_export, defaults are used for all three. If you specify one thing, it has to be a valid citation processor, and then the default bibliography and citation styles are used. If you specify two, they have to be a valid citation processor and a valid bibliography style, and then the default citation style is used.

(If you have an empty #+cite_export: line, the export generates a PDF with no citations or bibliography, and org-lint reports an error: “Missing export processor name.”)

In our above example, because we didn’t specify cite_export we were using the default citation processor, which is basic. However, we could specify it by name:

#+cite_export: basic

If we put that in basic.org and export to PDF we will get the same as before.

#+options: title:nil author:nil date:nil toc:nil num:nil

#+bibliography: Basic.bib
#+cite_export: basic

"Most scholarly works have citations and a bibliography or reference
section," wrote a computer scientist [cite/nb:@friends].

* Bibliography

#+print_bibliography:

That Org file exports to this PDF.

Basic processor, same as before
Basic processor, same as before

Indeed, same as before.

Bibliography styles

Defining only the citation processor and nothing more means the default bibliography and citation styles are used. What if we don’t want the default bibliography style? What is available? There are three options, listed in lisp/oc-basic.el:

  • author-year (the default)
  • numeric
  • plain

Let’s start by working through these bibliography styles. First, author-year, which is the default. This will be the same again: before we were defaulting to the default option, now we’re specifying in cite_export that we want to use it.

#+options: title:nil author:nil date:nil toc:nil num:nil

#+bibliography: Basic.bib
#+cite_export: basic author-year

"Most scholarly works have citations and a bibliography or reference
section," wrote a computer scientist [cite/nb:@friends].

* Bibliography

#+print_bibliography:

This exports to:

Basic processor, author-year bibliography, same as before
Basic processor, author-year bibliography, same as before

Again, same as before. Next, change cite_export to specify the numeric style.

#+options: title:nil author:nil date:nil toc:nil num:nil

#+bibliography: Basic.bib
#+cite_export: basic numeric

"Most scholarly works have citations and a bibliography or reference
section," wrote a computer scientist [cite/nb:@friends].

* Bibliography

#+print_bibliography:

This exports to:

Basic processor, numeric bibliography
Basic processor, numeric bibliography

Aha! They match! The numeric citation style (specified in the citation object by nb) goes with the numeric bibliography style. That makes sense. We have solved the problem!

But let’s keep going and change cite_export one last time to use the plain bibliography style.

#+options: title:nil author:nil date:nil toc:nil num:nil

#+bibliography: Basic.bib
#+cite_export: basic plain

"Most scholarly works have citations and a bibliography or reference
section," wrote a computer scientist [cite/nb:@friends].

* Bibliography

#+print_bibliography:

This exports to:

Basic processor, plain bibliography
Basic processor, plain bibliography

The plain bibliography style is plain indeed. It’s sort of like author-year but without formatting and just the family name of the author.

That covers the three options for bibliography style we can set in cite_export. Next, setting a citation style and how the two sets of options fit together.