<latex>
<latex> is a Text
component that stores a LaTeX-formatted string. It is equivalent to
<text> with the isLatex attribute defaulted to true.
The primary reason <latex> exists is that the latex property of a
<math> (or any math-valued component) returns a <latex>.
That makes round-tripping through the LaTeX form natural: a reference like
$myMath.latex is itself a <latex>, and feeding it back into a
<math> produces the original expression — without having to set
format="latex" on the outer <math>.
<latex> is rarely useful as a display tag — <m>,
<me>, and <md> always parse their children as LaTeX,
so for typeset output they do the job whether you wrap the LaTeX in
<latex>, in <text>, or leave it bare. <latex> becomes
distinguishable from <text> only when the surrounding context is going
to parse the content, not just render it. The canonical such context is a
<math>.
How <math> consumes a <latex> child
Each text-like child of a <math> parses its own value with
its own parser before being incorporated as a math sub-expression: a
<latex> (or any <text> with isLatex="true") uses the LaTeX
parser, a plain <text> uses the text parser. This is independent of
the outer <math>’s format attribute, which only controls how the
outer math parses its own string content.
So <math><latex>…</latex></math> parses the contents as LaTeX even
though the outer <math>’s format is still its default "text".
Attributes and Properties
Attributes for <latex>
Positioning (2)
anchorpoint. Default value: . Coordinates of the anchor point used to position this component on a graph.
positionFromAnchorkeyword. Where this component sits relative to its anchor point.
| Value | Description |
|---|---|
upperRight | Place the component above and to the right of the anchor point. |
upperLeft | Place the component above and to the left of the anchor point. |
lowerRight | Place the component below and to the right of the anchor point. |
lowerLeft | Place the component below and to the left of the anchor point. |
top | Place the component directly above the anchor point. |
bottom | Place the component directly below the anchor point. |
left | Place the component directly to the left of the anchor point. |
right | Place the component directly to the right of the anchor point. |
center (default) | Center the component on the anchor point. |
Other (3)
draggableboolean. Default value: true. Whether the text can be dragged on a graph.
isLatexboolean. Default value: true. Whether the text content is treated as LaTeX.
layernumber. Default value: 0. Z-order layer index when shown on a graph.
Common to all components (9)
copyreference. Create an independent copy of another component by reference. Enter a references a $name.
disabledboolean. Default value: false. Whether this component is disabled and cannot be interacted with.
extendreference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.
fixedboolean. Default value: false. Whether this component's value is fixed and cannot be modified.
fixLocationboolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
hideboolean. Default value: false. Whether to hide this component from the rendered output.
isResponseboolean. Default value: false. Whether this component is treated as a response for the purposes of assessment.
nametext. The name used to reference this component from elsewhere in the document.
styleNumberinteger. Default value: 1. The style number used to select this component's visual styling from the available style definitions.
Properties for <latex name="l">
Positioning (2)
$l.anchorpoint. The coordinates where this component is anchored on the graph.
$l.positionFromAnchortext. Where this component sits relative to its anchor point.
Other (21)
$l.backgroundColortext. Human-readable name for this component's background color, derived from the active style and theme.
$l.characters[ text ]. The text value split into characters (graphemes).
$l.disabledboolean. Whether this component is disabled and cannot be interacted with.
$l.draggableboolean. Whether the text can be dragged on a graph.
$l.fixedboolean. Whether this component's value is fixed and cannot be modified.
$l.fixLocationboolean. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).
$l.isLatexboolean. Whether the text content is treated as LaTeX.
$l.latexlatex. The LaTeX content as a string.
$l.layernumber. Z-order layer index when shown on a graph.
$l.list[ text ]. The text value split into items at commas.
$l.mathmath. The text parsed as a math expression.
$l.numbernumber. The text parsed as a number.
$l.numCharactersinteger. The number of characters (graphemes) in the text value.
$l.numListItemsinteger. The number of comma-separated items when the text is interpreted as a list.
$l.numWordsinteger. The number of words in the text value.
$l.texttext. The text rendered as a plain text string.
$l.textColortext. Human-readable name for this component's text color, derived from the active style and theme.
$l.textStyleDescriptiontext. Human-readable description of this component's text styling (color and any background color).
$l.valuelatex. The text value.
$l.words[ text ]. The text value split into words.
Common to all components (4)
$l.doenetMLtext. The DoenetML source code that produced this component.
$l.hideboolean. Whether to hide this component from the rendered output.
$l.isResponseboolean. Whether this component is treated as a response for the purposes of assessment.
$l.styleNumberinteger. The style number used to select this component's visual styling from the available style definitions.
Examples
Example: Round-trip math → latex → math
The first two paragraphs show the original expression and its
LaTeX-formatted string. The third places $m.latex (which is a
<latex> component) inside a <math>. The outer <math>
has no format attribute, yet the round trip works: the <latex>
child uses the LaTeX parser to convert its own contents back into a math
expression, which the outer <math> then incorporates.
Example: Why a plain <text> does not round-trip
Wrapping $m.latex in a <text> instead of a <latex> loses the
isLatex flag. The <text> parses its own value using its own
isLatex setting (false by default), so the text parser tries to read the
LaTeX string and fails — the result renders as a blank box, _. Setting
format="latex" on the outer <math> does not help, because that
attribute only controls how the outer math parses its own string content;
the <text> child is still parsed by the <text>’s own parser.
The real fix is to mark the child as LaTeX — either with isLatex="true" on
the <text>, or by using a <latex>, which is just that case
spelled more concisely.
Example: Reuse one LaTeX string in multiple places
A named <latex> value can be referenced anywhere a text or math
component is accepted. The <math> parses the LaTeX into an expression
(via the round-trip mechanism above); <me> renders it as
display math. Storing the LaTeX once keeps every consumer in sync.