6

I really like cleveref.

And I've been using it when writing a manuscript with the ametsoc style file

But there is at least one problem: The appendix letters (which must be manually assigned and referenced in the text) get displaced.

Example:

\appendix[A]
\appendixtitle{Title name}

Should yield

Appendix A

Title name

But instead I get

Appendix

A

Title name

I don't want to go over the entire text and replace my \crefs with the appropriate Fig. Eqn. etc... especially since I might want to reuse the text in another document, where sections might be chapters.

Any ideas?


Minimum working example

\documentclass[twocol]{ametsoc}
\journal{mwr}
\usepackage{cleveref} 
\begin{document}
\appendix[A]
\appendixtitle{Title}
  Blah blah
\end{document}
  • Could please add a minimal working example (MWE) showing the issue? – egreg Oct 30 '14 at 11:41
  • Please advise where the file ametsoc.cls might be obtained from. It doesn't seem to be on the CTAN. – Mico Oct 30 '14 at 12:02
  • @Mico It's at the bottom of the ametsoc documentation page that I linked to – Patrick Oct 30 '14 at 12:25
7

The cleveref package patches \appendix assuming it's a parameterless macro, which isn't true with ametsoc.

My strategy is thus to recover the correct definition of \appendix from the badly patched macro and doing the patch in a safer way.

\documentclass[twocol]{ametsoc}
\journal{mwr}
\usepackage{cleveref}
\usepackage{xpatch}

% split the badly patched \appendix command
% into the two parts: the first four tokens
% will restore the correct definition of \appendix
% and the rest is the patching text, stored
% into \appendtoappendix
\begingroup
\def\splitappendix#1#2#3#4#5\splitappendix{%
  \endgroup
  \def\appendix{#1#2#3{#4}}\toks0={#5}%
  \edef\cleverefappendixaddition{\the\toks0}%
}
\expandafter\splitappendix\appendix\splitappendix % \splitappendix will disappear
\xapptocmd\appendix{\cleverefappendixaddition}{}{}

\begin{document}
\appendix[A]           
\appendixtitle{Title}
  Blah blah
\end{document}

enter image description here

A possibly simpler strategy would be

\documentclass[twocol]{ametsoc}
\journal{mwr}

\let\goodappendix\appendix
\def\appendix{}

\usepackage{cleveref}

\let\cleverefappendixaddition\appendix
\let\appendix\goodappendix
\usepackage{xpatch}
\xapptocmd\appendix{\cleverefappendixaddition}{}{}

that would obtain the same result, but requires codes intermixed with package loading.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.