# How can I have two sets of numbering for formulas?

How can I have two sets of numbering for formulas in an article like the following:

(1) y=ax+b

(i) E=mc^2

(ii) S=r^2

(2) y=x^2

(iii) f(x):=4x

(3) abc

(4) bca

(5) cab

I have read answers to this related question. But I cannot adapt those codes to the case here since another set of numbering is only used in the "Definition" environment in the linked question; while in my question, I would like to be able to switch between two sets of numbering whenever I want.

• Using \tag you can even number them randomly. Commented Mar 29, 2017 at 20:21

Below I defined an alternative equation counter, and use \useoriginaleqn and \usealternateeqn to switch between using either. The switch also updates the representation:

\documentclass{article}

\usepackage{mathtools}

\makeatletter
\newcounter{altequation}
\let\c@equationstore\c@equation
\let\c@altequationstore\c@altequation
% Switch between different equation counters/representations
\newcommand{\useoriginaleqn}{%
\let\c@equation\c@equationstore
\renewcommand{\theequation}{\arabic{equation}}}
\newcommand{\usealternateeqn}{%
\let\c@equation\c@altequation
\renewcommand{\theequation}{\roman{equation}}}
\makeatletter

\AtBeginDocument{\def\theHequation{\theHsection.\theequation}}

\begin{document}

See the following equations: \eqref{eqn:first}, \eqref{eqn:second}, \eqref{eqn:third}, \eqref{eqn:fourth}

$$y = ax + b \label{eqn:first}$$

\usealternateeqn

$$E = mc^2 \label{eqn:second}$$

$$S = r^2 \label{eqn:third}$$

\useoriginaleqn

$$y = x^2 \label{eqn:fourth}$$

\usealternateeqn

$$f(x) \vcentcolon= 4x$$

\useoriginaleqn

$$abc$$

$$bca$$

$$cab$$

\end{document}

• More work is required if this also has to work with hyperref (and avoid duplicate hyperlink targets).
– Werner
Commented Mar 29, 2017 at 20:42
• Thank you for your answer! I do use the package hyperref. Would you please elaborate a little bit regarding what should be done further?
– user5590
Commented Mar 29, 2017 at 20:47
• @Jack: I've updated the answer to be compatible with hyperref. The requirement is to update \theHequation.
– Werner
Commented Mar 29, 2017 at 21:07