有没有办法控制显示的深度\localtablecontents
,类似于 minitoc 包中控制深度的方法\setcounter{parttocdepth}{.}
。\setcounter{minitocdepth}{.}
这将允许在我的 MWE 中显示不同的深度,用于\localtableofcontents
s\part
和\chapter
s。\part
例如,在 s 中,我只想显示\chapter
s 和\section
s,而不是显示到 s 的完整深度\subsubsection
。此外,我注意到编号在级别停止\section
,为什么?
顺便说一句,etoc
和的互通\usepackage{hyperref}
将是一个单独的问题的主题。
\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}
答案1
该命令\etocsettocdepth
设置了 的 ToC 深度,例如,它\localtableofcontents
类似于\setcounter{tocdepth}{1}
。它将保持粘性,直到另一个调用最终会更改该值。如果中间请求了\etocsettocdepth
另一个,则可以改用 —— 此设置仅适用于一个(即下一个)。tocdepth
\etocsetnexttocdepth
ToC
可以使用 来控制章节等的编号\setcounter{secnumdepth}{3}
,其中3
表示subsubsection
此处。
hyperref
并etoc
一起工作,如果hyperref
加载时间晚于etoc
——这实际上是一个一般规则。
\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}