I am using the xr and cleveref packages to reference figures in another document, using the same figure and table numbers as the other document, as shown here. However, for non-floating figures and tables, I can't use the \@captype used in \extref. Therefore, I'd like to get the cleveref type of a given reference. However, I have been unable to find a technique for this.
Here's a MWE without xr and the external document (because I don't think those complications are important for this question, unless there's no way to extract the cleveref type).
Updated MWE (showing more precisely the problem):
\documentclass{article}
\usepackage{graphicx}
\usepackage{cleveref}
\usepackage{caption}
\makeatletter
\newcommand{\extref}[1]{%
@namedef{the@captype}{\ref{#1}}%
}
\makeatother
\begin{document}
\begin{center}
\includegraphics{example-image-a.jpg}
\captionof{figure}{caption\label{fig:example}}
\end{center}
\begin{center}
\includegraphics{example-image-a.jpg}
\extref{fig:example}
\captionof{figure}{repeated}
\end{center}
Here is a reference: \cref{fig:example}.
\end{document}


\extref. I need to replace\@captypewith something that extracts the cleveref type. – Rico Picone Aug 04 '23 at 22:57