LaTeX (amsmath). The format that lands in a journal.
Verbose source and a toolchain to compile it, in exchange for being the one
target a paper actually accepts. CI compiles every example with a two-package
TeX, which is also a check that the preamble stays installable from a small one.
See :class:math_spec.typesetting.format.Format.
Source code in src/math_spec/typesetting/latex.py
| def apply(self, function: str, argument: str) -> str:
return f'{function}({argument})'
|
Source code in src/math_spec/typesetting/latex.py
| def cardinality(self, inner: str) -> str:
return rf'\lvert {inner} \rvert'
|
Source code in src/math_spec/typesetting/latex.py
| def document(self, blocks: list[str], *, standalone: bool) -> str:
body = '\n\n'.join(blocks) + '\n'
return f'{_PREAMBLE}\n{body}\n\\end{{document}}\n' if standalone else body
|
Source code in src/math_spec/typesetting/latex.py
| def equations(self, lines: list[Line], *, numbered: bool) -> str:
environment = 'align' if numbered else 'align*'
rows = [
f'{self.prose(line.label) if line.label else ""} && {line.left} & {line.right} && {line.condition}'.rstrip(
' &'
)
for line in lines
]
body = ' \\\\\n'.join(rows)
return f'\\begin{{{environment}}}\n{body}\n\\end{{{environment}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def escape(self, prose: str) -> str:
return _escape(prose)
|
Source code in src/math_spec/typesetting/latex.py
| def fraction(self, numerator: str, denominator: str) -> str:
return rf'\frac{{{numerator}}}{{{denominator}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def glossary(self, title: str, entries: list[Entry]) -> str:
rows = '\n'.join(rf'\item[{self.math(e.symbol)}] {e.meaning(self.dash)}' for e in entries)
return f'\\paragraph{{{title}}}\n\\begin{{description}}\n{rows}\n\\end{{description}}'
|
Source code in src/math_spec/typesetting/latex.py
| def greek(self, name: str) -> str:
return f'\\{name}'
|
Source code in src/math_spec/typesetting/latex.py
| def italic(self, name: str) -> str:
return rf'\mathit{{{_escape(name)}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def joined(self, parts: list[str], operator: str) -> str:
return f' {operator} '.join(parts) if operator else r',\ '.join(parts)
|
Source code in src/math_spec/typesetting/latex.py
| def math(self, expression: str) -> str:
return f'${expression}$'
|
Source code in src/math_spec/typesetting/latex.py
| def mono(self, text: str) -> str:
return rf'\texttt{{{_escape(text)}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def note(self, text: str) -> str:
return f'\\noindent {text}'
|
Source code in src/math_spec/typesetting/latex.py
| def parenthesise(self, inner: str) -> str:
return rf'\left( {inner} \right)'
|
Source code in src/math_spec/typesetting/latex.py
| def prose(self, text: str) -> str:
return rf'\text{{{_escape(text)}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def script(self, letter: str) -> str:
return rf'\mathcal{{{letter}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def section(self, title: str, body: str) -> str:
return f'\\paragraph{{{title}}}\n{body}'
|
Source code in src/math_spec/typesetting/latex.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/latex.py
| def summation(self, domain: str, body: str) -> str:
return rf'\sum_{{{domain}}} {body}'
|
Source code in src/math_spec/typesetting/latex.py
| def superscript(self, base: str, tail: str) -> str:
return f'{base}^{{{tail}}}'
|
Source code in src/math_spec/typesetting/latex.py
| def upright(self, name: str) -> str:
return rf'\mathrm{{{_escape(name)}}}'
|