7

Is there a way to control the depth of what is shown by \localtablecontents, similarly to how \setcounter{parttocdepth}{.} and \setcounter{minitocdepth}{.} control the depth in the minitoc package. This would allow on a different depth of what is shown in my MWE for the \localtableofcontents of \parts and \chapters. In \parts for example I would only like to show \chapters and \sections not the full depth down to \subsubsections. Also, I notice numbering ceases at the \section level, why?

By the way, interworking of etoc and \usepackage{hyperref} will be the subject of a separate question.

\documentclass[a4paper, 11pt, oneside]{book}
% MWE 20June16
% COMMENTS: etoc. how to control the depth of \localtablecontents.
\usepackage{lipsum}
\usepackage{shorttoc}
%\usepackage{hyperref}
\usepackage{etoc}
\begin{document}
%===========
\frontmatter
%===========
% all toc depths: -1=\part, 0=\chapter, 1=\section, 2=\subsection,   3=\subsubsection
\setcounter{tocdepth}{3}  % main table of contents, if used
\shorttableofcontents{Summary Contents}{0}
%\tableofcontents
\chapter{Preface}
\lipsum[1]
\chapter{Introduction}
\lipsum[2]
%===========
\mainmatter
%===========
\part{Part ONE}
%\begingroup
%\let\clearpage\relax  % does not serve the same purpose for \part as it does for \chapter, regardless of whether the \documentclass{..,oneside] parameter is set or not. 
\localtableofcontents
%\endgroup
%\newpage

\chapter{Chap. One}
\begingroup
\let\clearpage\relax
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Alpha}
General comments pertaining to all subsections of this section.
\subsection{Subsec. one}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 1}
\lipsum[1]
\subsubsection{Subsubsec. 2}
\lipsum[1]
\subsection{Subsec. two}
\lipsum[1]
\section{Sec. Bravo}
General comments pertaining to all subsections of this section.
\subsection{Subsec. three}
\lipsum[1]
\subsection{Subsec. four}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\chapter{Chap. Two}
\begingroup
\let\clearpage\relax
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Charlie}
General comments pertaining to all subsections of this section.
\subsection{Subsec. five}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 3}
\lipsum[1]
\subsubsection{Subsubsec. 4}
\lipsum[1]
\subsection{Subsec. six}
\lipsum[1]
\section{Sec. Delta}
General comments pertaining to all subsections of this section.
\subsection{Subsec. seven}
\lipsum[1]
\subsection{Subsec. eight}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\chapter{Chap. Three}
\begingroup
\let\clearpage\relax
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Echo}
General comments pertaining to all subsections of this section.
\subsection{Subsec. nine}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 5}
\lipsum[1]
\subsubsection{Subsubsec. 6}
\lipsum[1]
\subsection{Subsec. ten}
\lipsum[1]
\section{Sec. Foxtrot}
General comments pertaining to all subsections of this section.
\subsection{Subsec. eleven}
\lipsum[1]
\subsection{Subsec. twelve}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\part{Part TWO}
\localtableofcontents
% etc. etc.

\part{Part THREE}
\localtableofcontents
% etc. etc.

\end{document}
2
  • 1
    \etocsettocdepth{...} is what you want, most likely, where ... stands for the relevant toc-depth. And etoc and hyperref seem to work together very well, if hyperref is loaded after etoc, not before
    – user31729
    Jun 20, 2016 at 3:15
  • with etoc you don't really need shorttoc
    – touhami
    Jun 20, 2016 at 8:27

1 Answer 1

8

The command \etocsettocdepth sets the depth of the ToC for the \localtableofcontents and is similar to \setcounter{tocdepth}{1}, for example. \etocsettocdepth is sticky until another call will change the value eventually. If another tocdepth is requested in between, \etocsetnexttocdepth can be used instead -- this setting is used only for one (i.e. the next) ToC.

The numbering of the section etc. can be controlled with \setcounter{secnumdepth}{3}, where 3 means subsubsection here.

hyperref and etoc work together, if hyperref is loaded later than etoc -- which is a general rule, actually.

\documentclass[a4paper, 11pt, oneside]{book}
% MWE 20June16
% COMMENTS: etoc. how to control the depth of \localtablecontents.
\usepackage{lipsum}
\usepackage{shorttoc}
\usepackage{etoc}
\usepackage{hyperref}
\begin{document}
%===========
\frontmatter
%===========
% all toc depths: -1=\part, 0=\chapter, 1=\section, 2=\subsection,   3=\subsubsection
\setcounter{tocdepth}{3}  % main table of contents, if used
\setcounter{secnumdepth}{3} 
\shorttableofcontents{Summary Contents}{0}
%\tableofcontents
\chapter{Preface}
\lipsum[1]
\chapter{Introduction}
\lipsum[2]
%===========
\mainmatter
%===========
\part{Part ONE}
%\begingroup
%\let\clearpage\relax  % does not serve the same purpose for \part as it does for \chapter, regardless of whether the \documentclass{..,oneside] parameter is set or not. 
\etocsettocdepth{1}
\localtableofcontents
%\endgroup
%\newpage

\chapter{Chap. One}
\begingroup
\let\clearpage\relax
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Alpha}
General comments pertaining to all subsections of this section.
\subsection{Subsec. one}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 1}
\lipsum[1]
\subsubsection{Subsubsec. 2}
\lipsum[1]
\subsection{Subsec. two}
\lipsum[1]
\section{Sec. Bravo}
General comments pertaining to all subsections of this section.
\subsection{Subsec. three}
\lipsum[1]
\subsection{Subsec. four}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\chapter{Chap. Two}
\begingroup
\let\clearpage\relax
\etocsettocdepth{1}
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Charlie}
General comments pertaining to all subsections of this section.
\subsection{Subsec. five}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 3}
\lipsum[1]
\subsubsection{Subsubsec. 4}
\lipsum[1]
\subsection{Subsec. six}
\lipsum[1]
\section{Sec. Delta}
General comments pertaining to all subsections of this section.
\subsection{Subsec. seven}
\lipsum[1]
\subsection{Subsec. eight}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\chapter{Chap. Three}
\begingroup
\let\clearpage\relax
\localtableofcontents
\endgroup
\newpage

\addcontentsline{toc}{section}{Introduction}
\section*{Introduction}
Introducing the topic of this chapter.
\section{Sec. Echo}
General comments pertaining to all subsections of this section.
\subsection{Subsec. nine}
General comments to all subsubsections of this subsection
\subsubsection{Subsubsec. 5}
\lipsum[1]
\subsubsection{Subsubsec. 6}
\lipsum[1]
\subsection{Subsec. ten}
\lipsum[1]
\section{Sec. Foxtrot}
General comments pertaining to all subsections of this section.
\subsection{Subsec. eleven}
\lipsum[1]
\subsection{Subsec. twelve}
\lipsum[1]
\addcontentsline{toc}{section}{Summary}
\section*{Summary}
Summarizing all topics discussed in this chapter and looking ahead.

\part{Part TWO}
\localtableofcontents
% etc. etc.

\part{Part THREE}
\localtableofcontents
% etc. etc.

\end{document}

enter image description here

2
  • Works like a charm. I'll get back to you on the subject of hyperref after some experimenting. Jun 20, 2016 at 7:16
  • It is not needed (at least if I trust etoc's manual ;-) ) to load hyperref after etoc; this being said I concur that as a general rule it is safest to load hyperref last among packages.
    – user4686
    Sep 10, 2016 at 13:30

You must log in to answer this question.

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