在 Ipython 输出中写入 Latex
Writing Latex in Ipython output
考虑 IPython 笔记本中的以下行:
B=1.0e5 # in Gauss
fce = 1.80e6 * B
print "Electron gyrofrequency $f_{ce}$= %0.5e " %(fce)
我无法让 $f_{ce}$ 以乳胶形式打印。我也试过:
from IPython.display import display, Math, Latex
display ("Electron gyrofrequency" + Math(r'f_{ce}') + "= %0.5e " %(fce))
我收到一个错误:
TypeError: cannot concatenate 'str' and 'Math' objects
您可以通过将其传递给 Latex
构造函数来呈现完整的乳胶字符串:
from IPython.display import Latex
B=1.0e5 # in Gauss
fce = 1.80e6 * B
Latex("Electron gyrofrequency $f_{ce}$= %0.5e " % fce)
考虑 IPython 笔记本中的以下行:
B=1.0e5 # in Gauss
fce = 1.80e6 * B
print "Electron gyrofrequency $f_{ce}$= %0.5e " %(fce)
我无法让 $f_{ce}$ 以乳胶形式打印。我也试过:
from IPython.display import display, Math, Latex
display ("Electron gyrofrequency" + Math(r'f_{ce}') + "= %0.5e " %(fce))
我收到一个错误:
TypeError: cannot concatenate 'str' and 'Math' objects
您可以通过将其传递给 Latex
构造函数来呈现完整的乳胶字符串:
from IPython.display import Latex
B=1.0e5 # in Gauss
fce = 1.80e6 * B
Latex("Electron gyrofrequency $f_{ce}$= %0.5e " % fce)