关于 Counter 的疑问

关于 Counter 的疑问

我是 TeX 新手,我正在使用模板输入一些内容。我想对格式进行以下更改:

  1. 我想对所有的定理、命题、推论等使用相同的计数器。
  2. 我希望计数器计到节(如 1.1.1)而不是章(如 1.1)。

我知道如何在空白文件中执行此操作,只需使用代码

\newtheorem{theoremname}[counter]{Theoremname}[section]

但在这个模板中它不起作用。

.cls文件中相关代码如下:

% initialize theorem environment

\if@envcntshowhiercnt % show hierarchy counter
   \def\@thmcountersep{.}
   \spnewtheorem{theorem}{Theorem}[\envankh]{\bfseries}{\itshape}
   \@addtoreset{theorem}{chapter}
\else          % theorem counter only
   \spnewtheorem{theorem}{Theorem}{\bfseries}{\itshape}
   \if@envcntreset
      \@addtoreset{theorem}{chapter}
      \if@envcntresetsect
         \@addtoreset{theorem}{section}
      \fi
   \fi
\fi

%definition of divers theorem environments
\spnewtheorem*{claim}{Claim}{\itshape}{\rmfamily}
\spnewtheorem*{proof}{Proof}{\itshape}{\rmfamily}
%
\if@envcntsame % all environments like "Theorem" - using its counter
   \def\spn@wtheorem#1#2#3#4{\@spothm{#1}[theorem]{#2}{#3}{#4}}
\else % all environments with their own counter
   \if@envcntshowhiercnt % show hierarchy counter
      \def\spn@wtheorem#1#2#3#4{\@spxnthm{#1}{#2}[\envankh]{#3}{#4}}
   \else          % environment counter only
      \if@envcntreset % environment counter is reset each section
         \if@envcntresetsect
            \def\spn@wtheorem#1#2#3#4{\@spynthm{#1}{#2}{#3}{#4}
             \@addtoreset{#1}{chapter}\@addtoreset{#1}{section}}
         \else
            \def\spn@wtheorem#1#2#3#4{\@spynthm{#1}{#2}{#3}{#4}
                                      \@addtoreset{#1}{chapter}}
         \fi
      \else
         \let\spn@wtheorem=\@spynthm
      \fi
   \fi
\fi
%
\let\spdefaulttheorem=\spn@wtheorem
%
\spn@wtheorem{case}{Case}{\itshape}{\rmfamily}
\spn@wtheorem{conjecture}{Conjecture}{\itshape}{\rmfamily}
\spn@wtheorem{corollary}{Corollary}{\bfseries}{\itshape}
\spn@wtheorem{definition}{Definition}{\bfseries}{\rmfamily}
\spn@wtheorem{example}{Example}{\itshape}{\rmfamily}
\spn@wtheorem{exercise}{Exercise}{\bfseries}{\rmfamily}
\spn@wtheorem{lemma}{Lemma}{\bfseries}{\itshape}
\spn@wtheorem{note}{Note}{\itshape}{\rmfamily}
\spn@wtheorem{problem}{Problem}{\bfseries}{\rmfamily}
\spn@wtheorem{property}{Property}{\itshape}{\rmfamily}
\spn@wtheorem{proposition}{Proposition}{\bfseries}{\itshape}
\spn@wtheorem{question}{Question}{\itshape}{\rmfamily}
\spn@wtheorem{solution}{Solution}{\bfseries}{\rmfamily}
\spn@wtheorem{remark}{Remark}{\itshape}{\rmfamily}

这对我来说很难理解。有人能告诉我怎么做吗?提前谢谢。

答案1

如果您希望类定理环境共享计数器,请使用适当的选项svmult

\documentclass[envcountsame]{svmult}

% these are already defined
%\spnewtheorem{theorem}{Theorem}{\bfseries}{\itshape}
%\spnewtheorem{lemma}{Lemma}{\bfseries}{\itshape}
%\spnewtheorem{definition}{Definition}{\bfseries}{\upshape}

\begin{document}

\begin{lemma}
This is a lemma.
\end{lemma}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{definition}
This is a \emph{definition}
\end{definition}

\end{document}

在此处输入图片描述

如果您希望按部分编号:

\documentclass[envcountsame,envcountsect]{svmult}

% these are already defined
%\spnewtheorem{theorem}{Theorem}{\bfseries}{\itshape}
%\spnewtheorem{lemma}{Lemma}{\bfseries}{\itshape}
%\spnewtheorem{definition}{Definition}{\bfseries}{\upshape}

\begin{document}

\section{Title}

\begin{lemma}
This is a lemma.
\end{lemma}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{definition}
This is a \emph{definition}
\end{definition}

\end{document}

在此处输入图片描述

您还可以将 LaTeX 通用方法与nospthms选项一起使用。

\documentclass[nospthms]{svmult}

\usepackage{amsthm}

\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}

\begin{document}

\section{Title}

\begin{lemma}
This is a lemma.
\end{lemma}

\begin{theorem}
This is a theorem.
\end{theorem}

\begin{definition}
This is a \emph{definition}
\end{definition}

\end{document}

输出与前一个类似。

相关内容