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 中呈现
基础教程推荐
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
