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.

As pointed out in this answer, using \( and \) in order to enter inline math mode in LaTeX is the recommended practice. However, this takes a bit longer if one compares it to $.

Is there a way to make it quicker when using emacs+auctex? What are you guys doing in order to type it in quicker?

share|improve this question

2 Answers 2

up vote 5 down vote accepted

I use yasnippet. awesome package for inserting snippets. there is latex snippet bundle you can use. Infact there is already a written snippet to insert exactly what you are asking for.

share|improve this answer
    
It looks like the one thing I was after. Does the LaTeX bundle include a snippet for \( \) or did you add one manually? I found only the one for \[ and \]... –  Dror Sep 5 '11 at 5:43
    
Yes, its already included. I type math and hit TAB. thats it. its dead easy to write a new snippet for your needs. –  kindahero Sep 5 '11 at 6:29
    
Thnx! math+TAB generates a \[ \] pair - but I managed to create the snippet I needed! Thnx again. –  Dror Sep 5 '11 at 7:18
    
@kindahero I would use a simpler key, as in shorter, for inline math because it may be used very often. –  N.N. Dec 30 '11 at 13:59
1  
@kindahero Indeed. I just meant that you might use inline math several times per paragraph and then you will be more effective if you use a short key. –  N.N. Dec 30 '11 at 15:30

You can setup a key binding in your .emacs file. This definition is based on the one for TeX-insert-braces (C-c{) from tex.el.

(add-hook 'LaTeX-mode-hook
  '(lambda ()
    (define-key TeX-mode-map "\C-cm" 'TeX-insert-inline-math)
    (defun TeX-insert-inline-math (arg)
      "Like TeX-insert-brackes but for \(...\)" (interactive "P")
      (if (TeX-active-mark)
        (progn
          (if (< (point) (mark)) (exchange-point-and-mark))
          (insert "\\)")
          (save-excursion (goto-char (mark)) (insert "\\(")))
          (insert "\\(")
          (save-excursion
            (if arg (forward-sexp (prefix-numeric-value arg)))
            (insert "\\)"))))))
share|improve this answer

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.