See :class:math_spec.typesetting.format.Format.
The cyclic operators spell with .o, Typst's circled modifier;
minus.circle does not compile.
Source code in src/math_spec/typesetting/typst.py
| def apply(self, function: str, argument: str) -> str:
return f'{function}({argument})'
|
Source code in src/math_spec/typesetting/typst.py
| def cardinality(self, inner: str) -> str:
return f'abs({inner})'
|
Source code in src/math_spec/typesetting/typst.py
| def cases(self, arms: list[tuple[str, str]]) -> str:
return 'cases({})'.format(self.cases_row.join(f'{value} & {condition}' for value, condition in arms))
|
No preamble/body split: standalone only adds the page setup.
Source code in src/math_spec/typesetting/typst.py
| def document(self, blocks: list[str], *, standalone: bool) -> str:
"""No preamble/body split: ``standalone`` only adds the page setup."""
body = paragraphs(blocks)
return f'{_PREAMBLE}\n{body}' if standalone else body
|
A block equation, aligned on & as amsmath does.
Source code in src/math_spec/typesetting/typst.py
| def equations(self, lines: list[Line], *, numbered: bool) -> str:
"""A block equation, aligned on ``&`` as amsmath does."""
body = ' \\\n '.join(aligned_rows(lines, self, gap=' & '))
numbering = '#set math.equation(numbering: "(1)")\n' if numbered else ''
return f'{numbering}$ {body} $'
|
Source code in src/math_spec/typesetting/typst.py
| def escape(self, prose: str) -> str:
return _escape(prose)
|
Source code in src/math_spec/typesetting/typst.py
| def fraction(self, numerator: str, denominator: str) -> str:
return f'frac({numerator}, {denominator})'
|
Source code in src/math_spec/typesetting/typst.py
| def glossary(self, title: str, entries: list[Entry]) -> str:
rows = '\n'.join(f'/ {self.math(e.symbol)}: {e.meaning}' for e in entries)
return f'== {title}\n{rows}'
|
Source code in src/math_spec/typesetting/typst.py
| def greek(self, name: str) -> str:
return name
|
Source code in src/math_spec/typesetting/typst.py
| def italic(self, name: str) -> str:
return f'italic({_quote(name)})'
|
Source code in src/math_spec/typesetting/typst.py
| def joined(self, parts: list[str], operator: str) -> str:
return f' {operator} '.join(parts) if operator else ', '.join(parts)
|
Source code in src/math_spec/typesetting/typst.py
| def math(self, expression: str) -> str:
return f'${expression}$'
|
Source code in src/math_spec/typesetting/typst.py
| def mono(self, text: str) -> str:
return _raw(text)
|
Source code in src/math_spec/typesetting/typst.py
| def note(self, text: str) -> str:
return text
|
Source code in src/math_spec/typesetting/typst.py
| def parenthesise(self, inner: str) -> str:
return f'({inner})'
|
Source code in src/math_spec/typesetting/typst.py
| def prose(self, text: str) -> str:
return f'upright({_quote(text)})'
|
Source code in src/math_spec/typesetting/typst.py
| def quoted(self, label: str) -> str:
in_quotes = f"'{label}'"
return f'upright({_quote(in_quotes)})'
|
Source code in src/math_spec/typesetting/typst.py
| def script(self, letter: str) -> str:
return f'cal({letter})'
|
Source code in src/math_spec/typesetting/typst.py
| def section(self, title: str, body: str) -> str:
return f'== {title}\n{body}'
|
Source code in src/math_spec/typesetting/typst.py
| def subscript(self, base: str, indices: list[str]) -> str:
return f'{base}_({",".join(indices)})' if indices else base
|
Source code in src/math_spec/typesetting/typst.py
| def summation(self, domain: str, body: str) -> str:
return f'sum_({domain}) {body}'
|
Source code in src/math_spec/typesetting/typst.py
| def superscript(self, base: str, tail: str) -> str:
return f'{base}^({tail})'
|
Source code in src/math_spec/typesetting/typst.py
| def upright(self, name: str) -> str:
return f'upright({_quote(name)})'
|