Expand description
Equation lines: the four commands an author writes inside a display-math
environment’s body (\\, \label, \tag and \nonumber), and the reader
that splits such a body into lines.
An equation line is one line of a display-math environment as its body reads
between two \\: its mathematics, its labels, its tag and its no-number mark;
each line is one reference point (equation
lines). An align body such
as a &= b \label{eq:first} \\ c &= d \nonumber holds two lines. The
math feature declares one reference point per line and numbers it
from what equation_lines reads here; the lowering rules of the feature
that processes mathematics write each line’s tag or number, and, on the
latex-recomposed backend, each line’s labels.
§The four commands
| written | field name | what the line records |
|---|---|---|
\\, \\[1ex] | LINEBREAK_COMMAND | the end of the line, and the optional spacing as written |
\label{eq:name} | LABEL_FIELD | a label of the line |
\tag{A}, \tag*{A} | TAG_COMMAND | the tag’s content as inline nodes, and whether the star was written |
\nonumber | NONUMBER_COMMAND | the line is not numbered |
The four commands are declared in the scoped package
(ScopedPackageDef) PACKAGE (flm.math.lines): a set of element
declarations that can be written only inside the environment bodies and
arguments whose declarations refer to the package by name (scoped
packages). The bodies of the
six display-math environments refer to it, and the declarations are for math
mode only, so this module’s declarations apply inside
\begin{align}…\end{align} and the other five environments, and nowhere
else. In inline mathematics \(…\) and in displayed mathematics \[…\],
\\ and \tag are commands this module does not declare (under the
math-passthrough feature,
unknown commands kept as source); in text mode they mean what another feature
declares there, if anything.
All four are fields: macros that a construct reads as data rather than
as content (fields). Each node
carries an element named FIELD and is
read by the command’s name, and the environment’s reader, equation_lines,
gives them their meaning. Where a command is written inside its line makes no
difference to what the line records. The \label declared here is a
separate declaration from the \label that a heading reads after its
arguments, but it produces a field node of the same field name, so
the references feature’s reader of a label, label_use,
reads it unchanged.
The optional argument of \\ must follow the command immediately: in
a \\ [b] the [b] is content of the next line, not spacing. This keeps a
bracketed expression at the start of a line from being read as spacing.
\nonumber is the only way to write the no-number mark. \notag, which
LaTeX’s amsmath package also accepts, is not declared: inside a body it is
an unknown command, kept as source in the line.
The whitespace right after a command’s name belongs to the command’s node
(see macros in the syntax guide), so
the newline after \nonumber is not part of the line’s content. The name of
\\ is a single character that is not a letter, which takes no such
whitespace, so the newline after it begins the next line’s content.
§Reading a body as lines
equation_lines reads the direct children of an environment’s body once
and returns one EquationLine per line, in order:
- A
\\ends the line being read. - A
\label,\tagor\nonumberis taken out of the content and recorded on the line it is written in. A\labelwritten on a line of its own before the\\belongs to the line that\\ends; one written right after a\\belongs to the next line. The whitespace around such a command stays in the content; where the command stood on a line of its own, the LaTeX writers keep a blank line from appearing through themathlibrary’s newline rule (normalize_line_newlines). - Everything else (mathematics, whitespace, comments, and nested environments
as a whole) is the line’s
content, in order. The nodes of a nested environment are not examined, so a\\inside acasesormatrixenvironment nested in analigndoes not split the outer lines. - A body with no
\\is one line. - A
\\followed only by whitespace, blank lines and comments ends the last line and begins no further one. It is not recorded (the last line’slinebreakisNone), and the whitespace and comments after it are added to the last line’s content as written. A backend that writes the lines back therefore never writes a final\\, which would make LaTeX add the space of an empty line after the last equation. Anything else after the last\\(mathematics, a\label, a\tagor a\nonumber) begins a further line.
A line’s linebreak is therefore Some exactly when another line follows it.
§The error, and empty lines
The body parser of the display-math environments (LinesBehavior) checks
the lines when a body is parsed and reports one condition as an Error:
LabelWithoutNumber (flm.math.label-without-number), a \label or a
\tag written on a line that cannot be numbered, a line marked \nonumber
or any line of equation*, align* or gather*. Each such command is
reported once.
Whether a line must hold mathematics is a question for the feature that
processes mathematics, not for this module: a line holding only whitespace,
comments, a \label, a \tag or a \nonumber, a \\ at the start of a
body, two \\ in a row and an empty body are read here without a report.
A processing feature reports each such line from its check stage, as
math-passthrough does.
The tree keeps the body as written, and equation_lines returns every
line, an empty line as an EquationLine with no content, so that a backend
can still write back what the author wrote.
§Lowering
None of the four commands is lowered on its own. Their nodes are only ever
written inside an environment’s body, which the environment’s lowering rule
reads as lines and writes from the lines’ data. A field node that reaches a
backend on its own is an Error, reported by the only lowering rule of the
field element (FieldRule).
§The lines and the numbers
The environment declares one reference point per line, whose index is the
line’s index. A line that can be numbered carries the labels written on it, so
\ref{eq:name} refers to the line it labels and shows the number the document
gave that line; a line that cannot be numbered keeps no label, so nothing can
refer to it. A line’s \tag replaces its number: the reference point states the tag’s content (Tag::content_ref), and the
line counts in nothing. The math feature’s documentation describes
the reference points in full.
§Map of the module
PACKAGE,package— the scoped package of the four commands.LINEBREAK_COMMAND,TAG_COMMAND,NONUMBER_COMMAND,SPACING_ARG,STAR_ARG,TEXT_ARG— the names of the commands and of their arguments.equation_lines,EquationLine— the reader and what it returns for one line;line_break,LineBreak,tag_of,Tag— the readers of one\\and one\tag.LinesBehavior,body_behavior— the body parser of the environments.LabelWithoutNumber,LineCommand— the condition the parse reports.
Structs§
- Equation
Line - One equation line of a display-math environment, as
equation_linesreads it: its content, labels, tag, no-number mark and line break. The module documentation, Reading a body as lines, says how a body is split into lines. - Label
Without Number - Condition
flm.math.label-without-number(an Error): a\labelor a\tagis written on an equation line that cannot be numbered, a line marked\nonumberor any line of a starred environment (equation*,align*,gather*). - Line
Break - A
\\node, asline_breakreads it: the node and its spacing. - Lines
Behavior - The body parser (
FlmBodyParser) of the six display-math environments: techy’s ordinary parse of an environment body, up to and including\end{name}, followed by the check of the equation lines, which reportsLabelWithoutNumberamong the parse’s diagnostics. See the module documentation, The error, and empty lines. - Tag
- A
\tagnode, astag_ofreads it: the node, its content and whether the star was written.
Enums§
- Line
Command - The command that a
LabelWithoutNumbercondition reports:\labelor\tag.
Constants§
- LINEBREAK_
COMMAND - The name of the line-break field, a single backslash: the author writes
it after the escape character, so the command reads
\\. - NONUMBER_
COMMAND - The name of the no-number field,
nonumber. - PACKAGE
- The name of the scoped package that holds the four commands,
flm.math.lines: the body declaration of each display-math environment refers to it, which makes the commands available inside the body. - SPACING_
ARG - The name of the optional argument of
\\,spacing: the vertical space added after the line, as in\\[1ex]. - STAR_
ARG - The name of the star argument of
\tag,star: when it is written (\tag*), the tag is shown without parentheses. - TAG_
COMMAND - The name of the tag field,
tag. - TEXT_
ARG - The name of the mandatory argument of
\tag,text: the tag’s content, read in text mode.
Functions§
- body_
behavior - The
LinesBehaviorof a display-math environment,numberedsaying whether the environment numbers its lines: the body parser that the environment’s body declaration carries (BodyDef::parser). - equation_
lines - The equation lines of a display-math environment’s body: one
EquationLineper line, in order. The module documentation, Reading a body as lines, says exactly how the body is split. - line_
break - Reads a
\\node:Somewith its spacing whennodeis the line-break field of this module,Nonefor any other node. - package
- The scoped package
PACKAGEwith the declarations of the four commands, owned byowner: what themathfeature registers, and what the body of each display-math environment refers to. - tag_of
- Reads a
\tagnode:Somewith its content and its star whennodeis the tag field of this module,Nonefor any other node. A tag whose text argument is absent (after a parse recovery) has no content.