Issue #771 new

# latex output doesn't set tocdepth

Erich Blume
created an issue

I am new to Sphinx and may be going about this the wrong way, but it seemed to me like Sphinx's latex output mode isn't setting the tocdepth counter appropriately. The result is that the toctree is properly built to honor the :maxdepth: variable, BUT the latex \tableofcontents doesn't follow that same depth.

== Steps to reproduce ==

# run `make latexpdf' and note that the resulting latex document's table of contents only goes to a depth of 2 (the latex default).

== Workaround ==

For now I have the following in my conf.py file:

{{{

# !python

latex_elements = { 'preamble': r'\setcounter{tocdepth}{10}', } }}}

This works fine and produces the intended result but you'll notice that it is simply using a dummy 'large' value, 10. It would be much better if Sphinx detected the toctree :maxdepth: argument and inserted the appropriate \secounter{tocdepth}{#} decleration. (I believe that latex has a maximum value for this counter above which higher values have no additional effect - this could be used as the value to specify when :maxdepth: is not given.)