%%
%% This is file `cleveref.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% cleveref.dtx  (with options: `package')
%% 
%% LaTeX package for automatic cross-referencing text.
%% 
%% Copyright (C) 2006  Toby Cubitt
%% See the files README and COPYING.
%% 
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
%% of this license or (at your option) any later version.
%% The latest version of this license is in:
%%
%%    http://www.latex-project.org/lppl.txt
%%
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cleveref}
 [2009/11/02 v0.12 Intelligent cross-referencing]
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\let\cref@old@refstepcounter\refstepcounter
\def\refstepcounter{%
  \@ifnextchar[{\refstepcounter@optarg}{\refstepcounter@noarg}%]
}
\def\refstepcounter@noarg#1{%
  \cref@old@refstepcounter{#1}%
  \cref@resetby{#1}{\@result}%
  \ifx\@result\relax\def\@result{}%
  \else\edef\@result{\csname the\@result\endcsname}\fi%
  \protected@edef\@currentlabel{%
    [#1][\arabic{#1}][\@result]\@currentlabel}}
\def\refstepcounter@optarg[#1]#2{%
  \cref@old@refstepcounter{#2}%
  \cref@resetby{#2}{\@result}%
  \ifx\@result\relax\def\@result{}%
  \else\edef\@result{\csname the\@result\endcsname}\fi%
  \protected@edef\@currentlabel{%
    [#1][\arabic{#2}][\@result]\@currentlabel}}
\def\cref@override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
\AtBeginDocument{%
  \let\cref@old@label\label
  \def\label{\@ifnextchar[\label@optarg\cref@old@label}%]
  \def\label@optarg[#1]{%
    \protected@edef\@currentlabel{%
      \expandafter\cref@override@label@type\@currentlabel\@nil{#1}}%
    \cref@old@label}%
  \@ifpackageloaded{amsmath}{%
    \let\cref@label\label%
    \let\cref@old@label@in@display\label@in@display%
    \def\label@in@display{%
      \@ifnextchar[\label@in@display@optarg\label@in@display@noarg}%]
    \def\label@in@display@noarg#1{\cref@old@label@in@display{{#1}}}
    \def\label@in@display@optarg[#1]#2{%
      \cref@old@label@in@display{[#1]{#2}}}
    \def\ltx@label#1{\cref@label#1}%
  }{}%
}
\def\cref@reflabel#1#2{\@result}
\AtBeginDocument{%
  \DeclareRobustCommand{\ref}{\cref@ref}
  \def\cref@ref#1{%
    \expandafter\ifx\csname r@#1\endcsname\relax%
      \let\@result\relax%
    \else%
      \cref@getlabel{#1}{\@result}%
    \fi%
    \expandafter\@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
}
\let\cref@old@appendix\appendix
\renewcommand\appendix{%
  \cref@old@appendix%
  \@ifundefined{chapter}{%
    \def\refstepcounter@noarg##1{%
      \cref@old@refstepcounter{##1}%
      \cref@resetby{##1}{\@result}%
      \ifx\@result\relax\def\@result{}%
      \else\edef\@result{\csname the\@result\endcsname}\fi%
      \def\@tmpa{##1}
      \def\@tmpb{section}%
      \ifx\@tmpa\@tmpb%
        \protected@edef\@currentlabel{%
          [appendix][\arabic{##1}][\@result]\@currentlabel}%
      \else
        \protected@edef\@currentlabel{%
          [##1][\arabic{##1}][\@result]\@currentlabel}
      \fi}
  }{%
    \def\refstepcounter@noarg##1{%
      \cref@old@refstepcounter{##1}%
      \cref@resetby{##1}{\@result}%
      \ifx\@result\relax\def\@result{}%
      \else\edef\@result{\csname the\@result\endcsname}\fi%
      \def\@tmpa{##1}
      \def\@tmpb{chapter}%
      \ifx\@tmpa\@tmpb%
        \protected@edef\@currentlabel{%
          [appendix][\arabic{##1}][\@result]\@currentlabel}%
      \else
        \protected@edef\@currentlabel{%
          [##1][\arabic{##1}][\@result]\@currentlabel}
      \fi}%
  }%
}
\def\cref@getlabel#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoftwo\@tmpa}%
  \expandafter\@cref@getlabel\@tmpa\@nil#2}
\def\@cref@getlabel{\@ifnextchar[%]
  \@@cref@getlabel{\@@cref@getlabel[][][]}}
\def\@@cref@getlabel[#1][#2][#3]#4\@nil#5{\def#5{#4}}
\def\cref@gettype#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoftwo\@tmpa}%
  \expandafter\@cref@gettype\@tmpa\@nil#2}
\def\@cref@gettype{\@ifnextchar[%]
  \@@cref@gettype{\@@cref@gettype[][][]}}
\def\@@cref@gettype[#1][#2][#3]#4\@nil#5{\def#5{#1}}
\def\cref@getcounter#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoftwo\@tmpa}%
  \expandafter\@cref@getcounter\@tmpa\@nil#2}
\def\@cref@getcounter{\@ifnextchar[%]
  \@@cref@getcounter{\@@cref@getcounter[][][]}}
\def\@@cref@getcounter[#1][#2][#3]#4\@nil#5{\def#5{#2}}
\def\cref@getprefix#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoftwo\@tmpa}%
  \expandafter\@cref@getprefix\@tmpa\@nil#2}
\def\@cref@getprefix{\@ifnextchar[%]
  \@@cref@getprefix{\@@cref@getprefix[][][]}}
\def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
\def\cref@append@toks#1#2{\toks0={#2}%
  \edef\act{\noexpand#1={\the#1\the\toks0}}%
  \act}%
\def\cref@stack@init#1{\def#1{\@nil}}
\def\cref@stack@top#1{\expandafter\cref@stack@top@aux#1}
\def\cref@stack@top@aux#1,#2\@nil{#1}
\def\cref@stack@pop#1{\expandafter\cref@stack@pop@aux#1#1}
\def\cref@stack@pop@aux#1,#2\@nil#3{\def#3{#2\@nil}}
\def\cref@stack@push#1#2{%
  \expandafter\cref@stack@push@aux\expandafter{#2}{#1}{#2}}
\def\cref@stack@push@aux#1#2#3{\def#3{#2,#1}}
\def\cref@stack@pull#1#2{\expandafter\cref@stack@pull@aux#2{#1}{#2}}
\def\cref@stack@pull@aux#1\@nil#2#3{\def#3{#1#2,\@nil}}
\newif\if@cref@stackempty
\newif\if@cref@stackfull
\def\cref@isstackempty#1{%
  \def\@tmpa{\@nil}%
  \ifx#1\@tmpa\@cref@stackemptytrue%
  \else\@cref@stackemptyfalse\fi}
\def\cref@isstackfull#1{%
  \def\@tmpa{\@nil}%
  \ifx#1\@tmpa\@cref@stackfullfalse%
  \else\@cref@stackfulltrue\fi}
\newif\if@cref@inresetlist
\def\cref@isinresetlist#1#2{%
  \def\@counter{#1}%
  \begingroup%
    \def\@elt##1{##1,}%
    \expandafter\ifx\csname cl@#2\endcsname\relax%
      \gdef\cref@resetstack{,\@nil}%
    \else%
      \xdef\cref@resetstack{\csname cl@#2\endcsname\noexpand\@nil}%
    \fi%
  \endgroup%
  \cref@isstackfull{\cref@resetstack}%
  \@whilesw\if@cref@stackfull\fi{%
    \edef\@nextcounter{\cref@stack@top{\cref@resetstack}}%
    \ifx\@nextcounter\@counter%
      \@cref@stackfullfalse%
    \else%
      \let\@nextcounter\relax%
      \cref@stack@pop{\cref@resetstack}%
      \cref@isstackfull{\cref@resetstack}%
    \fi}%
  \ifx\@nextcounter\relax%
    \@cref@inresetlistfalse%
  \else%
    \@cref@inresetlisttrue%
  \fi}
\def\cref@resetby#1#2{%
  \cref@isinresetlist{#1}{subsubsubsection}%
  \if@cref@inresetlist%
    \def#2{subsubsubsection}%
  \else%
    \cref@isinresetlist{#1}{subsubsection}%
    \if@cref@inresetlist%
      \def#2{subsubsection}%
    \else%
      \cref@isinresetlist{#1}{subsection}%
      \if@cref@inresetlist%
        \def#2{subsection}%
      \else%
        \cref@isinresetlist{#1}{section}%
        \if@cref@inresetlist%
          \def#2{section}%
        \else%
          \cref@isinresetlist{#1}{chapter}%
          \if@cref@inresetlist%
            \def#2{chapter}%
          \else%
            \cref@isinresetlist{#1}{part}%
            \if@cref@inresetlist%
              \def#2{part}%
            \else%
              \let#2\relax%
            \fi%
          \fi%
        \fi%
      \fi%
    \fi%
  \fi}
\DeclareRobustCommand{\cref}[1]{\@cref{cref}{#1}}
\DeclareRobustCommand{\Cref}[1]{\@cref{Cref}{#1}}
\DeclareRobustCommand{\crefrange}[2]{\@setcrefrange{#1}{#2}{cref}{}}
\DeclareRobustCommand{\Crefrange}[2]{\@setcrefrange{#1}{#2}{Cref}{}}
\def\@cref#1#2{%
  \begingroup%
  \countdef\count@consecutive=0%
  \def\@empty{}%
  \newif\if@firstgroup%
  \newif\if@secondgroup%
  \newif\if@secondref%
  \cref@stack@init{\@refstack}%
  \cref@stack@push{#2}{\@refstack}%
  \@firstgrouptrue%
  \@secondgroupfalse%
  \cref@isstackfull{\@refstack}%
  \@whilesw\if@cref@stackfull\fi{%
    \cref@stack@init{\@refsubstack}%
    \edef\@nextref{\cref@stack@top{\@refstack}}%
    \expandafter\ifx\csname r@\@nextref\endcsname\relax%
      \def\@currenttype{\@undefined}%
    \else%
      \expandafter\cref@gettype\expandafter{\@nextref}{\@currenttype}%
    \fi%
    \let\@nexttype\@currenttype%
    \@whilesw\ifx\@nexttype\@currenttype\fi{%
      \expandafter\cref@stack@pull\expandafter%
        {\@nextref}{\@refsubstack}%
      \cref@stack@pop{\@refstack}%
      \cref@isstackempty{\@refstack}%
      \if@cref@stackempty%
        \def\@nexttype{\relax}%
      \else%
        \edef\@nextref{\cref@stack@top{\@refstack}}%
        \ifx\@nextref\@empty%
          \let\@currenttype\@nexttype%
        \else%
          \expandafter\ifx\csname r@\@nextref\endcsname\relax%
            \def\@currenttype{\@undefined}%
          \else%
            \expandafter\cref@gettype\expandafter%
              {\@nextref}{\@currenttype}%
          \fi%
        \fi%
      \fi}%
    \if@firstgroup%
      \@firstgroupfalse%
      \@secondgrouptrue%
    \else%
      \cref@isstackfull{\@refstack}%
      \if@cref@stackfull%
        \@setcref@middlegroupconjunction%
      \else%
        \if@secondgroup%
          \@setcref@pairgroupconjunction%
        \else%
          \@setcref@lastgroupconjunction%
        \fi%
      \fi%
      \@secondgroupfalse%
    \fi%
    \edef\@nextref{\cref@stack@top{\@refsubstack}}%
    \cref@stack@pop{\@refsubstack}%
    \cref@isstackempty{\@refsubstack}%
    \if@cref@stackempty%
      \expandafter\@setcref\expandafter{\@nextref}{#1}{}%
    \else%
      \edef\@beginref{\@nextref}%
      \let\@endref\relax%
      \edef\@nextref{\cref@stack@top{\@refsubstack}}%
      \count@consecutive=1%
      \expandafter\ifx\csname r@\@beginref\endcsname\relax%
        \@cref@refconsecutivefalse%
      \else%
        \ifx\@nextref\@empty%
          \@cref@refconsecutivefalse%
          \@whilesw\ifx\@nextref\@empty\fi{%
            \cref@stack@pop{\@refsubstack}%
            \cref@isstackempty{\@refsubstack}%
            \if@cref@stackempty%
              \let\@nextref\relax%
            \else%
              \edef\@nextref{\cref@stack@top{\@refsubstack}}%
            \fi%
          }%
          \ifnum\count@consecutive=2%
            \edef\@endref{\@endref,}%
          \fi%
        \else%
          \expandafter\ifx\csname r@\@nextref\endcsname\relax%
            \@cref@refconsecutivefalse%
          \else%
            \edef\@tmpa{{\@beginref}{\@nextref}}%
            \expandafter\cref@isrefconsecutive\@tmpa%
          \fi%
        \fi%
      \fi%
      \@whilesw\if@cref@refconsecutive\fi{%
        \advance\count@consecutive 1%
        \let\@endref\@nextref%
        \cref@stack@pop{\@refsubstack}%
        \cref@isstackempty{\@refsubstack}%
        \if@cref@stackempty%
          \@cref@refconsecutivefalse%
        \else%
          \edef\@nextref{\cref@stack@top{\@refsubstack}}%
          \ifx\@nextref\@empty%
            \@cref@refconsecutivefalse%
            \@whilesw\ifx\@nextref\@empty\fi{%
              \cref@stack@pop{\@refsubstack}%
              \cref@isstackempty{\@refsubstack}%
              \if@cref@stackempty%
                \let\@nextref\relax%
              \else%
                \edef\@nextref{\cref@stack@top{\@refsubstack}}%
              \fi%
            }%
            \ifnum\count@consecutive=2%
              \edef\@endref{\@endref,}%
            \fi%
          \else%
            \expandafter\ifx\csname r@\@nextref\endcsname\relax%
              \@cref@refconsecutivefalse%
            \else%
              \edef\@tmpa{{\@endref}{\@nextref}}%
              \expandafter\cref@isrefconsecutive\@tmpa%
            \fi%
          \fi%
        \fi}%
      \ifx\@endref\relax%
        \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
      \else%
        \ifnum\count@consecutive=2%
          \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
          \expandafter\cref@stack@push\expandafter%
            {\@endref}{\@refsubstack}%
        \else%
          \edef\@tmpa{{\@beginref}{\@endref}}%
          \if@cref@stackempty%
            \expandafter\@setcrefrange\@tmpa{#1}{}%
          \else%
            \expandafter\@setcrefrange\@tmpa{#1}{@first}%
          \fi%
        \fi%
      \fi%
      \@secondreftrue%
      \cref@isstackfull{\@refsubstack}%
      \@whilesw\if@cref@stackfull\fi{%
        \edef\@beginref{\cref@stack@top{\@refsubstack}}%
        \cref@stack@pop{\@refsubstack}%
        \let\@endref\relax%
        \cref@isstackempty{\@refsubstack}%
        \if@cref@stackempty%
          \if@secondref%
            \expandafter\@setcref\expandafter{\@beginref}{#1}{@second}%
          \else%
            \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
          \fi%
        \else%
          \edef\@nextref{\cref@stack@top{\@refsubstack}}%
          \count@consecutive=1%
          \ifx\@nextref\@empty%
            \@cref@refconsecutivefalse%
            \@whilesw\ifx\@nextref\@empty\fi{%
              \cref@stack@pop{\@refsubstack}%
              \cref@isstackempty{\@refsubstack}%
              \if@cref@stackempty%
                \let\@nextref\relax%
              \else%
                \edef\@nextref{\cref@stack@top{\@refsubstack}}%
              \fi%
            }%
            \ifnum\count@consecutive=2%
              \edef\@endref{\@endref,}%
            \fi%
          \else%
            \expandafter\ifx\csname r@\@nextref\endcsname\relax%
              \@cref@refconsecutivefalse%
            \else%
              \edef\@tmpa{{\@beginref}{\@nextref}}%
              \expandafter\cref@isrefconsecutive\@tmpa%
            \fi%
          \fi%
          \@whilesw\if@cref@refconsecutive\fi{%
            \advance\count@consecutive 1%
            \let\@endref\@nextref%
            \cref@stack@pop{\@refsubstack}%
            \cref@isstackempty{\@refsubstack}%
            \if@cref@stackempty%
              \@cref@refconsecutivefalse%
            \else%
              \edef\@nextref{\cref@stack@top{\@refsubstack}}%
              \ifx\@nextref\@empty%
              \@cref@refconsecutivefalse%
              \@whilesw\ifx\@nextref\@empty\fi{%
                \cref@stack@pop{\@refsubstack}%
                \cref@isstackempty{\@refsubstack}%
                \if@cref@stackempty%
                  \let\@nextref\relax%
                \else%
                  \edef\@nextref{\cref@stack@top{\@refsubstack}}%
                \fi%
              }%
              \ifnum\count@consecutive=2%
                \edef\@endref{\@endref,}%
              \fi%
              \else%
                \expandafter\ifx\csname r@\@nextref\endcsname\relax%
                  \@cref@refconsecutivefalse%
                \else%
                  \edef\@tmpa{{\@endref}{\@nextref}}%
                  \expandafter\cref@isrefconsecutive\@tmpa%
                \fi%
              \fi%
            \fi}%
          \cref@isstackempty{\@refsubstack}%
          \if@cref@stackempty%
            \if@secondref%
              \def\@pos{@second}%
            \else%
              \def\@pos{@last}%
            \fi%
          \else%
            \def\@pos{@middle}%
          \fi%
          \ifx\@endref\relax%
            \edef\@tmpa{{\@beginref}{#1}{\@pos}}%
            \expandafter\@setcref\@tmpa%
          \else%
            \ifnum\count@consecutive=2%
              \expandafter\@setcref\expandafter%
                {\@beginref}{#1}{@middle}%
              \expandafter\cref@stack@push\expandafter%
                {\@endref}{\@refsubstack}%
            \else%
              \edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
              \expandafter\@setcrefrange\@tmpa%
            \fi%
          \fi%
        \fi%
        \@secondreffalse%
        \cref@isstackfull{\@refsubstack}%
      }% end loop over reference substack
    \fi%
    \cref@isstackfull{\@refstack}%
  }% end loop over main reference stack
  \endgroup}
\def\@setcref#1#2#3{%
  \expandafter\ifx\csname r@#1\endcsname\relax%
    \protect\G@refundefinedtrue%
    \nfss@text{\reset@font\bfseries ??}%
    \@latex@warning{Reference `#1' on page \thepage \space undefined}%
  \else%
    \cref@gettype{#1}{\@temptype}%  puts label type in \@temptype
    \cref@getlabel{#1}{\@templabel}%  puts label in \@templabel
    \expandafter\ifx\csname #2@\@temptype @format#3\endcsname\relax%
      \protect\G@refundefinedtrue%
      \nfss@text{\reset@font\bfseries ??}~\@templabel%
      \@latex@warning{\string\Cref \space reference format for label
        type `\@temptype' undefined}%
    \else%
      \expandafter\@@setcref\expandafter%
        {\csname #2@\@temptype @format#3\endcsname}{#1}%
    \fi%
  \fi}
\def\@@setcref#1#2{\cref@getlabel{#2}{\@templabel}#1{\@templabel}{}{}}
\newif\if@cref@refconsecutive%
\def\cref@isrefconsecutive#1#2{%
  \begingroup%
    \countdef\refa@counter=1%
    \countdef\refb@counter=2%
    \cref@getcounter{#1}{\@result}%
    \refa@counter=\@result%
    \advance\refa@counter 1%
    \cref@getcounter{#2}{\@result}%
    \refb@counter=\@result%
    \cref@getprefix{#1}{\refa@prefix}%
    \cref@getprefix{#2}{\refb@prefix}%
    \def\@after{\@cref@refconsecutivefalse}%
    \ifx\refa@prefix\refb@prefix%
      \ifnum\refa@counter=\refb@counter%
        \def\@after{\@cref@refconsecutivetrue}%
      \fi%
    \fi%
  \expandafter\endgroup\@after}
\def\@setcrefrange#1#2#3#4{%
  \begingroup%
    \expandafter\ifx\csname r@#1\endcsname\relax%
      \protect\G@refundefinedtrue%
      \@latex@warning{Reference `#1' on page \thepage \space%
        undefined}%
      \expandafter\ifx\csname r@#2\endcsname\relax%
        \nfss@text{\reset@font\bfseries ??}--%
        \nfss@text{\reset@font\bfseries ??}%
        \@latex@warning{Reference `#2' on page \thepage \space%
          undefined}%
      \else%
        \cref@getlabel{#2}{\@labelb}%
        \nfss@text{\reset@font\bfseries ??}--\@labelb%
      \fi%
    \else%
      \expandafter\ifx\csname r@#2\endcsname\relax%
        \protect\G@refundefinedtrue%
        \cref@getlabel{#1}{\@labela}%
        \@labela--\nfss@text{\reset@font\bfseries ??}%
        \@latex@warning{Reference `#2' on page \thepage \space undefined}%
      \else%
        \cref@gettype{#1}{\@typea}%
        \cref@gettype{#2}{\@typeb}%
        \cref@getlabel{#1}{\@labela}%
        \cref@getlabel{#2}{\@labelb}%
        \edef\@formata{\expandafter\noexpand%
          \csname #3range@\@typea @format#4\endcsname}%
        \edef\@formatb{\expandafter\noexpand%
          \csname #3range@\@typeb @format#4\endcsname}%
        \expandafter\ifx\@formata\relax%
          \protect\G@refundefinedtrue%
          \nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb%
          \@latex@warning{#3\space reference range format for label
            type `\@typea' undefined}%
        \else%
          \ifx\formata\formatb%
            \expandafter\@@setcrefrange\expandafter{\@formata}{#1}{#2}%
          \else%
            \protect\G@refundefinedtrue%
            \nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb%
            \@latex@warning{Types inconsistent in reference range for
              references `#1' and `#2' on page \thepage}%
          \fi%
        \fi%
      \fi%
    \fi%
  \endgroup}
\def\@@setcrefrange#1#2#3{%
  \cref@getlabel{#2}{\@labela}%
  \cref@getlabel{#3}{\@labelb}%
  #1{\@labela}{\@labelb}{}{}{}{}}
\def\@setcref@pairgroupconjunction{\crefpairgroupconjunction}
\def\@setcref@middlegroupconjunction{\crefmiddlegroupconjunction}
\def\@setcref@lastgroupconjunction{\creflastgroupconjunction}
\newcommand{\crefdefaultlabelformat}[1]{%
  \def\cref@default@label##1##2##3{#1}}
\newcommand{\crefname}[3]{%
  \@crefname{cref}{#1}{#2}{#3}%
  \@crefdefineallformats{#1}}
\newcommand{\Crefname}[3]{%
  \@crefname{Cref}{#1}{#2}{#3}%
  \@crefdefineallformats{#1}}
\newcommand{\creflabelformat}[2]{%
  \@creflabelformat{#1}{#2}%
  \@crefdefineallformats{#1}}
\newcommand{\crefrangelabelformat}[2]{%
  \@crefrangelabelformat{#1}{#2}%
  \@crefdefineallformats{#1}}
\def\@creflabelformat#1#2{%
  \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}}
\def\@crefrangelabelformat#1#2{%
  \expandafter\def\csname cref@#1@rangelabel\endcsname%
  ##1##2##3##4##5##6{#2}}
\def\@crefname#1#2#3#4{%
  \begingroup%
    \expandafter\gdef\csname #1@#2@name\endcsname{#3}%
    \expandafter\gdef\csname #1@#2@name@plural\endcsname{#4}%
    \def\@tmpa##1##2\@nil{%
      \if##1c%
        \def\@other{C##2}%
        \def\@changecase{\MakeUppercase}%
      \else%
        \def\@other{c##2}%
        \def\@changecase{\MakeLowercase}%
      \fi}%
    \@tmpa#1\@nil%
    \@ifundefined{\@other @#2@name}{%
      \expandafter\expandafter\expandafter\def%
      \expandafter\expandafter\expandafter\@tmpa%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@name\endcsname}%
      \expandafter\expandafter\expandafter\def%
      \expandafter\expandafter\expandafter\@tmpb%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@name@plural\endcsname}%
      \expandafter\expandafter\expandafter\def%
      \expandafter\expandafter\expandafter\@tmpa%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpa}%
      \expandafter\expandafter\expandafter\def%
      \expandafter\expandafter\expandafter\@tmpb%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpb}%
      \toksdef\@toksa=0%
      \@toksa={%
        \expandafter\gdef\csname\@other @#2@name\endcsname}%
      \expandafter\the\expandafter\@toksa\expandafter{\@tmpa}%
      \@toksa={%
        \expandafter\gdef\csname\@other @#2@name@plural\endcsname}%
      \expandafter\the\expandafter\@toksa\expandafter{\@tmpb}%
    }{}%
  \endgroup}
\def\@crefconstructcomponents#1{%
  \@ifundefined{cref@#1@label}{%
    \let\@tmplabel\cref@default@label%
  }{%
    \expandafter\let\expandafter\@tmplabel%
    \csname cref@#1@label\endcsname%
  }%
  \@ifundefined{cref@#1@rangelabel}{%
    \expandafter\def\expandafter\@tmpa\expandafter{%
      \@tmplabel{####1}{####3}{####4}}%
    \expandafter\def\expandafter\@tmpb\expandafter{%
      \@tmplabel{####2}{####5}{####6}}%
    \toksdef\@toksa=0%
    \@toksa={\def\@tmprangelabel##1##2##3##4##5##6}%
    \expandafter\expandafter\expandafter\expandafter%
    \expandafter\expandafter\expandafter\the%
    \expandafter\expandafter\expandafter\expandafter%
    \expandafter\expandafter\expandafter\@toksa%
    \expandafter\expandafter\expandafter\expandafter%
    \expandafter\expandafter\expandafter{%
      \expandafter\expandafter\expandafter\@tmpa%
      \expandafter\crefrangeconjunction\@tmpb}%
  }{%
    \expandafter\let\expandafter\@tmprangelabel%
    \csname cref@#1@rangelabel\endcsname%
  }%
  \expandafter\expandafter\expandafter\def%
  \expandafter\expandafter\expandafter\@tmpname%
  \expandafter\expandafter\expandafter{%
    \csname cref@#1@name\endcsname}%
  \expandafter\expandafter\expandafter\def%
  \expandafter\expandafter\expandafter\@tmpName%
  \expandafter\expandafter\expandafter{%
    \csname Cref@#1@name\endcsname}%
  \expandafter\expandafter\expandafter\def%
  \expandafter\expandafter\expandafter\@tmpnameplural%
  \expandafter\expandafter\expandafter{%
    \csname cref@#1@name@plural\endcsname}%
  \expandafter\expandafter\expandafter\def%
  \expandafter\expandafter\expandafter\@tmpNameplural%
  \expandafter\expandafter\expandafter{%
    \csname Cref@#1@name@plural\endcsname}%
  \expandafter\def\expandafter\@tmplabel\expandafter{%
    \@tmplabel{########1}{########2}{########3}}%
  \expandafter\def\expandafter\@tmprangelabel\expandafter{%
    \@tmprangelabel{########1}{########2}{########3}%
    {########4}{########5}{########6}}%
}
\def\@crefdefineformat#1{%
  \begingroup%
    \@crefconstructcomponents{#1}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpfirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpname\expandafter~\@tmplabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpFirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpName\expandafter~\@tmplabel}%
    \toksdef\@toksa=0%
    \@toksa={\crefformat{#1}}%
    \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
    \@toksa={\Crefformat{#1}}%
    \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
  \endgroup}
\def\@crefrangedefineformat#1{%
  \begingroup%
    \@crefconstructcomponents{#1}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpfirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpFirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
    \toksdef\@toksa=0%
    \@toksa={\crefrangeformat{#1}}%
    \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
    \@toksa={\Crefrangeformat{#1}}%
    \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
  \endgroup}
\def\@crefdefinemultiformat#1{%
  \begingroup%
    \@crefconstructcomponents{#1}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpfirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpnameplural\expandafter~\@tmplabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpFirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpNameplural\expandafter~\@tmplabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpsecond%
    \expandafter\expandafter\expandafter{%
      \expandafter\crefpairconjunction\@tmplabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpmiddle%
    \expandafter\expandafter\expandafter{%
      \expandafter\crefmiddleconjunction\@tmplabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmplast%
    \expandafter\expandafter\expandafter{%
      \expandafter\creflastconjunction\@tmplabel}%
    \toksdef\@toksa=0%
    \toksdef\@toksb=1%
    \@toksb={}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpfirst}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpsecond}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpmiddle}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmplast}}%
    \@toksa={\crefmultiformat{#1}}%
    \expandafter\the\expandafter\@toksa\the\@toksb%
    \@toksb={}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpFirst}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpsecond}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpmiddle}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmplast}}%
    \@toksa={\Crefmultiformat{#1}}%
    \expandafter\the\expandafter\@toksa\the\@toksb%
  \endgroup}
\def\@crefrangedefinemultiformat#1{%
  \begingroup%
    \@crefconstructcomponents{#1}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpfirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpFirst%
    \expandafter\expandafter\expandafter{%
      \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpsecond%
    \expandafter\expandafter\expandafter{%
      \expandafter\crefpairconjunction\@tmprangelabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmpmiddle%
    \expandafter\expandafter\expandafter{%
      \expandafter\crefmiddleconjunction\@tmprangelabel}%
    \expandafter\expandafter\expandafter\def%
    \expandafter\expandafter\expandafter\@tmplast%
    \expandafter\expandafter\expandafter{%
      \expandafter\creflastconjunction\@tmprangelabel}%
    \toksdef\@toksa=0%
    \toksdef\@toksb=1%
    \@toksb={}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpfirst}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpsecond}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpmiddle}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmplast}}%
    \@toksa={\crefrangemultiformat{#1}}%
    \expandafter\the\expandafter\@toksa\the\@toksb%
    \@toksb={}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpFirst}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpsecond}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmpmiddle}}%
    \expandafter\cref@append@toks\expandafter\@toksb\expandafter{%
      \expandafter{\@tmplast}}%
    \@toksa={\Crefrangemultiformat{#1}}%
    \expandafter\the\expandafter\@toksa\the\@toksb%
  \endgroup}
\def\@crefdefineallformats#1{%
  \@crefdefineformat{#1}%
  \@crefrangedefineformat{#1}%
  \@crefdefinemultiformat{#1}%
  \@crefrangedefinemultiformat{#1}}
\newcommand{\crefformat}[2]{\@crefformat{cref}{#1}{#2}}
\newcommand{\Crefformat}[2]{\@crefformat{Cref}{#1}{#2}}
\newcommand{\crefrangeformat}[2]{\@crefrangeformat{crefrange}{#1}{#2}}
\newcommand{\Crefrangeformat}[2]{\@crefrangeformat{Crefrange}{#1}{#2}}
\newcommand{\crefmultiformat}[5]{%
  \@crefmultiformat{cref}{#1}{#2}{#3}{#4}{#5}}
\newcommand{\Crefmultiformat}[5]{%
  \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}{#5}}
\newcommand{\crefrangemultiformat}[5]{%
  \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}{#5}}
\newcommand{\Crefrangemultiformat}[5]{%
  \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}{#5}}
\def\@crefformat#1#2#3{%
  \begingroup%
    \expandafter\gdef\csname #1@#2@format\endcsname##1##2##3{#3}%
    \def\@tmpa##1##2\@nil{%
      \if##1c%
        \def\@other{C##2}%
        \def\@changecase{\MakeUppercase}%
      \else%
        \def\@other{c##2}%
        \def\@changecase{\MakeLowercase}%
      \fi}%
    \@tmpa#1\@nil%
    \@ifundefined{\@other @#2@format}{%
      \toksdef\@toksa=0%
      \@toksa={\def\@tmpa##1##2##3}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@format\endcsname{##1}{##2}{##3}}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
      \@toksa={%
        \expandafter\gdef\csname\@other @#2@format\endcsname##1##2##3}%
      \expandafter\the\expandafter\@toksa\expandafter{%
        \@tmpa{##1}{##2}{##3}}%
    }{}%
  \endgroup}
\def\@crefrangeformat#1#2#3{%
  \begingroup%
    \expandafter\gdef\csname #1@#2@format\endcsname%
      ##1##2##3##4##5##6{#3}%
    \def\@tmpa##1##2\@nil{%
      \if##1c%
        \def\@other{C##2}%
        \def\@changecase{\MakeUppercase}%
      \else%
        \def\@other{c##2}%
        \def\@changecase{\MakeLowercase}%
      \fi}%
    \@tmpa#1\@nil%
    \@ifundefined{\@other @#2@format}{%
      \toksdef\@toksa=0%
      \@toksa={\def\@tmpa##1##2##3##4##5##6}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@format\endcsname{##1}{##2}{##3}{##4}{##5}{##6}}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
      \@toksa={\expandafter\gdef%
        \csname\@other @#2@format\endcsname##1##2##3##4##5##6}%
      \expandafter\the\expandafter\@toksa\expandafter{%
        \@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
    }{}%
  \endgroup}
\def\@crefmultiformat#1#2#3#4#5#6{%
  \begingroup%
    \expandafter\gdef\csname #1@#2@format@first\endcsname##1##2##3{#3}%
    \expandafter\gdef\csname #1@#2@format@second\endcsname##1##2##3{#4}%
    \expandafter\gdef\csname #1@#2@format@middle\endcsname##1##2##3{#5}%
    \expandafter\gdef\csname #1@#2@format@last\endcsname##1##2##3{#6}%
    \def\@tmpa##1##2\@nil{%
      \if##1c%
        \def\@other{C##2}%
        \def\@changecase{\MakeUppercase}%
      \else%
        \def\@other{c##2}%
        \def\@changecase{\MakeLowercase}%
      \fi}%
    \@tmpa#1\@nil%
    \@ifundefined{\@other @#2@format@first}{%
      \toksdef\@toksa=0%
      \@toksa={\def\@tmpa##1##2##3}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@format@first\endcsname{##1}{##2}{##3}}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
      \@toksa={%
        \expandafter\gdef\csname\@other @#2@format@first\endcsname%
          ##1##2##3}%
      \expandafter\the\expandafter\@toksa\expandafter{%
        \@tmpa{##1}{##2}{##3}}%
    }{}%
    \@ifundefined{\@other @#2@format@second}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@second\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@second\endcsname%
    }{}%
    \@ifundefined{\@other @#2@format@middle}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@middle\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@middle\endcsname%
    }{}%
    \@ifundefined{\@other @#2@format@last}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@last\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@last\endcsname%
    }{}%
  \endgroup}
\def\@crefrangemultiformat#1#2#3#4#5#6{%
  \begingroup%
    \expandafter\gdef\csname #1@#2@format@first\endcsname%
      ##1##2##3##4##5##6{#3}%
    \expandafter\gdef\csname #1@#2@format@second\endcsname%
      ##1##2##3##4##5##6{#4}%
    \expandafter\gdef\csname #1@#2@format@middle\endcsname%
      ##1##2##3##4##5##6{#5}%
    \expandafter\gdef\csname #1@#2@format@last\endcsname%
      ##1##2##3##4##5##6{#6}%
    \def\@tmpa##1##2\@nil{%
      \if##1c%
        \def\@other{C##2}%
        \def\@changecase{\MakeUppercase}%
      \else%
        \def\@other{c##2}%
        \def\@changecase{\MakeLowercase}%
      \fi}%
    \@tmpa#1\@nil%
    \@ifundefined{\@other @#2@format@first}{%
      \toksdef\@toksa=0%
      \@toksa={\def\@tmpa##1##2##3##4##5##6}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \csname#1@#2@format@first\endcsname%
          {##1}{##2}{##3}{##4}{##5}{##6}}%
      \expandafter\expandafter\expandafter\the%
      \expandafter\expandafter\expandafter\@toksa%
      \expandafter\expandafter\expandafter{%
        \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
      \@toksa={%
        \expandafter\gdef\csname\@other @#2@format@first\endcsname%
          ##1##2##3##4##5##6}%
      \expandafter\the\expandafter\@toksa\expandafter{%
        \@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
    }{}%
    \@ifundefined{\@other @#2@format@second}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@second\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@second\endcsname%
    }{}%
    \@ifundefined{\@other @#2@format@middle}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@middle\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@middle\endcsname%
    }{}%
    \@ifundefined{\@other @#2@format@last}{%
      \@toksa={%
        \expandafter\global\expandafter\let%
        \csname\@other @#2@format@last\endcsname}%
      \expandafter\the\expandafter\@toksa%
        \csname #1@#2@format@last\endcsname%
    }{}%
  \endgroup}
\newcommand{\crefrangeconjunction}{ to~}
\newcommand{\crefpairconjunction}{ and~}
\newcommand{\crefmiddleconjunction}{, }
\newcommand{\creflastconjunction}{ and~}
\crefdefaultlabelformat{#2#1#3}
\AtBeginDocument{%
  \@ifundefined{crefpairgroupconjunction}{%
    \let\crefpairgroupconjunction\crefpairconjunction}{}%
  \@ifundefined{crefmiddlegroupconjunction}{%
    \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
  \@ifundefined{creflastgroupconjunction}{%
    \def\@tmpa{ and~}%
    \ifx\creflastconjunction\@tmpa%
      \def\creflastgroupconjunction{, and~}%
    \else%
      \let\creflastgroupconjunction\creflastconjunction%
    \fi}{}%
  \@ifundefined{cref@equation@name}{%
    \@crefname{cref}{equation}{eq.}{eqs.}%
    \@crefname{Cref}{equation}{Equation}{Equations}}{}%
  \@ifundefined{cref@equation@label}{%
    \@creflabelformat{equation}{\textup{(#2#1#3)}}%
    \@ifundefined{cref@equation@rangelabel}{%
      \@crefrangelabelformat{equation}{%
        \textup{(#3#1#4)}--\textup{(#5#2#6)}}}{}}{}%
   \@ifundefined{cref@chapter@name}{%
     \@crefname{cref}{chapter}{chapter}{chapters}%
     \@crefname{Cref}{chapter}{Chapter}{Chapters}}{}%
  \@ifundefined{cref@section@name}{%
    \@crefname{cref}{section}{section}{sections}%
    \@crefname{Cref}{section}{Section}{Sections}}{}%
  \@ifundefined{cref@subsection@name}{%
    \@crefname{cref}{subsection}{section}{sections}%
    \@crefname{Cref}{subsection}{Section}{Sections}}{}%
  \@ifundefined{cref@subsubsection@name}{%
    \@crefname{cref}{subsubsection}{section}{sections}%
    \@crefname{Cref}{subsubsection}{Section}{Sections}}{}%
  \@ifundefined{cref@subsubsubsection@name}{%
    \@crefname{cref}{subsubsubsection}{section}{sections}%
    \@crefname{Cref}{subsubsubsection}{Section}{Sections}}{}%
  \@ifundefined{cref@appendix@name}{%
    \@crefname{cref}{appendix}{appendix}{appendices}%
    \@crefname{Cref}{appendix}{Appendix}{Appendices}}{}%
  \@ifundefined{cref@figure@name}{%
    \@crefname{cref}{figure}{fig.}{figs.}%
    \@crefname{Cref}{figure}{Figure}{Figures}}{}%
  \@ifundefined{cref@figure@rangelabel}{%
    \@crefrangelabelformat{figure}{#3#1#4--#5#2#6}}{}%
  \@ifundefined{cref@table@name}{%
    \@crefname{cref}{table}{table}{tables}%
    \@crefname{Cref}{table}{Table}{Tables}}{}%
  \@ifundefined{cref@theorem@name}{%
    \@crefname{cref}{theorem}{theorem}{theorems}%
    \@crefname{Cref}{theorem}{Theorem}{Theorems}}{}%
  \@ifundefined{cref@enumi@name}{%
    \@crefname{cref}{enumi}{item}{items}%
    \@crefname{Cref}{enumi}{Item}{Items}}{}%
  \@ifundefined{cref@enumii@name}{%
    \@crefname{cref}{enumii}{item}{items}%
    \@crefname{Cref}{enumii}{Item}{Items}}{}%
  \@ifundefined{cref@enumiii@name}{%
    \@crefname{cref}{enumiii}{item}{items}%
    \@crefname{Cref}{enumiii}{Item}{Items}}{}%
  \@ifundefined{cref@enumiv@name}{%
    \@crefname{cref}{enumiv}{item}{items}%
    \@crefname{Cref}{enumiv}{Item}{Items}}{}%
  \@ifundefined{cref@enumv@name}{%
    \@crefname{cref}{enumv}{item}{items}%
    \@crefname{Cref}{enumv}{Item}{Items}}{}%
  \@ifundefined{cref@equation@format}{%
    \@crefdefineformat{equation}}{}%
  \@ifundefined{crefrange@equation@format}{%
    \@crefrangedefineformat{equation}}{}%
  \@ifundefined{cref@equation@format@first}{%
    \@crefdefinemultiformat{equation}}{}%
  \@ifundefined{crefrange@equation@format@first}{%
    \@crefrangedefinemultiformat{equation}}{}%
  \@ifundefined{cref@chapter@format}{%
    \@crefdefineformat{chapter}}{}%
  \@ifundefined{crefrange@chapter@format}{%
    \@crefrangedefineformat{chapter}}{}%
  \@ifundefined{cref@chapter@format@first}{%
    \@crefdefinemultiformat{chapter}}{}%
  \@ifundefined{crefrange@chapter@format@first}{%
    \@crefrangedefinemultiformat{chapter}}{}%
  \@ifundefined{cref@section@format}{%
    \@crefdefineformat{section}}{}%
  \@ifundefined{crefrange@section@format}{%
    \@crefrangedefineformat{section}}{}%
  \@ifundefined{cref@section@format@first}{%
    \@crefdefinemultiformat{section}}{}%
  \@ifundefined{crefrange@section@format@first}{%
    \@crefrangedefinemultiformat{section}}{}%
  \@ifundefined{cref@subsection@format}{%
    \@crefdefineformat{subsection}}{}%
  \@ifundefined{crefrange@subsection@format}{%
    \@crefrangedefineformat{subsection}}{}%
  \@ifundefined{cref@subsection@format@first}{%
    \@crefdefinemultiformat{subsection}}{}%
  \@ifundefined{crefrange@subsection@format@first}{%
    \@crefrangedefinemultiformat{subsection}}{}%
  \@ifundefined{cref@subsubsection@format}{%
    \@crefdefineformat{subsubsection}}{}%
  \@ifundefined{crefrange@subsubsection@format}{%
    \@crefrangedefineformat{subsubsection}}{}%
  \@ifundefined{cref@subsubsection@format@first}{%
    \@crefdefinemultiformat{subsubsection}}{}%
  \@ifundefined{crefrange@subsubsection@format@first}{%
    \@crefrangedefinemultiformat{subsubsection}}{}%
  \@ifundefined{cref@subsubsubsection@format}{%
    \@crefdefineformat{subsubsubsection}}{}%
  \@ifundefined{crefrange@subsubsubsection@format}{%
    \@crefrangedefineformat{subsubsubsection}}{}%
  \@ifundefined{cref@subsubsubsection@format@first}{%
    \@crefdefinemultiformat{subsubsubsection}}{}%
  \@ifundefined{crefrange@subsubsubsection@format@first}{%
    \@crefrangedefinemultiformat{subsubsubsection}}{}%
  \@ifundefined{cref@appendix@format}{%
    \@crefdefineformat{appendix}}{}%
  \@ifundefined{crefrange@appendix@format}{%
    \@crefrangedefineformat{appendix}}{}%
  \@ifundefined{cref@appendix@format@first}{%
    \@crefdefinemultiformat{appendix}}{}%
  \@ifundefined{crefrange@appendix@format@first}{%
    \@crefrangedefinemultiformat{appendix}}{}%
  \@ifundefined{cref@figure@format}{%
    \@crefdefineformat{figure}}{}%
  \@ifundefined{crefrange@figure@format}{%
    \@crefrangedefineformat{figure}}{}%
  \@ifundefined{cref@figure@format@first}{%
    \@crefdefinemultiformat{figure}}{}%
  \@ifundefined{crefrange@figure@format@first}{%
    \@crefrangedefinemultiformat{figure}}{}%
  \@ifundefined{cref@table@format}{%
    \@crefdefineformat{table}}{}%
  \@ifundefined{crefrange@table@format}{%
    \@crefrangedefineformat{table}}{}%
  \@ifundefined{cref@table@format@first}{%
    \@crefdefinemultiformat{table}}{}%
  \@ifundefined{crefrange@table@format@first}{%
    \@crefrangedefinemultiformat{table}}{}%
  \@ifundefined{cref@theorem@format}{%
    \@crefdefineformat{theorem}}{}%
  \@ifundefined{crefrange@theorem@format}{%
    \@crefrangedefineformat{theorem}}{}%
  \@ifundefined{cref@theorem@format@first}{%
    \@crefdefinemultiformat{theorem}}{}%
  \@ifundefined{crefrange@theorem@format@first}{%
    \@crefrangedefinemultiformat{theorem}}{}%
  \@ifundefined{cref@enumi@format}{%
    \@crefdefineformat{enumi}}{}%
  \@ifundefined{crefrange@enumi@format}{%
    \@crefrangedefineformat{enumi}}{}%
  \@ifundefined{cref@enumi@format@first}{%
    \@crefdefinemultiformat{enumi}}{}%
  \@ifundefined{crefrange@enumi@format@first}{%
    \@crefrangedefinemultiformat{enumi}}{}%
  \@ifundefined{cref@enumii@format}{%
    \@crefdefineformat{enumii}}{}%
  \@ifundefined{crefrange@enumii@format}{%
    \@crefrangedefineformat{enumii}}{}%
  \@ifundefined{cref@enumii@format@first}{%
    \@crefdefinemultiformat{enumii}}{}%
  \@ifundefined{crefrange@enumii@format@first}{%
    \@crefrangedefinemultiformat{enumii}}{}%
  \@ifundefined{cref@enumiii@format}{%
    \@crefdefineformat{enumiii}}{}%
  \@ifundefined{crefrange@enumiii@format}{%
    \@crefrangedefineformat{enumiii}}{}%
  \@ifundefined{cref@enumiii@format@first}{%
    \@crefdefinemultiformat{enumiii}}{}%
  \@ifundefined{crefrange@enumiii@format@first}{%
    \@crefrangedefinemultiformat{enumiii}}{}%
  \@ifundefined{cref@enumiv@format}{%
    \@crefdefineformat{enumiv}}{}%
  \@ifundefined{crefrange@enumiv@format}{%
    \@crefrangedefineformat{enumiv}}{}%
  \@ifundefined{cref@enumiv@format@first}{%
    \@crefdefinemultiformat{enumiv}}{}%
  \@ifundefined{crefrange@enumiv@format@first}{%
    \@crefrangedefinemultiformat{enumiv}}{}%
  \@ifundefined{cref@enumiv@format}{%
    \@crefdefineformat{enumiv}}{}%
  \@ifundefined{crefrange@enumiv@format}{%
    \@crefrangedefineformat{enumiv}}{}%
  \@ifundefined{cref@enumiv@format@first}{%
    \@crefdefinemultiformat{enumiv}}{}%
  \@ifundefined{crefrange@enumiv@format@first}{%
    \@crefrangedefinemultiformat{enumiv}}{}%
}
\@ifpackageloaded{hyperref}{%
\PackageInfo{cleveref}{`hyperref' support loaded}
\@ifpackagewith{hyperref}{backref}{%
  \PackageError{cleveref}{`cleveref' is currently incompatible with
    `hyperref's `backref' option}{Remove the `backref' option from
    `hyperref' if you want to use `cleveref'}}{}
\def\cref@reflabel#1#2#3#4#5{\@result}
\def\cref@hyperref#1{\expandafter\expandafter\expandafter%
  \@fourthoffive\csname r@#1\endcsname}
\def\cref@getlabel#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoffive\@tmpa}%
  \expandafter\@cref@getlabel\@tmpa\@nil#2}
\def\cref@gettype#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoffive\@tmpa}%
  \expandafter\@cref@gettype\@tmpa\@nil#2}
\def\cref@getcounter#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoffive\@tmpa}%
  \expandafter\@cref@getcounter\@tmpa\@nil#2}
\def\cref@getprefix#1#2{%
  \expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
  \edef\@tmpa{\expandafter\@firstoffive\@tmpa}%
  \expandafter\@cref@getprefix\@tmpa\@nil#2}
\def\H@refstepcounter#1{%
  \stepcounter{#1}%
  \cref@resetby{#1}{\@result}%
  \ifx\@result\relax\def\@result{}%
  \else\edef\@result{\csname the\@result\endcsname}\fi%
  \protected@edef\@currentlabel{%
    [#1][\arabic{#1}][\@result]%
    \csname p@#1\endcsname\csname the#1\endcsname}}
\def\refstepcounter@noarg#1{\cref@old@refstepcounter{#1}%
}
\def\refstepcounter@optarg[#1]#2{%
  \cref@old@refstepcounter{#2}%
  \expandafter\@cref@getlabel\@currentlabel\@nil{\@tmplabel}%
  \cref@resetby{#2}{\@tmpreset}%
  \ifx\@tmpreset\relax\def\@tmpreset{}%
  \else\edef\@tmpreset{\csname the\@tmpreset\endcsname}\fi%
  \protected@edef\@currentlabel{%
    [#1][\arabic{#2}][\@tmpreset]\@tmplabel}}
\renewcommand\appendix{%
  \cref@old@appendix%
  \@ifundefined{chapter}{%
    \def\H@refstepcounter##1{%
      \stepcounter{##1}%
      \cref@resetby{##1}{\@result}%
      \ifx\@result\relax\def\@result{}%
      \else\edef\@result{\csname the\@result\endcsname}\fi%
      \def\@tmpa{##1}%
      \def\@tmpb{section}%
      \ifx\@tmpa\@tmpb%
        \protected@edef\@currentlabel{%
          [appendix][\arabic{##1}][\@result]%
          \csname p@##1\endcsname\csname the##1\endcsname}%
      \else%
        \protected@edef\@currentlabel{%
          [##1][\arabic{##1}][\@result]%
          \csname p@##1\endcsname\csname the##1\endcsname}%
      \fi}%
  }{%
    \def\H@refstepcounter##1{%
      \stepcounter{##1}%
      \cref@resetby{##1}{\@result}%
      \ifx\@result\relax\def\@result{}%
      \else\edef\@result{\csname the\@result\endcsname}\fi%
      \def\@tmpa{##1}%
      \def\@tmpb{chapter}%
      \ifx\@tmpa\@tmpb%
        \protected@edef\@currentlabel{%
          [appendix][\arabic{##1}][\@result]%
          \csname p@##1\endcsname\csname the##1\endcsname}%
      \else%
        \protected@edef\@currentlabel{%
          [##1][\arabic{##1}][\@result]%
          \csname p@##1\endcsname\csname the##1\endcsname}%
      \fi}%
  }%
}
\newif\if@crefstarred
\DeclareRobustCommand{\cref}{%
  \@ifstar{\@crefstar{cref}}{\@crefnostar{cref}}}
\DeclareRobustCommand{\Cref}{%
  \@ifstar{\@crefstar{Cref}}{\@crefnostar{Cref}}}
\DeclareRobustCommand{\crefrange}{%
  \@ifstar{\@crefrangestar{cref}}{\@crefrangenostar{cref}}}
\DeclareRobustCommand{\Crefrange}{%
  \@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}}
\def\@crefnostar#1#2{\@cref{#1}{#2}}
\def\@crefstar#1#2{%
  \@crefstarredtrue\@crefnostar{#1}{#2}\@crefstarredfalse}
\def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}}
\def\@crefrangestar#1#2#3{%
  \@crefstarredtrue\@crefrangenostar{#1}{#2}{#3}\@crefstarredfalse}
\def\@@setcref#1#2{%
  \cref@getlabel{#2}{\@tmplabel}%
  \if@crefstarred%
    #1{\@tmplabel}{}{}%
  \else%
    \edef\@tmplink{\cref@hyperref{#2}}%
    #1{\@tmplabel}{\hyper@linkstart{link}{\@tmplink}}{\hyper@linkend}%
  \fi}
\def\@@setcrefrange#1#2#3{%
  \cref@getlabel{#2}{\@labela}%
  \cref@getlabel{#3}{\@labelb}%
  \if@crefstarred%
    #1{\@labela}{\@labelb}{}{}{}{}%
  \else%
    \edef\@linka{\cref@hyperref{#2}}%
    \edef\@linkb{\cref@hyperref{#3}}%
    #1{\@labela}{\@labelb}%
      {\hyper@linkstart{link}{\@linka}}{\hyper@linkend}%
      {\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}%
  \fi}
}{}
\AtBeginDocument{%
 \DeclareRobustCommand{\ref}{\@ifstar\cref@refstar\cref@ref}
 \def\cref@refstar#1{%
   \expandafter\ifx\csname r@#1\endcsname\relax%
     \let\@result\relax%
   \else%
     \cref@getlabel{#1}{\@result}%
   \fi%
   \expandafter\real@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
}
\@ifpackageloaded{ntheorem}{%
\PackageInfo{cleveref}{`ntheorem' support loaded}
\@ifpackagewith{ntheorem}{thref}{%
  \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref'
    option}%
  \renewcommand{\thref}{\cref}}{}
\@ifundefined{theorem@prework}{\let\theorem@prework\relax}{}
\gdef\@thm#1#2#3{%
   \if@thmmarks%
     \stepcounter{end\InTheoType ctr}%
   \fi%
   \renewcommand{\InTheoType}{#1}%
   \if@thmmarks%
     \stepcounter{curr#1ctr}%
     \setcounter{end#1ctr}{0}%
   \fi%
   \refstepcounter[#1]{#2}%  <<<<<
   \theorem@prework%
   \thm@topsepadd \theorempostskipamount%
   \ifvmode \advance\thm@topsepadd\partopsep\fi%
   \trivlist%
   \@topsep \theorempreskipamount%
   \@topsepadd \thm@topsepadd%
   \advance\linewidth -\theorem@indent%
   \advance\@totalleftmargin \theorem@indent%
   \parshape \@ne \@totalleftmargin \linewidth%
   \@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}%]
 }
\AtBeginDocument{%
  \@ifundefined{cref@lemma@name}{%
    \@crefname{cref}{lemma}{lemma}{lemmas}%
    \@crefname{Cref}{lemma}{Lemma}{Lemmas}}{}%
  \@ifundefined{cref@corollary@name}{%
    \@crefname{cref}{corollary}{corollary}{corollaries}%
    \@crefname{Cref}{corollary}{Corollary}{Corollaries}}{}%
  \@ifundefined{cref@proposition@name}{%
    \@crefname{cref}{proposition}{proposition}{propositions}%
    \@crefname{Cref}{proposition}{Proposition}{Proposition}}{}%
  \@ifundefined{cref@definition@name}{%
    \@crefname{cref}{definition}{definition}{definitions}%
    \@crefname{Cref}{definition}{Definition}{Definitions}}{}%
  \@ifundefined{cref@result@name}{%
    \@crefname{cref}{result}{result}{results}%
    \@crefname{cref}{result}{Result}{Results}}{}%
  \@ifundefined{cref@lemma@format}{%
    \@crefdefineformat{lemma}}{}%
  \@ifundefined{crefrange@lemma@format}{%
    \@crefrangedefineformat{lemma}}{}%
  \@ifundefined{cref@lemma@format@first}{%
    \@crefdefinemultiformat{lemma}}{}%
  \@ifundefined{crefrange@lemma@format@first}{%
    \@crefrangedefinemultiformat{lemma}}{}%
  \@ifundefined{cref@corollary@format}{%
    \@crefdefineformat{corollary}}{}%
  \@ifundefined{crefrange@corollary@format}{%
    \@crefrangedefineformat{corollary}}{}%
  \@ifundefined{cref@corollary@format@first}{%
    \@crefdefinemultiformat{corollary}}{}%
  \@ifundefined{crefrange@corollary@format@first}{%
    \@crefrangedefinemultiformat{corollary}}{}%
  \@ifundefined{cref@definition@format}{%
    \@crefdefineformat{definition}}{}%
  \@ifundefined{crefrange@definition@format}{%
    \@crefrangedefineformat{definition}}{}%
  \@ifundefined{cref@definition@format@first}{%
    \@crefdefinemultiformat{definition}}{}%
  \@ifundefined{crefrange@definition@format@first}{%
    \@crefrangedefinemultiformat{definition}}{}%
  \@ifundefined{cref@result@format}{%
    \@crefdefineformat{result}}{}%
  \@ifundefined{crefrange@result@format}{%
    \@crefrangedefineformat{result}}{}%
  \@ifundefined{cref@result@format@first}{%
    \@crefdefinemultiformat{result}}{}%
  \@ifundefined{crefrange@result@format@first}{%
    \@crefrangedefinemultiformat{result}}{}%
}%
}{}
\DeclareOption{poorman}{%
\PackageInfo{cleveref}{option `poorman' loaded}
\edef\cref@text{}
\AtBeginDocument{%
  \newwrite\@crefscript%
  \immediate\openout\@crefscript=\jobname.sed%
}
\AtEndDocument{%
  \immediate\closeout\@crefscript%
  \newread\@crefscript%
  \immediate\openin\@crefscript=\jobname.sed%
  \begingroup%
    \newif\if@not@eof%
    \def\@eof{\par }%
    \catcode`.=13 \catcode`[=13 \catcode`]=13
    \catcode`^=13 \catcode`$=13 %$
    \catcode`\=0 \catcode`<=1 \catcode`>=2
    \catcode`\\=13 \catcode`\{=12 \catcode`\}=12 \catcode`_=12
    \lccode`/=92
    \lccode`~=92\lowercase{\def~{\string/\string/}}%
    \lccode`~=46\lowercase{\def~{\string/\string.}}%
    \lccode`~=91\lowercase{\def~{\string/\string[}}%
    \lccode`~=93\lowercase{\def~{\string/\string]}}%
    \lccode`~=94\lowercase{\def~{\string/\string^}}%
    \lccode`~=36\lowercase{\def~{\string/\string$}}% $
    \lccode`~=0 \lccode`/=0 \catcode`~=12
    \def\cref@text{}%
    \immediate\read\@crefscript to \@tmpa%
    \ifx\@tmpa\@eof%
      \@not@eoffalse%
    \else%
      \@not@eoftrue%
      \edef\@tmpa{\@tmpa}%
    \fi%
    \@whilesw\if@not@eof\fi{%
      \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
        \@tmpa^^J}%
      \immediate\read\@crefscript to \@tmpa%
      \ifx\@tmpa\@eof%
        \@not@eoffalse%
      \else%
        \@not@eoftrue%
        \edef\@tmpa{\@tmpa}%
      \fi}%
  \endgroup%
  \immediate\closein\@crefscript%
  \begingroup%
    \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
    \lowercase{\edef\@tmpa{s/||usepackage|(|[.*|]|)|?<cleveref>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refname<.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]reflabelformat<.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||[cC]refdefaultlabelformat<.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||crefpairconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||creflastconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{%
        s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]ref><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
    \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}%
    \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
      \@tmpa^^J}%
  \endgroup%
  \newwrite\@crefscript%
  \immediate\openout\@crefscript=\jobname.sed%
  \immediate\write\@crefscript{\cref@text}%
  \immediate\closeout\@crefscript%
}
\@ifpackageloaded{hyperref}{%
  \def\@crefnostar#1#2{%
    \edef\cref@text{}%
    \@cref{#1}{#2}%
    \cref@writescript{%
      \expandafter\string\csname#1\endcsname\string{#2\string}}}
  \def\@crefrangenostar#1#2#3{%
    \edef\cref@text{}%
    \@setcrefrange{#2}{#3}{#1}{}%
    \cref@writescript{%
      \expandafter\string\csname#1range\endcsname%
      \string{#2\string}\string{#3\string}}}%
}{%
  \DeclareRobustCommand{\cref}[1]{%
    \edef\cref@text{}%
    \@cref{cref}{#1}%
    \cref@writescript{\string\cref\string{#1\string}}}
  \DeclareRobustCommand{\Cref}[1]{%
    \edef\cref@text{}%
    \@cref{Cref}{#1}%
    \cref@writescript{\string\Cref\string{#1\string}}}
  \DeclareRobustCommand{\crefrange}[2]{%
    \edef\cref@text{}%
    \@setcrefrange{#1}{#2}{cref}{}%
    \cref@writescript{%
      \string\crefrange\string{#1\string}\string{#2\string}}}
  \DeclareRobustCommand{\Crefrange}[2]{%
    \edef\cref@text{}%
    \@setcrefrange{#1}{#2}{Cref}{}%
    \cref@writescript{%
      \string\Crefrange\string{#1\string}\string{#2\string}}}%
}
\def\cref@writescript#1{%
  \edef\@tmpa{\cref@getmeaning{\cref@text}}%
  \immediate\write\@crefscript{s/#1/\@tmpa/g}}
\let\old@@setcref\@@setcref
\let\old@@setcrefrange\@@setcrefrange
\def\cref@getmeaning#1{\expandafter\@cref@getmeaning\meaning#1\@nil}
\def\@cref@getmeaning#1->#2\@nil{#2}
\def\@@setcref#1#2{%
  \old@@setcref{#1}{#2}%
  \expandafter\g@addto@macro\expandafter{%
    \expandafter\cref@text\expandafter}\expandafter{%
    #1{\ref{#2}}{}{}}}
\def\@@setcrefrange#1#2#3{%
  \old@@setcrefrange{#1}{#2}{#3}%
  \expandafter\g@addto@macro%
    \expandafter{\expandafter\cref@text\expandafter}%
    \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
\def\@setcref@pairgroupconjunction{%
  \crefpairgroupconjunction%
  \expandafter\g@addto@macro%
    \expandafter{\expandafter\cref@text\expandafter}%
    \expandafter{\crefpairgroupconjunction}}
\def\@setcref@middlegroupconjunction{%
  \crefmiddlegroupconjunction%
  \expandafter\g@addto@macro%
    \expandafter{\expandafter\cref@text\expandafter}%
    \expandafter{\crefmiddlegroupconjunction}}
\def\@setcref@lastgroupconjunction{%
  \creflastgroupconjunction%
  \expandafter\g@addto@macro%
    \expandafter{\expandafter\cref@text\expandafter}%
    \expandafter{\creflastgroupconjunction}}
} % end of poorman option
\ProcessOptions\relax
\endinput
%%
%% End of file `cleveref.sty'.
