Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
add comment

3 Answers

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: /
# --
\frac{$1}{$2}

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
add comment

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.

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
1  
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
add comment

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
add comment

Your Answer

 
discard

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.