Macros

MathLive has over 800 Latex commands predefined. Some are primitives but others are macros, that is commands defined with a Latex expression.

You can view the default macros by inspecting the macros property of the config object:

import MathLive from 'mathlive'; const mf = document.getElementById('mf'), { }); console.log(mf.getOption('macros'));
<math-field id='mf'>x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}</math-field>

You can add (or remove) macros by using setOptions({macros: ...}).

import MathLive from 'mathlive'; const mf = document.getElementById('mf'); mf.setOptions({ macros: { ...mf.getOptions('macros'), smallfrac: '{}^{#1}\\!\\!/\\!{}_{#2}', }, });
<math-field id="mf">\scriptCapitalE=\smallfrac{5}{7}+\frac{5}{7}</math-field>

The macro definition can contain up to eight arguments, represented by #1 to #9.

Next

Shortcuts
Manage inline shortcuts and keyboard shortcuts