0

I have the following document:

\documentclass[11pt, a4paper, headsepline]{scrbook} 

\begin{document}

 \tableofcontents

 \chapter{Chapter one}
 \section{Section one.one}
 \subsection{Subsection one.one.one}
 \subsection{Subsection one.one.two}
 \section{Section one.two}
 \subsection{Subsection one.two.one}
 \subsection{Subsection one.two.two}
 \section{Section one.three}
 \subsection{Subsection one.one.one}
 \subsection{Subsection one.one.two}

\end{document}

But I want the following toc:

1 Chapter one
1.1 Section one.one
1.1.1 Subsection one.one.one
1.1.2 Subsection one.one.two
1.2 Section one.two <<<--- here subsections are missing
1.3 Section one.three
1.3.1 Subsection one.one.one
1.3.2 Subsection one.one.two

Excluding some subsections via \addtocontents{toc}{\setcounter{tocdepth}{1}} didn't work or maybe I implemented it wrong. Any hints?

2
  • So you only want to exclude stuff from the toc?
    – Skillmon
    Jul 19, 2017 at 18:15
  • 1
    Correct, however, the answer below did work :D
    – Kay
    Jul 19, 2017 at 18:23

1 Answer 1

2

You need to protect the \setcounter:

\documentclass[11pt, a4paper, headsepline]{scrbook}

\begin{document}

 \tableofcontents

 \chapter{Chapter one}
 \section{Section one.one}
 \subsection{Subsection one.one.one}
 \subsection{Subsection one.one.two}
 \section{Section one.two}
 \addtocontents{toc}{\protect\setcounter{tocdepth}{1}}
 \subsection{Subsection one.two.one}
 \subsection{Subsection one.two.two}
 \addtocontents{toc}{\protect\setcounter{tocdepth}{3}}
 \section{Section one.three}
 \subsection{Subsection one.one.one}
 \subsection{Subsection one.one.two}

\end{document}

 You can also use the tocvsec2 package https://ctan.org/pkg/tocvsec2
0

You must log in to answer this question.

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