Sphinx LaTeX Table of Contents - 避免包含的第一个文件的 toctree 嵌套
Sphinx LaTeX Table of Contents - avoid toctree nesting of included rst files
我有一个 Sphinx 文档,其结构如下:
My chapter title
=====================
Chapter intro part 1
--------------------------
Brief introduction that I would like to have in the start of this chapter...
Chapter intro part 2
--------------------------
Another short section ...
.. toctree::
:hidden:
:maxdepth: 2
folder/subchapter1
folder/subchapter2
当我基于此呈现 HTML 时,一切都按预期进行 - 我有本章的起始页,我的子章可从侧边菜单访问。
但是,当我构建 LaTeX/PDF 输出时,层次结构在目录和编号的 Table 中的结构如下:
0.2 My chapter title
- 0.2.1 Chapter intro part 1
- 0.2.2 Chapter intro part 2
- 0.2.2.1 subchapter1
- 0.2.2.2 subchapter2
我想要的是:
0.2 My chapter title
- 0.2.1 Chapter intro part 1
- 0.2.2 Chapter intro part 2
- 0.2.3 subchapter1 title
- 0.2.3 subchapter2 title
或者:
0.2 My chapter title
0.2.1 subchapter1 title
0.2.2 subchapter2 title
我意识到这可能是对 "hack" toctree
概念的尝试,但我试图同时满足 HTML 和 [=30= 的层次结构要求]LaTeX 代码相同。
我正在使用 Sphinx 1.8.5 和默认的 LaTeX 构建设置。
我最终使用了如下结构:
Hardware
=============================
.. only:: html
.. include:: hardware/intro.rst
.. toctree::
:hidden:
:maxdepth: 2
hardware/intro
hardware/installation
hardware/connector
在conf.py
我添加了:
if tags.has("output_html"):
exclude_patterns.append("*/intro.rst")
并且在我的构建过程中,我添加了标签 output_html
,因为标准 html
标签在 conf.py
中不可访问。有了这个,我得到了我想要的。
我有一个 Sphinx 文档,其结构如下:
My chapter title
=====================
Chapter intro part 1
--------------------------
Brief introduction that I would like to have in the start of this chapter...
Chapter intro part 2
--------------------------
Another short section ...
.. toctree::
:hidden:
:maxdepth: 2
folder/subchapter1
folder/subchapter2
当我基于此呈现 HTML 时,一切都按预期进行 - 我有本章的起始页,我的子章可从侧边菜单访问。
但是,当我构建 LaTeX/PDF 输出时,层次结构在目录和编号的 Table 中的结构如下:
0.2 My chapter title
- 0.2.1 Chapter intro part 1
- 0.2.2 Chapter intro part 2
- 0.2.2.1 subchapter1
- 0.2.2.2 subchapter2
我想要的是:
0.2 My chapter title
- 0.2.1 Chapter intro part 1
- 0.2.2 Chapter intro part 2
- 0.2.3 subchapter1 title
- 0.2.3 subchapter2 title
或者:
0.2 My chapter title
0.2.1 subchapter1 title
0.2.2 subchapter2 title
我意识到这可能是对 "hack" toctree
概念的尝试,但我试图同时满足 HTML 和 [=30= 的层次结构要求]LaTeX 代码相同。
我正在使用 Sphinx 1.8.5 和默认的 LaTeX 构建设置。
我最终使用了如下结构:
Hardware
=============================
.. only:: html
.. include:: hardware/intro.rst
.. toctree::
:hidden:
:maxdepth: 2
hardware/intro
hardware/installation
hardware/connector
在conf.py
我添加了:
if tags.has("output_html"):
exclude_patterns.append("*/intro.rst")
并且在我的构建过程中,我添加了标签 output_html
,因为标准 html
标签在 conf.py
中不可访问。有了这个,我得到了我想要的。