如何在目录页中隐藏某一章的所有章节和小节?
我想要的是如果我有这个:
\documentclass[12pt, a4paper, draft, titlepage]{report}
\begin{document}
\tableofcontents
\chapter{This chapter is listed in the contents page}
\section{So are all its sections}
\subsection{--- and subsections!}
\chapter{This chapter name is listed in the contents page}
\section{But this section doesn't appear on the contents page.}
\subsection{This section doesn't appear on the contents page either.}
\end{document}
有什么方法可以隐藏该特定章节的所有节和小节?
答案1
您可以在文档中间更改计数器的值tocdepth
,将其写入 ToC 的适当位置。这样您就可以改变显示的内容和不显示的内容。
\documentclass{report}
\begin{document}
\tableofcontents
\chapter{This chapter is listed in the contents page}
\section{So are all its sections}
\subsection{--- and subsections!}
\addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
% From this point on, only show up to \chapters in the ToC
\chapter{This chapter name is listed in the contents page}
\section{But this section doesn't appear on the contents page.}
\subsection{This section doesn't appear on the contents page either.}
\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
% From this point on, only show up to \subsection in the ToC
\chapter{This chapter is listed in the contents page}
\section{So are all its sections}
\subsection{--- and subsections!}
\end{document}
部门单位有以下“级别”:
-1
=\part
0
=\chapter
1
=\section
2
=\subsection
3
=\subsubsection
4
=\paragraph
5
=\subparagraph
其他文档类别可能提供不同的级别。