maroba
maroba

Reputation: 65

Resolution of math expressions Sphinx / imgmath

I'm using sphinx.ext.imgmath to include mathematical expressions in my Python project documentation. It's working, but the resolution of the produced images is quite low. How can I make it produce images with higher resolution?

Upvotes: 3

Views: 549

Answers (1)

lvdhorst
lvdhorst

Reputation: 78

With imgmath you can use either the png or svg format. In my experience, svg has a better resolution by default. You can enable it in your Sphinx config.py by defining the variable

imgmath_image_format = 'svg'

You may need to adjust the math font size. This can be done using

imgmath_font_size = 14  # for font size 14

If you really need png, then you can override the default settings for the dvipng application which is used by imgmath. The corresponding variable for conf.py is

imgmath_dvipng_args = ['-gamma', '1.5', '-D', '110', '-bg', 'Transparent']

which is the default. Those are key value pairs for dvipng. -D means output resolution, and its value is 110. You can increase it, but that makes the whole displayed image bigger as well. So you have to fiddle with the font size. For other dvipng options, use its command line help.

All in all, I recommend using svg. :-)

Upvotes: 2

Related Questions