Skip to main content

Module eqref

Module eqref 

Source
Expand description

\eqref{eq:euler}: a reference to an equation line that shows its number and nothing else, (13) where \ref{eq:euler} shows Eq.~(13).

The command belongs to the math feature because what it refers to, one line of a display-math environment, belongs to that feature. It takes one label, whose label type (the part before the colon; see reference points, labels and anchors) must be eq (TARGET_TYPE), the label type that an equation line accepts (LABEL_TYPES). A label of any other type is an Error at the command (NotAnEquation, flm.math.eqref-not-an-equation), and the command then shows the label’s text, unlinked, as an unresolved reference does.

§What the command shows

An \eqref shows what \ref[noprefix] shows for the same label: the number the document gave the line, between the parentheses of the equation counter style (COUNTER_STYLE) and without the prefix words; for a line with a \tag, the tag’s content; and when the label refers to no equation line, or the references feature is not registered, the label as written, unlinked. The default rule RULE does not decide this itself: it calls the references feature’s function for reference commands, lower_reference, so that \eqref and \ref always show a label the same way. Unlike a \ref with one label, an \eqref adds none of the texts that RefsConfig writes around a single reference (one_pre, one_post): it shows the number and nothing else.

§Recomposing to LaTeX

On the latex-recomposed backend, LATEX_RULE writes \eqref{…} around the label’s safe label, the key under which the recomposed LaTeX writes every label (SafeLabels), and requests the LaTeX package amsmath, which defines \eqref. The numbering is LaTeX’s there, so the compiled document shows the number LaTeX gave the equation, not the one FLM computed.

An \eqref whose label no equation line carries is written under the safe label assigned to that label, as every reference to a missing label is, and LaTeX reports it as an undefined reference. A label of a type other than eq is the same Error as on every other backend, and the label is written as the document wrote it, never as the safe label of the construct that carries that label, so a recomposed \eqref never points at a heading.

The label is read as characters first, as a \ref’s is (read_target_at_lowering). A label that holds a placeholder of a user definition’s template cannot be read that way; the uses of such a definition are then expanded instead of written as calls, and the label of an expanded use is written through target_spelling. That function also handles a label that appears only inside a synthesized value (a small tree that a stage builds during a run): it reads the label’s name from the references feature’s value names table (ValueSafeLabels, flm.labels.safe.value).

§Without the references feature

The rules read the tables of the references feature optionally, under peer declarations (PeerName): when that feature is registered, the stages that write the tables run before the rules; when it is not, the command shows its label as the document wrote it, unlinked. A registry with mathematics and without references therefore renders an \eqref instead of refusing the plan.

Rendering reports nothing about the missing references feature; the registry build has already reported one Note for each unresolved peer declaration. The check of the label type reads what the author wrote, before any table is read, so \eqref{eq:euler} in such a registry shows eq:euler unlinked and reports nothing, and only a label of another type is an Error.

§Map of the module

Structs§

EqrefElement
The data of the element value of flm.math.eqref, and the element’s Referencing aspect: it declares the reference site (RefSite) of an \eqref node, a place that refers to a reference point.
EqrefLatexRule
The body of LATEX_RULE: \eqref around the label’s safe label, and a request for the LaTeX package amsmath. See the module documentation, Recomposing to LaTeX.
EqrefRule
The body of RULE: it shows the line’s number through the references feature’s lower_reference, and reports NotAnEquation for a label of another type. See the module documentation, What the command shows.
NotAnEquation
Condition flm.math.eqref-not-an-equation (an Error): the label of an \eqref does not have the label type eq.

Constants§

EQREF
The name of the element of \eqref, flm.math.eqref. Its element value carries an EqrefElement, which is also the element’s Referencing aspect.
LATEX_COMMAND
The LaTeX command that the recomposed LaTeX writes, eqref: the amsmath package’s reference to an equation, which prints the number in parentheses.
LATEX_RULE
The name of the recomposition rule of EQREF for the latex-recomposed backend, flm.math.eqref.lower.latex-recomposed, whose body is EqrefLatexRule.
RULE
The name of the default lowering rule of EQREF on every backend, flm.math.eqref.lower.default, whose body is EqrefRule.
TARGET_TYPE
The label type that the label of an \eqref must have, eq: the type of the labels an equation line accepts.

Functions§

args
The arguments of \eqref: its one label. There are no display options, because an \eqref always shows the number alone.
element
The element value of every \eqref node. It is one shared value, so that no second element value named flm.math.eqref is ever created.
eqref_target
The label of an \eqref node: its argument read as characters, trimmed of the whitespace around it, and parsed when the text has the form type:label. None when node is not an \eqref, or when its argument holds a placeholder of a user definition’s template that was not expanded: such an argument has no characters to read, declares no reference site, and nothing is reported for it.
register
Registers \eqref: peer declarations (PeerName) of the references feature’s resolutions table and value names, the element and its element type’s text, and its two rules.
rules
The two rules of \eqref, ready to be registered: RULE, the default on every backend, and LATEX_RULE, the default on the latex-recomposed backend only.