# Change counter equation

I am relatively new working with LaTeX and I don't know how to solve this problem.

I have several equations that I wrote in a general form, but when writing them, I want to show that the general form is just a generalization for three specific formulas; i.e.

I have this

but I want to have this:

P.S: I could use the command tag like in this post Customize equation numbering for Equation environment?, but I have over 60 equations and I could not use the command tag for each line individually (Also, there could be multiple errors doing it manually) Can someone help me please?

My MWE is:

\documentclass[a4paper,12pt]{article}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}

\begin{document}

$$E=mc^2$$

\end{document}

EDIT: For more clarity, I put some equations with subscript (j) and others not; and those with subscript I want to be counted not as just one equation; but from n (number of previous equation) to j (from 1 to 3).I know how to set this MANUALLY, but that wouldn't be efficient nor exent of mistakes since we are talking of over 100 equations in different sections). An example is:

My MWE is the following:

\begin{document}

$$F=ma$$

$$E=m_{j}c^2 \tag{2), (3), (4}$$

\setcounter{equation}{4}
$$A=B+C$$

$$D_{j}= E_{j} + F_{j} \tag{6), (7), (8}$$

\end{document}
• Welcome! $$E=mc^2 \tag{1),(2),(3}$$ gives you that output. (I am not sure I understand the purpose, though. Maybe you want to explain where the numbers derive from such that one can provide a more automatic solution?)
– user194703
Nov 9 '19 at 0:24
• Can you describe the how you come up with 3 equation numbers next to the equation? Will there always be 3, or sometimes 2 and then occasionally 1? Please elaborate. Anything is possible, but we need some specifics in terms of the use case.
– Werner
Nov 9 '19 at 1:45
• @Schrödinger'scat I only put tag to put an example; this would work with one line. However, I have multiple lines and I need the counter to work (for some lines n+1; for others n+3) Nov 9 '19 at 9:21
• @Werner There would be some lines that will count as just one equation (counter: n+1 being n the previous equation number counted) ; others for three (n + 3) Nov 9 '19 at 9:24
• @IgnacioRuizNestosa How are you going to refer to these multi-label equations? That is, if this equation has the label \label{eq:Einstein}, what should \eqref{eq:Einstein} give you?
– user194703
Nov 9 '19 at 9:49

I'm not sure it's a good idea, particularly if you never refer to a single case. You can just refer to “Equations (1)”, which will give readers the hint that they're more than one.

Anyway, here's an implementation that also allows to refer to a single equation from the bunch.

\documentclass{article}
\usepackage{amsmath,xparse}

\ExplSyntaxOn

\NewDocumentCommand{\multinumber}{mo}
{
\seq_clear:N \l__ignacio_multinumber_seq
\int_step_inline:nn { #1 }
{
\refstepcounter{equation}
\IfValueT{#2}{ \use:c{ ltx@label } {#2-##1} }
\seq_put_right:Nx \l__ignacio_multinumber_seq { (\theequation) }
}
\tag* { \seq_use:Nn \l__ignacio_multinumber_seq { ,~ } }
}

\ExplSyntaxOff

\begin{document}

References: \ref{Einstein} (global), \ref{Einstein-1} (first)

$$F=ma$$

$$\label{Einstein} E=m_{j}c^2 \multinumber{3}[Einstein]$$

$$A=B+C$$

$$D_{j}= E_{j} + F_{j} \multinumber{3}$$

\end{document}

• Thank you @egreg! It works perfect! Nov 9 '19 at 21:06

This allows you to add multiple equation numbers via a command \multitag.

\documentclass[a4paper,12pt]{article}
\usepackage[spanish]{babel}
\usepackage[latin1]{inputenc}
\usepackage{mathtools}
\newcounter{iloop}
\newcounter{imax}
\newcommand{\MultiNum}{\edef\temp{}%
\setcounter{iloop}{0}\loop%
\stepcounter{iloop}%
\ifnum\value{iloop}<\value{imax}%
\edef\temp{\temp\number\value{equation}),(}\refstepcounter{equation}%
\repeat%
\edef\temp{\temp\number\value{equation}}%
\refstepcounter{equation}}
\newcommand\multitag[1][1]{\setcounter{imax}{#1}%
\MultiNum%
\tag{\temp}}

\begin{document}
Einstein
$$\label{eq:Einstein} E=mc^2 \multitag[3]$$
Photon
$$\label{eq:Photon} E=h\nu \multitag[2]$$
Thermo
$$E=TS$$
Wrong
$$\label{eq:Wrong} E=mc^3$$
\eqref{eq:Wrong} is wrong, \eqref{eq:Einstein} is correct, and so is \eqref{eq:Photon}.
\end{document}

Not sure if it is a good idea use a tag as a reference, because then, it should be counted or not? Is 1+2+3=4 or it is simply 1+2+3? What the reader must expect for the next equation, 4 or 5? That is, the sequence must be 1,2,3,1+2+3,4,... or maybe 1,2,3,1+2+3(=4),5...?.

Anyway, for the first case, is possible using \label{} and \ref{}, and for the second, you must add also a \addtocounter{equation}{1} in the 4th (1+2+3) equation:

\documentclass{article}
\usepackage[spanish]{babel}
\usepackage{amsmath}

\begin{document}
Siendo la masa  ...

$$\label{a} m = \gamma m_0 = \frac{m_0}{\sqrt{1-v^2/c^2}}$$

Y el momento linear es bla bla ...
$$\label{b} E = \sqrt{p^2c^2+m^2c^4} = \gamma mc^2$$

Por lo dicho anteriormente, ....
$$\label{c} \gamma = \frac{1}{\sqrt{1-(\frac{v}{c})^2}} \approx 1+ \frac{1}{2} \left(\frac{v}{c} \right)^2$$

Entonces, juntándolo todo   \eqref{d} llegamos a:
$$\label{d} %\addtocounter{equation}{1} E=mc^2 \tag{\ref{a},\ref{b},\ref{c}}$$

Lo que está tan claro como que 2 y 2 son:

$$\label{e} 2+2=22$$

\end{document}
• Hi @Fran. Please refer to the edited part of the question for more clarity. Nov 9 '19 at 10:35
• @IgnacioRuizNestosa Then you want \tag{\theequation, \addtocounter{equation}{1}\theequation, \addtocounter{equation}{1}\theequation} but then cannot be referenced properly in text!
– Fran
Nov 9 '19 at 10:54