I am trying to reference a table by its number in a Sphinx doc. I give a name to the table and try to use numref
afterwards, but it incorrectly displays the table's label ("modules_classes") instead of its number.
.. _modules_classes:
.. table:: Modules and their corresponding abstract classes
[table content]
Modules and their corresponding abstract classes are presented on table :numref:`modules_classes`.
I've also tried doing like this, as I found an example online, but the outcome is the same:
.. table:: Modules and their corresponding abstract classes
:name: modules_classes
The way I see it, I don't need to import the numfig
package, as it is included in Sphinx by default. Using the command :ref:
displays the table's caption, so I understand the reference is correct. Can someone point what is wrong in what I've done?
The remedy is to set numfig = True
in conf.py. Without this setting, you should see a message when running sphinx-build that says "WARNING: numfig is disabled. :numref: is ignored".
This works for HTML and LaTeX output. See https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-numfig.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With