Mixing up Zotero citation markers
Zotero has an essential place in my research and writing process. It’s a free, open-source reference manager that doesn’t try to lock you into a for-profit platform. For years I’ve been using the RTF/ODF-Scan add-on, so that I can cite things using plain-text codes and later format the references in any citation style I want, using the Zotero plugin in LibreOffice. Recently I decided to switch to a more flexible Pandoc-based workflow, which requires a different kind of in-text citation marker. How to convert Zotero scannable cites into Pandoc-style citation keys was not obvious, though, so I’m documenting it here in case anyone else needs to do this.
The solution that I found uses another Zotero add-on, Better BibTex (BBT), to create a custom export of my Zotero library. For each reference in the library, this export includes both the Zotero-internal keys that are used in scannable cites and the BibTeX citation keys, generated by BBT, which are referenced in Pandoc-style citations. Using that export as a crosswalk made it possible to write a Python script that takes my existing documents (in Markdown format) and translates all the citation markers. I documented the details in this notebook.
Because, for any project longer than a blog post, I really prefer writing in Scrivener over a word processor like Microsoft Word or LibreOffice. Scrivener makes the outlining, writing, revising, and editing process so much easier. I’m not sure how to describe Scrivener, but by the most mundane possible description it’s a “content-generation tool for writers” (ugh). Anyway, there is no Zotero integration for Scrivener in the same way that there is for Word or LibreOffice, so these citation-marker systems are essential to get the full flexibility of citation management.
To convert my Scrivener projects where I had been using Zotero scannable cites, I exported the text to Pandoc Markdown, processed it like I mentioned above, and then brought it back into Scrivener using the Import and Split feature. The text completely retains its structure and formatting. And the best part is that any future export to Markdown can then be turned into Word, LaTeX, or any other format that Pandoc can produce—with or without citation processing. I now quick-copy citations from Zotero into my documents in Pandoc format (thanks to BBT) instead of as scannable cites.
As a side note, a research librarian once pointed out to me that these weird writing workflows can be fragile because they depend on a handful of developers not quitting their open-source projects. It’s true, so thank you to all those people! Between Zotero and Pandoc, there’s a lot of effort being put in by a very active community. There may not even be any need for this silly cite-translation hack in future versions of Zotero. By the way, the RTF/ODF-Scan add-on is great—plus, it has the kind of charm you can only get from free software: