ignore some files
[org-ref.git] / org-ref.org
index 8f5ff7c..bc84328 100644 (file)
-#+TITLE: Org-ref - The best reference handling for org-mode
+#+TITLE: The org-ref manual
 #+AUTHOR: John Kitchin
-#+DATE: April 29, 2014
+#+DATE: 2015-03-15 Sun
+#+OPTIONS: toc:nil ^:{}
+#+LATEX_HEADER: \usepackage{natbib}
+\maketitle
+\tableofcontents
 
-* Introduction
+* Introduction to org-ref
+Org-ref is a library for org-mode cite:Dominik201408 that provides rich support for citations, labels and cross-references in org-mode. org-ref is especially suitable for org-mode documents destined for LaTeX export and scientific publication. It is also extremely useful for research documents and notes.
 
-This document is an experiment at creating a literate program to provide similar features as reftex for org-mode referencing. These features include:
+The basic idea of org-ref is that it defines a set of functional org-mode links for citations, cross-references and labels that export properly to LaTeX, and that provide clickable functionality to the user. org-ref interfaces with helm-bibtex to facilitate citation entry, and can also use reftex.
 
-1. using completion to create links
-2. storing links to places,
-3. Clickable links that do useful things
-4. Exportable links to LaTeX
-5. Utility functions for dealing with bibtex files and org-files
+org-ref provides a fairly large number of utilities for finding bad citations, extracting bibtex entries from citations in an org-file, and functions for interacting with bibtex entries. We find these utilities indispensable in scientific writing.
 
-** Header
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-;;; org-ref.el --- setup bibliography, cite, ref and label org-mode links.
+org-ref is [[id:32B558A3-7B48-4581-982B-082017B0AEE8][customizable]].
 
-;; Copyright(C) 2014 John Kitchin
+org-ref has been in development since sometime in 2013. We have published a lot of scientific articles with it cite:hallenbeck-2013-effec-o2,mehta-2014-ident-poten,xu-2014-relat,xu-2014-probin-cover,miller-2014-simul-temper,curnan-2014-effec-concen,boes-2015-estim-bulk,xu-2015-linear-respon,xu-2015-relat. Be sure to check out the supporting information files for each of these. The org source for the supporting information is usually embedded in the supporting information.
 
-;; Author: John Kitchin <jkitchin@andrew.cmu.edu>
-;; This file is not currently part of GNU Emacs.
+There has been a lot of recent discussion on the org-mode mailing list about a citation syntax for org-mode. It is not clear what the impact of this on org-ref will be. The new syntax will more cleanly support pre/post text, and it will be separate from the links used in org-ref. It is not clear if the new syntax will support all of the citation types, especially those in biblatex, that are supported in org-ref. The new citations are likely to be clickable, and could share functionality with org-ref. The new citation syntax will not cover labels and cross-references though, so these links from org-ref will still exist.
 
-;; This program is free software; you can redistribute it and/or
-;; modify it under the terms of the GNU General Public License as
-;; published by the Free Software Foundation; either version 2, or (at
-;; your option) any later version.
+** Basic usage of org-ref
 
-;; This program is distributed in the hope that it will be useful, but
-;; WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;; General Public License for more details.
+*** Bibliography links
+org-ref provides a bibliography link to specify which bibtex files to use in the document. You should use the filename with extension, and separate filenames by commas. This link is clickable; clicking on a filename will open the file. Also, if your cursor is on a filename, you will see a minibuffer message about whether the file exists or not. On export, the bibliography will appear at the position where the link is defined.
 
-;; You should have received a copy of the GNU General Public License
-;; along with this program ; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-;; Boston, MA 02111-1307, USA.
+There is also a bibliographystyle link that specifies the style. This link does nothing but export to a LaTeX command.
 
-;;; Commentary:
-;;
-;; Lisp code to setup bibliography cite, ref and label org-mode links.
-;; also sets up reftex for org-mode. The links are clickable and do
-;; things that are useful. You should really read org-ref.org for details.
-;;
-;; Package-Requires: ((dash))
-#+END_SRC
-
-** requires
-The only external require is reftex-cite
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(require 'reftex-cite)
-(require 'dash)
-#+END_SRC
+If you use biblatex, then you use an addbibresource link. biblatex support is not very well tested by me, because we do not use it.
 
-** Custom variables
-There are some variables needed later to tell this library where you store your pdf files, where your notes file is, and your default bibliography. This variable is similar to the reftex-default-bibliography. I do not remember why I made it separate.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defgroup org-ref nil
-  "customization group for org-ref")
-
-(defcustom org-ref-bibliography-notes
-  nil
-  "filename to where you will put all your notes about an entry in
-  the default bibliography."
-  :type 'file
-  :group 'org-ref)
-
-(defcustom org-ref-default-bibliography
-  nil
-  "list of bibtex files to search for. You should use full-paths for each file."
-  :type '(repeat :tag "List of bibtex files" file)
-  :group 'org-ref)
-
-(defcustom org-ref-pdf-directory
-  nil
-  "directory where pdfs are stored by key. put a trailing / in"
-  :type 'directory
-  :group 'org-ref)
-
-(defcustom org-ref-default-citation-link
-  "cite"
-  "The default type of citation link to use"
-  :type 'string
-  :group 'org-ref)
-
-(defcustom org-ref-insert-cite-key
-  "C-c ]"
-  "Keyboard shortcut to insert a citation."
-  :type 'string
-  :group 'org-ref)
-
-(defcustom org-ref-bibliography-entry-format
-  '(("article" . "%a, %t, <i>%j</i>, <b>%v(%n)</b>, %p (%y). <a href=\"%U\">link</a>. <a href=\"http://dx.doi.org/%D\">doi</a>.")
-
-    ("book" . "%a, %t, %u (%y).")
-
-    ("proceedings" . "%e, %t in %S, %u (%y).")
-
-    ("inproceedings" . "%a, %t, %p, in %b, edited by %e, %u (%y)"))
-
-  "string to format an entry. Just the reference, no numbering at the beginning, etc... see the `org-ref-reftex-format-citation' docstring for the escape codes."
-  :type 'string
-  :group 'org-ref)
-
-(defcustom org-ref-open-notes-function
-  (lambda ()
-    (org-show-entry)
-    (show-branches)
-    (show-children)
-    (org-cycle '(64))
-    ;;(org-tree-to-indirect-buffer)
-    (outline-previous-visible-heading 1)
-    (recenter-top-bottom 0))
-  "User-defined way to open a notes entry. This is excecuted after the entry is found, with the cursor at the beginning of the headline. The default setting fully expands the notes, and moves the headline to the top of the buffer")
-
-
-(defcustom org-ref-open-pdf-function
-   'org-ref-open-pdf-at-point
-"User-defined function to open a pdf from a link. The function must get the key at point, and derive a path to the pdf file, then open it. The default function is `org-ref-open-pdf-at-point'."
-  :type 'function)
-
-
-(defcustom org-ref-insert-cite-function
-  'org-ref-insert-cite-link
-  "Function to call to insert citation links."
- :type 'function)
-
-
-(defcustom org-ref-cite-onclick-function
-  'org-ref-cite-onclick-minibuffer-menu
-  "Function that runs when you click on a cite link. The function must take no arguments"
- :type 'function)
-#+END_SRC
+*** Citations
+    :PROPERTIES:
+    :CUSTOM_ID: citations
+    :END:
+org-ref uses the [[bibliography link]] to determine which bibtex files to get citations from, and falls back to the bibtex files defined in the variable  reftex-default-bibliography or org-ref-default-bibliography.
 
-This next variable determines the citation types that are available in org-ref. Links for each one are automatically generated, and completion functions are automatically generated. Users may add to this list in their own init files.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defcustom org-ref-cite-types
-  '("cite" "nocite" ;; the default latex cite commands
-    ;; natbib cite commands, http://ctan.unixbrain.com/macros/latex/contrib/natbib/natnotes.pdf
-    "citet" "citet*" "citep" "citep*"
-    "citealt" "citealt*" "citealp" "citealp*"
-    "citenum" "citetext"
-    "citeauthor" "citeauthor*"
-    "citeyear" "citeyear*"
-    "Citet" "Citep" "Citealt" "Citealp" "Citeauthor"
-    ;; biblatex commands
-    ;; http://ctan.mirrorcatalogs.com/macros/latex/contrib/biblatex/doc/biblatex.pdf
-    "Cite"
-    "parencite" "Parencite"
-    "footcite" "footcitetext"
-    "textcite" "Textcite"
-    "smartcite" "Smartcite"
-    "cite*" "parencite*" "supercite"
-    "autocite" "Autocite" "autocite*" "Autocite*"
-    "Citeauthor*"
-    "citetitle" "citetitle*"
-    "citedate" "citedate*"
-    "citeurl"
-    "fullcite" "footfullcite"
-    ;; "volcite" "Volcite" cannot support the syntax
-    "notecite" "Notecite"
-    "pnotecite" "Pnotecite"
-    "fnotecite"
-    ;; multicites. Very limited support for these.
-    "cites" "Cites" "parencites" "Parencites"
-    "footcites" "footcitetexts"
-    "smartcites" "Smartcites" "textcites" "Textcites"
-    "supercites" "autocites" "Autocites"
-    ;; for the bibentry package
-    "bibentry"
-    )
-  "List of citation types known in org-ref"
-  :type '(repeat :tag "List of citation types" string)
-  :group 'org-ref)
-#+END_SRC
+For simple citation needs, org-ref is simple to use. At the point you want to insert a citation, you select the "Org -> org-ref -> Insert citation" menu (or use the key-binding C-c ] by default), select the reference(s) you want in the helm-bibtex buffer and press enter. The citation will be inserted automatically into your org-file. You "select" an entry by using the arrow keys to move up and down to the entry you want. You can narrow the selection by typing a pattern to match, e.g. author name, title words, year, keyword, etc... You can select multiple entries by pressing C-spc to mark enties in the helm-bibtex buffer.
 
-We need a hook variable to store user-defined bibtex entry cleaning functions
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defcustom org-ref-clean-bibtex-entry-hook nil
-  "Hook that is run in org-ref-clean-bibtex-entry. The functions should take no arguments, and operate on the bibtex entry at point."
-  :group 'org-ref
-  :type 'hook)
-#+END_SRC
+If the cursor is on a citation key, you should see a message in the minibuffer that summarizes which citation it refers to. If you click on a key, you should see a helm selection buffer with some actions to choose, including opening the bibtex entry, opening/getting a pdf for the entry, searching the entry in Web of Science, etc...
 
-** Program variables
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defvar org-ref-bibliography-files
-  nil
-  "variable to hold bibliography files to be searched")
-#+END_SRC
-
-** org-mode / reftex setup
-
-We setup reftex here. We use a custom insert cite link function defined here: [[*org-ref-insert-cite-link][org-ref-insert-cite-link]]. We setup reftex to use our org citation format.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(require 'reftex)
-(defun org-mode-reftex-setup ()
-    (and (buffer-file-name)
-         (file-exists-p (buffer-file-name))
-        (global-auto-revert-mode t)
-        ;; I do not remember why I put this next line in. It doesn't
-        ;; work for org-files. Nothing very bad happens, but it gives
-        ;; an annoying error. Commenting it out for now.
-         ;(reftex-parse-all)
-        )
-    (make-local-variable 'reftex-cite-format)
-    (setq reftex-cite-format 'org)
-    (define-key org-mode-map (kbd org-ref-insert-cite-key) org-ref-insert-cite-function))
-
-(add-hook 'org-mode-hook 'org-mode-reftex-setup)
-
-(eval-after-load 'reftex-vars
-  '(progn
-      (add-to-list 'reftex-cite-format-builtin
-                   '(org "Org-mode citation"
-                         ((?\C-m . "cite:%l")     ; default
-                         (?d . ",%l")            ; for appending
-                         (?a . "autocite:%l")
-                         (?t . "citet:%l")
-                         (?T . "citet*:%l")
-                         (?p . "citep:%l")
-                         (?P . "citep*:%l")
-                         (?h . "citeauthor:%l")
-                         (?H . "citeauthor*:%l")
-                         (?y . "citeyear:%l")
-                         (?x . "citetext:%l")
-                         (?n . "nocite:%l")
-                         )))))
-#+END_SRC
-
-You may want to add new formats to the reftex-cite-format-builtin variable. Here is an example of adding two new formats. Note that this does not create the links.
-
-#+BEGIN_SRC emacs-lisp :tangle no
-;; add new format
-(setf (nth 2 (assoc 'org reftex-cite-format-builtin))
-      (append (nth 2 (assoc 'org reftex-cite-format-builtin)) '((?W  . "textcite:%l")
-            (?z  . "newcite:%l"))))
-#+END_SRC
-
-You can define a new citation link like this:
-#+BEGIN_SRC emacs-lisp :tangle no
-(org-ref-define-citation-link "citez" ?z)
-#+END_SRC
+The default citation type is [[id:32B558A3-7B48-4581-982B-082017B0AEE8][customizable]], and set to "cite". If you want another type of citation type, then type C-u before pressing enter in the helm-bibtex selection buffer. You will be prompted for the type of citation you actually want.
 
-* Links
-Most of this library is the creation of functional links to help with references and citations.
-** General utilities
-We need several general utilities for this module. They are organized here. We frequently need to remove white space from the front and back of a string. Here we do that for a string.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-strip-string (string)
-  "strip leading and trailing whitespace from the string"
-  (replace-regexp-in-string
-   (concat search-whitespace-regexp "$" ) ""
-   (replace-regexp-in-string
-    (concat "^" search-whitespace-regexp ) "" string)))
+Here is a list of supported citation types. You can customize this if you want.
+#+BEGIN_SRC emacs-lisp :results code
+org-ref-cite-types
 #+END_SRC
 
-It is helpful to make the previous function operate on a list of strings here.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-split-and-strip-string (string)
-  "split key-string and strip keys. Assumes the key-string is comma delimited"
-  (mapcar 'org-ref-strip-string (split-string string ",")))
-#+END_SRC
-
-** bibliography and bibliographystyle
-*** An html bibliography
-
-Reftex is no longer being developed. I want a url and doi option for formatting, so I am modifying this [[file:emacs-24.3/lisp/textmodes/reftex-cite.el::(defun%20reftex-format-citation%20(entry%20format)][function]] from reftex-cite to provide that. We need to modify the reftex-get-bib-field code a bit to remove enclosing braces and quotes so we can make nice looking links.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-reftex-get-bib-field (field entry &optional format)
-  "similar to reftex-get-bib-field, but removes enclosing braces and quotes"
-  (let ((result))
-    (setq result (reftex-get-bib-field field entry format))
-    (when (and (not (string= result "")) (string= "{" (substring result 0 1)))
-      (setq result (substring result 1 -1)))
-    (when (and (not (string= result "")) (string= "\"" (substring result 0 1)))
-      (setq result (substring result 1 -1)))
-      result))
-
-(defun org-ref-reftex-format-citation (entry format)
-  "return a formatted string for the bibtex entry (from bibtex-parse-entry) according
-to the format argument. The format is a string with these percent escapes.
-
-In the format, the following percent escapes will be expanded.
-
-%l   The BibTeX label of the citation.
-%a   List of author names, see also `reftex-cite-punctuation'.
-%2a  Like %a, but abbreviate more than 2 authors like Jones et al.
-%A   First author name only.
-%e   Works like %a, but on list of editor names. (%2e and %E work a well)
-
-It is also possible to access all other BibTeX database fields:
-%b booktitle     %c chapter        %d edition    %h howpublished
-%i institution   %j journal        %k key        %m month
-%n number        %o organization   %p pages      %P first page
-%r address       %s school         %u publisher  %t title
-%v volume        %y year
-%B booktitle, abbreviated          %T title, abbreviated
-%U url
-%D doi
-%S series
-
-Usually, only %l is needed.  The other stuff is mainly for the echo area
-display, and for (setq reftex-comment-citations t).
-
-%< as a special operator kills punctuation and space around it after the
-string has been formatted.
-
-A pair of square brackets indicates an optional argument, and RefTeX
-will prompt for the values of these arguments.
-
-Beware that all this only works with BibTeX database files.  When
-citations are made from the \bibitems in an explicit thebibliography
-environment, only %l is available."
-  ;; Format a citation from the info in the BibTeX ENTRY
-
-  (unless (stringp format) (setq format "\\cite{%l}"))
-
-  (if (and reftex-comment-citations
-           (string-match "%l" reftex-cite-comment-format))
-      (error "reftex-cite-comment-format contains invalid %%l"))
-
-  (while (string-match
-          "\\(\\`\\|[^%]\\)\\(\\(%\\([0-9]*\\)\\([a-zA-Z]\\)\\)[.,;: ]*\\)"
-          format)
-    (let ((n (string-to-number (match-string 4 format)))
-          (l (string-to-char (match-string 5 format)))
-          rpl b e)
-      (save-match-data
-        (setq rpl
-              (cond
-               ((= l ?l) (concat
-                          (org-ref-reftex-get-bib-field "&key" entry)
-                          (if reftex-comment-citations
-                              reftex-cite-comment-format
-                            "")))
-               ((= l ?a) (reftex-format-names
-                          (reftex-get-bib-names "author" entry)
-                          (or n 2)))
-               ((= l ?A) (car (reftex-get-bib-names "author" entry)))
-               ((= l ?b) (org-ref-reftex-get-bib-field "booktitle" entry "in: %s"))
-               ((= l ?B) (reftex-abbreviate-title
-                          (org-ref-reftex-get-bib-field "booktitle" entry "in: %s")))
-               ((= l ?c) (org-ref-reftex-get-bib-field "chapter" entry))
-               ((= l ?d) (org-ref-reftex-get-bib-field "edition" entry))
-               ((= l ?D) (org-ref-reftex-get-bib-field "doi" entry))
-               ((= l ?e) (reftex-format-names
-                          (reftex-get-bib-names "editor" entry)
-                          (or n 2)))
-               ((= l ?E) (car (reftex-get-bib-names "editor" entry)))
-               ((= l ?h) (org-ref-reftex-get-bib-field "howpublished" entry))
-               ((= l ?i) (org-ref-reftex-get-bib-field "institution" entry))
-               ((= l ?j) (org-ref-reftex-get-bib-field "journal" entry))
-               ((= l ?k) (org-ref-reftex-get-bib-field "key" entry))
-               ((= l ?m) (org-ref-reftex-get-bib-field "month" entry))
-               ((= l ?n) (org-ref-reftex-get-bib-field "number" entry))
-               ((= l ?o) (org-ref-reftex-get-bib-field "organization" entry))
-               ((= l ?p) (org-ref-reftex-get-bib-field "pages" entry))
-               ((= l ?P) (car (split-string
-                               (org-ref-reftex-get-bib-field "pages" entry)
-                               "[- .]+")))
-               ((= l ?s) (org-ref-reftex-get-bib-field "school" entry))
-               ((= l ?S) (org-ref-reftex-get-bib-field "series" entry))
-               ((= l ?u) (org-ref-reftex-get-bib-field "publisher" entry))
-               ((= l ?U) (org-ref-reftex-get-bib-field "url" entry))
-               ((= l ?r) (org-ref-reftex-get-bib-field "address" entry))
-              ;; strip enclosing brackets from title if they are there
-               ((= l ?t) (org-ref-reftex-get-bib-field "title" entry))
-               ((= l ?T) (reftex-abbreviate-title
-                          (org-ref-reftex-get-bib-field "title" entry)))
-               ((= l ?v) (org-ref-reftex-get-bib-field "volume" entry))
-               ((= l ?y) (org-ref-reftex-get-bib-field "year" entry)))))
-
-      (if (string= rpl "")
-          (setq b (match-beginning 2) e (match-end 2))
-        (setq b (match-beginning 3) e (match-end 3)))
-      (setq format (concat (substring format 0 b) rpl (substring format e)))))
-  (while (string-match "%%" format)
-    (setq format (replace-match "%" t t format)))
-  (while (string-match "[ ,.;:]*%<" format)
-    (setq format (replace-match "" t t format)))
-  ;; also replace carriage returns, tabs, and multiple whitespaces
-  (setq format (replace-regexp-in-string "\n\\|\t\\|\s+" " " format))
-  format)
-
-(defun org-ref-get-bibtex-entry-citation (key)
-  "returns a string for the bibliography entry corresponding to key, and formatted according to the type in `org-ref-bibliography-entry-format'"
-
-  (let ((org-ref-bibliography-files (org-ref-find-bibliography))
-       (file) (entry) (bibtex-entry) (entry-type) (format))
-
-    (setq file (catch 'result
-                (loop for file in org-ref-bibliography-files do
-                      (if (org-ref-key-in-file-p key (file-truename file))
-                          (throw 'result file)
-                        (message "%s not found in %s" key (file-truename file))))))
-
-    (with-temp-buffer
-      (insert-file-contents file)
-      (bibtex-search-entry key nil 0)
-      (setq bibtex-entry (bibtex-parse-entry))
-      (setq entry-type (downcase (cdr (assoc "=type=" bibtex-entry))))
-      (setq format (cdr (assoc entry-type org-ref-bibliography-entry-format)))
-      (if format
-         (setq entry  (org-ref-reftex-format-citation bibtex-entry format))
-       (save-restriction
-         (bibtex-narrow-to-entry)
-         (setq entry (buffer-string)))))
-    entry))
-#+END_SRC
-
-#+RESULTS:
-: org-ref-reftex-format-citation
-
-Here is how to use the function. You call it with point in an entry in a bibtex file.
-
-#+BEGIN_SRC emacs-lisp :tangle no
-(let((org-ref-bibliography-entry-format   "%a, %t, <i>%j</i>, <b>%v(%n)</b>, %p (%y). <a href=\"%U\">link</a>. <a href=\"http://dx.doi.org/%D\">doi</a>."))
-  (org-ref-get-bibtex-entry-citation  "armiento-2014-high"))
-#+END_SRC
 #+RESULTS:
-: Armiento, Kozinsky, Hautier, , Fornari \& Ceder, High-throughput screening of perovskite alloys for  piezoelectric performance and thermodynamic  stability, <i>Phys. Rev. B</i>, <b>89()</b>, 134103 (2014). <a href="http://link.aps.org/doi/10.1103/PhysRevB.89.134103">link</a>. <a href="http://dx.doi.org/10.1103/PhysRevB.89.134103">doi</a>.
-
-I am not sure why full author names are not used.
-
-This code provides some functions to generate a simple sorted bibliography in html. First we get all the keys in the buffer.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-keys ()
-  "return a list of unique keys in the buffer."
-  (let ((keys '()))
-    (org-element-map (org-element-parse-buffer) 'link
-      (lambda (link)
-       (let ((plist (nth 1 link)))
-         (when (-contains? org-ref-cite-types (plist-get plist ':type))
-           (dolist
-               (key
-                (org-ref-split-and-strip-string (plist-get plist ':path)))
-             (when (not (-contains? keys key))
-               (setq keys (append keys (list key)))))))))
-    ;; Sort keys alphabetically
-    (setq keys (cl-sort keys 'string-lessp :key 'downcase))
-    keys))
-#+END_SRC
-
-This function gets the html for one entry.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-entry-html (key)
-  "returns an html string for the bibliography entry corresponding to key"
-
-  (format "<li><a id=\"%s\">[%s] %s</a></li>" key key (org-ref-get-bibtex-entry-citation key)))
-#+END_SRC
-
-Now, we map over the whole list of keys, and the whole bibliography, formatted as an unordered list.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-html-bibliography ()
-  "Create an html bibliography when there are keys"
-  (let ((keys (org-ref-get-bibtex-keys)))
-    (when keys
-      (concat "<h1>Bibliography</h1>
-<ul>"
-             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-html x)) keys "\n")
-             "\n</ul>"))))
+#+BEGIN_SRC emacs-lisp
+("cite" "nocite" "citet" "citet*" "citep" "citep*" "citealt" "citealt*" "citealp" "citealp*" "citenum" "citetext" "citeauthor" "citeauthor*" "citeyear" "citeyear*" "Citet" "Citep" "Citealt" "Citealp" "Citeauthor" "Cite" "parencite" "Parencite" "footcite" "footcitetext" "textcite" "Textcite" "smartcite" "Smartcite" "cite*" "parencite*" "supercite" "autocite" "Autocite" "autocite*" "Autocite*" "Citeauthor*" "citetitle" "citetitle*" "citedate" "citedate*" "citeurl" "fullcite" "footfullcite" "notecite" "Notecite" "pnotecite" "Pnotecite" "fnotecite" "cites" "Cites" "parencites" "Parencites" "footcites" "footcitetexts" "smartcites" "Smartcites" "textcites" "Textcites" "supercites" "autocites" "Autocites" "bibentry")
 #+END_SRC
 
-I do not have plans to make a numbered bibliography with numbered citations anytime soon. This will require changing the way the citation links are exported, and keeping track of the numbers.
-
-*** An org bibliography
-You can export an org-file to an org-file or org-buffer (org-org-epxort-as-org). In this case, it would be useful convert the cite links to links to custom_ids, and the bibliography link to a first-level heading Bibliography with org-bibtex like headings for each entry. This code should enable this. Right now, it does not appear to work for org export though.
-
-First, we get the string for a single entry.
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-entry-org (key)
-  "returns an org string for the bibliography entry corresponding to key"
-  (let ((org-ref-bibliography-files (org-ref-find-bibliography))
-       (file) (entry) (bibtex-entry) (entry-type) (format))
-
-    (setq file (catch 'result
-                (loop for file in org-ref-bibliography-files do
-                      (if (org-ref-key-in-file-p key (file-truename file))
-                          (throw 'result file)
-                        (message "%s not found in %s" key (file-truename file))))))
-
-    (with-temp-buffer
-      (insert-file-contents file)
-      (bibtex-search-entry key nil 0)
-      (setq entry (bibtex-parse-entry))
-      (format "** %s - %s
-  :PROPERTIES:
-  %s
-  :END:
-" (org-ref-reftex-get-bib-field "author" entry)
-(org-ref-reftex-get-bib-field "title" entry)
-(concat "   :CUSTOM_ID: " (org-ref-reftex-get-bib-field "=key=" entry) "\n"
-       (mapconcat (lambda (element) (format "   :%s: %s"
-                                            (upcase (car element))
-                                            (cdr element)))
-                  entry
-                  "\n"))))))
-#+END_SRC
+If the cursor is on a citation, or at the end of the citation, and you add another citation, it will be appended to the current citation.
 
-Now, we loop over the keys, and combine all the entries into a bibliography.
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-org-bibliography ()
-  "Create an org bibliography when there are keys"
-  (let ((keys (org-ref-get-bibtex-keys)))
-    (when keys
-      (concat "* Bibliography
-"
-             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-org x)) keys "\n")
-             "\n"))))
-#+END_SRC
+If you want to /replace/ an existing key in a citation, put the cursor on the key, run the insert citation command, and type C-u C-u before pressing enter in the helm-bibtex selection buffer. The key will be replaced. Of course, you can just delete it yourself, and add a new key.
 
-*** An ascii bibliography
+Finally, if you do not like the order of the keys in a citation, you can put your cursor on a key and use shift-arrows (left or right) to move the key around. Alternatively, you can run the command org-ref-sort-citation-link which will sort the keys by year, oldest to newest.
 
-This function gets the html for one entry.
+org-ref has basic support for pre/post text in citations. We have very little need for this in scientific publishing; we write pre text before the citation, and post text after it. However, you can get pre/post text by using a description in a cite link, with pre/post text separated by ::. For example, [[cite:Dominik201408][See page 20::, for example]]. It is a little awkward to see this because you cannot see the key. It is a low priority to find a fix for this, because it is not common in scientific publishing and you can always fall back to the old-fashioned LaTeX: \cite[See page 20][, for example]{Dominik201408}.
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-entry-ascii (key)
-  "returns an ascii string for the bibliography entry corresponding to key"
+You may want to bind a hydra menu to a key-binding or key-chord. For example:
 
-  (format "[%s] %s" key (org-ref-get-bibtex-entry-citation key)))
+#+BEGIN_SRC emacs-lisp
+(key-chord-define-global "kk" 'org-ref-cite-hydra/body)
 #+END_SRC
 
-Now, we map over the whole list of keys, and the whole bibliography, formatted as an unordered list.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-ascii-bibliography ()
-  "Create an html bibliography when there are keys"
-  (let ((keys (org-ref-get-bibtex-keys)))
-    (when keys
-      (concat
-"Bibliography
-=============
-"
-             (mapconcat (lambda (x) (org-ref-get-bibtex-entry-ascii x)) keys "\n")
-             "\n"))))
-#+END_SRC
+This will allow you to quickly press kk while on a cite link to access functions that can act on the link.
 
+*** label links
+LaTeX uses labels to define places you can refer to. These can be labels in the captions of figures and tables, or labels in sections.
 
-*** the links
-We use a link for the bibliography so that we can click on it to open the bibliography file. The link may have more than one bibliography file in it, separated by commas. Clicking opens the file under the cursor. The bibliographies should be full filenames with the bib extension. Clicking on this link makes reftex-default-bibliography local and sets it to the list of files in the link. We need this to use reftex's searching capability.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type "bibliography"
-                  ;; this code is run on clicking. The bibliography
-                  ;; may contain multiple files. this code finds the
-                  ;; one you clicked on and opens it.
-                  (lambda (link-string)
-                      ;; get link-string boundaries
-                      ;; we have to go to the beginning of the line, and then search forward
-
-                    (let* ((bibfile)
-                           ;; object is the link you clicked on
-                           (object (org-element-context))
-
-                           (link-string-beginning)
-                           (link-string-end))
-
-                    (save-excursion
-                      (goto-char (org-element-property :begin object))
-                      (search-forward link-string nil nil 1)
-                      (setq link-string-beginning (match-beginning 0))
-                      (setq link-string-end (match-end 0)))
-
-                      ;; We set the reftex-default-bibliography
-                      ;; here. it should be a local variable only in
-                      ;; the current buffer. We need this for using
-                      ;; reftex to do citations.
-                      (set (make-local-variable 'reftex-default-bibliography)
-                           (split-string (org-element-property :path object) ","))
-
-                      ;; now if we have comma separated bibliographies
-                      ;; we find the one clicked on. we want to
-                      ;; search forward to next comma from point
-                      (save-excursion
-                        (if (search-forward "," link-string-end 1 1)
-                            (setq key-end (- (match-end 0) 1)) ; we found a match
-                          (setq key-end (point)))) ; no comma found so take the point
-                      ;; and backward to previous comma from point
-                      (save-excursion
-                        (if (search-backward "," link-string-beginning 1 1)
-                            (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
-                          (setq key-beginning (point)))) ; no match found
-                      ;; save the key we clicked on.
-                      (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end)))
-                      (find-file bibfile))) ; open file on click
-
-                    ;; formatting code
-                  (lambda (keyword desc format)
-                    (cond
-                     ((eq format 'org) (org-ref-get-org-bibliography))
-                      ((eq format 'ascii) (org-ref-get-ascii-bibliography))
-                     ((eq format 'html) (org-ref-get-html-bibliography))
-                     ((eq format 'latex)
-                      ;; write out the latex bibliography command
-                      (format "\\bibliography{%s}" (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
-                                                                                                     (mapcar 'expand-file-name
-                                                                                                             (split-string keyword ","))
-                                                                                                     ",")))))))
+Or you can put a label link into a caption like this.
+#+caption: Another simple table. label:tab-ydata
+| y |
+| 4 |
+| 5 |
 
-#+END_SRC
+org-ref can help you insert unique labels with the command elisp:org-ref-helm-insert-label-link. This will show you the existing labels, and insert your new label as a link.
 
-Believe it or not, sometimes it makes sense /not/ to include the bibliography in a document (e.g. when you are required to submit references as a separate file). To generate the references,  in another file, you must make a little tex file with these contents, and then compile it.
-
-#+BEGIN_LaTeX
-  \input{project-description.bbl}
-#+END_LaTeX
-
-Here, we make a =nobibliography= link that acts like the bibliography, enables creation of the bbl file, but does not put an actual bibliography in the file.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type "nobibliography"
-                  ;; this code is run on clicking. The bibliography
-                  ;; may contain multiple files. this code finds the
-                  ;; one you clicked on and opens it.
-                  (lambda (link-string)
-                      ;; get link-string boundaries
-                      ;; we have to go to the beginning of the line, and then search forward
-
-                    (let* ((bibfile)
-                           ;; object is the link you clicked on
-                           (object (org-element-context))
-
-                           (link-string-beginning)
-                           (link-string-end))
-
-                    (save-excursion
-                      (goto-char (org-element-property :begin object))
-                      (search-forward link-string nil nil 1)
-                      (setq link-string-beginning (match-beginning 0))
-                      (setq link-string-end (match-end 0)))
-
-                      ;; We set the reftex-default-bibliography
-                      ;; here. it should be a local variable only in
-                      ;; the current buffer. We need this for using
-                      ;; reftex to do citations.
-                      (set (make-local-variable 'reftex-default-bibliography)
-                           (split-string (org-element-property :path object) ","))
-
-                      ;; now if we have comma separated bibliographies
-                      ;; we find the one clicked on. we want to
-                      ;; search forward to next comma from point
-                      (save-excursion
-                        (if (search-forward "," link-string-end 1 1)
-                            (setq key-end (- (match-end 0) 1)) ; we found a match
-                          (setq key-end (point)))) ; no comma found so take the point
-                      ;; and backward to previous comma from point
-                      (save-excursion
-                        (if (search-backward "," link-string-beginning 1 1)
-                            (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
-                          (setq key-beginning (point)))) ; no match found
-                      ;; save the key we clicked on.
-                      (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end)))
-                      (find-file bibfile))) ; open file on click
-
-                    ;; formatting code
-                  (lambda (keyword desc format)
-                    (cond
-                     ((eq format 'org) (org-ref-get-org-bibliography))
-                      ((eq format 'ascii) (org-ref-get-ascii-bibliography))
-                     ((eq format 'html) (org-ref-get-html-bibliography))
-                     ((eq format 'latex)
-                      ;; write out the latex bibliography command
-
-;                     (format "{\\setbox0\\vbox{\\bibliography{%s}}}"
-;                             (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
-;                                                                               (mapcar 'expand-file-name
-;                                                                                       (split-string keyword ","))
-;                                                                               ",")))
-
-                      (format "\\nobibliography{%s}"
-                              (replace-regexp-in-string  "\\.bib" "" (mapconcat 'identity
-                                                                                (mapcar 'expand-file-name
-                                                                                        (split-string keyword ","))
-                                                                                ",")))
-
-                      ))))
-#+END_SRC
+label links are "functional" if you put your cursor on the link, you will get a message in the minibuffer showing you the number of occurrences of that label in the buffer. That number should be one!
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type "printbibliography"
-                  (lambda (arg) (message "Nothing implemented for clicking here."))
-                  (lambda (keyword desc format)
-                    (cond
-                      ((eq format 'org) (org-ref-get-org-bibliography))
-                      ((eq format 'html) (org-ref-get-html-bibliography))
-                     ((eq format 'latex)
-                      ;; write out the biblatex bibliography command
-                      "\\printbibliography"))
-))
-#+END_SRC
+*** ref links
+A ref link refers to a label of some sort. For example, you can refer to a table name, e.g. Table ref:table-1.
 
-We also create a bibliographystyle link. There is nothing to do on clicking here, and we create it for consistency. This sets the style for latex export, so use something appropriate there, e.g. unsrt, plain, plainnat, ...
+#+tblname: table-1
+#+caption: A simple table.
+| x |
+| 1 |
+| 2 |
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type "bibliographystyle"
-                  (lambda (arg) (message "Nothing implemented for clicking here."))
-                  (lambda (keyword desc format)
-                    (cond
-                     ((eq format 'latex)
-                      ;; write out the latex bibliography command
-                      (format "\\bibliographystyle{%s}" keyword)))))
-#+END_SRC
+Or you can refer to an org-mode label as in Table ref:table-3.
 
-*** Completion for bibliography link
-It would be nice
+#+label: table-3
+#+caption: A simple table.
+| x |
+| 1 |
+| 2 |
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-bibliography-complete-link (&optional arg)
- (format "bibliography:%s" (read-file-name "enter file: " nil nil t)))
+You can also refer to an org-ref label link as in Table ref:tab-ydata.
 
-(defun org-ref-insert-bibliography-link ()
-  "insert a bibliography with completion"
-  (interactive)
-  (insert (org-bibliography-complete-link)))
-#+END_SRC
+To help you insert ref links, use the "Org->org-ref->Insert ref" menu, or run the command org-ref-helm-insert-ref-link.
 
-** addbibresource
-This is apparently used for biblatex.
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type "addbibresource"
-                  ;; this code is run on clicking. The addbibresource
-                  ;; may contain multiple files. this code finds the
-                  ;; one you clicked on and opens it.
-                  (lambda (link-string)
-                      ;; get link-string boundaries
-                      ;; we have to go to the beginning of the line, and then search forward
-
-                    (let* ((bibfile)
-                           ;; object is the link you clicked on
-                           (object (org-element-context))
-
-                           (link-string-beginning)
-                           (link-string-end))
-
-                    (save-excursion
-                      (goto-char (org-element-property :begin object))
-                      (search-forward link-string nil nil 1)
-                      (setq link-string-beginning (match-beginning 0))
-                      (setq link-string-end (match-end 0)))
-
-                      ;; We set the reftex-default-addbibresource
-                      ;; here. it should be a local variable only in
-                      ;; the current buffer. We need this for using
-                      ;; reftex to do citations.
-                      (set (make-local-variable 'reftex-default-addbibresource)
-                           (split-string (org-element-property :path object) ","))
-
-                      ;; now if we have comma separated bibliographies
-                      ;; we find the one clicked on. we want to
-                      ;; search forward to next comma from point
-                      (save-excursion
-                        (if (search-forward "," link-string-end 1 1)
-                            (setq key-end (- (match-end 0) 1)) ; we found a match
-                          (setq key-end (point)))) ; no comma found so take the point
-                      ;; and backward to previous comma from point
-                      (save-excursion
-                        (if (search-backward "," link-string-beginning 1 1)
-                            (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
-                          (setq key-beginning (point)))) ; no match found
-                      ;; save the key we clicked on.
-                      (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end)))
-                      (find-file bibfile))) ; open file on click
-
-                    ;; formatting code
-                  (lambda (keyword desc format)
-                    (cond
-                     ((eq format 'html) (format "")); no output for html
-                     ((eq format 'latex)
-                        ;; write out the latex addbibresource command
-                      (format "\\addbibresource{%s}" keyword)))))
-#+END_SRC
+ref links are functional. If you put the cursor on a ref link, you will get a little message in the minibuffer with some context of the corresponding label. If you click on the ref link, the cursor will jump to the label.
 
-** List of Figures
-
-In long documents, a list of figures is not uncommon. Here we create a clickable link that generates a temporary buffer containing a list of figures in the document, and their captions. We make a function that can be called interactively, and define a link type that is rendered in LaTeX to create the list of figures.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-list-of-figures (&optional arg)
-  "Generate buffer with list of figures in them"
-  (interactive)
-  (save-excursion (widen)
-  (let* ((c-b (buffer-name))
-        (counter 0)
-        (list-of-figures
-         (org-element-map (org-element-parse-buffer) 'link
-           (lambda (link)
-             "create a link for to the figure"
-             (when
-                 (and (string= (org-element-property :type link) "file")
-                      (string-match-p
-                       "[^.]*\\.\\(png\\|jpg\\|eps\\|pdf\\)$"
-                       (org-element-property :path link)))
-               (incf counter)
-
-               (let* ((start (org-element-property :begin link))
-                      (parent (car (cdr (org-element-property :parent link))))
-                      (caption (caaar (plist-get parent :caption)))
-                      (name (plist-get parent :name)))
-                 (if caption
-                     (format
-                      "[[elisp:(progn (switch-to-buffer \"%s\")(widen)(goto-char %s))][figure %s: %s]] %s\n"
-                      c-b start counter (or name "") caption)
-                   (format
-                    "[[elisp:(progn (switch-to-buffer \"%s\")(widen)(goto-char %s))][figure %s: %s]]\n"
-                    c-b start counter (or name "")))))))))
-    (switch-to-buffer "*List of Figures*")
-    (setq buffer-read-only nil)
-    (org-mode)
-    (erase-buffer)
-    (insert (mapconcat 'identity list-of-figures ""))
-    (setq buffer-read-only t)
-    (use-local-map (copy-keymap org-mode-map))
-    (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
-
-(org-add-link-type
- "list-of-figures"
- 'org-ref-list-of-figures ; on click
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\listoffigures")))))
-#+END_SRC
+A brief note about references to a section. This only works if you put a label in the org-mode headline. Otherwise, you must use a CUSTOM_ID and a CUSTOM_ID link. For example section [[#citations]] has a CUSTOM_ID of citations. Section ref:sec-misc has a label link in the headline. That works, but is not too pretty.
 
-** List of Tables
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-list-of-tables (&optional arg)
-  "Generate a buffer with a list of tables"
-  (interactive)
-  (save-excursion
-  (widen)
-  (let* ((c-b (buffer-name))
-        (counter 0)
-        (list-of-tables
-         (org-element-map (org-element-parse-buffer 'element) 'table
-           (lambda (table)
-             "create a link for to the table"
-             (incf counter)
-             (let ((start (org-element-property :begin table))
-                   (name  (org-element-property :name table))
-                   (caption (caaar (org-element-property :caption table))))
-               (if caption
-                   (format
-                    "[[elisp:(progn (switch-to-buffer \"%s\")(widen)(goto-char %s))][table %s: %s]] %s\n"
-                    c-b start counter (or name "") caption)
-                 (format
-                  "[[elisp:(progn (switch-to-buffer \"%s\")(widen)(goto-char %s))][table %s: %s]]\n"
-                  c-b start counter (or name ""))))))))
-    (switch-to-buffer "*List of Tables*")
-    (setq buffer-read-only nil)
-    (org-mode)
-    (erase-buffer)
-    (insert (mapconcat 'identity list-of-tables ""))
-    (setq buffer-read-only t)
-    (use-local-map (copy-keymap org-mode-map))
-    (local-set-key "q" #'(lambda () (interactive) (kill-buffer))))))
-
-(org-add-link-type
- "list-of-tables"
- 'org-ref-list-of-tables
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\listoftables")))))
-#+END_SRC
-** label
-
-The label link provides a way to create labels in org-mode. We make it clickable because we want to make sure labels are unique. This code will tell you how many instances of a label are found.  We search for label links, LaTeX labels, and the org-mode format for labels. We probably should search for tblnames too.
-*************** TODO search tblnames, custom_ids and check for case sensitivity
-*************** END
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(org-add-link-type
- "label"
- (lambda (label)
-   "on clicking count the number of label tags used in the buffer. A number greater than one means multiple labels!"
-   (message (format "%s occurences"
-                   (+ (count-matches (format "label:%s\\b[^-:]" label) (point-min) (point-max) t)
-                       ;; for tblname, it is not enough to get word boundary
-                       ;; tab-little and tab-little-2 match then.
-                       (count-matches (format "^#\\+tblname:\\s-*%s\\b[^-:]" label) (point-min) (point-max) t)
-                      (count-matches (format "\\label{%s}\\b" label) (point-min) (point-max) t)
-                       ;; this is the org-format #+label:
-                      (count-matches (format "^#\\+label:\\s-*%s\\b[^-:]" label) (point-min) (point-max) t)))))
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'html) (format "(<label>%s</label>)" path))
-    ((eq format 'latex)
-     (format "\\label{%s}" keyword)))))
-#+END_SRC
+**** Miscellaneous ref links  label:sec-misc
+org-ref also provides a pageref, nameref and eqref link.
 
-We want to store links on labels, so you can put the cursor on the label, press C-c l, and later use C-c C-l to insert a link to the label. We also want to store links to tables with a table name, and for sections with CUSTOM_ID.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-label-store-link ()
-  "store a link to a label. The output will be a ref to that label"
-  ;; First we have to make sure we are on a label link.
-  (let* ((object (org-element-context)))
-    (when (and (equal (org-element-type object) 'link)
-               (equal (org-element-property :type object) "label"))
-      (org-store-link-props
-       :type "ref"
-       :link (concat "ref:" (org-element-property :path object))))
-
-    ;; Store link on table
-    (when (equal (org-element-type object) 'table)
-      (org-store-link-props
-       :type "ref"
-       :link (concat "ref:" (org-element-property :name object))))
-
-;; it turns out this does not work. you can already store a link to a heading with a CUSTOM_ID
-    ;; store link on heading with custom_id
-;    (when (and (equal (org-element-type object) 'headline)
-;             (org-entry-get (point) "CUSTOM_ID"))
-;      (org-store-link-props
-;       :type "ref"
-;       :link (concat "ref:" (org-entry-get (point) "CUSTOM_ID"))))
-
-    ;; and to #+label: lines
-    (when (and (equal (org-element-type object) 'paragraph)
-              (org-element-property :name object))
-      (org-store-link-props
-       :type "ref"
-       :link (concat "ref:" (org-element-property :name object))))
-))
-
-(add-hook 'org-store-link-functions 'org-label-store-link)
-#+END_SRC
-** ref
-
-The ref link allows you make links to labels. Clicking on the link takes you to the label, and provides a mark to go back to.
-
-At the moment, ref links are not usable for section links. You need [[#CUSTOM_ID]] type links.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(org-add-link-type
- "ref"
- (lambda (label)
-   "on clicking goto the label. Navigate back with C-c &"
-   (org-mark-ring-push)
-   ;; next search from beginning of the buffer
-
-   ;; it is possible you would not find the label if narrowing is in effect
-   (widen)
-
-   (unless
-       (or
-       ;; our label links
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "label:%s\\b" label) nil t))
-
-       ;; a latex label
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "\\label{%s}" label) nil t))
-
-       ;; #+label: name  org-definition
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "^#\\+label:\\s-*\\(%s\\)\\b" label) nil t))
-
-       ;; org tblname
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "^#\\+tblname:\\s-*\\(%s\\)\\b" label) nil t))
-
-;; Commented out because these ref links do not actually translate correctly in LaTeX.
-;; you need [[#label]] links.
-       ;; CUSTOM_ID
-;      (progn
-;        (goto-char (point-min))
-;        (re-search-forward (format ":CUSTOM_ID:\s-*\\(%s\\)" label) nil t))
-       )
-     ;; we did not find anything, so go back to where we came
-     (org-mark-ring-goto)
-     (error "%s not found" label))
-   (org-show-entry)
-   (message "go back with (org-mark-ring-goto) `C-c &`"))
- ;formatting
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'html) (format "(<ref>%s</ref>)" path))
-    ((eq format 'latex)
-     (format "\\ref{%s}" keyword)))))
-#+END_SRC
+Note for eqref, you must use a LaTeX label like this:
 
-It would be nice to use completion to enter a ref link, where a list of labels is provided. The following code searches the buffer for org and latex labels, custom_ids, and table names as potential items to make a ref link to.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-org-labels ()
- "find #+LABEL: labels"
-  (save-excursion
-    (goto-char (point-min))
-    (let ((matches '()))
-      (while (re-search-forward "^#\\+label:\\s-+\\(.*\\)\\b" (point-max) t)
-       (add-to-list 'matches (match-string-no-properties 1) t))
-matches)))
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-custom-ids ()
- "return a list of custom_id properties in the buffer"
- (let ((results '()) custom_id)
-   (org-map-entries
-    (lambda ()
-      (let ((custom_id (org-entry-get (point) "CUSTOM_ID")))
-       (when (not (null custom_id))
-         (setq results (append results (list custom_id)))))))
-results))
-#+END_SRC
-
-Here we get a list of the labels defined as raw latex labels, e.g. \label{eqtre}.
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-latex-labels ()
-  (save-excursion
-    (goto-char (point-min))
-    (let ((matches '()))
-      (while (re-search-forward "\\\\label{\\([a-zA-z0-9:-]*\\)}" (point-max) t)
-       (add-to-list 'matches (match-string-no-properties 1) t))
-matches)))
-#+END_SRC
-
-Finally, we get the table names.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-tblnames ()
-  (org-element-map (org-element-parse-buffer 'element) 'table
-    (lambda (table)
-      (org-element-property :name table))))
-#+END_SRC
+\begin{equation}
+e^x = 4 \label{eq:1}
+\end{equation}
 
-Now, we can put all the labels together which will give us a list of candidates.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-get-labels ()
-  "returns a list of labels in the buffer that you can make a ref link to. this is used to auto-complete ref links."
-  (save-excursion
-    (save-restriction
-      (widen)
-      (goto-char (point-min))
-      (let ((matches '()))
-       (while (re-search-forward "label:\\([a-zA-z0-9:-]*\\)" (point-max) t)
-         (add-to-list 'matches (match-string-no-properties 1) t))
-       (append matches (org-ref-get-org-labels) (org-ref-get-latex-labels) (org-ref-get-tblnames) (org-ref-get-custom-ids))))))
-#+END_SRC
+Then you can refer to Eq. eqref:eq:1 in your documents.
 
-Now we create the completion function. This works from the org-machinery, e.g. if you type C-c C-l to insert a link, and use completion by pressing tab.
+** org-ref customization of helm-bibtex
+org-ref adds a few new features to helm-bibtex. First, we add keywords as a searchable field. Second, org-ref modifies the helm-bibtex search buffer to include the keywords. Since keywords now can have a central role in searching, we add some functionality to add keywords from the helm-bibtex buffer as a new action.
 
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-complete-link (&optional arg)
-  "Completion function for ref links"
-  (let ((label))
-    (setq label (completing-read "label: " (org-ref-get-labels)))
-    (format "ref:%s" label)))
-#+END_SRC
+We change the order of the actions in helm-bibtex to suit our work flow, and add some new actions. We define a format function for org-mode that is compatible with the usage defined in section [[#citations]]. Finally, we add some new fallback options for additional scientific search engines.
 
-Alternatively, you may want to just call a function that inserts a link with completion:
+** Some basic org-ref utilities
+The command org-ref does a lot for you automatically. It will check the buffer for errors, e.g. multiply-defined labels, bad citations or ref links, and provide easy access to a few commands through a helm buffer.
 
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-insert-ref-link ()
- (interactive)
- (insert (org-ref-complete-link)))
-#+END_SRC
+org-ref-clean-bibtex-entry will sort the fields of a bibtex entry, clean it, and give it a bibtex key. This function does a lot of cleaning:
 
-** pageref
-
-This refers to the page of a label in LaTeX.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(org-add-link-type
- "pageref"
- (lambda (label)
-   "on clicking goto the label. Navigate back with C-c &"
-   (org-mark-ring-push)
-   ;; next search from beginning of the buffer
-   (widen)
-   (unless
-       (or
-       ;; our label links
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "label:%s\\b" label) nil t))
-
-       ;; a latex label
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "\\label{%s}" label) nil t))
-
-       ;; #+label: name  org-definition
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "^#\\+label:\\s-*\\(%s\\)\\b" label) nil t))
-
-       ;; org tblname
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "^#\\+tblname:\\s-*\\(%s\\)\\b" label) nil t))
-
-;; Commented out because these ref links do not actually translate correctly in LaTeX.
-;; you need [[#label]] links.
-       ;; CUSTOM_ID
-;      (progn
-;        (goto-char (point-min))
-;        (re-search-forward (format ":CUSTOM_ID:\s-*\\(%s\\)" label) nil t))
-       )
-     ;; we did not find anything, so go back to where we came
-     (org-mark-ring-goto)
-     (error "%s not found" label))
-   (message "go back with (org-mark-ring-goto) `C-c &`"))
- ;formatting
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'html) (format "(<pageref>%s</pageref>)" path))
-    ((eq format 'latex)
-     (format "\\pageref{%s}" keyword)))))
-#+END_SRC
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-pageref-complete-link (&optional arg)
-  "Completion function for ref links"
-  (let ((label))
-    (setq label (completing-read "label: " (org-ref-get-labels)))
-    (format "ref:%s" label)))
-#+END_SRC
+1. adds a comma if needed in the first line of the entry
+2. makes sure the doi field is an actual doi, and not a url.
+3. fixes bad year entries
+4. fixes empty pages
+5. Escapes & to \&
+6. generate a key according to your setup
+7. Runs your hook functions
+8. sorts the fields in the entry
+9. checks the buffer for non-ascii characters.
 
-Alternatively, you may want to just call a function that inserts a link with completion:
+This function has a hook org-ref-clean-bibtex-entry-hook, which you can add functions to of your own. Each function must work on a bibtex entry at point.
 
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-pageref-insert-ref-link ()
- (interactive)
- (insert (org-pageref-complete-link)))
-#+END_SRC
-
-** nameref
-
-The nameref link allows you make links to the text of a section with a label. Clicking on the link takes you to the label, and provides a mark to go back to. This only works if you put a raw latex label in the headline.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(org-add-link-type
- "nameref"
- (lambda (label)
-   "on clicking goto the label. Navigate back with C-c &"
-   (org-mark-ring-push)
-   ;; next search from beginning of the buffer
-   (widen)
-   (unless
-       (or
-       ;; a latex label
-       (progn
-         (goto-char (point-min))
-         (re-search-forward (format "\\label{%s}" label) nil t))
-       )
-     ;; we did not find anything, so go back to where we came
-     (org-mark-ring-goto)
-     (error "%s not found" label))
-   (message "go back with (org-mark-ring-goto) `C-c &`"))
- ;formatting
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'html) (format "(<nameref>%s</nameref>)" path))
-    ((eq format 'latex)
-     (format "\\nameref{%s}" keyword)))))
-#+END_SRC
-
-** eqref
-This is just the LaTeX ref for equations. On export, the reference is enclosed in parentheses.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(org-add-link-type
- "eqref"
- (lambda (label)
-   "on clicking goto the label. Navigate back with C-c &"
-   (org-mark-ring-push)
-   ;; next search from beginning of the buffer
-   (widen)
-   (goto-char (point-min))
-   (unless
-       (or
-       ;; search forward for the first match
-       ;; our label links
-       (re-search-forward (format "label:%s" label) nil t)
-       ;; a latex label
-       (re-search-forward (format "\\label{%s}" label) nil t)
-       ;; #+label: name  org-definition
-       (re-search-forward (format "^#\\+label:\\s-*\\(%s\\)\\b" label) nil t))
-     (org-mark-ring-goto)
-     (error "%s not found" label))
-   (message "go back with (org-mark-ring-goto) `C-c &`"))
- ;formatting
- (lambda (keyword desc format)
-   (cond
-    ((eq format 'html) (format "(<eqref>%s</eqref>)" path))
-    ((eq format 'latex)
-     (format "\\eqref{%s}" keyword)))))
-#+END_SRC
-
-** cite
-This is the main reason this library exists. We want the following behavior. A cite link should be able to contain multiple bibtex keys. You should be able to click on the link, and get a brief citation of the entry for that key, and a menu of options to open the bibtex file, open a pdf if you have it, open your notes on the entry, or open a url if it exists. You should be able to insert new references onto an existing cite link, or create new ones easily. The following code implements these features.
-
-*** Implementing the click actions of cite
-
-**** Getting the key we clicked on
-The first thing we need is to get the bibtex key we clicked on.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-get-bibtex-key-under-cursor ()
-  "returns key under the bibtex cursor. We search forward from
-point to get a comma, or the end of the link, and then backwards
-to get a comma, or the beginning of the link. that delimits the
-keyword we clicked on. We also strip the text properties."
-  (interactive)
-  (let* ((object (org-element-context))
-        (link-string (org-element-property :path object)))
-    ;; you may click on the part before the citations. here we make
-    ;; sure to move to the beginning so you get the first citation.
-    (let ((cp (point)))
-      (goto-char (org-element-property :begin object))
-      (search-forward link-string (org-element-property :end object))
-      (goto-char (match-beginning 0))
-      ;; check if we clicked before the path and move as needed.
-      (unless (< cp (point))
-       (goto-char cp)))
-
-    (if (not (org-element-property :contents-begin object))
-       ;; this means no description in the link
-       (progn
-         ;; we need the link path start and end
-         (save-excursion
-           (goto-char (org-element-property :begin object))
-           (search-forward link-string nil nil 1)
-           (setq link-string-beginning (match-beginning 0))
-           (setq link-string-end (match-end 0)))
-
-         ;; The key is the text between commas, or the link boundaries
-         (save-excursion
-           (if (search-forward "," link-string-end t 1)
-               (setq key-end (- (match-end 0) 1)) ; we found a match
-             (setq key-end link-string-end))) ; no comma found so take the end
-         ;; and backward to previous comma from point which defines the start character
-         (save-excursion
-           (if (search-backward "," link-string-beginning 1 1)
-               (setq key-beginning (+ (match-beginning 0) 1)) ; we found a match
-             (setq key-beginning link-string-beginning))) ; no match found
-         ;; save the key we clicked on.
-         (setq bibtex-key (org-ref-strip-string (buffer-substring key-beginning key-end)))
-         (set-text-properties 0 (length bibtex-key) nil bibtex-key)
-         bibtex-key)
-      ;; link with description. assume only one key
-      link-string)))
-#+END_SRC
-
-We also need to find which bibliography file that key is in. For that, we need to know which bibliography files are referred to in the file. If none are specified with a bibliography link, we use the default bibliography. This function searches for a bibliography link, and then the LaTeX bibliography link. We also consider the addbibresource link which is used with biblatex.
-
-**** Getting the bibliographies
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-find-bibliography ()
-  "find the bibliography in the buffer.
-This function sets and returns cite-bibliography-files, which is a list of files
-either from bibliography:f1.bib,f2.bib
-\bibliography{f1,f2}
-internal bibliographies
-
-falling back to what the user has set in org-ref-default-bibliography
-"
-  (interactive)
-  (catch 'result
-    (save-excursion
-      (goto-char (point-min))
-      ;;  look for a bibliography link
-      (when (re-search-forward "\\<bibliography:\\([^\]\|\n]+\\)" nil t)
-       (setq org-ref-bibliography-files
-             (mapcar 'org-ref-strip-string (split-string (match-string 1) ",")))
-       (throw 'result org-ref-bibliography-files))
-
-
-      ;; we did not find a bibliography link. now look for \bibliography
-      (goto-char (point-min))
-      (when (re-search-forward "\\\\bibliography{\\([^}]+\\)}" nil t)
-       ;; split, and add .bib to each file
-       (setq org-ref-bibliography-files
-             (mapcar (lambda (x) (concat x ".bib"))
-                     (mapcar 'org-ref-strip-string
-                             (split-string (match-string 1) ","))))
-       (throw 'result org-ref-bibliography-files))
-
-      ;; no bibliography found. maybe we need a biblatex addbibresource
-      (goto-char (point-min))
-      ;;  look for a bibliography link
-      (when (re-search-forward "addbibresource:\\([^\]\|\n]+\\)" nil t)
-       (setq org-ref-bibliography-files
-             (mapcar 'org-ref-strip-string (split-string (match-string 1) ",")))
-       (throw 'result org-ref-bibliography-files))
-
-      ;; we did not find anything. use defaults
-      (setq org-ref-bibliography-files org-ref-default-bibliography)))
-
-    ;; set reftex-default-bibliography so we can search
-    (set (make-local-variable 'reftex-default-bibliography) org-ref-bibliography-files)
-    org-ref-bibliography-files)
-#+END_SRC
-
-**** Finding the bibliography file a key is in
-Now, we can see if an entry is in a file.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-key-in-file-p (key filename)
-  "determine if the key is in the file"
-  (interactive "skey: \nsFile: ")
-  (save-current-buffer
-    (let ((bibtex-files (list filename)))
-      (bibtex-search-entry key t))))
-#+END_SRC
-
-Finally, we want to know which file the key is in.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-get-bibtex-key-and-file (&optional key)
-  "returns the bibtex key and file that it is in. If no key is provided, get one under point"
- (interactive)
- (let ((org-ref-bibliography-files (org-ref-find-bibliography))
-       (file))
-   (unless key
-     (setq key (org-ref-get-bibtex-key-under-cursor)))
-   (setq file     (catch 'result
-                   (loop for file in org-ref-bibliography-files do
-                         (if (org-ref-key-in-file-p key (file-truename file))
-                             (throw 'result file)))))
-   (cons key file)))
-#+END_SRC
-
-**** convenience functions to act on citation at point
-     :PROPERTIES:
-     :ID:       af0b2a82-a7c9-4c08-9dac-09f93abc4a92
-     :END:
-We need some convenience functions to open act on the citation at point. These will get the pdf, open the url, or open the notes.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-open-pdf-at-point ()
-  "open the pdf for bibtex key under point if it exists"
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-         (pdf-file (format (concat org-ref-pdf-directory "%s.pdf") key)))
-    (if (file-exists-p pdf-file)
-       (org-open-file pdf-file)
-(message "no pdf found for %s" key))))
-
-
-(defun org-ref-open-url-at-point ()
-  "open the url for bibtex key under point."
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-        (bibfile (cdr results)))
-    (save-excursion
-      (with-temp-buffer
-        (insert-file-contents bibfile)
-        (bibtex-search-entry key)
-        ;; I like this better than bibtex-url which does not always find
-        ;; the urls
-        (catch 'done
-          (let ((url (bibtex-autokey-get-field "url")))
-            (when  url
-              (browse-url url)
-              (throw 'done nil)))
-
-          (let ((doi (bibtex-autokey-get-field "doi")))
-            (when doi
-              (if (string-match "^http" doi)
-                  (browse-url doi)
-                (browse-url (format "http://dx.doi.org/%s" doi)))
-              (throw 'done nil))))))))
-
-
-(defun org-ref-open-notes-at-point ()
-  "open the notes for bibtex key under point."
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-        (bibfile (cdr results)))
-    (save-excursion
-      (with-temp-buffer
-        (insert-file-contents bibfile)
-        (bibtex-search-entry key)
-        (org-ref-open-bibtex-notes)))))
-
-
-(defun org-ref-citation-at-point ()
-  "give message of current citation at point"
-  (interactive)
-  (let* ((cb (current-buffer))
-       (results (org-ref-get-bibtex-key-and-file))
-       (key (car results))
-       (bibfile (cdr results)))
-    (message "%s" (progn
-                   (with-temp-buffer
-                      (insert-file-contents bibfile)
-                      (bibtex-search-entry key)
-                      (org-ref-bib-citation))))))
-
-
-(defun org-ref-open-citation-at-point ()
-  "open bibtex file to key at point"
-  (interactive)
-  (let* ((cb (current-buffer))
-       (results (org-ref-get-bibtex-key-and-file))
-       (key (car results))
-       (bibfile (cdr results)))
-    (find-file bibfile)
-    (bibtex-search-entry key)))
-#+END_SRC
-
-**** the actual minibuffer menu
-Now, we create the menu. This is a rewrite of the cite action. This makes the function extendable by users.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defvar org-ref-cite-menu-funcs '()
- "Functions to run on cite click menu. Each entry is a list of (key menu-name function).
-The function must take no arguments and work on the key at point. Do not modify this variable, it is set to empty in the menu click function, and functions are conditionally added to it.")
-
-
-(defvar org-ref-user-cite-menu-funcs
-  '(("C" "rossref" org-ref-crossref-at-point)
-    ("y" "Copy entry to file" org-ref-copy-entry-at-point-to-file)
-    ("s" "Copy summary" org-ref-copy-entry-as-summary))
-  "user-defined functions to run on bibtex key at point.")
-
-
-(defun org-ref-copy-entry-as-summary ()
-  "Copy the bibtex entry for the citation at point as a summary."
-  (interactive)
-    (save-window-excursion
-      (org-ref-open-citation-at-point)
-      (kill-new (org-ref-bib-citation))))
-
-
-(defun org-ref-copy-entry-at-point-to-file ()
-  "Copy the bibtex entry for the citation at point to NEW-FILE.
-Prompt for NEW-FILE includes bib files in org-ref-default-bibliography, and bib files in current working directory. You can also specify a new file."
-  (interactive)
-  (let ((new-file (ido-completing-read
-                  "Copy to bibfile: "
-                  (append org-ref-default-bibliography
-                          (f-entries "." (lambda (f) (f-ext? f "bib"))))))
-       (key (org-ref-get-bibtex-key-under-cursor)))
-    (save-window-excursion
-      (org-ref-open-citation-at-point)
-      (bibtex-copy-entry-as-kill))
-
-    (let ((bibtex-files (list (file-truename new-file))))
-      (if (assoc key (bibtex-global-key-alist))
-         (message "That key already exists in %s" new-file)
-       ;; add to file
-       (save-window-excursion
-         (find-file new-file)
-         (goto-char (point-max))
-          ;; make sure we are at the beginning of a line.
-         (unless (looking-at "^") (insert "\n\n"))
-         (bibtex-yank)
-         (save-buffer))))))
-
-
-(defun org-ref-get-doi-at-point ()
-  "Get doi for key at point."
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-        (bibfile (cdr results))
-         doi)
-    (save-excursion
-      (with-temp-buffer
-        (insert-file-contents bibfile)
-        (bibtex-search-entry key)
-       (setq doi (bibtex-autokey-get-field "doi"))
-       ;; in case doi is a url, remove the url part.
-       (replace-regexp-in-string "^http://dx.doi.org/" "" doi)))))
-
-
-;; functions that operate on key at point for click menu
-(defun org-ref-wos-at-point ()
-  "open the doi in wos for bibtex key under point."
-  (interactive)
-  (doi-utils-wos (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-wos-citing-at-point ()
-  "open the doi in wos citing articles for bibtex key under point."
-  (interactive)
-  (doi-utils-wos-citing (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-wos-related-at-point ()
-  "open the doi in wos related articles for bibtex key under point."
-  (interactive)
-  (doi-utils-wos-related (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-google-scholar-at-point ()
-  "open the doi in google scholar for bibtex key under point."
-  (interactive)
-  (doi-utils-google-scholar (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-pubmed-at-point ()
-  "open the doi in pubmed for bibtex key under point."
-  (interactive)
-  (doi-utils-pubmed (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-crossref-at-point ()
-  "open the doi in crossref for bibtex key under point."
-  (interactive)
-  (doi-utils-crossref (org-ref-get-doi-at-point)))
-
-
-(defun org-ref-cite-onclick-minibuffer-menu (&optional link-string)
-  "action when a cite link is clicked on.
-Provides a menu of context sensitive actions. If the bibtex entry has a pdf, you get an option to open it. If there is a doi, you get a lot of options."
-  (interactive)
-  (let* ((results (org-ref-get-bibtex-key-and-file))
-        (key (car results))
-         (pdf-file (format (concat org-ref-pdf-directory "%s.pdf") key))
-         (bibfile (cdr results))
-        (url (save-excursion
-               (with-temp-buffer
-                 (insert-file-contents bibfile)
-                 (bibtex-search-entry key)
-                 (bibtex-autokey-get-field "url"))))
-        (doi (save-excursion
-               (with-temp-buffer
-                 (insert-file-contents bibfile)
-                 (bibtex-search-entry key)
-                 ;; I like this better than bibtex-url which does not always find
-                 ;; the urls
-                 (bibtex-autokey-get-field "doi")))))
-
-    (when (string= "" doi) (setq doi nil))
-    (when (string= "" url) (setq url nil))
-    (setq org-ref-cite-menu-funcs '())
-
-    ;; open action
-    (when
-       bibfile
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("o" "pen" org-ref-open-citation-at-point)))
-
-    ;; pdf
-    (when (file-exists-p pdf-file)
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       `("p" "df" ,org-ref-open-pdf-function) t))
-
-    ;; notes
-    (add-to-list
-     'org-ref-cite-menu-funcs
-     '("n" "otes" org-ref-open-notes-at-point) t)
-
-    ;; url
-    (when (or url doi)
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("u" "rl" org-ref-open-url-at-point) t))
-
-    ;; doi funcs
-    (when doi
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("w" "os" org-ref-wos-at-point) t)
-
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("c" "iting" org-ref-wos-citing-at-point) t)
-
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("r" "elated" org-ref-wos-related-at-point) t)
-
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("g" "oogle scholar" org-ref-google-scholar-at-point) t)
-
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       '("P" "ubmed" org-ref-pubmed-at-point) t))
-
-    ;; add user functions
-    (dolist (tup org-ref-user-cite-menu-funcs)
-      (add-to-list
-       'org-ref-cite-menu-funcs
-       tup t))
-
-    ;; finally quit
-    (add-to-list
-     'org-ref-cite-menu-funcs
-     '("q" "uit" (lambda ())) t)
-
-    ;; now we make a menu
-    ;; construct menu string as a message
-    (message
-     (concat
-      (let* ((results (org-ref-get-bibtex-key-and-file))
-            (key (car results))
-            (bibfile (cdr results)))
-       (save-excursion
-         (with-temp-buffer
-           (insert-file-contents bibfile)
-           (bibtex-search-entry key)
-           (org-ref-bib-citation))))
-      "\n"
-      (mapconcat
-       (lambda (tup)
-        (concat "[" (elt tup 0) "]"
-                (elt tup 1) " "))
-       org-ref-cite-menu-funcs "")))
-    ;; get the input
-    (let* ((input (read-char-exclusive))
-          (choice (assoc
-                   (char-to-string input) org-ref-cite-menu-funcs)))
-      ;; now run the function (2nd element in choice)
-      (when choice
-       (funcall
-        (elt
-         choice
-         2))))))
+#+BEGIN_SRC emacs-lisp
+(add-hook 'org-ref-clean-bibtex-entry-hook 'jmax-replace-nonascii)
 #+END_SRC
 
 #+RESULTS:
-: org-ref-cite-onclick-minibuffer-menu
+| jmax-title-case-article | jmax-replace-nonascii |
 
-*** A function to format a cite link
+org-ref-extract-bibtex-entries will create a bibtex file from the citations in the current buffer.
 
-Next, we define a formatting function for the cite link. This is done so that the cite link definition is very short, and easy to change. You just need to specify the functions in the definition. This function is deprecated. The formatting is defined later automatically.
-
-#+BEGIN_SRC emacs-lisp  :tangle no
-;(defun org-ref-cite-link-format (keyword desc format)
-;   (cond
-;    ((eq format 'html) (mapconcat (lambda (key) (format "<a name=\"#%s\">%s</a>" key key) (org-ref-split-and-strip-string keyword) ",")))
-;    ((eq format 'latex)
-;     (concat "\\cite" (when desc (format "[%s]" desc)) "{"
-;           (mapconcat (lambda (key) key) (org-ref-split-and-strip-string keyword) ",")
-;           "}"))))
-#+END_SRC
+** LaTeX export
+All org-ref links are designed to export to the corresponding LaTeX commands.
 
-*** The actual cite link
-Finally, we define the cite link. This is deprecated; the links are autogenerated later. This is here for memory.
+** Other exports
+There is some basic support for HTML and ascii export. Not all bibtex entry types are supported, but basic support exists for articles and books.
 
-#+BEGIN_SRC emacs-lisp :tangle no
-;(org-add-link-type
-; "cite"
-; 'org-ref-cite-onclick-minibuffer-menu
-; 'org-ref-cite-link-format)
-#+END_SRC
-
-*** Automatic definition of the cite links
-There are many different kinds of citations in LaTeX, but they are all variants of a basic syntax of \citetype[optional text]{label1,label2}. Here we use lisp to generate the link definitions. We define a function that creates the code to create the link, and then we evaluate it. We also create the completion function for the new link, and add it to the list of known links.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defmacro org-ref-make-completion-function (type)
-  `(defun ,(intern (format "org-%s-complete-link" type)) (&optional arg)
-     (interactive)
-     (format "%s:%s"
-            ,type
-            (completing-read
-             "bibtex key: "
-             (let ((bibtex-files (org-ref-find-bibliography)))
-               (bibtex-global-key-alist))))))
-#+END_SRC
+* Other libraries in org-ref
+These are mostly functions for adding to bibtex files, or for operating on bibtex files.
 
-We will want to generate formatting functions for each citation type. The reason for doing this is so we can on the fly change the formatting later.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defmacro org-ref-make-format-function (type)
-  `(defun ,(intern (format "org-ref-format-%s" type)) (keyword desc format)
-     (cond
-      ((eq format 'org)
-       (mapconcat
-       (lambda (key)
-         (format "[[#%s][%s]]" key key))
-       (org-ref-split-and-strip-string keyword) ","))
-
-      ((eq format 'ascii)
-       (concat "["
-              (mapconcat
-               (lambda (key)
-                 (format "%s" key))
-               (org-ref-split-and-strip-string keyword) ",") "]"))
-
-      ((eq format 'html)
-       (mapconcat
-       (lambda (key)
-         (format "<a href=\"#%s\">%s</a>" key key))
-       (org-ref-split-and-strip-string keyword) ","))
-
-      ((eq format 'latex)
-       (if (string= (substring type -1) "s")
-          ;; biblatex format for multicite commands, which all end in s. These are formated as \cites{key1}{key2}...
-          (concat "\\" ,type (mapconcat (lambda (key) (format "{%s}"  key))
-                                        (org-ref-split-and-strip-string keyword) ""))
-        ;; bibtex format
-       (concat "\\" ,type (when desc (org-ref-format-citation-description desc)) "{"
-              (mapconcat (lambda (key) key) (org-ref-split-and-strip-string keyword) ",")
-              "}"))))))
+** doi-utils
+This library adds two extremely useful tools for getting bibtex entries and pdf files of journal manuscripts. Add this to your emacs setup:
+#+BEGIN_SRC emacs-lisp
+(require 'doi-utils)
 #+END_SRC
 
+The provides two important commands:
 
+- doi-utils-add-bibtex-entry-from-doi
+This will prompt you for a DOI, and a bibtex file, and then try to get the bibtex entry, and pdf of the article.
 
-We create the links by mapping the function onto the list of defined link types.
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-format-citation-description (desc)
-  "return formatted citation description. if the cite link has a description, it is optional text for the citation command. You can specify pre and post text by separating these with ::."
-  (interactive)
-  (cond
-   ((string-match "::" desc)
-    (format "[%s][%s]" (car (setq results (split-string desc "::"))) (cadr results)))
-   (t (format "[%s]" desc))))
+- doi-utils-add-entry-from-crossref-query
+This will prompt you for a query string, which is usually the title of an article, or a free-form text citation of an article. Then you will get a helm buffer of matching items, which you can choose from to insert a new bibtex entry into a bibtex file.
 
-(defun org-ref-define-citation-link (type &optional key)
-  "add a citation link for org-ref. With optional key, set the reftex binding. For example:
-(org-ref-define-citation-link \"citez\" ?z) will create a new citez link, with reftex key of z,
-and the completion function."
-  (interactive "sCitation Type: \ncKey: ")
-
-  ;; create the formatting function
-  (eval `(org-ref-make-format-function ,type))
-
-  (eval-expression
-   `(org-add-link-type
-     ,type
-     org-ref-cite-onclick-function
-     (quote ,(intern (format "org-ref-format-%s" type)))))
-
-  ;; create the completion function
-  (eval `(org-ref-make-completion-function ,type))
-
-  ;; store new type so it works with adding citations, which checks
-  ;; for existence in this list
-  (add-to-list 'org-ref-cite-types type)
-
-  ;; and finally if a key is specified, we modify the reftex menu
-  (when key
-    (setf (nth 2 (assoc 'org reftex-cite-format-builtin))
-         (append (nth 2 (assoc 'org reftex-cite-format-builtin))
-                 `((,key  . ,(concat type ":%l")))))))
-
-;; create all the link types and their completion functions
-(mapcar 'org-ref-define-citation-link org-ref-cite-types)
+** isbn
+#+BEGIN_SRC emacs-lisp
+(require 'isbn)
 #+END_SRC
 
-*** org-ref-insert-cite-link
-We need a convenient method to insert links. In reftex you use the keystroke C-c ], which gives you a minibuffer to search the bibtex files from. This function is bound to that same keystroke here [[*org-mode%20/%20reftex%20setup][org-mode / reftex setup]]. This function will append to a cite link if you call it while on a link.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-insert-cite-link (alternative-cite)
-  "Insert a default citation link using reftex. If you are on a link, it
-appends to the end of the link, otherwise, a new link is
-inserted. Use a prefix arg to get a menu of citation types."
-  (interactive "P")
-  (org-ref-find-bibliography)
-  (let* ((object (org-element-context))
-        (link-string-beginning (org-element-property :begin object))
-        (link-string-end (org-element-property :end object))
-        (path (org-element-property :path object)))
-
-    (if (not alternative-cite)
-
-       (cond
-        ;; case where we are in a link
-        ((and (equal (org-element-type object) 'link)
-              (-contains? org-ref-cite-types (org-element-property :type object)))
-         (goto-char link-string-end)
-         ;; sometimes there are spaces at the end of the link
-         ;; this code moves point pack until no spaces are there
-         (while (looking-back " ") (backward-char))
-         (insert (concat "," (mapconcat 'identity (reftex-citation t ?a) ","))))
-
-        ;; We are next to a link, and we want to append
-        ((save-excursion
-           (backward-char)
-           (and (equal (org-element-type (org-element-context)) 'link)
-                (-contains? org-ref-cite-types (org-element-property :type (org-element-context)))))
-         (while (looking-back " ") (backward-char))
-         (insert (concat "," (mapconcat 'identity (reftex-citation t ?a) ","))))
-
-        ;; insert fresh link
-        (t
-         (insert
-          (concat org-ref-default-citation-link
-                  ":"
-                  (mapconcat 'identity (reftex-citation t) ",")))))
-
-      ;; you pressed a C-u so we run this code
-      (reftex-citation)))
-  )
-#+END_SRC
-cite:zhou-2004-first-lda-u,paier-2006-errat,boes-2015-estim-bulk
+This library provides some functions to get bibtex entries for books from their ISBN.
 
+- isbn-to-bibtex
 
-#+RESULTS:
-: org-ref-insert-cite-link
-
-*** Completion in cite links
-If you know the specific bibtex key, you may like to use completion directly. You use this with the org-mode machinery and tab completion. Here is the prototypical completion function. These are now all created when the links are created.
-
-#+BEGIN_SRC emacs-lisp  :tangle no
-(defun org-cite-complete-link (&optional arg)
-  "Completion function for cite links"
-  (format "%s:%s"
-          org-ref-default-citation-link
-         (completing-read
-          "bibtex key: "
-          (let ((bibtex-files (org-ref-find-bibliography)))
-            (bibtex-global-key-alist)))))
+** pubmed
+#+BEGIN_SRC emacs-lisp
+(require 'pubmed)
 #+END_SRC
 
-Alternatively, you may shortcut the org-machinery with this command. You will be prompted for a citation type, and then offered key completion.
+This library provides a number of new org-mode links to Pubmed entries. See http://www.ncbi.nlm.nih.gov/pmc/about/public-access-info/#p3 for details of these identifiers.
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-insert-cite-with-completion (type)
-  "Insert a cite link with completion"
-  (interactive (list (ido-completing-read "Type: " org-ref-cite-types)))
-  (insert (funcall (intern (format "org-%s-complete-link" type)))))
-#+END_SRC
+pmcid:PMC3498956
 
-** Storing links to a bibtex entry
-org-mode already defines a store link function for bibtex entries. It does not store the link I want though, it only stores a brief citation of the entry. I want a citation link. Here is a function to do that.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-store-bibtex-entry-link ()
-  "Save a citation link to the current bibtex entry. Saves in the default link type."
-  (interactive)
-  (let ((link (concat org-ref-default-citation-link
-                ":"
-                (save-excursion
-                  (bibtex-beginning-of-entry)
-                  (reftex-get-bib-field "=key=" (bibtex-parse-entry))))))
-    (message "saved %s" link)
-    (push (list link) org-stored-links)
-    (car org-stored-links)))
-#+END_SRC
+pmid:23162369
 
-** Index entries
-org-ref minimally supports index entries. To make an index in a file, you should put in the LaTeX header these lines
-
-
-#+LATEX_HEADER: \usepackage{makeidx}
-#+LATEX_HEADER: \makeindex
-
-
-Finally, put \makeindex at the end of the document where you want the index to appear. You will need to run the makeindex program at an appropriate point in your LaTeX to pdf, or use ox-manuscript, which will do it for you.
-
-
-Use index links to create entries (see http://en.wikibooks.org/wiki/LaTeX/Indexing). Clicking on an index link runs occur on the buffer for the entry. The link exports to LaTeX. Some links may need to be enclosed in double brackets if they have spaces in them.
-
-
-index:hello
-index:hello!Peter
-[[index:hello!Sam@\textsl{Sam}]]
-[[index:Lin@\textbf{Lin}]]
-[[index:Joe|textit]]
-[[index:Lin@\textbf{Lin}]]
-[[index:Peter|see {hello}]]
-[[index:Jen|seealso{Jenny}]]
-
-index:encodings!input!cp850
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type
- "index"
- (lambda (path)
-   (occur path))
-
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-      (format "\\index{%s}" path)))))
-
-;; this will generate a temporary index of entries in the file.
-(org-add-link-type
- "printindex"
- (lambda (path)
-   (let ((*index-links* '())
-        (*initial-letters* '()))
-
-     ;; get links
-     (org-element-map (org-element-parse-buffer) 'link
-       (lambda (link)
-        (let ((type (nth 0 link))
-              (plist (nth 1 link)))
-
-          (when (equal (plist-get plist ':type) "index")
-            (add-to-list
-             '*index-links*
-             (cons (plist-get plist :path)
-                   (format
-                    "[[elisp:(progn (switch-to-buffer \"%s\") (goto-char %s))][%s]]"
-(current-buffer)
-                    (plist-get plist :begin)  ;; position of link
-                    ;; grab a description
-                    (save-excursion
-                      (goto-char (plist-get plist :begin))
-                      (if (thing-at-point 'sentence)
-                          ;; get a sentence
-                          (replace-regexp-in-string
-                           "\n" "" (thing-at-point 'sentence))
-                        ;; or call it a link
-                        "link")))))))))
-
-     ;; sort the links
-     (setq *index-links*  (cl-sort *index-links* 'string-lessp :key 'car))
-
-     ;; now first letters
-     (dolist (link *index-links*)
-       (add-to-list '*initial-letters* (substring (car link) 0 1) t))
-
-     ;; now create the index
-     (switch-to-buffer (get-buffer-create "*index*"))
-     (org-mode)
-     (erase-buffer)
-     (insert "#+TITLE: Index\n\n")
-     (dolist (letter *initial-letters*)
-       (insert (format "* %s\n" (upcase letter)))
-       ;; now process the links
-       (while (and
-              ,*index-links*
-              (string= letter (substring (car (car *index-links*)) 0 1)))
-        (let ((link (pop *index-links*)))
-          (insert (format "%s %s\n\n" (car link) (cdr link))))))
-     (switch-to-buffer "*index*")))
- ;; formatting
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-      (format "\\printindex")))))
-#+END_SRC
+nihmsid:NIHMS395714
 
-#+RESULTS:
-| lambda | (path)             | (let ((*index-links* (quote nil)) (*initial-letters* (quote nil))) (org-element-map (org-element-parse-buffer) (quote link) (lambda (link) (let ((type (nth 0 link)) (plist (nth 1 link))) (when (equal (plist-get plist (quote :type)) index) (add-to-list (quote *index-links*) (cons (plist-get plist :path) (format [[elisp:(progn (switch-to-buffer "%s") (goto-char %s))][%s]] (current-buffer) (plist-get plist :begin) (save-excursion (goto-char (plist-get plist :begin)) (if (thing-at-point (quote sentence)) (replace-regexp-in-string \n  (thing-at-point (quote sentence))) link))))))))) (setq *index-links* (cl-sort *index-links* (quote string-lessp) :key (quote car))) (dolist (link *index-links*) (add-to-list (quote *initial-letters*) (substring (car link) 0 1) t)) (switch-to-buffer (get-buffer-create *index*)) (org-mode) (erase-buffer) (insert #+TITLE: Index\n\n) (dolist (letter *initial-letters*) (insert (format * %s\n (upcase letter))) (while (and *index-links* (string= letter (substring (car (car *index-links*)) 0 1))) (let ((link (pop *index-links*))) (insert (format %s %s\n\n (car link) (cdr link)))))) (switch-to-buffer *index*)) |
-| lambda | (path desc format) | (cond ((eq format (quote latex)) (format \printindex)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
-
-** Glossary
-org-ref provides some minimal support for a glossary. See http://en.wikibooks.org/wiki/LaTeX/Glossary for details. You need to put these lines in the header.
-
-#+LATEX_HEADER: \usepackage{glossaries}
-#+LATEX_HEADER: \makeglossaries
-
-And at the end of the document put \makeglossaries.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(org-add-link-type
- "newglossaryentry"
- nil ;; no follow action
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\newglossaryentry{%s}{%s}" path desc)))))
-
-
-;; link to entry
-(org-add-link-type
- "gls"
-  nil ;; no follow action
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\gls{%s}" path)))))
-
-;; plural
-(org-add-link-type
- "glspl"
-  nil ;; no follow action
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\glspl{%s}" path)))))
-
-;; capitalized link
-(org-add-link-type
- "Gls"
-  nil ;; no follow action
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\Gls{%s}" path)))))
-
-;; capitalized link
-(org-add-link-type
- "Glspl"
-  nil ;; no follow action
- (lambda (path desc format)
-   (cond
-    ((eq format 'latex)
-     (format "\\Glspl{%s}" path)))))
-#+END_SRC
+Also, you can retrieve a bibtex entry for a PMID with
 
-#+RESULTS:
-| Glspl             | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Glspl{%s} path))))                                                                                                                                                                                                                                                                                                                     |
-| Gls               | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \Gls{%s} path))))                                                                                                                                                                                                                                                                                                                       |
-| glspl             | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \glspl{%s} path))))                                                                                                                                                                                                                                                                                                                     |
-| gls               | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \gls{%s} path))))                                                                                                                                                                                                                                                                                                                       |
-| newglossaryentry  | nil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | (lambda (path desc format) (cond ((eq format (quote latex)) (format \newglossaryentry{%s}{%s} path desc))))                                                                                                                                                                                                                                                                                                 |
-| google            | (lambda (link-string) (browse-url (format http://www.google.com/search?q=%s (url-hexify-string link-string))))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| ResearcherID      | (lambda (link-string) (browse-url (format http://www.researcherid.com/rid/%s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| orcid             | (lambda (link-string) (browse-url (format http://orcid.org/%s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| message           | org-mac-message-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| mac-outlook       | org-mac-outlook-message-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| skim              | org-mac-skim-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| addressbook       | org-mac-addressbook-item-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| x-together-item   | org-mac-together-item-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| ans               | (lambda (path) (let* ((fields (split-string path ::)) (label (nth 0 fields)) (data (nth 1 fields)) (data-file (format %s-%s.dat tq-userid label))) (let ((temp-file data-file) (temp-buffer (get-buffer-create (generate-new-buffer-name  *temp file*)))) (unwind-protect (prog1 (save-current-buffer (set-buffer temp-buffer) (insert data)) (save-current-buffer (set-buffer temp-buffer) (write-region nil nil temp-file nil 0))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))) (mygit (format git add %s data-file)) (mygit (format git commit -m "%s" data-file)) (mygit git push origin master)))                                                                                                                                                                                              | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| mc                | (lambda (link) (org-entry-put (point) ANSWER link) (save-restriction (save-excursion (org-narrow-to-subtree) (goto-char (point-max)) (if (bolp) nil (insert \n)) (insert (format # you chose %s link)))))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| exercise          | (lambda (arg) (tq-check-internet) (tq-get-assignment arg))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| solution          | (lambda (label) (tq-check-internet) (let ((default-directory (file-name-as-directory (expand-file-name tq-root-directory)))) (if (file-exists-p solutions) nil (make-directory solutions)) (let ((default-directory (file-name-as-directory (expand-file-name solutions)))) (if (file-exists-p label) (progn (find-file (concat label / label .org)) (tq-update)) (mygit (format git clone %s@%s:solutions/%s tq-current-course tq-git-server label)) (find-file (concat label / label .org))))))                                                                                                                                                                                                                                                                                                                  | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| assignment        | (lambda (arg) (tq-check-internet) (tq-get-assignment arg))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| doi               | doi-link-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| bibentry          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-bibentry                                                                                                                                                                                                                                                                                                                                                                                     |
-| Autocites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocites                                                                                                                                                                                                                                                                                                                                                                                    |
-| autocites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocites                                                                                                                                                                                                                                                                                                                                                                                    |
-| supercites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-supercites                                                                                                                                                                                                                                                                                                                                                                                   |
-| Textcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Textcites                                                                                                                                                                                                                                                                                                                                                                                    |
-| textcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-textcites                                                                                                                                                                                                                                                                                                                                                                                    |
-| Smartcites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Smartcites                                                                                                                                                                                                                                                                                                                                                                                   |
-| smartcites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-smartcites                                                                                                                                                                                                                                                                                                                                                                                   |
-| footcitetexts     | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcitetexts                                                                                                                                                                                                                                                                                                                                                                                |
-| footcites         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcites                                                                                                                                                                                                                                                                                                                                                                                    |
-| Parencites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Parencites                                                                                                                                                                                                                                                                                                                                                                                   |
-| parencites        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencites                                                                                                                                                                                                                                                                                                                                                                                   |
-| Cites             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Cites                                                                                                                                                                                                                                                                                                                                                                                        |
-| cites             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cites                                                                                                                                                                                                                                                                                                                                                                                        |
-| fnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-fnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
-| Pnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Pnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
-| pnotecite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-pnotecite                                                                                                                                                                                                                                                                                                                                                                                    |
-| Notecite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Notecite                                                                                                                                                                                                                                                                                                                                                                                     |
-| notecite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-notecite                                                                                                                                                                                                                                                                                                                                                                                     |
-| footfullcite      | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footfullcite                                                                                                                                                                                                                                                                                                                                                                                 |
-| fullcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-fullcite                                                                                                                                                                                                                                                                                                                                                                                     |
-| citeurl           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeurl                                                                                                                                                                                                                                                                                                                                                                                      |
-| citedate*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citedate*                                                                                                                                                                                                                                                                                                                                                                                    |
-| citedate          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citedate                                                                                                                                                                                                                                                                                                                                                                                     |
-| citetitle*        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetitle*                                                                                                                                                                                                                                                                                                                                                                                   |
-| citetitle         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetitle                                                                                                                                                                                                                                                                                                                                                                                    |
-| Citeauthor*       | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citeauthor*                                                                                                                                                                                                                                                                                                                                                                                  |
-| Autocite*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocite*                                                                                                                                                                                                                                                                                                                                                                                    |
-| autocite*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocite*                                                                                                                                                                                                                                                                                                                                                                                    |
-| Autocite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Autocite                                                                                                                                                                                                                                                                                                                                                                                     |
-| autocite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-autocite                                                                                                                                                                                                                                                                                                                                                                                     |
-| supercite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-supercite                                                                                                                                                                                                                                                                                                                                                                                    |
-| parencite*        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencite*                                                                                                                                                                                                                                                                                                                                                                                   |
-| cite*             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cite*                                                                                                                                                                                                                                                                                                                                                                                        |
-| Smartcite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Smartcite                                                                                                                                                                                                                                                                                                                                                                                    |
-| smartcite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-smartcite                                                                                                                                                                                                                                                                                                                                                                                    |
-| Textcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Textcite                                                                                                                                                                                                                                                                                                                                                                                     |
-| textcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-textcite                                                                                                                                                                                                                                                                                                                                                                                     |
-| footcitetext      | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcitetext                                                                                                                                                                                                                                                                                                                                                                                 |
-| footcite          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-footcite                                                                                                                                                                                                                                                                                                                                                                                     |
-| Parencite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Parencite                                                                                                                                                                                                                                                                                                                                                                                    |
-| parencite         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-parencite                                                                                                                                                                                                                                                                                                                                                                                    |
-| Cite              | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Cite                                                                                                                                                                                                                                                                                                                                                                                         |
-| Citeauthor        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citeauthor                                                                                                                                                                                                                                                                                                                                                                                   |
-| Citealp           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citealp                                                                                                                                                                                                                                                                                                                                                                                      |
-| Citealt           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citealt                                                                                                                                                                                                                                                                                                                                                                                      |
-| Citep             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citep                                                                                                                                                                                                                                                                                                                                                                                        |
-| Citet             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-Citet                                                                                                                                                                                                                                                                                                                                                                                        |
-| citeyear*         | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeyear*                                                                                                                                                                                                                                                                                                                                                                                    |
-| citeyear          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeyear                                                                                                                                                                                                                                                                                                                                                                                     |
-| citeauthor*       | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeauthor*                                                                                                                                                                                                                                                                                                                                                                                  |
-| citeauthor        | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citeauthor                                                                                                                                                                                                                                                                                                                                                                                   |
-| citetext          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citetext                                                                                                                                                                                                                                                                                                                                                                                     |
-| citenum           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citenum                                                                                                                                                                                                                                                                                                                                                                                      |
-| citealp*          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealp*                                                                                                                                                                                                                                                                                                                                                                                     |
-| citealp           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealp                                                                                                                                                                                                                                                                                                                                                                                      |
-| citealt*          | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealt*                                                                                                                                                                                                                                                                                                                                                                                     |
-| citealt           | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citealt                                                                                                                                                                                                                                                                                                                                                                                      |
-| citep*            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citep*                                                                                                                                                                                                                                                                                                                                                                                       |
-| citep             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citep                                                                                                                                                                                                                                                                                                                                                                                        |
-| citet*            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citet*                                                                                                                                                                                                                                                                                                                                                                                       |
-| citet             | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-citet                                                                                                                                                                                                                                                                                                                                                                                        |
-| nocite            | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-nocite                                                                                                                                                                                                                                                                                                                                                                                       |
-| cite              | org-ref-cite-onclick-minibuffer-menu                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | org-ref-format-cite                                                                                                                                                                                                                                                                                                                                                                                         |
-| eqref             | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (goto-char (point-min)) (if (or (re-search-forward (format label:%s label) nil t) (re-search-forward (format \label{%s} label) nil t) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                                                                                                                                                                                                 | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<eqref>%s</eqref>) path)) ((eq format (quote latex)) (format \eqref{%s} keyword))))                                                                                                                                                                                                                                                  |
-| nameref           | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<nameref>%s</nameref>) path)) ((eq format (quote latex)) (format \nameref{%s} keyword))))                                                                                                                                                                                                                                            |
-| pageref           | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                                     | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<pageref>%s</pageref>) path)) ((eq format (quote latex)) (format \pageref{%s} keyword))))                                                                                                                                                                                                                                            |
-| ref               | (lambda (label) on clicking goto the label. Navigate back with C-c & (org-mark-ring-push) (widen) (if (or (progn (goto-char (point-min)) (re-search-forward (format label:%s\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format \label{%s} label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+label:\s-*\(%s\)\b label) nil t)) (progn (goto-char (point-min)) (re-search-forward (format ^#\+tblname:\s-*\(%s\)\b label) nil t))) nil (org-mark-ring-goto) (error %s not found label)) (org-show-entry) (message go back with (org-mark-ring-goto) `C-c &`))                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<ref>%s</ref>) path)) ((eq format (quote latex)) (format \ref{%s} keyword))))                                                                                                                                                                                                                                                        |
-| label             | (lambda (label) on clicking count the number of label tags used in the buffer. A number greater than one means multiple labels! (message (format %s occurences (+ (count-matches (format label:%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format ^#\+tblname:\s-*%s\b[^-:] label) (point-min) (point-max) t) (count-matches (format \label{%s}\b label) (point-min) (point-max) t) (count-matches (format ^#\+label:\s-*%s\b[^-:] label) (point-min) (point-max) t)))))                                                                                                                                                                                                                                                                                                                           | (lambda (keyword desc format) (cond ((eq format (quote html)) (format (<label>%s</label>) path)) ((eq format (quote latex)) (format \label{%s} keyword))))                                                                                                                                                                                                                                                  |
-| list-of-tables    | org-ref-list-of-tables                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoftables))))                                                                                                                                                                                                                                                                                                                    |
-| list-of-figures   | org-ref-list-of-figures                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \listoffigures))))                                                                                                                                                                                                                                                                                                                   |
-| addbibresource    | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-addbibresource)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile))) | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \addbibresource{%s} keyword))))                                                                                                                                                                                                                                                                 |
-| bibliographystyle | (lambda (arg) (message Nothing implemented for clicking here.))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote latex)) (format \bibliographystyle{%s} keyword))))                                                                                                                                                                                                                                                                                                   |
-| printbibliography | (lambda (arg) (message Nothing implemented for clicking here.))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) \printbibliography)))                                                                                                                                                                                                    |
-| nobibliography    | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile)))   | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \nobibliography{%s} (replace-regexp-in-string \.bib  (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,)))))) |
-| bibliography      | (lambda (link-string) (let* ((bibfile) (object (org-element-context)) (link-string-beginning) (link-string-end)) (save-excursion (goto-char (org-element-property :begin object)) (search-forward link-string nil nil 1) (setq link-string-beginning (match-beginning 0)) (setq link-string-end (match-end 0))) (set (make-local-variable (quote reftex-default-bibliography)) (split-string (org-element-property :path object) ,)) (save-excursion (if (search-forward , link-string-end 1 1) (setq key-end (- (match-end 0) 1)) (setq key-end (point)))) (save-excursion (if (search-backward , link-string-beginning 1 1) (setq key-beginning (+ (match-beginning 0) 1)) (setq key-beginning (point)))) (setq bibfile (org-ref-strip-string (buffer-substring key-beginning key-end))) (find-file bibfile)))   | (lambda (keyword desc format) (cond ((eq format (quote org)) (org-ref-get-org-bibliography)) ((eq format (quote ascii)) (org-ref-get-ascii-bibliography)) ((eq format (quote html)) (org-ref-get-html-bibliography)) ((eq format (quote latex)) (format \bibliography{%s} (replace-regexp-in-string \.bib  (mapconcat (quote identity) (mapcar (quote expand-file-name) (split-string keyword ,)) ,))))))   |
-| rmail             | org-rmail-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| mhe               | org-mhe-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| irc               | org-irc-visit                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| info              | org-info-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| gnus              | org-gnus-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| docview           | org-docview-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | org-docview-export                                                                                                                                                                                                                                                                                                                                                                                          |
-| bibtex            | org-bibtex-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| bbdb              | org-bbdb-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | org-bbdb-export                                                                                                                                                                                                                                                                                                                                                                                             |
-| pydoc             | (lambda (link-string) (shell-command (format python -m pydoc %s link-string)))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| index             | (lambda (path) (tq-index) (occur path))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| attachfile        | (lambda (link-string) (org-open-file link-string))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | (lambda (keyword desc format) (cond ((eq format (quote html)) (format )) ((eq format (quote latex)) (format \attachfile{%s} keyword))))                                                                                                                                                                                                                                                                     |
-| msx               | org-msx-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| id                | org-id-open                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| file+emacs        | org-open-file-with-emacs                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-| file+sys          | org-open-file-with-system                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | nil                                                                                                                                                                                                                                                                                                                                                                                                         |
-
-
-
-* Utilities
-** create simple text citation from bibtex entry
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-bib-citation ()
-  "From a bibtex entry, create and return a simple citation string.
-This assumes you are in an article."
-
-  (bibtex-beginning-of-entry)
-  (let* ((cb (current-buffer))
-        (bibtex-expand-strings t)
-        (entry (loop for (key . value) in (bibtex-parse-entry t)
-                     collect (cons (downcase key) value)))
-        (title (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "title" entry)))
-        (year  (reftex-get-bib-field "year" entry))
-        (author (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "author" entry)))
-        (key (reftex-get-bib-field "=key=" entry))
-        (journal (reftex-get-bib-field "journal" entry))
-        (volume (reftex-get-bib-field "volume" entry))
-        (pages (reftex-get-bib-field "pages" entry))
-        (doi (reftex-get-bib-field "doi" entry))
-        (url (reftex-get-bib-field "url" entry))
-        )
-    ;;authors, "title", Journal, vol(iss):pages (year).
-    (format "%s, \"%s\", %s, %s:%s (%s)"
-           author title journal  volume pages year)))
-#+END_SRC
+- pubmed-insert-bibtex-from-pmid
 
-#+RESULTS:
-: org-ref-bib-citation
-
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-bib-html-citation ()
-  "from a bibtex entry, create and return a simple citation with html links."
-
-  (bibtex-beginning-of-entry)
-  (let* ((cb (current-buffer))
-        (bibtex-expand-strings t)
-        (entry (loop for (key . value) in (bibtex-parse-entry t)
-                     collect (cons (downcase key) value)))
-        (title (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "title" entry)))
-        (year  (reftex-get-bib-field "year" entry))
-        (author (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "author" entry)))
-        (key (reftex-get-bib-field "=key=" entry))
-        (journal (reftex-get-bib-field "journal" entry))
-        (volume (reftex-get-bib-field "volume" entry))
-        (pages (reftex-get-bib-field "pages" entry))
-        (doi (reftex-get-bib-field "doi" entry))
-        (url (reftex-get-bib-field "url" entry))
-        )
-    ;;authors, "title", Journal, vol(iss):pages (year).
-    (concat (format "%s, \"%s\", %s, %s:%s (%s)."
-                   author title journal  volume pages year)
-           (when url (format " <a href=\"%s\">link</a>" url))
-           (when doi (format " <a href=\"http://dx.doi.org/%s\">doi</a>" doi)))
-    ))
+** arxiv
+#+BEGIN_SRC emacs-lisp
+(require 'arxiv)
 #+END_SRC
 
-** open pdf from bibtex
-We bind this to a key here: [[*key%20bindings%20for%20utilities][key bindings for utilities]].
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-open-bibtex-pdf ()
-  "open pdf for a bibtex entry, if it exists. assumes point is in
-the entry of interest in the bibfile. but does not check that."
-  (interactive)
-  (save-excursion
-    (bibtex-beginning-of-entry)
-    (let* ((bibtex-expand-strings t)
-           (entry (bibtex-parse-entry t))
-           (key (reftex-get-bib-field "=key=" entry))
-           (pdf (format (concat org-ref-pdf-directory "%s.pdf") key)))
-      (message "%s" pdf)
-      (if (file-exists-p pdf)
-          (org-open-link-from-string (format "[[file:%s]]" pdf))
-        (ding)))))
-#+END_SRC
+This library provides an org-mode link to http://arxiv.org entries:  arxiv:cond-mat/0410285, and a function to get a bibtex entry and pdfs for arxiv entries:
+
+- arxiv-add-bibtex-entry
+- arxiv-get-pdf
 
-** open notes from bibtex
-We bind this to a key here [[*key%20bindings%20for%20utilities][key bindings for utilities]].
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-open-bibtex-notes ()
-  "from a bibtex entry, open the notes if they exist, and create a heading if they do not.
-
-I never did figure out how to use reftex to make this happen
-non-interactively. the reftex-format-citation function did not
-work perfectly; there were carriage returns in the strings, and
-it did not put the key where it needed to be. so, below I replace
-the carriage returns and extra spaces with a single space and
-construct the heading by hand."
-  (interactive)
-
-  (bibtex-beginning-of-entry)
-  (let* ((cb (current-buffer))
-        (bibtex-expand-strings t)
-        (entry (loop for (key . value) in (bibtex-parse-entry t)
-                     collect (cons (downcase key) value)))
-        (title (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "title" entry)))
-        (year  (reftex-get-bib-field "year" entry))
-        (author (replace-regexp-in-string "\n\\|\t\\|\s+" " " (reftex-get-bib-field "author" entry)))
-        (key (reftex-get-bib-field "=key=" entry))
-        (journal (reftex-get-bib-field "journal" entry))
-        (volume (reftex-get-bib-field "volume" entry))
-        (pages (reftex-get-bib-field "pages" entry))
-        (doi (reftex-get-bib-field "doi" entry))
-        (url (reftex-get-bib-field "url" entry))
-        )
-
-    ;; save key to clipboard to make saving pdf later easier by pasting.
-    (with-temp-buffer
-      (insert key)
-      (kill-ring-save (point-min) (point-max)))
-
-    ;; now look for entry in the notes file
-    (if  org-ref-bibliography-notes
-       (find-file-other-window org-ref-bibliography-notes)
-      (error "org-ref-bib-bibliography-notes is not set to anything"))
-
-    (goto-char (point-min))
-    ;; put new entry in notes if we don't find it.
-    (if (re-search-forward (format ":Custom_ID: %s$" key) nil 'end)
-       (funcall org-ref-open-notes-function)
-      ;; no entry found, so add one
-      (insert (format "\n** TODO %s - %s" year title))
-      (insert (format"
- :PROPERTIES:
-  :Custom_ID: %s
-  :AUTHOR: %s
-  :JOURNAL: %s
-  :YEAR: %s
-  :VOLUME: %s
-  :PAGES: %s
-  :DOI: %s
-  :URL: %s
- :END:
-[[cite:%s]] [[file:%s/%s.pdf][pdf]]\n\n"
-key author journal year volume pages doi url key org-ref-pdf-directory key))
-(save-buffer))))
+** sci-id
+#+BEGIN_SRC emacs-lisp
+(require 'sci-id)
 #+END_SRC
 
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-open-notes-from-reftex ()
-  "Call reftex, and open notes for selected entry."
-  (interactive)
-  (let ((bibtex-key )))
+This package just defines two new org-mode links for http://www.orcid.org, and http://www.researcherid.com. Here are two examples:
 
-    ;; now look for entry in the notes file
-    (if  org-ref-bibliography-notes
-       (find-file-other-window org-ref-bibliography-notes)
-      (error "org-ref-bib-bibliography-notes is not set to anything"))
+orcid:0000-0003-2625-9232
 
-    (goto-char (point-min))
+researcherid:A-2363-2010
 
-    (re-search-forward (format
-                       ":Custom_ID: %s$"
-                       (first (reftex-citation t)) nil 'end))
-    (funcall org-ref-open-notes-function))
-#+END_SRC
+** jmax-bibtex
+These are functions I use often in bibtex files.
 
-** open url in browser from bibtex
-
-We bind this to a key here [[*key%20bindings%20for%20utilities][key bindings for utilities]].
-
-+ This function may be duplicative of bibtex-url. But I think my function is better unless you do some complicated customization of bibtex-generate-url-list.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-open-in-browser ()
-  "Open the bibtex entry at point in a browser using the url field or doi field"
-(interactive)
-(save-excursion
-  (bibtex-beginning-of-entry)
-  (catch 'done
-    (let ((url (bibtex-autokey-get-field "url")))
-      (when  url
-        (browse-url url)
-        (throw 'done nil)))
-
-    (let ((doi (bibtex-autokey-get-field "doi")))
-      (when doi
-        (if (string-match "^http" doi)
-            (browse-url doi)
-          (browse-url (format "http://dx.doi.org/%s" doi)))
-        (throw 'done nil)))
-    (message "No url or doi found"))))
-#+END_SRC
+*** Generate new bibtex files with adapted journal names
+The variable jmax-bibtex-journal-abbreviations contains a mapping of a short string to a full journal title, and an abbreviated journal title. We can use these to create new versions of a bibtex file with full or abbreviated journal titles. You can add new strings like this:
 
-** citeulike
-   I discovered you could upload a bibtex entry to citeulike using http requests. The upload is actually done by a [[*The%20upload%20script][python script]], because it was easy to write. Here is the emacs command to do this. It is not a fast operation, and  do not use it frequently.
-
-*** function to upload bibtex to citeulike
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-upload-bibtex-entry-to-citeulike ()
-  "with point in  a bibtex entry get bibtex string and submit to citeulike.
-
-Relies on the python script /upload_bibtex_citeulike.py being in the user directory."
-  (interactive)
-  (message "uploading to citeulike")
-  (save-restriction
-    (bibtex-narrow-to-entry)
-    (let ((startpos (point-min))
-          (endpos (point-max))
-          (bibtex-string (buffer-string))
-          (script (concat "python " starter-kit-dir "/upload_bibtex_citeulike.py&")))
-      (with-temp-buffer (insert bibtex-string)
-                        (shell-command-on-region (point-min) (point-max) script t nil nil t)))))
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'jmax-bibtex-journal-abbreviations
+  '("JIR" "Journal of Irreproducible Research" "J. Irrep. Res."))
 #+END_SRC
 
-*** The upload script
-Here is the python script for uploading.
-
-*************** TODO document how to get the cookies
-*************** END
+- jmax-bibtex-generate-longtitles :: Generate a bib file with long titles as
+     defined in `jmax-bibtex-journal-abbreviations'
+- jmax-bibtex-generate-shorttitles :: Generate a bib file with short titles as
+     defined in `jmax-bibtex-journal-abbreviations'
 
+*** Modifying bibtex entries
 
-#+BEGIN_SRC python :tangle upload_bibtex_citeulike.py
-#!python
-import pickle, requests, sys
+- jmax-stringify-journal-name :: replace a journal name with a string in
+     `jmax-bibtex-journal-abbreviations'
+- jmax-set-journal-string :: in a bibtex entry run this to replace the journal
+     with a string selected interactively.
 
-# reload cookies
-with open('c:/Users/jkitchin/Dropbox/blogofile-jkitchin.github.com/_blog/cookies.pckl', 'rb') as f:
-    cookies = pickle.load(f)
+- jmax-title-case-article :: title case the title in an article entry.
+- jmax-sentence-case-article :: sentence case the title in an article entry.
 
-url = 'http://www.citeulike.org/profile/jkitchin/import_do'
+- jmax-replace-nonascii :: replace nonascii characters in a bibtex
+     entry. Replacements are in `jmax-nonascii-latex-replacements'. This
+     function is a hook function in org-ref-clean-bibtex-entry.
 
-bibtex = sys.stdin.read()
+The non-ascii characters are looked up in a list of cons cells. You can add your own non-ascii replacements like this. Note backslashes must be escaped doubly, so one \ is \\\\ in the cons cell.
 
-data = {'pasted':bibtex,
-        'to_read':2,
-        'tag_parsing':'simple',
-        'strip_brackets':'no',
-        'update_id':'bib-key',
-        'btn_bibtex':'Import BibTeX file ...'}
-
-headers = {'content-type': 'multipart/form-data',
-           'User-Agent':'jkitchin/johnrkitchin@gmail.com bibtexupload'}
-
-r = requests.post(url, headers=headers, data=data, cookies=cookies, files={})
-print r
+#+BEGIN_SRC emacs-lisp
+(add-to-list 'jmax-nonascii-latex-replacements
+  '("æ" . "{\\\\ae}"))
 #+END_SRC
 
-** Build a pdf from a bibtex file
-   It is useful to have a pdf version of an entire bibliography to check it for formatting, spelling, or to share it. This function creates a pdf from a bibtex file. I only include the packages  I commonly use in my bitex files.
-
-#+BEGIN_SRC emacs-lisp :tangle org-ref.el
-(defun org-ref-build-full-bibliography ()
-  "build pdf of all bibtex entries, and open it."
-  (interactive)
-  (let* ((bibfile (file-name-nondirectory (buffer-file-name)))
-       (bib-base (file-name-sans-extension bibfile))
-       (texfile (concat bib-base ".tex"))
-       (pdffile (concat bib-base ".pdf")))
-    (find-file texfile)
-    (erase-buffer)
-    (insert (format "\\documentclass[12pt]{article}
-\\usepackage[version=3]{mhchem}
-\\usepackage{url}
-\\usepackage[numbers]{natbib}
-\\usepackage[colorlinks=true, linkcolor=blue, urlcolor=blue, pdfstartview=FitH]{hyperref}
-\\usepackage{doi}
-\\begin{document}
-\\nocite{*}
-\\bibliographystyle{unsrtnat}
-\\bibliography{%s}
-\\end{document}" bib-base))
-    (save-buffer)
-    (shell-command (concat "pdflatex " bib-base))
-    (shell-command (concat "bibtex " bib-base))
-    (shell-command (concat "pdflatex " bib-base))
-    (shell-command (concat "pdflatex " bib-base))
-    (kill-buffer texfile)
-    (org-open-file pdffile)
-    ))
-#+END_SRC
+These functions are compatible with bibtex-map-entries, so it is possible to conveniently apply them to all the entries in a file like this:
 
-** Extract bibtex entries cited in an org-file
-When you use your default bibliography file, and you want to send an org-file to a collaborator, you may need to include bibtex entries so the other person can see them. This function does that and puts the entries in a section at the end of the document that can be tangled to a bib-file.
-
-#+BEGIN_SRC emacs-lisp  :tangle org-ref.el
-(defun org-ref-extract-bibtex-entries ()
-  "extract the bibtex entries referred to by cite links in the current buffer into a src block at the bottom of the current buffer.
-
-If no bibliography is in the buffer the `reftex-default-bibliography' is used."
-  (interactive)
-  (let* ((temporary-file-directory (file-name-directory (buffer-file-name)))
-         (tempname (make-temp-file "extract-bib"))
-         (contents (buffer-string))
-         (cb (current-buffer))
-        basename texfile bibfile results)
-
-    ;; open tempfile and insert org-buffer contents
-    (find-file tempname)
-    (insert contents)
-    (setq basename (file-name-sans-extension
-                   (file-name-nondirectory buffer-file-name))
-         texfile (concat tempname ".tex")
-         bibfile (concat tempname ".bib"))
-
-    ;; see if we have a bibliography, and insert the default one if not.
-