Skip to content

Using ..only:: with .. figure:: and numfig=True skips numbering #4726

@miketheman

Description

@miketheman

Problem

  • Given using an .. only:: directive to modify what kind of .. figure:: with caption is included
  • When rendering the html output
  • Then the resulting numbering skips entries that are not rendered

Procedure to reproduce the problem

config.py has numfig=True

A snippet:

.. only:: latex

  .. figure:: _static/zones.png

     Zones

.. only:: html

  .. figure:: _static/zones.svg

     Zones

Results

Segment of rendered HTML, prettified for readability:

<div class="figure" id="id3">
  <a class="reference internal image-reference" href="_images/zones.svg">
    <img alt="_images/zones.svg" src="_images/zones.svg">
  </a>
  <p class="caption">
    <span class="caption-number">Fig. 1.2 </span>
    <span class="caption-text">Zones</span>
  </p>
</div>

Expected results

I'd expect the numbering to follow 1.1 and not skip to 1.2.

The next figures in the page have the same problem - so every figure is numbered with an even number.

Environment info

  • OS: macOS 10.13.3
  • Python version: 2.7.14
  • Sphinx version: 1.5.2, 1.6.6, 1.7.1

I also found an old issue, that had similar keywords but may be unrelated, yet is still open, so I link here: #1412 - it seems numfig extension has since been incorporated into core - I have not installed this extension.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions