# Not displaying 'Figure' cross reference

I'm using ShareLatex and I'm trying to add a cross reference of a figure, but the result of the \ref{fig:sampe} only displays the number of the image and does not follow the format 'Figure 1' for example. I've tried with figure and subfigures and the result is the same.

Currently I'm using the following packages:

\usepackage{caption}
\usepackage{subcaption}
\usepackage{cleveref}


And also added the following lines:

\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand\thesubfigure{(\alph{subfigure})}


Does anyone knows why is this happening?

I've already checked the following posts this and this. Thanks in advance.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage{caption}
\usepackage{subcaption}

\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
\renewcommand{\figurename}{Figura}
\renewcommand\thesubfigure{(\alph{subfigure})}

\usepackage[
backend=biber,
sorting=none,
urldate=edtf,
date=edtf,
seconds=true
]{biblatex}
\usepackage{url}
\usepackage{float}

\begin{document}

Some text, here it would have to appear the first reference \cref{fig:test1} , here it would have to appear the seconds reference \cref{fig:nav01_welcome}.

\begin{figure}[H]
\begin{center}
\caption{Pantalla de bienvenida}
\label{fig:test1}
\end{center}
\end{figure}

\begin{figure}
\centering
\begin{subfigure}[h]{0.48\textwidth}
\centering
\caption{Arabic numerals}\label{fig:1a}
\label{fig:nav01_welcome}
\end{subfigure}
\begin{subfigure}[h]{0.48\textwidth}
\centering
\caption{Arabic numerals}\label{fig:1b}
\end{subfigure}
\caption{Capital Roman numerals}\label{fig:1}
\end{figure}

\end{document}

• have you tried using \cref{<key>}? Welcome to TeX.SE! – Troy May 13 '17 at 15:25
• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – Heiko Oberdiek May 13 '17 at 15:51
• Thanks. I've edited my post to add the comilable code sample where the problem I'm facing can be reproduced. But anyway thanks @Troy, \cref{<key>} did the trick. – texuser May 14 '17 at 8:11
• How is this compilable? There is no documentclass line. You claimed to load package cleveref but the example doesn't show that either. – Johannes_B May 14 '17 at 8:21
• Also, visitado en does not seem to be english. Why are you confusing yourself and others by saying so? – Johannes_B May 14 '17 at 8:23

All is well if you load the cleveref package last -- and if you use \cref instead of \ref.

Two additional suggestions: Don't provide more than one \label per \caption. And, the three \centering instructions in the second figure environment may be eliminated if you replace \quad with \hfill.

\documentclass[demo,spanish]{article} % remove 'demo' option in real document
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx,babel,caption,subcaption}

\captionsetup[subfigure]{subrefformat=simple,labelformat=simple}
%\renewcommand{\figurename}{Figura}
\renewcommand\thesubfigure{(\alph{subfigure})}

\begin{document}

Here's the first cross-reference: \cref{fig:test}.

Here's the second cross-reference: \cref{fig:2a}.

\begin{figure}[h]
\centering
\caption{Pantalla de bienvenida}
\label{fig:test}
\end{figure}

\begin{figure}[h]
\begin{subfigure}{0.48\textwidth}