LaTeX Output¶
Every expression in sft-wick can be rendered as publication-ready LaTeX.
The to_latex() Method¶
All expression types implement to_latex():
result = compute_moment(obs, action, order=1)
# Single expression
print(result.order(0).to_latex())
# e.g. "C_{ab}(x, y) C_{cd}(z, w) + ..."
# Full result (order by order)
print(result.to_latex())
# O(0): ...
# O(1): ...
Examples of LaTeX output for each expression type:
Expression |
LaTeX |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Custom Propagator Names¶
Use LaTeXFormatter to replace the default
propagator names C and R:
from sft_wick import LaTeXFormatter
fmt = LaTeXFormatter(propagator_names={
'C': 'G',
'R': r'R^{\mathrm{ret}}'
})
print(fmt.format(result.order(0)))
# G_{ab}(x, y) instead of C_{ab}(x, y)
Equation Formatting¶
format_equation() wraps an expression in an equation:
fmt.format_equation(r'\langle O \rangle', result.total)
# \langle O \rangle = <formatted expression>
Aligned Environment¶
format_aligned() generates a LaTeX align environment showing
each perturbative order on its own line:
print(fmt.format_aligned(result.order_terms))
Output:
\begin{align}
O(0) &= \ldots \\
O(1) &= \ldots \\
\end{align}
Integrating into Papers¶
The LaTeX output is designed to paste directly into .tex documents.
Typical workflow:
Run the calculation in a Python script or Jupyter notebook.
Call
to_latex()orformat_aligned()to get the LaTeX string.Paste into your paper inside a
\begin{equation}or\begin{align}environment.
Tip
In Jupyter notebooks, use IPython.display.Math to render
expressions inline:
from IPython.display import Math
Math(result.order(0).to_latex())