# Wrong reference to equation: Reference to section instead of equation number

I try to reference in the text to an equation number like:

see equation \ref{eqdesign2}


the equation is:

\sbox{\myendhook}{%
\begin{footnotesize}%
\begin{tabular}{@{}ll}
$\mu_m$ & Magnetic permeability [$H/m$]\\
$N$     & Number of windings [-]\\
$A$     & Area of the coil [$m^2$]\\
$l$     & Length of the coil [$m$]
\end{tabular}
\end{footnotesize}
}
\begin{fleqns}[2em]
$$L_1 = \frac{\mu_m N^2 A}{l} \label{eqdesign2}$$
\end{fleqns}


Such that the outcome is

As you can see the reference to the equation is not correct. I tried solving this by using 'gather', such that the code becomes:

see equation \ref{eqdesign3}

\sbox{\myendhook}{%
\begin{footnotesize}%
\begin{tabular}{@{}ll}
$\mu_m$ & Magnetic permeability [$H/m$]\\
$N$     & Number of windings [-]\\
$A$     & Area of the coil [$m^2$]\\
$l$     & Length of the coil [$m$]
\end{tabular}
\end{footnotesize}
}
\begin{fleqns}[2em]
\begin{gather}
L_1 = \frac{\mu_m N^2 A}{l}
\label{eqdesign3}
\end{gather}
\end{fleqns}


The reference is now good, but the \sbox with table is not displayed anymore.

The box is made with the following code:

\makeatletter
\@fleqntrue
\let\old@mathmargin=\@mathmargin
\@mathmargin=-1sp
\let\oldmathindent=\mathindent
\let\mathindent=\@mathmargin
\newsavebox{\myendhook} % for the tabulars
\def\tagform@#1{{(\maketag@@@{\ignorespaces#1\unskip\@@italiccorr)}
\makebox[0pt][r]{% after the equation number
\makebox[0.4\textwidth][l]{\usebox{\myendhook}}}%
\global\sbox{\myendhook}{}% empty box
}}
\makeatother


Someone an idea on how to solve the reference or solving the box display?

• Welcome to TeX.SE. Please provide the compilable document that has this issue, not only fragments. At the moment it looks like if the \@currentlabel content is stuck inside the box you're defining and never get's out.
– user31729
Jan 16 '17 at 17:50

I guess that you like to have something like this:

Since you not provide MWE, I haven't clue for what you need new environment. Above image of equation is obtain by fairly simpler code:

\documentclass{article}
\usepackage{mathtools}
\usepackage{array}

\begin{document}
see equation \ref{eqdesign3}

\begin{flalign}\label{eqdesign3}
L_1 & = \frac{\mu_m N^2 A}{l}
&   &   \begin{tabular}{>{\footnotesize $}r<{$:}>{\footnotesize}l}
\mu_m  & Magnetic permeability [$H/m$]\\
N   & Number of windings [-]\\
A   & Area of the coil [$m^2$]\\
l   & Length of the coil [$m$]
\end{tabular}
\end{flalign}
\end{document}


Note: the footnotesize is not an environment, sou your use is wrong.