Menu

#181 LaTeX writer: Fix tocdepth when chapter/part in use

None
closed-accepted
nobody
None
5
2021-10-31
2021-06-06
No

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.

1 Attachments

Discussion

  • Günter Milde

    Günter Milde - 2021-06-17
    • status: open --> open-accepted
     
  • Günter Milde

    Günter Milde - 2021-06-17

    Committed in r8769. Thank you for the patch.

     
  • Günter Milde

    Günter Milde - 2021-10-31
    • status: open-accepted --> closed-accepted
     
  • Günter Milde

    Günter Milde - 2021-10-31

    Applied in Docutils 0.18.
    Thanks again for the patch

     

Log in to post a comment.