cleveref and aliascnt: referring to subequations and inequalities in a smart way

Preliminary Remark:

A document may contain labels referring to equations and subequations, respectively. Moreover, some of the equations may actually represent inequalities. When using the cleveref package, it is a common problem that all of the references are of the same form, e. g., eq. (1). However, it would be more intuitive for the reader, if subequations would be referred to as eqs. (1) and inequalities as ineq. (1) or ineqs. (1). One possibility to solve this problem is to define the desired references via \crefname{pluralequation}{eqs.}{eqs.} and use optional arguments for the respective labels to override the cross-reference type, e. g., \label[pluralequation]{eq1}; see Referencing subequations with cleveref. A similar approach can be applied to inequalities as shown in How to reference an inequality with \cref?. Thus, the cross-reference type has to be manually defined for each of the labels with this method.

My question:

However, on page 9 in the cleveref manual, one can find the paragraph:

If you need to do this [i. e., overriding the cross-reference type] frequently, it can become tedious specifying the label explicitly each time. An alternative is to use the aliascnt package. This lets you define one counter to be an alias for another, so that effectively the same counter has two names. Since cleveref determines the label type from the counter name, the two counter aliases can have different cross-reference formats whilst really being the same counter. You have to somehow arrange for the correct counter alias to be used depending on which cross-reference format you want (probably by defining two variants of the environment in question). But the effort involved might be worth the convenience of not having to remember to pass an explicit optional argument to a large number of labels.

There is a brief example how this can be realized for theorem environments. Unfortunately, no further explanations are given for actual equation environments. Therefore, I would like to know: How can aliascnt be utilized to properly define subequations and inequality environments so that no optional arguments are necessary for the labels?

To be more precise, I would like to understand how the approach in the cited cleveref manual is supposed to work. As written in the manual, this alternative approach with aliascnt should be superior to the above-mentioned approach of manually overriding the cross-reference type each time I want to refer to an inequality or subequation.

• Not really, but the linking might be suitable for somebody. Aug 5, 2015 at 11:57
• I've deleted my question as the O.P. rejected it, so I'll leave it to others
– user31729
Aug 5, 2015 at 12:18
• I am not sure why my question was unclear, but I tried to rephrase it differently. In particular, I emphasize that the linked answer does not answer my question. Aug 5, 2015 at 12:52
• Unfortunately, I have no idea how the method from the manual can be realized. Therefore, I am not able to post useful code. Aug 5, 2015 at 13:24
• There's a way of creating a new equality-like environment that shares a counter with the equality environment, while avoiding the aliascnt package. See here. Dec 7, 2022 at 4:10

Here's an attempt to explain how the aliascnt method, which is mentioned but not fully explained in section 6 of the user guide of the cleveref package, might work.

Suppose you have lots of inequalities in your paper and that the numbered inequalities share a counter with equations. To use the aliascnt method, you need to (a) use \newaliascnt and \aliascntresetthe directives to initialize the new counter (called inq in the example below) and (b) set up an environment to display inequalities. In the code below, this environment is called ineq. (The code shown here also uses the hyperref package and loads the cleveref package with the option nameinlink, so as to highlight the output of the two \cref instructions.)

Speaking mostly for myself, I'd say that employing the aliascnt method is most likely to pay off if your document has lots of (say, more than a dozen) inequalities. If the number of inequalities is less than a dozen or so, I'd say that the \label[ineq]{<label-name>} route, suggested in the answer to How to reference an inequality with \cref?, is both less work and more straightforward to implement.

\documentclass{article}

\usepackage{aliascnt}
\newaliascnt{inq}{equation}
\aliascntresetthe{inq}
\crefname{inq}{inequality}{inequalities}
\creflabelformat{inq}{#2\textup{(#1)}#3}

% Define an environment called "ineq". (Code lifted
% straight from code in 'latex.ltx' for "equation"
% environment!)
\makeatletter
\def\ineq{$$\refstepcounter{inq}} \def\endineq{\eqno \hbox{\@eqnnum}$$\@ignoretrue}
\makeatother

\begin{document}
A first inequality:
\begin{ineq} \label{ineq:new}
1+1 \le 2.
\end{ineq}

A cross-reference to \cref{ineq:new}. For a change, an equation:
$$\label{eq:pyth} a^2+b^2=c^2.$$

A second inequality, with abject apologies to Leonhard Euler:
\begin{ineq} \label{ineq:basel}
\sum_{k=1}^\infty\frac{1}{k^2}<2.
\end{ineq}

As \cref{ineq:new,ineq:basel,eq:pyth} fail to show, \dots
\end{document}