Zotero integration/plugin/workflow at least!

I finally got around to transitioning from ODF/RTF scan to the Pandoc workflow so I could upgrade to Zotero 7 and wanted to share the steps I took to get it working. With this workflow, you can write in Scrivener as you normally do (i.e. not in Markdown format) and export directly to a Word document with linked citations (after a Zotero refresh). As it relies on Markdown format there are some limitations, primarily related to formatting. If, like me, you only do minimal formatting in Scrivener (e.g. headers, titles, and body) it doesn’t seem to pose a problem. The other drawback to the Pandoc workflow is that BetterBibTex citekeys are non-static, unlike those used for the ODF/RTF workflow.

If anyone has any suggestions on how to improve this workflow or finds any errors, please let me know!

  1. Install Homebrew
    1. Open Terminal and paste the following: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. Install Pandoc
    1. Open Terminal and paste the following: brew install pandoc
    2. Download zotero.lua file from this page and place it in the filters folder in your Pandoc directory. You may need to create the filters folder within the pandoc directory and the path to the folder should look something like this: ~/.local/share/pandoc/filters/ or /Users/[username]/.local/share/pandoc/filters/
  3. Install BetterBibTex extension in Zotero, export an auto-updating bibliography, and set the Quick-Copy format:
    1. Auto-updating bibliography:
      1. In Zotero, navigate to File > Export Library
      2. Under format, select “Better BibTeX JSON”
      3. Make sure the “Keep updated” checkbox is ticked
      4. Select a location for the file where it can permanently live
    2. Quick-Copy format:
      1. In Zotero, navigate to Zotero > Settings
      2. Under “Better BibTex” scroll down to “Quick-Copy”
      3. Under “Quick-Copy format” select “Pandoc citation” and make sure “Surround Pandoc citations with brackets.” Note that this functionality (surrounding with brackets) appears to be broken. I’m holding out hope that a future version of BetterBibTex will fix this. If this happens, the Zotpick AppleScript will need to be recompiled to not insert brackets (see below).
  4. Download the appropriate Zotpick script (zotpick-pandoc for Scrivener.applescript). For whatever reason, this script does not insert citations in brackets (if somebody knows a better way to fix this, let me know). To address this:
    1. Open the script in Script Editor
    2. Find the section that looks like this:
tell application "System Events"
	try
		repeat with letter in theReference
			keystroke letter
			delay keyDelay
		end repeat
	on error errMsg
		display alert errMsg
	end try
end tell
  1. Add “keystroke [“ and “keystroke ]” to the script, so it looks like this:
	try
		keystroke "["
		repeat with letter in theReference
			keystroke letter
			delay keyDelay
		end repeat
		keystroke "]"
	on error errMsg
		display alert errMsg
	end try
end tell
  1. Go to File > Export and for “File Format” select “Application.” For “Code Sign” select “Sign to Run Locally.”
    1. Place the exported application file in your Applications folder (or other location where it can live permanently).
      Note: If you exit the Zotero citation selector without selecting a citation, Scrivener will be refocused and “[ ]” will be typed. This is an issue that I don’t know how to fix.
  2. Set up Scrivener:
    1. Open Scrivener and go to Scrivener > Settings. Navigate to “Citations” and set up the Zotpick application you just created as the “Bibliography Manager.” Once you exit settings, press ⌘Y. The Zotero citation picker should be called up. On the first call you will be asked to grant permissions by MacOS. Make sure you grant all of them! Once granted, when a citation is selected in the picker, it should refocus Scrivener and paste a BibTex citation in brackets which looks like: [@sloanePlanningAngeles2012, p. 162-163]
    2. Go to File > Compile and select “MultiMarkdown” from “Compile for.”
      1. Select the gear icon from the right pane and make sure “Convert rich text to MultiMarkdown” is selected and “Escape special characters” is unselected.
    3. Select “Basic MultiMarkdown,” click the “+” icon in the lower left, and select “Duplicate & Edit Format” to create a custom format and set up post-processing.
      1. In the window that is called up, navigate to “Processing” and make sure “Post-process on command-line” is selected.
      2. Click “Edit Script” and, in to the text box labeled path, paste: /opt/homebrew/bin/pandoc
      3. In the textbox labeled “Arguments” paste: --lua-filter=zotero.lua --citeproc --output <$outputname>.docx --bibliography /Users/[username]/.local/share/pandoc/My\ Library.bib <$inputfile>
        Note: You will need to change the path for your bibliography depending on where you output it to.
      4. When you save your custom Compile Format, make sure you save to “My Formats” rather than “My Projects” so you can access it from other Scrivener projects.
  3. Now when you compile your Scrivener document it will now produce a Markdown file (there are options in Scrivener to delete this file after post-processing) as well as a Microsoft Word document with converted citations, all you need to do is refresh them!
4 Likes