from keecas import format_value, symbols
# Define symbol with subscript
sigma_Rd = symbols(r"\sigma_{Rd}")
# Format symbol (LHS)
format_value(sigma_Rd) # Returns: '\sigma_{Rd}''\\sigma_{Rd}'
Format a value to LaTeX string using type-based dispatch.
This is the main entry point for formatting values in keecas equations. Dispatches to specialized formatters based on value type. For unhandled types, falls back to sympy.latex().
value : Any Value to format (any type) col_index : int, optional Column index - 0 for LHS, 1+ for RHS (default: 0) Kept for API consistency but not used by default formatters **kwargs Additional arguments passed to latex() function (e.g., mul_symbol, mode, fold_frac_powers)
str LaTeX string representation
'\\sigma_{Rd}'
To register custom type formatters:
Supported types (built-in registrations): - str: Plain text wrapped in - int: Integer to LaTeX string - float: Float to LaTeX string - IPython.display.Markdown: Wrapped in - pint.Quantity: Converted to SymPy, then formatted - sympy.Mul: Numeric/unit separation, then formatted as Basic - sympy.Basic: LaTeX via sympy.latex()
format_str : String formatter format_int : Integer formatter format_float : Float formatter format_sympy : SymPy expression formatter