Image grid in reStructuredText / Sphinx

jeremiahbuddha picture jeremiahbuddha · Apr 19, 2012 · Viewed 10.2k times · Source

I'm using Sphinx to create documentation for a Python project I'm working on. I have three images I would like to display in a 1x3 grid (i.e. all on the same line), and I'm trying to figure out how to do this in reStructuredText. Right now I have

.. image:: _images/report_title.png

.. image:: _images/report_slide1.png

.. image:: _images/report_slide2.png

I thought about trying to build one of the reST tables around them on a single line, but that seemed a little ridiculous. How can I grid these images?

Answer

Chris picture Chris · Apr 19, 2012

You can specify the width option for each of your images (see the reStructuredText image directive documentation) to be approximately one third or less of the width of the page.

Try, for example

.. image:: _images/report_title.png
   :width: 30%
.. image:: _images/report_slide1.png
   :width: 30%
.. image:: _images/report_slide2.png
   :width: 30%

The lengths allowed in the width (and height) options are discussed here (they essentially correspond to the length units in CSS documents).