Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:11:28+00:00 2026-06-16T00:11:28+00:00

I am using Sphinx to write a document with lots of references: .. _human-factor:

  • 0

I am using Sphinx to write a document with lots of references:

.. _human-factor:

The Human Factor
================

...

(see :ref:`human-factor` for details)

The compiled document contains something like this:

(see The Human Factor for details)

Instead I would like to have it formatted like this:

(see 5.1 The Human Factor for details)

I tried to google the solution and I found out that the latex hyperref package can do this but I have no idea how to add this to the Sphinx build.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:11:29+00:00Added an answer on June 16, 2026 at 12:11 am

    I resolved it by basically using numsec.py from here: https://github.com/jterrace/sphinxtr

    I had to replace the doctree_resolved function with this one to get section number + title (e.g. “5.1 The Human Factor”).

    def doctree_resolved(app, doctree, docname):
        secnums = app.builder.env.toc_secnumbers
        for node in doctree.traverse(nodes.reference):
            if 'refdocname' in node:
                refdocname = node['refdocname']
                if refdocname in secnums:
                    secnum = secnums[refdocname]
                    emphnode = node.children[0]
                    textnode = emphnode.children[0]
    
                    toclist = app.builder.env.tocs[refdocname]
                    anchorname = None
                    for refnode in toclist.traverse(nodes.reference):
                        if refnode.astext() == textnode.astext():
                            anchorname = refnode['anchorname']
                    if anchorname is None:
                        continue
                    linktext = '.'.join(map(str, secnum[anchorname]))
                    node.replace(emphnode, nodes.Text(linktext
                        + ' ' + textnode))
    

    To make it work one needs to include the numsec extension in conf.py and also to add :numbered: in the toctree like so:

    .. toctree::
       :maxdepth: 1
       :numbered:
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to start using Sphinx to document some little projects of mine, but
I want to start using Sphinx to document my project. I told Sphinx to
I'm using the SPH_MATCH_EXTENDED2 match mode with Sphinx 0.9.9 and I want to write
I am currently using Sphinx to document a mixed-language project, such that the documentation
I am using Sphinx to document a webservice that will be deployed in different
I am using sphinx with the pngmath extension to document my code that has
I've created a Sphinx document using sphinx-quickstart . Are there any good examples/tutorials about
I'm using Sphinx's autodoc feature to document my API. Example: DEFAULT_OPTION = 'default' def
I am using Sphinx to write some notes. I am using the Mathjax extension
I'm using sphinx to list me some items from my database here. It's almost

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.