[Tex/LaTex] emacs auctex: how to get \frac{}{} and \bm{}

auctexemacs

How can I find out (in AUCTeX) if \frac{}{} and \bm{} have predefined keyboard shortcuts?
I couldn't find these two.

Best Answer

I can't find anything like that in the auctex documentation, but if you'd like to have shortcuts for them, add the following lines to your .xemacs/init.el file (if you use xemacs) or your .emacs file (if you use emacs):

(defun insert-frac ()
  "We insert  \\frac{}{} and position point before the first right brace."
  (interactive)
  (progn
    (insert "\\frac{}{}")
    (backward-char)
    (backward-char)
    (backward-char)))
;;--------------------------------------------------------------------
(defun insert-bm ()
  "We insert  \\bm{} and position point before the right brace."
  (interactive)
  (progn
    (insert "\\bm{}")
    (backward-char)))
;--------------------------------------------------------------------
(global-set-key "\C-cf"   'insert-frac)
(global-set-key "\C-cb"   'insert-bm)

You can then insert \frac{}{} and put point inside the first pair of braces by typing Control-c f and you can insert \bm{} and put point inside the braces by typing Control-c b.