# Zotero

Zotero! Full-service reference management. It starts with browser plugin which will import the metadata and PDF of the article you are browsing, then creates a big interactive searchable database of these things. From there one can export to various other formats, such a BibTeX, or render bibliographies directly based on plugins for your word processor. But don’t listen to me blather. Read the manual. Or the other manual. Or some other person’s manual.

Zotero has an API with which you can query, read and write bibliographic entries in your database, making it easy to scrip automatic updates and such.

It has an active community around it, and I don’t feel that I am locking my data away with an untrusted party if I rely upon it. (Of course, you can always try to migrate data around from anything to anything else by exporting to BibTeX or similar, but if you have URLs in there, or consort with foreigners who dare to have diacritics in their names, this leads to trouble). I can use the API to make changes that I couldn’t make manually, without worrying about that parsing nonsense. Moreover some other apps, such as Mendeley, already use the Zotero API, so you know that it’s not going to be a community of one playing with it.

To be evaluated, the currently active clients seem to be

I prefer no client at all. I use the Zotero plugin zotfile to synchronise a folder full of attachments to my tablet. It’s not perfect, but it’s easy and robust.

### Installing Zotero

Easy with windows and mac; there are standard installers. A little more tedious with linux. retorquere’s repo of deb installers is a simple way for Ubuntu. There are none of the snap-app packages one would expect for ubunutu. However, there is a cross-platform flatpak zotero, which is good, with the usual caveats about flatpak.

flatpak install flathub org.zotero.Zotero
flatpak override --user --filesystem=/PATH/TO/ZOTEROFOLDER \
org.zotero.Zotero

### Zotero Hacks

• Integrate with your existing folder of PDFs?

Richard Zach points out

… you keep your PDF directory synced across computers (e.g., if it lives in your Dropbox), linking the PDFs is just as good. If you add a PDF, Zotero will look up the metadata for you and add a reference to your database.

As a bonus, this means you don’t have to pay Zotero for storage. I pay them anyway because I want to support this project. Maybe I should just donate?

• For exporting references from Zotero to my plain text blog, I wrote a CSL file which renders my citations and bibliographies as Markdown and RestructuredText, which is good enough for the internet. This is a hack that works, but it could be better if you want to keep your citation keys consistent across internet and web pages.

• You could write a custom exporter for Zotero without lots of pain. However, writing code always produces some pain. Nonetheless, here are overview docs, detail docs, and all the code. One problem I have is writing to output formats with need a unique citekey reference to the items in the bibliography. Here is a simple example which deals with that citekey issue (albeit with an outdated version of the citekey system) Here is a soothing walk-through of the whole process.

• There is a Javascript API which you can access manually for one-off tricks, e.g. batch editing

• When debugging zotero, the secret flag to dump the log to stdout is -ZoteroDebugText.

tl;dr. There are many over-engineered solutions to get zotero citations in a blog. I use pandoc markdown with Better BibTeX. Anyway, if you want a more fragile but fancier solution, there are other options below.

#### Via BetterBibTeX

Better BibTeX, a.k.a BBT, makes all the BibTeX stuff in Zotero smoother, and since BibTeX also integrates with markdown via pandoc, this is a double win.

The biggest trick is that BBT makes sensible, user-accessible citation keys for your references, and if you use these consistently to refer to your sources, life will go well for you.

The citation keys are generated magically by a format string. (Of course, there is no guarantee your colleagues will agree on a sensible standard for citation keys, but that problem is perennial.)

[Auth:fold:nopunctordash][title:fold:nopunctordash:skipwords:select,1,1][year]

which I think is approximately the same as the much shorter

[zotero:clean]

That may be the same as as this other shortish one

​[auth][veryshorttitle1_1][year]

I am not sure if the latter two options handle diacritial marks correctly; I should check. Additionally, I do not trust [zotero:clean] because occasionally its meaning changes and it ruins everything.

So, say I want to cite the classic

Ingrid Daubechies (1988) Orthonormal bases of compactly supported wavelets. Communications on Pure and Applied Mathematics, 41(7), 909–996. DOI.

In broad terms, these all generate citation key DaubechiesOrthonormal1988 to refer to that article. I could then refer to that citation in LaTeX as \cite{DaubechiesOrthonormal1988}, in markdown as @DaubechiesOrthonormal1988 and so on.

BibTeX will also generate the necessary biblography databases (e.g. .bib file) for my software too and even keep that file updated as I add more articles to zotero.

I am fond of the following BibLaTeX export exclusions to keep the files small.

file,abstract,note,keywords,lccn

BBT has a Cite-as-you-write feature for integration with generic editors, including a GUI popup. I do not use this. It also has HTTP-pull export support, meaning that accessing an up-to-date bib file is a matter of an HTTP request that looks like http://127.0.0.1:23119/better-bibtex/collection?/1/citation_management.biblatex to pull all the records in the citation_management collection and this works from my local copy of Zotero, so it’s fast and reliable compared to the cloud Zotero server API which depends upon my internet connection etc.

Pro tip: the pull export works better if for me if I set the advanced preference extensions.zotero.translators.better-bibtex.sorted to be true so that the reference sorting is consistent.

citr provides an interactive citation finder for RStudio that works with BetterBibTeX.

install.packages("citr")

### Via CSL

CSL is a citation rendering mini-language used by modern journals and software to express house style. And you can use it too.

This is a slightly weird way to get plain-text citations out; CSL is a system for instructing your citation software how to render citations in your word processor; but it can be forced to pump out normal text. It is robust ad simple. There is a CSL editor online so this is easy-ish. One catch is that you might, like me, wish to get your BibTeX citation keys out to refer to them. But Bibtex keys are not accessible to CSL, so this doesn’t quite work.

• Here is my docutils/ReST style file, restructuredtext.csl, which renders citations as plain text with ReST markup, including anchor links.

It’s ugly, because it has to battle with a grumpy rich-text XML infrastructure to render plain text, but it gets the job done without any coding, and is robust against software changes.

• Similarly, here is my Markdown style file, markdown.csl, which, likewise, renders citations as plain text with Markdown markup, including anchor links.

• Emiliano Heyns has a BibTeX key CSL, which renders Emiliano’s preferred citekey \{LeDT06} (sadly not quite matching mine.)

CSL has a citation-label variable, but it doesn’t correspond to the bibtex keys generated by BBT, which is unsatisfactory.

### Via the Atom citation picker

For Atom+Zotero+Markdown, you could try zotero citation, which adds a citation picker to the atom editor. References look like

[$$Heyns, 2014$$](#@heyns2014)
[$$Heyns, 2014$$](?@heyns2014,heyns2015)

They are rendered in the output by an in-built pandoc filter, which is installed separately. One locates the output bibliography in the document in either pandoc-YAML or plaintext format at

[#bibliography]: #

I don’t bother; BetterBibTeX works fine for my needs and across many editors.

### Dynamic bibliography generation in situ

Erik Hetzner’s zotxt can avoid the need to create bibfiles, rendering bibliographies directly by querying the zotero app, rather than rendering an intermediate file. Since rendering an intermediate file is scriptable, this does not appeal to me.