2

I am using IEEEtran for typesetting and it seems that subequations are cited appropriately when leaving their numbering to the default value. When I customize it, however, the equation numbering resets to 1 for all subequations, but when I reference them, they are referenced correctly.

enter image description here

Here is my source code:

\documentclass[]{IEEEtran}

    \usepackage{amsmath}
    \usepackage{amssymb, amsfonts}
    \usepackage{adjustbox}
    \usepackage[]{mathtools}

        % Custom equation numbering for journals

            % Numbering style
            \newtagform{Eq}[\renewcommand{\theequation}{[\arabic{equation}]}]{}{}
            \usetagform{Eq}

            % Referencing style
            \renewcommand{\theequation}{\arabic{equation}}


    \usepackage{etoolbox}
    \patchcmd{\subequations}{\alph{equation}}{-\Roman{equation}}{}{}



\begin{document}



\begin{equation}
    P =
    \begin{dcases}
    %
    E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s}
    \\
    \int x-3\, dx & \text{display style}
    %
    \end{dcases}
    %
    \label{eq:Eq1}
\end{equation}


\begin{subequations}


    \begin{align}
        I_{sc} & = I_{sc,ref} & \hspace{-15mm} \bigg[  1 + \frac{\alpha}{100} (T_{op}-T_{ref}) \biggl]
        \vspace{2 mm}
        \label{eq:SubEq1}
        \\
        %
        V_{oc} & = V_{oc,ref} & \hspace{-15mm} \bigg[  1 + \frac{\beta}{100} (T_{op}-T_{ref}) \biggl]
        \vspace{2 mm}
        \label{eq:SubEq2}
        \\
        %
        P_{mp} & = P_{mp,ref} & \hspace{-15mm} \bigg[  1 + \frac{\gamma}{100} (T_{op}-T_{ref}) \biggl]
        \label{eq:SubEq3}
    \end{align}


\end{subequations}

See SubEq. \ref{eq:SubEq1}


\begin{equation}
    P =
    \begin{dcases}
    %
    E = m c^2 & c \approx 3.00\times 10^{8}\,\mathrm{m}/\mathrm{s}
    \\
    \int x-3\, dx & \text{display style}
    %
    \end{dcases}
    %
    \label{eq:Eq4}
\end{equation}


\end{document}

As an aside, is there a way to customize subequations numbering without using \patchcmd command?

3

You need to modify (and simplify) the \newtagform instruction.

enter image description here

\documentclass[]{IEEEtran}
\usepackage{mathtools, amssymb, amsfonts}
\usepackage{etoolbox, calc, siunitx}

% Custom equation numbering for journals
\newtagform{Eq}{[}{]}
\usetagform{Eq}
\patchcmd{\subequations}{\alph{equation}}{-\Roman{equation}}{}{}
%% or, possibly:
%% \patchcmd{\subequations}{\alph{equation}}{-\arabic{equation}}{}{}

% utility macro
\newcommand\spbox[2]{\makebox[\widthof{$#1$}][r]{$#2$}}

\begin{document}

\begin{equation}
    P =
    \begin{dcases}
    %
    E = m c^2 & c \approx \SI{3.00e8}{\meter\per\second}
    \\
    \int x-3\, dx & \text{display style}
    %
    \end{dcases}
    %
    \label{eq:Eq1}
\end{equation}

\begin{subequations}
\begin{align}
    I_{\textrm{sc}} &= \spbox{P_{\textrm{mp,ref}}}{I_{\textrm{sc,ref}}}
    \Bigl[ 1 + \frac{\alpha}{100} (T_{\textrm{op}}-T_{\textrm{ref}}) \Bigr]
    \label{eq:SubEq1}
    \\[2mm]
    %
    V_{\textrm{oc}} &= \spbox{P_{\textrm{mp,ref}}}{V_{\textrm{oc,ref}}}
    \Bigl[ 1 + \frac{\beta}{100}  (T_{\textrm{op}}-T_{\textrm{ref}}) \Bigr]
    \label{eq:SubEq2}
    \\[2mm]
    %
    P_{\textrm{mp}} &= P_{\textrm{mp,ref}} 
    \Bigl[ 1 + \frac{\gamma}{100} (T_{\textrm{op}}-T_{\textrm{ref}}) \Bigr]
    \label{eq:SubEq3}
\end{align}
\end{subequations}
See subeq.~\eqref{eq:SubEq1}.

\begin{equation}
    P =
    \begin{dcases}
    %
    E = m c^2 & c \approx \SI{3.00e8}{\meter\per\second}
    \\
    \int x-3\, dx & \text{display style}
    %
    \end{dcases}
    %
    \label{eq:Eq4}
\end{equation}
\end{document}

Addendum to address the OP's follow-up comment, about why it's necessary to use \patchcmd to achieve the OP's formatting objective and, relatedly, why there is no counter called subequation (or subequations).

I'm not in a position to address the deep, philosopical why questions directly. (For one, I was never involved in the design of the amsmath package!) However, I can provide an explanation of what the subequations environment does. This explanation will, hopefully, address your why questions indirectly.

Let's begin by looking at the relevant code in the file amsmath.sty:

\newcounter{parentequation}% Counter for ``parent equation''.
% ...
\newenvironment{subequations}{%
  \refstepcounter{equation}%
  \protected@edef\theparentequation{\theequation}%
  \setcounter{parentequation}{\value{equation}}%
  \setcounter{equation}{0}%
  \def\theequation{\theparentequation\alph{equation}}%
  \ignorespaces
}{%
  \setcounter{equation}{\value{parentequation}}%
  \ignorespacesafterend
}
  • A new counter is defined, but it's called parentequation rather than subequation.

  • \subequations (equivalent to \begin{subequations}) executes the six lines of code that end with \ignorespaces.

  • When \subequations is run, the equation counter is stepped (via \refstepcounter). Next, the value of equation is assigned to the parentequation counter. E.g., if the value of the equation counter was "15" after being stepped, the value of parentequation is set to "15".

    The instruction \protected@edef\theparentequation{\theequation} takes care of the possibility that the author may need to cross-reference the group of (sub)equations as a whole. A call-out to the "parent equation" will use the format that's used for "normal" equations in other parts of the document.

  • Next, the equation counter is reset to 0 and the \theequation macro -- the macro that is used to display the counter -- is (re)defined as a composite of the parentequation and equation counters. Importantly, this redefinition of the \theequation macro is local to the subequations environment: it will cease to be in effect once the subequations environment ends.

  • After all this, the body of the subequations environment is entered. In this part, one usually finds environments such as equation, align, etc. As part of their work, these environments usually step the equation counter.

    The beauty (genius?!) of the subequations setup now becomes apparent: the subordinated equation, align, etc environments need not be informed at all that they are embedded in a subequations environment. Hence, the subordinated environments can keep doing their usual stuff, and they don't have to switch from stepping the equation counter to stepping the (non-existent) subequation counter. (And, they don't have to be informed when the subequations environment ends!)

  • When the subequations environment ends, the instructions \setcounter{equation}{\value{parentequation}} and \ignorespacesafterend are run. \setcounter{equation}{\value{parentequation}} serves to reset the value of the equation counter, to the value of parentequation. E.g., if the value of parentequation was "15", this value is transferred (back) to the equation counter.

To recap, the subequations environment does not require the subordinated equation-type environments (equation, align, etc) to do anything different from what they would do if they were not inside a subequations environment.

I'm not in a position to decide whether the simplicity of this setup was the reason for why it was chosen. Nevertheless, I think it's worth being aware of.

Speaking for myself, using \patchcmd to modify the innards of the subequations environment doesn't seem like a high price to pay for this simplicity. For sure, I wouldn't agree with the proposition that there's an issue with consistency (or inconsistency, as the case may be) in one's operations.

  • It works. Thank you :) But is there a way to modify subequations numbering without \patchcmd command? – Al-Motasem Aldaoudeyeh Mar 13 '18 at 6:31
  • @Al-MotasemAldaoudeyeh - Is there a reason for not using \patchcmd? BTW, I used the command mainly because you used it in your code. – Mico Mar 13 '18 at 7:00
  • I customize floats and main equations without having to patch anything. It is a matter of consistency. Table counters, for example, are \thetable and main equations counters are \theequation, so why do not the subequations have a counter named \thesubequation? – Al-Motasem Aldaoudeyeh Mar 13 '18 at 7:25
  • @Al-MotasemAldaoudeyeh - I've provided an addendum to describe and discuss the setup of the subequations environment. The discussion, hopefully, also explains why your preferred modus operandi, viz., modify a counter called subequation, cannot be made to work. If you're worried that the "patch" in \patchcmd somehow implies that it does something half-baked, or "patchy", please rest assured that using \patchcmd is not, in any way at all, inferior. – Mico Mar 13 '18 at 10:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.