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

8 thoughts on “How to manage and export bibliographic notes/refs in org-mode”

  1. You may also want to add special customizations of reftex-cite-format, for example as :
    (quote ((?b . “[[bib:%l][%l-bib]]”)
    (?n . “[[note:%l][%l-note]]”)
    (?t . “%t”)
    (?h . “** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[bib:%l][%l-bib]]”))

    See the link above for more details

  2. Excellent.

    I need one help.

    The .emacs set up is based on org folder in Home. How can I put the files in Dropbox ? What changes do I need to make in .emacs.

    I am totally new to emacs and do not know lisp. Please give me the code 😐

  3. In bibliography.org file, the last line is not working it seems (I must be doing some mistake)

    See also [[note:berger06integration]]

    After clicking, it says “no match- create this as a new heading ?”

  4. Hey Olivier,

    It seems that your code is a good way to handle it. It would be nice, if you expand your post a little bit and provide an insight into the whole corresponding ‘.emacs’.

    Cheers!

  5. Hi,
    Thanks for this great post. One thing though. Suppose I have an org file for a book, with different notes corresponding to different page. Pages are in CUSTOM_ID. Is it possible to have a link to a heading in an arbitarary org file, something like [[note:%s::#%s]] in which the first string is org file for notes on some book, and the second string is the CUSTOM_ID for a heading.

    Also is it possible for rtcite eport handler to identify #%s as a page number for \\cite?

Leave a Reply

Your email address will not be published. Required fields are marked *