[英]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.