Discussion:
[Docutils-users] Link to a heading by number in ReST
Steven D'Aprano
2016-09-29 02:18:33 UTC
Permalink
I have a ReST (ReStructured Text) document that auto-numbers headings
like:

My Heading
----------

which will be given a number like 10.1 (say), except of course I don't
know what the number will be until I've compiled the .rst file.

I'm using this as a legal document, where the canonical way to refer to
a clause is by number, not title. So rather than say:

see clause My Heading ...

I want to say

see clause 10.1 ...


How can I do this using ReST and/or Sphinx?
--
Steve
Guenter Milde
2016-09-29 14:32:57 UTC
Permalink
Post by Steven D'Aprano
I have a ReST (ReStructured Text) document that auto-numbers headings
My Heading
----------
which will be given a number like 10.1 (say), except of course I don't
know what the number will be until I've compiled the .rst file.
I'm using this as a legal document, where the canonical way to refer to
see clause My Heading ...
I want to say
see clause 10.1 ...
How can I do this using ReST and/or Sphinx?
This is not (yet) implemented in standard reStructuredText.
It is on the todo list for Docutils.
Maybe there is a Sphinx extension.

If you only need LaTeX output, you can use raw LaTeX to define a reference as
\ref{normalized-name-of-the-heading}

Günter

Loading...