diff options
author | Karl Berry <karl@freefriends.org> | 2007-11-03 23:59:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2007-11-03 23:59:08 +0000 |
commit | 971d67d195a21a89798b1204d3fc7b8553a631d9 (patch) | |
tree | e796443ba276081cef7eb6d8c1684885441eb51c /Master/texmf-dist/tex/latex/cleveref | |
parent | a335315e96e045d8d7fb154d641a61284234cbd7 (diff) |
cleveref update (1nov07)
git-svn-id: svn://tug.org/texlive/trunk@5329 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cleveref')
-rw-r--r-- | Master/texmf-dist/tex/latex/cleveref/cleveref.sty | 1123 |
1 files changed, 720 insertions, 403 deletions
diff --git a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty index 4568bca3429..71d7d2a4690 100644 --- a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty +++ b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty @@ -22,7 +22,7 @@ %% version 1999/12/01 or later. \NeedsTeXFormat{LaTeX2e}[1999/12/01] \ProvidesPackage{cleveref} - [2007/10/07 v0.8 Automatic cross-reference formatting] + [2007/30/10 v0.10 Automatic cross-reference formatting] %% \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 @@ -55,7 +55,25 @@ \else\edef\@result{\csname the\@result\endcsname}\fi% \protected@edef\@currentlabel{% [#1][\arabic{#2}][\@result]\@currentlabel}} -\def\cref@label#1#2{\@result} +\AtBeginDocument{% + \let\old@label\label + \def\label{\@ifnextchar[\label@optarg\old@label}%] + \def\override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4} + \def\label@optarg[#1]{% + \protected@edef\@currentlabel{% + \expandafter\override@label@type\@currentlabel\@nil{#1}}% + \old@label}% + \@ifpackageloaded{amsmath}{% + \let\cref@label\label% + \let\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{\old@label@in@display{{#1}}} + \def\label@in@display@optarg[#1]#2{\old@label@in@display{[#1]{#2}}} + \def\ltx@label#1{\cref@label#1}% + }{}% +} +\def\cref@reflabel#1#2{\@result} \AtBeginDocument{% \expandafter\def\csname ref \endcsname#1{% \expandafter\ifx\csname r@#1\endcsname\relax% @@ -63,8 +81,8 @@ \else% \cref@getlabel{#1}{\@result}% \fi% - \expandafter\@setref\csname r@#1\endcsname{\cref@label}{#1}}% - \def\ref{\expandafter\protect\csname ref \endcsname} + \expandafter\@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}% + \def\ref{\expandafter\protect\csname ref \endcsname}% } \def\cref@getlabel#1#2{% \expandafter\let\expandafter\@tempa\csname r@#1\endcsname% @@ -94,6 +112,9 @@ \def\@cref@getprefix{\@ifnextchar[%] \@@cref@getprefix{\@@cref@getprefix[][][]}} \def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}} +\def\append@toks#1#2{\toks0={#2}% + \edef\act{\noexpand#1={\the#1\the\toks0}}% + \act}% \def\stack@init#1{\def#1{\@nil}} \def\stack@top#1{\expandafter\stack@top@aux#1} \def\stack@top@aux#1,#2\@nil{#1} @@ -108,8 +129,7 @@ \def\isstackempty#1{% \def\@tmpa{\@nil}% \ifx#1\@tmpa\stackemptytrue% - \else\stackemptyfalse\fi -} + \else\stackemptyfalse\fi} \def\isstackfull#1{% \def\@tmpa{\@nil}% \ifx#1\@tmpa\stackfullfalse% @@ -181,9 +201,12 @@ \countdef\count@consecutive=0% \def\@empty{}% \newif\if@firstgroup% + \newif\if@secondgroup% + \newif\if@secondref% \stack@init{\@refstack}% \stack@push{#2}{\@refstack}% \@firstgrouptrue% + \@secondgroupfalse% \isstackfull{\@refstack}% \@whilesw\ifstackfull\fi{% \stack@init{\@refsubstack}% @@ -214,15 +237,21 @@ \fi% \fi}% \if@firstgroup% + \@firstgroupfalse% + \@secondgrouptrue% \else% \isstackfull{\@refstack}% \ifstackfull% - \@setcref@middleconjunction% + \@setcref@middlegroupconjunction% \else% - \@setcref@lastconjunction% + \if@secondgroup% + \@setcref@pairgroupconjunction% + \else% + \@setcref@lastgroupconjunction% + \fi% \fi% + \@secondgroupfalse% \fi% - \@firstgroupfalse% \edef\@nextref{\stack@top{\@refsubstack}}% \stack@pop{\@refsubstack}% \isstackempty{\@refsubstack}% @@ -250,7 +279,7 @@ \ifnum\count@consecutive=2% \edef\@endref{\@endref,}% \fi% - \else + \else% \expandafter\ifx\csname r@\@nextref\endcsname\relax% \refconsecutivefalse% \else% @@ -282,7 +311,7 @@ \ifnum\count@consecutive=2% \edef\@endref{\@endref,}% \fi% - \else + \else% \expandafter\ifx\csname r@\@nextref\endcsname\relax% \refconsecutivefalse% \else% @@ -297,7 +326,7 @@ \ifnum\count@consecutive=2% \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}% \expandafter\stack@push\expandafter{\@endref}{\@refsubstack}% - \else + \else% \edef\@tmpa{{\@beginref}{\@endref}}% \ifstackempty% \expandafter\@setcrefrange\@tmpa{#1}{}% @@ -306,6 +335,7 @@ \fi% \fi% \fi% + \@secondreftrue% \isstackfull{\@refsubstack}% \@whilesw\ifstackfull\fi{% \edef\@beginref{\stack@top{\@refsubstack}}% @@ -313,7 +343,11 @@ \let\@endref\relax% \isstackempty{\@refsubstack}% \ifstackempty% - \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}% + \if@secondref% + \expandafter\@setcref\expandafter{\@beginref}{#1}{@second}% + \else% + \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}% + \fi% \else% \edef\@nextref{\stack@top{\@refsubstack}}% \count@consecutive=1% @@ -331,7 +365,7 @@ \ifnum\count@consecutive=2% \edef\@endref{\@endref,}% \fi% - \else + \else% \expandafter\ifx\csname r@\@nextref\endcsname\relax% \refconsecutivefalse% \else% @@ -362,7 +396,7 @@ \ifnum\count@consecutive=2% \edef\@endref{\@endref,}% \fi% - \else + \else% \expandafter\ifx\csname r@\@nextref\endcsname\relax% \refconsecutivefalse% \else% @@ -373,7 +407,11 @@ \fi}% \isstackempty{\@refsubstack}% \ifstackempty% - \def\@pos{@last}% + \if@secondref% + \def\@pos{@second}% + \else% + \def\@pos{@last}% + \fi% \else% \def\@pos{@middle}% \fi% @@ -386,12 +424,13 @@ {\@beginref}{#1}{@middle}% \expandafter\stack@push\expandafter% {\@endref}{\@refsubstack}% - \else + \else% \edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}% \expandafter\@setcrefrange\@tmpa% \fi% \fi% \fi% + \@secondreffalse% \isstackfull{\@refsubstack}% }% end loop over reference substack \fi% @@ -466,7 +505,7 @@ \expandafter\ifx\@formata\relax% \protect\G@refundefinedtrue% \nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb% - \@latex@warning{#3 \space reference format for label + \@latex@warning{#3\space reference range format for label type `\@typea' undefined}% \else% \ifx\formata\formatb% @@ -484,39 +523,279 @@ \cref@getlabel{#2}{\@labela}% \cref@getlabel{#3}{\@labelb}% #1{\@labela}{\@labelb}{}{}{}{}} -\def\@setcref@middleconjunction{\crefmiddleconjunction} -\def\@setcref@lastconjunction{\creflastconjunction} +\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{% + \expandafter\def\csname #1@#2@name\endcsname{#3}% + \expandafter\def\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}% + \newtoks\@toksa% + \@toksa={% + \expandafter\def\csname\@other @#2@name\endcsname}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpa}% + \@toksa={% + \expandafter\def\csname\@other @#2@name@plural\endcsname}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpb}% + }{}% +} +\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}}% + \@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{% + \newtoks\@toksa% + \@crefconstructcomponents{#1}% puts format components into tmp macros + \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}% + \@toksa={\crefformat{#1}}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}% + \@toksa={\Crefformat{#1}}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}% +} +\def\@crefrangedefineformat#1{% + \newtoks\@toksa% + \newtoks\@toksb% + \@crefconstructcomponents{#1}% puts format components into tmp macros + \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}% + \@toksa={\crefrangeformat{#1}}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}% + \@toksa={\Crefrangeformat{#1}}% + \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}% +} +\def\@crefdefinemultiformat#1{% + \newtoks\@toksa% + \newtoks\@toksb% + \@crefconstructcomponents{#1}% puts format components into tmp macros + \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}% + \@toksb={}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpfirst}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpsecond}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpmiddle}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmplast}}% + \@toksa={\crefmultiformat{#1}}% + \expandafter\the\expandafter\@toksa\the\@toksb% + \@toksb={}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpFirst}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpsecond}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpmiddle}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmplast}}% + \@toksa={\Crefmultiformat{#1}}% + \expandafter\the\expandafter\@toksa\the\@toksb% +} +\def\@crefrangedefinemultiformat#1{% + \newtoks\@toksa% + \newtoks\@toksb% + \@crefconstructcomponents{#1}% puts format components into tmp macros + \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}% + \@toksb={}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpfirst}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpsecond}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpmiddle}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmplast}}% + \@toksa={\crefrangemultiformat{#1}}% + \expandafter\the\expandafter\@toksa\the\@toksb% + \@toksb={}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpFirst}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpsecond}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmpmiddle}}% + \expandafter\append@toks\expandafter\@toksb\expandafter{% + \expandafter{\@tmplast}}% + \@toksa={\Crefrangemultiformat{#1}}% + \expandafter\the\expandafter\@toksa\the\@toksb% +} +\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}[4]{% - \@crefmultiformat{cref}{#1}{#2}{#3}{#4}} -\newcommand{\Crefmultiformat}[4]{% - \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}} -\newcommand{\crefrangemultiformat}[4]{% - \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}} -\newcommand{\Crefrangemultiformat}[4]{% - \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}} +\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{% \expandafter\def\csname #1@#2@format\endcsname##1##2##3{#3}% \def\@tmpa##1##2\@nil{% - \if##1c \def\@other{C##2}% - \else\def\@other{c##2}\fi}% + \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}{% - \def\@tmpa##1##2\@nil{% - \if##1c\def\@changecase{\MakeUppercase}% - \else\def\@changecase{\Makelowercase}\fi}% - \@tmpa#1\@nil% \newtoks\@toksa% \@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\the\expandafter\@toksa\expandafter{% - \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}% + \expandafter\expandafter\expandafter\the% + \expandafter\expandafter\expandafter\@toksa% + \expandafter\expandafter\expandafter{% + \expandafter\@changecase\@tmpa{##1}{##2}{##3}}% \@toksa={% \expandafter\def\csname\@other @#2@format\endcsname##1##2##3}% \expandafter\the\expandafter\@toksa\expandafter{% @@ -527,55 +806,67 @@ \expandafter\def\csname #1@#2@format\endcsname% ##1##2##3##4##5##6{#3}% \def\@tmpa##1##2\@nil{% - \if##1c \def\@other{C##2}% - \else\def\@other{c##2}\fi}% + \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}{% - \def\@tmpa##1##2\@nil{% - \if##1c\def\@changecase{\MakeUppercase}% - \else\def\@changecase{\Makelowercase}\fi}% - \@tmpa#1\@nil% \newtoks\@toksa% \@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\the\expandafter\@toksa\expandafter{% - \expandafter\MakeUppercase\@tmpa{##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\def% \csname\@other @#2@format\endcsname##1##2##3##4##5##6}% \expandafter\the\expandafter\@toksa\expandafter{% \@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}% }{}% } -\def\@crefmultiformat#1#2#3#4#5{% +\def\@crefmultiformat#1#2#3#4#5#6{% \expandafter\def\csname #1@#2@format@first\endcsname##1##2##3{#3}% - \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#4}% - \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#5}% - \newtoks\@toksa% + \expandafter\def\csname #1@#2@format@second\endcsname##1##2##3{#4}% + \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#5}% + \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#6}% \def\@tmpa##1##2\@nil{% - \if##1c \def\@other{C##2}% - \else\def\@other{c##2}\fi}% + \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}{% - \def\@tmpa##1##2\@nil{% - \if##1c\def\@changecase{\MakeUppercase}% - \else\def\@changecase{\Makelowercase}\fi}% - \@tmpa#1\@nil% \@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\the\expandafter\@toksa\expandafter{% - \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}% + \expandafter\expandafter\expandafter\the% + \expandafter\expandafter\expandafter\@toksa% + \expandafter\expandafter\expandafter{% + \expandafter\@changecase\@tmpa{##1}{##2}{##3}}% \@toksa={% \expandafter\def\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\let\csname\@other @#2@format@second\endcsname}% + \expandafter\the\expandafter\@toksa% + \csname #1@#2@format@second\endcsname% + }{}% \@ifundefined{\@other @#2@format@middle}{% \@toksa={% \expandafter\let\csname\@other @#2@format@middle\endcsname}% @@ -589,36 +880,47 @@ \csname #1@#2@format@last\endcsname% }{}% } -\def\@crefrangemultiformat#1#2#3#4#5{% +\def\@crefrangemultiformat#1#2#3#4#5#6{% \expandafter\def\csname #1@#2@format@first\endcsname% ##1##2##3##4##5##6{#3}% - \expandafter\def\csname #1@#2@format@middle\endcsname% + \expandafter\def\csname #1@#2@format@second\endcsname% ##1##2##3##4##5##6{#4}% - \expandafter\def\csname #1@#2@format@last\endcsname% + \expandafter\def\csname #1@#2@format@middle\endcsname% ##1##2##3##4##5##6{#5}% + \expandafter\def\csname #1@#2@format@last\endcsname% + ##1##2##3##4##5##6{#6}% \def\@tmpa##1##2\@nil{% - \if##1c \def\@other{C##2}% - \else\def\@other{c##2}\fi}% + \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}{% - \def\@tmpa##1##2\@nil{% - \if##1c\def\@changecase{\MakeUppercase}% - \else\def\@changecase{\MakeLowercase}\fi}% - \@tmpa#1\@nil% \@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\the\expandafter\@toksa\expandafter{% - \expandafter\MakeUppercase\@tmpa{##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\def\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\let\csname\@other @#2@format@second\endcsname}% + \expandafter\the\expandafter\@toksa% + \csname #1@#2@format@second\endcsname% + }{}% \@ifundefined{\@other @#2@format@middle}{% \@toksa={% \expandafter\let\csname\@other @#2@format@middle\endcsname}% @@ -632,209 +934,184 @@ \csname #1@#2@format@last\endcsname% }{}% } -\crefformat{equation}{eq.~\textup{(#2#1#3)}} -\Crefformat{equation}{Equation~\textup{(#2#1#3)}} -\crefformat{chapter}{chapter~#2#1#3} -\Crefformat{chapter}{Chapter~#2#1#3} -\crefformat{section}{section~#2#1#3} -\Crefformat{section}{Section~#2#1#3} -\crefformat{subsection}{section~#2#1#3} -\Crefformat{subsection}{Section~#2#1#3} -\crefformat{subsubsection}{section~#2#1#3} -\Crefformat{subsubsection}{Section~#2#1#3} -\crefformat{subsubsubsection}{section~#2#1#3} -\Crefformat{subsubsubsection}{Section~#2#1#3} -\crefformat{figure}{fig.~#2#1#3} -\Crefformat{figure}{Figure~#2#1#3} -\crefformat{theorem}{theorem~#2#1#3} -\Crefformat{theorem}{Theorem~#2#1#3} -\crefformat{enumi}{item~#2#1#3} -\Crefformat{enumi}{Item~#2#1#3} -\crefformat{enumii}{item~#2#1#3} -\Crefformat{enumii}{Item~#2#1#3} -\crefformat{enumiii}{item~#2#1#3} -\Crefformat{enumiii}{Item~#2#1#3} -\crefformat{enumiv}{item~#2#1#3} -\Crefformat{enumiv}{Item~#2#1#3} -\crefmultiformat{equation}% - {eqs.~\textup{(#2#1#3)}}% - {, \textup{(#2#1#3)}}% - { and~\textup{(#2#1#3)}} -\Crefmultiformat{equation}% - {Equations~\textup{(#2#1#3)}}% - {, \textup{(#2#1#3)}}% - { and~\textup{(#2#1#3)}} -\crefmultiformat{chapter}% - {chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{chapter}% - {Chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{section}% - {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{section}% - {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{subsection}% - {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{subsection}% - {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{subsubsection}% - {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{subsubsection}% - {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{subsubsubsection}% - {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{subsubsubsection}% - {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{figure}% - {figs.~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{figure}% - {Figures~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{theorem}% - {theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{theorem}% - {Theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{enumi}% - {items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{enumi}% - {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{enumii}% - {items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{enumii}% - {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{enumiii}% - {items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{enumiii}% - {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{enumiv}% - {items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{enumiv}% - {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefrangeformat{equation}{% - eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}} -\Crefrangeformat{equation}{% - Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}} -\crefrangeformat{chapter}{chapters~#3#1#4--#5#2#6} -\Crefrangeformat{chapter}{Chapters~#3#1#4--#5#2#6} -\crefrangeformat{section}{sections~#3#1#4--#5#2#6} -\Crefrangeformat{section}{Sections~#3#1#4--#5#2#6} -\crefrangeformat{subsection}{sections~#3#1#4--#5#2#6} -\Crefrangeformat{subsection}{Sections~#3#1#4--#5#2#6} -\crefrangeformat{subsubsection}{sections~#3#1#4--#5#2#6} -\Crefrangeformat{subsubsection}{Sections~#3#1#4--#5#2#6} -\crefrangeformat{subsubsubsection}{sections~#3#1#4--#5#2#6} -\Crefrangeformat{subsubsubsection}{Sections~#3#1#4--#5#2#6} -\crefrangeformat{figure}{figs.~#3#1#4--#5#2#6} -\Crefrangeformat{figure}{Figures~#3#1#4--#5#2#6} -\crefrangeformat{theorem}{theorems~#3#1#4--#5#2#6} -\Crefrangeformat{theorem}{Theorems~#3#1#4--#5#2#6} -\crefrangeformat{enumi}{items~#3#1#4--#5#2#6} -\Crefrangeformat{enumi}{Items~#3#1#4--#5#2#6} -\crefrangeformat{enumii}{items~#3#1#4--#5#2#6} -\Crefrangeformat{enumii}{Items~#3#1#4--#5#2#6} -\crefrangeformat{enumiii}{items~#3#1#4--#5#2#6} -\Crefrangeformat{enumiii}{Items~#3#1#4--#5#2#6} -\crefrangeformat{enumiv}{items~#3#1#4--#5#2#6} -\Crefrangeformat{enumiv}{Items~#3#1#4--#5#2#6} -\crefrangemultiformat{equation}% - {eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}}% - {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}% - { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}} -\Crefrangemultiformat{equation}% - {Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}}% - {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}% - { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}} -\crefrangemultiformat{chapter}% - {chapters~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{chapter}% - {Chapters~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{section}% - {sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{section}% - {Sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{subsection}% - {sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{subsection}% - {Sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{subsubsection}% - {sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{subsubsection}% - {Sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{subsubsubsection}% - {sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{subsubsubsection}% - {Sections~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{figure}% - {figs.~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{figure}% - {Figures~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{theorem}% - {theorems~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{theorem}% - {Theorems~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{enumi}% - {items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{enumi}% - {Items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{enumii}% - {items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{enumii}% - {Items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{enumiii}% - {items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{enumiii}% - {Items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{enumiv}% - {items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{enumiv}% - {Items~#3#1#4--#5#2#6}% - {, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\def\crefmiddleconjunction{, } -\def\creflastconjunction{, and } -\DeclareOption{hyperref}{% -\PackageInfo{cleveref}{option `hyperref' loaded} -\def\cref@label#1#2#3#4#5{\@result} +\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@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@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@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{% @@ -842,15 +1119,15 @@ \edef\@tempa{\expandafter\@firstoffive\@tempa}% \expandafter\@cref@getlabel\@tempa\@nil#2} \def\cref@gettype#1#2{% - \expandafter\let\expandafter\@tempa\csname r@#1\endcsname + \expandafter\let\expandafter\@tempa\csname r@#1\endcsname% \edef\@tempa{\expandafter\@firstoffive\@tempa}% \expandafter\@cref@gettype\@tempa\@nil#2} \def\cref@getcounter#1#2{% - \expandafter\let\expandafter\@tempa\csname r@#1\endcsname + \expandafter\let\expandafter\@tempa\csname r@#1\endcsname% \edef\@tempa{\expandafter\@firstoffive\@tempa}% \expandafter\@cref@getcounter\@tempa\@nil#2} \def\cref@getprefix#1#2{% - \expandafter\let\expandafter\@tempa\csname r@#1\endcsname + \expandafter\let\expandafter\@tempa\csname r@#1\endcsname% \edef\@tempa{\expandafter\@firstoffive\@tempa}% \expandafter\@cref@getprefix\@tempa\@nil#2} \def\H@refstepcounter#1{% @@ -880,10 +1157,11 @@ \DeclareRobustCommand{\Crefrange}{% \@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}} \def\@crefnostar#1#2{\@cref{#1}{#2}} -\def\@crefstar#1#2{\@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse} +\def\@crefstar#1#2{% + \@crefstarredtrue\@crefnostar{#1}{#2}\@crefstarredfalse} \def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}} \def\@crefrangestar#1#2#3{% - \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse} + \@crefstarredtrue\@crefrangenostar{#1}{#2}{#3}\@crefstarredfalse} \def\@@setcref#1#2{% \cref@getlabel{#2}{\@templabel}% \if@crefstarred% @@ -904,100 +1182,85 @@ {\hyper@linkstart{link}{\@linka}}{\hyper@linkend}% {\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}% \fi} -} % end of hyperref option -\DeclareOption{ntheorem}{% -\PackageInfo{cleveref}{option `ntheorem' loaded} +}{} +\@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 + \if@thmmarks% \stepcounter{end\InTheoType ctr}% - \fi + \fi% \renewcommand{\InTheoType}{#1}% - \if@thmmarks + \if@thmmarks% \stepcounter{curr#1ctr}% \setcounter{end#1ctr}{0}% - \fi + \fi% \refstepcounter[#1]{#2}% <<<<< - \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 + \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}}%] } -\crefformat{lemma}{lemma~#2#1#3} -\Crefformat{lemma}{Lemma~#2#1#3} -\crefformat{corrollary}{corrollary~#2#1#3} -\Crefformat{corrollary}{Corrollary~#2#1#3} -\crefformat{proposition}{proposition~#2#1#3} -\Crefformat{proposition}{Proposition~#2#1#3} -\crefformat{definition}{definition~#2#1#3} -\Crefformat{definition}{Definition~#2#1#3} -\crefformat{result}{result~#2#1#3} -\Crefformat{result}{Result~#2#1#3} -\crefrangeformat{lemma}{lemma~#3#1#4--#5#2#6} -\Crefrangeformat{lemma}{Lemma~#3#1#4--#5#2#6} -\crefrangeformat{corrollary}{corrollary~#3#1#4--#5#2#6} -\Crefrangeformat{corrollary}{Corrollary~#3#1#4--#5#2#6} -\crefrangeformat{proposition}{proposition~#3#1#4--#5#2#6} -\Crefrangeformat{proposition}{Proposition~#3#1#4--#5#2#6} -\crefrangeformat{definition}{definition~#3#1#4--#5#2#6} -\Crefrangeformat{definition}{Definition~#3#1#4--#5#2#6} -\crefrangeformat{result}{result~#3#1#4--#5#2#6} -\Crefrangeformat{result}{Result~#3#1#4--#5#2#6} -\crefmultiformat{lemma}% - {lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{lemma}% - {Lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{corrollary}% - {corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{corrollary}% - {Corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{proposition}% - {propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{proposition}% - {Propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{definition}% - {definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{definition}% - {Definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefmultiformat{result}% - {results~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\Crefmultiformat{result}% - {Results~#2#1#3}{, #2#1#3}{ and~#2#1#3} -\crefrangemultiformat{lemma}% - {lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6}% -\Crefrangemultiformat{lemma}% - {Lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{corrollary}% - {corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{corrollary}% - {Corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{proposition}% - {propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{proposition}% - {Propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{definition}% - {definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{definition}% - {Definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\crefrangemultiformat{result}% - {results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -\Crefrangemultiformat{result}% - {Results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}% - { and~#3#1#4--#5#2#6} -} % end of ntheorem option +\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{} @@ -1026,21 +1289,21 @@ \lccode`~=0 \lccode`/=0 \catcode`~=12 \def\cref@text{}% \immediate\read\@crefscript to \@tmpa% - \edef\@tmpa{\@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% - \edef\@tmpa{\@tmpa}% \ifx\@tmpa\@eof% \@not@eoffalse% \else% \@not@eoftrue% + \edef\@tmpa{\@tmpa}% \fi}% \endgroup% \immediate\closein\@crefscript% @@ -1048,54 +1311,103 @@ \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} + \@tmpa^^J}% \lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter\cref@text\expandafter{% - \@tmpa^^J} + \@tmpa^^J}% \lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}% \expandafter\g@addto@macro\expandafter\cref@text\expandafter{% - \@tmpa^^J} + \@tmpa^^J}% \lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}% \expandafter\g@addto@macro\expandafter\cref@text\expandafter{% - \@tmpa^^J} + \@tmpa^^J}% \lowercase{\edef\@tmpa{% s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}% \expandafter\g@addto@macro\expandafter\cref@text\expandafter{% - \@tmpa^^J} + \@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} + \@tmpa^^J}% \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}% - \expandafter\g@addto@macro\expandafter\cref@text\% - expandafter{\@tmpa} - \endgroup + \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% -}% -\renewcommand{\cref}[1]{% - \edef\cref@text{}% - \@cref{cref}{#1}% - \cref@writescript{\string\cref\string{#1\string}}} -\renewcommand{\Cref}[1]{% - \edef\cref@text{}% - \@cref{Cref}{#1}% - \cref@writescript{\string\Cref\string{#1\string}}} -\renewcommand{\crefrange}[2]{% - \edef\cref@text{}% - \@setcrefrange{#1}{#2}{cref}{}% - \cref@writescript{% - \string\crefrange\string{#1\string}\string{#2\string}}} -\renewcommand{\Crefrange}[2]{% - \edef\cref@text{}% - \@setcrefrange{#1}{#2}{Cref}{}% - \cref@writescript{% - \string\Crefrange\string{#1\string}\string{#2\string}}} +} +\@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}% -} + \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} @@ -1107,19 +1419,24 @@ #1{\ref{#2}}{}{}}} \def\@@setcrefrange#1#2#3{% \old@@setcrefrange{#1}{#2}{#3}% - \expandafter\g@addto@macro + \expandafter\g@addto@macro% \expandafter{\expandafter\cref@text\expandafter}% \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}} -\def\@setcref@middleconjunction{% - \crefmiddleconjunction% - \expandafter\g@addto@macro +\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{\crefmiddleconjunction}} -\def\@setcref@lastconjunction{% - \creflastconjunction% - \expandafter\g@addto@macro + \expandafter{\crefmiddlegroupconjunction}} +\def\@setcref@lastgroupconjunction{% + \creflastgroupconjunction% + \expandafter\g@addto@macro% \expandafter{\expandafter\cref@text\expandafter}% - \expandafter{\creflastconjunction}} + \expandafter{\creflastgroupconjunction}} } % end of poorman option \ProcessOptions\relax \endinput |