cottax.consumers.visualization.latex.text module

Names set as LaTeX: a Formatter whose spellings are LaTeX rendered into the markup every drawing here reads (naming.MARKUP), so one formatter serves the XDSMs, dot and the N2.

The supported LaTeX is the subset such markup can carry – sub- and superscripts, greek, upright / bold / script alphabets, accents as combining marks, the common relations and operators. Anything else is written through as upright text rather than raising, so an unknown macro is legible in the picture instead of failing the build.

A name is read as math (y_1 is already what LaTeX would set), unless it holds a $, in which case it alternates text / math as a LaTeX line does (Discipline $1$).

FALLBACK = frozenset({'′', 'ℏ', 'ℑ', 'ℓ', 'ℜ', '↦', '⇒', '∀', '∂', '∃', '∅', '∇', '∈', '∉', '∏', '∑', '∓', '∘', '∝', '∠', '∩', '∪', '∫', '∼', '≈', '≠', '≡', '≤', '≥', '⊂', '⊆', '⊕', '⊗', '⊥', '⋆', '⋯', '⟨', '⟩', '⟶'})

a renderer that cannot find a glyph draws nothing (g leq 0 once printed as g 0).

Type:

The symbols Latin Modern Roman does not carry, set in MATH_FACE as mathcal is

SPACE = {' ': ' ', '!': '', ',': ' ', ':': ' ', ';': ' ', 'qquad': '  ', 'quad': ' '}

Spacing macros. ! is negative and has no counterpart, so it is dropped.

MATH_FACE = 'STIXGeneral, serif'

a text face carries none of them, and a renderer that cannot find a glyph draws nothing rather than reaching for another font.

Type:

The face mathcal, mathbb, lowercase greek and FALLBACK are set in

ARGUMENT = frozenset({'acute', 'bar', 'bm', 'boldsymbol', 'breve', 'check', 'ddot', 'dot', 'grave', 'hat', 'mathbb', 'mathbf', 'mathcal', 'mathit', 'mathnormal', 'mathrm', 'mathscr', 'mathsf', 'operatorname', 'overline', 'text', 'textrm', 'tilde', 'vec', 'widehat', 'widetilde'})

The macros that take a braced argument, so _text{max} reads as one token.

latex_to_markup(s: str)[source]

A LaTeX-ish string as markup: all math without a $ (a variable name already is), alternating text / math from text mode with one.

Return type:

str

subscripted(name: str)[source]

A declared name as the notation it stands for: V1 is V_{1}, S1S2 is S_{1}S_{2}. An identifier cannot carry a subscript, so a digit against a letter is one; anything holding LaTeX of its own is the caller’s spelling and passes through.

Return type:

str

tex(s: str | None)[source]

A LaTeX string as a label a drawing sets rather than prints.

Return type:

str | None

class LatexFormatter(names: Mapping[str, str] | None = None, notation: Notations | None = None, spell: Callable[[Label], str] = spell_plain)[source]

Bases: Formatter

Every name spelt as LaTeX: names maps a plain spelling (spell, spell_plain by default) to the LaTeX that replaces it – {‘V1’: r’mathcal{D}_1’} – and anything not in it is read as LaTeX as it stands, digits made subscripts (subscripted).

A minted name given in names is named outright: drawn as given, and not under the notation of its purpose – {‘^solve.S1’: ‘S_1’} draws S_1. Every other minted name is written in its purpose’s notation, in LaTeX: notation by Mint class – {Solve: Around(r’S_{{}}’)} – else its MintDrawing’s, else as mathrm{<spelling>}(·).

spell(path: Label)[source]
Return type:

str

set(source: str)[source]
Return type:

str

label(text: str)[source]
Return type:

str

text(text: Text)[source]
Return type:

str

outright(path: Label)[source]
Return type:

bool

notation(m: Mint)[source]
Return type:

Notation