Rafael <[email protected]> writes:
> I have been writing presentations in org-mode lately with a lot of math
> content. I am using org-cdlatex, and have already customized it to, say,
> type R'B inside math mode to obtain \mathbb{R}. I wonder, however, if it
> would be possible to make this procedure shorter, and obtain \mathbb{R}
> as soon as pressing R, *but only inside math mode*.
>
> I guess I could approximate this with abbrevs or yasnippet, but I think
> this would require an extra key besides the R, which is closer to what I
> already have.
I remembered that Org knows already if point is inside a math
expression, so by looking at the source I came up with the following,
that seems to work. Sorry for the noise.
#+BEGIN_SRC emacs-lisp
(defun org-cdlatex-real-numbers ()
(interactive)
(if (org-inside-LaTeX-fragment-p)
(insert "\\mathbb{R}")
(insert "R")
))
(add-hook 'org-mode-hook
(lambda ()
(local-set-key (kbd "R")
'org-cdlatex-real-numbers
)))
#+END_SRC