summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/cleveref
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-07-16 15:55:33 +0000
committerKarl Berry <karl@freefriends.org>2007-07-16 15:55:33 +0000
commitfba6aeb2879447d0ab08ac86032e72bc8002d2e1 (patch)
treeb30974ad2257589ad2eed706dd0f03487a661c75 /Master/texmf-dist/tex/latex/cleveref
parent095c21ac9a136a78a974cb1bdcb06215f815eb64 (diff)
cleveref update (13jul07)
git-svn-id: svn://tug.org/texlive/trunk@4601 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/cleveref')
-rw-r--r--Master/texmf-dist/tex/latex/cleveref/cleveref.sty290
1 files changed, 228 insertions, 62 deletions
diff --git a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty
index 78b6f2f0e5d..4568bca3429 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/11/06 v0.6 Automatic cross-reference formatting]
+ [2007/10/07 v0.8 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
@@ -57,13 +57,14 @@
[#1][\arabic{#2}][\@result]\@currentlabel}}
\def\cref@label#1#2{\@result}
\AtBeginDocument{%
- \def\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@label}{#1}}%
+ \expandafter\def\csname ref \endcsname#1{%
+ \expandafter\ifx\csname r@#1\endcsname\relax%
+ \let\@result\relax%
+ \else%
+ \cref@getlabel{#1}{\@result}%
+ \fi%
+ \expandafter\@setref\csname r@#1\endcsname{\cref@label}{#1}}%
+ \def\ref{\expandafter\protect\csname ref \endcsname}
}
\def\cref@getlabel#1#2{%
\expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
@@ -105,10 +106,13 @@
\newif\ifstackempty
\newif\ifstackfull
\def\isstackempty#1{%
- \expandafter\ifx#1\@nil\stackemptytrue%
- \else\stackemptyfalse\fi}
+ \def\@tmpa{\@nil}%
+ \ifx#1\@tmpa\stackemptytrue%
+ \else\stackemptyfalse\fi
+}
\def\isstackfull#1{%
- \expandafter\ifx#1\@nil\stackfullfalse%
+ \def\@tmpa{\@nil}%
+ \ifx#1\@tmpa\stackfullfalse%
\else\stackfulltrue\fi}
\newif\ifinresetlist
\def\isinresetlist#1#2{%
@@ -168,13 +172,14 @@
\fi%
\fi%
\fi}
-\newcommand{\cref}[1]{\@cref{cref}{#1}}
-\newcommand{\Cref}[1]{\@cref{Cref}{#1}}
-\newcommand{\crefrange}[2]{\@setcrefrange{#1}{#2}{cref}{}}
-\newcommand{\Crefrange}[2]{\@setcrefrange{#1}{#2}{Cref}{}}
+\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%
\stack@init{\@refstack}%
\stack@push{#2}{\@refstack}%
@@ -197,11 +202,15 @@
\def\@nexttype{\relax}%
\else%
\edef\@nextref{\stack@top{\@refstack}}%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
- \def\@currenttype{\@undefined}%
+ \ifx\@nextref\@empty%
+ \let\@currenttype\@nexttype%
\else%
- \expandafter\cref@gettype\expandafter%
- {\@nextref}{\@currenttype}%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@currenttype{\@undefined}%
+ \else%
+ \expandafter\cref@gettype\expandafter%
+ {\@nextref}{\@currenttype}%
+ \fi%
\fi%
\fi}%
\if@firstgroup%
@@ -227,11 +236,27 @@
\expandafter\ifx\csname r@\@beginref\endcsname\relax%
\refconsecutivefalse%
\else%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \ifx\@nextref\@empty%
\refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@beginref}{\@nextref}}%
- \expandafter\isrefconsecutive\@tmpa%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \stack@pop{\@refsubstack}%
+ \isstackempty{\@refsubstack}%
+ \ifstackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\stack@top{\@refsubstack}}%
+ \fi%
+ }%
+ \ifnum\count@consecutive=2%
+ \edef\@endref{\@endref,}%
+ \fi%
+ \else
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{\@beginref}{\@nextref}}%
+ \expandafter\isrefconsecutive\@tmpa%
+ \fi%
\fi%
\fi%
\@whilesw\ifrefconsecutive\fi{%
@@ -243,11 +268,27 @@
\refconsecutivefalse%
\else%
\edef\@nextref{\stack@top{\@refsubstack}}%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \ifx\@nextref\@empty%
\refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@endref}{\@nextref}}%
- \expandafter\isrefconsecutive\@tmpa%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \stack@pop{\@refsubstack}%
+ \isstackempty{\@refsubstack}%
+ \ifstackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\stack@top{\@refsubstack}}%
+ \fi%
+ }%
+ \ifnum\count@consecutive=2%
+ \edef\@endref{\@endref,}%
+ \fi%
+ \else
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{\@endref}{\@nextref}}%
+ \expandafter\isrefconsecutive\@tmpa%
+ \fi%
\fi%
\fi}%
\ifx\@endref\relax%
@@ -276,11 +317,27 @@
\else%
\edef\@nextref{\stack@top{\@refsubstack}}%
\count@consecutive=1%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \ifx\@nextref\@empty%
\refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@beginref}{\@nextref}}%
- \expandafter\isrefconsecutive\@tmpa%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \stack@pop{\@refsubstack}%
+ \isstackempty{\@refsubstack}%
+ \ifstackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\stack@top{\@refsubstack}}%
+ \fi%
+ }%
+ \ifnum\count@consecutive=2%
+ \edef\@endref{\@endref,}%
+ \fi%
+ \else
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{\@beginref}{\@nextref}}%
+ \expandafter\isrefconsecutive\@tmpa%
+ \fi%
\fi%
\@whilesw\ifrefconsecutive\fi{%
\advance\count@consecutive 1%
@@ -291,11 +348,27 @@
\refconsecutivefalse%
\else%
\edef\@nextref{\stack@top{\@refsubstack}}%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \ifx\@nextref\@empty%
\refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@endref}{\@nextref}}%
- \expandafter\isrefconsecutive\@tmpa%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \stack@pop{\@refsubstack}%
+ \isstackempty{\@refsubstack}%
+ \ifstackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\stack@top{\@refsubstack}}%
+ \fi%
+ }%
+ \ifnum\count@consecutive=2%
+ \edef\@endref{\@endref,}%
+ \fi%
+ \else
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{\@endref}{\@nextref}}%
+ \expandafter\isrefconsecutive\@tmpa%
+ \fi%
\fi%
\fi}%
\isstackempty{\@refsubstack}%
@@ -309,8 +382,10 @@
\expandafter\@setcref\@tmpa%
\else%
\ifnum\count@consecutive=2%
- \edef\@tmpa{{\@beginref}{#1}{\@pos}}%
- \expandafter\@setcref\@tmpa%
+ \expandafter\@setcref\expandafter%
+ {\@beginref}{#1}{@middle}%
+ \expandafter\stack@push\expandafter%
+ {\@endref}{\@refsubstack}%
\else
\edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
\expandafter\@setcrefrange\@tmpa%
@@ -557,8 +632,8 @@
\csname #1@#2@format@last\endcsname%
}{}%
}
-\crefformat{equation}{eq.~#2(#1)#3}
-\Crefformat{equation}{Eq.~#2(#1)#3}
+\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}
@@ -570,13 +645,25 @@
\crefformat{subsubsubsection}{section~#2#1#3}
\Crefformat{subsubsubsection}{Section~#2#1#3}
\crefformat{figure}{fig.~#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.~#2(#1)#3}{, #2(#1)#3}{ and~#2(#1)#3}
+ {eqs.~\textup{(#2#1#3)}}%
+ {, \textup{(#2#1#3)}}%
+ { and~\textup{(#2#1#3)}}
\Crefmultiformat{equation}%
- {Eqs.~#2(#1)#3}{, #2(#1)#3}{ and~#2(#1)#3}
+ {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}%
@@ -600,13 +687,31 @@
\crefmultiformat{figure}%
{figs.~#2#1#3}{, #2#1#3}{ and~#2#1#3}
\Crefmultiformat{figure}%
- {Figs.~#2#1#3}{, #2#1#3}{ and~#2#1#3}
+ {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}
-\crefrangeformat{equation}{eqs.~#3(#1)#4--#5(#2)#6}
-\Crefrangeformat{equation}{Eqs.~#3(#1)#4--#5(#2)#6}
+\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}
@@ -618,17 +723,25 @@
\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}{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.~#3(#1)#4--#5(#2)#6}%
- {, #3(#1)#4--#5(#2)#6}%
- { and~#3(#1)#4--#5(#2)#6}
+ {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}%
- {Eqs.~#3(#1)#4--#5(#2)#6}%
- {, #3(#1)#4--#5(#2)#6}%
- { and~#3(#1)#4--#5(#2)#6}
+ {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}%
@@ -670,11 +783,11 @@
{, #3#1#4--#5#2#6}%
{ and~#3#1#4--#5#2#6}
\crefrangemultiformat{figure}%
- {figs~#3#1#4--#5#2#6}%
+ {figs.~#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}%
+ {Figures~#3#1#4--#5#2#6}%
{, #3#1#4--#5#2#6}%
{ and~#3#1#4--#5#2#6}
\crefrangemultiformat{theorem}%
@@ -685,6 +798,38 @@
{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}{%
@@ -725,18 +870,40 @@
\else\edef\@tempreset{\csname the\@tempreset\endcsname}\fi%
\protected@edef\@currentlabel{%
[#1][\arabic{#2}][\@tempreset]\@templabel}}
+\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\@cref{#1}{#2}\@crefstarredfalse}
+\def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}}
+\def\@crefrangestar#1#2#3{%
+ \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse}
\def\@@setcref#1#2{%
\cref@getlabel{#2}{\@templabel}%
- \edef\@templink{\cref@hyperref{#2}}%
- #1{\@templabel}{\hyper@linkstart{link}{\@templink}}{\hyper@linkend}}
+ \if@crefstarred%
+ #1{\@templabel}{}{}%
+ \else%
+ \edef\@templink{\cref@hyperref{#2}}%
+ #1{\@templabel}{\hyper@linkstart{link}{\@templink}}{\hyper@linkend}%
+ \fi}
\def\@@setcrefrange#1#2#3{%
\cref@getlabel{#2}{\@labela}%
\cref@getlabel{#3}{\@labelb}%
- \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}}
+ \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}
} % end of hyperref option
\DeclareOption{ntheorem}{%
\PackageInfo{cleveref}{option `ntheorem' loaded}
@@ -868,7 +1035,6 @@
\@whilesw\if@not@eof\fi{%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
\@tmpa^^J}%
- \show\cref@text%
\immediate\read\@crefscript to \@tmpa%
\edef\@tmpa{\@tmpa}%
\ifx\@tmpa\@eof%