想要向自定义 .cls 文件添加子节编号

想要向自定义 .cls 文件添加子节编号

我从一本期刊上获得了这个样式文件,并对其进行了修改。目前,定理编号方案仅使用两位数字:一位用于章节,一位用于条目。我不喜欢条目编号在每个新子节中不重置为 1。我想在编号方案中添加第三个数字,以便它使用 (Section.Subsection.Item)。第二节第三子节中的第一个定理应该是定理 2.3.1。我该如何更改它?下面,我提供了一个示例 tex 文件,我将把 CLS 文件放在注释中。谢谢!!!

TEX 文件:

\documentclass[leqno]{physics_custom}
\usepackage{hyperref}
\usepackage{amssymb,amsmath}
\usepackage{enumerate}
\usepackage{graphicx}
\usepackage{centernot}
\usepackage{bold-extra}
\usepackage{mathrsfs}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem{mainthm}[thm]{Main Theorem}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\theoremstyle{definition}
\newtheorem{defin}[thm]{Definition}
\newtheorem{rem}[thm]{Remark}
\newtheorem{exa}[thm]{Example}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newtheorem*{xrem}{Remark}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\numberwithin{equation}{section}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 

\begin{document}

%% Note that the first letters in the title are capitalized

%% Provide an abbreviation of the title, to be used in running heads.

\TitleHead{Paper about Hodor }
\title{Paper about Hodor}


\AuthorHead{Jim Bob}
\author{Jim \textsc{Bob}\footnote{Tooker: [email protected];}}



\maketitle
\thispagestyle{empty}
\begin{abstract}
Abstract goes here
\end{abstract}

\section{first section}

\begin{rem}
    I want to change it to make this Remark 1.0.1
\end{rem}

\subsection{first section, first subsection}

\begin{thm}
    Currently, this shows up as Theorem 1.2 but I want to change it to be Theorem 1.1.1 because it is the first theorem of the first subsection of the first subsection.
\end{thm}

\begin{lem}
    Should be Lemma 1.1.2
\end{lem}


\subsection{first section, second subsection}

\begin{exa}
    This example really shows what I don't like.  Currently it is Example 1.4 but I'd like it to be Example 1.2.1
\end{exa}


\section{second section}

\begin{cor}
    You probably get it by now, but this should be Corollary 2.0.1
\end{cor}


\begin{cor}
    Should be Corollary 2.0.2
\end{cor}


\begin{cor}
    Should be Corollary 2.0.3
\end{cor}



\subsection{second section, first subsection}

\begin{thm}
    Should be Theorem 2.1.1
\end{thm}



\subsection{second section, second subsection}


\begin{thm}
    Should be Theorem 2.2.1
\end{thm}


\subsection{second section, third subsection}


\begin{thm}
    Should be Theorem 2.3.1
\end{thm}

答案1

为了改变定理的数字显示方式,您必须执行以下操作:

\renewcommand*{\thethm}{\arabic{section}.\arabic{subsection}.\arabic{thm}}

这将重新定义 thm 计数器的显示方式。由于您的所有定理都共享 thm 计数器,因此它们都将按您想要的方式显示。

然后,当您编写\newtheorem{thm}{Theorem}[section]它时,意味着每次使用环境时thm,thm 计数器都会增加一,并且每次使用时都会重置为 0。\section考虑到您想要的行为,您应该使用,\newtheorem{thm}{Theorem}[subsection]以便每次使用时重置计数器\subsection

相关内容