6

I am trying to migrate from Zotero to org-ref, and got stuck when trying to use the doi-utils-add-bibtex-entry-from-doi command. After reading the Automatic Reference Key Generation section and searching online couldn't find an answer to this question. Can I change the order of the auto-generated entries (author, year, title), for example, to have an author_title_year bibtex key? Thank you in advance.

Ajned
  • 672
  • 4
  • 19

1 Answers1

5

The order of the components of the key are hard-coded, so you can't change them with a user option. However, you can re-write the function to set the order you want. You need to load your modified function after the original version, so your modification will replace it. The following code does this:

(eval-after-load "bibtex"
  '(defun bibtex-generate-autokey ()
    (let* ((names (bibtex-autokey-get-names))
           (year (bibtex-autokey-get-year))
           (title (bibtex-autokey-get-title))
           (autokey (concat
                     bibtex-autokey-prefix-string ;; optional prefix string
                     names
                     (unless (or (equal names "")
                                 (equal title ""))
                       "_") ;; string to separate names from title
                     title
                     (unless (or (and (equal names "")
                                      (equal title ""))
                                 (equal year ""))
                       bibtex-autokey-year-title-separator)
                     year)))
      (if bibtex-autokey-before-presentation-function
          (funcall bibtex-autokey-before-presentation-function autokey)
        autokey))))
Tyler
  • 21,719
  • 1
  • 52
  • 92