How to get \cref to print “Fig.” in emacs?

I'm having trouble using \cref in emacs' AUCTeX + RefTeX mode. The pdf shows the reference to a picture as "section 1.3" instead of "Fig.1a" (see snapshot below) as it should, when \usepackage{cleveref} is loaded in the preamble of the main.tex file.

I've read these 2 discussions: link-1, link-2, and I have added the following lines to my .emacs file but can't notice any change in emacs' behaviour.

;;emacs RefTeX
(setq reftex-ref-macro-prompt nil) ;skips picking the reference style

;code taken from SX "Cleveref: AUCTeX and RefTeX set-up"
"latex"
"cleveref"
(lambda ()
(if (boundp 'reftex-ref-style-alist)
'reftex-ref-style-alist
'("Cleveref" "cleveref"
(("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
(reftex-ref-style-activate "Cleveref")
'("cref" TeX-arg-ref)
'("Cref" TeX-arg-ref)
'("cpageref" TeX-arg-ref)
'("Cpageref" TeX-arg-ref)))))


Can someone help me out, please?

=MWE=

\documentclass[10pt, a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[italian]{babel}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage{esdiff}
\usepackage[version=4]{mhchem}
\usepackage[a4paper]{geometry}
\usepackage{fullpage}
\usepackage{lipsum}

% FONT CHOICE
% Palatino for serif & math, Helvetica for ss, Courier for tt
\usepackage{mathpazo} % math & rm
\usepackage[scaled]{helvet} % ss
\usepackage{courier} % tt
\normalfont

\usepackage{siunitx}
\DeclareSIUnit\Molar{\textsc{m}}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{cleveref}

\graphicspath{{./IMGS/}}

\title{sometitle}

\begin{document}
\begin{enumerate}
\item bla bla bla? [cfr. \cref{fig:rame}]
\end{enumerate}

\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[scale=.4]{a}
\label{fig:nacl}
\begin{subfigure}[b]{0.4\textwidth}
\includegraphics[scale=0.4]{b}
\label{rame}
\end{subfigure}
\label{fig:figure}
\caption{General caption}
\end{figure}

\end{document}


=SNAPSHOT=

• Maybe you should tell which version of emacs and auctex, which OS you are using. I won't be able to help you anyway, but maybe these hints would help some experts. Did you go into the same troubles when you compile with latexmk from outside emacs? – sztruks Oct 31 '15 at 19:51
• Your two subfigure environments appear to lack \caption statements. Also, for the overall  figure, the label should come after the caption. – Mico Oct 31 '15 at 19:57

The issues you're experiencing are not related to emacs, and they are only indirectly related to cleveref. You need to do the following:

• In the main figure, interchange the order of \caption and \label: the \caption statement must come before the \label statement.

• Provide \caption statements for each of the two subfigure environments. Be mindful of the fact that the \caption statements must come before the \label statements.

• Fix the argument of the \label instruction in the second subfigure: It currently reads rame, whereas the argument of \cref is fig:rame. I suggest you change the \label statement to \label{fig:rame}.

Finally, if you need \cref to generate Fig. rather than fig., be sure to load the cleveref package with the option capitalize (capitalise works too).

• Thanks for the capitalize hint! There's still a teeny-tiny problem I'm getting – when I press C-c ) I get \ref{} instead of \cref{}. Also, Emacs still asks for reference style . Is the elisp code above, not effective? – WobblyWindows Nov 1 '15 at 9:45
• I'm afraid I'm not an Emacs expert. May I ask you to pose a new question that's specifically about (a) how to get C-c to generate \cref{} and (b) how to answer Emacs's query about reference styles? – Mico Nov 1 '15 at 9:54
• @WobblyWindows I have just the thing if you'd like to post a question so it's not hidden in these comments =) – Sean Allred Nov 1 '15 at 14:27