[Tex/LaTex] amsmath – multiple labels in one equation


I would like to use multiple labels in the same equation when using amsmath. Basic latex already has this feature, but not amsmath, which seems to manipulate labels in complicated ways. Is it possible to alter the amsmath.sty code to restore this feature?

Or, alternatively, how to temporarily unload the amsmath package? This issue arises when compiling together different articles with \include, some using amsmath and not others. But I found that unloading packages is not possible in latex.

Best Answer

According to p. 86 of the cleveref user guide,

With amsmath, the original \label command is stored in \ltx@label, and \label@in@display replaces \label inside [single-line] equations. \label@in@display just saves the label for later, and defining it is left until the end of the equation, when \ltx@label is finally called.

Hence, you may want to include the following code in the preamble, after loading the amsmath package:


so that you have a command that doesn't contain the "secret letter" @. Alternatively, you could execute the command \let\ltxxlabel\label before loading the amsmath package. Then, replace all \label commands in your document -- except, of course, those that are actually associated with equation numbers -- with \ltxxlabel.

I cannot try out this suggested solution myself since I don't have a clear idea as to how you use the \label command in your document for purposes other than creating associations with equation numbers. Nevertheless, I would encourage you to try out this method.

Addendum: The cleveref user guide has the following to say about the treatment of the \label macro in the multiline equation environments (such as gather, align, and multline) of the amsmath environment:

The amsmath multi-line equation environments scan their bodies twice: Once to measure, once to typeset. In the measure phase, the \label command is disabled by letting it to \@gobble. ... Unfortunately, amsmath wasn't designed with redefinitions of \label in mind ... The multline environment works a bit differently to the other amsmath environments, in that \label is disabled during the typesetting phase, and enabled during the measuring phase.

Given these observations, it would seem that only the adventurous and daring may want to delve into redefining the ways that amsmath works with the \label command in its multiline equation environments. I must admit to not being sufficiently daring, at least not in this category...