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 = MathLive.makeMathField(document.getElementById('mathfield'), { }); console.log(mf.getConfig().macros);
<div id="mathfield">x=\frac{-b\pm \sqrt{b^2-4ac}}{2a}</div>

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

import MathLive from 'mathlive'; const mf = MathLive.makeMathField(document.getElementById('mathfield'), { }); mf.$setConfig({ macros: { ...mf.getConfig('macros'), smallfrac: '{}^{#1}\\!\\!/\\!{}_{#2}', }, });
<div id="mathfield">\scriptCapitalK=\smallfrac{5}{7}+\frac{5}{7}</div>

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

Next

Shortcuts
Manage inline shortcuts and keyboard shortcuts