LaTeX equations do not render in google Colaboratory when using IPython.display.Latex

五迷三道 提交于 2019-12-03 14:33:13

You can get the Latex to render by including the MathJax library.

from IPython.display import Math, HTML
display(HTML("<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.3/"
               "latest.js?config=default'></script>"))

Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx')

A similar questions was asked here: Rendering LaTeX in output cells in Colaboratory

酒井 敦

As an alternative, the following description should work on text cell on Colab.

\begin{equation}

F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx

\end{equation}

I came across this question unaware of the markdown cell way of rendering latex. So in case someone is looking for that ...

As an easier alternative, Latex can be rendered directly using the text cells feature of Google-colab notebooks.

For example, the following text when entered into a text cell renders as shown, A

python notebook 

Equation 1
$$\frac{sin(x)}{x}$$

foo bar 

Equation 2
\begin{equation}
F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx
\end{equation}

When rendered by colab, it becomes:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!