3

My question is:

when I am editing (La)TeX code, regularly I need to type the famous dollar signs in order to put mathematical code ($x^2+y^2=z^2$), a very frequent thing indeed.

Therefore, I would like to change the keyboard input inside Emacs (preferably only in TeX-related modes), in order to swap the numerical row of the keyboard; that way, I don't need to press Shift key in order to insert special symbols in the numerical row like $&*#%[]...

(Also, my keyboard is a Brazilian ABNT2)

Many thanks in advance!

1

I don't have access to a Brezilian keyboard. For swapping an ordinary US Qwerty keyboard you can use the following. You can adapt it for any keyboard. (This is essentially the answer https://emacs.stackexchange.com/a/3882/ duo to @abo-abo).

(add-hook 'LaTeX-mode-hook 'my-latex-hook)
(defun my-latex-hook ()
  (require 'tex-site)
  (define-key LaTeX-mode-map "`" (lambda () (interactive)  (insert "~")))
  (define-key LaTeX-mode-map "~" (lambda () (interactive) (insert "`")))
  (define-key LaTeX-mode-map "1" (lambda () (interactive)  (insert "!")))
  (define-key LaTeX-mode-map "!" (lambda () (interactive)  (insert "1")))
  (define-key LaTeX-mode-map "2" (lambda () (interactive)  (insert "@")))
  (define-key LaTeX-mode-map "@" (lambda () (interactive)  (insert "2")))
  (define-key LaTeX-mode-map "3" (lambda () (interactive)  (insert "#")))
  (define-key LaTeX-mode-map "#" (lambda () (interactive)  (insert "3")))
  (define-key LaTeX-mode-map "4" (lambda () (interactive)  (insert "$")))
  (define-key LaTeX-mode-map "$" (lambda () (interactive)  (insert "4")))
  (define-key LaTeX-mode-map "5" (lambda () (interactive)  (insert "%")))
  (define-key LaTeX-mode-map "%" (lambda () (interactive)  (insert "5")))
  (define-key LaTeX-mode-map "6" (lambda () (interactive)  (insert "^")))
  (define-key LaTeX-mode-map "^" (lambda () (interactive)  (insert "6")))
  (define-key LaTeX-mode-map "7" (lambda () (interactive)  (insert "&")))
  (define-key LaTeX-mode-map "&" (lambda () (interactive)  (insert "7")))
  (define-key LaTeX-mode-map "8" (lambda () (interactive)  (insert "*")))
  (define-key LaTeX-mode-map "*" (lambda () (interactive)  (insert "8")))
  (define-key LaTeX-mode-map "9" (lambda () (interactive)  (insert "(")))
  (define-key LaTeX-mode-map "(" (lambda () (interactive)  (insert "9")))
  (define-key LaTeX-mode-map "0" (lambda () (interactive)  (insert ")")))
  (define-key LaTeX-mode-map ")" (lambda () (interactive)  (insert "0")))
  (define-key LaTeX-mode-map "-" (lambda () (interactive)  (insert "_")))
  (define-key LaTeX-mode-map "_" (lambda () (interactive)  (insert "-")))
  (define-key LaTeX-mode-map "+" (lambda () (interactive)  (insert "=")))
  (define-key LaTeX-mode-map "=" (lambda () (interactive)  (insert "+")))
)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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