TransWikia.com

Subequation numbering in iopart

TeX - LaTeX Asked by bjorne on August 11, 2021

Given a system of equations (1a), (1b), etc. I want to be able to reference both (1a) and the entire system (1). This is trivial with subequations, but in an iopart document this environment does not seem to be supported (no amsmath, I guess) and the recommendation is to use numparts ... endnumparts. However, with numparts, I cannot manage to reference properly. First, eqnarrays do not seem to be referenceable (not an issue with numparts, but still), and second, even if I put everything into equation environments which are referenceable, I still cannot refer to the entire system.

MWE:

documentclass[10pt]{iopart}
usepackage{cleveref}
crefname{equation}{}{}
begin{document}
    
    section{Example}
    
    numpartsbegin{eqnarray} label{system1}
    a=1, 
    b=2
    end{eqnarray}endnumparts
    
    numpartsbegin{equation} label{system2a}
    a=1
    end{equation}begin{equation} label{system2b}
    b=2
    end{equation}endnumparts
    
    cref{system1} should read (1) but instead labels the section
    cref{system2a,system2b} should read (2) but instead reads (2a) and (2b)
end{document}

One Answer

The iopart class makes several fundamental errors, the main one doing a silly thing that makes it incompatible with amsmath.

I tried to contact the support team, but got no answer at all.

Another error is in the definition of numparts where the equation counter is stepped with addtocounter instead of refstepcounter.

However, eqnarray doesn't behave well with cleveref, so in order to refer to the single equations you need to use the plain ref.

documentclass[10pt]{iopart}
usepackage{cleveref}
usepackage{etoolbox}

crefname{equation}{}{}

patchcmd{numparts}{addtocounter{equation}{1}}{refstepcounter{equation}}{}{}

begin{document}

setcounter{section}{8} % just to test
    
section{Example}
    
begin{numparts}label{system1}
begin{eqnarray}
  a&=&1,label{system1a}
  b&=&2label{system1b}
end{eqnarray}
end{numparts}
begin{numparts}label{system2}
begin{equation} label{system2a}
  a=1
end{equation}
begin{equation} label{system2b}
  b=2
end{equation}
end{numparts}

cref{system1} refers to the first system; separately ref{system1a} and ref{system1b}

cref{system2} refers to the second system; separately cref{system2a,system2b}

end{document}

enter image description here

On the other hand, I'd simply ignore what the people at IOP think and use amsmath.

documentclass[10pt]{iopart}

% for using amsmath
expandafterletcsname equation*endcsnamerelax
expandafterletcsname endequation*endcsnamerelax

usepackage{amsmath}
usepackage{etoolbox}

patchcmd{subequations}{alph{equation}}{textit{alph{equation}}}{}{}

usepackage{cleveref}

crefname{equation}{}{}

begin{document}

setcounter{section}{8} % just to test
    
section{Example}
    
begin{subequations}label{system1}
begin{align}
  a&=1,label{system1a}
  b&=2label{system1b}
end{align}
end{subequations}
begin{subequations}label{system2}
begin{equation} label{system2a}
  a=1
end{equation}
begin{equation} label{system2b}
  b=2
end{equation}
end{subequations}

cref{system1} refers to the first system; separately cref{system1a,system1b}

cref{system2} refers to the second system; separately cref{system2a,system2b}

end{document}

I bet they wouldn't discover it. The patch to emulate the output of iopart with the subequation letter in italics has to be made before loading cleveref.

Correct answer by egreg on August 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP