Extra “appendix” when referencing using cleveref in elsarticle

How do I get rid of the extra "appendix" appearing when I cross-reference an appendix section? Example output is "...see appendix Appendix A". MWE as follows:

\documentclass[preprint,3p]{elsarticle}

\usepackage{cleveref}

\begin{document}

\begin{frontmatter}

\title{Title}

\author{Author}

\begin{abstract}
Abstract abstract abstract
\end{abstract}

\end{frontmatter}

\section{Section1}
We would like to reference \cref{sec:app}. And the same for \cref{sec:app2}.

\appendix
\section{Section One} \label{sec:app}
Something here

\section{Section Two} \label{sec:app2}

\end{document}


If you want to suppress the cross-reference name for a particular type, it's simpler to just use

\crefname{appendix}{}{}


Then all the formats get defined for you automatically, instead of having to redefine \crefformat, \crefmultiformat, \crefrangeformat, and \labelcrefformat separately. (These days, cleveref is clever enough to omit the usual non-breaking space after the cross-reference name if you define an empty name.)

However, this solution (and ach's too) will break cleveref's multi-reference features somewhat. E.g. \cref{apdx1,apdx2,apdx3,apdx5,apdx7} will produce "Appendix 1 to Appendix 3 and Appendix 4 and Appendix 5", instead of "Appendices 1 to 3, 4 and 5".

Luckily, elsarticle defines an \appendixname macro to hold the string used in appendix labels, no doubt to allow it to be customised easily. So the best solution is simply to get rid of elsarticle's \appendixname entirely, and let cleveref do its job as usual, by adding this to your preamble:

\def\appendixname{}

• Note that it should be \crefname{appendix}{}{} not \crefname{appendux}{}{} – darthbith Dec 28 '14 at 14:04

The elsarticle class evidently redefines the labels for the appendices to contain the word "Appendix", but cleveref assumes alphanumeric labels that need a word with them.

A simple solution to this clash is to redefine the way cleveref formats the appendix references, via \crrefformat{<type>}{<format>} (cf. section 7.2.1 of the cleverref manual).

Applied to your MWE it would be

\documentclass[preprint,3p]{elsarticle}

\usepackage{cleveref}

\crefformat{appendix}{#2#1#3}

\begin{document}

\begin{frontmatter}

\title{Title}

\author{Author}

\begin{abstract}
Abstract abstract abstract
\end{abstract}

\end{frontmatter}

\section{Section1}
We would like to reference \cref{sec:app}. And the same for \cref{sec:app2}.

\appendix
\section{Section One} \label{sec:app}
Something here

\section{Section Two} \label{sec:app2}

\end{document}


This yields

We would like to reference Appendix A. And the same for Appendix B.