You can use the makefile to automatically build the appropriate output formats.
A tutorial is also available demonstrating a similar process for using Sphinx with SVG and LaTeX PDF output .
Use the file wildcard parameter in the .rst source.
.. image:: my_image.*
Use Inkscape to convert source images to PDF and PNG files at build time. You can do this automatically during build by adding the following code to your Makefile:
SOURCEDIR = source
Finally, update the clean , latex and latexpdf to be dependent on the corresponding image goals:
... clean: clean-images ... html: images-png ... latex: images-pdf ... latexpdf: images-pdf ...
Now you can create your images by typing make images and cleaning them with make clean-images . Using make html , make latex and make latexpdf will automatically make sure your images are up to date.
One problem is that Sphinx, by default, prefers SVG over PNG in HTML output. You can fix this by overriding preferences in your conf.py file.
After importing, add the following lines at the top of your conf.py file.
# Redefine supported_image_types for the HTML builder from sphinx.builders.html import StandaloneHTMLBuilder StandaloneHTMLBuilder.supported_image_types = ['image/png', 'image/svg+xml', 'image/gif', 'image/jpeg']
Nickf source share