In a regular jupyter notebook, running, for example, the following:
from IPython.display import display, Math, Latex
display(Math(r'F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx'))
produces an equation rendered in LaTeX (via Mathjax).
Even though LaTeX works fine in markdown cells, LaTeX equations produced as above do not seem to render in Google Colaboratory.
The same happens to the output of functions for example from qutip, which would normally render in latex (for example, qutip.basis(2, 0)
would normally render in latex, but doesn't in Colaboratory).
Why does this happen? Is there a way to have this work?
As an easier alternative, Latex can be rendered directly using the text cells feature of Google-colab notebooks. Show activity on this post.
The Jupyter Notebook uses MathJax to render LaTeX inside HTML / Markdown. Just put your LaTeX math inside $ $ . Or enter in display math mode by writing between $$ $$ . The [n] is optional.
One of the most popular is Jupyter Notebook that uses MathJax to render the Latex syntax inside the markdown/HTML. To use LaTeX in the Jupyter notebook, put the Latex math content inside the '$ … $' double '$$ … $$' symbols.
Update (April / 2021):
It's possible to write formulas in Colab just putting them between $
symbols, with no need to import libraries:
$F(k) = \int_{-\infty}^{\infty} f(x) e^{2\pi i k} dx$
Old answer
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}
An alternative is to use it as markdown with githubusercontent (source) instead a codeline on Colab, add a text (markdown text) and then to use the next line. e.g.
<img src="https://render.githubusercontent.com/render/math?math=e^{i \pi} = -1">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With