修改 book.cls 类以添加一个部分级别(subsubsubsection)

修改 book.cls 类以添加一个部分级别(subsubsubsection)

我想book.cls通过添加一个节级别 (subsubsubsection) 来修改类。我知道这可以通过包来完成titlesec,但我正在寻找一种方法在类的副本中执行此操作,book.cls然后我将继续调用mybook.cls

我已经完成了以下操作,但是得到的输出不太正确,我将附上一张图片。

\newcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\Large\bfseries}}
\newcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}
\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\newcommand\subsubsubsection{\@startsection{subsubsubsection}{4}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}                                    
\newcommand\paragraph{\@startsection{paragraph}{5}{\z@}%
                                    {3.25ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}
\newcommand\subparagraph{\@startsection{subparagraph}{6}{\parindent}%
                                       {3.25ex \@plus1ex \@minus .2ex}%
                                       {-1em}%
                                      {\normalfont\normalsize\bfseries}}
\setcounter{secnumdepth}{4}
\newcounter {part}
\newcounter {chapter}
\newcounter {section}[chapter]
\newcounter {subsection}[section]
\newcounter {subsubsection}[subsection]
\newcounter {subsubsubsection}[subsubsection]
\newcounter {paragraph}[subsubsubsection]
\newcounter {subparagraph}[paragraph]
\renewcommand \thepart {\@Roman\c@part}
\renewcommand \thechapter {\@arabic\c@chapter}
\renewcommand \thesection  {\thechapter.\@arabic\c@section}
\renewcommand\thesubsection   {\thesection.\@arabic\c@subsection}
\renewcommand\thesubsubsection {\thesubsection.\@arabic\c@subsubsection}
\renewcommand\thesubsubsubsection  {\thesubsubsection.\@arabic\c@subsubsubsection}
\renewcommand\theparagraph    {\thesubsubsubsection.\@arabic\c@paragraph}
\renewcommand\thesubparagraph {\theparagraph.\@arabic\c@subparagraph}
\def\toclevel@chapter{0}
\def\toclevel@section{1}
\def\toclevel@subsection{2}
\def\toclevel@subsubsection{3}
\def\toclevel@subsubsubsection{4}
\def\toclevel@paragraph{5}
\def\toclevel@subparagraph{6}
\newcommand*\l@section{\@dottedtocline{1}{1.5em}{2.3em}}
\newcommand*\l@subsection{\@dottedtocline{2}{3.8em}{3.2em}}
\newcommand*\l@subsubsection{\@dottedtocline{3}{7.0em}{4.1em}}
\newcommand*\l@subsubsubsection{\@dottedtocline{4}{10em}{5em}}
\newcommand*\l@paragraph{\@dottedtocline{5}{12em}{6em}}
\newcommand*\l@subparagraph{\@dottedtocline{6}{14em}{7em}}

\setcounter{secnumdepth}{4}如果我设置和,就会发生以下情况\setcounter{tocdepth}{4}

在此处输入图片描述

如果我将上述内容设置为 3,就会发生以下情况:

在此处输入图片描述

测试子子子部分下的额外文本很奇怪,我不明白它是从哪里来的。

以下是用于产生图片输出的代码:

\documentclass[10pt,a4paper,titlepage,openright]{mybook}

\usepackage[utf8]{inputenc}
\usepackage[hidelinks]{hyperref}
\usepackage{titlesec}

\begin{document}

\tableofcontents
\section{Test Section}
test
\subsection{Test Subsection}
test
\subsubsection{Test Subsubsection}
test
\subsubsubsection{Test Subsubsubsection}
test
\paragraph{Test Paragraph}
test
\subparagraph{Test Subparagraph}
test

\end{document}

相关内容