0

I've got my index file set up like so:

Doc Title
==============================

..toctree::
   :maxdepth: 3
   :numbered:
   :caption: Contents

   01_file1
   01.3_file2

If the contents are thus...

01_file1.txt:

Level 1 section title
--------------------------------------------

Level 2 section title
............................................

Another Level 2 section title
............................................

and for 01.3_file2.txt:

A third Level 2 section title
............................................

I would expect this because Sphinx treats everything as a single document:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
  1.3 A third Level 2 section title

But instead I get this:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
2. A third Level 2 section title

I'm guessing this is because Sphinx (or maybe reST/Markdown?) restarts implicit heading levels with each new text file. Is there a way to get what I actually want?

Quoting the reST documentation...

Rather than imposing a fixed number and order of section title adornment styles, the order enforced will be the order as encountered. The first style encountered will be an outermost title (like HTML H1), the second style will be a subtitle, the third will be a subsubtitle, and so on.

4

1 回答 1

1

父文件确定其包含的子文件的标题级别。要获得所需的效果,请01.3_file2从中删除,然后在要包含它的index位置放置一个.. include:: 01.3_file2in 。01_file1.txt


指数:

Doc Title
==============================

..toctree::
   :maxdepth: 3
   :numbered:
   :caption: Contents

   01_file1

01_file1.txt:

Level 1 section title
--------------------------------------------

Level 2 section title
............................................

Another Level 2 section title
............................................

.. include:: 01.3_file2.txt

01.3_file2.txt:

A third Level 2 section title
............................................

结果是:

1. Level 1 section title
  1.1 Level 2 section title
  1.2 Another Level 2 section title
  1.3 A third Level 2 section title
于 2018-10-04T07:12:58.083 回答