2

I'd like to be able to export BibTeX entries as (flexibly formatted) strings.

For example, a BibTeX entry like this one:

@Article{Chomsky:59,
  author    = {Noam Chomsky},
  title     = {On Certain Formal Properties of Grammars},
  year      = {1959},
  volume    = {2},
  pages     = {137--167},
  journal   = {Information and Control}
}

Should be converted into the following string:

Chomsky, Noam. 1959. On Certain Formal Properties of Grammars. Information and Control 2. 137--167. 

I used to manage my BibTeX database with JabRef which lets you customize exports. But I haven't seen something similar in Emacs/bibtex.el.

4

The org-ref package contains this functionality. Contrary to the name, org-ref has a lot of functionality outside of org mode. Take a look at the function org-ref-format-bibtex-entry. It also integrates this into helm-bibtex, so if you get everything set up correctly, you can call helm-bibtex, mark the citations you want, then hit f7 which inserts a formatted list.

EDIT:

If you didn't want to add a whole package with lots of dependencies, you can write your own function. Here's an example to illustrate:

(defun bibtex-format-entry-to-string ()
 "Format bibtex entry under point to a string."
 (interactive)
  (save-excursion
    (bibtex-beginning-of-entry)
    (let ((authors (bibtex-text-in-field "author"))
          (year (bibtex-text-in-field "year"))
          (title (bibtex-text-in-field "title")))
      (format "%s, %s, %s" authors year title))))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.