'How to pretty print to a file in sympy?
Suppose I have the following code:
import sympy as sp
from sympy.physics.quantum import TensorProduct
s=sp.eye(2)
a=TensorProduct(s*x,TensorProduct(s,s)).subs(x,x**2+2*x+1)
sp.pprint(a)
The code will generate an output with a limited widths (which I hate):
My questions are:
- Why there is a width limit while my window has enough space and how to change it?
- How to print such an output to a file?
Solution 1:[1]
sp.preview(a, viewer='file', filename="out.png", dvioptions=['-D','300'])
Would allow you to save the expression as LaTeX/png/pdf.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | idanp |

