I use Python-Sphinx to document some Python code I wrote. I'm using the pngmath extension to render LaTeX math expressions. The problem is, the background-color of the rendered images is white and the background color on which the images are shown differs from page to page. I can set the background color with


but there does not seem to be a transparent color. How can I make the background color of the images transparent?

  • If I understand this correctly, there is no transparent background color. The transparency needs to be a property of the image itself. – Peter Grill Jan 10 '12 at 6:27

Adding -bg Transparent to dvipng works fine.


The Python-Sphinx documentation says

When you “add” an argument, you need to reproduce the default arguments if you want to keep them; that is, like this:

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

-- Math support in Sphinx

But in the configuration file, this has to be

pngmath_dvipng_args = ['gamma', '1.5', '-D', '110', '-bg', 'Transparent']
# or
pngmath_dvipng_args = 'gamma 1.5 -D 110 -bg Transparent'.split()
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.