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

4 Answers 4


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."
    (insert "\\frac{}{}")
(defun insert-bm ()
  "We insert  \\bm{} and position point before the right brace."
    (insert "\\bm{}")
(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.

  • Dear Phil, thanks. I couldn't find anything in the manual, too. An alternative approach to yours is to define a snippet with yasnippet. Cheers, Marius Commented Sep 24, 2011 at 6:28
  • @Marius: Yes, I've recently heard of yasnippet, and it looks interesting. I've had all sorts of things like this set up for years, though, so I haven't felt pressed to learn a new way. If I were starting now, I might use yasnippet instead. Best regards, Commented Sep 24, 2011 at 20:22
  • 2
    FWIW you can use (backward-char 3), and you probably want (define-key LaTeX-mode-map ...) unless you want the binding in all modes (not just LaTeX). Commented Oct 12, 2011 at 11:47

I suggest a snippet. You need less keys and do not block expensive hotkey sequences. After installing yasnippet create this snippet via menu

# -*- mode: snippet -*-
# name: frac
# key: /
# --

and save it in the snippet folder. The filename is just for your eyes. Now you type / TAB and get \frac{|}{} with cursor at |

You can find my complete configuration on github if you get stuck. emacs-config

  • That's exactly what I use, very useful!
    – sebastian
    Commented Nov 22, 2012 at 13:22

In Auctex, you can just use C-c RET frac RET and it will do just what you requested (with the cursor in the proper place.

  • Is that any faster than \frac, though? To me, it seems not to be a shortcut.
    – dustin
    Commented Sep 15, 2014 at 22:32
  • C-c RET frac RET is seven keystrokes. \frac{}{} C-b C-b C-b is twelve keystrokes. Even if you wait until after typing the numerator to close the first brace and after the denominator to close the second, it is nine keystrokes. So, yes. Commented Sep 16, 2014 at 2:35

You can customize LaTeX-math-list. It takes a key and a string or function as well as some menu definitions. In LaTeX-math-mode (a minor mode), pressing LaTeX-math-abbrev-prefix (default "`") and the key you defined either inserts the string or runs the function. Thus adding (with Phil's definition of insert-frac)

(?f 'insert-frac "frac" "Constructs")

will make it so that `` fwill insert\frac{}{}with the cursor properly positioned. Of course you will no longer be able to insert\phithis way, but you can choose a better key thanf`.

Looking at LaTeX-math-default shows you all the defaults. By default there is an entry for frac, but no key is assigned to it. There is no default for \bm.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .