Currently, when Docutils converts a document containing .. contents:: :depth: N
to LaTeX, the user-supplied depth value is used as-is. This works fine when the only sectioning commands in the resulting document are \section
and its subdivisions, but when the documentclass uses chapters or use_part_section
is in effect, this gives the wrong result. For example, a depth of 1 means to only show the topmost sectioning level in the TOC; when that level is "chapter", the tocdepth
counter should be set to 0, and when it is "part", the counter should be set to either -1 (if the document class uses chapters) or 0 (if it does not).
The attached patch corrects the calculation of tocdepth
using basically the same code that is already in use for calculating secnumdepth
.
Committed in r8769. Thank you for the patch.
Applied in Docutils 0.18.
Thanks again for the patch