我有这样的事情:
Section 1
...
Section 2
...
Section 3
Subsection 3.1
...
Section 4
...
我想有这样的事情:
Section 1
...
Section 2
...
Section A
Subsection A.1
...
Section 4
...
换句话说 - 将部分编号之一改为其他3 == A. 我需要这个用于我的论文,这是在文章课上写的,当我试图添加附录时, hyperref 包破了,并且“链接”到第1部分指向附录A
编辑: 我在描述问题时犯了一个错误,我的意思是目录不起作用,因为LaTeX生成代码(* .toc文件):
\contentsline {section}{\numberline {1}}{1}{section.1}
\contentsline {section}{\numberline {2}}{1}{section.2}
\contentsline {section}{\numberline {A}}{1}{section.1}
答案 0 :(得分:6)
我创建了以下构造,现在更新了它:
<强>描述强>:
部分的新计数器,仅在\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。
答案 1 :(得分:2)
自:
\renewcommand\thesection{%
\ifnum\alphainsection=1%
\Alph{alphasect}
\else%
\arabic{section}
\fi%
}%
致:
\renewcommand\thesection{%
\ifnum\alphainsection=1%
\Alph{alphasect}%
\else
\arabic{section}%
\fi%
}%
答案 2 :(得分:1)
通过在hyperref包中添加选项[naturalnames],可以更轻松地解决Karpik遇到的问题(hyperref问题):
\usepackage[naturalnames]{hyperref}
答案 3 :(得分:0)
查看titlesec包。
答案 4 :(得分:0)
好的,我使用@Pindatjuh代码解决它,解决方案非常难看......
\newcounter{alphasect}
\renewcommand\thesection{%
\ifnum\value{alphasect}=1%
A%%
\else
\ifnum\value{alphasect}=2%
B%%
\else
\ifnum\value{alphasect}=3%
C%%
\else
\ifnum\value{alphasect}=4%
D%%
\else
\arabic{section}%%
\fi\fi\fi\fi}%
\newenvironment{asection}{%
\setcounter{alphasect}{1}%%
}{%
\setcounter{alphasect}{0}%%
}%
\newenvironment{bsection}{%
\setcounter{alphasect}{2}%%
}{%
\setcounter{alphasect}{0}%%
}%
a比文件:
\section{First test}
First content
\section{Second test}
Second content
\begin{asection}
\section{Third test}
\subsection{Subsection test}
Content test
\end{asection}
\begin{bsection}
\section{Test Other section}
\end{bsection}
\section{Fourth test}
Last content
现在内容列表有效,并且显示为