Skip to main content

Links and citations

<a to="eq-var">Equation (2)</a>
<a href="https://doi.org/10.1093/mnras/stag2029">the archived release</a>
AttributeMeaning
toThe id of an element to jump to
hrefAn external URL

<a> needs one of the two (link error). If both are present, to wins.

Internal destinations are resolved after drawing, not during layout. That is why a forward reference needs no second compile pass: every id is already drawn by the time annotations are written.

A pointer that reaches nothing is an error (dangling-link). It is reported at compile time, not deferred to the PDF.

<h2 id="results">{label()} Results</h2>
…
<p>As shown in <a to="results">the results</a>.</p>

Ids are available on headings, paragraphs, images, tables, divs and pages. Duplicate ids are an error (duplicate-id); an id in a header or footer is an error (id-in-page-part).

The bibliography is authored​

A bibliography is a <bib> holding component instances. The component's props are the record schema:

// bibliography.mtx
from "./entry.mtx" import component { Entry };

export component Bibliography {
return (
<bib>
<Entry id="jin2026" short="Jin et al. (2026)"
author="Jin M., Zhu F.-R., Zong P., Zhang B."
year="2026" journal="MNRAS" volume="553" pages="stag2029" />
<Entry id="gupta2024" short="Gupta and Okafor (2024)"
author="Gupta R., Okafor C."
year="2024" journal="Phys. Rev. E" volume="109" pages="045301" />
</bib>
);
}
// entry.mtx
export component Entry {
prop id: string;
prop short: string;
prop author: string;
prop year: string;
prop journal: string;
prop volume: string;
prop pages: string;

return (
<p id={id} font-size={8} leading={1.2}>
{author} ({year}). {journal} {volume}, {pages}.
</p>
);
}

The rules collect enforces:

  • one <bib> per source (bib-twice);
  • a <bib> may hold only component instances (bib-child);
  • every record needs a literal id of type string (bib-id);
  • duplicate keys are errors;
  • the rendered element must write id={id}, or pointers to it dangle;
  • the record component must not import a generated module.

<bib> itself carries no names. The store's name comes from configuration.

Generated stores​

collect writes one module per citable kind, including the bibliography:

// gen/refs.g.mtx
export type Refs = "jin2026" | "gupta2024";
export const refs = {
"jin2026": { label: "1", short: "Jin et al. (2026)", … },
"gupta2024": { label: "2", short: "Gupta and Okafor (2024)", … },
};

The union is the point: a citation's to prop can be typed as Refs, so an id that does not exist is a type error before layout:

from "./gen/refs.g.mtx" import type { Refs };
from "./gen/refs.g.mtx" import const { refs };

export component Cite {
prop to: Refs;
return <a to={to}>{refs[to].short}</a>;
}
<p>Implementations differ mostly in storage <Cite to="jin2026" />.</p>

<Cite to="jin27" /> fails to resolve, because jin27 is not in the union.

Formatting is a component​

There is no bibliography style switch and no citation format setting. The printed form is whatever the component writes:

export component CiteAuthor {
prop to: Refs;
const record = refs[to];
return <a to={to}>{record.author} ({record.year})</a>;
}

Swapping the component changes the style for the whole project. The alias short cannot be derived from author and year — “et al.” for three or more, “and” for two, a bare surname for one is a conditional — so it is authored once per record.

Store names​

Where stores live, and what their types and consts are called, comes from configuration:

{
"generated": {
"dir": "gen",
"kinds": { "figures": "fig", "tables": "tab", "equations": "eq", "headings": "head" },
"refs": { "const": "refs", "type": "Refs" }
}
}
KindDefault fileDefault typeDefault const
figuresgen/fig.g.mtxFigurefigures
tablesgen/tab.g.mtxTabletables
equationsgen/eq.g.mtxEquationequations
headingsgen/head.g.mtxHeadingheadings
refsgen/refs.g.mtxRefsrefs

Generated files are ordinary source. Commit them: the union is only useful to an editor if it exists before the next build.