Macros

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

To view the default macros, inspect the macros option:

import '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>

To add or remove macros use setOptions({macros: ...}).

import '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.