I have inequalities being cross-referenced by \cref as equations.

1-) How can I change that? (and still have inequalities with the same numbering as equations)

2-) How can I change that and have inequalities with their own numbering?


&f(x) \geq g(x)& \label{i:positivity}

Admitting that \cref{i:positivity} has a solution, ...  

  • Why not use \eqref{}? – Sigur Jul 11 '14 at 1:44
  • 1
    This solves. But since I was using cref to automatically handle all the different types of references, I was wondering if this would still be doable using it. – capadocia Jul 11 '14 at 1:51
  • 1
    @Sigur - Assume the hyperref package is loaded and cleveref was loaded with the option nameinlink. By writing "by inequality \eqref{xyz}" instead of "by \cref{xyz}", one loses the feature of having the word "inequality" be part of the "target" of the hyperlink. – Mico Jul 11 '14 at 7:29

Assuming you want to use the same counter variable for both equation-like and inequality-like environments, you can proceed by informing cleveref (i) that certain environments are "special" (specifically, that they are inequalities) and (ii) what to do in terms of typesetting the cross-references to these "special" objects. The former can be achieved by providing an optional argument to the \label command. (cleveref cleverly redefines \label to make this possible.) The latter can be achieved by executing appropriate \crefname and \creflabelformat instructions.

enter image description here

\usepackage[colorlinks]{hyperref} %%  just for this example

 %% \upshape ensures that the number and surrounding parens are typeset in upright mode

\setlength\parindent{0pt} %%  just for this example
\setlength\textwidth{4in} %%  just for this example

&f(x) \geq g(x)& \label[ineq]{i:positivity} %% note optional argument of \label
Admitting that \cref{i:positivity} has a solution, \dots 

Section 6 of the user guide of the cleveref package provides a fuller explanation of how this works. In that section, it's also explained how to automate this a bit if you have lots and lots of inequalities, in which case it might become tedious to have to remember to supply the option ineq to \label whenever the object is an inequality.

  • 1
    Did you mean to write either \textup{(#1)} or {\upshape(#1)} where you used \upshape{(#1)}? – Crissov Jul 11 '14 at 8:46
  • @Crissov - Good catch: It should be {\upshape(1)}. I'll edit the code accordingly. – Mico Jul 11 '14 at 14:31

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.