[Tex/LaTex] \Cref not working

cleverefcross-referencing

\documentclass[Afour,sageh,times]{sagej}

\usepackage[english]{babel}
\usepackage{cleveref}


\begin{document}

\section{Introduction}
\label{sec:Introduction}

\Cref{sec:discussion}

\section{Discussion}
\label{sec:discussion}

\end{document}

The above minimal example doesn't work as when I use \Cref, it doesn't work and
prints only ??. Can anybody please help me out with this error.

Thanks.

Best Answer

The sagej document class sets \setcounter{secnumdepth}{-2}. This means that absolutely no sectioning headers are numbered anywhere in the document. Therefore, both \section{Introduction} and \section{Discussion} produce unnumbered sectioning headers.

LaTeX's cross-referencing mechanism works by associating each \label instruction with the most recently incremented counter variable. Since your MWE contains no counters that are incrementef, \Cref cannot possibly generate a valid cross-reference. That's why you get ??.

enter image description here

If you want numbered section-level headers, set \setcounter{secnumdepth}{1} somewhere in your preamble. Do be aware, though, that this change quite likely defeats the design choices of the sagej document class and, as such, may not be viewed favorably by editors.

Related Question