如何在sympy(jupyter笔记本)中将latex字符串显示为latex输出?

2024-05-14 13:04:54 发布

您现在位置:Python中文网/ 问答频道 /正文

我在Jupyter的序言是:

%reset
import numpy as np
from sympy import *
from sympy.physics.quantum import Commutator, Dagger, Operator
from sympy.vector import CoordSys3D
import matplotlib.pyplot as plt
from sympy.interactive import printing
printing.init_printing(use_latex = True)

如何以latex格式打印以下字符串?我非常不希望字符串中术语的顺序发生变化

'\\mathbf{R}_B \\cdot j'

Tags: 字符串fromimportnumpyasnpjupyterlatex
2条回答

this solution之后

from IPython.display import display, Math
display(Math('\\mathbf{R}_B \\cdot j'))

输出

enter image description here

所以答案是:

从IPython.display导入数学

display(Math('\\mathbf{R}_B \\cdot j'))

保留了符号的顺序。但是,'Math'没有属性'subs',并且无法进行sympy操作,因此似乎无法对此输出执行sympy操作

相关问题 更多 >

    热门问题