is a low-level box structure that parameterizes the display and evaluation of the boxes boxi.

Details and Options

  • The parameters of TemplateBox are plugged into functions that create new box expressions to be used for display or evaluation. The option DisplayFunction specifies the function used to construct boxes for display, while InterpretationFunction specifies the function used for evaluation.
  • If the tag of the TemplateBox is a string, then that style will be used for the TemplateBox.
  • The following options can be given:
  • DisplayFunctionNonepure function that assembles boxi into a box structure for display
    EditableAutomaticwhether to allow boxi to be edited
    InterpretationFunctionAutomaticpure function that assembles boxi into a box structure for evaluation
    SelectableAutomaticwhether to allow boxi to be individually selected
    TooltipNonetooltip to display when the mouse cursor is over the box
    TooltipStyle{}style specifications for the tooltip
    TooltipDelay0.how long to delay before displaying the tooltip
  • DisplayFunction and InterpretationFunction only accept pure functions that allow for simple rearrangement and substitution into a box structure. The functions do not evaluate in the Wolfram Language kernel and do not support standard kernel functionality.
  • If the DisplayFunction is specified on the stylesheet, all displayed instances of the TemplateBox change uniformly when the stylesheet changes.
  • One important aspect of a TemplateBox is that it will only allow you to edit and interact with the box arguments to the TemplateBox, not the boxes that are part of the DisplayFunction.
  • For default input and output cells, if you copy an expression containing a TemplateBox, the Wolfram System places the fully resolved InterpretationFunction on the clipboard so that evaluation semantics are preserved in copy/paste. Copy As Plain Text will copy the DisplayFunction boxes.
  • You can write MakeBoxes and MakeExpression rules that use TemplateBox in order to define new notations.
  • If a TemplateBox cannot support arbitrary box expressions as parameters, it is generally advisable to use the option Editable->False to prevent users from editing the parameters.


open allclose all

Basic Examples  (3)

Display a template that is stored in the style "Binomial" in a stylesheet:

Click for copyable input

Display a template with an explicit DisplayFunction:

Click for copyable input

Use InterpretationFunction to control how a template evaluates:

Click for copyable input
Click for copyable input

Options  (6)

See Also

TagBox  InterpretationBox

Introduced in 2008