+** 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
+
+#+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
+
+#+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 |
+
+