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.
EDIT: I've added compilable code.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[noabbrev,capitalize,nameinlink]{cleveref}
\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}
\includegraphics[width=0.5\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Pantalla de bienvenida}
\label{fig:test1}
\end{center}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[h]{0.48\textwidth}
\centering
\includegraphics[width=\textwidth]{./images/navigation/nav01_welcome.png}
\caption{Arabic numerals}\label{fig:1a}
\label{fig:nav01_welcome}
\end{subfigure}
\quad
\begin{subfigure}[h]{0.48\textwidth}
\centering
\includegraphics[width=\textwidth]{./images/navigation/nav02_welcome.png}
\caption{Arabic numerals}\label{fig:1b}
\end{subfigure}
\caption{Capital Roman numerals}\label{fig:1}
\end{figure}
\end{document}
Best Answer
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 secondfigure
environment may be eliminated if you replace\quad
with\hfill
.