Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When using cleveref one may want to use its macros for making all cross-references, even those where the cross-reference name is empty. The cross-reference name is the name that is appended to a cross-reference to describe its type, e.g. a \cref to Figure 1 outputs "figure 1" (rather than outputting just "1" like \ref does). To define an empty cross-reference name for figures one can, as described in the manual on page 19, do as follows:

\crefname{figure}{}{}

The problem with doing this is that even if the cross-references name indeed is emptied the space before the cross-reference is longer than when just using \ref. How can one avoid such a long space?

Here is an example that illustrates the problem:

\documentclass{article}

\usepackage{cleveref}
\usepackage{enumitem}

\crefname{enumi}{}{}
\crefname{equation}{}{}

\begin{document}

\begin{enumerate}
\item foo\label{item:1}
\end{enumerate}
\begin{equation}
1+1=2\label{eq:1}      
\end{equation}

In \cref{item:1}.% Too long space after "In"

In \ref{item:1}.

In \cref{eq:1}.% Too long space after "In"

In \ref{eq:1}.

\end{document}

Output of MWE

share|improve this question
add comment

2 Answers

up vote 4 down vote accepted

If you want to use the cleveref package but don't want to prefix the "name" of the cross-referenced item (or items), there is no need to undefine the names via various

\crefname{xyz}{}{}

instructions. Simply use the \labelcref command instead of the \cref command. As the macro's name suggests, it operates only on the "label" part of the cross-referenced item(s) but otherwise does just the same things as \cref does.

\documentclass{article}
\usepackage{enumitem,amsmath,cleveref}
\begin{document}
\begin{enumerate}
\item foo\label{item:1}
\end{enumerate}
\begin{equation}
1+1=2\label{eq:1}      
\end{equation}

In \labelcref{item:1}.

In \ref{item:1}.

In \labelcref{eq:1}.

In \eqref{eq:1}. % \eqref inserts parentheses automatically
\end{document}

enter image description here

share|improve this answer
    
But what if you want to use \cref for constructs that does not have a cross-reference name, such as linguistic examples that are merely referred to as (1), (2), (3), etc.? –  N.N. May 17 '12 at 17:39
    
The \labelcref approach works regardless of whether a "name" for an item to be cross referenced has already been defined or not. It's also handy when you want to override an existing "name." –  Mico May 17 '12 at 17:53
    
@N.N: Please be a bit more specific about the "constructs that do not have cross-reference names, such as linguistic examples" that you have in mind. The two examples you gave in your posting (items in an enumerated list, and equations) do have default names ("item" and "equation", respectively) set up for them. –  Mico May 17 '12 at 19:31
    
Say, any new list created via enumitem. –  N.N. May 17 '12 at 19:49
    
@N.N. -- items in such a list have the name "item" by default. At any rate, as my MWE demonstrates, use of \creflabel to cross-reference such items is quite problem-free... –  Mico May 17 '12 at 20:39
add comment

In general, using \labelcref as per Mico's answer seems to be the correct solution. If you want to use \cref for constructs that do not have a cross-reference name, here's a workaround:

\crefname{enumi}{\unskip}{\unskip}
\crefname{equation}{\unskip}{\unskip}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.