2

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.

1 Answers1

3

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

enter image description here

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

\begin{equation} y = ax + b \label{eqn:first} \end{equation}

\usealternateeqn

\begin{equation} E = mc^2 \label{eqn:second} \end{equation}

\begin{equation} S = r^2 \label{eqn:third} \end{equation}

\useoriginaleqn

\begin{equation} y = x^2 \label{eqn:fourth} \end{equation}

\usealternateeqn

\begin{equation} f(x) \vcentcolon= 4x \end{equation}

\useoriginaleqn

\begin{equation} abc \end{equation}

\begin{equation} bca \end{equation}

\begin{equation} cab \end{equation}

\end{document}
Werner
  • 603,163
  • 1
    More work is required if this also has to work with hyperref (and avoid duplicate hyperlink targets). – Werner Mar 29 '17 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? –  Mar 29 '17 at 20:47
  • 1
    @Jack: I've updated the answer to be compatible with hyperref. The requirement is to update \theHequation. – Werner Mar 29 '17 at 21:07