TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

share|improve this answer
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 – Marius Hofert Sep 24 '11 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, – Phil Hirschhorn Sep 24 '11 at 20:22
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). – Ivan Andrus Oct 12 '11 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

share|improve this answer
That's exactly what I use, very useful! – sebastian Nov 22 '12 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.

share|improve this answer
Is that any faster than \frac, though? To me, it seems not to be a shortcut. – dustin Sep 15 '14 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. – Sam Grondahl Sep 16 '14 at 2:35

You can customize LaTeX-math-list. It takes a key and a string or function as well as some menu definitions. Then after pressing a prefix key (defined by LaTeX-math-abbrev-prefix and by defualt "`") and the key you defined it 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 ` f will insert \frac{}{} with the cursor properly positioned. Of course you will no longer be able to insert \phi this way, but you can choose a better key than f.

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.