我有这样的事情:
Section 1
...
Section 2
...
Section 3
Subsection 3.1
...
Section 4
...
Run Code Online (Sandbox Code Playgroud)
我希望有这样的事情:
Section 1
...
Section 2
...
Section A
Subsection A.1
...
Section 4
...
Run Code Online (Sandbox Code Playgroud)
换句话说 - 将一个部分编号更改为其他部分3 == A我需要这个用于我的论文,这是在文章课上写的,当我试图添加附录时,hyperref包破了,并且"链接"到第1部分指向附录一个
编辑:我在描述问题时犯了一个错误,我的意思是目录不起作用,因为LaTeX生成代码(*.toc文件):
\contentsline {section}{\numberline {1}}{1}{section.1}
\contentsline {section}{\numberline {2}}{1}{section.2}
\contentsline {section}{\numberline {A}}{1}{section.1}
Run Code Online (Sandbox Code Playgroud)
我创建了以下构造,现在更新它:
说明:
部分的新计数器,仅用于\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}
}%
Run Code Online (Sandbox Code Playgroud)
在文件中:
\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
Run Code Online (Sandbox Code Playgroud)
产品:
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
Run Code Online (Sandbox Code Playgroud)
经过测试,可与HyperRef配合使用.
| 归档时间: |
|
| 查看次数: |
20072 次 |
| 最近记录: |