You can simply use a HTML link element, <a href="..."...</a>
if you know how section id
s are generated. The id
s for items in the table of contents are simply lower-cased section titles with white space replaced by hyphens, -
. So this reStructuredText
Title
=====
.. contents:: Table of Contents
Section 1
---------
Some filler text...
Section 2
---------
Some filler text...
results in the following HTML snippet (<head>
etc. removed)
<body>
<div class="document" id="title">
<h1 class="title">Title</h1>
<div class="contents topic" id="table-of-contents">
<p class="topic-title first">Table of Contents</p>
<ul class="simple">
<li><a class="reference internal" href="#section-1" id="id1">Section 1</a></li>
<li><a class="reference internal" href="#section-2" id="id2">Section 2</a></li>
</ul>
</div>
<div class="section" id="section-1">
<h1><a class="toc-backref" href="#id1">Section 1</a></h1>
<p>Some filler text...</p>
</div>
<div class="section" id="section-2">
<h1><a class="toc-backref" href="#id2">Section 2</a></h1>
<p>Some filler text...</p>
</div>
</div>
</body>
Therefore, in order to link to a table of contents item you can use the following reStructuredText
.. raw:: html
<small class="..."><a href="#section-1">Section 1</a></small>
If you want to link to the section itself then replace the href
value with #id1
or the relevant section's id
.