# [Tex/LaTex] Hypotheses and Subhypotheses with ntheorem

ntheorem

The goal is to have an environment that can, depending on a trigger, either create this:

Hypothesis 1 The better the answer, the higher the score.

or that

Hypothesis 2a Higher score is positive correlated with shoesize.

Hypothesis 2b Lower score is negative correlated with shoesize.

I tried a code I found in Google Groups, and it works. However it produces some error messages which I don't understand. Please see the minimal example below:

\documentclass{article}
\usepackage{ntheorem}
\newtheorem{hyp}{Hypothesis}
\newcounter{subhyp}
\newcommand{\subhyp}{
\setcounter{subhyp}{0}
\renewcommand\thehyp{\protect\stepcounter{subhyp}%
}
\newcommand{\normhyp}{
\renewcommand\thehyp{\arabic{hyp}}
\stepcounter{hyp}
}
\begin{document}

\normhyp
\begin{hyp}
The better the answer, the higher the score.
\end{hyp}

\subhyp
\begin{hyp}
Higher score is positive correlated with shoesize.
\end{hyp}

\begin{hyp}
Lower score is negative correlated with shoesize.
\end{hyp}

\end{document}


I'd avoid abusing \thehyp: you'll be in trouble if you want to get a list of hypotheses, for instance.

In my opinion, the best approach is to enclose the "subhypotheses" in an environment that changes the meaning of the hyp counter and of some related things.

\documentclass{article}
\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}

\begin{hyp}
The better the answer, the higher the score.
\end{hyp}

\begin{subhyp}
\begin{hyp}
Higher score is positive correlated with shoesize.
\end{hyp}

\begin{hyp}
Lower score is negative correlated with shoesize.
\end{hyp}
\end{subhyp}

\begin{hyp}
Something
\end{hyp}

\begin{subhyp}
\begin{hyp}
Again
\end{hyp}
\begin{hyp}
And again
\end{hyp}
\end{subhyp}

\begin{hyp}
Will it work?
\end{hyp}

\end{document}


You can still use \subhyp and \normhyp, if you prefer, but it's better to profit of the group structure of LaTeX.