18

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...

3
  • Welcome to TeX.sx!
    – Corentin
    Mar 14, 2013 at 16:18
  • 1
    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, 2013 at 16:31
  • @Mico: You just solved my 100%-CPU hang problem! Thanks!
    – letmaik
    May 5, 2013 at 13:55

4 Answers 4

11

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.

6
  • 3
    +1 isn't this true for any label and ref though (not just cref and vref)?
    – cmhughes
    Mar 14, 2013 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, 2013 at 17:23
  • @XochitlCORMON If this solves your problem, may I ask you to accept the answer?
    – mafp
    Mar 15, 2013 at 17:59
  • 1
    I had this problem because I was using caption*{} to suppress figure numbering.
    – Andrew
    Mar 7, 2014 at 18:10
  • 1
    I had this problem because I was using \setcounter{secnumdepth}{0} to suppress section numbering.
    – bers
    Jan 29, 2019 at 11:44
2

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"

0

I encountered this error when I placed my \crefname statement inside my document instead of in my preamble. (The location with the preamble may also matter; see the other answers).

2
  • The code in the question doesn't include \crefname, does it? What does 'my \crefname statement' refer to?
    – cfr
    Jan 15 at 23:56
  • That's a command from the cleveref package that defines the displayed names of environments. The situation I described is not the problem the OP had, but if other people are having this same error, then they are likely to arrive at this page.
    – Paul Wintz
    Jan 16 at 23:25
0

I have run into the same error, but I resolved it by defining the "theorem" environment that was causing trouble in the preamble after loading cleveref. Namely, the preamble should have the following lines in this order:

\usepackage{cleveref}
\newtheorem{coro}{corollary}

and not the other way around.

You must log in to answer this question.

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