1

I want to have sub-hypotheses so I use following code:

    \newtheorem{hyp}{Hypothesis}

    \makeatletter
    \newcounter{subhyp} 
    \let\savedc@hyp\c@hyp
    \newenvironment{subhyp}
    {%
    \setcounter{subhyp}{0}%
    \stepcounter{hyp}%
    \edef\saved@hyp{\thehyp}% Save the current value of hyp
    \let\c@hyp\c@subhyp     % Now hyp is subhyp
    \renewcommand{\thehyp}{\saved@hyp\alph{hyp}}%
    }
    {}
    \newcommand{\normhyp}{%
    \let\c@hyp\savedc@hyp % revert to the old one
    \renewcommand\thehyp{\arabic{hyp}}%
    } 
    \makeatother

It works great, however there is no break in the hypothesis numbering across chapters. I want the counter on the hypotheses to restart at the beginning of each new chapter. Can anyone help me modify this to restart the counter?

Here is a MWE:

    \documentclass{report}
    \usepackage{ntheorem}}
    \newtheorem{hyp}{Hypothesis}

    \makeatletter
    \newcounter{subhyp} 
    \let\savedc@hyp\c@hyp
    \newenvironment{subhyp}
    {%
    \setcounter{subhyp}{0}%
    \stepcounter{hyp}%
    \edef\saved@hyp{\thehyp}% Save the current value of hyp
    \let\c@hyp\c@subhyp     % Now hyp is subhyp
    \renewcommand{\thehyp}{\saved@hyp\alph{hyp}}%
    }
    {}
    \newcommand{\normhyp}{%
    \let\c@hyp\savedc@hyp % revert to the old one
    \renewcommand\thehyp{\arabic{hyp}}%
    } 
    \makeatother

    \begin{document}
    \chapter{This is Chapter 1}

    \begin{subhyp}
    \begin{hyp}
    This is hypothesis 1A
    \end{hyp}
    \begin{hyp}
     This is hypothesis 1B
    \end{hyp}
    \end{subhyp}

    \chapter{This is Chapter 2}
    \begin{subhyp}
    \begin{hyp}
    This should be hypothesis 1A
    \end{hyp}
    \begin{hyp}
     This should be hypothesis 1B
    \end{hyp}
    \end{subhyp}
    \end{document}
Werner
  • 603,163
AdamU
  • 11

0 Answers0