$BoxForms


$BoxForms

contains the current list of general-purpose “BoxForms” formatters.

Elements of $BoxForms are valid forms to be used as a second parameter in MakeBoxes expressions.

Adding a new MakeBoxes rule does not automatically extend the $BoxForms list as happens, for example, in $PrintForm when new FormatValues are defined.

To see how to add a new form, let us first list the values defined in $Boxforms. This will be useful to compare against later:

Now we add a rule with our new form MyBoxForm:

Although a rule involving MyBoxForm has been defined in MakeBoxes, the rule is not triggered in boxing.

And it is not defined in $BoxForms either:

To have MyBoxForm formatting take effect in boxing via MakeBoxes, we first need to add the new form to $BoxForms:

This automatically stores the new form in $PrintForms and $OutputForms:

We also need to define in MyBoxForm its ParentForm:

Now,

The ParentForm is used when a MakeBoxes rule for a given expression is not available:

Above, the MyBoxForm rule is not used to format the argument, because the rule used to format the expression propagates TradionalForm (the ParentForm of our custom BoxForm) to the arguments.

To fix this, define a rule that propagates the box form to its elements:

Now,

Suppose now we want to remove the new BoxForm. We can reset $BoxForms to its default values by unset it:

This does not remove the value from $PrintForm or $OutputForm:

To remove MyBoxForm, unset in each variable:

$OutputForms