55

前者は Unicode バージョンのみを印刷しpprintprint後者はきれいな印刷を行いません。

from sympy import symbols, Function
import sympy.functions as sym
from sympy import init_printing
init_printing(use_latex=True)
from sympy import pprint
from sympy import Symbol

x = Symbol('x')

# If a cell contains only the following, it will render perfectly.
(pi + x)**2

# However I would like to control what to print in a function, 
# so that multiple expressions can be printed from a single notebook cell.
pprint((pi + x)**2)
4

4 に答える 4

33

問題は init_printing ステートメントにあります。ノートブックでは、ラテックスを実行したくない場合は、代わりに mathjax を使用する必要があるため、代わりにこれを試してください。

init_printing(use_latex='mathjax')

これを使用すると、セルの最後の行として sympy 式がある場合でも、どこでも通常のきれいな印刷が得られます。

于 2014-07-26T16:44:34.633 に答える