[Share] To disable math keyboard bindings in label

When you are in math mode, for example equation, align, eqnarray, very often you want to label the equation or one of the equations for later reference in the article or document, there is a chance that you triggered a keybinding when you are in label. My case is as follows:

In math-mode, I bind d i to the math formula \partial_i (in terms of Tex, \partial_{i}). For me it is extremely useful. Say I want to label the equation differential. When there was no third line of the below code, \partial_i will be popping up in label.

(kbd-map
 (:mode in-math?)
 (:require (not (in-variants-disabled?)))     
 ("d i" (math-insert '(concat "<partial>" (rsub "i")))))

Alternative solution could also be

(kbd-map
 (:mode in-math?)
 ("d i" (math-insert '(concat "<partial>" (rsub "i")))))

(kbd-map
 (:mode in-variants-disabled?)
 ("d i" "di"))

Figure

Reference of TeXmacs code:

  1. progs/kernel/texmacs/tm-modes.scm, See texmacs-modes.
  2. progs/kernel/gui/kbd-define.scm, See the definitions of kbd-add-condition, kbd-map-one, kbd-map-body and kbd-map
1 Like