6

我有这样的事情:

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 节指向附录一种

编辑:我在描述问题时犯了一个错误,我的意思是目录不起作用,因为 LaTeX 生成代码(*.toc 文件):

\contentsline {section}{\numberline {1}}{1}{section.1}
\contentsline {section}{\numberline {2}}{1}{section.2}
\contentsline {section}{\numberline {A}}{1}{section.1}
4

5 回答 5

8

我创建了以下结构,现在对其进行了更新

说明

节的新计数器,仅在\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 一起使用。

于 2010-05-15T10:34:43.930 回答
3

对于 Sandra,我在使用上面的 Pindatjuh 代码时遇到了间距问题。它影响了所有列表。我修复了它,在其代码的第三块的几行末尾添加了“%”。现在我没有间距了。

从:

\renewcommand\thesection{%
 \ifnum\alphainsection=1% 
   \Alph{alphasect}
 \else%
  \arabic{section}
 \fi%
}%

到:

\renewcommand\thesection{%
 \ifnum\alphainsection=1% 
   \Alph{alphasect}%
 \else
   \arabic{section}%
 \fi%
}%
于 2012-04-16T04:54:27.947 回答
1

通过将选项 [naturalnames] 添加到 hyperref 包,可以更轻松地解决 Karpik 遇到的问题(hyperref 问题): \usepackage[naturalnames]{hyperref}

于 2012-08-29T11:47:22.767 回答
0

看看titlesec包。

于 2010-05-15T10:09:33.163 回答
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}%%
 }%

比文档中的:

\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

现在内容列表有效,并按应有的方式显示

于 2010-05-15T12:06:59.010 回答