如何不在目录中显示子子部分?

如何不在目录中显示子子部分?

我发现这个小片段可以获取 subsubsubsection:

% -- For subsubsubsections:
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{3}
\makeatletter
\newcounter {subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection .\@alph\c@subsubsubsection}
\newcommand\subsubsubsection{\@startsection{subsubsubsection}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\newcommand*\l@subsubsubsection{\@dottedtocline{3}{10.0em}{4.1em}}
\newcommand*{\subsubsubsectionmark}[1]{}
\makeatother

因此我得到了像 8.1.1.a 这样的部分。它工作得很好,但问题是我在目录中看到了那些子子部分,但我不想看到它们:

在此处输入图片描述

我怎样才能将它们从目录中删除?

答案1

改变

\newcommand*\l@subsubsubsection{\@dottedtocline{3}{10.0em}{4.1em}}

\newcommand*\l@subsubsubsection{\@dottedtocline{4}{10.0em}{4.1em}}

(第一个强制参数\dottecttocline控制目录中条目的级别)。

完整示例:

\documentclass{article}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{3}

\makeatletter
\newcounter {subsubsubsection}[subsubsection]
\renewcommand\thesubsubsubsection{\thesubsubsection .\@alph\c@subsubsubsection}
\newcommand\subsubsubsection{\@startsection{subsubsubsection}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\newcommand*\l@subsubsubsection{\@dottedtocline{4}{10.0em}{4.1em}}
\newcommand*{\subsubsubsectionmark}[1]{}
\makeatother

\begin{document}

\tableofcontents

\section{Test section}
\subsection{Test subsection}
\subsubsection{Test subsubsection}
\subsubsubsection{Test subsubsubsection}

\end{document}

在此处输入图片描述

请注意,您可能需要对\paragraph和的级别做一些额外的调整\subparagraph

您可以使用titlesec包以更简单的方式定义新的分段级别。

相关内容