I can universally vary the table of contents depth.
This is typically handled with command:\setcounter{tocdepth}{ [depth] }
.
I can partially vary the table of contents depth.
This is instead handled with package:tocvsec2
.
I can create separate tables of contents, such as global and sectional.
This is handled with package:titletoc
.
Currently, using tocvsec2
to vary tocdepth
affects all titletoc
tocs.
I would like separate [partially-varied tocdepth
parameters] for separate [tocs].
MWE Explanation
In the MWE,
Item 1
has subsectionsABC
, each with subsubsectionsxyz
.Item 2
has subsectionsIIa
andIIb
Each mimicsItem 1
.Item 3
mimicsItem 1
.Item 4
has subsectionsxyz
.
What is desired from the MWE,
- The
global
table of contents (first) should includeItem
andABC
sections.- This occurs.
- The
global
table of contents (first) should excludexyz
subsections.- This occurs.
- Each
sectional
table of contents (all others) should exclude other top-level sections.- This occurs.
- Each
sectional
table of contents (all others) should include other subsections.- This does not occur.
- The
xyz
sections are blocked, like the global section.
The MWE is lengthy. Apologies.
MWE
\documentclass{scrartcl}
\usepackage{geometry} % margin/page layout settings
\usepackage{scrlayer-scrpage} % improved header commands. [supercedes `fancyhdr' package].
\usepackage{titletoc} % sub-[tables of contents]
\usepackage[hidelinks]{hyperref} % hyperlinks.
\usepackage{tocvsec2} % variable depth in table of contents
% Margin Settings:
\newlength{\xhmargin } \setlength{\xhmargin }{0.750in}
\newlength{\xtmargin } \setlength{\xtmargin }{0.750in}
\newlength{\xbmargin } \setlength{\xbmargin }{0.750in}
\newlength{\xheadheight} \setlength{\xheadheight}{2.700em}
\newlength{\xheadsep } \setlength{\xheadsep }{1.000em}
\newlength{\xfootheight} \setlength{\xfootheight}{2.700em}
\newlength{\xfootskip } \setlength{\xfootskip }{3.700em} % [ = Footheight + Footsep]
\KOMAoptions{fontsize = 12pt ,
parskip = half- ,
headheight = \xheadheight ,
footheight = \xfootheight ,
DIV = current }
\geometry{letterpaper ,
hmargin = \xhmargin ,
tmargin = \xtmargin ,
bmargin = \xbmargin ,
headsep = \xheadsep ,
footskip = \xfootskip }
%Initialize headers and footers
\chead{\normalfont Header 1 \\ Header 2}
\cfoot{\normalfont Footer 1 \\ Footer 2}
\ofoot{\normalfont Page \thepage}
%Setup section numbering: Make \paragraph like \subsubsection.
\makeatletter
\newcommand{\subsubsubsection}{\@startsection{paragraph}{4}{\z@}%
{-2.5ex\@plus -1ex \@minus -.25ex}%
{1.25ex \@plus .25ex}%
{\normalfont\normalsize\bfseries}}
\makeatother
%Setup section numbering: Make \paragraph and \subparagraph numbered.
\setcounter{secnumdepth}{5}
\setcounter{tocdepth} {5}
\begin{document}
\tableofcontents
\clearpage
\settocdepth{subsection}
\section{Item I}
\startcontents[Item I]
\printcontents[Item I]{}{1}{ \subsection*{Contents} }
\clearpage
\subsection{A}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\clearpage
\subsection{B}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\clearpage
\subsection{C}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\stopcontents[Item I]
\clearpage
\settocdepth{subsubsection}
\section{Item II}
\startcontents[Item II]
\printcontents[Item II]{}{2}{ \subsection*{Contents} }
\clearpage
\subsection{Item IIa}
\clearpage
\subsubsection{A}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\clearpage
\subsubsection{B}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\clearpage
\subsubsection{C}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\clearpage
\subsection{Item IIb}
\clearpage
\subsubsection{A}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\clearpage
\subsubsection{B}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\clearpage
\subsubsection{C}
\subsubsubsection{x}
\subsubsubsection{y}
\subsubsubsection{z}
\stopcontents[Item II]
\clearpage
\settocdepth{subsection}
\section{Item III}
\startcontents[Item III]
\printcontents[Item III]{}{1}{ \subsection*{Contents} }
\clearpage
\subsection{A}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\clearpage
\subsection{B}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\clearpage
\subsection{C}
\subsubsection{x}
\subsubsection{y}
\subsubsection{z}
\stopcontents[Item III]
\clearpage
\settocdepth{section}
\section{Item IV}
\startcontents[Item IV]
\printcontents[Item IV]{}{1}{ \subsection*{Contents} }
\clearpage
\subsection{x}
\subsection{y}
\subsection{z}
\stopcontents[Item IV]
\end{document}
Best Answer
We need to replace
by
Note: don't use
\stopcontents
Complete code