3

The question will be self answered and it is simple. Sometimes, we need to create a family of equations with the same number but with something different (an extra counter or something) For example I have the equations (1) then the (2) and now I want to open a family of equations (3 (i)), (3 (ii)), then to continue with (4)... then to define (3 (iii)) ... etc...

And this has to work with amsmath package to give numbers like (2.2 (i)) etc.

I didn't found something similar but probably I am not using the appropriate keywords. So If it is a duplicate just inform me to write there. Creating the answer...

To make clear what I want... Is to have families of equations without having to give custom tags and changing number of equation counter.

The next photo shows the desired result (with families of quadratic and elliptic equations and equations not in families between them):

enter image description here

PS:This question came out of this question but it was just a misunderstanding of mine. He wanted something else (and I will edit the code of this topic answer to answer that too)

1 Answer 1

1

We can define a newcommand to do this. The command is:

Edit: add amsmath package to your preamble.

\makeatletter
\newcommand*\ifcounter[1]{%
  \ifcsname c@#1\endcsname%
    \expandafter\@firstoftwo%
  \else%
    \expandafter\@secondoftwo%
  \fi%
}%
\makeatother


\makeatletter
\newcommand\EqFamTag[2][roman]{%
\ifcounter{#2}{%
\expandafter\addtocounter{#2}{1}%
\xdef\temp{\csname #2 Eq\endcsname \space(\csname #1\endcsname{#2})}%
\global\expandafter\let\csname #2\arabic{#2}\endcsname\temp%
\tag{\temp}%
}{%
\global\expandafter\newcounter{#2}%
\expandafter\addtocounter{#2}{1}%
\xdef\temp{\theequation\space(\csname #1\endcsname{#2})}%
\xdef\eqonfamily{\theequation}%
\global\expandafter\let\csname #2 Eq\endcsname\eqonfamily%
\global\expandafter\let\csname #2\arabic{#2}\endcsname\temp%
\tag{\temp}%
\expandafter\addtocounter{equation}{1}
}%
}%
\makeatother

Where I using the answer of @clemens from the question Check if counter exists

To use the command, we just writing (for example):

\begin{equation}
 x^2=3\EqFamTag{Parabolic}
\end{equation}

and we can give or not give a label... If we don't give a label we can still refer to our member of Parabolic family using:

(\csname Parabolic1\endcsname) 

for first member... or

(\csname Parabolic2\endcsname)

for 2nd member etc

The command works with amsmath package and we can have

\numberwithin{equation}{section}

or whatever we like.

We can continue our family members in a new section but the numbering will remember first member's section and number.

Finally, we can use other than \roman numbering (like capital alpharithmetic or anything latex supports) adding a parameter like

\begin{equation}
 {x^4}+\frac{3\cdot x^2}{10}+7=0\EqFamTag[Alph]{Quartic}
\end{equation}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .