定理子假设

定理子假设

我正在尝试创建:

 Hypothesis 1a
 Hypothesis 1b
 Hypothesis 2a
 Hypothesis 2b
 Hypothesis 3

我遵循了先前的讨论,但我得到的不是“假设 3”,而是“假设 2c”。

我该怎么做才能得到“假设 3”?非常感谢您的帮助。

\documentclass{article}
\usepackage{ntheorem}
\theoremindent1\parindent
\theoremseparator{:}
\newtheorem{theorem}{Hypothesis}
\usepackage{chngcntr}
\newcounter{pretheorem}
\counterwithin{theorem}{pretheorem}
\renewcommand\thetheorem{\arabic{pretheorem}\alph{theorem}}
\newcommand{\theoremgroup}{\refstepcounter{pretheorem}}
\begin{document}
\theoremgroup
    \begin{theorem}
        This is Hypothesis 1a
    \end{theorem}

    \begin{theorem}
        This is Hypothesis 1b
    \end{theorem}
\theoremgroup
    \begin{theorem}
        This is Hypothesis 2a
    \end{theorem}
    \begin{theorem}
        This is Hypothesis 2b
    \end{theorem}
\theoremgroup
    \begin{theorem}
        This is Hypothesis 3, but I'm getting Hypothesis 2c
    \end{theorem}
\end{document}

答案1

subequations您可以调整来自的代码amsmath。由于这独立于ntheorem,因此我从示例中省略了该部分;您可以添加定理的设置。

\documentclass{article}

\newtheorem{hypothesis}{Hypothesis}

\makeatletter
\newcounter{parenthypothesis}
\newenvironment{subhypothesis}
 {
  \refstepcounter{hypothesis}%
  \protected@edef\theparenthypothesis{\thehypothesis}%
  \setcounter{parenthypothesis}{\value{hypothesis}}%
  \setcounter{hypothesis}{0}%
  \def\thehypothesis{\theparenthypothesis\alph{hypothesis}}%
  \ignorespaces
}{%
  \setcounter{hypothesis}{\value{parenthypothesis}}%
  \ignorespacesafterend
}
\makeatother

\begin{document}

\begin{subhypothesis}
\begin{hypothesis}
This is Hypothesis 1a
\end{hypothesis}

\begin{hypothesis}
This is Hypothesis 1b
\end{hypothesis}
\end{subhypothesis}

\begin{subhypothesis}
\begin{hypothesis}
This is Hypothesis 2a
\end{hypothesis}
\begin{hypothesis}
This is Hypothesis 2b
\end{hypothesis}
\end{subhypothesis}

\begin{hypothesis}
This is Hypothesis 3
\end{hypothesis}

\end{document}

在此处输入图片描述

答案2

您提供的代码为最终假设生成数字“3a”。如果您希望它被编号为“3”,即没有任何后缀,则需要将 final\theoremgroup指令替换为

\counterwithout{theorem}{pretheorem}

相关内容