1

Consider the following MWE:

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

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

\AtBeginDocument{\let\latexlabel\label}

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

\begin{document}

\begin{equation*}
\refstepcounter{equation}\latexlabel{a}
\refstepcounter{equation}\latexlabel{c}
\refstepcounter{equation}\latexlabel{e}
a=b\quad c=d\quad e=f 
\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:

enter image description here

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

enter image description here

  • 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
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.