Ken Mankoff <mank...@gmail.com> writes:

> Wow. I was going point out that citing for both formats is cumbersome
> and makes the document hard-to-read, but the MACRO solves this. I was
> not aware of MACRO's. I guess this is both the beauty and pain of Org
> and emacs, all this customization. And down the rabbit-hole I go,
> because now I need to redefine my RefTeX shortcut so that it inserts
> {{{cite(key)}}} instead of \cite{key}.

Another possibility is using links as suggested by Tom S. Dye.  These
do not suffer from the newline problem you encountered.  They do not
format nicely, though, if you have complicated cite-constructions.

Here's an example using biblatex syntax in LaTeX and a cite tag in
HTML:

(org-add-link-type
 "textcite" 'ramus/find-lit
 (lambda (path desc format)
   (cond
    ((eq format 'html)
     (format "(<cite>%s</cite>)" path))
    ((eq format 'odt)
     (format "%s" path))
    ((eq format 'latex)
     (if (or (not desc) (equal 0 (search "cite:" desc)))
         (format "\\textcite{%s}" path)
       (format "\\textcite[%s][%s]{%s}"
               (cadr (split-string desc ";"))
               (car (split-string desc ";"))  path))))))

where rasmus/find-lit opens the correct pdf from my local archive, if
possible.

You can add reftex support in a manner similar to the following:

(with-eval-after-load 'org
  (defun org-mode-reftex-setup ()
    ;; (load-library "reftex")
    (require 'reftex)
    (and (buffer-file-name)
         (file-exists-p (buffer-file-name))
         ;; (reftex-parse-all)
         )
    (make-local-variable 'reftex-cite-format)
    (setq reftex-cite-format 'org)
    (define-key org-mode-map (kbd "C-c )") 'reftex-citation))
  (add-hook 'org-mode-hook 'org-mode-reftex-setup))

(with-eval-after-load 'reftex
  (add-to-list 'reftex-cite-format-builtin
               '(org "Org-mode citation"
                     ((?m . "[[cite:%l]]")
                      (?t . "[[textcite:%l]]")
                      (?p . "[[parencite:%l]]")
                      (?s . "[[citepos:%l]]")
                      (?a . "[[citeauthor:%l]]")
                      (?y . "[[citeyear:%l]]")
                      (?l . "%l")))))


–Rasmus                      

-- 
Send from my Emacs


Reply via email to