<mathInput/>
<mathInput/> is an Input
component that renders a user-input field that stores mathematical content.
When referenced, a named <mathInput/> can be used in computations in the same manner
as a <math> component.
Attributes and Properties
| Attribute | Type | Values |
|---|---|---|
bindValueTo = "…" | ||
displayDecimals = "…" | integer | |
displayDigits = "…" | integer | |
displaySmallAsZero = "…" | number | |
format = "…" | text | "text" "latex" |
functionSymbols = "…" | textList | |
hideNaN = "…" | boolean | "true" "false" |
labelIsName = "…" | boolean | "true" "false" |
minWidth = "…" | integer | |
padZeros = "…" | boolean | "true" "false" |
parseScientificNotation = "…" | boolean | "true" "false" |
prefill = "…" | math | |
prefillLatex = "…" | latex | |
removeStrings = "…" | ||
splitSymbols = "…" | boolean | "true" "false" |
unionFromU = "…" | boolean | "true" "false" |
| Property | Type |
|---|---|
$m.collaborateGroups | collaborateGroups |
$m.disabled | boolean |
$m.displayDecimals | integer |
$m.displayDigits | integer |
$m.displaySmallAsZero | number |
$m.fixed | boolean |
$m.fixLocation | boolean |
$m.format | text |
$m.functionSymbols | textList |
$m.hidden | boolean |
$m.hideNaN | boolean |
$m.immediateValue | math |
$m.immediateValueChanged | boolean |
$m.label | label |
$m.labelIsName | boolean |
$m.list | [ math ] |
$m.matrix | [ math ] |
$m.matrixSize | numberList |
$m.minWidth | integer |
$m.numColumns | integer |
$m.numDimensions | integer |
$m.numListItems | integer |
$m.numRows | integer |
$m.padZeros | boolean |
$m.parseScientificNotation | boolean |
$m.prefill | math |
$m.prefillLatex | latex |
$m.rawRendererValue | latex |
$m.splitSymbols | boolean |
$m.text | text |
$m.unionFromU | boolean |
$m.value | math |
$m.valueChanged | boolean |
$m.vector | [ math ] |
$m.x | math |
$m.y | math |
$m.z | math |
Example: Assign a name to user-input math expression
A <mathInput/> renders an input field for storing and naming user-provided math expressions.
Example: Do some math with user-input
A named <mathInput/> can be referenced within a <math> for computations.
Example: <mathInput/> with structured prefill
A <mathInput/> can incorporate a prefill with shaded blanks.
Attribute Example: prefill
The prefill attribute can be used to specify an initial value of
the <mathInput/>, or a template for anticipated responses. Blank spaces,
if used, are rendered as grey input boxes.
Attribute Example: prefillLatex
The most common way to enter LaTex in a prefill is to use the format = "latex" attribute.
However, the prefillLatex attribute is a means of preserving non-standard formatting
which is typically removed when LaTeX is parsed as a math component.
Attribute Example: format
The format attribute gives the option for prefilled <mathInput/> components
to contain content formatted in LaTex. If supported, expressions entered in the
prefill of the <mathInput/> will be parsed by Doenet as math components and
may be used in further computations.
Attribute Example: functionSymbols
The functionSymbols attribute is used to specify when a character is formatted as a
function that takes an argument in parentheses. The default values that are automatically
considered functions symbols are f and g.
Attribute Example: splitSymbols
The splitSymbols attribute is used to modify the default mathematical simplification of
multicharacter values in a <mathInput/>. By default, Doenet assumes adjacent characters
are single variables multiplied together, and “splits” them during parsing. So, for example,
multicharacter values such as xyz are interpreted as the product . However,
if you wish to treat a grouping of symbols as a single variable, you can turn off this
behavior by specifying splitSymbols="false".
Attribute Example: bindValueTo
The bindValueTo attribute is used to create a bidirectional link between the
value of a <mathInput/> and that of another component. This attribute
accepts a reference to a named math component or the property of a named component as input.
Attribute Example: unionFromU
By default, an uppercase “U” entered in a <mathInput/> will be interpreted as
the letter U. To enter a union, one can use the virtual keyboard (by clicking button at
the bottom of the screen), and finding the symbol in the keyboard’s Set menu.
(Or, if one knows LaTeX, one could type \cup for union.)
Attribute Example: hideNaN
By default, the text NaN is suppressed within the <mathInput/> box. To override this
behavior, the hideNaN attribute may be set to false.
Attribute Example: removeStrings
The removeStrings attribute allows Doenet to ignore elements of a user’s input which cannot be parsed into a math.
Attribute Example: minWidth
The minWidth attribute is set to 50 by default. Adjust this value for a longer or shorter input box.
Property Example: Attributes as properties
The above-listed attributes of <mathInput/> are also accessible as properties.
Property Example: value
The value property renders the value stored in the <mathInput> after the user has
clicked Enter (or mouse-clicked on another part of the screen).
Property Example: immediateValue
The immediateValue property contains the value the user enters into the input as they are typing.
Property Example: text
The text property of a <mathInput/> stores its content as a string.
Property Example: rawRendererValue
The rawRendererValue property stores/renders the LaTeX code required for rendering the math expression, updated as the user types.