This post originally appeared on vxlabs.com, my more broadly-themed tech blog. It is reproduced here with permission.
I have written before explaining how you can use org-ref to insert citations into your org mode documents, and then have them export perfectly into PDF documents via LaTeX.
On my quest for personal knowledge management nirvana where my org mode
files serve as the single universal source of truth, from which I can
generate any other document and publication formats that might be
required, I ran into the problem of org-ref citations on the one hand,
ox-hugo’s use of pandoc-style
citations on the
I could not make peace with the fact that I would have to use different styles of citations in org mode, depending on what my intended output modality was going to be.
What exactly is the issue?
org-ref expects citations of the form
cite:surname2011,otherref2012. Depending on the bibliography
cite: can result in different output,
e.g. parenthetical or inline.
ox-hugo first converts org mode to blackfriday-flavour markdown, and
then, if if the relevant metadata is found, passes that markdown through
pandoc and pandoc-citeproc to have pandoc-style
If you intended to generate PDF, you would have to use style 1, whereas
if you were intending to publish on your website using
would have to switch all of your citations.
Surely there must be a way to solve this!
Until someone comes up with an actual solution, you can make the
following change to the
org-ref-make-format-function macro in
In short, copy the
cond sexp handling pandoc export and use it to
override the existing markdown export case by simply inserting it before
What will happen, is that during the first org to markdown conversion, org-ref-style citations will be converted to pandoc-style citations.
It would probably be better to write some sort of opt-in bridge code that could for example advise the generated org-ref export functions to perform the hack above in a nicer way.
Other solutions to this problem have been discussed on the ox-hugo github, but it looks like they are letting org-ref do all the work, while here we are simply converting org-ref-style citations to pandoc-style before the ox-hugo pandoc stage.
Can you show me how this works?
This org source:
Will be rendered like this:
I recently read a really great paper on neural speech synthesis using transfer learning via a speaker discrimination task (Jia et al. 2018). If you would like to reproduce that work, you’ll probably run into the VoxCeleb2 dataset (Chung, Nagrani, and Zisserman 2018).
Note 1: Limitations
With this hack, there’s no easy way to produce inline citations,
@cite1. One would have to modify the patched code
to distinguish between
cite: in the pandoc-translation.
Note 2: org-ref-default-bibliography
For org-ref’s super slick interactive citation insertion function
C-c ]) to work, you have to set the file-local
org-ref-default-bibliography to the path of the
I have the following at the end of this org file to make that happen:
This post shows one hacky way of continuing to use only org-ref-style
cite: links in your org files, but still having the ability of
producing ox-hugo pages with perfect bibliographies.
Chung, Joon Son, Arsha Nagrani, and Andrew Zisserman. 2018. “VoxCeleb2: Deep Speaker Recognition.” In Interspeech 2018, 1086–90. ISCA. https://doi.org/10.21437/Interspeech.2018-1929.
Jia, Ye, Yu Zhang, Ron Weiss, Quan Wang, Jonathan Shen, Fei Ren, zhifeng Chen, et al. 2018. “Transfer Learning from Speaker Verification to Multispeaker Text-to-Speech Synthesis.” In Advances in Neural Information Processing Systems 31, edited by S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, 4480–90. Curran Associates, Inc.