I'm trying to save images of a formula, which I have written in LaTeX. Here's the formula:
triple_integral_formula = r"$$1)\int_{0}^{2\pi}\int_{0}^{\frac{\pi}{4}}\int_{0}^{3}\rho^2sin(\phi)d\rho d\phi d\theta$$"
I am using SymPy to save the images to later display on a PDF using reportlab. This is the code I have so far to do that:
preview(triple_integral_formula, viewer='file', filename='triple_integral.png', euler=False, dvioptions=["-T", "tight", "-z", "0", "--truecolor", "-D 600", "-bg", "Transparent"])
Here is the image output:
It might be hard to see because of the transparent background but all works well and it's saving the image properly. The only problem is that I want these images to be a certain width. From what I've read so far, the -D 600
section of the dvioptions list sets the "density", which I interpreted as the resolution. I tried to look online to find all of the different options that you can put inside the dvioptions list but couldn't find anything for setting width.
How can I accomplish this? Is a better way to display LaTeX formulas on a PDF (using reportlab or otherwise)?
\sin
etc to get correct spacing and font