sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

GIF Figures do not have numbers that can be used by `numref`

Open jontwo opened this issue 8 months ago • 2 comments

Describe the bug

We have just started to add GIFs to our docs and have noticed that, even though numfig=True, the PNG Figures have numbers, but the GIFs do not. We're just using the default StandaloneHTMLBuilder.

How to Reproduce

In any docs project, add a figure with a gif image. The caption does not have a Fig. number.

.. figure:: example.png

    This image will have a number

.. figure:: example.gif

    This image does not have a number

I tried adding a numref to the page, in case the number was generated but not displayed, and got the attached bug report. The error message assert target_node is not None suggested a number was expected but not found.

Environment Information

Platform:              linux; (Linux-5.15.0-141-generic-x86_64-with-glibc2.35)
Python version:        3.12.10 (main, Apr  9 2025, 08:55:05) [GCC 11.4.0])
Python implementation: CPython
Sphinx version:        7.2.6
Docutils version:      0.20.1
Jinja2 version:        3.1.4
Pygments version:      2.18.0

Sphinx extensions


Additional context

sphinx-err-806t9bmd.log

Error report generated when attempting to use numref to reference the missing figure number.

jontwo avatar Jun 12 '25 07:06 jontwo

Actually, sphinx has just decided that all my input files have changed and done a full rebuild. I now have Figure numbers, but I'm still getting the numref error. I've updated the title to reflect this.

jontwo avatar Jun 12 '25 10:06 jontwo

Using your code in a fresh empty project created by sphinx-quickstart, with numfig = True in conf.py I can not reproduce the issue.

Image

Same with using myst-parser and .md file. Please reduce your case to some minimal reproducer.

jfbu avatar Jun 12 '25 13:06 jfbu