1

How can I disable the nameinlink feature of cleveref for a specific \cref instance?

1 Answer 1

1

You asked:

How can I disable the nameinlink feature of cleveref for a specific \cref instance?

I will assume that the hyperref package is loaded along with cleveref. Please advise if this is not the case.

I don't believe that the cleveref package offers a macro that would let you achieve your formatting objective directly. However, it's straightforward to achieve the desired effect by (a) switching from \cref to \labelcref and (b) inserting the required label word by hand.

For instance, let us assume that a document has two equations with labels eq:1 and eq:2 and that you wish to cross-reference these equations. If cleveref is set to output English language strings, the instruction

\cref{eq:1,eq:2}

will generate

eqs. (1) and (2)

with the string "eqs." forming a hyperlink together with "(1)". (Aside: If you loaded cleveref with the option noabbrev, you would get "equations" instead of "eqs.".) However, there's nothing to stop you from writing either

eqs.\ \labelcref{eq:1,eq:2}

or eqs.~\labelcref{eq:1,eq:2}

With either method, the word eqs. will not be part of the hyperlink. Observe that ~ inserts a non-breaking space between "eqs." and "(1)"; using a simple backslash-space sequence, in contrast, inserts an ordinary (i.e., breakable) space. The ~ method would be preferred if it's important to avoid having line breaks between an item's label (here: "eqs.") and its associated number.


A full MWE (minimum working example):

enter image description here

\documentclass{article}
\usepackage[colorlinks,allcolors=blue]{hyperref}
\usepackage[nameinlink]{cleveref}

\begin{document}
\begin{equation}\label{eq:1} a \end{equation}
\begin{equation}\label{eq:2} b \end{equation}

\cref{eq:1,eq:2}

eqs.\ \labelcref{eq:1,eq:2}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .