简体   繁体   English

reStructuredText / Sphinx 中的图像网格

[英]Image grid in reStructuredText / Sphinx

I'm using Sphinx to create documentation for a Python project I'm working on.我正在使用 Sphinx 为我正在处理的 Python 项目创建文档。 I have three images I would like to display in a 1x3 grid (ie all on the same line), and I'm trying to figure out how to do this in reStructuredText.我想在 1x3 网格中显示三张图像(即全部在同一行),我试图弄清楚如何在 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.我曾想过尝试在一行中围绕它们构建一个 reST 表,但这似乎有点荒谬。 How can I grid these images?如何网格化这些图像?

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.您可以将每个图像的width选项(请参阅reStructuredText 图像指令文档)指定为页面宽度的大约三分之一或更小。

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). 这里讨论了宽度(和高度)选项中允许的长度(它们基本上对应于CSS文档中的长度单位)。

The alternate answer is to use directives as aliases to the image.另一个答案是使用指令作为图像的别名。

.. |logo| image:: ../iamges/wiki_logo_openalea.png
   :width: 20pt
   :height: 20pt

Then use the alias inside a table:然后在表中使用别名:

 +---------+-----------+
 | |logo|  +  |logo2|  +
 +---------+-----------+

For the aliasing, I had better luck with:对于混叠,我有更好的运气:

.. |logo1| image:: logo1.png    
   :scale: 100%
   :align: middle
.. |logo2| image:: logo2.png
   :scale: 50%
   :align: top

+---------+---------+
| |logo1| | |logo2| |
+---------+---------+

I provide another reference.我提供另一个参考。 If you want to place puml you can try如果你想放置puml你可以试试

    +---------------------+----------------------+
    | .. uml:: class.puml | .. uml:: class.puml  +
    |    :scale: 100%     |     :scale: 100%     +
    +---------------------+----------------------+

Use a list-table without border::使用无边框列表::

.. list-table:: simple image grid
   :class: borderless

   * - .. image:: _images/report_title.png
     - .. image:: _images/report_slide1.png
     - .. image:: _images/report_slide2.png

Works also with "figure" directives, if you want a caption.如果您想要标题,也可以与“figure”指令一起使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM