GeneralA conflict between cleveref and a publisher sty file

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
mzzxx11
Posts: 2
Joined: Thu May 15, 2014 9:21 pm

A conflict between cleveref and a publisher sty file

Post by mzzxx11 »

A publisher's .sty file defines an appendix command:

Code: Select all

%NEW MACRO TO HANDLE APPENDICES
\newcounter{appendixc}
\newcounter{subappendixc}[appendixc]
\newcounter{subsubappendixc}[subappendixc]
\renewcommand{\thesubappendixc}{\Alph{appendixc}.\arabic{subappendixc}}
\renewcommand{\thesubsubappendixc}
    {\Alph{appendixc}.\arabic{subappendixc}.\arabic{subsubappendixc}}

\renewcommand{\appendix}[1] {\vspace{14pt}
        \refstepcounter{appendixc}
        \setcounter{section}{0}
        \setcounter{figure}{0}
        \setcounter{table}{0}
        \setcounter{lemma}{0}
        \setcounter{theorem}{0}
        \setcounter{corollary}{0}
        \setcounter{equation}{0}
        \renewcommand{\thesection}{\Alph{appendixc}.\arabic{section}}
        \renewcommand{\thefigure}{\Alph{appendixc}.\arabic{figure}}
        \renewcommand{\thetable}{\Alph{appendixc}.\arabic{table}}
        \renewcommand{\theappendixc}{\Alph{appendixc}}
        \renewcommand{\thelemma}{\Alph{appendixc}.\arabic{lemma}}
        \renewcommand{\thetheorem}{\Alph{appendixc}.\arabic{theorem}}
        %\renewcommand{\thedefinition}{\Alph{appendixc}.\arabic{definition}}
        \renewcommand{\thecorollary}{\Alph{appendixc}.\arabic{corollary}}
        \renewcommand{\theequation}{\Alph{appendixc}.\arabic{equation}}
        %\noindent{\bf Appendix \theappendixc. #1}\par\vspace{5pt}}
        \noindent{\bfseries Appendix \theappendixc \quad #1}\par\vspace{5pt}}
\newcommand{\subappendix}[1] {\vspace{14pt}
        \refstepcounter{subappendixc}
        \noindent{\bfseries Appendix \thesubappendixc {\kern1pt \textit{ #1}}}
    \par\vspace{8pt}}
\newcommand{\subsubappendix}[1] {\vspace{14pt}
        \refstepcounter{subsubappendixc}
        \noindent{\textrm{Appendix \thesubsubappendixc {\kern1pt \textit{#1}}}}
    \par\vspace{8pt}}
I'm also using the cleveref package which is tweaking the appendix command and/or counter:

Code: Select all

\@ifundefined{appendix}{}{%
  \g@addto@macro\appendix{%
    \@ifundefined{chapter}{%
      \gdef\refstepcounter@noarg#1{%
        \cref@old@refstepcounter{#1}%
        \cref@constructprefix{#1}{\cref@result}%
        \ifx\cref@result\@empty%
          \def\cref@result{2147483647}%
        \else%
          \edef\cref@result{2147483647,\cref@result}%
        \fi%
        \def\@tempa{#1}%
        \def\@tempb{section}%
        \ifx\@tempa\@tempb%
          \protected@edef\cref@currentlabel{%
            [appendix][\arabic{#1}][\cref@result]%
            \csname p@#1\endcsname\csname the#1\endcsname}%
        \else%
          \def\@tempa{#1}%
          \def\@tempb{subsection}%
          \ifx\@tempa\@tempb%
            \protected@edef\cref@currentlabel{%
              [subappendix][\arabic{#1}][\cref@result]%
              \csname p@#1\endcsname\csname the#1\endcsname}%
          \else%
            \def\@tempa{#1}%
            \def\@tempb{subsubsection}%
            \ifx\@tempa\@tempb%
              \protected@edef\cref@currentlabel{%
                [subsubappendix][\arabic{#1}][\cref@result]%
                \csname p@#1\endcsname\csname the#1\endcsname}%
            \else%
              \@ifundefined{cref@#1@alias}%
                {\def\@tempa{#1}}%
                {\def\@tempa{\csname cref@#1@alias\endcsname}}%
              \protected@edef\cref@currentlabel{%
                [\@tempa][\arabic{#1}][\cref@result]%
                \csname p@#1\endcsname\csname the#1\endcsname}%
            \fi%
          \fi%
        \fi}%
    }{%
      \def\refstepcounter@noarg#1{%
        \cref@old@refstepcounter{#1}%
        \cref@constructprefix{#1}{\cref@result}%
        \ifx\cref@result\@empty%
          \def\cref@result{2147483647}%
        \else%
          \edef\cref@result{2147483647,\cref@result}%
        \fi%
        \def\@tempa{#1}%
        \def\@tempb{chapter}%
        \ifx\@tempa\@tempb%
          \protected@edef\cref@currentlabel{%
            [appendix][\arabic{#1}][\cref@result]%
            \csname p@#1\endcsname\csname the#1\endcsname}%
        \else%
          \def\@tempa{#1}%
          \def\@tempb{section}%
          \ifx\@tempa\@tempb%
            \protected@edef\cref@currentlabel{%
              [subappendix][\arabic{#1}][\cref@result]%
              \csname p@#1\endcsname\csname the#1\endcsname}%
          \else%
            \def\@tempa{#1}%
            \def\@tempb{subsection}%
            \ifx\@tempa\@tempb%
              \protected@edef\cref@currentlabel{%
                [subsubappendix][\arabic{#1}][\cref@result]%
                \csname p@#1\endcsname\csname the#1\endcsname}%
            \else%
              \def\@tempa{#1}%
              \def\@tempb{subsubsection}%
              \ifx\@tempa\@tempb%
                \protected@edef\cref@currentlabel{%
                  [subsubsubappendix][\arabic{#1}][\cref@result]%
                  \csname p@#1\endcsname\csname the#1\endcsname}%
              \else%
                \@ifundefined{cref@#1@alias}%
                  {\def\@tempa{#1}}%
                  {\def\@tempa{\csname cref@#1@alias\endcsname}}%
                \protected@edef\cref@currentlabel{%
                  [\@tempa][\arabic{#1}][\cref@result]%
                  \csname p@#1\endcsname\csname the#1\endcsname}%
              \fi%
            \fi%
          \fi%
        \fi}%
    }%
  }%
}% end of \@ifundefined{appendix}
Following the publisher's guidelines, I define an appendix as \appendix{A}. This causes the compilation error , which I'm unable to solve:

Code: Select all

! Argument of \@ifundefined has an extra }.
<inserted text> 
                \par 
l.52 \appendix
               {A}
I would be grateful if someone here could assist in solving this

TIA

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

mzzxx11
Posts: 2
Joined: Thu May 15, 2014 9:21 pm

Re: A conflict between cleveref and a publisher sty file

Post by mzzxx11 »

The problem has solved by loading cleveref before the publisher's .sty file
Post Reply