I'd like to have two equation-like environments, with separate numbering, and easily use them inside various amsmath environments.
Inspired by an answer by Egreg to Clone of the `amsmath` equation environment with different spacing, I wrote
\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\newcounter{savedequation} \newcounter{myhypo}
\newcommand{\setmyhypo}{%
\setcounter{savedequation}{\value{equation}}%
\setcounter{equation}{\value{myhypo}}%
\renewcommand\theequation{$H_\arabic{equation}$}%
}
\newcommand{\unsetmyhypo}{%
\setcounter{myhypo}{\value{equation}}%
\setcounter{equation}{\value{savedequation}}%
}
\newenvironment{hypothesis}{%
\setmyhypo%
\begin{equation}%
}{%
\end{equation}%
\unsetmyhypo%
}
\begin{document}
\begin{hypothesis} \label{test_1} a=b \end{hypothesis}
\begin{gather}
\label{test_2} c=d \
\setmyhypo
\notag e=f \
\label{test_3} h=i
\unsetmyhypo
\end{gather}
\setmyhypo
\begin{gather}
\label{test_4} j=k \
\notag l=m
\end{gather}
\unsetmyhypo
\eqref{test_1}, \eqref{test_2} and \eqref{test_4} work but not \eqref{test_3}.
\end{document}
Any idea on how to use both equation-like environments inside the same gather (it may be cleaner for alignment purpose)?
Edit: refinements:
\makeatletter
\newcommand{\setmyhypo}{%
\setcounter{savedequation}{\value{equation}}%
\setcounter{equation}{\value{myhypo}}%
\renewcommand\theequation{$H_{\arabic{equation}}$}%
\tagsleft@true\let\veqno\@@leqno%
}
\newcommand{\unsetmyhypo}{%
\setcounter{myhypo}{\value{equation}}%
\setcounter{equation}{\value{savedequation}}%
\renewcommand\theequation{\arabic{equation}}%
\tagsleft@false\let\veqno@@eqno%
}
\makeatother
