1

I would like to have the images side by side in pdf and html. I use the sphinx to generate the restructuredtext.

It would be good to look as follows: enter image description here

I have considered using csv-table, but it does not work well for the outlines around the images are awkward. .. csv-table:: :header: :widths: 60, 60

".. figure:: ../_static/1.png :width: 75mm :height: 75mm :align: left", ".. figure:: ../_static/2.png :width: 75mm :height: 75mm :align: right enter image description here

Ailsa90
  • 11
  • 2

2 Answers2

0

I suggest you fall back to the raw HTML output as this is very difficult, if not impossible to do in Restructed Text only.

.. raw:: HTML

   <div style="display: flex">
      <img src="_static/1.png">
      <img src="_static/2.png">
   </div>

You are going to need basic HTML skills to style it though.

Mikko Ohtamaa
  • 82,057
  • 50
  • 264
  • 435
-1

You can try using an extension that supports grids, like the following:

  • Thanks a lot. It is useful for more than 2 figures. But when I use 2 figures, and installed "myst-parser syntax" as recommended, it does not work. Maybe there is something wrong with my config. Have you tried two figures? – Ailsa90 Dec 19 '22 at 08:13
  • I haven't used the extension, but there is a two image example at the bottom of the documentation: https://sphinx-subfigure.readthedocs.io/en/latest/ You could try opening an issue and seeing if they will add the example code used in the examples. – Jared Dillard Dec 19 '22 at 23:29
  • That is a good idea. Thanks a lot. I have open an issue in https://github.com/chrisjsewell/sphinx-subfigure/issues. – Ailsa90 Dec 22 '22 at 09:30