Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly numref table in Sphinx?

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?

like image 364
Douglas De Rizzo Meneghetti Avatar asked Apr 29 '16 23:04

Douglas De Rizzo Meneghetti


1 Answers

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.

like image 118
mzjn Avatar answered Sep 21 '22 08:09

mzjn