# Package amsmath Error: Multiple \label's

Sorry about the previous errors in the code.

Could any one help with the numbering in the \overset or \underset in equations?

I need to add number above/below certain variables in the equations because I have so many variables. And the equations are very long. I consider to use the counter to auto-number the variables in equations. I tried the following code, but it seems that the \overset and \underset conflicts with the label of equation.

I got the following errors:

Package amsmath Error: Multiple \label's: label 'Eq1' will be lost. Y & = \overset{\dln{aaa}}{\boxed{a}}


\documentclass{article}

\usepackage{amssymb}
\usepackage{amsmath}

\DeclareRobustCommand{\dln}[1]{%

\begin{document}

Here is the equation:\\

\label{Eq1} % I need the Eq. number \begin{aligned} % I need the aligned equation Y & = \overset{\dln{aaa}}{\boxed{a}} x_1 \\ % I need the aaa to be auto numbered & + \underset{2}{\boxed{b}} x_2 % I need the bbb to be auto numbered \end{aligned}

Here is how to refer \dln{aaa}. % I need to refer the number indexed by aaa

\end{document}


This is what I want:

• Please consider cleaning up your previous question before asking a new one. – marmot Jan 25 at 23:19
• As I told you in your other question: You can't have more than one label in an equation environment -- the \dln macro is logically wrong – user31729 Jan 25 at 23:27
• Thank you. I deleted the previous post. I have a large number of coefficients/variables such as "a", "b", in the equations which I need to label. I can directly number them in the \overset or \underset. But if I insert a new number at the beginning, I have to change all the numbers affected. So, I hope to label the coefficients/variables using refstepcounter and refer them in the text through \dln{aaa}. – Yuan Jan 25 at 23:29
• Thank you Christian. Is there any other way to deal with it? Or, I have to use \underset{1}{\boxed{a}} directly? – Yuan Jan 25 at 23:30
• How about \label{Eq1} \begin{aligned} Y & = \overset{\ref{Eq1}}{\boxed{a}} x_1 \\ & + \underset{\the\numexpr\theequation+1}{\boxed{b}} x_2 \end{aligned} ? – marmot Jan 25 at 23:46

\documentclass{article}

\usepackage{amssymb}
\usepackage{amsmath}

\makeatletter
\def\zzlabel#1{\ifmeasuring@\else\ltx@label{#1}\fi}
\makeatletter

\DeclareRobustCommand{\dln}[1]{%
\label{Eq1} % I need the Eq. number \begin{aligned} % I need the aligned equation Y & = \overset{\dln{aaa}}{\boxed{a}} x_1 \\ % I need the aaa to be auto numbered & + \underset{\dln{bbb}}{\boxed{b}} x_2 % I need the bbb to be auto numbered \end{aligned}