[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.

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

Alternative solution could also be

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

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


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

Exactly what I want! What is the meaning of in-variants-disabled?

To make it more flexiable, move cursor into the slot and type what you want:

   ("d i" (begin
            (insert "<partial>")
            (insert-go-to '(rsub "") '(0 0))))
   ("d I" (begin
            (insert "<partial>")
            (insert-go-to '(rsup "") '(0 0))))

I don’t know whether @susoren is reading the forum in these days, I am going to answer in his stead.
With the procedure-source form you can get the source for Scheme functions.

(procedure-source in-variants-disabled?)


(lambda () (tree-in? (tree-up (cursor-tree)) (quote (hlink reference pageref label))))

I did not try and figure out what tree-up does, this said it looks like a list of tags within which you want to disable tab variants … and other keyboard shortcuts.

1 Like