Question

Is there a way to put 2 different images on the same "line", so, side-by side?

I know there is the :align: option, but if I put two images, the first with :align: left and the second with :align: right it doesn't work, because the latter is put in another paragraph.

Was it helpful?

Solution 5

Try this:

.. class:: center

This text is centered

OTHER TIPS

I used substitution definitions:

|pic1| any text |pic2|

.. |pic1| image:: img1.png
   :width: 45%

.. |pic2| image:: img2.png
   :width: 45%
.. list-table:: 

    * - .. figure:: ../_static/1repren.png

           Fig 1. Representations

      - .. figure:: ../_static/5transparency.png

           Fig 2. Transparency
    * - .. figure:: ../_static/9ele.png

           Fig 3. Electrostatics

      - .. figure:: ../_static/11R3D.PNG.png

           Fig 4. R3D

You want the images to be part of the same paragraph and you want them to split the width of the screen so do something like this:

.. image:: im1.jpg
    :width: 50 %
.. image:: im2.jpg
    :width: 50 %

This doesn't exactly work, there will be some spacing between the 2 images which will put the total width >100%. A simple workaround is setting the widths to 49%. Doing so, below is the output with the unformatted image above to compare: RenderedImages

More reading: reST docs on Images

To make this snippet (mentioned above by @fiona) work you need to declare | pic | before referencing it.

.. |pic1| image:: img1.png
   :width: 45%

.. |pic2| image:: img2.png
   :width: 45%

|pic1| any text |pic2|
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top