Expand description
The text commands of math mode: \text{…} and the related commands, which
put document text inside a formula.
A text command is a command of math mode whose one argument is read in
text mode: inside a formula, its argument is document content rather than
mathematical notation. An author writes a word of text inside a formula, such
as “for all x such that”, a unit or a short remark, with \text{…},
\textbf{…}, \mbox{…} or another of the twelve commands of COMMANDS.
Everything else in a formula is carried to the output as the author wrote it
(see the math feature).
§Where the commands are declared
This module declares the twelve commands for math mode only
([Mode::Math]). In text mode they are not this module’s: \textbf,
\textit and \texttt are the
textstyles feature’s, and \text,
\mbox and the others are unknown commands, an Error in text mode.
The textstyles feature declares \textbf, \textit and \texttt in text
mode only, the default of a declaration (ElementDef::modes). The two
features therefore declare these names in modes that do not overlap: in text
mode the name is the textstyles feature’s, in math mode this feature’s.
Two declarations whose modes do not overlap never clash, so neither feature
declares an override, and the order in which the two features are registered
does not matter.
§What the argument holds
The argument of a text command is read in text mode, with the parsing rules of
text, so it holds ordinary FLM content: formatting commands (\emph{…}),
references (\ref{…}), uses of user definitions, and mathematics again
(\(…\)). The two modes differ at the argument’s edge: a command that no
feature declares is kept as source in the mathematics around the argument,
but is an Error inside it, because the argument is text.
Three later steps follow from this, each in its own module:
- the block-structure pass lays the argument out as inline content (whitespace resolved, typographic substitution applied), although the formula around it is an opaque region that the pass leaves untouched;
- on the
htmlbackend, and inside a display-math environment on thetextbackend, the lowering puts the argument’s content inside aflm.pres.math-textnode among the formula’s source, the only part of the formula that is content (on thetextbackend,\(…\)and\[…\]are copied whole as source); - the
latex-recomposedbackend writes the command back as the LaTeX macro of the same name, its argument recomposed as text (super::latex).
§The element and its rules
The twelve commands form one family, declared as one element type with one
element value per command (elements and
aspects): the element
type TEXT (flm.math.text), each element value carrying a
MathTextCommand with the command’s name, which a backend writes back.
RULE(flm.math.text.lower.default) is the default rule on every backend: it stages (builds into the lowered tree; seeLowerer) aflm.pres.math-textnode that carries the command’s name, over the argument lowered through the rules. The rules of themathfeature that write a formula on thetextandhtmlbackends lower each text command they find through it.- On the
latex-recomposedbackend,TEXT_LATEX_RULEis the default instead.
§Commands not declared here
\intertext and \shortintertext also take text, but they set a paragraph
of text between two lines of a display-math environment, not content inside a
formula. FLM does not model them: the reader of equation lines
(super::lines::equation_lines) would leave such a command in the content
of the line that follows it. They are therefore unknown commands, kept as
source like any unknown command in mathematics.
Structs§
- Math
Text Command - The data of one element value of
flm.math.text: which text command was written. - Text
Rule - The body of
RULE: it stages aflm.pres.math-textnode that carries the command’s name, over the command’s argument lowered through the rules.
Constants§
- COMMANDS
- The text commands declared for math mode, in the order they are registered:
text,textnormal,textup,textrm,textmd,textbf,textit,textsl,textsc,textsf,texttt,mbox. - CONTENT_
ARG - The name of the only argument of every text command,
content. - RULE
- The name of the default lowering rule of
TEXTon every backend,flm.math.text.lower.default, whose body isTextRule. - TEXT
- The name of the element type of the text commands of math mode,
flm.math.text. The data of each element value is aMathTextCommand.