Skip to content

Searching using Zotero's collections

Ramon Diaz-Uriarte edited this page Nov 19, 2024 · 3 revisions

When using https://github.com/retorquere/zotero-better-bibtex, Zotero's collection are exported as "groups" in the bib file. As explained in https://github.com/emacs-citar/citar/issues/769#issuecomment-2483019322 and https://github.com/emacs-citar/citar/issues/741, " the groups fields are parsed, and so stored in the cache". To use them in searches (and/or to narrow searches) all you need to do is add "groups" to the citar-templates.

This is a simple example.

First, create this bibtex file: test1.bib

@article{ag1,
  title = {One title by one author},
  author = {Someone},
  groups = {Group1}
}


@article{ag2,
  title = {The first paper by the second author},
  author ={AuthorB},
  groups = {caracol}
}


@article{ag3,
  title = {This title by second author has a different group},
  author ={AuthorB},
  groups = {hola}
}

Now, emacs -Q and:

  1. M-x package-initialize (citar, vertico, and orderless are installed)
  2. M-x vertico-mode
  3. Evaluate
(setq citar-bibliography '("~/tmp/test1.bib"))
(setq completion-styles '(orderless basic))

And also evaluate this citar-templatesdefinition

(setq citar-templates
      '((main . "${author editor:30%sn}     ${date year issued:4}     ${title:48}")
        (suffix . "          ${=key= id:15}    ${=type=:12}    ${tags groups keywords:*}")
        (preview . "${author editor:%etal} (${year issued date}) ${title}, ${journal journaltitle publisher container-title collection-title}.\n")
        (note . "Notes on ${author editor:%etal}, ${title}")))

This is copied from https://github.com/emacs-citar/citar#templates, but we add "groups" to "suffix".

  1. Open a buffer/file, say test.tex and M-x citar-insert-keys

  2. Start typing AuthorB and if you type cara you select only the ag2 entry.

  3. Type hola (the name of the other group): ag3 is the only selected reference.

Clone this wiki locally