LaTeX从TOC中删除子部分

时间:2018-03-11 02:20:29

标签: latex tableofcontents

我在LaTeX中使用以下代码来设置目录中的内容级别:

\setcounter{secnumdepth}{2}\newcommand{\restoretoc}\addtocontents{toc}
{\protect\vspace*{2.5em}{\setcounter{tocdepth}{1}{\setcounter{secnumdepth}{2}}}

输出如下:

enter image description here

计数器消失但子字幕和页码仍然存在。如何删除子目录的目录中的所有计数器,标题和页码?

1 个答案:

答案 0 :(得分:0)

第一个简单的建议:

\documentclass{book}
\begin{document}
\tableofcontents
\chapter{First}
\section{First first}
\section{First second}
\subsection*{First second first}
%\setcounter{subsection}{1}
\subsection{First second second}
\end{document}

这样,“已加星标的”\subsection*(或章节或章节)不会出现在目录中。

此外,取消注释行\setcounter{subsection}{1}(并编辑其中的数字1),您可以根据需要使用以下子部分编号。 编译两次以测试此,因为目录文件要求它更新输出pdf或dvi文件。

如果计数器subsection设置为subsubsection或更多,我撰写的关于secnumdepth的内容也适用于3

相关问题