Macros
Over 800 LaTeX commands are predefined. Some are primitives but others are macros, that is commands defined with a LaTeX expression. You can define your own macros.
Adding/Removing Macros
To add a macro use mf.macros = {...mf.macros, ...}
.
If you do not include the ...mf.macros
expression, all the standard macros will be
turned off.
The example below will define a new command, \average
, which will be
replaced by \operatorname{average}
, that is displayed as a single unit
using an upright font.
Try changing \operatorname
to \mathbf
to see the difference.
You can use standard LaTeX commands in the definition of a macro. For example,
the following macro definition uses the \,
and \;
commands to insert
horizontal spacing and {}^
to place the \prime
command on the subscript
line.
mf.macros = { ...mf.macros,
minutes: "\\,{}^\\prime\\;",
seconds: "\\,\\doubleprime\\;",
};
The macro definition can contain up to eight arguments, represented by #1
to #9
.
By default, a macro command behaves as a group whose subcomponents cannot be
modified. This behavior can be controlled using the captureSelection
flag
in the expanded definition of a macro.
To define a macro whose content is selectable and editable set
captureSelection
to false
.
To remove a macro set its definition to undefined:
Adding a Matching Shortcut
By defining a new macro, a new LaTeX command is added to the dictionary of commands that can be used in a LaTeX expression.
To input a macro, type \ followed by the macro name, then RETURN
Custom macros are also included in the value of the mathfield
expressed as a LaTeX string (mf.value
).
It may also be convenient to associate the macro with an inline shortcut. Inline shortcuts can be typed without having to enter the LaTeX editing mode (without having to type the \ key).
To define an associated inline shortcut, use the inlineShortcuts
option.
Inspecting Available Macros
To view the available macros, inspect the macros
property:
Disabling Macros
To turn off all macros, use mf.macros = {}
.