Skip to content

Research Paper Management with Emacs, org-mode and RefTeX

January 4, 2011

Update 3-11-14:  Nuno Salgueiro in the comments led me to a RefTeX change that broke the “jump to this entry in notes.org” behavior (it seems “reftex-citation” returns a list now, regardless if there is only one entry). This can be fixed by changing (reftex-citation t) to (first (reftex-citation t)).

Update 1-19-11: I’ve added a screencast of me demonstrating how I use this setup to work with my papers, I’ve also re-written the “Workflow” section (due to the fact it was kind of confusing…) Hope this all helps :]

Update 4-27-12:  olberger (in the comments section) has added, what I consider, an incredibly clever and useful function to help when writing papers. I’ve just finished tweaking it slightly for my purposes, but please check out his post, here. I’ll be adding what I did to this post… when I get around to it.

My labmates and I have been searching for a while now for methods to organize the mountain of research papers we collect as graduate students. I’ve tried a handful of approaches, and was happy using zim-wiki for a while, but entering info became a choir, and finding a paper could sometimes be a hassle.

My recent attempts at working with lisp have led me to switch to emacs, and in what seems to be a common occurrence, I wanted to do everything in emacs. As silly as that sounds, I believe I’ve found my solution to organize my papers through emacs.

Managing papers and references in emacs is nothing new, and I actually followed a few guides on how other people used org-mode and reftex to do so. Specifically this post, and this email. My hope with this initial post is to pull the bits together, show what I built on top of them, and how I setup my org files to facilitate my workflow. If you don’t know how to use or don’t know what emacs and org-mode are, give a quick search–there is plenty of info out there.

Setting up RefTeX

First, we want to load to load RefTeX whenever we use org-mode. This is well documented, and mine only differs in the citation formats I pass to RefTex, and my additional key binding.

(defun org-mode-reftex-setup ()
  (load-library "reftex")
  (and (buffer-file-name) (file-exists-p (buffer-file-name))
       (progn
	 ;enable auto-revert-mode to update reftex when bibtex file changes on disk
	 (global-auto-revert-mode t)
	 (reftex-parse-all)
	 ;add a custom reftex cite format to insert links
	 (reftex-set-cite-format
	  '((?b . "[[bib:%l][%l-bib]]")
	    (?n . "[[notes:%l][%l-notes]]")
	    (?p . "[[papers:%l][%l-paper]]")
	    (?t . "%t")
	    (?h . "** %t\n:PROPERTIES:\n:Custom_ID: %l\n:END:\n[[papers:%l][%l-paper]]")))))
  (define-key org-mode-map (kbd "C-c )") 'reftex-citation)
  (define-key org-mode-map (kbd "C-c (") 'org-mode-reftex-search))

(add-hook 'org-mode-hook 'org-mode-reftex-setup)

Jump to Entry

The other difference I added was the binding of  “C-c (” to org-mode-reftex-search, which I defined earlier in my init.el. This is the command that will jump to the entry in my org-mode file, and follows

(defun org-mode-reftex-search ()
  ;;jump to the notes for the paper pointed to at from reftex search
  (interactive)
  (org-open-link-from-string (format "[[notes:%s]]" (reftex-citation t))))


(defun org-mode-reftex-search ()
  ;;jump to the notes for the paper pointed to at from reftex search
  (interactive)
  (org-open-link-from-string (format "[[notes:%s]]" (first (reftex-citation t)))))

Simple. But I was happy with the results. Update: changes in reftex from initial authoring of this post have reftex-citation return a list. An updated function to fix this has been added :P

Making Org-mode work with you

Lastly, org-mode needs a few things to pull all this together. The first and most important is importing the bibtex file. RefTeX looks for a LaTeX \bibliography tag anywhere in the file, I place mine as an org-mode comment at the start of the file

# \bibliography{~/research/refs.bib}

The other thing needed is link abbreviations. While you could hardcode this into your citation formats, I prefer to put abbreviations in for the citation formats, and define defaults elsewhere in my init.el

(setq org-link-abbrev-alist
      '(("bib" . "~/research/refs.bib::%s")
	("notes" . "~/research/org/notes.org::#%s")
	("papers" . "~/research/papers/%s.pdf")))

These can be easily overridden in an org-mode file, which I actually do for the org-mode file I store the actual entries in. If I left it as is, following a “notes” link in this org-mode file would open the same file in a new window and jump to the entry in that one. Not quite what we want. This is where I override it in the local file by adding this to my heading.

#+LINK: notes #%s

Now, if I follow a “notes” link in the entries file, it jumps to that entry in the same frame, while following a “notes” link in another org-mode file (or using my new reftex search addition) will open this file in a new frame and jump to the entry.

Workflow

My setup for this involves two main files: refs.bib, the main bibtex file, and notes.org, the org-mode file I use to manage the papers and store notes for each.

In notes.org my overall workflow follows a typical org-mode hierarchical layout, the key parent being “Papers” with each child heading being either a category or an entry for a paper, each with the appropriate or useful org-mode tags. Each paper headline corresponds to that paper, and I write notes under these headlines about the paper.

The hierarchical layout has children inheriting parents tags which is quite nifty. This is my initial lookup method when I’m looking for a paper. For example, I want to find a paper that describes how to couple EDOT using an iron catalyst, I can type “C-c \” to do a tag search, type in one or all of the relevant keywords, and org-mode will show the entries matching those tag[s]. I can then expand those entries, see what notes I’ve written on the papers, and when I found the one I’m looking for, I can open the link to the pdf I’ve placed there using “C-c C-o”.

When I find a new paper I need to add, I initially gather all the data I need to use org-mode: the bibtex entry and the paper itself. I modify the bibtex key to fit with my scheme (FirstAuthorYear) but you can use whatever suites you best. I then save the paper using that bibtex key as the filename in another folder.

Note: I manage my bibtex entries by first saving each new bibtex entry as a separate file in a collective folder (due to the fact I usually export them from the journal’s website when I find the paper) and then I concatenate all the files in that folder to make a new bibtex file using

$ cat bibtex/*.bib > refs.bib

This feels a little messy, but the easiest solution I could think of; I’m sure I could setup a command to do this for me from emacs, but this is a low priority. The one problem with this is if you change the bibtex file while org-mode is running, RefTeX will not see the changes. To do so you need to enable “global-auto-revert-mode” in emacs. Supposedly, this is automatically enabled in emacs 23, but it seems to be disabled by default for me (23.2.1)

Adding a new headline in my notes.org file is simplified by using RefTex. I place my cursor on a new line and hit “C-c )” which is bound to “reftex-citation”. The first prompt is for a citation format (if more than one) and I have a few for different purposes. I hit ‘h’ for heading, which contains all the formatting for a barebones paper headline. This puts a new entry with the title of the paper as the headline, a propeties list with custom-id of the bibtex key (this allows linking to this entry by it’s bibtex key), and a body containing a link to the pdf. After selecting the format, RefTeX prompts for a regex to search the bibtex file with, presenting a list of matching entries. Selecting the desired entry inserts the citation, in this case, the new entry.

This is how we exploit RefTeX, we create custom citation formats that are really org-mode tags and formattings. A few other formats I have are all org-mode links: one that links to the entry in the bibtex file itself, one that links to the pdf, and another that links to the entry in the org-mode file. I use org-mode link abbreviations to get general behavior that can be changed on a per-file basis.

Another option I recently added to this is a way to search for other info I may not have placed in a tag, such as an author or journal name. Here I shamelessly take adavtage of having reftex loaded again. I bound this key to a custom command I made that will jump to the entry for the bibtex entry you select from the reftex-citation prompt.

And that’s that! So far, this is the most powerful approach I have found, and I know I’ve spent less time searching than any other method I’ve found. What’s also great about this is that org-mode’s exporting allows me to export this as HTML to serve up on our group’s website for the rest of my group to use. An additional benefit is that because I’m already gathering bibtex entries, when it comes time to write a paper, I already have all my citation data, and I can easily search a key to retrieve all my notes on that paper as well.

There are some weaknesses I’m still trying to work out, such as manually scraping bibtex entries and making sure everything has the proper filename. The problem really is that all the journals aren’t consistent with these things (some don’t even provide bibtex export! Luckily, there’s bibutils to handle the conversions) and entries need to be tweaked and/or pdf’s named according to the key. Ideally, I would like to find a database that I could script a tool against to scrape the data I need and already name and places the files for me, but that is for another day/entry

I’ve been trying to see about using attachments to handle the papers instead, but I haven’t been able to tweak it to my satisfaction just yet. Still trying though. This should allow me to attach multiple files for an entry (such as supporting info, etc)

About these ads

From → Howto

51 Comments
  1. Hi, thanks for this; it sounds very interesting. First, I wasn’t aware of the features of RefTex. I’ve been using AucTeX for years but used it without RefTex. Now my workflow is even better. Thank you.

    Second, is it possible for you to put up a screencast on research paper management based on this post? I would love to manage research papers in emacs, especially via org-mode with the help of bibtex. However, the setup seems rather complicated and it is hard to visualize the workflow. I’m sure there are added benefits, but it’d be great to see it on video before others like myself invest the time to set it up. Hope you have time for it.

    • Haha, I did have a hard time writing that workflow section. A screencast would certainly be clearer–I will have to start working on one. In the very least I may at least post some screenshots.

      Glad I could help out :]

      • Please post your screencast or screenshots once you have it up. I’m holding out on implementing it until I see it as I’m a little confused. Thanks!

    • Screencast up and running ;]

      I’m sure my emacs/org-mode inexperience will show in this video, but hopefully it does get the idea across :]

  2. Totti permalink

    Nice workflow. I was thinking about something like this for a while. At the moment I use Jabref, which isn’t bad but I would prefer something within emacs. A few more questions before I start to break my workflow.
    Is there a way to export all references of a single manuscript into an individual file? The aux-file of Bibtex should provide the list of used bibtex keys. I don’t want to send my large bibtex file to publishers at the final end. I would prefer just to send the necessary subset.
    Did I understood correctly.that all additional inflation like own notes, comments, ratings or whatever are not part of the bibtex entry but part of org mode? Since this would allow to keep official and private infos seperated. Don’t want to sent my own notes around if I have to send the bib file. This is the main disadvantage in jabref which saves everything as bibtex entries.

    • Thanks :]

      That’s a good question, but I have no idea :P I’ve never used AucTex before, but I imagine it might be possible. I do know you can have more than one bibtex file for RefTex to parse; so, instead of having one giant bibtex file, you could have several small ones and list them all in the org-mode file for RefTex to use

      And yes, all the notes, comments, tags, etc are all part of the org-mode file, not the bibtex file. The bibtex file only has bibtex entries in it, which RefTex uses kind of like meta-data in this setup. What I like most about this setup is everything is stored on disk as plain-ol-text: easy to inspect, revision control, migrate to other programs, etc…

  3. Totti:

    For your question, “Is there a way to export all references of a single manuscript into an individual file?”

    After you successfully run latex several times to get everything right, you will find in the same folder a “.bbl” file. That file contains all the entries in your manuscript, and you can just attach the content of this bbl file to your main latex file (by replacing the bibtex line).

  4. tincman:

    Thanks for this post.

    I have a short lisp function that do the auto formatting for me, and here is the code:

    ;; Filename: fbib.el
    ;; Author: Da Zhang
    ;; Usage:
    ;; Compile:
    ;; System:
    ;; Bugs:
    ;; Created: Thu Apr 29 23:38:36 2010
    ;; Last-Updated: Fri Oct 15 14:22:05 2010 (-14400 -0400)
    ;; Update #: 40
    ;; Description:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;; -*- Mode: Emacs-Lisp -*- ;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;
    ;;; Code:

    (defun fbib ()
    “Format the bib entry copied from websites, and generate the file name for saving the pdf files systematically.”
    (interactive)
    (goto-char (point-max))
    (re-search-backward “@” nil t)
    (beginning-of-line)
    (setq beg-pos (point))

    ;; remove the original bib entry name
    (re-search-forward “\{” nil t)
    (re-search-forward “,”)
    (backward-char)
    (let ((beg (point)))
    (re-search-backward “\{” nil t)
    (forward-char)
    (delete-region beg (point)))

    ;; search for author name and copy it to bib entry name
    (let ((tmp (point)))
    (re-search-forward “author” nil t)
    (re-search-forward “\{” nil t)
    (let ((start (point)))
    (re-search-forward “\}” nil t)
    (let ((end (point)))
    (if (re-search-in-region “,” start end)
    (backward-word 1)
    (if (re-search-in-region “and” start end)
    (backward-word 2)
    (re-search-forward “\}” nil t)
    (backward-word 1)))))
    ;; (re-search-forward “and” nil t)
    ;; (backward-word 2)
    (let ((beg (point)))
    (forward-word)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “-”))
    ;; search for year and copy it to bib entry name
    (let ((tmp (point)))
    (re-search-forward “year” nil t)
    (re-search-forward “\{” nil t)
    (let ((beg (point)))
    (forward-word)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “-”))

    ;; search for article title and copy it to bib entry name
    (let ((tmp (point)))
    (re-search-forward “title” nil t)
    (re-search-forward “\{” nil t)
    (let ((beg (point)))
    (re-search-forward “\}” nil t)
    (backward-char)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (let ((bib-name-end (point)))
    (replace-in-region ” ” “-” tmp bib-name-end)
    (replace-in-region “:” “-” tmp bib-name-end)
    ))

    ;; optional: search keywords, and kill it
    (goto-char beg-pos)
    (if (re-search-forward “keywords” nil t)
    (progn
    (beginning-of-line)
    (let ((beg (point)))
    (re-search-forward “\},”)
    (forward-char)
    (kill-region beg (point)))))

    ;; optional: search url, and move it to the back of the entry
    (goto-char beg-pos)
    (if (re-search-forward “url” nil t)
    (progn
    (beginning-of-line)
    (kill-line)
    (re-search-forward “^\}” nil t)
    (forward-char)
    (yank)
    (re-search-backward “url” nil t)
    (beginning-of-line)
    (let ((beg (point)))
    (end-of-line)
    (comment-region beg (point)))))

    ;; form the pdf file name and add it to the end of the buffer
    (goto-char (point-max))
    (let ((tmp (point)))
    (goto-char beg-pos)
    (re-search-forward “author” nil t)
    (re-search-forward “\{” nil t)
    (let ((start (point)))
    (re-search-forward “\}” nil t)
    (let ((end (point)))
    (if (re-search-in-region “,” start end)
    (backward-word 1)
    (if (re-search-in-region “and” start end)
    (backward-word 2)
    (re-search-forward “\}” nil t)
    (backward-word 1)))))
    ;; (re-search-forward “and” nil t)
    ;; (backward-word 2)
    (let ((beg (point)))
    (forward-word)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “_”))
    (let ((tmp (point)))
    (re-search-backward “year” nil t)
    (re-search-forward “\{” nil t)
    (let ((beg (point)))
    (forward-word)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “_”))
    (let ((tmp (point)))
    (re-search-backward “title” nil t)
    (re-search-forward “\{” nil t)
    (let ((beg (point)))
    (re-search-forward “\}” nil t)
    (backward-char)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “_”))
    (let ((tmp (point)))
    (re-search-backward “journal” nil t)
    (re-search-forward “\{” nil t)
    (let ((beg (point)))
    (re-search-forward “\}” nil t)
    (backward-char)
    (copy-region-as-kill beg (point)))
    (goto-char tmp)
    (yank)
    (insert “.pdf”))
    (beginning-of-line)
    (let ((pdf-name-beg (point)))
    (end-of-line)
    (replace-in-region “:” “_” pdf-name-beg (point)))

    ;; optional: search abstract, and delete it
    (goto-char beg-pos)
    (if (re-search-forward “abstract” nil t)
    (progn
    (beginning-of-line)
    (let ((beg (point)))
    (re-search-forward “\}” nil t)
    (end-of-line)
    (kill-region beg (point)))
    (kill-line)))
    )

    (defun re-search-in-region (pat start end)
    “regexp search forward in region specified by start and end.”
    (save-restriction
    (narrow-to-region start end)
    (goto-char (point-min))
    (re-search-forward pat nil t)))

    (defun replace-in-region (from-string to-string start end)
    “Replace from-string with to-string in region specified by start and end.”
    (save-restriction
    (narrow-to-region start end)
    (goto-char (point-min))
    (while (search-forward from-string nil t) (replace-match to-string nil t))
    )
    )

    (provide ‘fbib)
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; fbib.el ends here

  5. rbenit68 permalink

    I would like to see a “reduced” version of notes.org file, particularly the :PROPERTIES: content of an article

    • Ah yes, an example document would probably have helped me explain it better, I’ll add one as soon as I can, but for now, the :PROPERTIES: section is pretty simple.

      ** Some Paper!
      :PROPERTIES:
      :Custom_ID: Tincman2011
      :END:
      (…and all the notes/links for this paper)

      The custom_id field is a handle for org-mode to link to; this is the best way I could find to make links to entries in my notes.org file. For example, following a link such as [[notes.org::#Tincman2011]] will jump to that heading.

  6. Karl permalink

    Hi!

    I am new to Emacs and org-mode being eager to replace Mendeley with Reftex/org. The method presented here is great! Although I need one additional thing you might be able to help me: I need the Created property in a newly created entry.

    So basically I do think I need to extend the line …

    (?h . “* %l – %t\n:PROPERTIES:\n:Created: %U\n:Custom_ID: %l\n:END:\n[[papers:%l][%l-pdf]] [[bib:%l][%l-bib]]”)

    (hopefully this line gets quoted correctly)

    … with a timestamp. My test with the %U did not do anything at all at my side. Is there someone being able to help here?

    Thanks!

    • Karl permalink

      I found the solution to the problem mentioned by me:

      ;; ######################################################
      ;; org-mode and paper references

      (defadvice reftex-format-citation (before eval-citation-format)
      (setq format (eval format)))

      (defun org-mode-reftex-setup ()
      (load-library “reftex”)
      (and (buffer-file-name) (file-exists-p (buffer-file-name))
      (progn
      ;enable auto-revert-mode to update reftex when bibtex file changes on disk
      (global-auto-revert-mode t)
      (reftex-parse-all)
      ;add a custom reftex cite format to insert links
      (reftex-set-cite-format
      ‘((?b . “[[bib:%l][%l-bib]]”)
      (?n . “[[notes:%l][%l-notes]]”)
      (?p . “[[papers:%l][%l-pdf]]”)
      (?t . “%t”)
      (?h . (concat “* %l – %t\n:PROPERTIES:\n:Created: ”
      “”
      “\n:Custom_ID: %l\n:END:\n[[papers:%l][%l-pdf]] [[bib:%l][%l-bib]]”))
      ))))
      (define-key org-mode-map (kbd “C-c )”) ‘reftex-citation)
      (define-key org-mode-map (kbd “C-c (“) ‘org-mode-reftex-search))

      ;(add-hook ‘org-mode-hook ‘org-mode-reftex-setup)
      (add-hook ‘org-mode-hook
      (lambda ()
      (if (member “CHECK_NEEDED” org-todo-keywords-1)
      (org-mode-reftex-setup))))

      (defun org-mode-reftex-search ()
      ;;jump to the notes for the paper pointed to at from reftex search
      (interactive)
      (org-open-link-from-string (format “[[notes:%s]]” (reftex-citation t))))

      (setq org-link-abbrev-alist
      ‘((“bib” . “~/archive/papers_from_web/references.bib::%s”)
      (“notes” . “~/share/all/org/references.org::#%s”)
      (“papers” . “~/archive/papers_from_web/%s.pdf”)))

      ;; tries to format a new BibTeX entry according to own format
      ;; from: http://www.mfasold.net/blog/2009/02/using-emacs-org-mode-to-draft-papers/
      ;(vk-load-part “format-bib.el”)
      ;; does not work well enough – skipping for now

  7. novoid permalink

    I wonder how the method described on this page here is related to org-bibtex.el … does org-bibtex.el do “more”? Or is the method here better in any kind?

    http://www.google.at/search?q=org-bibtex.el

    • I had heard of org-bibtex, but I have never really looked into it. It does sound like it can most of the same things, but maybe with a different workflow? And perhaps better integration? The only thing I can’t seem to find is the ability to link to PDF’s, but this is easy enough to add in. I’d definitely love to hear from someone about their experiences with it (because of course, a maintained contrib script would be much better than a home-spun solution ;])

  8. Nuno permalink

    Your setup is simply great. It was not easy to understand (I’m an Emacs noob, with no knowledge of Lisp, so I had to read your tutorial a few times and watch your video at low speed to see all the steps involved) but now everything’s working perfectly! Hard to imagine a better way of managing references, really.

    Just one question: when you’re writing an article/thesis/whatever in org-mode, do you add the following block to the head of the org document?

    #+LINK: bib file:~/research/refs.bib::%s
    #+LINK: note file:~/research/org/notes.org::%s

    Thank you so much!

    PS – Couldn’t resist to publicize your blog post: http://tinyurl.com/3zfzynv

    • Thanks man :]

      As for your question, yes those are the links you would use in a separate org-mode file, however I personally added those into my init.el, making them the default, and overriding them in my notes.org.

  9. Looks relatively good. I like that everything is in plain text as isn’t the case with Mendeley. I like the ease of retreiving citations in mendeley too and grabbing papers through our University’s source it. I’ll have to do some investigating to see if I can automate the citation grabbing through another source then I may adopt org-mode.

    Cheers,
    Jeff

    • My fellow grad students have been getting excited over Mendeley, and your comment reminded me of our schools source/portal for fulltext links, I wonder if there is way to automate it there…

  10. olberger permalink

    I think I’ve improved a bit on what you have described by implementing the generation of proper citations in the LaTeX export for links pointing to bib or note refs.

    More details here : http://www-public.it-sudparis.eu/~berger_o/weblog/2012/03/23/how-to-manage-and-export-bibliographic-notesrefs-in-org-mode/

    • That is very clever! One of the weaknesses I’ve been having (and wondering how to improve) is having \cite{Bah2012} in a paper I’m writing and wanting to double check the paper, and then having to use my org-mode-reftex-search function, then ‘C-c o’ the header. The ability to just insert links, and have them exported properly definitely cuts this problem down.

      My drafts just got more readable and usable ;]

  11. Hello! dbkegeg interesting dbkegeg site! I’m really like it! Very, very dbkegeg good!

  12. Olivier Berger permalink

    @tinkman Glad you found it useful :-)

  13. Jirka Musil permalink

    Thanks for the clear instructions. The only paragraph that I had to read 5 times was “Jump to entry …”, but looking at the elisp cleared it up. :) Thank you a million times, I was so excited to press C-c ) and see that it did The Right Thing!

  14. Uwe permalink

    This is really great! Thanks a lot! For getting the BibTex data you should really have a look at zotero (http://www.zotero.org/) a Firefox plugin. It can automatically sync with a bibtex file using this plugin http://rtwilson.com/academic/autozotbib .

    • I’ve avoided zotero for a while due to it being a plugin, but it may be worth reconsidering to autosync

  15. no sleep permalink

    Hi, this seems really nice! But I keep having error with this setting. Could you share your wisdom on this?

    My system is:
    - Linux-mint-13
    - TexLive-2012 from ubuntu backport
    - AucTeX 11.86
    - Emacs24 snapshot from backport

    and I have .emacs (exactly as you specified above and nothing else there) as well as refs.bib and notes.org files.

    When I try to export my org file as pdf by using C-c, C-e, p,, it gives me an error message.
    ——————————————————————————————
    “Exporting to PDF…done, with some errors: [undefined citation]”
    —————————————————————————————-
    and the PDF file has [?] where citation should be.

    I googled this error and found some similar symptom and did what they suggested.
    (http://lists.gnu.org/archive/html/emacs-orgmode/2012-03/msg01205.html)

    (setq org-latex-to-pdf-process ‘(“pdflatex -interaction nonstopmode %b”
    “/usr/bin/bibtex %b”
    “pdflatex -interaction nonstopmode %b”
    “pdflatex -interaction nonstopmode %b”))

    But it did not change anything.

    Could you help me on this? I want to solve this and take some sleep now!!

    best,

    Nick

    • no sleep permalink

      Sorry, forgot to add my org file that I am trying to export. (test.org)
      ——————————————————————————-
      #\bibliography{~/test/refs.bib}

      * Head
      some work \cite{Anybody08}

      \bibliographystyle{plain}
      \bibliography{refs}
      ___________________________________________________

      “C-c, [” works and I am able to insert \cite{Anybody08} as expected. All I can guess is that I am missing something in .emacs file or in test.org file as you see it.

      Thank you very much in advance.

      Nick

      • The fix you found on google should work, I imagine. I have avoided adding that line (as it affects all org-mode pdf exports, and I do quite a few different things with it). I usually just export as latex, then on the command line do:

        pdflatex (bah)
        bibtex (bah)
        pdflatex (bah)
        pdflatex (bah)

        However, the fix you found should have done the above. Perhaps try doing it manually first?

        The next thing I can think of is bibtex/latex are both very picky about file paths. I do no think they understand expansions (such as ~) and I think bibtex on it’s own may not understand relative path names (but I could be wrong on this point). When I had this problem, I just took a sledge hammer to it and started writing the full expanded path, eg. “\bibliography{/home/tincman/research/refs.bib}”

        Hope this helps

        • Nick permalink

          THANK YOU!

          NOW I AM SEEING THE BIBLIOGRAPHY IN MY PDF FILE !!!!!

          Doing it manually in terminal worked because it generated more human readable error messages. I would like to share what I did and learnt so far.

          In the meanwhile, waiting for your reply:
          1) I tried zotero and found it satisfactory in organizing and extracting reference information from a downloaded scientific article file.
          2) Next, I tried zotelo to associate zotero with my emacs. (https://github.com/vitoshka/zotelo). The result was good. I can use reference information stored in zotero from my emacs buffer. This means I can search my “file1.bib” file, which is automatically generated by zotelo and have it put \cite{…} in my org file.
          3) Now I was back with the issue of exporting it to pdf, as I posted above.

          Here is how I followed your first suggestion:
          i) export ztest.org to latex
          => newly generated files:
          ii) pdflatex ztest.tex
          => newly generated files: , , , ,

          (Here, I am omitting the “ztest” in front of each file extension)

          iii-WRONG) bibtex ztest.tex
          => message: “I couldn’t open file name ‘ztest.tex.aux’

          (I searched bibtex option and figured the following out)

          iv-CORRECT) bibtex ztest
          v) pdflatex ztest.tex
          vi) pdflatex ztest.tex

          So, I still do not know what was wrong with my original procedure, using emacs to execute LaTeX and pdfLaTeX (C-c, C-e, l and C-c, C-e, p), as well as BibTeX. (I did not have problem on my Windows 7 pc)

          In following your suggestion of manual compile, I made an initial mistake by giving the wrong argument to bibtex command, but was able to fix it as above.

          I hope this may be some help to other beginners like me and, again I really appreciate your help.

          best,

          Nick

  16. Anonymous permalink

    FWIW, I was told that latexmk makes it easy to run pdflatex the right number of time and simplifies the process…

  17. Mark permalink

    Each entry in the auto-generated bibtex files that Mendeley creates contains a field called “file” that looks like:

    file = {:home/username/path/to/paper name.pdf:pdf}

    Is there an easy way to make the :Custom_ID: property in your customized reftex-set-cite-format pull out the pdf-file name from this field?

    • Mark permalink

      (oops, I guess I didn’t really mean the :Custom_ID: property, but rather the “papers:” link target)

    • If there is I could not find it. I was trying for a long while to use RefTeX to extraxt specific fields from bibtex entries for other uses. Things may have changed in newer version as well. I’ll have to revisit this, perhaps rolling my own solution if possible as well.

  18. Kyle permalink

    Hey, thanks for the post. Sorry to comment on quite an old thread (but since there was an update almost a year later from the original post, it doesn’t feel quite as wrong). I’ve tried to get a similar thing going from a bit of a different angle. It’s not as pure of a solution because it uses python (and the main advantage comes if the area of research is heavily covered by pubmed). Certainly still a lot of things I want to get around to adding, but it’s been working pretty well for me.

    https://gitorious.org/bog

  19. Christof permalink

    Hey also thanks from me for this great post. Since a long time I wanted to employ a system that does what yours does. So far I used jabref to manage my papers but I did not have a convenient system to take notes. My workflow of capturing the bibtex key and the saving the papers was actually the same as yours so that it was easy for me to start using your system without a major struggle. I really like that the notes can be tagged in org-mode, so that it is easy to compile sets of information.

  20. Reblogged this on Duong Bao Duy and commented:
    Research Paper Management with Emacs, org-mode and RefTeX

  21. Chris permalink

    Thanks for this article, I’ve implemented it and it works really well for my purposed. One thing I find myself doing a lot, however, is replacing the default link (referencing a PDF) to a digital object identifier (DOI) link, if one exists for the paper.

    I’ve been thinking about how to incorporate some kind of check for a DOI in the .bib entry, and using that if one exists; but I can’t figure out how I would implement that. Any thoughts? I think it would be a very good addition.

  22. Greetings!

    I’m experiencing a strange issue. I have the setup described in this article and it used to work flawlessly. Now, I believe something possibly changed in reftex. One of the citations I have in my notes.org file has ‘Custom_ID: Contreras2002′. When I do ‘C-c (‘ I can find it on the citations list. Then I press RET and get ‘No match – create this as a new heading? (y or n)’.

    This never happened before. The puzzling part is this: if I go to the entry in the notes.org file and manually change ‘Custom_ID: (Contreras2002)’ — yes, with parentheses–, it works, i.e., ‘C-c (‘ and RET on that citation will jump to the correct notes.org entry.

    Could it be somehow related to this problem?
    http://tex.stackexchange.com/questions/47443/enable-parentheses-bib-entry-with-reftex

    My limited knowledge in Lisp does not allow me to move any further, so any help would be deeply appreciated.

    • To be honest, I haven’t been using org-mode much anymore (or I would have caught this!)

      This is indeed a change that seems to have happened in RefTeX, but not the one you linked. It seems “reftex-citation” now defaults to returning a list, even if it returns one citation. This is why the parenthesis are around the text (lists in lisp are denoted by parenthesis, everything in lisp is a list! ;D)

      To fix this we just need to tell “org-mode-reftex-search” to take the first result “reftex-citation” returns: (reftex-citation t) will become (first (reftex-citation t)). The function as a whole now looks like:

      (defun org-mode-reftex-search ()
      ;;jump to the notes for the paper pointed to at from reftex search
      (interactive)
      (org-open-link-from-string (format “[[notes:%s]]” (first (reftex-citation t “?l”)))))

      Thanks for finding this. To be honest I’ve been using Zotero lately to manage my references (makes it much much easier to scrape papers as you find them), but have been meaning to come back and revisit using emacs/org-mode and fix the problems that kept me using this regularly (I fell pretty far behind in managing my references…). Of course, I still use Org-mode/reftex when authoring ;D nothing beats it.

      Updated the post to reflect this :]

      • Thanks for the help, tincman; it’s now working perfectly again (I only had to replace ‘first’ by ‘car’, no big thing).

        I saw the parentheses and didn’t think the output could be a list, which shows how good (lame!) my command of Lisp is. :D

        Anyway, much appreciated for your help in solving this and looking forward for your comeback with further improvements!

  23. Adrian permalink

    Hi,
    Many thanks for putting this workflow up. However, I’m running into one small problem — the links to the pdf files do not seem to work. That is, I can create a new entry in the org file using C-c ) and that all seems to work beautifully. However, if I later want to open the pdf file associated with that entry, I can place my cursor on the blue link and type C-c C-o and I get the message “No match — create this as a new heading?”. I’ve named the pdf after the citation key in the BibTeX file (e.g. if the paper is by John Doe and published in 2014, my key is doe14 and the file containing the pdf is called doe14.pdf) and I’ve tried variants of this, but nothing seems to work. If I hover my cursor over the link itself, it says LINK: papers:doe14

    So I’m not really sure what’s going on here. I think your approach is a very powerful one and it links the main programs I use all the time. Any light you can cast on this problem would be greatly appreciated.

    Thanks!

    • Hmm, I’m not able to reproduce this, and seems like it should work from what you posted.

      I am running an old version of org-mode (7.8), and perhaps newer versions changed the link definition behavior.

      What version of org-mode are you running? What do you have down for ‘org-link-abbrev-alist’ in your init.el?

Trackbacks & Pingbacks

  1. Tweets that mention Research Paper Management with Emacs, org-mode and RefTeX « Mathletic -- Topsy.com
  2. research paper management or library with emacs
  3. GCC源代码阅读 | EvilCode 邪恶代码
  4. org-mode citation and export to LaTex(PDF) and HTML « Sail Home

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.