In realtà con in codice che hai postato ho problemi quando la dichiarazione della costante è all’interno dell’ambiente multline o equation.
Hai una soluzione?
Non mi risulta; puoi fare un esempio, per favore?
Questo funziona
`\documentclass[a4paper]{article}
\usepackage{amsmath}
\newcounter{constant}
\newcommand{\newconstant}[1][]{%
\refstepcounter{constant}%
\if\relax\detokenize{#1}\relax\else\label{#1}\fi
c_{\arabic{constant}}}
\newcommand{\useconstant}[1]{c_{\ref{#1}}}
\begin{document}
New
\begin{equation}
x=\newconstant
\end{equation}
New (pippo)
\begin{equation}
x=\newconstant[pippo]
\end{equation}
Use pippo
\begin{equation}
y=\useconstant{pippo}
\end{equation}
Use pippo and new
\begin{multline}
a=\useconstant{pippo}\\
+\newconstant
\end{multline}
\end{document}`
Ciao
Enrico