How to manage and export bibliographic notes/refs in org-mode

I’ve felt the need to manage my bibliography with org-mode, allowing me to write drafts of papers while being able to keep a track of all the litterature I’ve read and published already.

There are already many resources which explain how to integrate org-mode with reftex for instance, in order to cite papers inside org-mode, or how to link to biblographic references in bibtex format using org-bibtex.

People have also posted hints on how to manage bibliographic notes inside an org-mode file, which would allow to keep a track of read papers, tag them, add comments, and link these notes to the bibtex file contents.

But I couldn’t find a single comprehensive resource explaining if/how to manage links to such bibliographic notes that can both be navigated inside org-mode, and be exported to latex for previewing article drafts.

Here’s a proposal in attempt to bind all these needs together.

Let’s say we have one bibtex file ~/org/bibliography.bib which contains all the papers references.

We’ll also add into ~/org/bibliography.org all the notes relating to these articles. These notes will be identified by CUSTOM_ID properties which will contain the bibliographic reference of the papers.

Then we can create a draft in ~/org/draft.org which takes advantage of these.

We can then use two new link prefixes, bib and note to create links to entries in the bibtex file and the corresponding bibliographic notes. These are based on the use of a special rtcite link, that will be handled by a bit of emacs lisp.

Provided that some code is added in the .emacs to treat link opening and latex export for these rtcite links, we now have a valid solution :

  • clicking on a note:abibref link in an org-mode document will jump to the corresponding bibliographic note about a particular paper ‘abibref’ (a section in ~/org/bibliography.org which has a :CUSTOM_ID: abibref property).
  • clicking on bib:abibref link in an org-mode document will jump to the corresponding bibliographic reference in the bibtex file.
  • exporting an org document containing either of the above links to LaTeX will produce correct references cite{abibref} LaTeX code (see the results here : draft.pdf).

Details of the bibliographic notes contents (~/org/bibliography.org):

#+LINK: bib rtcite:bibliography.bib::%s

#+LINK: note rtcite:bibliography.org::#%s

#+title: My bibliographic notes

# \bibliography{bibliography}

* My papers

** 2005

*** Why and how to contribute to libre software when you integrate them into an in-house application ?

:PROPERTIES:
:CUSTOM_ID: bac05why
:END:

[[bib:bac05why][BibTeX]] .

/This is an interesting paper.../

See also [[note:berger06integration]]

In the above, note that note: links use rtcite links with a # character, which will allow jumping to the CUSTOM_ID property.

Details of a paper draft (~/org/draft.org) :

#+LINK: note rtcite:~/org/bibliography.org::#%s

#+LINK: bib rtcite:~/org/bibliography.bib::%s

#+title: How to mix org and bib for fun and profit
#+author: Olivier Berger

# \bibliography{bibliography}

* Read a lot

See [[note:bac05why][Why and how to contribute to libre software]] or [[bib:berger06integration]] .

#+BIBLIOGRAPHY: bibliography plain limit:t

Excerpts of the corresponding .emacs :

(defun my-rtcite-export-handler (path desc format)
  (message "my-rtcite-export-handler is called : path = %s, desc = %s, format = %s" path desc format)
  (let* ((search (when (string-match "::#?\\(.+\\)\\'" path)
                   (match-string 1 path)))
         (path (substring path 0 (match-beginning 0))))
    (cond ((eq format 'latex)
           (if (or (not desc) 
                   (equal 0 (search "rtcite:" desc)))
               (format "\\cite{%s}" search)
             (format "\\cite[%s]{%s}" desc search))))))


(require 'org)

(org-add-link-type "rtcite" 
                   'org-bibtex-open
                   'my-rtcite-export-handler)

The above is an adapted version of a proposal sent to the org-mode list by Nick Dokos in a response to Andreas Willig : http://lists.gnu.org/archive/html/emacs-orgmode/2012-02/msg00640.html