Print a spec as math#
Turn a spec file into the math a paper would print, from the file alone, and keep the document current as the file changes.
- Print Markdown first and read it:
- Give the symbols their conventional spelling with a symbol table beside
the spec,
spec.symbols.yaml. Without one,loadprints as \(\mathrm{load}_t\); with one it prints as whatever you write:
notation: latex
dimensions:
snapshot: { index: s, set: "\\mathcal{S}" }
generator: { index: g, set: "\\mathcal{G}" }
names:
cost: c
load: "\\ell"
capacity: "\\bar p"
A key naming nothing in the spec is an error.
- Emit a document that compiles.
--standalonewraps the fragment in a preamble, so the output builds on its own:
python -m mathspec latex spec.yaml --symbols spec.symbols.yaml --standalone -o spec.tex
python -m mathspec typst spec.yaml --standalone -o spec.typ
Then tectonic spec.tex or typst compile spec.typ. A symbol table is
written for one notation, so the Typst render takes a table with
notation: typst or none. Without --standalone the output is a fragment
to \input or #include into a paper.
- Print the rows a curve or a set states with
--expand:
The same table serves both renders: a name the expansion emits, such as
cost_curve_lam, may be spelled in it.
- Keep it current with a rule in the paper's build:
spec.tex: spec.yaml spec.symbols.yaml
python -m mathspec latex $< --symbols spec.symbols.yaml --standalone -o $@
Typeset the math lists every option and what a symbol table may say.