1

I'm trying to create:

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

I followed the code from an earlier thread, but instead of getting "Hypothesis 3", I get "Hypothesis 2c".

What should I do to get "Hypothesis 3"? Thanks so much for all your help.

\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
1

You can adapt the code for subequations from amsmath. Since this is independent from ntheorem, I omit that part from the example; you can add the setting for the theorem.

\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}

enter image description here

0

The code you've provided generates the number "3a" for the final hypothesis. If you want it to be numbered "3", i.e., without any suffix, you need to replace the final \theoremgroup directive with

\counterwithout{theorem}{pretheorem}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.