!pip install --upgrade sympy
from sympy import *
def custom_latex_printer(expr, **options):
from IPython.display import Math, HTML
from google.colab.output._publish import javascript
url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-AMS_CHTML"
javascript(content="""window.MathJax = {
tex2jax: {
inlineMath: [ ['$','$'] ],
processEscapes: true
}
};""")
javascript(url=url)
return latex(expr, **options)
init_printing(use_latex="mathjax", latex_printer=custom_latex_printer)
Latex output from sympy does not correctly display in Google Colaboratory Jupyter notebooks - Stack Overflow Die gängigsten Suchmethoden wie sympy1.4 oder höher reichen nicht aus.
Release Notes for 1.4 · sympy/sympy Wiki · GitHub
- By default, LaTeX output in the Jupyter notebook is framed with $\displaystyle ...$. This prevents it from being centered in PDF output from nbconvert (see https://github.com/jupyter/notebook/issues/4060). (#15625 by @mgeier)
(Die LaTex-Ausgabe verwendet standardmäßig den Inline-Formelmodus.)
Recommended Posts