문제

I have a vanilla sphinx project (Sphinx 1.2b3.) created with "sphinx-quickstart"

I add a basic page.rst with 4 header levels.

I can control the depth of the html toc in index.rst:

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

   page

Based upon the documentation http://sphinx-doc.org/latest/markup/toctree.html I adjust the conf.py as follow:

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
}

Then I build:

$ make clean
$ make html
$ make latexpdf

The html show only level 1 as expected but the pdf keeps showing 2 toc levels - screen shoot enter image description here:

Any hints?

thx

pelle

solution

was provided by jacob -> simply think required level num -1:

'preamble': '\setcounter{tocdepth}{0}'
도움이 되었습니까?

해결책

The default Sphinx latex document class is based on the report class and uses chapters, hence to show only the chapter names in the latex table of contents you have to set

\setcounter{tocdepth}{0} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top