【问题标题】:How can I place images side-by-side in restructured text?如何将图像并排放置在重组文本中?
【发布时间】:2014-04-04 16:08:40
【问题描述】:

有没有办法将 2 个不同的图像放在同一“行”上,所以,并排?

我知道有:align: 选项,但如果我放两张图片,第一张带有:align: left,第二张带有:align: right,它不起作用,因为后者放在另一段中。

【问题讨论】:

    标签: restructuredtext text-alignment


    【解决方案1】:

    要使这个 sn-p(@fiona 上面提到的)工作,你需要声明 |图片 |在引用它之前。

    .. |pic1| image:: img1.png
       :width: 45%
    
    .. |pic2| image:: img2.png
       :width: 45%
    
    |pic1| any text |pic2|
    

    【讨论】:

      【解决方案2】:
      .. 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
      

      【讨论】:

        【解决方案3】:

        我用substitution definitions:

        |pic1| any text |pic2|
        
        .. |pic1| image:: img1.png
           :width: 45%
        
        .. |pic2| image:: img2.png
           :width: 45%
        

        【讨论】:

        • 上述答案中的空白换行符必须在那里。只是在没有这些的情况下尝试过,它没有给出预期的输出。
        【解决方案4】:

        您希望图像成为同一段落的一部分,并且希望它们分割屏幕的宽度,因此请执行以下操作:

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

        这并不完全有效,两个图像之间会有一些间距,这会使总宽度 >100%。一个简单的解决方法是将宽度设置为 49%。这样做,下面是与上面未格式化的图像进行比较的输出: RenderedImages

        更多阅读:reST docs on Images

        【讨论】:

          【解决方案5】:

          试试这个:

          .. class:: center
          
          This text is centered
          

          【讨论】:

          • 它对我不起作用。你能进一步解释一下这是如何工作的吗?那个.. class:: center.. image::s 之前?
          猜你喜欢
          • 2020-11-27
          • 1970-01-01
          • 1970-01-01
          • 2012-02-26
          • 1970-01-01
          • 2013-06-05
          • 1970-01-01
          • 2016-12-07
          • 2017-10-31
          相关资源
          最近更新 更多