/** * Labelled equations and numbered statements (#530). A `\label{eq:x}` in a * display formula (on a row of an `align` or `gather`) numbers it in * reading order, as LaTeX's amsmath does; a callout style with `numbering` * counts its boxes as theorems, lemmas or definitions, as amsthm does, and * styles naming one counter share it. Both are anchors: `\eqref{eq:x}`, * `\ref{x}`, `:ref{id="x"}` and `@eq:x` print their number and link to * them. * * Two passes over the parsed content: {@link numberStatements} counts * (pure, also run by the outline and the continuation, so a book laid out * one chapter at a time numbers on), {@link applyStatementNumbering} * writes the numbers into the content the layout measures — a `\tag*` in * the formula, a run-in label or a title on the box, the references inside * formulas — and sets a style's end mark (a proof's ∎). */ import type { ContentBlock } from '../parse/index.js'; import type { HeadingCounters, ResolvedCalloutNumberingConfig, ResolvedCalloutStyleConfig } from '../types.js'; import type { ResolvedConfig } from '../vdt.js'; import type { MeasuredBlock } from '../measure/index.js'; /** Counter values at a point of the book, by counter name (`'equation'` * for the equations), each with the heading counters of its last count. */ export type StatementCounterState = Record; /** A numbered target: an equation's label or a counted box's `{#id}`. */ export interface CountedTarget { id: string; kind: 'equation' | 'statement'; /** The bare number ("3", "2.1"); what `\ref` and `style=number` print. */ number: string; /** What a reference prints by default: "(3)", "Theorem 2". */ label: string; } /** What a counted box prints. */ export interface CountedStatement { numbering: ResolvedCalloutNumberingConfig; style: ResolvedCalloutStyleConfig; /** "Theorem 2" ("Proof" for a label with no counter). */ head: string; /** The fence's `title`, printed after the head in parentheses. */ note?: string; } export interface StatementNumbering { /** Numbered targets by identifier (the first setting wins). */ targets: Map; /** The TeX of each display formula whose labels were numbered, by the * formula's source start: `\label` turned into `\tag*{(3)}`. */ tex: Map; /** Counted boxes by the fence's `containerId`. */ statements: Map; /** The counters at the end of the content. */ counters: StatementCounterState; } /** * Count the labelled equations and the counted boxes of `blocks`, in * reading order, from the counters `start` carries (the preceding * chapters'). Pure: the content is not touched. */ export declare function numberStatements(blocks: readonly ContentBlock[], resolved: ResolvedConfig, start?: { headings?: HeadingCounters; counters?: StatementCounterState; }): StatementNumbering; /** What a reference inside a formula prints: `\eqref` the formatted * number, `\ref` the bare one; `?` for a label nothing numbers. */ export type CountedLookup = (id: string) => { number: string; label: string; } | undefined; /** `\eqref{x}` / `\ref{x}` in a formula's TeX replaced by the number they * name, as text. */ export declare function resolveMathRefs(tex: string, lookup: CountedLookup): string; /** * The content with the numbers written in (see the module comment). The * blocks `numbering` counted are found by their key (a formula's source * start, a fence's container id), so the content may have gained blocks * since it was counted (an expanded `:::toc`). `lookup` resolves a * reference inside a formula that names a target of another chapter. */ export declare function applyStatementNumbering(blocks: readonly ContentBlock[], numbering: StatementNumbering, resolved: ResolvedConfig, lookup?: CountedLookup): ContentBlock[]; /** The targets a book outline's counted anchors name, for references * inside formulas to another chapter. */ export declare function outlineLookup(targets: ReadonlyMap | undefined): CountedLookup | undefined; /** A box's end mark flush right on its block's last line (#530): the space * before it widened to the measure, or, on a line the mark has to itself, * a space set before it. A line read in another order (right-to-left * runs) keeps its setting. */ export declare function flushEndMark(measured: MeasuredBlock, mark: string, measureWidth: number): MeasuredBlock; //# sourceMappingURL=statementNumbering.d.ts.map