按字典顺序对章节、小节、小节和所有类定理环境进行编号

按字典顺序对章节、小节、小节和所有类定理环境进行编号

我希望章节、子章节、子章节和所有类定理环境的编号都严格按照字典顺序排列。此外,类定理环境的编号包含在

  • X 部分应以 X 开头。
  • XY 小节应以 XY 开头
  • 子节 XYZ 应以 XYZ 开头

此外,我们不希望有无用的零,即对于所有的 X、Y、Z,

  • 如果出现 0.X,则 1 也会出现(也许,作为某个 1 的前缀...),
  • 如果出现 X.0.Y,则 X.1 也会出现(也许,作为某些 X.1 的前缀...),
  • 如果 XY0.Z 出现,则 XY1 也会出现(也许,作为某些 XY1 的前缀……)。

我们可以认为,从算法上移除无用的零就是将所有 0.X 转换为 X 直到饱和,然后将所有 X.0.Y 转换为 XY 直到饱和,然后将所有 XY0.Z 转换为 XYZ 直到饱和。(这是针对人类的算法,不是针对 TeX 的算法。)

此外,最近的 \section、\subsection 或 \subsubsection 之后的第一个类定理环境的数字应该以 1 结尾。

我正在使用带有 amsthm 和 cleveref 包的 IEEEtran 类。

AMS FAQ 仅提到了部分非自动解决方案,涉及几个类似于定理的环境,例如“定理”。不久前,comp.text.tex 上有一个针对书籍类的部分解决方案。IEEEtran & amsthm & cleveref 是否有自动解决方案?是否有可以替代 amsthm 的方案来完成这项工作?

已附上 MWE。

提前谢谢大家!!!

\documentclass[10pt,journal,compsoc]{IEEEtran}
\usepackage{ifxetex,ifluatex}
\newif\ifxetexorluatex
\ifxetex
  \xetexorluatextrue
\else
  \ifluatex
    \xetexorluatextrue
  \else
    \xetexorluatexfalse
  \fi
\fi

\usepackage[ngerman,american]{babel}
\usepackage{amsmath}
\ifxetexorluatex
\usepackage{unicode-math}
\fi
\usepackage[unicode=true,
 bookmarks=false,
 breaklinks=false,pdfborder={0 0 1},%backref=section,
 colorlinks=false,hidelinks]{hyperref}
\usepackage{amsthm}
\usepackage[nosort]{cleveref}% nosort just for the purpose of debugging
\usepackage{mathtools}

\theoremstyle{definition}
\newtheorem{defn}{Definition}[subsection]
\newtheorem{exmp}[defn]{Example}
\newtheorem*{exmp*}{Example}
\theoremstyle{plain}
\newtheorem{lem}[defn]{Lemma}
\newtheorem{prop}[defn]{Proposition}
\newtheorem{thm}[defn]{Theorem}
\newtheorem{corl}[defn]{Corollary}
\theoremstyle{remark}
\newtheorem{note}[defn]{Note}

\crefname{section}{\S}{\S\S}
\crefname{subsection}{\S}{\S\S}
\crefname{subsubsection}{\S}{\S\S}
\crefformat{section}{\S\,#2#1#3}
\crefformat{subsection}{\S\,#2#1#3}
\crefformat{subsubsection}{\S\,#2#1#3}
\crefname{lem}{Lemma}{Lemmas}
\Crefname{lem}{Lemma}{Lemmas}
\crefname{defn}{Def.}{Defs.}
\Crefname{defn}{Def.}{Defs.}
\crefname{figure}{Fig.}{Figs.}
\Crefname{figure}{Fig.}{Figs.}
\crefname{thm}{Thm.}{Thms.}
\Crefname{thm}{Thm.}{Thms.}
\crefname{exmp}{Example}{Examples}
\Crefname{exmp}{Example}{Examples}
\crefname{prop}{Prop.}{Props.}
\Crefname{prop}{Prop.}{Props.}
\crefname{corl}{Cor.}{Cors.}
\Crefname{corl}{Cor.}{Cors.}
\crefname{enumi}{part}{parts}
\Crefname{enumi}{Part}{Parts}

\begin{document}
Introduction
\begin{defn}\label{ZO}Want the number 0.1 here.\end{defn}
\section{Initial Section}
\begin{exmp}\label{OZO}Want the number 1.0.1 here.\end{exmp}
\begin{lem}\label{OZT}Want the number 1.0.2 here.\end{lem}
\subsection{Initial Subsection}
\begin{exmp*}Want no number here.\end{exmp*}
\begin{prop}\label{OOO}Want number 1.1.1 here.\end{prop}
\begin{thm}\label{OOT}Want number 1.1.2 here.\end{thm}
\subsection{Another Subsection}
\begin{corl}\label{OTO}Want number 1.2.1 here.\end{corl}
\begin{note}\label{OTT}Want number 1.2.2 here.\end{note}

\section{Another section}
\begin{defn}\label{TZO}Want number 2.0.1 here.\end{defn}
\begin{exmp}\label{TZT}Want number 2.0.2 here.\end{exmp}
\subsection{Some subsection}
\begin{lem}\label{TOZO}Want number 2.1.0.1 here.\end{lem}
\begin{prop}\label{TOZT}Want number 2.1.0.2 here.\end{prop}
\subsubsection{Some subsubsection}
\begin{thm}\label{TOOO}Want number 2.1.1.1 here.\end{thm}
\begin{corl}\label{TOOT}Want number 2.1.1.2 here.\end{corl}
\subsubsection{Another subsubsection}
\begin{note}\label{TOTO}Want number 2.1.2.1 here.\end{note}
\begin{defn}\label{TOTT}Want number 2.1.2.2 here.\end{defn}
\subsection{Some subsection}
\begin{exmp}\label{TTZO}Want number 2.2.0.1 here.\end{exmp}
\begin{lem}\label{TTZT}Want number 2.2.0.2 here.\end{lem}
\subsubsection{Some subsubsection}
\begin{prop}\label{TTOO}Want number 2.2.1.1 here.\end{prop}
\begin{thm}\label{TTOT}Want number 2.2.1.2 here.\end{thm}
\subsubsection{Another subsubsection}
\begin{corl}\label{TTTO}Want number 2.2.2.1 here.\end{corl}
\begin{note}\label{TTTT}Want number 2.2.2.2 here.\end{note}

\appendices
\section{Some appendix}
\begin{defn}\label{AZO}Want number A.0.1 here.\end{defn}
\begin{exmp}\label{AZT}Want number A.0.2 here.\end{exmp}
\subsection{Some subsubsection}
\begin{lem}\label{AOO}Want number A.1.1 here.\end{lem}
\begin{prop}\label{AOT}Want number A.1.2 here.\end{prop}
\subsection{Another subsubsection}
\begin{thm}\label{ATO}Want number A.2.1 here.\end{thm}
\begin{corl}\label{ATT}Want number A.2.2 here.\end{corl}

\section{Another appendix}
\begin{note}\label{BZO}Want number B.0.1 here.\end{note}
\begin{defn}\label{BZT}Want number B.0.2 here.\end{defn}
\subsection{Some subsection}
\begin{exmp}\label{BOZO}Want number B.1.0.1 here.\end{exmp}
\begin{lem}\label{BOZT}Want number B.1.0.2 here.\end{lem}
\subsubsection{Some subsubsection}
\begin{prop}\label{BOOO}Want number B.1.1.1 here.\end{prop}
\begin{thm}\label{BOOT}Want number B.1.1.2 here.\end{thm}
\subsubsection{Another subsubsection}
\begin{corl}\label{BOTO}Want number B.1.2.1 here.\end{corl}
\begin{note}\label{BOTT}Want number B.1.2.2 here.\end{note}
\subsection{Some subsection}
\begin{defn}\label{BTZO}Want number B.2.0.1 here.\end{defn}
\begin{exmp}\label{BTZT}Want number B.2.0.2 here.\end{exmp}
\subsubsection{Some subsubsection}
\begin{lem}\label{BTOO}Want number B.2.1.1 here.\end{lem}
\begin{prop}\label{BTOT}Want number B.2.1.2 here.\end{prop}
\subsubsection{Another subsubsection}
\begin{thm}\label{BTTO}Want number B.2.2.1 here.\end{thm}
\begin{corl}\label{BTTT}Want number B.2.2.2 here.\end{corl}

And now let us reference them all:

\Cref{ZO,OZO,OZT,OOO,OOT,OTO,OTT,TZO,TZT,TOZO,TOZT,TOOO,TOOT,TOTO,TOTT,TTZO,TTZT,TTOO,TTOT,TTTO,TTTT,AZO,AZT,AOO,AOT,ATO,ATT,BZO,BZT,BOZO,BOZT,BOOO,BOOT,BOTO,BOTT,BTZO,BTZT,BTOO,BTOT,BTTO,BTTT}
\end{document}

相关内容