How to create a link to a header in restructuredtext?

后端 未结 2 1356
说谎
说谎 2021-01-22 10:12

I have a document in restructuredtest like:

Header 1
========

and from some any other point (might be the same \'rst\' file or a different one

2条回答
  •  心在旅途
    2021-01-22 10:54

    Your first link was almost correct. You need to add a label preceding the section header, separated by a blank line. See Inline markup, Cross-referencing arbitrary locations, using the :ref: directive.

    In your case:

    .. _header-1-label-name:
    
    Header 1
    ========
    
    Some text
    
    Here is a section reference: :ref:`header-1-label-name`.
    
    Here is a section reference with a title: :ref:`Header 1 with a title `.
    

提交回复
热议问题