1

How do I remove the section and subsection from the table of contents and just have the chapters?

\documentclass{book}
\usepackage{lipsum}
\usepackage{titletoc}

\begin{document} \tableofcontents \chapter{Introduction} \lipsum[1] \section{First section} \lipsum[2-3] \section{Second section} \lipsum[4-5] \section{Last section} \lipsum[6-7] \chapter{Second chapter} \lipsum[1] \section{First section} \lipsum[2-3] \section{Second section} \lipsum[4-5] \section{Last section} \lipsum[6-7] \chapter{Last chapter} \lipsum[1] \section{First section} \lipsum[2-3] \section{Second section} \lipsum[4-5] \section{Last section} \lipsum[6-7] \end{document}

Bernard
  • 271,350

1 Answers1

1

Just add \setcounter{tocdepth}{0} to your header.

Miyase
  • 2,544
  • 2
  • 12
  • 26
  • In the document preamble, I suppose ... – Zarko Apr 07 '22 at 17:51
  • I'd say yes, but out of curiosity I made a couple of tries. It works as long as the macro is before \tableofcontents, in the preamble as well as in the body of text. – Miyase Apr 08 '22 at 08:20
  • Can you predict why LaTeX set this as a counter rather than a count? I feel it's strange. – youthdoo Jan 03 '23 at 10:09