ReferencemathInput

<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

Attributes for <mathInput>
AttributeTypeValues
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"
Props for <mathInput name="m">
PropertyType
$m.collaborateGroupscollaborateGroups
$m.disabledboolean
$m.displayDecimalsinteger
$m.displayDigitsinteger
$m.displaySmallAsZeronumber
$m.fixedboolean
$m.fixLocationboolean
$m.formattext
$m.functionSymbolstextList
$m.hiddenboolean
$m.hideNaNboolean
$m.immediateValuemath
$m.immediateValueChangedboolean
$m.labellabel
$m.labelIsNameboolean
$m.list[ math ]
$m.matrix[ math ]
$m.matrixSizenumberList
$m.minWidthinteger
$m.numColumnsinteger
$m.numDimensionsinteger
$m.numListItemsinteger
$m.numRowsinteger
$m.padZerosboolean
$m.parseScientificNotationboolean
$m.prefillmath
$m.prefillLatexlatex
$m.rawRendererValuelatex
$m.splitSymbolsboolean
$m.texttext
$m.unionFromUboolean
$m.valuemath
$m.valueChangedboolean
$m.vector[ math ]
$m.xmath
$m.ymath
$m.zmath

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 xyzx \cdot y \cdot z. 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 \cup 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.