Skip to content

Citations (work in progress)

OliverBalfour edited this page Jun 26, 2021 · 4 revisions

Preface

Pandoc supports its own citations markdown extension which Obsidian doesn't have. This tutorial outlines how to use citations, but note that currently at any given time you can only use Pandoc's or Obsidian's markdown extensions. So, if you want citations, you must forfeit features like wikilinks, DataView tables, admonitions and Templater, and if you don't need citations you can do whatever you like.

Using Pandoc citations in this plugin

This example will use a BibTeX style bibliography to illustrate. CSL-JSON and other standard formats exported from Zotero or EndNote should work too. This example is based on demo 24 on the Pandoc demos page.

  1. Create a BibTeX bibliography as follows in a file called test.bib and save it somewhere you'll remember. Then, add a bunch of BibTeX citation blocks after each other. The following one was originally exported from Google Scholar's cite button:
@article{srivastava2014dropout,
  title={Dropout: a simple way to prevent neural networks from overfitting},
  author={Srivastava, Nitish and Hinton, Geoffrey and Krizhevsky, Alex and Sutskever, Ilya and Salakhutdinov, Ruslan},
  journal={The Journal of Machine Learning Research},
  year={2014}
}
  1. Create a new note in Obsidian and cite some of the documents. For example, @srivastava2014dropout will cite the above paper. For more advanced citation syntax see the Pandoc citation extension docs.

  2. Add YAML frontmatter to the top of the note specifying the bibliography:

---
bibliography: /path/to/test.bib
---
Rest of document, citing stuff like @srivastava2014dropout

Note: it's also possible to put --metadata bibliography=/path/to/report.bib (without any quotes) on a new line in the Extra Pandoc arguments setting to save typing.

  1. In the plugin settings, make the following changes
  • Set "Export files from HTML or markdown?" to "Markdown"
  • Append --citeproc to "Extra Pandoc arguments"
  1. Export to whichever format you like

  2. 🎉 🎉 🎉

Future direction

Having to choose between citations and Obsidian markdown kinda sucks. I'm still thinking of ways to resolve this, but don't expect a perfect solution anytime soon.

My current ideas to make it slightly easier are:

  • Add a YAML frontmatter setting to choose between Pandoc/Obsidian markdown when exporting at a file level. This will mean you can default to Obsidian markdown and only revert to Pandoc where necessary.
  • Add some settings to hide away the complexities of --citeproc, the CSL-JSON vs BibTeX formats, default bibliography metadata fields, etc. Rename the "Export files from ..." setting to choose between Pandoc and Obsidian markdown rather than choosing between input formats which is slightly less intuitive.
  • Can we leverage another plugin like the Obsidian citations plugin to do the heavy lifting?
Clone this wiki locally