我已经按照如下方式设置了索引文件:
Doc Title
==============================
..toctree::
:maxdepth: 3
:numbered:
:caption: Contents
01_file1
01.3_file2
如果内容如此……
01_file1.txt:
Level 1 section title
--------------------------------------------
Level 2 section title
............................................
Another Level 2 section title
............................................
以及01.3_file2.txt:
A third Level 2 section title
............................................
这是我期望的,因为Sphinx将所有内容都视为一个文档:
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
但是我得到了:
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
我猜这是因为Sphinx(或者也许是reST / Markdown?)会为每个新的文本文件重新启动隐式标题级别。有没有办法得到我真正想要的?
引用reST documentation ...
不是强加节标题装饰样式的固定编号和顺序,而是强制执行的顺序将是遇到的顺序。遇到的第一个样式将是最外面的标题(如HTML H1),第二个样式将是字幕,第三个样式将是字幕,依此类推。
答案 0 :(得分:1)
父文件确定其包含的子文件的标题级别。为了获得理想的效果,请从01.3_file2
中删除index
,然后在要添加的位置将.. include:: 01.3_file2
放在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