# How to cross-reference name of subfigures

I have a document where I use figures and subfigures (provided by the package subcaption). When I cross-reference subfigures using \Cref{subfigure-label} I get the right cross-reference, e.g., "Figure 1a", but when I try to get only its name, i.e., "figure", by means of \nameCref{subfigure-label} or \lcnamecref{subfigure-label} I get only question marks.

How could I get the names of the cross-referenced subfigures, namely, "figure" or, if possible, "subfigure" instead of the question marks?.

Here a MWE

\documentclass[10pt,a4paper]{article}
\usepackage{graphicx}
\usepackage{cleveref}
\usepackage{subcaption}
\begin{document}

\begin{figure}
%First landscape as subfigure
\begin{subfigure}[t]{0.4\textwidth}
\includegraphics[width=\textwidth]{landscape.jpeg}
\caption{first landscape}\label{fig:landscape-1}
\end{subfigure}\hspace{0.2\textwidth}
%Second landscape as subfigure
\begin{subfigure}[t]{0.4\textwidth}
\includegraphics[width=\textwidth]{landscape.jpeg}
\caption{second landscape}\label{fig:landscape-2}
\end{subfigure}
\caption{Two landscapes}\label{fig:landscapes}
\end{figure}

%Text cross-referencing the figures and subfigures
Above there is a \lcnamecref{fig:landscapes}, its name is \Cref{fig:landscapes}.\\
\Cref{fig:landscape-1} is a beautiful landscape, and so in \Cref{fig:landscape-2}.
The first landscape is a \lcnamecref{fig:landscape-1}
and the second is a \nameCref{fig:landscape-2} too.

\end{document}

Thanks!

• Use \crefname{subfigure}{figure}{figures} \Crefname{subfigure}{Figure}{Figures} before \begin{document} and load cleveref after subcaption – user31729 Nov 30 '17 at 11:38

You have to inform cleveref about the meaning of subfigure counter reference information. This is not done (yet) in cleveref, so \crefname{subfigure}{figure}{figures} and \Crefname{subfigure}{Figure}{Figures} is needed, otherwise ?? is displayed.

Change figure to subfigure etc. if needed/desired.

cleveref should also loaded at last package, even after hyperref.

\documentclass[10pt,a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{subcaption}
\usepackage{cleveref}

\crefname{subfigure}{figure}{figures}
\Crefname{subfigure}{Figure}{Figures}
\begin{document}

\begin{figure}
%First landscape as subfigure
\begin{subfigure}[t]{0.4\textwidth}
\includegraphics[width=\textwidth]{landscape.jpeg}
\caption{first landscape}\label{fig:landscape-1}
\end{subfigure}\hspace{0.2\textwidth}
%Second landscape as subfigure
\begin{subfigure}[t]{0.4\textwidth}
\includegraphics[width=\textwidth]{landscape.jpeg}
\caption{second landscape}\label{fig:landscape-2}
\end{subfigure}
\caption{Two landscapes}\label{fig:landscapes}
\end{figure}

%Text cross-referencing the figures and subfigures
Above there is a \lcnamecref{fig:landscapes}, its name is \Cref{fig:landscapes}.\\
\Cref{fig:landscape-1} is a beautiful landscape, and so in \Cref{fig:landscape-2}.
The first landscape is a \lcnamecref{fig:landscape-1}
and the second is a \nameCref{fig:landscape-2} too.

\end{document}
• I am really glad and thankful for an easy and perfectly correct answer in some minutes time. But It feels like I am unskilled in LaTeX; I, myself, should have found this answer. ;) – loved.by.Jesus Nov 30 '17 at 11:50
• very good for your excellent work +1. – Sebastiano Nov 30 '17 at 20:39