# cleveref breaks \appendix with optional argument defined in IEEEtran

I think the title says it all. Including cleveref in this MWE changes how the output looks:

\documentclass{IEEEtran}
% \usepackage{cleveref}
\begin{document}
\end{document}


Is there an option to prevent that? I have looked at the cleveref manual, but haven't found anything yet.

I believe this is fixed in the pre-release versions (0.21) available from my web site, and quite possibly also in the previous pre-release (0.20): http://www.dr-qubit.org/latex.html

At least, the MWE produces identical output with and without cleveref.

• Having checked out v0.21, I believe you are right :) Also, I am glad to see the enum-sort bug has been fixed. Finally, I have replaced v0.19 by v0.21 in my 30-page document without seeing any difference, so it only got better. Thanks! – bers Jun 13 '17 at 7:08

The fastest and easiest way is for sure to save the meaning of \appendix before loading cleveref and restore it to that after loading the package:

\documentclass{IEEEtran}
\let\ieeeappendix\appendix
\usepackage{cleveref}
\let\appendix\ieeeappendix

\begin{document}
\end{document}


Note however, that this might restrict the functionality of cleveref.

• "Note however, that this might restrict the functionality of cleveref." - Yes, a reference to a section in the appendix becomes section A rather than appendix A. Fortunately, without \section commands, \cref does not work properly anyway, so much is not lost ;) – bers Jan 24 '17 at 9:23

Give IEEEtran a chance to maintain its definition of \appendix by using \AtBeginDocument{...} and a more robust version of \appendix.

Since IEEEtran uses \refstepcounter{section} in the \appendix code, \label will store this information, so cleveref will always report Section instead of Appendix. Use \label[appendix]{foo} instead then.

\documentclass{IEEEtran}

\usepackage{letltxmacro}

\usepackage{xparse}

\makeatletter
\LetLtxMacro\ieeetran@appendix\appendix
\AtBeginDocument{%
\RenewDocumentCommand{\appendix}{o}{%
\IfValueTF{#1}{%
\ieeetran@appendix[#1]%
}{%
\ieeetran@appendix%
}%
}
}
\makeatother

\usepackage{cleveref}

\begin{document}
See \Cref{appone}

\appendix \label[appendix]{appone}