# Custom equation numbering

I want to label an equation

$1 + 2 + \cdots + i = \frac{i(i+1)}{2} \eqname{Inequality(i)} \label{ineq}$


involving the variable "i" as a function of (i) so the expected output looks like

[LaTeX rendering of the above equation] (2.4)(i)

(which actually means there are "i" such equations). The (2.4) might refer to Equation 4 of Section 2. When I access the equation later, I would like it to appear as

Since Equation (2.4)(n+1) follows from Equation (2.4)(n), use induction...

(EDIT: Improved the wording to clarify the questions in comments. )

• do you have problem if both (2.4) and (i) will be in parenthesis like ((2.4)(i)) or (2.4 (i)) and what do you prefer from these two? – koleygr Jun 29 '17 at 17:16
• Either is fine as long as the dependence on (i) is explicit. Thanks! – Abhishek Parab Jun 29 '17 at 17:18
• I don't understand very well what all these numbers are . Is (i) a number of a subequation (in which case 2 would be, say, a chapter number, and 4 the main equation number), or is a certain group of equations numbered in roman, independently from other equations, in which case $2$ would be the chapter number and 4 the section number? – Bernard Jun 29 '17 at 17:46
• @Bernard It is the latter; the equation itself involves an "i". I have edited the equation to make it more relevant. – Abhishek Parab Jun 29 '17 at 17:54
• And Big Math Equation, I suppose, is just a shortcut for this post of the real maths stuff in the equation? – Bernard Jun 29 '17 at 17:58

Let’s see if I guessed correctly what you wish to get:

This output was generated by the following code:

% My standard header for TeX.SX answers:
\documentclass[a4paper]{article} % To avoid confusion, let us explicitly
% declare the paper format.

\usepackage[T1]{fontenc}         % Not always necessary, but recommended.
% End of standard header.  What follows pertains to the problem at hand.

\usepackage{amsmath}

\numberwithin{equation}{section}

\newcommand*{\myTagFormat}[2]{(\ref{#1})($#2$)}

\begin{document}

\section{First}

Just to include a couple of equations:
\begin{align}
1 &= 1 \label{eq:one} \\
1+2 &= 3 \label{eq:two}
\end{align}
Until now, we have equations \eqref{eq:one} and~\eqref{eq:two}.

\section{Second}

Still another equation of the same form:
$$1+2+3 = 6 \label{eq:three}$$
Generalizing equations \eqref{eq:one}, \eqref{eq:two}, and~\eqref{eq:three}, we
claim that
% Little trick:
\refstepcounter{equation}\label{eq:base}% <-- Note!
$$1+2+\dots+n = \frac{n(n+1)}{2} \tag*{\myTagFormat{eq:base}{n}}\label{eq:base-n}$$
Now you can either:
\begin{itemize}
\item
reference equation~\ref{eq:base-n} directly (note that you must use
\verb|\ref| instead of \verb|\eqref|, here), or
\item
say that equation~\myTagFormat{eq:base}{i+1} follows from
equation~\myTagFormat{eq:base}{i} by adding $i+1$ on both sides of the
latter.
\end{itemize}
One more equation to check that we haven't spoiled the numbering:
$$x=y$$

\end{document}


I didn't really understood the question in first reading, and I thought you want something like this.

But It was not exactly what you want because my answer there can not give results like (n+1)... but if we change it a little bit we can have this:

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

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


which can be used like this:

$$\frac{x^2}{2}+\frac{3\cdot y^2}{10}=2\EqFamCustomTag{Elliptic}{n+1}$$


and give you what you want... (I hope)... For automatic numbering in the other equations you have, you can use the one of my referred question-answer (This question started that too...)

• Thanks but I found the solution by @GustavoMezetti easier to implement. – Abhishek Parab Jun 30 '17 at 15:31
• You are welcome... No problem @AbhishekParab... May be someone will look for automatic generated numbers and then will find mine useful too... It is good to have more than one solutions in the questions... – koleygr Jun 30 '17 at 16:03

Using mathtools package command \newtagform, you can customize equations numbering in very detailed manner. The general syntax of the command is:

\newtagform{label}[tag format]{left}{right}


The label is just a unique ID for the tagging method which can be retrieved using the command \usetagform{label}, left and right are what should be written to the left and right of the tag (usually brackets). The tag format is the details of the tagging you want. In your particular case, you can use the following syntax:

[\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}]


After you setup new numbering format, you must also change how equations will appear when you reference them. For the style you want, the code should be:

\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}


Here is an example of how this custom numbering works:

\documentclass[]{report}
\usepackage{amsmath}
\usepackage{amssymb, amsfonts}
\usepackage{gensymb}
\usepackage{mathtools}
\newtagform{Alph}[\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}]{}{}
\usetagform{Alph}
\renewcommand{\theequation}{(\arabic{chapter}.\arabic{section})(\roman{equation})}

\begin{document}

\chapter{First Chapter}

\section{First Section}
\label{sec:one}

$$I = I_{ ph } - \overbrace{ I_{ rs } \biggl[ exp \biggl( \frac{V + I R_{s}}{a \thinspace V_{t}} \biggl) - 1 \biggl] % overbrace title }^{ I_{d} } - \overbrace{ \frac{V + I R_{s}}{R_{p}} % overbrace title }^{I_{p}} % \label{eq:I_PV_m}$$

$$\label{eq:R_p} % R_{p} = R_{p,ref} \biggl( \frac{G_{ref}}{G_{op}} \biggl) \biggl( \frac{T_{op}}{T_{ref}} \biggl)^{\delta_{p}}$$

$$PMARE = \underset{i}{max} \biggl| \frac{x_{i}-y_{i}}{y_{i}} \biggl| \times 100\% \quad i = 1, 2, \cdots , n % \label{eq:PMPARE}$$

A test for referencing Eqs. \ref{eq:I_PV_m}, \ref{eq:R_p}, and \ref{eq:PMPARE} which belong to Section \ref{sec:one}.

\section{Second Section}
\label{sec:two}

$$\label{eq:R_{s}} % R_{s} = R_{s,ref} \biggl( \frac{T_{op}}{T_{ref}} \biggl)^{\delta_{s}}$$

\begin{align}
I_{ph} &= I_{sc} \frac{R_{s} + R_{p}}{R_{p}}  \notag
\\
&= I_{sc,ref} \bigg[  1 + \frac{\alpha}{100} (T_{op}-T_{ref}) \biggl]
\frac{G_{op}}{G_{ref}} \frac{R_{s} + R_{p}}{R_{p}}
%
\label{eq:I_ph}
\end{align}

A test for referencing Eqs. \ref{eq:R_{s}} and \ref{eq:I_ph}which belong to Section \ref{sec:two}.

\end{document}


Other kinds of numbering options include \Roman (capitalized roman letters) \alph, and \Alph. Good luck

• Actually what I wanted is somewhat different. Thanks for your help, I appreciate it. – Abhishek Parab Jun 30 '17 at 15:32