Search code examples
python-sphinxrestructuredtext

How to create floating figures in reStructuredText / Sphinx?


I want to have a figure with text wrapped around it.

This is what I'm saying:

Installation of Optional Accessories
====================================

.. warning:: Never plug in or unplug a Hand Robot or a Grasp Sensor while the robot is turned on, as the system will not function properly and damage to the robot could occur.

Installing a Hand Robot
-----------------------

.. _`fig-attach-hand-robot`:
.. figure:: attach-hand-robot.*
  :scale: 40%
  :align: right

  Attach Hand Robot

Make sure the robot is turned off as described in the section :ref:`turn-off-robot`. 

Take the hand robot out of the grounded bin that sits on top of the electrical panel (if you have an adjustable height table) or sits on top of the rear table (if you have a fixed height table). Make sure not to touch the pins on the electrical wiring while doing so. Insert the conical protrusion of the hand robot into the conical receptacle (see :ref:`fig-attach-hand-robot`). Once the hand robot is supported by the InMotion Arm Robot, make sure the two knobs below the Hand Robot have engaged and sprung in. If they have not, twist them until they do as shown (see :ref:`fig-knobs-in`).


and this screenshot of PDF output is what I'm getting.

  • Why is the figure caption centered, rather than under the image?
  • Why isn't the body text ("Make sure ..." and "Take the ...") on the LEFT of the image, rather than underneath it? I want the figure to float right and have the text on its left.

Solution

  • So, I did some research into reStructuredText and it seems what you want is not actually possible.

    The documentation for the figure and the image directives never mention the ability to wrap text around the object.

    This might be a feature request to provide to the Sphinx developers although I suspect they'll reject it because it isn't explicitly mentioned in the rst specification.

    I was hoping the bounty would garner this some attention but I suspect is hasn't.