具有上下索引的方程的 Smypy 打印格式

问题描述

我有一个类似这样的代码

print("Gamma^",syms[i],"_",syms[j],syms[k],"=",syms[1],syms[2]**2)

当我在 jupyter-lab 中打印时,它看起来像这样

Gamma^ r _ phi phi = r theta**2
Gamma^ theta _ r theta = r theta**2
Gamma^ theta _ theta r = r theta**2
Gamma^ theta _ phi phi = r theta**2
Gamma^ phi _ r phi = r theta**2
Gamma^ phi _ theta phi = r theta**2
Gamma^ phi _ phi r = r theta**2
Gamma^ phi _ phi theta = r theta**2

有没有办法让它变成这样

enter image description here

或至少非常相似

解决方法

我能够获得类似的东西

Gamma = IndexedBase('Gamma')
phi,theta,r = symbols('phi,r')
display(Eq(Gamma[phi,theta]**phi,r*theta**2))

enter image description here