可以设置一个文档结构层级newlevel
,它不受任何其他计数器(如、、section
等)的从属,也就是说,当 else sec 计数器加 1 时,新层级计数器不会改变。因此,我们得到如下文档:subsection
subsubsection
section 1: the first section
subsection 1.1: the 1st subsection of the fist section
subsection 1.2: the 2nd subsection of the fist section
newlevel 1: I
subsection 1.3: the 3rd subsection of the fist section
newlevel 2: Have
section 2: the second subsection of the fist section
newlevel 3: A
subsection 2.1: the 1st subsection of the second section
subsection 2.2: the 2nd subsection of the second section
subsection 2.3: the 3rd subsection of the second section
newlevel 4: Dream
我想要实现这些的最根本原因是我可以在目录和标题中显示新级别的标签和标题。
答案1
是的,这是可能的。子节等的计数器仅在设置节计数器时重置,因为它们的定义方式如下:
\newcounter {subsection}[section]
因此,只需定义您的新级别以便使用独立的计数器,然后使用 \@startsection:
\documentclass{article}
\usepackage{color}
\makeatletter
\newcounter{newlevel}
\newcommand\newlevel{\@startsection {newlevel}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\color{blue}\normalfont\Large\bfseries}}
\newcommand\newlevelmark[1]{}
\begin{document}
\section{a}
\subsection{b}
\newlevel{I}
\newlevel{have}
\section{b}
\newlevel{a}
\subsection{c}
\newlevel{dream}
\end{document}