如何设置Sphinx和latexpdf toc深度?

时间:2013-11-19 13:50:05

标签: latex python-sphinx

我有一个用" sphinx-quickstart创建的香草狮身人面像项目(Sphinx 1.2b3。)"

我添加了一个基本的page.rst,包含4个标题级别。

我可以在index.rst中控制html toc的深度:

.. toctree::
   :maxdepth: 1
   :numbered:

   page

根据文档http://sphinx-doc.org/latest/markup/toctree.html,我将conf.py调整如下:

ADDITIONAL_PREAMBLE = """
\setcounter{tocdepth}{1}
"""

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'a4paper',

# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
'preamble': '\setcounter{tocdepth}{1}'
#'preamble': ADDITIONAL_PREAMBLE
}

然后我建立:

$ make clean
$ make html
$ make latexpdf

html仅按预期显示1级,但pdf仍显示2个toc级别 - 屏幕截图enter image description here

任何提示?

THX

PELLE

溶液

由jacob提供 - >简单地认为所需的等级数为-1:

'preamble': '\setcounter{tocdepth}{0}'

1 个答案:

答案 0 :(得分:6)

默认的Sphinx乳胶文档类基于报告类并使用章节,因此仅显示您必须设置的乳胶目录中的章节名称

\setcounter{tocdepth}{0}