Created
June 17, 2024 20:07
-
-
Save VictorieeMan/32fa2e518a262e9bdfc1898da536a25a to your computer and use it in GitHub Desktop.
Latex symbols test code for python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# # import sympy as sp | |
# latex_symbols = ["\\alpha"] # list of LaTeX symbols | |
# # unicode_mapping = {latex: sp.preview(latex, viewer='file', output='unicode') for latex in latex_symbols} | |
# import sympy as sp | |
# def latex_to_unicode(latex_str): | |
# return sp.printing.latex2unicode(latex_str) | |
# # latex_symbols = [...] # list of LaTeX symbols | |
# unicode_mapping = {latex: latex_to_unicode(latex) for latex in latex_symbols} | |
from pylatexenc.latex2text import LatexNodes2Text | |
def latex_to_unicode(latex_str): | |
return LatexNodes2Text().latex_to_text(latex_str) | |
latex_symbols = ["\\alpha",r"\frac{a+2}{b}",r"\pi",r"\mathbb{7}"] # list of LaTeX symbols | |
unicode_mapping = {latex: latex_to_unicode(latex) for latex in latex_symbols} | |
print(unicode_mapping) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment