# How to number automaticaly a family of equations (and ref to them)

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):

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)

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

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

\makeatletter
\newcommand\EqFamTag[2][roman]{%
\ifcounter{#2}{%
\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}%
\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}%
}%
}%
\makeatother


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

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

$$x^2=3\EqFamTag{Parabolic}$$


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

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