我发现这个小片段可以获取 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
包以更简单的方式定义新的分段级别。