[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] managing articles in my personal library, and their citational m

From: Jorge A. Alfaro Murillo
Subject: Re: [O] managing articles in my personal library, and their citational material, using org mode instead of bibtex
Date: Wed, 20 Nov 2013 19:49:25 -0500

I once tried to do something similar in org mode, at the end I thought I was doing twice the work, so I ended up with just one big .bib file.

I copy the bib info from the website and then I have a function to yank it a little bit cleaner into my bib file, something like this:

  (defun bibtex-yank-citation ()
    "Yanks a citation in a .bib file. Eliminates several fields,
  removes the key for the entry, and changes the abstract field for
  an annote field."
    (goto-char (point-max))
    (let ((position (point)))
      (insert (current-kill 0))
      (goto-char position)
      (re-search-forward "\\(@.+?{\\).+?," nil t)
      (replace-match "\\1," nil nil)
      (goto-char position)
      (while (re-search-forward "%" nil t)
             (replace-match "\\\\%" nil nil))
      (goto-char position)
      (while (re-search-forward "’" nil t)
             (replace-match "'" nil nil))
      (goto-char position)
      (while (re-search-forward "á" nil t)
             (replace-match "{\\\\\'a}" nil nil))
      (goto-char position)
      (while (re-search-forward "é" nil t)
             (replace-match "{\\\\\'e}" nil nil))
      (goto-char position)
      (while (re-search-forward "í" nil t)
             (replace-match "{\\\\\'i}" nil nil))
      (goto-char position)
      (while (re-search-forward "ó" nil t)
             (replace-match "{\\\\\'o}" nil nil))
      (goto-char position)
      (while (re-search-forward "ú" nil t)
             (replace-match "{\\\\\'u}" nil nil))
      (goto-char position)
      (while (re-search-forward "ñ" nil t)
             (replace-match "{\\\\~n}" nil nil))
      (goto-char position)
      (while (re-search-forward "ç" nil t)
             (replace-match "{\\\\c{c}}" nil nil))
      (goto-char position)
      (while (re-search-forward "–" nil t)
             (replace-match "-" nil nil))
      (goto-char position)
      (goto-char position)
      (while (re-search-forward "\\(^[[:space:]]*\\)abstract" nil t)
             (replace-match "annote" nil nil))))

It also removes the key, so that then I just add extra information into the annote field and then I generate the key with C-c C-c (bibtex-clean-entry). You can configure your key type very specifically. See all the variables bibtex-autokey-

That takes care of the new bibtex entry without effort. Now I have

  (defun bibtex-kill-ring-save-key ()
    "Kill-ring-save the bibtex key."
    (let ((position (point)))
      (if (not (eq (point-max) position))
      (search-backward-regexp "^@" nil nil)
      (search-forward "{")
      (copy-region-as-kill (point)
                           (funcall (lambda ()
                                      (search-forward ",")
      (goto-char position)))

To save the key to the kill-ring, and then I save the paper with that filename under a unique folder.

Finally I have a function that opens the respective pdf when the cursor is within one entry. And keys for the functions, bound to Hyper keys:
  (eval-after-load "bibtex" '(progn
                               (define-key bibtex-mode-map
                                 (kbd "H-y") 'bibtex-yank-citation)
                               (define-key bibtex-mode-map
                                 (kbd "H-r") 'bibtex-kill-ring-save-key)
                               (define-key bibtex-mode-map
                                 (kbd "H-o") 'bibtex-open-reference-at-point)))

I even have a similar function that I use globally:
      (defun open-reference-at-point ()
        (er/expand-region 2)
        (let* ((beg (region-beginning))
              (end (region-end))
              (article-name (buffer-substring beg end)))
          (call-process "evince" nil 0 nil
                        (concat "~/documents/references/articles/"

So if I am in LaTeX, it is enough to call open-reference-at-point over the text in \cite{...} and the pdf opens automatically.

As you can see everything just depends on using one folder for all the references, one file for all the bib entries and the same name of the key dot pdf for the pdf name. And you end up with an automatically super good documented bib file. Which is very handy when you call C-c [ in LaTeX (reftex-citation) and just vaguely remember something about what you want to cite. Also if you want to open a certain reference you can search your well documented bib file and open the reference with one key.

One last thing to get navigation a la org mode (C-c C-p and C-c C-n) and folding with TAB in your bib file:

  (defun bibtex-previous-entry ()
    "Go to the previous bibtex entry."
    (search-backward-regexp "^@" nil nil 2)
    (search-forward "{"))
  (defun bibtex-next-entry ()
    "Go to the next bibtex entry."
    (search-forward-regexp "^@")
    (search-forward "{"))

  (add-hook 'bibtex-mode-hook (lambda ()

  (eval-after-load "bibtex" '(progn
                               (define-key bibtex-mode-map
                                 (kbd "<tab>") 'hs-toggle-hiding)
                               (define-key bibtex-mode-map
                                 (kbd "C-c C-p") 'bibtex-previous-entry)
                               (define-key bibtex-mode-map
                                 (kbd "C-c C-n") 'bibtex-next-entry)))

This almost makes you forget that you are actually in a bib file and not an org-mode file.



On 20/11/13 14:37, Eric Schulte wrote:
> Alan L Tyree <address@hidden> writes:
>> On 20/11/13 03:25, Eric Schulte wrote:
>>> Ian Barton <address@hidden> writes:
>>>> On 19/11/13 01:40, Christopher W. Ryan wrote:
>>>>> Not sure "citational" is even a word, but hopefully it conveys my meaning!
>>>>> I've been using LaTeX for academic writing and reading for quite some
>>>>> time, with emacs as my editor. I'm pretty familiar with managing a .bib
>>>>> file containing all the references I've collected, and using it in LaTeX
>>>>> \cite commands.
>>>>> I've come to org-mode more recently. I'm trying to imagine how I might
>>>>> use it to manage my "personal library." I have a directory full of pdf
>>>>> files, each a downloaded article. Some articles I reference in papers I
>>>>> write; others I just read and want to keep.  I also have a .bib file
>>>>> where I put the citational material for all those articles. Whenever I
>>>>> download an article, I add its entry to my .bib file. I tend to manage
>>>>> this with JabRef because it searches Medline so easily, but I also will
>>>>> edit the .bib file directly when necessary.
>>>>> I like the idea of an org file containing the citational information
>>>>> (authors, title, journal, etc)  *plus* links to the pdfs on my hard
>>>>> drive, or on the internet. I could also include my notes about the
>>>>> articles. But what would that org file look like? How do I insert a
>>>>> reference to an article into the org file which contains the article I
>>>>> am writing?
>>>>> I'd be grateful for any explanations, or links to tutorials.
>>>> Can't help with managing the citations in org, as the last time I had
>>>> to do this I was using a card index file:)
>>>> However, to address your other questions one way of doing this would
>>>> be to create an org file with a heading for each article:
>>>> * Article 1.
>>>> Here are some notes.
>>>> * Article 2
>>>> My notes
>>> I've been using such an org file for most of grad school and I couldn't
>>> be happier with the results.  I have a single reading.org file with one
>>> top-level entry for each article I read.  Currently at 533 articles
>>> (many still tagged TODO) and 16,558 lines.
>>> To create each headline, I first copy the bibtex information onto my
>>> clipboard, then I call `org-bibtex-yank' which converts the bibtex
>>> information into a headline with properties. E.g.,
>>>       * Software mutational robustness
>>>         :PROPERTIES:
>>>         :TITLE:    Software mutational robustness
>>>         :BTYPE:    article
>>>         :CUSTOM_ID: schulte2013software
>>>         :YEAR:     2013
>>>         :ISSN:     1389-2576
>>>         :JOURNAL:  Genetic Programming and Evolvable Machines
>>>         :DOI:      10.1007/s10710-013-9195-8
>>>         :URL:      http://dx.doi.org/10.1007/s10710-013-9195-8
>>>         :PUBLISHER: Springer US
>>>         :KEYWORDS: Mutational robustness; Genetic programming; Mutation testing; Proactive diversity; N-version programming; Neutral landscapes
>>>         :AUTHOR:   Schulte, Eric and Fry, ZacharyP. and Fast, Ethan and Weimer, Westley and Forrest, Stephanie
>>>         :PAGES:    1-32
>>>         :LANGUAGE: English
>>>         :END:
>>>       file:papers/10.1007_s10710-013-9195-8.pdf
>>>       The arXiv preprint is up at http://arxiv.org/abs/1204.4224.
>>>       More notes...
>> Is there some easy way to import entire bibtex files in this way?
> org-bibtex-import-from-file
>> I find citations to be frustrating. Is there some way that bibtex (or
>> org files such as the above) can be used to enter citations in an org
>> file so that they are exported correctly by the different exporters?
>> Or is there someplace where all this information is gathered and I
>> just am too blind to see it?
> I don't know, I personally use org-bibtex-export-to-kill-ring to convert
> citations to bibtex individually and manually.
I think I have a terminology problem. What I mean is to enter
something like \cite{mann82} in the text and have it spit out (Mann
1982) in each and every export as well as constructing an entry for
the bibliography.

Of course, the actual form of the output should be configurable to
some extent, but I'd be happy with one form that always comes out the

Is that possible? I'm currently fudging the issue by entering a
Markdown style entry in the text, for example
address@hidden:_legal_aspec_money], exporting to Markdown and then using
Pandoc to get the final result.

Not elegant.


>> Thanks for any help.
>> Alan
>> <SNIP>

Alan L Tyree                    http://www2.austlii.edu.au/~alan
Tel:  04 2748 6206              sip:address@hidden

reply via email to

[Prev in Thread] Current Thread [Next in Thread]