[Tex/LaTex] Add equation name besides equation number (so that \eqref inserts only the number)

amsmathequationsnumbering

I am trying to add equation names besides the equation numbers but, in addition, in such a way that \eqref inserts just the number.

Inspired by the top answer in Add equation name underneath equation number, I tried the following solution:

\documentclass{article}
\usepackage{amsmath}
\newcommand\mylabel[2]{\label{#1} \\[-\baselineskip] \tag*{#2\ \hphantom{(\ref{#1})}}}

\begin{document}

\begin{align}
f(x) = a \mylabel{eq:a}{Constant} \\
h(x) = ax^2+bx+c \mylabel{eq:b}{Quadratic}
\end{align}

Equations \eqref{eq:a} and \eqref{eq:b} look OK\dots 

\begin{align}
j(x) = \varinjlim_{C_j} \mylabel{eq:c}{Way too low!}
\end{align}

\dots but the method fails in style for Equation \eqref{eq:c}.

\end{document}

enter image description here

As you can see, the trick I used is to write the equation name in a new line and then lift it by -\baselineskip. For simple equations as (1) or (2) I get exactly what I want. But indeed, this is shoddy work and it fails as soon as the equation gets a little more complicated, e.g. for (3).

I don't know whether I could use another length instead of -\baselineskip so that I always get the correct lift, or whether there is a more elegant (and not too complicated) way to achieve what I want.

Best Answer

Based on the answer at How to put a text label *before* an equation?, I just moved the label from the left to the right. In this MWE, I use the flalign environment to accomplish the task. In the linked answer, there is also a method employing stacks, if flalign is not right for your need.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\noindent text
\begin{flalign}
\phantom{\text{Constant}}&&f(x) = a&&\text{Constant}\label{eq:a}\\
\phantom{\text{Quadratic}}&&h(x) = ax^2+bx+c&&\text{Quadratic}\label{eq:b}
\end{flalign}
Equations \eqref{eq:a} and \eqref{eq:b} look OK\dots 
\begin{flalign}
\phantom{\text{Just right!}}&&j(x) = \varinjlim_{C_j}
&&\text{Just right!}\label{eq:c}
\end{flalign}
\dots and the method no longer fails in style for Equation \eqref{eq:c}.
\end{document}

enter image description here

This process can be streamlined with the macro

\newcommand\nameeq[2]{\phantom{\text{#2}}&&#1&&\text{#2}}

and the following usage:

\begin{flalign}
\nameeq{f(x) = a}{Constant}\label{eq:a}\\
\nameeq{h(x) = ax^2+bx+c}{Quadratic}\label{eq:b}
\end{flalign}