# Adding "Appendix" in front of "Figure" in cref

I'm trying to create a list of appendix table/figures, which are formatted as: "Appendix Table/Figure #." I'm using the following code:

\renewcommand{\figurename}{Appendix Figure}
\renewcommand{\tablename}{Appendix Table}
\setcounter{figure}{0}
\setcounter{table}{0}

\begin{figure}[H]
\centering
\caption{Sources of Data}
\label{fig:appx_source}
\centering
\includegraphics[width=0.8\textwidth]{"Source"}
\end{figure}



However, when I use \cref{fig:appx_source} it seems like it outputs "Figure 1" instead of "Appendix Figure 1". Is there a way where I can make cref output "Appendix Figure 1"?

• Will all figure and table environments be located in the appendix? Or might there be both a "Figure 1", in the body of the document, and an "Appendix Figure 1" in, well, the appendix? Please advise. A further question: Does your document employ the hyperref package? Finally, would you be willing to switch from "Appendix Figure 1" to "Figure A1", where A is the (alphabetical) "number" of the appendix section?
– Mico
Dec 2 '21 at 4:08

A comment up front: I do not actually recommend that you implement the approach laid out in your query and pursued further in this answer. First, if your document employs the hyperref package as well and if your document has figure and table environments in both the main body and in the appendix, hyperlinks to figures and tables in the appendix won't come out right. Second, the cross-references will be quite long and quickly look clunky. (Instead, assuming the appendix sections are "numbered" A, B, etc, I'd recommend that you change the numbering system for figure and table environments from "1", "2", ... to "A.1", "A.2", ... via \counterwithin{figure}{section} and \counterwithin{table}{section} statements. That way, hyperlinks will be set correctly, and no cleveref-related adjustments are needed to begin with.)

You may achieve your formatting goal by making use of the aliasing mechanism described in section 6, "Overriding the cross-reference type", of the user guide of the cleveref package. Specifically, I would suggest that you provide two \crefname statements in the preamble, to define the alias labels for figure and table environments, and issue two \crefalias statements upon reaching the appendix material.

\documentclass{article}
\usepackage[capitalize,noabbrev]{cleveref}
\crefname{appfig}{Appendix Figure}{Appendix Figures}
\crefname{apptab}{Appendix Table}{Appendix Tables}

\begin{document}
\section{Hello}
Cross-references  to \cref{fig:source,fig:info,tab:there,tab:material}.

% A minimalist way of creating "labels":
\refstepcounter{figure} \label{fig:here}
\refstepcounter{table}  \label{tab:there}

\appendix
\renewcommand{\figurename}{Appendix Figure}
\renewcommand{\tablename}{Appendix Table}
\setcounter{figure}{0}
\setcounter{table}{0}
\crefalias{figure}{appfig}
\crefalias{table}{apptab}

\section{World}

\refstepcounter{figure} \label{fig:source}
\refstepcounter{figure} \label{fig:info}
\refstepcounter{table}  \label{tab:material}

Cross-references  to \cref{fig:here,fig:source}.
\end{document}