u/h_nouar

▲ 0 r/LaTeX

I had a discussion with ChatGPT to find a way to number referenced equations only while -in contrast with mathtools' showonlyrefs- keeping the numbering sequential: 1,2,3 etc. and not 2,5,6 etc. and I got this from the AI mate:

\newcommand{\eq}[2]{%

\def\tempa{#1}%

\ifx\tempa\empty

\begin{equation*}

#2

\end{equation*}

\else

\begin{equation}

#2

\label{#1}

\end{equation}

\fi

}

So basically a

\eq{eq:pythagoras}{a^2 + b^2 = c^2}

would give a referenced numbered equation

while

\eq{}{a^2 + b^2 = c^2}

can be referenced and numbered whenever I fill the first operand

reddit.com
u/h_nouar — 13 days ago