Latex output from sympy does not correctly display in Google Colaboratory Jupyter notebooks

后端 未结 3 1676
夕颜
夕颜 2021-01-11 16:19

I am using Google\'s Colaboratory platform to run python in a Jupyter notebook. In standard Jupyter notebooks, the output of sympy functions is correctly typeset Latex, but

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 16:36

    You need to include MathJax library before display. Set it up in a cell like this first.

    from google.colab.output._publish import javascript
    url = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/latest.js?config=default"
    

    Later, you include javascript(url=url) before displaying:

    x=sp.symbols('x')
    a=sp.Integral(sp.sin(x)*sp.exp(x),x)
    javascript(url=url)
    a
    

    Then, it will display correctly.

提交回复
热议问题