wswld
wswld

Reputation: 1238

Automatically numbering and referencing Sphinx tables

Is there a way to reference Sphinx tables the following way:

.. table Supertable

    +--------+----+
    |Foo     |Bar |
    +--------+----+

And then:

:table:`Supertable`

And magic! The problem is, that there are certain tables, that could be referenced throughout one document and such linking could come very useful.

On a side note the approach I've illustrated my question with doesn't work.

Also, as another part of the same question, is there a way to automatically numerate the tables? I'm pretty positive I've seen one somewhere, but it could be something manual. I mean like in:

Table 11: Consumption of peanut butter by the state..

This functionality, if available at all, is eluding me.

Upvotes: 1

Views: 1552

Answers (1)

wswld
wswld

Reputation: 1238

OK, I've found an answer to the first part of my question. Actually it's a nobrainer:

.. _table:

.. table Supertable

    +--------+----+
    |Foo     |Bar |
    +--------+----+

And then:

:ref:`table`

As for enumerated tables I have actually seen enumerated figures, not tables and it gets done in LaTeX output. I looked around and haven't found any trace of automatically enumerated tables in Sphinx. It would probably make a good feature request, but for now there seems to be no such feature.

PS: I've checked and actually tables are also enumerated in LaTeX. There is also a related problem discussed in this question.

Upvotes: 3

Related Questions