# Is there a way to insert a label anywhere so that it can evolve with the set of previously computed references?

Here's my problem: I'm trying to get specific references to any part of my argumentation/proof. In my example, the label is stacked on the equality symbol in such a way that it allows me to make it explicit later in my report. The only problem is that I had to set the numbering myself, risking an obvious mistake. In short, I'd like to know if there was a tool (or the possibility to implement such a tool) that enables free referencing through your text, letting you write something similar to the following

\documentclass{article}

\usepackage[french]{babel}

\newcommand\brackets[1]{\bigl(#1\bigr)}
\usepackage{amsmath}

\begin{document}
On écrit alors
$E(Z) = E\brackets{\sum_{j=1}^{n} j I_j} \stackrel{\label{linearity}}{=} \sum_{j=1}^{n} j E(I_j) \stackrel{\label{symmetry}}{=} E(I_j)\sum_{j=1}^{n} j = E(I_j)\dfrac{n(n+1)}{2}$
par les relations de linéarité de l'espérance \ref{linearity} et de symétrie de l'expérience \ref{symmetry}.
\end{document}


In order to get the wanted result automatically. (\brackets{} is a macro I implemented to get a proper spacing between the "function" and the brackets theirselves.)

This problem isn't that much constraining as long as I keep the count up to five or six equations. However I'd find this tool very useful to take advantage of for a lenghty job (if I still have to keep it dense). Thanks for answering me.

• This is a sample of the tool I was hoping for, in my report I did write respectively "(1)" and "(2)" in the place of \label and \ref. I know these two functions exist and are not suitable to what I am trying to do here but maybe it is only missing something else that would be a visible, evolving number to which I can assign a label... I just don't know much. Also, yes indeed I don't know what test file to provide for I just don't know how to write anything that works in my case. Thanks for the consideration. Mar 16 at 15:54
• I deleted my first comment as it was clearer what you wanted to do once I made your image appear. I test document would have helped though as it is only implicit in your use of \dfrac that you are using amsmath which makes it quite a bit harder as you can not use two label in an equation in amsmath. Mar 16 at 15:57
• a test document doesn't need to be much more than you posted but should be complete. (I added one, feel free to re-do it if you don't like it) Mar 16 at 16:00
• I'll think of that for my next posts! Thanks a lot. Mar 16 at 16:27
• Can you clarify? Are these labels part of the equation label set (i.e., your equation counts as eqs 1 and 2) or do they constitute their own unique numbering scheme (independent of equation numbers)? If the latter, are they reset for each equation (i.e., only referenced in their own caption), or do they continue where prior equations left off? Mar 16 at 16:27

As David noted, amsmath does not allow multiple labels per equation. So it would be a heavy price to pay to exclude amsmath. But if that were a willing sacrifice, then I introduce \eqlabel as a means to place an = sign with a superscripted equation label number. More than one are allowed in a given $...$ context and will literally signify multiple numbered equations within.

\documentclass{article}

\usepackage[french]{babel}

\newcommand\brackets[1]{\bigl(#1\bigr)}
%
%\usepackage{amsmath}
\def\dfrac#1#2{\frac{\displaystyle#1}{\displaystyle#2}}
%
\newcommand\eqlabel[1]{\refstepcounter{equation}\label{#1}\stackrel{(\ref{#1})}{=}}
\begin{document}
On écrit alors
$E(Z) = E\brackets{\sum_{j=1}^{n} j I_j} \eqlabel{linearity} \sum_{j=1}^{n} j E(I_j) \eqlabel{symmetry} E(I_j)\sum_{j=1}^{n} j = E(I_j)\dfrac{n(n+1)}{2}$
par les relations de linéarité de l'espérance \ref{linearity} et de symétrie de l'expérience \ref{symmetry}.

$$y = mx + b\label{nexteq}$$
In eq \ref{nexteq}...
\end{document}