Spenso · latest
On this page

to_svg

symbolica.community.tensor Function

to_svg(expression: Expression, show_dimensions: Optional[bool] = None, *, settings: Optional[DisplaySettings] = None, notation_source: Optional[str] = None) -> str

Render static mathematical tensor notation to SVG.

Parameters

expression Expression

Symbolica tensor syntax or scalar algebra to display. For a TensorExpression or component Tensor, prefer its formatting methods.

show_dimensions bool, optional

Override settings.show_dimensions for this call. None retains the selected settings, whose default omits dimensions.

settings DisplaySettings, optional

Tensor notation and display choices. Defaults to DisplaySettings().

notation_source str, optional

Custom Typst notation source used by the rich renderer. This is Typst code, not a filename; omit it for the supplied tensor notation.

Returns

str

SVG markup suitable for embedding or saving to a file.

Notes

SVG export uses the optional Python package typst (typst-py). Pass the returned markup to the notebook's SVG display facility.

# Errors

Returns ImportError if optional typst-py is unavailable, or RuntimeError if compilation fails. Registered Python printer exceptions are logged and decline the override, allowing native fallback.

Examples

from symbolica import S
expression = S("x") + 1
from symbolica.community.tensor import to_svg
output = to_svg(expression)