docs for muutils v0.6.17
View Source on GitHub

# muutils.nbutils.print_tex

quickly print a sympy expression in latex

View Source
View on GitHub

     1"""quickly print a sympy expression in latex"""
     2
     3import sympy as sp  # type: ignore
     4from IPython.display import Math, display  # type: ignore
     5
     6
     7def print_tex(
     8    expr: sp.Expr,
     9    name: str | None = None,
    10    plain: bool = False,
    11    rendered: bool = True,
    12):
    13    """function for easily rendering a sympy expression in latex"""
    14    out: str = sp.latex(expr)
    15    if name is not None:
    16        out = f"{name} = {out}"
    17
    18    if plain:
    19        print(out)
    20    if rendered:
    21        display(Math(out))

def print_tex( expr: sympy.core.expr.Expr, name: str | None = None, plain: bool = False, rendered: bool = True):
View Source
View on GitHub

     8def print_tex(
     9    expr: sp.Expr,
    10    name: str | None = None,
    11    plain: bool = False,
    12    rendered: bool = True,
    13):
    14    """function for easily rendering a sympy expression in latex"""
    15    out: str = sp.latex(expr)
    16    if name is not None:
    17        out = f"{name} = {out}"
    18
    19    if plain:
    20        print(out)
    21    if rendered:
    22        display(Math(out))

function for easily rendering a sympy expression in latex