# cref reference format for label type ' undefined

I have this error that I suspect comes from the fact that my tables and figures are in a slave file. It seems that cleveref does not manage to see the "class" of my float. I tried with varioref and I have a similar issue, I tried to put the \includegraphics before the text, I updated my TeXLive... Any help is welcome.

Here my example (sorry if it's not following the proper rule but it's my first time with a question).

\documentclass[english]{article}
\usepackage{graphicx}
\usepackage{lscape, rotating}
\usepackage{tabu, longtable}
\usepackage{babel}
\usepackage{hyperref, varioref, cleveref}
\usepackage[xindy, acronym, nonumberlist]{glossaries}

\begin{document}

Before running any analysis we first checked for collinearity or correlation
among variables and did not notice any specific relationship (scatterplot
not shown).

We present here scatterplot matrix of data grouped by theme: presence data
(\vref{Pevex8r}), CPUE data (\vref{Cevex8r}) and time and location data
(\vref{TLevex8r}).

As \gls{CPUE} data are severely skewed, we transformed them using a $log$
transformation: $\log($\gls{CPUE}$+1)$ (\vref{CTevex8r}).

\include{figure_Recap1}
\end{document}


Here is what my slave file looks like:

\begin{figure}
\scalebox{0.8}{
\includegraphics{../../R/Data_exploration/Plots/Pevex8r.pdf}
}
\label{Pevex8r}\caption{Scatterplot matrix of species presence variable}
\end{figure}

\begin{figure}
\scalebox{0.7}{
\includegraphics{../../R/Data_exploration/Plots/TLevex8r}
}
\label{TLevex8r}\caption{Scatterplot matrix of time and location variable}
\end{figure}


etc...

• Welcome to TeX.sx! Mar 14 '13 at 16:18
• A side comment: When loading the varioref, hyperref, and cleveref packages, it's best to load them in this order. (In your example code, you load hyperref before varioref.)
– Mico
Mar 14 '13 at 16:31
• @Mico: You just solved my 100%-CPU hang problem! Thanks! May 5 '13 at 13:55

You have to put the \label command after the \caption. Then, both \vref and \cref will work.

The reason for the error is that cleveref and varioref cannot determine the type of the label unless \caption is issued first. Putting the label after the caption will tell cleveref and varioref that the object's type is, in both of the examples you give, figure.

• +1 isn't this true for any label and ref though (not just cref and vref)? Mar 14 '13 at 17:13
• @cmhughes Yes, of course, but the error message in the title of the question refers to the broken type inference. Put differently, other \ref-like commands will also not work correctly, but won't show this error, sometimes not even an error at all.
– mafp
Mar 14 '13 at 17:23
– mafp
Mar 15 '13 at 17:59
• I had this problem because I was using caption*{} to suppress figure numbering. Mar 7 '14 at 18:10
• I had this problem because I was using \setcounter{secnumdepth}{0}` to suppress section numbering.
– bers
Jan 29 '19 at 11:44

In my case the error message was resolved by trying yet another ordering of loading the three packages varioref, cleveref and hyperref:

1. varioref
2. hyperref
3. cleveref

Source: https://en.wikibooks.org/w/index.php?title=LaTeX/Labels_and_Cross-referencing section "Interpackage interactions for varioref, hyperref, and cleveref"