sft_wick.latex — LaTeX Formatting

LaTeX output formatting for Wick contraction results.

class sft_wick.latex.LaTeXFormatter(propagator_names=None)[source]

Bases: object

Configurable LaTeX output for expressions.

Allows overriding propagator display names, e.g. rendering C as G or R as \(R^{\mathrm{ret}}\).

Parameters:

propagator_names (dict[str, str] | None) – Mapping from internal kind ("C", "R") to the desired LaTeX display name. Defaults to identity.

format(expr)[source]

Format an expression as LaTeX, applying name substitutions.

Parameters:

expr (Expr) – The expression to format.

Returns:

A LaTeX string with propagator names replaced.

Return type:

str

format_equation(lhs, expr)[source]

Format as a LaTeX equation: lhs = rhs.

Parameters:
  • lhs (str) – Left-hand side string (e.g. r"\langle O \rangle").

  • expr (Expr) – Right-hand side expression.

Returns:

A string of the form "lhs = <formatted rhs>".

Return type:

str

format_aligned(terms)[source]

Format order-by-order as a LaTeX align environment.

Parameters:

terms (dict[int, Expr]) – Mapping from perturbative order to expression, typically PerturbativeResult.order_terms.

Returns:

A complete \begin{align}...\end{align} LaTeX block.

Return type:

str