# Problem with side by side equation tag and custom tag style

Consider the following MWE:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amsmath}

\newtagform{brackets}{[}{]}
\usetagform{brackets}

\AtBeginDocument{\let\latexlabel\label}

\usepackage{hyperref}
\hypersetup{
filecolor=black,
urlcolor=black,
}
\urlstyle{same}

\begin{document}

\begin{equation*}
\refstepcounter{equation}\latexlabel{a}
\refstepcounter{equation}\latexlabel{c}
\refstepcounter{equation}\latexlabel{e}
\tag{\ref*{a},$,$ \ref*{c},$,$ \ref*{e}}
\end{equation*}

\end{document}


When I compile it, it doesn't show the third tag and gives me two errors:

• paragraph ended before @firstoffive was complete
• argument of @firstoffive has an extra }

I think the problems are due to the hyperref package because by removing it and substituting \tag* with \tag it doesn't give me any error whatsoever. In addition, when using hyperref I've to manually insert the commas in a math environment in order for them to be shown.

What are those errors? How can I get rid of them and have the file to compile correctly?

Thank you for your time, it is very appreciated.

Edit:

For more clarity, this is what the code erringly compiles to:

This is how I want it to compile, and how correctly compiles without using the hyperref package:

• What's the purpose of the two $,$ items in the argument of \tag? And what are you trying to achieve by using \latexlabel rather than \label directly? – Mico Nov 18 '18 at 20:15
• @Mico I've to insert manually the commas in a math environment because otherwise, for some obscure reason, it doesn't plot the commas between the tag numbers. I've not written the code myself, I took it from tex.stackexchange.com/questions/120670/… – Edoardo Serra Nov 18 '18 at 20:53
• @Mico question edited, now it should be more clear what is asked, thank you. – Edoardo Serra Nov 18 '18 at 21:03

In order for the code to compile correctly, \AtBeginDocument{\let\latexlabel\label} has to be loaded after the hyperref package. Doing so, not only the code compiles correctly but the commas in the math environment can and should be removed too.