Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 387
Daniel Avatar asked May 09 '13 13:05

Daniel


People also ask

How do you use a sphinx code block?

Literal code blocks (ref) are introduced by ending a paragraph with the special marker :: . The literal block must be indented (and, like all paragraphs, separated from the surrounding ones by blank lines): This is a normal text paragraph.


2 Answers

I have found that figures float to the side with :figwidth: and :align: specified. (Using the readthedocs theme.)

..  figure:: images/myimage.jpg
    :figwidth: 40%
    :align: right

https://docutils.sourceforge.io/docs/ref/rst/directives.html#figure

like image 149
jjz Avatar answered Sep 21 '22 15:09

jjz


Though it is too late but maybe the answer would help future people.

You can use the sidebar directive to put the image.

.. sidebar:: mandatory_title. Use can use image caption here

     .. Figure:: 1.png
like image 44
shubham Avatar answered Sep 21 '22 15:09

shubham