我创建了以下结构,现在对其进行了更新:
说明:
节的新计数器,仅在\begin{alphasection}
...\end{alphasection}
块中使用。不要嵌套块,否则原始节号会丢失;在这种情况下会给出一条错误消息。每个块将从“A”开始重新计数。原始节计数继续进行,因为这是 HyperRef 所必需的。
将以下代码放在序言中:
\newcounter{alphasect}
\def\alphainsection{0}
\let\oldsection=\section
\def\section{%
\ifnum\alphainsection=1%
\addtocounter{alphasect}{1}
\fi%
\oldsection}%
\renewcommand\thesection{%
\ifnum\alphainsection=1%
\Alph{alphasect}
\else%
\arabic{section}
\fi%
}%
\newenvironment{alphasection}{%
\ifnum\alphainsection=1%
\errhelp={Let other blocks end at the beginning of the next block.}
\errmessage{Nested Alpha section not allowed}
\fi%
\setcounter{alphasect}{0}
\def\alphainsection{1}
}{%
\setcounter{alphasect}{0}
\def\alphainsection{0}
}%
在文件中:
\section{First test}
First content
\section{Second test}
Second content
\begin{alphasection}
\section{Third test}
\subsection{Subsection test}
Content test
\section{Test Other section}
\end{alphasection}
\section{Fourth test}
Last content
生产:
1 First test
First content
2 Second test
Second content
A Third test
A.1 Subsection test
Content test
B Test Other section
5 Fourth test
Last content
经过测试,可与 HyperRef 一起使用。