TransWikia.com

Use of subequations and theorem environment

TeX - LaTeX Asked on May 12, 2021

I have a rather tricky (at least for me) equation numbering problem. I have a document with lots of numbered equations. Part way through the document I have a lemma (see below) for which I want to be able to reference each case with the format Lemma#(case number in lower-case roman numerals). So in my MWE I would want to reference the first case as ‘Lemma 1(i)’. I have seen promise using the subequation package but wasn’t able to fully get it working. How can this be done?

Here is a MWE:

documentclass[11pt]{article}

usepackage{amsmath,amssymb,amsthm}
usepackage{mathrsfs,mathtools}
newtheorem{lemma}{Lemma}
begin{document}

Here's a numbered equation
begin{equation}
E=mc^2
end{equation}

begin{lemma}[Explicit forms for $f(x)$]
label{lem:forms_of_f}
[
f(x)=%
begin{cases}
1 &(mathrm i)[0.5em]
int_0^infty e^{-x},mathrm dx &(mathrm{ii})[0.5em]
9sum_{k=1}^infty (10)^{-k} &(mathrm{iii})
end{cases}
]
end{lemma}

As you can see from Lemma ref{reference case 1 as '1(i)'}, $f(x)=1$. However, Lemma ref{reference case 2 as '1(ii)'}-ref{reference case 3 as '1(iii)'} also show that $f(x)=1$. Here's another numbered equation
begin{equation}
e^{pimathrm i}=-1.
end{equation}

end{document}

2 Answers

You can number a cases environment using numcases instead (from the cases package). Then you just have to adjust the formatting of the equation counter and store/restore it before/after the numcases environment.

enter image description here

documentclass{article}

usepackage{amsthm}
usepackage{mathtools,cases}

newtheorem{lemma}{Lemma}

newcounter{saveeqncntr}

begin{document}

Here's a numbered equation
begin{equation}
  E = mc^2
end{equation}

begin{lemma}[Explicit forms for $f(x)$]
label{lem:forms_of_f}
begingroup
setcounter{saveeqncntr}{value{equation}}
setcounter{equation}{0}
renewcommand{theequation}{roman{equation}}
begin{numcases}{f(x) =}
  1                                 label{eqn:forms_of_f_i}  
  int_0^infty e^{-x},mathrm{d}x label{eqn:forms_of_f_ii} 
  9sum_{k = 1}^infty (10)^{-k}    label{eqn:forms_of_f_iii}
end{numcases}
setcounter{equation}{value{saveeqncntr}}
endgroup
end{lemma}

As you can see from Lemma~ref{lem:forms_of_f}eqref{eqn:forms_of_f_i}, $f(x) = 1$. 
However, Lemma ref{lem:forms_of_f}eqref{eqn:forms_of_f_ii}--ref{lem:forms_of_f}eqref{eqn:forms_of_f_iii} 
also show that $f(x) = 1$. Here's another numbered equation
begin{equation}
  e^{pimathrm{i}} = -1.
end{equation}

end{document}

Correct answer by Werner on May 12, 2021

I suggest an extraequations environment and to use double references.

documentclass{article}
usepackage{amsmath,mathtools,empheq}

newtheorem{lemma}{Lemma}

newenvironment{extraequations}[1][roman]
 {%
  setcounter{parentequation}{value{equation}}
  setcounter{equation}{0}%
  renewcommand{theequation}{#1{equation}}%
  ignorespaces
 }
 {%
  setcounter{equation}{value{parentequation}}%
  ignorespacesafterend
 }

begin{document}

Here's a numbered equation
begin{equation}
E=mc^2
end{equation}

begin{extraequations}
begin{lemma}[Explicit forms for $f(x)$]label{lem:forms_of_f}
Text before the display, there should always be some
begin{empheq}[left={f(x)=empheqlbrace}]{align}
& 1 label{case-i} [1ex]
& int_0^infty e^{-x},dx label{case-ii} 
& 9sum_{k=1}^infty (10)^{-k} label{case-iii}
end{empheq}
end{lemma}
end{extraequations}

As you can see from Lemma ref{lem:forms_of_f}eqref{case-i}, $f(x)=1$. 
However, Lemma ref{lem:forms_of_f}eqref{case-ii} also show that $f(x)=1$. 
Here's another numbered equation
begin{equation}
e^{pi i}=-1.
end{equation}

end{document}

enter image description here

If you use hyperref, you need a further instruction:

newenvironment{extraequations}[1][roman]
 {%
  setcounter{parentequation}{value{equation}}
  setcounter{equation}{0}%
  renewcommand{theequation}{#1{equation}}%
  renewcommand{theHequation}{theparentequation--#1{equation}}% to keep hyperref happy
  ignorespaces
 }
 {%
  setcounter{equation}{value{parentequation}}%
  ignorespacesafterend
 }

You can use begin{extraequations}[alph] if you want extra equations numbered by letters.

Answered by egreg on May 12, 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