latexify-py: Generate LaTeX Formulas from Python Functions
latexify-py is a Python library that converts Python functions into LaTeX mathematical expressions, allowing you to install it via pip, check its version, decorate functions like a quadratic solver with @latexify.function to obtain both numeric results and the corresponding LaTeX formula, with source code available on GitHub.
latexify-py is a Python library that automatically converts Python functions into LaTeX mathematical expressions, making it easy to display complex equations.
Install the package:
pip install latexify-pyCheck the installed version:
import latexify
latexify.__version__Example usage: define a quadratic‑solver function and decorate it with @latexify.function . The ordinary call returns the numeric result, while the decorated function yields the LaTeX formula.
@latexify.function
def solve(a, b, c):
return (-b + math.sqrt(b**2 - 4*a*c)) / (2*a) print(solve(1, 4, 3)) # -1.0
print(solve) # \mathrm{solve}(a, b, c) = \frac{-b + \sqrt{b^{2} - 4 a c}}{2 a}For more information and source code, visit the GitHub repository: https://github.com/google/latexify_py
Java Tech Enthusiast
Sharing computer programming language knowledge, focusing on Java fundamentals, data structures, related tools, Spring Cloud, IntelliJ IDEA... Book giveaways, red‑packet rewards and other perks await!
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.