Zotero citations in Markdown - publishing to ePub or PDF
Mostly notes to myself - I hope you find them useful.
So, you want to write your dissertation or thesis in Markdown. But how do you manage all your citations?
- Install Zotero
- Install the Better BibTex plugin
- Restart Zotero. The BBT plugin will launch a configuration screen - use it to set your preferences
- Install VS Code (or VS Codium)
- Install the VS Code Zotero plugin
Now, when you want to enter a citation in Markdown, the combined plugins will generate something like this:
MARKDOWN## Abstract
Space is really big @adamsHitchhiker1979
That @adamsHitchhiker1979
is the citation.
Formatting citations
You want to export your Markdown to something like ePub or PDF with nicely formatted citations like (Adams, 1979)
Use Pandoc!
- Install Pandoc
- In Zotero, use File → Export Library. Export in Better BibTex format as
test.bib
.
Add the following configuration section to the top of your Markdown file:
MARKDOWN---
bibliography: test.bib
...
Run the following command:
pandoc --citeproc test.md -o test.epub
Hey presto! You now have a nicely formatted ePub with all the citations in your preferred format, and the bibliography at the end.
Format the citations better
The citations don't look the way I want them to!
- Download your preferred Citation Style from Zotero, save it as
whatever.csl
- Add the following into your Markdown file's configuration section
csl: whatever.csl
-
Important Make sure that your citations are wrapped in
[
and]
otherwise Pandoc will mess things up. See the Pandoc Citations Extension for more details.
Your Markdown should look something like this:
MARKDOWN---
bibliography: test.bib
csl: whatever.csl
link-citations: true
...
# Intro
Computers are complicated [@verletComputerExperimentsClassical1967].
Then run pandoc --citeproc test.md -o test.epub
- you can change the file type to html, pdf, or anything else your system supports.
Make it look even nicer
This is the boilerplate that I use.
MARKDOWN---
bibliography: test.bib
csl: whatever.csl
link-citations: true
reference-section-title: References
title: My brilliant title
...
# Intro
Computers are complicated [@verletComputerExperimentsClassical1967].
## Something
More info [@smithEvolutionInnovationCapability2017]
<div id="refs">
## References
</div>
## The End
Goodbye!
That gives you a title, ensures that all in-text citations link down to the references, and puts the references somewhere other than the end. Here's the HTML it produces using pandoc --citeproc test.md -o bib.html
:
HTML<h1 id="intro">Intro</h1>
<p>Computers are complicated <span class="citation" data-cites="verletComputerExperimentsClassical1967">(<a
href="#ref-verletComputerExperimentsClassical1967" role="doc-biblioref">Verlet, 1967</a>)</span>.</p>
<h2 id="something">Something</h2>
<p>More info <span class="citation" data-cites="smithEvolutionInnovationCapability2017">(<a
href="#ref-smithEvolutionInnovationCapability2017" role="doc-biblioref">Smith <em>et al.</em>, 2017</a>)</span>
</p>
<div id="refs" class="references csl-bib-body" role="doc-bibliography">
<h2 id="references">References</h2>
<div id="ref-smithEvolutionInnovationCapability2017" class="csl-entry" role="doc-biblioentry">
Smith, C. <em>et al.</em> (2017) <span>‘The <span>Evolution</span> of an
<span>Innovation Capability</span>’</span>, <em>Research-Technology
Management</em>, 60(2), pp. 26–35. Available at: <a
href="https://doi.org/10.1080/08956308.2017.1276388">https://doi.org/10.1080/08956308.2017.1276388</a>.
</div>
<div id="ref-verletComputerExperimentsClassical1967" class="csl-entry" role="doc-biblioentry">
Verlet, L. (1967) <span>‘Computer "<span>Experiments</span>" on
<span>Classical Fluids</span>. <span>I</span>. <span>Thermodynamical
Properties</span> of <span>Lennard-Jones Molecules</span>’</span>,
<em>Physical Review</em>, 159(1), pp. 98–103. Available at: <a
href="https://doi.org/10.1103/PhysRev.159.98">https://doi.org/10.1103/PhysRev.159.98</a>.
</div>
</div>
<h2 id="the-end">The End</h2>
<p>Goodbye!</p>
If that was useful to you - or if you think you know a better way - please drop a comment in the box.
Andy Wootton said on fosstodon.org:
@Edent I recently started using Obsidian. It works from a directory of .md files, each a note, and [[links]] in the notes form a graph of the connections between notes. References are just another note. I haven't dealt with the presentation layer yet. It's not perfect but it's the best thing I've found.
rob dyke dot com said on mastodon.social:
@Edent many moon ago I wrote my dissertation, using SVN, LaTeX, BiBTeX, and bash scripts to wrangle a PDF output and othersGot a new project. Needed some new tooling.
More comments on Mastodon.