LaTeX:如何将一个节号更改为自定义字母?
我有这样的想法:LaTeX:如何将一个节号更改为自定义字母?,latex,pdflatex,Latex,Pdflatex,我有这样的想法: Section 1 ... Section 2 ... Section 3 Subsection 3.1 ... Section 4 ... Section 1 ... Section 2 ... Section A Subsection A.1 ... Section 4 ... 我想要这样的东西: Section 1 ... Section 2 ... Section 3 Subsection 3.1 ... Section 4 ... Section 1 ... S
Section 1
...
Section 2
...
Section 3
Subsection 3.1
...
Section 4
...
Section 1
...
Section 2
...
Section A
Subsection A.1
...
Section 4
...
我想要这样的东西:
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包坏了,并且指向附录A的第1节的“链接”
编辑:
我在描述问题时犯了一个错误,我的意思是目录不起作用,因为LaTeX生成代码(*.toc文件):
看看这个包。我创建了以下结构,现在对其进行了更新: 说明:
\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
节的新计数器,仅在\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
在文档中:
\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
产生:
\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配合使用。好的,我使用@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
现在目录工作了,它按应有的方式显示给桑德拉,
我在使用上面的Pindatjuh代码时遇到了间距问题。这影响了所有的名单。
我修正了在代码第三块的几行末尾添加“%”的问题。现在我没有了间隔
发件人:
致:
Karpik的问题(hyperref的问题)可以通过在hyperref包中添加选项[naturalnames]来更轻松地解决:
\usepackage[naturalnames]{hyperref}
问题是hyperref包A与1相同,因此指向第1节的链接直接指向A节我需要一个命令,该命令将告诉LaTeX保持原始计数器运行,但显示不同的值(在我的示例中,保持数字3但显示A,保持数字4但显示B)@user309937修复了该问题;)享受吧!