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.

I have started the practice of live-texing my math/physics notes. Although I am not practicising it in a live-lecture, I am doing it for the online lectures I am viewing to get fast and accustomed to it. I am not a pro touch typer, but have a decent speed of about 60 wpm. Some of the tricks I have used are to use lots of \newcommand to ease it down.

Most helpful would be something to substitute equation delimiters that do not involve pressing a dead key. For various reasons (portability to an online CMS) I have begun using \(..\) instead of $..$ the former involves six key strokes and the latter involves three. For the display mode the former style involves four keystrokes while the latter involves five. I would like to accomplish that in a single keystroke. What keyboard shortcuts can I set, or is there something I can do within latex?

Similarly, is it possible to have one keystroke for { ,},_,^ etc?

At present I ignore the delimiters when the lecturer is going really fast, and after the lecture have an extremely buggy and ugly tex file which I have to edit. I would like to have as finished a file as possible. Normal sentences do not pose much of a problem, but the math is slowing me down. I would prefer not to download another keyboard though.

share|improve this question
4  
Good keyboard layouts for typing (La)TeX might be of interest. Andrew Stacey's answer could give you some good ideas. –  Gonzalo Medina Sep 9 '11 at 1:36
1  
I don't know what OS you use, but for windows there is Autohotkey, a program which allows you to map (almost) anything to any key comco you like (e.g. insert \left[ \right] and position the cursur in the middle), you can also assign media keys, all your mouse buttons (assuming you have more than the usual two) and also combos including your mousewheel. –  Tom Bombadil Sep 9 '11 at 1:54
    
@Tom I am using Ubuntu. I will look if there is such an alternative for Authotkey there. –  yayu Sep 9 '11 at 1:56
1  
I would think that most LaTeX IDEs would offer shortcuts to do this. Of course, this usually involves 2 keystrokes minimum per shortcut (like Ctrl+1, or Ctrl+2, ...). –  Werner Sep 9 '11 at 2:12
    
show 1 more comment

3 Answers

up vote 5 down vote accepted

If you're using a good enough editor, you can set up all sorts of things to happen with a single keystroke. For example, I use xemacs, and I have

  • Alt-p (or escape-p) insert a pair of parentheses and put point in between them,
  • alt-m (or escape-m) insert a pair of dollar signs and put point in between them,
  • alt-o (or escape-o) insert a pair of braces and put point in between them,
  • alt-p (or escape-p) insert a pair of parentheses and put point in between them,

plus a few other things. To get out of them, I have alt-j (or escape-j) "jump out" of any of these, i.e., it moves forward until after the first right paren, right brace, or right bracket. I also have the key ^ insert that character along with a pair of braces and put point inside the braces, the key _ insert that character along with a pair of braces and put point inside the braces, and the key [ insert a pair of brackets and put point in between them.

I set this all up in my .xemacs/init.el file; I'll append the relevant part of that file here.

;; Set up my LaTeX-mode keybindings:

(add-hook 'LaTeX-mode-hook 'add-my-latex-keybindings)
(defun add-my-latex-keybindings ()
  (progn
    (local-set-key "[" 'bracket-pair)
    (local-set-key "^" 'superscript-braces)
    (local-set-key "_" 'subscript-braces)))

;;--------------------------------------------------------------------
;;--------------------------------------------------------------------

;; This begins the definitions of our own functions:

;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun dollar-pair ()
  "We insert a pair of dollar signs and position
    point in between them."
  (interactive)
  (progn
    (insert "$$")
    (backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun paren-pair (arg)
 "We insert a pair of parentheses and position point in between them.
  If called with an argument, then we insert \"\\bigl(\\bigr)\"
  and position point inside of that."
  (interactive "P")
      (if arg
    (progn
      (insert "\\bigl(")
      (save-excursion (insert "\\bigr)")))
        (progn
          (insert "()")
          (backward-char))))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun brace-pair ()
  "We insert a pair of braces and position
    point in between them."
  (interactive)
  (progn
    (insert "{}")
    (backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
(defun bracket-pair ()
  "We insert a pair of brackets and position
    point in between them."
  (interactive)
  (progn
    (insert "[]")
    (backward-char)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun superscript-braces ()
  "We insert a superscript symbol followed by a pair of braces
    and position point in between the braces."
  (interactive)
  (progn
    (insert "^")
    (brace-pair)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun subscript-braces ()
  "We insert a subscript symbol followed by a pair of braces
    and position point in between the braces."
  (interactive)
  (progn
    (insert "_")
    (brace-pair)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun insert-verbatim ()
  "We insert  \\verb\"\" and position point in between the quotes."
  (interactive)
  (progn
    (insert "\\verb\"\"")
    (backward-char)))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun jump-out ()
  "We first expand the abbrev before point (if there is an abbrev
    before point), and then we move point forward in the file until we
    pass the first dollar sign, right paren, right bracket, right brace
    or double quote."
  (interactive)
  (progn
    (expand-abbrev)
    (re-search-forward "[])}$\"]")))
;;--------------------------------------------------------------------
;;--------------------------------------------------------------------
(defun fontchange-em ()
  "We insert  \\emph{} and position point before the right brace."
  (interactive)
  (progn
    (insert "\\emph{}")
    (backward-char)))
;;---------------------------------------------------------------
;;---------------------------------------------------------------
;; Key bindings:


(global-set-key "\ej"     'jump-out)
(global-set-key "\C-cj"   'jump-out)
(global-set-key "\em"     'dollar-pair)
(global-set-key "\C-cm"   'dollar-pair)
(global-set-key "\ep"     'paren-pair)
(global-set-key "\C-cp"   'paren-pair)
(global-set-key "\eo"     'brace-pair)
(global-set-key "\C-co"   'brace-pair)
(global-set-key "\en"     'insert-verbatim)
(global-set-key "\C-cn"   'insert-verbatim)
(global-set-key "\ee"     'LaTeX-environment)
(global-set-key "\C-ce"   'LaTeX-environment)
(global-set-key "\ek"     'fontchange-em)
(global-set-key "\C-ck"   'fontchange-em)
share|improve this answer
    
Probably you'd like to change $$. Consider this: tex.stackexchange.com/questions/503/why-is-preferable-to/… In any case, very nice setting! –  Dror Sep 9 '11 at 7:16
    
Dror: the dollar pair is not used as a pair. The cursor is put in between them in order to type an inline equation. Then again, perhaps ( and ) would've been better. –  Ben Sep 9 '11 at 11:24
add comment

I'm using yasnippet in AUCTeX+EMACS, which gives me for example the option to type im TAB and obtain \( \) with the courser in between, then another TAB sends me outside of the pair.

share|improve this answer
add comment

A while back, Machi, Marsden, and McKay described a program FasTeX which enabled on the fly expansions such as "d" -> "$", "dxa" -> "$\alpha$" etc. for extremely rapid entry of TeX. The key is that the abbreviations were chosen consistently and carefully so as not to cause problems with regular English words.

Details are described in TUGboat Vol. 16 (1995) No. 4.

Even if you do not use the program, they though very carefully about the abbreviations and I find the scheme to be very useful. Emacs abbrev-mode can be used to do this.

Here is a list of the abbreviations.

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.