BUILT-IN WOLFRAM LANGUAGE SYMBOL

TemplateBox

TemplateBox[{box1,box2,},tag]
is a low-level box structure that parameterizes the display and evaluation of the boxes .

Details and OptionsDetails 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 into a box structure for display
    EditableAutomaticwhether to allow to be edited
    InterpretationFunctionAutomaticpure function that assembles into a box structure for evaluation
    SelectableAutomaticwhether to allow 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.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

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

In[1]:=
Click for copyable input
Out[1]=

Display a template with an explicit DisplayFunction:

In[1]:=
Click for copyable input
Out[1]=

Use InterpretationFunction to control how a template evaluates:

In[1]:=
Click for copyable input
In[2]:=
Click for copyable input
Out[2]=
Introduced in 2008
(7.0)