PSA: as of Zotero 5.0.71, access to the CAYW URL will no longer work from the browser for security reasons; curl
and other programmatic access such as from editors access will work.
Good news for TeXnicians and those down with Mark (aka Markdown, RST, whatnot): this is the time to go pester the author of your favorite editor for Zotero integration!
Graciously supplied by David Lukes:
paste it in your .vimrc (and modify to your liking):
function! ZoteroCite()
" pick a format based on the filetype (customize at will)
let format = &filetype =~ '.*tex' ? 'citep' : 'pandoc'
let api_call = 'http://127.0.0.1:23119/better-bibtex/cayw?format='.format.'&brackets=1'
let ref = system('curl -s '.shellescape(api_call))
return ref
endfunction
noremap <leader>z "=ZoteroCite()<CR>p
inoremap <C-z> <C-r>=ZoteroCite()<CR>
This inserts the citation at the cursor using the shortcut ctrl-z (in insert mode) or <leader>
z (in normal, visual etc. modes, <leader>
being backslash by default).
A sample implementation of real integration (rather than the working-but-clunky workarounds using paste) can be found in the Zotero Citations package for the Atom editor.
If you don’t feel like typing citations out (and let’s be honest, you don’t), executing VS Code Citation Picker for Zotero extension for the VS Code editor will call up a graphical picker which will insert these for you, formatted and all.
Dave Smith has gracefully written instructions on how to set up Scrivener 2.0 and Marked 2 for OSX to use the CAYW picker, including ready-to-run apps
Emilie has writen instructions for using the CAYW picker for Scrivener 1.0 in Windows 10, with the necessary files
David Lukes takes Overleaf integration one step further with a GreaseMonkey/TamperMonkey userscript which not only allows popping up the CAYW picker straight from your browser, no other tools required, but adds a hotkey to refresh your bib file on Overleaf. This should work with the free subscription, no fiddling with git or dropbox required.
BBT exposes an URL at http://127.0.0.1:23119/better-bibtex/cayw 1. The url accepts the following URL parameters:
parameter | |
---|---|
probe |
If set to any non-empty value, returns ready . You can use this to test whether BBT CAYW picking is live; it will not pop up the picker |
format |
Set the output format |
clipboard |
Any non-empty value will copy the results to the clipboard |
minimize |
Any non-empty value will minimize Zotero windows after a pick |
texstudio |
Any non-empty value will try to push the pick to TeXstudio |
selected |
Any non-empty value will use the current selection in Zotero rather than popping up the pick window |
The following formats are available:
latex
. Generates natbib citation commands. Extra URL parameters allowed:
command
: the citation command to use (if unspecified, defaults to cite
)cite
is an alias for latex
with the assumption you want the cite command to be cite
biblatex
. Generates biblatex citation commands. Extra URL parameters allowed:
command
: the citation command to use (if unspecified, defaults to autocite
)mmd
: MultiMarkdownpandoc
. Accepts additional URL parameter brackets
; any non-empty value surrounds the citation with bracketsasciidoctor-bibtex
scannable-cite
for the ODF scannerformatted-citation
: output formatted citation as per the current Zotero quick-export setting, if it is set to a citation style, and not an export formatformatted-bibliography
: output formatted bibliography as per the current Zotero quick-export setting, if it is set to a citation style, and not an export formattranslate
invokes a Zotero export translator. Extra URL parameters allowed:
translator
: stripped name of one of the BBT translators (lowercased, remove ‘better’, and only the letters, e.g. biblatex
or csljson
), or a translator ID. Defaults to biblatex
.exportNotes
: set to true
to export notesuseJournalAbbreviation
: set to true
to use journal abbreviationsjson
: the full pick information Zotero provides.The picker passes the following data along with your picked items if you filled them out:
field | |
---|---|
locator |
the place within the work (e.g. page number) |
prefix |
for stuff like “see …” |
suffix |
for stuff after the citations |
suppress author |
if you only want the year |
However not all output formats support these. Pandoc and scannable cite are the richest ones, supporting all 4. MultiMarkdown supports
none. The formatted-
formats will ignore these. LaTeX supports all 4, in a way:
latex
(natbib
) format: if you choose suppress author
for none or all of your items in a pick, you
will get the citation as you would normally enter it, such as \cite{author1,author2}
, or
\citeyear{author1,author2}
. If you use locator
, prefix
, suffix
in any one of them, or you use suppress author
for some but not for others, the picker will write them out all separate, like \cite[p. 1]{author1}\citeyear{author2}
,
as natbib doesn’t seem to have a good mechanism for combined citations that mix different prefixes/suffixes/locators.biblatex
format: suppress author
is ignored unless the command is one of \cite
, \autocite
or \parencite
and there is one items only, in which case the starred variant of the command is returned, which
hides the author; for multiple items with locator
s, prefix
es or suffix
es, the s
-affixed variant of the
command is generatedSome of the formatters use abbreviated labels for the results if you include a locator. The defaults are:
locator label | abbreviation |
---|---|
article | art. |
chapter | ch. |
subchapter | subch. |
column | col. |
figure | fig. |
line | l. |
note | n. |
issue | no. |
opus | op. |
page | p. |
paragraph | para. |
subparagraph | subpara. |
part | pt. |
rule | r. |
section | sec. |
subsection | subsec. |
Section | Sec. |
sub verbo | sv. |
schedule | sch. |
title | tit. |
verse | vrs. |
volume | vol. |
In your call to the CAYW URL, you can override the abbreviations by adding them to the query, e.g. http://127.0.0.1:23119/better-bibtex/cayw?format=mmd&page=&Section=sec., page-picks will have no label, and Section-picks will get sec.
rather than Sec.
.
The clipboard
option can be used as a workaround for editors that haven’t gotten around to integrating this yet. If
you use this option you will probably want to bind to a hotkey, either system-wide (which is going to be platform-dependent, I know
AutoHotKey works for windows, for OSX Karabiner ought to
do the job, and for Linux xbindkeys could do the job.
For example, if you call up http://127.0.0.1:23119/better-bibtex/cayw?format=mmd&clipboard=yes, the Zotero citation picker will pop up. If you then select two items that happen to have cite keys adams2001
and brigge2002
, then
[#adams2001][][#brigge2002][]
, and[#adams2001][][#brigge2002][]
will be left on the clipboardMore of a gimmick than anything else, but if you add select=true
, BBT will select the picked items in Zotero.
For testing for other markdown formatters, you can construct simple references yourself, using the playground
formatter, with parameters:
citeprefix
, default empty, for text to put before the full citation.citepostfix
, default empty, for text to put after the full citation.keyprefix
, default empty, for text to put before each individual citekeykeypostfix
, default empty, for text to put after each individual citekeyseparator
, default ,
, for text to put between citekeysAlternately, the json
formatter will just give you the picks as JSON which you can turn into pretty much anything if you can code.
but if you need an extra format, just ask.
For Juris-M, the port number 23119
must be replaced with 24119
. ↩︎