When using Elsevier's article template elsarticle, the references to appendix sections return Appendix X instead of X. I personally dislike the double space, so I was trying to create a macro to retrieve the X from the reference. I tried to follow this answer guidance to create such a macro using xstring's \StrRight, which allows the retrieval of the last character of a given string. However, I cannot understand the result I am obtaining. Below, I present a minimal code to reproduce the problem and also a screenshot of its result.
\documentclass{elsarticle}
\usepackage{xstring}
\newcommand{\getLastLetter}[1]{%
\StrRight{#1}{1}[\lastLetter]%
\lastLetter
}
\begin{document}
The label letter of \ref{appendixSectionLabel} is \getLastLetter{\ref{appendixSectionLabel}}.
\appendix
\section{}
\label{appendixSectionLabel}
\end{document}

elsarticle.clsdefines\appendixnamewith\def\appendixname{Appendix }(with the space). I can't be sure, but this sounds like a typo to me. You can try\renewcommand\appendixname{Appendix}and observe for side effects... – gusbrs Jan 30 '24 at 02:02