3

how do I make cleveref use an abbreviated version of my reference for just one (a few) references? I usually prefer to write the full label (hence the noabbrev option), however I'm currently using some references in table headlines, where I'm running out of space

MWE

\documentclass{article}
\usepackage[nameinlink,noabbrev,capitalize]{cleveref}
\begin{document}
\begin{equation}
   c^2 = a^2 + b^2
   \label{eqn}
\end{equation}

\cref{eqn} shows an interesting result.
\end{document}

I'd prefer to locally change the label names (i.e., abbreviate them) for the scope of the table.

I tried calling \crefname inside the table environment without success.

 \begin{table}
 \crefname{equation}{Eq.}{Eqs.} % trying -- unsuccessfully -- to run '\crefname'
 \centering
    \begin{tabular}{cc}
        Assumption & \cref{eqn}
    \end{tabular}   
 \end{table}

Edit: As pointed out by egreg the solution with \crefname inside the table acutally works. I had a typo in my version.

2
  • 1
    Works for me. If I add the table to your sample document, I get this picture. Can you please show a full example that doesn't work?
    – egreg
    Commented May 26, 2020 at 13:57
  • Well, you're right. I accidentally had \Cref{eqn} in the code I copied over. Sorry for the confusion :/
    – dba
    Commented May 26, 2020 at 18:53

2 Answers 2

2

Since you're employing the package option capitalize (capitalise works too...), you could make use of the fact that the prefix labels generated by \Cref are never abbreviated.

Specifically, I suggest that you (a) no longer specify the option noabbrev, (b) replace all instances of \cref in the document with \Cref, and (c) change \Cref back to \cref if you wish to use abbreviated prefix labels.

enter image description here

\documentclass{article}
\usepackage[colorlinks,allcolors=blue]{hyperref} % optional
\usepackage[capitalize,nameinlink]{cleveref} % note: 'noabbrev' option not specified
\begin{document}
\begin{equation}\label{pyth} c^2 = a^2 + b^2 \end{equation}
\begin{equation}\label{triv} 1+1=2 \end{equation}

\Cref{pyth,triv} show that \dots 

\cref{pyth,triv} show that \dots
\end{document}
1

With hyperref, you can use the \hyperref command and customize on the fly: \hyperref[eqn]{Eq.~\ref*{eqn}} in your table entry.

2
  • Not the ideal solution when the type of environments change, but at least a simple hack I'll keep in mind. Thanks!
    – dba
    Commented May 26, 2020 at 18:56
  • @dba Sorry, it should not be hyperlink as initially suggested but \hyperref. Answer edited.
    – pluton
    Commented May 29, 2020 at 13:10

You must log in to answer this question.

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