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"
(eval-after-load
"latex"
'(TeX-add-style-hook
"cleveref"
(lambda ()
(if (boundp 'reftex-ref-style-alist)
(add-to-list
'reftex-ref-style-alist
'("Cleveref" "cleveref"
(("\\cref" ?c) ("\\Cref" ?C) ("\\cpageref" ?d) ("\\Cpageref" ?D)))))
(reftex-ref-style-activate "Cleveref")
(TeX-add-symbols
'("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
\linespread{1.05} % Palatino needs more leading (space between lines)
\usepackage[scaled]{helvet} % ss
\usepackage{courier} % tt
\normalfont
\usepackage{siunitx}
\DeclareSIUnit\Molar{\textsc{m}}
\usepackage{booktabs}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[colorlinks=false, pdfborder={0 0 0}]{hyperref}
\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}
\end{subfigure} \quad
\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}
subfigure
environments appear to lack\caption
statements. Also, for the overall ` figure`, the label should come after the caption.