[英]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 output 时,层次结构在目录和编号中如下所示:
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
我意识到这可能是试图“破解” toctree
概念,但我试图用相同的代码同时满足我对 HTML 和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
中不可访问。 有了这个,我得到了我想要的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.