LaTeX equations do not render in google Colaboratory when using IPython.display.Latex(使用 IPython.display.Latex 时,LaTeX 方程不会在谷歌 Colaboratory 中呈现)
问题描述
在常规的 jupyter 笔记本中,运行例如以下内容:
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^{2pi i k} dx'))
生成一个用 LaTeX 渲染的方程(通过 Mathjax).
produces an equation rendered in LaTeX (via Mathjax).
尽管 LaTeX 在 markdown 单元格中运行良好,但如上生成的 LaTeX 方程似乎无法在 Google Colaboratory 中呈现.同样的情况也发生在函数的输出上,例如来自 qutip 的函数,它通常会在乳胶中呈现(例如,qutip.basis(2, 0) 通常会在乳胶中呈现,但不会在 Colaboratory).
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?
推荐答案
更新(2021 年 4 月):
可以在 Colab 中编写公式,只需将它们放在 $ 符号之间,无需导入库:
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^{2pi i k} dx$
旧答案
作为替代方案,以下描述应适用于 Colab 上的文本单元格.
As an alternative, the following description should work on text cell on Colab.
egin{equation}
F(k) = int_{-infty}^{infty} f(x) e^{2pi i k} dx
end{equation}
这篇关于使用 IPython.display.Latex 时,LaTeX 方程不会在谷歌 Colaboratory 中呈现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 IPython.display.Latex 时,LaTeX 方程不会在谷歌 Colaboratory 中呈现
基础教程推荐
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 包装空间模型 2022-01-01
- 求两个直方图的卷积 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
