I have a table of contents (\tableofcontents) in my document. How can I hide subsections in it? I want that only names of sections are displayed there.

  • 10
    Write \subsection*{} with the asterisk, for a single case, or include \setcounter{tocdepth}{1} in your preamble for anything below Section (subsections, subsubsections won't appear). I think this question has certainly come up before...
    – Alenanno
    Commented Feb 5, 2016 at 14:42
  • 7
    \setcounter{tocdepth}{1} is quicker ;-)
    – user31729
    Commented Feb 5, 2016 at 14:44
  • @Alenanno: Must --- resist--- to answer... this ToC question ;-)
    – user31729
    Commented Feb 5, 2016 at 14:45
  • @ChristianHupfer I added it while you were posting lol
    – Alenanno
    Commented Feb 5, 2016 at 14:45
  • 10
    By the way, note that the asterisk will make the affected parts unnumbered!
    – Alenanno
    Commented Feb 5, 2016 at 14:47

1 Answer 1


The tocdepth counter decides to which depth down the entries appear in the ToC.

(Code slightly edited, thanks to https://tex.stackexchange.com/users/1357/jdh for pointing me to a typo!)

Usually, following values hold

  • \setcounter{tocdepth}{-1} -- only parts
  • \setcounter{tocdepth}{0} -- only parts and chapters
  • \setcounter{tocdepth}{1} -- part,chapters,sections
  • \setcounter{tocdepth}{2} -- part,chapters,sections, subsections
  • \setcounter{tocdepth}{3} -- part,chapters,sections, subsections,subsubsections
  • \setcounter{tocdepth}{4} -- part,chapters,sections, subsections,subsubsections and paragraphs
  • \setcounter{tocdepth}{5} -- part,chapters,sections, subsections, subsubsections, paragraphs and subparagraphs.

The memoir class adds the ToC depth -2 for the \book structure level at all, being higher leveled than \part.

This means, the larger the number for the counter, the greater the number of structuring in the ToC.

The toclevels can be found, for example in article.cls (and since book.cls loads article.cls) looking at the \@startsection{...} commands.

If for example, some parts of the structuring should not appear in the ToC at all, there's a trick


before the 'hidden parts' and later reenable them with


See Switching tocdepth in the middle of a document for an example about changing the tocdepth in between.

Please do not confuse tocdepth with the secnumdepth counter!

Just for completeness: Both tocdepth and secnumdepth are counters that aren't defined with\newcounter, but have the internal names \c@tocdepth and \c@secnumdepth in order to allow \setcounter etc. usage. You won't find them in the internal counter list and are no members of counter reset lists by default, which would be no of importance anyway.

The value of the tocdepth counter controls in the same manner which entries enter the regular bookmarks provided by hyperref.

  • 1
    You are missing {toc} in the trick, in the second line where you reenable the level. (And thanks for this trick!)
    – JDH
    Commented Aug 11, 2018 at 11:26
  • @JDH: Thanks for notifying -- I've corrected the typo.
    – user31729
    Commented Nov 25, 2018 at 10:46
  • How would this work for a specific level only? Like subsections only?
    – OctopuSS7
    Commented Apr 5, 2021 at 16:35
  • @JDH Do these settings change the minitoc setting as well?
    – Wallflower
    Commented May 16, 2023 at 21:29
  • @Wallflower I don't know.
    – JDH
    Commented May 17, 2023 at 6:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .