summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-05-06 15:04:02 +0000
committerKarl Berry <karl@freefriends.org>2009-05-06 15:04:02 +0000
commit0622731eb4278fed01effd61c773cad94f60573a (patch)
tree7d4992cb434c8988d57d8ebc940cca75eeb13910
parent14eca2eb231aa1f885e38594619aea15c8aa464c (diff)
cleveref update (30apr09)
git-svn-id: svn://tug.org/texlive/trunk@12950 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/cleveref/README29
-rw-r--r--Master/texmf-dist/doc/latex/cleveref/cleveref.pdfbin289339 -> 354276 bytes
-rw-r--r--Master/texmf-dist/source/latex/cleveref/cleveref.dtx6169
-rw-r--r--Master/texmf-dist/tex/latex/cleveref/cleveref.sty3505
4 files changed, 7119 insertions, 2584 deletions
diff --git a/Master/texmf-dist/doc/latex/cleveref/README b/Master/texmf-dist/doc/latex/cleveref/README
index f9e9be98296..b110f1554fb 100644
--- a/Master/texmf-dist/doc/latex/cleveref/README
+++ b/Master/texmf-dist/doc/latex/cleveref/README
@@ -17,15 +17,30 @@ http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the
details of that license.
-Abstract:
----------
+Description:
+------------
The cleveref package enhances LaTeX's cross-referencing features, allowing the
-formatting of references to be determined automatically according to the type
-of reference (equation, section, etc.). The format for each reference type can
+format of cross-references to be determined automatically according to the
+"type" of cross-reference (equation, section, etc.) and the context in which
+the cross-reference is used. The formatting for each cross-reference type can
be fully customised in the preamble of your document. In addition, cleveref
-can typeset references to lists of multiple labels, automatically formatting
-them according to their type, and collapsing sequences of numerically
-consecutive labels to a reference range. Again, the multiple-reference
+can type-set cross-references to lists of multiple labels, automatically
+formatting them according to their types, sorting them, and compressing
+sequences of numerically consecutive labels. Again, the multiple-reference
formatting is fully customisable. Though a number of other packages provide
similar features, all have certain deficiencies which cleveref attempts to
overcome.
+
+Using cleveref is easy. Basically, wherever you would previously have used
+\ref, you can use \cref instead. (Except at the beginning of a sentence, where
+you should use \Cref.) You no longer need to put the name of the thing you're
+referencing in front of the \cref command, because cleveref will sort that out
+for you: i.e. use "\cref{eq1}" instead of "eq.~(\ref{eq1})". If you want to
+refer to a range of labels, use the \crefrange command: "\crefrange{eq1}{eq5}"
+produces "eqs.~(1) to~(5)". Finally, if you want to refer to multiple things
+at once, you can now combine them all into one cross-reference and leave
+cleveref to sort it out: e.g. "\cref{eq2,eq1,eq3,eq5,thm2,def1}" produces:
+"eqs.~(1) to~(3) and~(5), theorem~5, and definition~1".
+
+Cleveref has various other useful features. For details, see the package
+documentation.
diff --git a/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf b/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf
index 441ab183fd6..93064625913 100644
--- a/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf
+++ b/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/cleveref/cleveref.dtx b/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
index 01238a7cc73..44e36f06c9e 100644
--- a/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
+++ b/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
%
% Package 'cleveref' to use with LaTeX2e
-% Copyright 2009 by Toby Cubitt
+% Copyright 2007--2009 by Toby Cubitt
%
% Written and maintained by Toby Cubitt
%
@@ -21,17 +21,18 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{cleveref}
-%<package> [2009/11/02 v0.12 Intelligent cross-referencing]
+%<package> [2009/17/04 v0.13 Intelligent cross-referencing]
%
%<*driver>
-\documentclass{ltxdoc}
-%\documentclass[draft]{ltxdoc}
+%\documentclass{ltxdoc}
+\documentclass[draft]{ltxdoc}
\usepackage{url}
-\usepackage{hyperref}
+%\usepackage{hyperref} % breaks index
\usepackage{cleveref}
-\EnableCrossrefs
+\DisableCrossrefs
\CodelineIndex
\RecordChanges
+\setcounter{IndexColumns}{2}
%%\newcommand{\package}[1]{\texttt{#1.sty}}
\newcommand{\package}[1]{\texttt{#1}}
\newcommand{\file}{\texttt}
@@ -60,7 +61,7 @@
%</driver>
% \fi
%
-% \CheckSum{3407}
+% \CheckSum{6721}
%% \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
@@ -77,40 +78,43 @@
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%
-% \changes{v0.1}{2006/29/06}{Initial version}
-% \changes{v0.2}{2007/18/04}{Complete rewrite}
-% \changes{v0.3}{2007/26/04}{Added reference ranges}
-% \changes{v0.4}{2007/26/05}{Renamed "cleveref" -- first public release}
-% \changes{v0.5}{2007/31/05}{Added poorman option}
-% \changes{v0.6}{2007/11/06}{Poorman no longer writes extra .tmp file}
-% \changes{v0.7}{2007/21/06}{Allow prevention of reference range
+% \changes{v0.01}{2006/06/29}{Initial version}
+% \changes{v0.02}{2007/04/18}{Complete rewrite}
+% \changes{v0.03}{2007/04/26}{Added reference ranges}
+% \changes{v0.04}{2007/05/26}{Renamed "cleveref" -- first public release}
+% \changes{v0.05}{2007/05/31}{Added poorman option}
+% \changes{v0.06}{2007/06/11}{Poorman no longer writes extra .tmp file}
+% \changes{v0.07}{2007/06/21}{Allow prevention of reference range
% collapsing}
-% \changes{v0.8}{2007/10/07}%
+% \changes{v0.08}{2007/07/10}%
% {Made referencing commands robust, improved default formats, made
% starred versions of referencing commands for hyperref, allowed
% multiple consecutive empty references in list to prevent range
-% collapsing, and fixed bugs. Phew!}
-% \changes{v0.8.1}{2007/08/08}{Bug fixes.}
-% \changes{v0.9}{2007/29/10}%
+% collapsing, and fixed bugs. Phew.}
+% \changes{v0.08.1}{2007/08/08}{Bug fixes.}
+% \changes{v0.09}{2007/10/29}%
% {Added an extra conjunction and format component, used when a list
% only contains a single pair of references or reference
% sub-lists. Formats are now constructed from customisable
% components, unless overridden using the old format definition
% commands.}
-% \changes{v0.10}{2007/30/10}%
+% \changes{v0.10}{2007/10/30}%
% {Allow optional argument to \\label to override reference
% type. Removed hyperref and ntheorem options; support for these and
% amsmath is enabled automatically if those packages are loaded.}
-% \changes{v0.11}{2007/21/11}{Made referencing aware of appendices.}
-% \changes{v0.11.1}{2007/29/11}{Bug fixes.}
-% \changes{v0.12}{2009/11/02}{Restore working \\ref* when hyperref is
+% \changes{v0.11}{2007/11/21}{Made referencing aware of appendices.}
+% \changes{v0.11.1}{2007/11/29}{Bug fixes.}
+% \changes{v0.12}{2009/02/11}{Restore working \\ref* when hyperref is
% loaded -- first release mirrored on www.dr-qubit.org}
+% \changes{v0.13}{2009/04/17}{Finally implemented sort and compress
+% package options. Support amsmath \\tag command. Added babel support
+% for English, German and French. Added varioref support.}
%
%
% \GetFileInfo{cleveref.sty}
%
-% \def\fileversion{0.12}
-% \def\filedate{11/02/2009}
+% \def\fileversion{0.13}
+% \def\filedate{17/04/2009}
%
% \title{The \package{cleveref} package\thanks{This document
% corresponds to \textsf{cleveref}~\fileversion, dated
@@ -122,18 +126,20 @@
%
% \begin{abstract}
% The \package{cleveref} package enhances \LaTeX{}'s cross-referencing
-% features, allowing the format of references to be determined
-% automatically according to the type of reference (equation, section,
-% etc.) and the context in which the reference is used. The formatting
-% for each reference type can be fully customised in the preamble of
-% your document. In addition, \package{cleveref} can typeset references
-% to lists of multiple labels, automatically formatting them according
-% to their type, and collapsing sequences of numerically consecutive
-% labels to a reference range. Again, the multiple-reference formatting
-% is fully customisable.
+% features, allowing the format of cross-references to be determined
+% automatically according to the ``type'' of cross-reference (equation,
+% section, etc.) and the context in which the cross-reference is
+% used. The formatting for each cross-reference type can be fully
+% customised in the preamble of your document. In addition,
+% \package{cleveref} can type-set cross-references to lists of multiple
+% labels, automatically formatting them according to their types,
+% sorting them, and compressing sequences of numerically consecutive
+% labels. Again, the multiple-reference formatting is fully
+% customisable.
% \end{abstract}
%
-%
+% \tableofcontents
+% \clearpage
%
% \section{Introduction}
% When ``clever'' is used in the name of a computer program, it usually
@@ -144,91 +150,100 @@
% consistent, visual appearance.
%
% Both these points of view are probably valid when it comes to the
-% \package{cleveref} package. It's goals are two-fold: to use the
+% \package{cleveref} package. Its goals are two-fold: to use the
% information that \LaTeX{} inherently has about labels as intelligently
-% as possible in order to type-set references to them (clever
+% as possible when type-setting cross-references to them (clever
% processing); and to enable you to produce an attractive, consistent
-% formatting of references throughout your document, with the minimum of
-% effort (you'd be clever to use it!).
+% formatting of cross-references throughout your document, with the
+% minimum of effort (you'd be clever to use it!).
%
% The \package{cleveref} package enhances \LaTeX{}'s cross-referencing
-% facilities by allowing references to be formatted automatically
-% according to the type of object they refer to (chapter, section,
-% equation, theorem, etc.) and the context in which the reference is
-% used. It can also automatically format references to multiple labels,
-% automatically collapsing references to consecutive labels into a
-% reference range, and all kinds of other clever wizardry.
+% facilities by allowing cross-references to be formatted automatically
+% according to the type of thing they refer to (chapter, section,
+% equation, theorem, etc.) and the context in which the cross-reference
+% is used. It can also automatically format cross-references to multiple
+% labels, sort lists of multiple cross-references, compres
+% cross-references to consecutive labels into a reference range, and all
+% kinds of other clever wizardry.
%
% In standard \LaTeX{}, you have almost certainly found yourself writing
-% things like |Eq.~(\ref{eq1})| and |Theorems~\ref{thm1} to~\ref{thm2}|
+% things like |Eq.~(\ref{eq1})| and |Theorems~\ref{thm1} to~\ref{thm3}|
% over and over again. Tedium isn't the only downside to this. What
-% happens if you later decide you want equation references to be typeset
+% happens if you later decide you want equation references to be type-set
% as |Equation~\ref{eq1}| instead? What happens if you decide to change
% the theorem labelled |thm1| into a lemma? You have to search through
% the entire \LaTeX{} source of your document, modifying all references
-% to equations, or changing all references to |thm1|.
+% to equations, and changing all references to |thm1|.
%
% The \package{cleveref} package allows you to define the format for
-% references once-and-for-all in the preamble of your document. If you
-% later decide to change the format of equation references, you only have
-% to change one preamble definition. If you xchange a theorem into a
-% lemma, you don't need to change any references at all, because
-% \package{cleveref} will automatically typeset references to it using
-% the appropriate formatting. This makes it far easier to typeset
-% references uniformly across your whole document, as well as avoiding
-% repetitively typing the same text for each and every reference.
-%
-% There are a number of other packages with similar goals, most notably
-% \package{varioref}, \package{fancyref}, \package{hyperref}'s |\autoref|
-% command, and (for theorem-like environments) \package{ntheorem} (with
-% the \option{thref} option). (There are many others, but these come
-% closest to providing similar features to \package{cleveref}.) However,
-% all have certain deficiencies which \package{cleveref} attempts to
-% overcome.
+% cross-references once-and-for-all in the preamble of your document. If
+% you later decide to change the format of equation references, you only
+% have to change one preamble definition. If you change a theorem into a
+% lemma, you don't need to change any cross-references at all, because
+% \package{cleveref} will automatically type-set cross-references to it
+% using the appropriate formatting. This makes it far easier to type-set
+% cross-references uniformly across your whole document, as well as
+% avoiding repetitively typing the same text for each and every
+% cross-reference.
+%
+% Given how useful this is, there are naturally a number of other
+% packages with similar goals, most notably \package{varioref},
+% \package{fancyref}, \package{hyperref}'s |\autoref| command, and (for
+% theorem-like environments) \package{ntheorem} (with the \option{thref}
+% option). (There are many others, but these come closest to providing
+% similar features to \package{cleveref}.) However, all have certain
+% deficiencies which \package{cleveref} attempts to overcome.
%
% The \package{fancyref} package doesn't automatically determine the type
-% of object being referred to. Instead, it relies on you adhering to a
+% of thing being referred to. Instead, it relies on you adhering to a
% naming convention for labels. This is usually a good idea in any case,
% but it can be inconvenient. For example, if you change a theorem into a
% lemma, you have to change the label name, and therefore also all
-% references to it. So you are back to searching and replacing through
-% the entire document.
+% cross-references to it. So you are back to searching and replacing
+% through the entire document, not to mention missing out on all the
+% other \package{cleveref} features.
%
% The enhanced referencing feature provided by the \package{varioref}
-% package decides how to format references when the label is
-% \emph{defined}, rather than when it is \emph{referenced}. Often this
-% isn't a problem. But it makes it impossible to format references
-% differently according the context in which they are referenced, which
-% can sometimes be very useful. For example, if you want references at
-% the beginning of a sentence formatted any other way than by
-% capitalising the first letter of the reference text, it is impossible
-% using \package{varioref}. Perhaps even more significantly, it makes it
-% impossible to typeset multiple references automatically; you are back
-% typesetting |Eqs.~(\ref{eq1}) and~(\ref{eq2})| or
-% |Eqs.~(\ref{eq1})--(\ref{eq3})| by hand. Not to mention missing out on
-% automatic collapsing of consecutive references, \package{ntheorem}
-% support, etc.
-%
-% The \package{hyperref} package's |\autoref| command typesets a name
-% before a reference, determined by the reference type. This is less
-% flexible than \package{cleveref}'s fully customisable reference
-% formatting but, when combined with \package{varioref}, the two packages
-% working together come close. However, even with \package{hyperref}, it
-% is impossible to customise precisely which part of the reference is
-% made into a hyper-link in PDF documents; this is very easy with
-% \package{cleveref}. And it still remains impossible to typeset multiple
-% references, have consecutive references collapsed automatically, etc.
+% package's\linebreak[4] |\labelformat| command decides how to format
+% cross-references when the label is \emph{defined}, rather than when it
+% is \emph{referenced}. Often this isn't a problem. But it makes it
+% impossible to format cross-references differently according the context
+% in which they are referenced, which can sometimes be very useful. For
+% example, if you want cross-references at the beginning of a sentence
+% formatted any other way than by capitalising the first letter of the
+% cross-reference text, it is impossible using
+% \package{varioref}. Perhaps even more significantly, it makes it
+% impossible to type-set multiple references automatically; you are back
+% to typing %
+% |Eqs.~(\ref{eq1}) to~(\ref{eq3})| by hand. Not to mention missing out
+% on automatic sorting and compressing of consecutive references,
+% \package{ntheorem} support, precise control over hyper-links,
+% etc. \package{cleveref} fully supports \package{varioref}, taking over
+% responsibility for type-setting cross-references, whilst retaining all
+% the \package{varioref} page-referencing magic.
+%
+% The \package{hyperref} package's |\autoref| command type-sets a name
+% before a cross-reference, determined by the cross-reference type. This
+% is less flexible than \package{cleveref}'s fully customisable
+% cross-reference formatting but, when combined with \package{varioref},
+% the two packages working together come close. However, even with
+% \package{hyperref}, it is impossible to customise precisely which part
+% of the cross-reference is made into a hyper-link in PDF documents; this
+% is very easy with \package{cleveref}. And it still remains impossible
+% to type-set multiple references, have consecutive references sorted and
+% compressed automatically, etc.
%
% The \package{ntheorem} package (with the \option{thref} option) does
-% things right\ldots except that it only works for theorem-like
-% environments. It is possible to use it for other environments, but only
-% in a bastardized form, by manually supplying an optional argument to
-% |\label| commands that specifies the label type. \package{cleveref}
-% works equally well when referencing any type of object, as well as
-% fully supporting \package{ntheorem}. And again, \package{cleveref}
-% provides a number additional features, such as multiple references,
-% automatic collapsing of reference ranges, control over the placement of
-% hyper-links, etc.
+% things right with regards how and when the format is defined\ldots
+% except that it only works for theorem-like environments. It is possible
+% to use it for other environments, but only in a bastardized form, by
+% manually supplying an optional argument to |\label| commands that
+% specifies the label type. \package{cleveref} works equally well when
+% referencing any type of thing, as well as fully supporting
+% \package{ntheorem}. And again, \package{cleveref} also provides a
+% number additional features over \package{ntheorem}, such as multiple
+% cross-references, automatic sorting and compressing of consecutive
+% cross-references, control over the placement of hyper-links, etc.
%
%
%
@@ -252,157 +267,183 @@
% the thing you're referencing in front of the |\cref| command, because
% \package{cleveref} will sort that out for you: i.e.\ use |\cref{eq1}|
% instead of |eq.~(\ref{eq1})|. If you want to refer to a range of
-% labels, use |\crefrange|: |\crefrange{eq1}{eq5}| gives
-% |eqs.~(1)--(5)|. Finally, if you want to refer to multiple things at
-% once, you can now combine them all into one reference and leave
+% labels, use the |\crefrange| command: |\crefrange{eq1}{eq5}| gives
+% |eqs.~(1) to~(5)|. Finally, if you want to refer to multiple things at
+% once, you can now combine them all into one cross-reference and leave
% \package{cleveref} to sort it out: e.g.\
-% |\cref{eq1,eq2,eq3,eq5,thm2,def1}| produces
-% |eqs.~(1)--(3) and~(5), theorem~5, and definition~1|.
+% |\cref{eq2,eq1,eq3,eq5,thm2,def1}| produces:%
+% |eqs.~(1) to~(3) and~(5),|\linebreak[4] |theorem~5, and definition~1|.
%
%
-% \section{Typesetting References}
+% \section{Type-Setting Cross-References}
% \label{sec:typesetting}
% \DescribeMacro\cref
-% To automatically typeset a cross-reference according to the type of
-% object referred to, simply refer to it using |\cref{|\meta{label}|}|.
+% To automatically type-set a cross-reference according to the type of
+% thing referred to, simply refer to it using |\cref{|\meta{label}|}|.
% \package{cleveref} imposes just one extra restriction on the names of
% labels: they are no longer allowed to contain commas ``,''. These are
-% instead used to typeset multiple references (see below).
+% instead used to type-set multiple cross-references (see below).
%
% \DescribeMacro\Cref
% As it is very difficult\footnote{Actually, very likely impossible!}
% for \LaTeX{} to determine whether a cross-reference appears at the
% beginning of a sentence or not, a capitalised version exists:
-% |\Cref{|\meta{label}|}|. By default, this typesets the reference with
-% the first letter capitalised. (Though the formatting of the |\cref| and
-% |\Cref| forms can be fully and independently customised, see
-% \cref{sec:customising}.)
+% |\Cref{|\meta{label}|}|. By default, this type-sets the cross-reference
+% with the first letter capitalised. (Though the formatting of the
+% |\cref| and |\Cref| forms can be fully and independently customised,
+% see \cref{sec:customising}.)
%
% \DescribeMacro\ref
% \package{cleveref} does \emph{not} modify the standard |\ref|
% command\footnote{This is not quite true. The original \cmd{\ref}
% command no longer works when \package{cleveref} is loaded, so
% \package{cleveref} redefines it to recover the original behaviour.},
-% so you can still use it to typeset the formatted label counter alone,
+% so you can still use it to type-set the formatted label counter alone,
% without any additional text or formatting.
%
% \DescribeMacro\crefrange
% \DescribeMacro\Crefrange
-% To typeset a reference range, e.g. |Eqs.~(1.1)--(1.5)|, use
-% |\crefrange| or |\Crefrange| (depending on the capitalisation you
-% require), which take the beginning and end of the range as arguments:
+% To type-set a cross-reference range, e.g. |Eqs.~(1.1) to~(1.5)|,
+% use\linebreak[4] |\crefrange| or |\Crefrange| (depending on the
+% capitalisation you require), which take the beginning and end of the
+% range as arguments:
% \begin{quote}
% |\crefrange{|\meta{label1}|}{|\meta{label2}|}|
% \end{quote}
%
% \DescribeMacro\cref
% \DescribeMacro\Cref
-% To typeset multiple references, simply list the lables inside the
-% |\cref| or |\Cref| command, separated by commas (you are not allowed
-% to use commas in label names when using \package{cleveref}):
+% To type-set multiple cross-references, simply list the lables inside
+% the |\cref| or |\Cref| command, separated by commas (you are not
+% allowed to use commas in label names when using \package{cleveref}):
% \begin{quote}
% |\cref{|\meta{label1}|,|\meta{label2}|,|\meta{label3}|,...}|
% \end{quote}
-% The references will be typeset in the order in which they appear in the
-% list, and sequences of consecutive references will be collapsed to a
-% reference range. It is up to you to put the labels in the order you
-% require. This is especially significant if the labels refer to
-% different types of object, or to consecutive sequences of labels. For
-% example, if |eq*| are equation labels, and |thm*| are theorem labels,
-% \begin{quote}
-% |\cref{eq1,eq2,eq3,thm1,thm2}|
-% \end{quote}
-% will be typeset as
-% \begin{quote}
-% eqs.~(1)--(3), and theorems~1 and~2
-% \end{quote}
-% whereas
-% \begin{quote}
-% |\cref{eq1,eq2,thm1,thm2,eq3}|
-% \end{quote}
-% will be typeset as
-% \begin{quote}
-% eqs.~(1) and~(2), theorems~1 and~2, and eq.~(3)
-% \end{quote}
-% (assuming you haven't customised the reference formats).
%
-% To prevent a sequence of consecutive references from being collapsed to
-% a reference range, you can separate the references in the list by one
-% or more empty references, at the point at which you want to prevent
-% collapsing. For example,
+% \DescribeMacro{\cref*}
+% \DescribeMacro{\Cref*}
+% \DescribeMacro{\crefrange*}
+% \DescribeMacro{\Crefrange*}
+% When \package{cleveref} is used along with the \package{hyperref}
+% package (see \cref{sec:customising,sec:other_packages}), additional
+% starred variants of all the referencing commands are available. The
+% standard referencing commands will make cross-references into
+% hyper-links; the starred variants prevent this, producing the same
+% type-set text but without creating hyper-links.
+%
+%
+% \section{Sorting and Compressing}
+% \label{sec:sort&compress}
+% When \package{cleveref} type-sets lists of multiple cross-references,
+% the default behaviour is to automatically sort the list and compress
+% sequences of consecutive cross-references into a reference range. You
+% can change this behaviour by supplying one of the following package
+% options:
+% \begin{description}
+% \item[\option{sort}] Sort lists of cross-references, but don't compress
+% consecutive references.
+% \item[\option{compress}] Compress sequences of consecutive references
+% into a reference range, but don't sort the list of cross-references.
+% \item[\option{nosort}] Neither sort lists of cross-references,
+% \emph{nor} compress consecutive references.
+% \item[\option{sort\&compress}] Sort lists of cross-references, and
+% compress sequences of consecutive references into a reference
+% range (this is the default).
+% \end{description}
+%
+% Occasionally, you may want to prevent a particular sequence of
+% consecutive cross-references from being compressed to a reference
+% range, without disabling this feature globally. To achieve this, you
+% can separate the cross-references in the list by one or more empty
+% references, at the point at which you want to prevent compression. For
+% example,
% \begin{quote}
% |\cref{eq1,eq2,eq3,,eq4}|
% \end{quote}
-% will be typeset as
+% will be type-set as
% \begin{quote}
-% eqs.~(1)--(3) and (4)
+% eqs.~(1) to~(3) and (4)
% \end{quote}
% or
% \begin{quote}
% |\cref{eq1,eq2,,eq3,eq4,eq5,,eq6,eq7,eq8}|
% \end{quote}
-% will be typeset as
+% will be type-set as
+% \begin{quote}
+% eqs.~(1), (2), (3) to~(5) and (6) to~(8)
+% \end{quote}
+% You can safely put an empty reference between cross-references that
+% would never be compressed anyway; it will simply be ignored.
+%
+% If lists of cross-references are also being sorted (the default), it
+% can be a little confusing to work out where the empty reference should
+% go in order to prevent compression of a particular consecutive
+% sequence. It's best to think of the empty reference as being
+% ``attached'' to the cross-reference preceding it. When the list is
+% sorted, the empty reference will still appear after the same preceding
+% reference, and will prevent it being compressed with any subsequent
+% consecutive cross-references. In other words, an empty reference
+% ensures that the preceding reference will appear explicitly in the
+% final, type-set cross-reference:
+% \begin{quote}
+% |\cref{eq3,,eq2,eq1,eq6,eq4,eq5}|
+% \end{quote}
+% will be type-set as
% \begin{quote}
-% eqs.~(1), (2), (3)--(5) and (6)--(7)
+% eqs.~(1) to~(3) and (4) to~(6)
% \end{quote}
-% You can safely put an empty reference between references that would
-% never be collapsed anyway; it will simply be ignored.
%
-% \DescribeMacro{\cref*}
-% \DescribeMacro{\Cref*}
-% \DescribeMacro{\crefrange*}
-% \DescribeMacro{\Crefrange*}
-% When \package{cleveref} is used along with the \package{hyperref}
-% package (see \cref{sec:customising,sec:other_packages}), additional
-% starred variants of all the referencing commands are available. The
-% standard referencing commands will make references into hyper-links;
-% the starred variants prevent this, producing the same typeset text but
-% without creating hyper-links.
%
%
-% \section{Customising the Reference Format}
+% \section{Customising the Cross-Reference Format}
% \label{sec:customising}
% The \package{cleveref} package allows you to take full control of the
-% typesetting of references. Defaults appropriate for English documents
-% are provided for the standard label types\footnote{For any pedantic
-% classics scholars out there: ``lemmas'' is recognised as a valid
-% plural form of ``lemma'' in all current versions of the Oxford
-% English Dictionary. ``Lemmata'' was last heard in a mathematical
-% debate that took place in a pub just around the corner from Hadrian's
-% wall\dots a few years before the Romans pulled out of
-% Britain. \package{cleveref} might have ``clever'' in its name, but
-% even that doesn't make it pretentious enough to use
-% ``lemmata''.}. But if you don't like them, or are writing in a
-% different language, or you need to cross-reference something for which
-% no default format is defined, then you can take charge and define your
-% own formats.
-%
-% If \package{cleveref} encounters a reference to a type it does not
-% know, it will produce a ``reference type undefined'' warning, and
-% typeset the reference as
+% type-setting of cross-references, by allowing the formatting to be
+% customised. Defaults appropriate for English documents are provided for
+% the standard label types\footnote{For any pedantic classics scholars
+% out there: ``lemmas'' is recognised as a valid plural form of
+% ``lemma'' in all current versions of the Oxford English
+% Dictionary. ``Lemmata'' was last heard in a mathematical debate that
+% took place in a pub just around the corner from Hadrian's wall\dots a
+% few years before the Romans pulled out of Britain. \package{cleveref}
+% might have ``clever'' in its name, but even that doesn't make it
+% pretentious enough to use ``lemmata''.}, and support for German and
+% French is provided via package options (see
+% \cref{sec:language_babel}). But if you don't like the defaults, or are
+% writing in a different language\footnote{Any contributions of
+% translations for missing languages are very welcome! See
+% \cref{sec:code:babel} for information on how to contribute
+% translations.}, or you need to refer to something for which no
+% default format is defined, then you can take charge and define your own
+% formats.
+%
+% If \package{cleveref} encounters a cross-reference to a type it does
+% not know, it will produce a ``reference type undefined'' warning, and
+% type-set the cross-reference as
% \begin{quote}
% {\bf ??}~|\ref{|\meta{label}|}|
% \end{quote}
-% i.e.\ it will typeset the reference as the label counter preceded by a
-% double question mark. The error message indicates the name of the
-% unknown reference type, which you will then probably want to
-% define. (References to undefined labels still produce a ``reference
-% undefined'' warning and are typeset as a double question mark, as
-% usual.)
-%
-% The reference formats are usually constructed out of components: the
-% reference name (different for each type of reference), the label
-% formats, and the conjunctions used in reference ranges and lists of
-% multiple references. There are three levels of customisation: you can
-% customise the components globally, individually for each reference
-% type, or you can take full control and ignore the components entirely.
-%
-%
-% \subsection{Global Customisation}
+% i.e.\ the label counter preceded by a double question mark. The error
+% message indicates the name of the unknown cross-reference type, which
+% you will then probably want to define. (References to undefined labels
+% still produce a ``reference undefined'' warning and appear as a double
+% question mark, as usual.)
+%
+% The cross-reference formats are usually constructed out of components:
+% the cross-reference name (different for each type of cross-reference),
+% the format for the label itself, and the conjunctions used in reference
+% ranges and lists of multiple cross-references. There are two levels of
+% customisation: you can either customise the components, or you can take
+% full control and override the component-derived format entirely.
+%
+%
+% \subsection{Customising the Cross-Reference Components}
+% \label{sec:component_customisation}
+%
+% \subsubsection{Global Customisation}
% \label{sec:global_customisation}
-% The global customisation commands can only be used in the preamble, and
-% \emph{must} come before any lower-level customisation commands if they
-% are to have any effect.
+% The global customisation commands affect all cross-reference formats,
+% unless they are overridden by lower-level customisation commands.
%
% \DescribeMacro\crefdefaultlabelformat
% The format for the label counter itself can be customised globally
@@ -415,102 +456,99 @@
% should!) contain three arguments, |#1|, |#2| and |#3|. The first
% argument is the formatted version of the label counter (e.g.\
% |\theequation|). The other two are used to mark the beginning and end
-% of the part of the reference that should form the hyper-link when the
-% \package{hyperref} package is used (see \cref{sec:other_packages}). The
-% hyper-link arguments |#2| and |#3| \emph{must} appear in that
-% order. (Leaving them out completely will not cause an error, but in
-% that case no hyper-link will be created when \package{hyperref} is
-% used, and there are better ways to achieve this. See
-% \cref{sec:typesetting,sec:other_packages}.)
+% of the part of the cross-reference that should form the hyper-link when
+% the \package{hyperref} package is used (see
+% \cref{sec:other_packages}). The hyper-link arguments |#2| and |#3|
+% \emph{must} appear in that order. (Leaving them out completely will not
+% cause an error, but in that case no hyper-link will be created when
+% \package{hyperref} is used, and there are better ways to achieve
+% this. See \cref{sec:typesetting,sec:other_packages}.)
+%
+% Note that the default format for equation cross-references already
+% overrides \cmd{\crefdefaultlabelformat} in order to surround the label
+% by brackets, so the label format for equations must be customised
+% individually (see \cref{sec:individual_customisation}).
%
% \DescribeMacro\crefrangeconjunction
% The conjunction used in a reference range can be customised by
-% redefining |\crefrangeconjunction|:
+% defining |\crefrangeconjunction|:
% \begin{quote}
-% |\renewcommand{\crefrangeconjunction}{|\meta{conjunction}|}|
+% |\newcommand{\crefrangeconjunction}{|\meta{conjunction}|}|
% \end{quote}
% It does not have to be an actual conjunction in the linguistic sense,
% e.g.\ it is perfectly reasonable to define it to be an emdash
% ``|--|''. |\crefrangeconjunction| is used directly between the start
% and end references in a reference range, without any additional space
-% surrounding it, e.g.\ |\crefrange{thm1}{thm2}| is typeset as
+% surrounding it, e.g.\ |\crefrange{thm1}{thm2}| is type-set as
% \begin{quote}
% |theorems~\ref{thm1}\crefrangeconjunction\ref{thm2}|
% \end{quote}
-% (assuming the default theorem format hasn't been customised). So you
-% may or may not want to include surrounding space, depending on the
-% formatting you desire. For example,
+% so you may or may not want to include surrounding space, depending on
+% the formatting you desire. For example,
% \begin{quote}
-% |\renewcommand{\crefrangeconjunction}{ and~}|
+% |\newcommand{\crefrangeconjunction}{ and~}|
% \end{quote}
% does require surrounding space, whereas
% \begin{quote}
-% |\renewcommand{\crefrangeconjunction}{--}|
+% |\newcommand{\crefrangeconjunction}{--}|
% \end{quote}
-% does not.
-%
-% Note that customizing |\crefrangeconjunction| will \emph{not} work for
-% equations and figures because of the way the default formats for these
-% are defined. See |\crefrangeformat| in
-% \cref{sec:individual_customisation} for a way to change the conjunction
-% for these reference types.
+% probably does not.
%
% \DescribeMacro\crefpairconjunction
% \DescribeMacro\crefmiddleconjunction
% \DescribeMacro\creflastconjunction
-% The conjunctions used in lists of references can be customised by
-% redefining |\crefpairconjunction|, |\crefmiddleconjunction| and
-% |\creflastconjunction|:
+% The conjunctions used in lists of multiple cross-references can be
+% customised by defining the commands |\crefpairconjunction|,
+% |\crefmiddleconjunction| and |\creflastconjunction|:
% \begin{quote}
-% |\renewcommand{\crefpairconjunction}{|\meta{conjunction}|}|\\
-% |\renewcommand{\crefmiddleconjunction}{|\meta{conjunction}|}|\\
-% |\renewcommand{\creflastconjunction}{|\meta{conjunction}|}|
+% |\newcommand{\crefpairconjunction}{|\meta{conjunction}|}|\\
+% |\newcommand{\crefmiddleconjunction}{|\meta{conjunction}|}|\\
+% |\newcommand{\creflastconjunction}{|\meta{conjunction}|}|
% \end{quote}
-% |\crefpairconjunction| is used when there are only two references in
-% the list, |\creflastconjunction| is used between the penultimate and
-% final reference in a list of more than two, and
+% |\crefpairconjunction| is used when there are only two cross-references
+% in the list, |\creflastconjunction| is used between the penultimate and
+% final cross-reference in a list of more than two, and
% |\crefmiddleconjunction| is used between all the others. Again, they do
% not have to be conjunctions in the linguistic sense, and the same
-% comments about surrounding space apply as in the case of
+% considerations about surrounding space apply as in the case of
% |\crefrangeconjunction|. For example, the default definition of
% |\crefmiddleconjunction| is:
% \begin{quote}
-% |\renewcommand{\crefmiddleconjunction}{, }|
+% |\newcommand{\crefmiddleconjunction}{, }|
% \end{quote}
%
% \DescribeMacro\crefpairgroupconjunction
% \DescribeMacro\crefmiddlegroupconjunction
-% \DescribeMacro\creflastgroupconjunction
-% By default, the conjunctions used to separate sub-lists of different
-% reference types in a multi-reference are identical to those used to
-% separate references of the same type\footnote{More accurately,
-% redefining $\backslash$crefpairconjunction etc.\ automatically
-% redefines $\backslash$crefpairgroupconjunction etc.\ so that they
-% match. If you \emph{don't} redefine anything, the default definition
-% of $\backslash$creflastgroupconjunction has an additional comma
-% lacking in $\backslash$creflastconjunction.}. You can override this
-% by redefining |\crefpairgroupconjunction|,
+% \DescribeMacro\creflastgroupconjunction By default, the conjunctions
+% used to separate sub-lists of different cross-reference types in a
+% multi-reference are identical to those used to separate
+% cross-references of the same type\footnote{More accurately, if you
+% redefine $\backslash$crefpairconjunction etc.\ in your preamble,
+% $\backslash$crefpairgroupconjunction etc.\ are automatically
+% redefined so that they match. (In some languages, the default
+% definition of $\backslash$creflastgroupconjunction has an additional
+% comma lacking in $\backslash$creflastconjunction.)}. You can override
+% this by defining the conjunction commands |\crefpairgroupconjunction|,
% |\crefmiddlegroupconjunction| and |\creflastgroupconjunction|.
%
-% For example, if |eq*|, |thm*| and |fig*| are respectively equation,
-% theorem and figure labels,
+% For example,
% \begin{quote}
% |\cref{eq1,eq2,eq3,thm1,thm2,fig1,thm3}|
% \end{quote}
-% is typeset as
+% is type-set as
% \begin{quote}
% eqs.~(1)|\crefrangeconjunction|(3)|\crefmiddlegroupconjunction|%\\
% theorems~1|\crefpairconjunction|2|\crefmiddlegroupconjunction|%\\
-% fig.~1|\creflastgroupconjunction|theorem~3
+% fig.~1|\creflastgroupconjunction{}|theorem~3
% \end{quote}
%
%
-% \subsection{Customising Individual Reference Types}
+% \subsubsection{Customising Individual Cross-Reference Types}
% \label{sec:individual_customisation}
% \DescribeMacro\crefname
% \DescribeMacro\Crefname
-% The reference name for a given reference type is customised using the
-% |\crefname| and |\Crefname| commands:
+% The cross-reference name for a given cross-reference type is customised
+% using the |\crefname| and |\Crefname| commands:
% \begin{quote}
% |\crefname{|\meta{type}|}{|\meta{singular}|}{|\meta{plural}|}|\\
% |\Crefname{|\meta{type}|}{|\meta{singular}|}{|\meta{plural}|}|
@@ -530,39 +568,55 @@
% explicitly. Otherwise you will get strange and fatal errors when
% processing the document.
%
-% The reference \meta{type} is usually the name of the counter for the
-% environment (equation, chapter, section, etc.). Currently, the only
-% exceptions are appendices, for which \meta{type} should be ``appendix''
-% (instead of chapter or section), and theorem-like environments when the
-% \package{ntheorem} package is loaded, for which \meta{type} should
-% instead be the environment name (lemma, corollary, definition,
-% etc.). \package{ntheorem} provides extra information about the
-% environment when different theorem-like environments use a common
-% counter, which \package{cleveref} makes use of to distinguish between
-% them automatically.
+% The cross-reference \meta{type} is usually the name of the counter for
+% the environment (equation, chapter, section, etc.). The exceptions are
+% appendices, labels whose type has been overridden explicitly by
+% supplying an optional argument (see \cref{sec:label_type}), and
+% theorem-like environments when the \package{ntheorem} package is
+% loaded, for which \meta{type} should instead be the environment name
+% (lemma, corollary, definition, etc.) even when different environments
+% are part of the same numbering sequence. (\package{ntheorem} provides
+% extra information about the environment when different theorem-like
+% environments share a common counter, which \package{cleveref} makes use
+% of to distinguish between them automatically.) In the case of
+% appendices, the \meta{type} is ``appendix'' for the top-level
+% sectioning command (\cmd{\chapter} or \cmd{\section}, depending on the
+% document class), ``subappendix'' for the sectioning command one level
+% below (\cmd{\section} or \cmd{\subsection}), ``subsubappendix'' for the
+% next level of sectioning command, etc.
+%
+% For convenience, if they have not been otherwise customised by the end
+% of the preamble, the cross-reference name (and label format) for
+% |subsection| is by default inherited from that of |section|, and that
+% of |subsubsection| is inherited from |subsection| (which might itself
+% have been inherited from |section|). Similarly for |subappendix|,
+% |subsubappendix| and |subsubsubappendix|, and also for |enumii|,
+% |enumiii|, |enumiv| and |enumv|. Finally, |subfigure| and |subtable|
+% inherit from |figure| and |table|, respectively.
%
% \DescribeMacro\creflabelformat
-% You may want the label format for a particular reference type to differ
-% from the global format set by |\crefdefaultlabelformat| (see
-% \ref{sec:global_customisation}. You can do this using
+% You may want the label format for a particular cross-reference type to
+% differ from the global format set by |\crefdefaultlabelformat| (see
+% \cref{sec:global_customisation}). You can do this using
% \begin{quote}
% |\creflabelformat{|\meta{type}|}{|\meta{format}|}|
% \end{quote}
-% The \meta{type} argument is the reference type to customise, and the
-% \meta{format} argument defines the label format for references of that
-% type. As in the case of\linebreak[4] |\crefdefaultlabelformat|, the
-% latter should contain the three arguments |#1|, |#2| and |#3|, the
-% first being the formatted version of the label counter, the others
-% determining the beginning and end of the portion that becomes a
-% hyper-link when the \package{hyperref} package is loaded (see
-% \cref{sec:other_packages}). |#2| and |#3| must appear in that order.
+% The \meta{type} argument is the cross-reference type to customise, and
+% the \meta{format} argument defines the label format for
+% cross-references of that type. As in the case of\linebreak[4]
+% |\crefdefaultlabelformat|, the latter should contain the three
+% arguments |#1|, |#2| and |#3|, the first being the formatted version of
+% the label counter, the others determining the beginning and end of the
+% portion that becomes a hyper-link when the \package{hyperref} package
+% is loaded (see \cref{sec:other_packages}). |#2| and |#3| \emph{must}
+% appear in that order.
%
% \DescribeMacro\crefrangelabelformat
-% Normally, the start and end references in a reference range are typeset
-% using using the usual label format (as defined by
+% Normally, the start and end references in a reference range are
+% type-set using the usual label format (as defined by
% |\crefdefaultlabelformat| or |\creflabelformat|) separated by
% |\crefrangeconjunction| (\cref{sec:global_customisation}). You can
-% override this for a given reference type using
+% override this for a given cross-reference type using
% \begin{quote}
% |\crefrangelabelformat{|\meta{type}|}{|\meta{format}|}|
% \end{quote}
@@ -571,46 +625,66 @@
% versions of the two label counters defining the reference range. The
% next two (|#3| and |#4|) denote the beginning and end of the hyper-link
% for the first reference, the final two (|#5| and |#6|) the hyper-link
-% for the second reference. The hyper-link arguments must appear in
-% order. For example, the default format for equations is defined as:
+% for the second reference. The hyper-link arguments \emph{must} appear
+% in order. For example,
% \begin{quote}
-% |\crefrangelabelformat{equation}{(#3#1#4)--(#5#2#6)}|
+% |\crefrangelabelformat{equation}{(#3#1#4) to~(#5#2#6)}|
% \end{quote}
%
-% Note that the above default reference range format for equations (and
-% similarly for figures) already overrides the normal
-% |\crefrangelabelformat|, so customizing |\crefrangeconjunction| will
-% not affect these particular default formats. If you want to change the
-% conjunction used in equation and figure reference ranges, you have to
-% use |\crefrangelabelformat|.
%
-%
-% \subsection{Taking Full Control}
+% \subsection{Low-Level Customisation: Taking Full Control}
% \label{sec:full-control_customisation}
-% If you need more precise control over the reference format than is
-% possible by customising the individual components, then you can take
+% If you need more precise control over the cross-reference format than
+% is possible by customising the individual components, then you can take
% full control of the format for any given type, overriding the
-% component-derived format entirely. The formats for single references,
-% reference ranges and multi-references are customised separately. If you
-% only customise some of these, the other formats will still be
-% constructed from components, as usual.
-%
-% \subsubsection{Single References}
+% component-derived format entirely. The formats for single
+% cross-references, reference ranges and multi-references are customised
+% separately. If you only customise some of these, the other formats will
+% be constructed from components, as usual.
+%
+% Note that when deciding which cross-references should be grouped
+% together for sorting and/or compressing, \package{cleveref} does
+% something slightly more complicated than simply checking whether the
+% reference types match. In fact, it checks whether the reference
+% \emph{formats} match\footnote{To be precise, \package{cleveref} checks
+% whether the $\backslash$|crefformat|'s match.}. This will always be
+% the case for cross-references of the same type. But it could also be
+% the case for cross-references that have different types, if the
+% cross-reference formats happen to be identical.
+%
+% The reason for doing this is to allow cross-references to e.g.\
+% sections and subsections to be grouped together if they have identical
+% formats. The default formats for the sectioning commands, figures and
+% subfigures, tables and subtables, and enumerated lists are set up in
+% this way. If you change any of them using the low-level customisation
+% commands, but still want them to be grouped together, then you must
+% ensure that the formats are \emph{identical}. (It is \emph{not}
+% sufficient for the formats to producing identical type-set text; the
+% format definitions must contain identical \LaTeX{} code.)
+%
+%
+% \subsubsection{Single Cross-References}
% \label{sec:ref_format}
% \DescribeMacro\crefformat
% \DescribeMacro\Crefformat
-% Reference formats for \emph{single} references are defined or redefined
-% using the\linebreak[4] |\crefformat| and |\Crefformat| commands, which
-% are used by the |\cref| and |\Cref| commands respectively. These take
-% two arguments: the reference type, and the formatting code:
+% Cross-reference formats for \emph{single} cross-references are defined or
+% redefined using the\linebreak[4] |\crefformat| and |\Crefformat|
+% commands, which are used by the |\cref| and |\Cref| commands
+% respectively. These take two arguments: the cross-reference type, and the
+% formatting code:
% \begin{quote}
% |\crefformat{|\meta{type}|}{|\meta{format}|}|\\
% |\Crefformat{|\meta{type}|}{|\meta{format}|}|
% \end{quote}
-% The \meta{type} is usually the name of the counter, except for
+% The \meta{type} is usually the name of the counter, except for labels
+% whose type has been overridden explicitly (see \cref{sec:label_type}),
% theorem-like environments when \package{ntheorem} is loaded, in which
-% case it is the environment name,and appendices, when it is
-% ``appendix''.
+% case it is the environment name, and appendices. For the latter, the
+% \meta{type} is ``appendix'' for the top-level sectioning command
+% (\cmd{\chapter} or \cmd{\section}, depending on the document class),
+% ``subappendix'' for the sectioning command one level below
+% (\cmd{\section} or \cmd{subsection}), ``subsubappendix'' for the next
+% level of sectioning command, etc.
%
% As in the case of the |\crefname| and |\Crefname| commands, if the
% corresponding |\Crefformat| is undefined when |\crefformat| is called,
@@ -627,15 +701,15 @@
% will need to |\protect| fragile commands. It should contain three
% arguments, |#1|, |#2| and |#3|. The first argument is the formatted
% version of the label counter (e.g.\ |\theequation|). The other two are
-% used to mark the beginning and end of the part of the reference that
-% forms the hyper-link when the \package{hyperref} package is used, and
-% must appear in that order (see \cref{sec:other_packages}).
+% used to mark the beginning and end of the part of the cross-reference
+% that forms the hyper-link when the \package{hyperref} package is used,
+% and \emph{must} appear in that order (see \cref{sec:other_packages}).
%
% As an example,
% \begin{quote}
% |\crefformat{equation}{Eq.~(#2#1#3)}|
% \end{quote}
-% will typeset equation references as
+% will type-set equation references as
% \begin{quote}
% Eq.~(\meta{counter})
% \end{quote}
@@ -660,57 +734,57 @@
% \DescribeMacro\Crefrangeformat
% The format for reference ranges is defined by |\crefrangeformat|
% and\linebreak[4] |\Crefrangeformat|. Like |\creformat| and
-% |\Crefformat|, the commands take two arguments: the reference type, and
-% the formatting code.
+% |\Crefformat|, the commands take two arguments: the cross-reference
+% type, and the formatting code.
% \begin{quote}
% |\crefrangeformat{|\meta{type}|}{|\meta{format}|}|\\
% |\Crefrangeformat{|\meta{type}|}{|\meta{format}|}|
% \end{quote}
-% The same comments apply as in the case of single references: the
-% \meta{type} is usually the name of the counter, except for theorem-like
-% environments when \package{ntheorem} is loaded, and if the
-% other-capitalisation variant is not already defined, it will be defined
-% automatically.
+% The same comments apply as in the case of single cross-references: the
+% \meta{type} is usually the name of the counter, except for appendices,
+% labels with explicitly overridden types, and theorem-like environments
+% when \package{ntheorem} is loaded. Again, if the other-capitalisation
+% variant is not already defined, it will be defined automatically.
%
% The \meta{format} argument can again be any valid \LaTeX{} code, with
% fragile commands |\protect|ed. However, this time it should contain
% \emph{six} arguments, |#1|--|#6|. The first two (|#1| and |#2|) are the
% formatted versions of the label counters, the next two (|#3| and |#4|)
% are used to mark the beginning and end of the hyper-link for the first
-% reference (|#1|), and the final two (|#5| and |#6|) mark the beginning
-% and end of the second reference's hyper-link.
+% cross-reference, and the final two (|#5| and |#6|) mark the beginning
+% and end of the second cross-reference's hyper-link.
%
-% As an example, the default
+% As an example,
% \begin{quote}
-% |\crefrangeformat{equation}{eqs.~(#3#1#4)--(#5#2#6)}|
+% |\crefrangeformat{equation}{eqs.~(#3#1#4) to~(#5#2#6)}|
% \end{quote}
-% will typeset equation reference ranges as
+% would type-set equation reference ranges as
% \begin{quote}
-% eqs.~(\meta{counter1})--(\meta{counter2})
+% eqs.~(\meta{counter1}) to~(\meta{counter2})
% \end{quote}
% with the counters (excluding the brackets) forming the hyper-links.
%
%
-% \subsubsection{Multiple References}
+% \subsubsection{Multiple Cross-References}
% \label{sec:multiple_ref_format}
% \DescribeMacro\crefmultiformat
% \DescribeMacro\Crefmultiformat
% \DescribeMacro\crefrangemultiformat
% \DescribeMacro\Crefrangemultiformat
-% The format for multiple references is defined by |\crefmultiformat|
-% and\linebreak[4] |\Crefmultiformat|, and that of reference ranges
-% within multiple references by |\crefrangemultiformat| and
-% |\Crefrangemultiformat|. Multi-references also require \emph{all} the
-% other reference formats to be defined (see
-% \cref{sec:ref_format,sec:ref_range_format}), including the single
+% The format for multiple cross-references is defined by
+% |\crefmultiformat| and\linebreak[4] |\Crefmultiformat|, and that of
+% reference ranges within multiple cross-references by
+% |\crefrangemultiformat| and |\Crefrangemultiformat|. Multi-references
+% also require \emph{all} the other cross-reference formats to be defined
+% (see \cref{sec:ref_format,sec:ref_range_format}), including the single
% reference range formats, even if you never use the |\crefrange| and
% |\Crefrange| commands.
%
-% The commands all take five arguments: the reference type, the format
-% for the first reference in a list, the format for the second reference
-% in a list of two, the format for the middle references in a list of
-% more than two, and the format for the last reference in a list of more
-% than two.
+% The commands all take five arguments: the cross-reference type, the
+% format for the first cross-reference in a list, the format for the
+% second cross-reference in a list of two, the format for the middle
+% cross-references in a list of more than two, and the format for the
+% last cross-reference in a list of more than two.
% \begin{quote}
% |\crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|\\
% |\Crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|\\
@@ -718,13 +792,14 @@
% |\Crefrangemultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|
% \end{quote}
%
-% The \meta{type} is, as ever, the counter name, or environment name in
-% the case of \package{ntheorem} theorem-like environments. The same
-% considerations apply to the formatting arguments \meta{first},
-% \meta{second}, \meta{middle} and \meta{last} as for the \meta{format}
-% argument of |\crefformat| or |\crefrangeformat|, including the meaning
-% of the arguments that should appear in the formatting code (|#1|, |#2|
-% and |#3| for |\crefmultiformat| and |\Crefmultiformat|, |#1|--|#6| for
+% The \meta{type} is, as ever, the counter name, except for appendices,
+% explicitly overridden label types, and theorem-like environments then
+% the \package{ntheorem} package is loaded. The same considerations apply
+% to the formatting arguments \meta{first}, \meta{second}, \meta{middle}
+% and \meta{last} as for the \meta{format} argument of |\crefformat| or
+% |\crefrangeformat|, including the meaning of the arguments that should
+% appear in the formatting code (|#1|, |#2| and |#3| for
+% |\crefmultiformat| and |\Crefmultiformat|, |#1|--|#6| for
% |\crefmultiformat| and |\Crefmultiformat|). However, when the
% corresponding other-capitalisation variant is automatically defined,
% only the first letter of the \meta{first} argument is upper- or
@@ -732,15 +807,15 @@
% variants.
%
% Be careful to get the spaces at the beginning and end of the formatting
-% code correct: the \meta{first} and {|\meta{second}|}, or \meta{first},
-% \meta{middle} and \meta{last}, \LaTeX{} code is typeset one after
+% code correct: the \meta{first} and \meta{second}, or \meta{first},
+% \meta{middle} and \meta{last}, \LaTeX{} code is type-set one after
% another in a multi-reference, with no space separating them. You may or
% may not want spaces at the beginning and end of the formatting code,
% depending on the formatting you desire. For example, in the default
-% equation format
+% equation format:
% \begin{quote}
-% |\crefmultiformat{equation}%|\\
-% |{eqs.~(#2#1#3)}{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}|
+% |\crefmultiformat{equation}{eqs.~(#2#1#3)}%|\\
+% | { and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}|
% \end{quote}
% the \meta{middle} argument should \emph{not} have a space at the
% beginning, whereas the \meta{second} and \meta{last} arguments
@@ -748,25 +823,91 @@
%
%
%
-% \section{Overriding the Reference Type}
-% As described previously, a label's reference type is usually determined
-% by its counter, or in the case of \package{ntheorem} theorem-like
+% \subsection{Language and \package{babel} support}
+% \label{sec:language_babel}
+% \package{cleveref} supports different languages via package options, in
+% the usual way, though not all languages are supported
+% yet\footnote{Currently, only \option{english}, \option{german},
+% \option{ngerman} and \option{french} are supported. Contributions of
+% translations for missing languages are very welcome! See
+% \cref{sec:code:babel} for information on how to contribute
+% translations.}. The \package{babel} package is also supported when it
+% is loaded, allowing you to change language using the \package{babel}
+% language switching commands such as \cmd{\selectlanguage} and
+% \cmd{\foreignlanguage}.
+%
+% The \package{babel} support works by redefining the cross-reference
+% names and conjunctions for the default cross-reference types. Any
+% customisations you make to the default cross-reference names and
+% conjunctions \emph{in the preamble} apply to the main language (i.e.\
+% the last language listed in the options). A \cmd{\selectlanguage}
+% command or similar will override these customisations, replacing them
+% with the defaults for the new language. If you later use
+% \cmd{\selectlanguage} to switch back to the main language, your
+% customisations will be restored. If you want to customise
+% cross-reference names or conjunctions for any language other than the
+% main one, you either have to explicitly redefine them after every
+% language switching command, or hook the redefinitions into
+% \package{babel}'s language switching mechanism. (See
+% \cref{sec:code:babel} and the \package{babel} documentation.)
+%
+% If you have defined formats for new cross-reference types for which no
+% defaults are provided, then you're on your own. \package{cleveref} will
+% not know how to redefine them for other languages, and again you will
+% have to take care of it yourself, either by explicitly redefining them
+% in your document after each language switch, or by hooking the
+% redefinitions into \package{babel}'s language switching mechanism.
+%
+% On the other hand, since the language switching commands only modify
+% the cross-reference components, if you use the low-level customisation
+% commands to take full control of the format for a particular
+% cross-reference type, then (unless you're careful) you take it out of
+% the control of \package{babel} entirely. If you want to use the
+% low-level customisation commands, but \emph{do} still want the language
+% switching commands to work, then you have to use the component macros
+% in your customised formats. The cross-reference names are stored in
+% macros called |\cref@\meta{type}@name|, |\Cref@\meta{type}@name|,
+% |\cref@\meta{type}@name@plural|, and
+% |\Cref@\meta{type}@name@plural|.\linebreak[4] (Note that since these
+% macro names contain the ``@'' character, you must use
+% \cmd{\makeatletter} and \cmd{\makeatother} to access them.)
+%
+% For example, if you wanted to redefine the equation format so that the
+% cross-reference name (``equation'') was also part of the hyper-link,
+% but you still want to be able to switch language using \package{babel},
+% you would need something like:
+% \begin{quote}
+% |\makeatletter|\\
+% |\crefformat{equation}{#2\cref@equation@name~(#1)#3}|\\
+% \dots\\
+% |\makeatother|
+% \end{quote}
+% and similarly for \cmd{\crefrangeformat}, \cmd{\crefmultiformat},
+% \cmd{\Crefformat}, etc.
+%
+%
+%
+% \section{Overriding the Cross-Reference Type}
+% \label{sec:label_type}
+% \DescribeMacro\label
+% As described previously, a label's ``type'' is usually determined by
+% its counter, or in the case of \package{ntheorem} theorem-like
% environments by the environment name. Occasionally, you may want to
-% override the reference type for a particular label. You can do this by
-% supplying the desired type as an optional argument to the |\label|
-% command:
+% override the cross-reference type for a particular label. You can do
+% this by supplying the desired type as an optional argument to the
+% |\label| command:
% \begin{quote}
% |\label[|\meta{type}|]{|\meta{label}|}|
% \end{quote}
%
% One circumstance in which is useful is when you want to define a
-% special reference format for certain labels of a given type. By
-% specifying a type that doesn't already exist in the |\label|'s optional
-% argument, you can then define the reference format for that new type in
-% whatever way you like, without affecting other references of the same
-% type. For example, if a particular equation contains multiple
-% expressions and you want it to always be referred to in the plural, you
-% could use:
+% special cross-reference format for certain labels of a given type. By
+% supplying a type that doesn't already exist as the optional argument to
+% |\label|, you can then define the cross-reference format for that new
+% type in whatever way you like, without affecting other cross-references
+% of the same type. For example, if a particular equation contains
+% multiple expressions and you want it to always be referred to in the
+% plural, you could use:
% \begin{quote}
% |\crefname{pluralequation}{eqs.}{eqs.}|\\
% \dots\\
@@ -779,19 +920,20 @@
% \package{aliascnt} package. This lets you define one counter to be an
% alias for another, so that effectively the same counter has two
% names. Since \package{cleveref} determines the label type from the
-% counter name, the two counter aliases can have different reference
-% formats whilst really being the same counter. You have to somehow
-% arrange for the correct counter alias to be used depending on which
-% reference format you want (probably by defining two variants of the
-% environment in question). But the effort involved might be worth the
-% convenience of not having to remember to pass an explicit optional
-% argument to a large number of labels.
-%
-% You can use this trick to get different reference formats for different
-% theorem-like environments, \emph{without} using the \package{ntheorem}
-% package\footnote{This trick seems to belong to \LaTeX{} mythology, and
-% certainly isn't my own idea! I haven't been able to definitively
-% track down who originally came up with it.}. For example,
+% counter name, the two counter aliases can have different
+% cross-reference formats whilst really being the same counter. You have
+% to somehow arrange for the correct counter alias to be used depending
+% on which cross-reference format you want (probably by defining two
+% variants of the environment in question). But the effort involved might
+% be worth the convenience of not having to remember to pass an explicit
+% optional argument to a large number of labels.
+%
+% You can use this trick to get different cross-reference formats for
+% different theorem-like environments, \emph{without} using the
+% \package{ntheorem} package\footnote{This trick seems to belong to
+% \LaTeX{} mythology, and certainly isn't my own idea! But I haven't
+% been able to definitively track down who originally came up with
+% it.}. For example,
% \begin{quote}
% |\usepackage{aliascnt}|\\
% |\usepackage{cleveref}|\\
@@ -805,28 +947,28 @@
%
% \section{Poor Man's \package{cleveref}}
% Sometimes you may need to send your \LaTeX{} source to someone who
-% can't install the \package{cleveref} package themselves. For example,
-% many academic journals accept papers in \LaTeX{} format, but only
-% support a small subset of the packages available on CTAN. The
+% can't or won't install the \package{cleveref} package themselves. For
+% example, many academic journals accept papers in \LaTeX{} format, but
+% only support a small subset of the packages available on CTAN. The
% \option{poorman} option was designed specifically to help in this
% situation.
%
% When the \option{poorman} option is supplied, your document will be
-% processed as normal. But in addition, a {\tt sed} script will
-% automatically be written, containing rules for replacing all the
-% \cmd{\cref} commands with the \LaTeX{} code that they would produce,
-% and using the standard \cmd{\ref} command to produce the
-% cross-references themselves. I.e.\ the script rewrites your document as
-% you would have done if you had had to do it manually!
+% processed as normal. But in addition, a |sed| script will automatically
+% be written, containing rules for replacing all the \cmd{\cref} commands
+% with the \LaTeX{} code that they would produce, and using the standard
+% \cmd{\ref} command to produce the cross-references themselves. I.e.\
+% the script rewrites your document as you would have done if you had had
+% to do it manually!
%
% The advantage, of course, is that you \emph{don't} have to do it
% manually. Instead, you can use all the features of \package{cleveref},
% and once you've created a version of your document that you want to
-% send elsewere, you can process it through the {\tt sed} script to
+% send elsewere, you can process it through the |sed| script to
% completely remove the \package{cleveref} dependency. The recipient
% won't even realise you used \package{cleveref}!
%
-% The {\tt sed} script is written to the same directory as the (main)
+% The |sed| script is written to the same directory as the (main)
% \LaTeX{} source file, and given the same name as that source file but
% with the extension \file{.sed}. To process your document through the
% script, all you need to do is run the following from your shell:
@@ -837,16 +979,32 @@
% where \meta{name} is the name of the file containing your \LaTeX{}
% source file minus the \file{.tex} extension, and \meta{newname} is
% whatever you want to call the new version. \emph{Do not} make
-% \meta{newname} the same as \meta{name}. (It's in any case wise to keep
-% the original \LaTeX{} source file containing the \package{cleveref}
-% commands, in case you need to produce an updated version of your
-% document in the future. Think of the \meta{newname}\file{.tex} file as
-% being rather like a \file{DVI} file: something you can always reproduce
-% from the original source.) If your document is composed of a number of
-% separate \LaTeX{} source files, combined with |\include| commands, only
-% one {\tt sed} script will be generated, but you will need to run \emph
-% {each} source file through that \emph{same} script (and probably modify
-% the |\include| commands to match the new file names).
+% \meta{newname} the same as \meta{name}: it won't work. (It's in any
+% case wise to keep the original \LaTeX{} source file containing the
+% \package{cleveref} commands, in case you need to produce an updated
+% version of your document in the future. Think of the
+% \meta{newname}\file{.tex} file in the same way as a \file{DVI} file:
+% something you can always reproduce from the original source.)
+%
+% If your document is composed of a number of separate \LaTeX{} source
+% files, combined with |\include| commands, only one |sed| script will be
+% generated, but you will need to run \emph {each} source file through
+% that \emph{same} script (and probably modify the |\include| commands to
+% match the new file names). However, using \package{babel}'s language
+% switching commands in a document split across multiple separate source
+% files is beyond the capabilities of the \package{poorman} option. You
+% will almost certainly need to manually tweak the |sed| script in that
+% case.
+%
+% Note that the \option{poorman} script cannot fully reproduce the
+% type-setting of the original \package{cleveref} cross-references in all
+% cases\footnote{At least, not without resorting to inserting low-level
+% \LaTeX{} code in your document, which would somewhat defeat the
+% purpose of the \option{poorman} option.}. In particular, any
+% customisation of hyper-links will be lost, and if you're using
+% \package{varioref} with the \option{legacyvarioref} option (see
+% \cref{sec:other_packages}, the spacing before the \cmd{\vref} command
+% will not be correct.
%
%
%
@@ -862,117 +1020,179 @@
% preamble.
%
% Since \package{cleveref} redefines many internal commands involved in
-% \LaTeX{}'s referencing system, it can interact badly with other
-% packages that do the same. \package{varioref}'s enhanced referencing
-% features (the ones you make use of by via the |\labelformat| command),
-% the \package{fancyref} package, and \package{ntheorem}'s \option{thref}
-% option are incompatible with \package{cleveref}. However, since
-% \package{cleveref} implements an enhanced version of these packages'
-% features, this is not really a problem. For example, if you have a
-% pre-existing document that uses \package{ntheorem}'s |\thref| command,
-% you can simply redefine it to call |\cref| instead:
-% \begin{quote}
-% |\renewcommand{\thref}{\cref}|
-% \end{quote}
-% In fact, \package{cleveref} does this for you automatically if
-% \package{ntheorem} was loaded with the \option{thref} option. Note that
-% you can still use the other features of \package{varioref} and
-% \package{ntheorem} whilst using \package{cleveref}, as long as
-% \package{cleveref} is loaded \emph{last}.
+% \LaTeX{}'s cross-referencing system, it can interact badly with other
+% packages that do the same. The \package{varioref} package's enhanced
+% referencing features (the ones you make use of by via the
+% |\labelformat| command), the \package{fancyref} package, and
+% \package{ntheorem}'s \option{thref} option are incompatible with
+% \package{cleveref}. However, since \package{cleveref} implements a
+% significantly enhanced version of these packages' features, this is not
+% really a problem.
+%
+% \DescribeMacro{\thref}
+% \DescribeMacro{\vref}
+% \DescribeMacro{\Vref}
+% \DescribeMacro{\vrefrange}
+% \DescribeMacro{\Vrefrange}
+% \DescribeMacro{\fullref}
+% \DescribeMacro{\Fullref}
+% In fact, if \package{ntheorem} is loaded with the \option{thref}
+% option, \package{cleveref} redefines \package{ntheorem}'s |\thref|
+% command for you, to be an alias for |\cref|. Similarly, if
+% \package{varioref} is loaded, \package{cleveref} redefines the |\vref|,
+% |\vrefrange|, |\fullref| commands and variants to instead use the
+% \package{cleveref} features for cross-reference formatting, whilst
+% retaining all the \package{varioref} page-referencing magic. You can
+% continue to use the other \package{varioref} and \package{ntheorem}
+% commands (other than |\labelformat| and the \option{thref} option)
+% whilst using \package{cleveref}, as long as \package{cleveref} is
+% loaded \emph{last}.
+%
+% \DescribeMacro{\vref*}
+% \DescribeMacro{\Vref*}
+% \DescribeMacro{\vrefrange*}
+% \DescribeMacro{\Vrefrange*}
+% \DescribeMacro{\fullref*}
+% \DescribeMacro{\Fullref*}
+% Note that, whilst in the business of redefining the \package{varioref}
+% commands, \package{cleveref} seizes the opportunity to get rid of the
+% irritating spacing behaviour of the \cmd{\vref} and \cmd{\Vref}
+% commands, instead making it consistent with the other
+% \package{cleveref} cross-referencing commands. This also frees up the
+% starred variants to be used to suppress hyper-links when the
+% \package{hyperref} package is loaded, as usual. (Unfortunately, due to
+% lack of support for this in \package{varioref}, the page references
+% will still be hyper-links, even when using the starred variants. Go bug
+% the \package{varioref} maintainer about this if you don't like it.)
+%
+% \DescribeMacro{legacyvarioref}
+% However, the \package{cleveref} redefinitions break strict
+% compatibility with the original \package{varioref} commands. If you
+% need the original spacing behaviour for compatibility reasons, pass the
+% \option{legacyvarioref} option to \package{cleveref}. If this option is
+% supplied, only the original \package{varioref} commands |\vref|,
+% |\vref*|, |\vrefrange| and |\fullref| will be provided, not any of the
+% additional variants, and the starred variants will change the spacing
+% around the commands as per the original \package{varioref}
+% implementation, rather than supressing hyper-links.
%
% Other packages which alter the \LaTeX{} referencing system are unlikely
-% to work properly with \package{cleveref}.
+% to work properly with \package{cleveref}. (For example, although
+% \package{cleveref} fully supports the \package{hyperref} package's
+% hyper-link features, the \option{backref} option is not currently
+% supported.) See \cref{sec:known_bugs} for additional information.
+%
%
%
+% \section{Known Bugs and Possible Improvements}
+% \label{sec:known_bugs}
%
-% \section{Known Bugs and Word-Arounds}
-% In no particular order.
+% \subsection{Known Bugs, Non-Bugs, and Work-Arounds}
+% In no particular order:
% \begin{itemize}
-% \item \package{cleveref} will not work properly with the standard
-% \LaTeX{} |eqnarray| environment. The |eqnarray| environment is poorly
-% implemented, making it somewhat difficult to get it to work properly
-% with \package{cleveref}. You're better off using the
-% \package{amsmath} replacements in any case, such as |gather|,
-% |align|, |multine| and |split|, which \emph{do} work properly with
-% \package{cleveref}. (See
-% \url{http://www.tug.org/pracjourn/2006-4/madsen/}).
% \item When both the \package{amsmath} \emph{and} \package{hyperref}
% packages are loaded at the same time, the \package{cleveref}
-% cross-referencing commands will not work in section titles. If anyone
-% can figure out why, let me know!
-% \item \package{cleveref} provides no \package{babel} support. (This
-% should be fixed in a future version.)
+% cross-referencing commands do not work when used within section
+% titles. If anyone can figure out why, let me know! As a work-around,
+% use |\ref| within section titles when your document uses both
+% \package{amsmath} and \package{hyperref}.
+% \item \package{cleveref} will not work properly with the standard
+% \LaTeX{} |eqnarray| environment. There is no intention to fix
+% this. The |eqnarray| environment is poorly implemented, making it
+% difficult to get it to work properly with \package{cleveref}. You're
+% better off using the \package{amsmath} replacements in any case, such
+% as |gather|, |align|, |multline| and |split|, which \emph{do} work
+% properly with \package{cleveref}. (See
+% \url{http://www.tug.org/pracjourn/2006-4/madsen/}).
+% \item \package{cleveref} currently only provides language support for
+% German and French. Please contribute translations for missing
+% languages!\footnote{See \cref{sec:code:babel} for information on how
+% to contribute translations.}
+% \item \package{cleveref} assumes that counters are only ever reset by
+% the standard sectioning commands (|\chapter|, |\section|, etc.). If
+% this is not the case, the automatic compression of consecutive
+% cross-references into a reference range may be incorrect. Making this
+% more flexible would be a simple task, but so far there doesn't seem
+% to be much need for it.
% \item \package{cleveref} breaks \package{hyperref}'s \option{backref}
% option, and probably also the \package{backref} package when used by
% itself. (This should be fixed in a future version.)
-% \item \package{cleveref} assumes that counters are only ever reset by
-% the standard sectioning commands (chapter, section, etc.). If this is
-% not the case, the automatic collapsing of consecutive references into
-% a reference range may be incorrect.
-% \item The \option{poorman} sed script always uses |\ref| rather than
-% |\ref*|, even if the command it's replacing is a starred variant
-% |\cref*|, |\crefrange*| etc. (This should be fixed in a future
+% \item \package{cleveref} is almost certainly incompatible with
+% \package{titleref}, \package{byname}, \package{nameref} and the
+% like. This shouldn't be difficult to fix, and if you want this
+% feature, then\dots patches are always welcome!
+% \item \package{cleveref} doesn't know about the \package{subfloat}
+% package, so you have to revert to using \cmd{\ref} for
+% cross-references to sub-figures. (This should be fixed in a future
% version.)
-% \item The \option{poorman} sed script uses |\ref| when replacing
-% \package{cleveref} cross-references, but this loses any custom
-% \package{cleveref} hyper-link formatting you might have defined. The
-% philosophy behind the \option{poorman} option is to replace
-% \package{cleveref}'s enhanced cross-referencing with standard
+% \item The \option{poorman} |sed| script loses any custom
+% \package{cleveref} hyper-link formatting you might have defined, and
+% does not reproduce the original spacing around the \cmd{\vref}
+% command when \package{varioref} is used with the
+% \option{legacyvarioref} option. This is not a bug; it is
+% intentional. The philosophy behind the \option{poorman} option is to
+% replace \package{cleveref}'s enhanced cross-referencing with standard
% \LaTeX{} cross-reference commands that are guaranteed to work with
% any standard \LaTeX{} installation. Although it would be simple to
-% fix this ``bug'', it's not obvious how to do it without compromising
-% this underlying philosophy, i.e.\ without using \LaTeX{} code that is
-% unlikely to be supported by journals.
+% fix these ``bugs'', it's almost certainly impossible without using
+% low-level \LaTeX{} code that is unlikely to be supported by journals,
+% thereby defeating the whole purpose of the \option{poorman} option.
% \end{itemize}
%
%
%
-% \section{Possible Future Improvements}
-% In no particular order.
+% \subsection{Possible Improvements}
+% In no particular order:
% \begin{itemize}
-% \item Allow reference-range collapsing to be disabled entirely via a
-% package option
-% \item Add an option to automatically sort references in a
-% multi-reference before typesetting them.
-% \item Enhance the \option{poorman} option to allow a choice of script
-% language rather than just sed (e.g.\ awk, perl, \dots?).
+% \item The \option{poorman} option could be enhanced to allow a choice
+% of scripting language rather than just |sed| (e.g.\ |awk|, |perl|,
+% \dots?), but these are unlikely to be much better for those apt to
+% complain about the use of |sed|. The portable option would be to
+% output a \TeX{} ``script'', but this would be a \emph{much} more
+% work\footnote{\LaTeX{} \emph{really} isn't suited to that kind of
+% pattern matching task -- just take a look at the code for escaping
+% regexp special characters in this package!} than I'm prepared to
+% invest.
% \end{itemize}
%
%
%
-% \StopEventually{\PrintIndex}
-%
+% \StopEventually{\clearpage\PrintChanges\clearpage\PrintIndex}
%
%
+% \clearpage
% \section{Implementation}
% Essentially, the core of the implementation consists of causing an
% extra piece of information -- the label ``type'' -- to be written to
% the aux file, and defining \cmd{\cref} commands which use this extra
-% information to typeset the reference.
+% information to type-set the reference.
%
-% The least invasive implementation seems to be that used by the
-% \package{varioref} package. Namely, to redefine the
+% The least invasive implementation of this kind of thing seems to be
+% that used by the \package{varioref} package. Namely, to redefine the
% \cmd{\refstepcounter} command so that the \cmd{\@currentlabel} macro,
-% which usually just cotains the typeset version of the counter, now
+% which usually just contains the type-set version of the counter, now
% contains the additional type information. (In fact, we write three
% extra pieces of information: the type, the counter value itself, and
-% the formatted version of the counter that causes the label's counter to
-% be reset, which we call the ``prefix'' from now on.)
-% \cmd{\@currentlabel} eventually gets written to the aux file as an
-% argument to \cmd{\newlabel} by the usual \LaTeX{} mechanisms. This
-% involves less hacking to get everything else working again, since very
-% few macros other than \cmd{\ref} use this particular \cmd{\newlabel}
-% argument (nor are other packages likely to, given that
-% \package{varioref} is a \texttt{required} \LaTeX{} package).
+% the value of the counter that causes the label's counter to be reset,
+% which we call the ``prefix'' from now on.) \cmd{\@currentlabel}
+% eventually gets written to the aux file as an argument to
+% \cmd{\newlabel} by the usual \LaTeX{} mechanisms. This involves less
+% hacking to get everything else working again, since very few macros
+% other than \cmd{\ref} rely on this particular \cmd{\newlabel} argument
+% (nor are other packages likely to, given that \package{varioref} plays
+% around with it and is a \texttt{required} \LaTeX{} package).
%
%
% \subsection{Redefinitions of \LaTeX{} kernel macros}
-% We store the original \cmd{\refstepcounter} in
-% \cmd{\cref@old@refstepcounter}, then redefine \cmd{\refstepcounter} so
-% that it first calls the old version and then adds the extra information
-% to \cmd{\@currentlabel}. The new \cmd{\@refstepcounter} can take an
-% optional argument, which overrides using the counter name as the
-% ``type'' and instead uses whatever is supplied.
+% \begin{macro}{\refstepcounter}
+% \begin{macro}{\@currentlabel}
+% \begin{macro}{\cref@old@refstepcounter}
+% We store the original \cmd{\refstepcounter} in
+% \cmd{\cref@old@refstepcounter}, then redefine \cmd{\refstepcounter}
+% so that it first calls the old version before adding the extra
+% information to \cmd{\@currentlabel}. The new \cmd{\@refstepcounter}
+% can take an optional argument, which overrides the default ``type''
+% inferred from the counter.
% \begin{macrocode}
\let\cref@old@refstepcounter\refstepcounter
\def\refstepcounter{%
@@ -980,25 +1200,29 @@
}
\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%
+ \cref@constructprefix{#1}{\@result}%
\protected@edef\@currentlabel{%
- [#1][\arabic{#1}][\@result]\@currentlabel}}
+ [#1][\arabic{#1}][\@result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}
\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%
+ \cref@constructprefix{#2}{\@result}%
\protected@edef\@currentlabel{%
[#1][\arabic{#2}][\@result]\@currentlabel}}
% \end{macrocode}
-%
-% We redefine the \cmd{\label} command to allow it to take an optional
-% argument that overrides the default reference type in
-% \cmd{\@currentlabel}. We have to postpone this redefinition of
-% \cmd{\label} until the beginning of the document because some other
-% packages do too, and we need to override their redefinitions.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\label}
+% \begin{macro}{\cref@override@label@type}
+% We redefine the \cmd{\label} command to allow it to take an optional
+% argument that overrides the default reference type in
+% \cmd{\@currentlabel}. We have to postpone this redefinition of
+% \cmd{\label} until the beginning of the document because some other
+% packages do too, and we need to override their
+% redefinitions. \cmd{\cref@override@label@type} is a convenience macro
+% for overriding the label type stored in \cmd{\@currentlabel}.
% \begin{macrocode}
\def\cref@override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
\AtBeginDocument{%
@@ -1009,47 +1233,73 @@
\expandafter\cref@override@label@type\@currentlabel\@nil{#1}}%
\cref@old@label}%
% \end{macrocode}
-%
-% The \package{amsmath} package redefines the \cmd{\label} command within
-% equation environments, so if it is loaded we have to extend the
-% behaviour to support the optional argument. With \package{amsmath}, the
-% original \cmd{\label} command in stored in \cmd{ltx@label}, and
-% \cmd{\label@in@display} replaces \cmd{label} inside
-% equations. \cmd{\label@in@display} just saves the label for later, and
-% defining it is left until the end of the equation, when
-% \cmd{\ltx@label} is finally called.
-%
-% To allow \cmd{label} within equations to support an optional argument,
-% we first store the original \cmd{\label@in@display} and the new
-% \cmd{\label} macro we defined above (since \cmd{\label} will be
-% clobbered inside equations). Then we redefine \cmd{label@in@display} so
-% that it wraps all its arguments, including any optional argument, in an
-% extra set of braces \{\}. These are stripped away again by
-% \cmd{\ltx@label} before calling the \cmd{\label} macro we defined above
-% (saved in \cmd{\cref@label}).
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{amsmath}
+% \begin{macro}{\label}
+% \begin{macro}{\label@in@display}
+% The \package{amsmath} package redefines the \cmd{\label} command
+% within equation environments, so if it is loaded we have to extend
+% the behaviour to support the optional argument. With
+% \package{amsmath}, the original \cmd{\label} command is stored in
+% \cmd{\ltx@label}, and \cmd{\label@in@display} replaces \cmd{label}
+% inside equations. \cmd{\label@in@display} just saves the label for
+% later, and defining it is left until the end of the equation, when
+% \cmd{\ltx@label} is finally called.
+%
+% To allow \cmd{\label} within equations to support an optional
+% argument, we first store the original \cmd{\label@in@display} and the
+% new \cmd{\label} macro we defined above (since \cmd{\label} will be
+% clobbered inside equations). Then we redefine \cmd{label@in@display}
+% so that it wraps all its arguments, including any optional argument,
+% in an extra set of braces. These are stripped away again by
+% \cmd{\ltx@label} before calling the \cmd{\label} macro we defined
+% above (saved in \cmd{\cref@label}).
% \begin{macrocode}
\@ifpackageloaded{amsmath}{%
- \let\cref@label\label%
- \let\cref@old@label@in@display\label@in@display%
+ \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\ltx@label#1{\cref@label#1}
+ \let\cref@old@make@df@tag@@\make@df@tag@@
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macro}{\make@df@tag@@}
+% \begin{macro}{\make@df@tag@@@}
+% We override the internals of the \package{amsmath} \cmd{\tag} command
+% to add the additional information to the label definition.
+% \begin{macrocode}
+ \def\make@df@tag@@#1{%
+ \gdef\df@tag{\maketag@@@{#1}%
+ \def\@currentlabel{[equation][][]#1}}}
+ \def\make@df@tag@@@#1{%
+ \gdef\df@tag{\tagform@{#1}%
+ \toks@\@xp{\p@equation{#1}}%
+ \edef\@currentlabel{[equation][][]\the\toks@}}}
}{}%
}
% \end{macrocode}
-%
-% The standard \cmd{\ref} macro spits out whatever was in
-% \cmd{\@currentlabel} when the label was written to the aux file, but
-% this now contains the additional type information which we don't
-% want. Therefore, we redefine \cmd{\cref} to recover the original
-% behaviour. We have to defer redefinition of \cmd{\ref} till the
-% beginning of the document, in case other packages (such as
-% \package{ntheorem}) modify it after \package{cleveref} is loaded. We
-% add a level of redirection to make it easier in case we need to
-% redefine it for \package{hyperref} later.
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ref}
+% The standard \cmd{\ref} macro spits out whatever was in
+% \cmd{\@currentlabel} when the label was written to the aux file, but
+% this now contains additional information which we don't
+% want. Therefore, we redefine \cmd{\ref} to recover the original
+% behaviour. We have to defer redefinition of \cmd{\ref} till the
+% beginning of the document, in case other packages (such as
+% \package{ntheorem}) modify it after \package{cleveref} is loaded. The
+% apparently pointless \cmd{\cref@reflabel} adds a leyer of indirection
+% to make it easier in case we need to redefine it for
+% \package{hyperref} later.
% \begin{macrocode}
\def\cref@reflabel#1#2{\@result}
\AtBeginDocument{%
@@ -1063,69 +1313,131 @@
\expandafter\@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
}
% \end{macrocode}
-%
-% The \cmd{\appendix} command causes the top-level sectioning commands
-% (\cmd{\chapter} or \cmd{\section}, depending on the document class) to
-% produce appendices instead. Since we want to be able to format
-% references to appendices separately from references to normal top-level
-% sections, we add to the tasks that \cmd{\appendix} does: it redefines
-% \cmd{\refstepcounter@noarg} to exceptionally override the label type
-% for chapters or sections, as appropriate, setting it to ``appendix''
-% instead.
+% \end{macro}
+%
+% \begin{macro}{\appendix}
+% \begin{macro}{\cref@old@appendix}
+% The \cmd{\appendix} command causes the top-level sectioning commands
+% (\cmd{\chapter} or \cmd{\section}, depending on the document class)
+% to produce appendices instead. Since we want to be able to format
+% references to appendices separately from references to normal
+% top-level sections, we add to the tasks that \cmd{\appendix} does: it
+% redefines \cmd{\refstepcounter@noarg} to exceptionally override the
+% label type for chapters or sections, as appropriate, setting it to
+% ``appendix'' instead. There are two alternative definitions: one if
+% ``section'' is the top-level sectioning command, and one if
+% ``chapter'' fulfils that role.
% \begin{macrocode}
\let\cref@old@appendix\appendix
\renewcommand\appendix{%
\cref@old@appendix%
\@ifundefined{chapter}{%
- \def\refstepcounter@noarg##1{%
+ \gdef\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}
+ \cref@constructprefix{##1}{\@result}%
+% \end{macrocode}
+% We add a large value to the front of the counter data, to force
+% references to anything in appendices to be sorted after everything
+% else.
+% \begin{macrocode}
+ \edef\@result{{2147483647}\@result}%
+% \end{macrocode}
+% Override the cross-reference type of sectioning commands.
+% \begin{macrocode}
+ \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}
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]\@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \@currentlabel}%
+ \else%
+ \protected@edef\@currentlabel{%
+ [##1][\arabic{##1}][\@result]\@currentlabel}%
+ \fi%
+ \fi%
+ \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}
+ \cref@constructprefix{##1}{\@result}%
+% \end{macrocode}
+% Again, the large value added to the front of the counter data forces
+% references to appendix items to be sorted last.
+% \begin{macrocode}
+ \edef\@result{{2147483647}\@result}%
+% \end{macrocode}
+% Override the cross-reference type of sectioning commands.
+% \begin{macrocode}
+ \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}
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{section}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]\@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubsubappendix][\arabic{##1}]%
+ [\@result]\@currentlabel}%
+ \else%
+ \protected@edef\@currentlabel{%
+ [##1][\arabic{##1}][\@result]\@currentlabel}%
+ \fi%
+ \fi%
+ \fi%
\fi}%
}%
}
% \end{macrocode}
+% \end{macro}
+% \end{macro}
%
%
% \subsection{Utility Macros}
-% Define some utility macros for extracting label, type, and counter
-% information from the contents of \cmd{\@currentlabel}, as written to
-% the aux file and stored in \cmd{\r@\meta{label}} when this is re-read
-% on the next pass. Some other packages commandeer the referencing system
-% to write label information to the aux file for other purposes, and
-% probably use \cmd{\ref} to recover it later. We still want them to
-% work, so our utility macros must cope with the type information being
-% absent. However, since we need them to be fully expandable in various
-% places, and \cmd{\@ifnextchar} is definitely \emph{not} fully
-% expandable, we use the work-around of having the macros store their
-% result in another macro, whose name is passed as the second
-% argument. This other macro \emph{will} then be fully expandable, and
-% can be used e.g.\ inside an \cmd{\edef} or
-% \cmd{\csname}\ldots\cmd{\endcsname}.
+% \begin{macro}{\cref@getlabel}
+% \begin{macro}{\cref@gettype}
+% \begin{macro}{\cref@getcounter}
+% \begin{macro}{\cref@getprefix}
+% Define some utility macros for extracting label, type, and counter
+% information from the contents of \cmd{\@currentlabel}, as written to
+% the aux file and stored in \cmd{\r@\meta{label}} when this is re-read
+% on the next pass. Some other packages commandeer the referencing
+% system to write label information to the aux file for other purposes,
+% and probably use \cmd{\ref} to recover it later. We still want them
+% to work, so our utility macros must cope with the type information
+% being absent. However, since we need them to be fully expandable in
+% various places, and \cmd{\@ifnextchar} is definitely \emph{not} fully
+% expandable, we use the work-around of having the macros store their
+% result in another macro, whose name is passed as the second
+% argument. This other macro \emph{will} then be fully expandable, and
+% can be used e.g.\ inside an \cmd{\edef} or
+% \cmd{\csname}\ldots\cmd{\endcsname}.
% \begin{macrocode}
\def\cref@getlabel#1#2{%
\expandafter\let\expandafter\@tmpa\csname r@#1\endcsname%
@@ -1156,29 +1468,220 @@
\@@cref@getprefix{\@@cref@getprefix[][][]}}
\def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cref@constructprefix}
+% The \cmd{\cref@constructprefix} macro constructs the prefix
+% information stored in \cmd{\@currentlabel} (retrieved using
+% \cmd{\cref@getprefix}). This information consists of the numerical
+% value of each counter that's involved in resetting the label's
+% counter, i.e.\ it contains the numerical values of the chapter,
+% section, subsection\dots numbers that (ought to) make up the
+% formatted label produced by \cmd{\the\meta{counter}}. E.g. if
+% \cmd{\theequation} produces ``B.1.3'', this utility macro will return
+% ``[2][1]'' (the ``3'' corresponds to the equation number itself,
+% which is stored separately in \cmd{\@currentlabel}). The first
+% argument is the counter in question; the return value is stored in
+% the second argument, which should be a macro name.
+%
+% The real work is done by the recursive \cmd{\@cref@constructprefix}
+% macro, which works its way upwards through the counters' reset lists
+% until it reaches a counter that isn't reset by any other.
+% \begin{macrocode}
+\def\cref@constructprefix#1#2{%
+% \end{macrocode}
+% We fully expand the first argument (the counter name) because sometimes
+% a counter name containing a macro gets passed to us.
+% \begin{macrocode}
+ \edef\@tmpa{\noexpand{\noexpand}\noexpand{#1\noexpand}}%
+ \expandafter\def\expandafter\@tmpa\expandafter{\@tmpa{#2}}%
+ \expandafter\@cref@constructprefix\@tmpa}
+\def\@cref@constructprefix#1#2#3{%
+ \cref@resetby{#2}{#3}%
+ \ifx#3\relax%
+ \edef#3{#1}%
+ \else%
+ \edef\@tmpa{{{\the\csname c@#3\endcsname}#1}{#3}}%
+ \expandafter\expandafter\expandafter\@cref@constructprefix%
+ \expandafter\@tmpa\expandafter{\expandafter#3\expandafter}%
+ \fi}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cref@countercmp}
+% The \cmd{\cref@countercmp} macro compares two sets of counter data,
+% as returned by \cmd{\cref@getcounter}, and \cmd{\chardef}'s its third
+% argument to 0 if they're equal, 1 if the first comes earlier than the
+% second, or 2 if the first comes later than the second. This is used
+% later for sorting references.
+% \begin{macrocode}
+\def\cref@counter@first#1#2\@nil{#1}
+\def\cref@counter@rest#1#2\@nil{#2}
+\def\cref@countercmp#1#2#3{%
+ \begingroup%
+ \def\@tmpa{#1}%
+% \end{macrocode}
+% In order to ensure empty references end up in the right place when
+% sorting lists of multiple references, we make the comparison macro
+% sorts them before a non-empty reference.
+% \begin{macrocode}
+ \ifx\@tmpa\@empty%
+ \def\@result{1}%
+ \else%
+ \def\@tmpa{#2}%
+ \ifx\@tmpa\@empty%
+ \def\@result{2}%
+ \else%
+% \end{macrocode}
+% Conversely, undefined references come after everything else.
+% \begin{macrocode}
+ \expandafter\ifx\csname r@#1\endcsname\relax%
+ \def\@result{2}%
+ \else%
+ \expandafter\ifx\csname r@#2\endcsname\relax%
+ \def\@result{1}%
+ \else%
+% \end{macrocode}
+% The real work of comparing two references is done by
+% \cmd{\@cref@countercmp}.
+% \begin{macrocode}
+ \cref@getcounter{#1}{\@countera}%
+ \cref@getprefix{#1}{\@prefixa}%
+ \cref@getcounter{#2}{\@counterb}%
+ \cref@getprefix{#2}{\@prefixb}%
+ \edef\@tmpa{{\@prefixa{\@countera}}{\@prefixb{\@counterb}}}%
+ \expandafter\@cref@countercmp\@tmpa%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \expandafter\endgroup\expandafter%
+ \chardef\expandafter#3\expandafter=\@result\relax}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\cref@countercmp}
+% The \cmd{\@cref@countercmp} macro recursively compares counter
+% components until it runs out of components for one of the references,
+% or finds an two corresponding components that are unequel.
+% \begin{macrocode}
+\def\@cref@countercmp#1#2{%
+ \let\@iterate\relax%
+ \def\@counta{#1}%
+ \def\@countb{#2}%
+ \ifx\@counta\@empty%
+ \ifx\@countb\@empty%
+ \def\@result{0}%
+ \else%
+ \def\@result{1}%
+ \fi%
+ \else%
+ \ifx\@countb\@empty%
+ \def\@result{2}%
+ \else%
+ \edef\@counta{\cref@counter@first#1\@nil}%
+ \edef\@countb{\cref@counter@first#2\@nil}%
+ \ifnum\@counta<\@countb\relax%
+ \def\@result{1}%
+ \else%
+ \ifnum\@counta>\@countb\relax%
+ \def\@result{2}%
+ \else%
+ \edef\@counta{\cref@counter@rest#1\@nil}%
+ \edef\@countb{\cref@counter@rest#2\@nil}%
+ \edef\@counta{{\@counta}{\@countb}}%
+ \expandafter\def\expandafter\@iterate\expandafter{%
+ \expandafter\@cref@countercmp\@counta}%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \@iterate}
+% \end{macrocode}
+% \end{macro}
%
-% A basic utility macro for appending tokens to a token register.
+% \begin{macro}{\cref@append@toks}
+% A basic utility macro for appending tokens to a token register.
% \begin{macrocode}
\def\cref@append@toks#1#2{\toks0={#2}%
\edef\act{\noexpand#1={\the#1\the\toks0}}%
\act}%
% \end{macrocode}
-%
-% We treat multiple references, supplied as a comma-separated list to
-% \cmd{\cref} or \cmd{\Cref}, as a stack structure. So we define some
-% utility macros for manipulating stacks (\cmd{\@nil} is used as an
-% end-of-stack delimeter).
+% \end{macro}
+%
+% \begin{macro}{\cref@stack@init}
+% \begin{macro}{\cref@stack@top}
+% \begin{macro}{\cref@stack@pop}
+% \begin{macro}{\cref@stack@push}
+% \begin{macro}{\cref@stack@topandbottom}
+% \begin{macro}{\cref@stack@add}
+% We treat multiple references, supplied as a comma-separated list to
+% \cmd{\cref} or \cmd{\Cref}, as a stack structure. So we define some
+% utility macros for manipulating stacks (\cmd{\@nil} is used as an
+% end-of-stack delimeter).
% \begin{macrocode}
\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@top#1{\expandafter\@cref@stack@top#1}
+\def\@cref@stack@top#1,#2\@nil{#1}
+\def\cref@stack@pop#1{\expandafter\@cref@stack@pop#1#1}
+\def\@cref@stack@pop#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}}
+ \expandafter\@cref@stack@push\expandafter{#2}{#1}{#2}}
+\def\@cref@stack@push#1#2#3{\def#3{#2,#1}}
+\def\cref@stack@pull#1#2{\expandafter\@cref@stack@pull#2{#1}{#2}}
+\def\@cref@stack@pull#1\@nil#2#3{\def#3{#1#2,\@nil}}
+\def\cref@stack@topandbottom#1#2#3{%
+ \def#2{}%
+ \def#3{}%
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef#2{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \cref@isstackfull{#1}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef#3{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \cref@isstackfull{#1}}%
+ \fi}
+\def\cref@stack@add#1#2{%
+ \begingroup%
+ \def\@arg1{#1}%
+ \let\@tmpstack#2%
+ \newif\if@notthere%
+ \@nottheretrue%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@tmpb{\cref@stack@top{\@tmpstack}}%
+ \def\@tmpa{#1}%
+ \ifx\@tmpa\@tmpb%
+ \@cref@stackfullfalse%
+ \@nottherefalse%
+ \else%
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}%
+ \fi
+ }%
+ \expandafter\endgroup%
+ \if@notthere\cref@stack@push{#1}{#2}\fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\if@cref@stackempty}
+% \begin{macro}{\if@cref@stackfull}
+% \begin{macro}{\cref@isstackempty}
+% \begin{macro}{\cref@isstackfull}
+% The \cmd{\cref@isstackempty} and \cmd{\cref@isstackfull} macros test
+% whether a stack is empty or full, respectively, and set the
+% corresponding conditionals\linebreak[4] |\if@cref@stackempty| and
+% |\if@cref@stackfull|.
+% \begin{macrocode}
\newif\if@cref@stackempty
\newif\if@cref@stackfull
\def\cref@isstackempty#1{%
@@ -1190,67 +1693,242 @@
\ifx#1\@tmpa\@cref@stackfullfalse%
\else\@cref@stackfulltrue\fi}
% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cref@stack@sort}
+% The \cmd{\cref@stack@sort} macro sorts a stack, using the comparison
+% macro passed in the second argument, which we use later to sort lists
+% of references. We use insertion sort despite its $O(n^2)$ scaling
+% because it's simpler to code, and because we're very unlikely to
+% encounter lists of more than ten or so referrences, so in practice a
+% more complicated $O(n\log n)$ sorting algorithm will very likely be
+% slower anyway.
+% \begin{macrocode}
+\def\cref@stack@sort#1#2{%
+ \begingroup%
+ \cref@stack@init{\@sortstack}%
+% \end{macrocode}
+% Push first element into sorted stack.
+% \begin{macrocode}
+ \edef\@element{\cref@stack@top{#1}}%
+ \expandafter\cref@stack@push\expandafter{\@element}{\@sortstack}%
+ \cref@stack@pop{#1}%
+% \end{macrocode}
+% If empty elements follow first one, need to add them after it in sorted
+% stack.
+% \begin{macrocode}
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \@whilesw\ifx\@tmpa\@empty\fi{%
+ \cref@stack@pull{}{\@sortstack}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@tmpa\relax%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \fi}%
+ \fi%
+% \end{macrocode}
+% Process elements from stack.
+% \begin{macrocode}
+ \cref@isstackfull{#1}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@element{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+% \end{macrocode}
+% If empty elements follow current one, need to add them to sorted stack,
+% right after element we're currently dealing with.
+% \begin{macrocode}
+ \def\@empties{}%
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \@whilesw\ifx\@tmpa\@empty\fi{%
+ \edef\@empties{\@empties,}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@tmpa\relax%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \fi}%
+ \fi%
+% \end{macrocode}
+% Insert current element into sorted stack, appending any following empty
+% elements.
+% \begin{macrocode}
+ \edef\@tmpa{{\expandafter\noexpand\@element}%
+ {\expandafter\noexpand\@empties}%
+ {\noexpand\@sortstack}{\noexpand#2}}%
+ \expandafter\cref@stack@insert\@tmpa%
+ \cref@isstackfull{#1}}%
+ \expandafter\endgroup\expandafter%
+ \def\expandafter#1\expandafter{\@sortstack}}
+% \end{macrocode}
+% \end{macro}
%
-% We need to be able to determine which counter is used to reset a given
-% counter. Usually, resets are done by sectioning counters, and we assume
-% that to be the case here. \cmd{\isinresetlist} searches through one
-% counter's reset list, stored in \cmd{\cl@\meta{counter}}, to determine
-% whether another counter appears there, and sets the new conditional
-% appropriately. \cmd{\reset@by} searches through all the sectioning
-% counters' reset lists, from lowest-level (subsubsection) to highest
-% (part), checking whether the given counter is in the list, and returns
-% the first sectioning counter whose list it appears (value is returned
-% by defining its second argument, which should be a macro name).
+% \begin{macro}{\cref@stack@insert}
+% \cmd{\cref@stack@insert}|{#1}{#2}{#3}{#4}| inserts |#1| into the
+% appropriate location in the sorted stack |#3| (appending |#2| onto
+% the end of |#1| when it's inserted), using the comparison macro |#4|.
+% \begin{macrocode}
+\def\cref@stack@insert#1#2#3#4{%
+ \let\@cmp#4%
+ \@cref@stack@insert{}{#1}{#2}{#3}%
+ \cref@stack@pop{#3}}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\@cref@stack@insert}
+% \cmd{\@cref@stack@insert}|{#1}{#2}{#3}{#4}| prepends |#1| to the
+% stack resulting from inserting |#2| (with |#3| appended to it) into
+% the sorted stack |#4|.
+% \begin{macrocode}
+\def\@cref@stack@insert#1#2#3#4{%
+ \let\@iterate\relax%
+ \cref@isstackempty{#4}%
+ \if@cref@stackempty%
+ \cref@stack@push{#1,#2#3}{#4}%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#4}}%
+ \expandafter\@cmp\expandafter{\@tmpa}{#2}{\@result}%
+ \ifnum\@result=2\relax%
+ \cref@stack@push{#1,#2#3}{#4}%
+ \else%
+ \cref@stack@pop{#4}%
+ \edef\@tmpa{{\noexpand#1,\@tmpa}{\noexpand#2}%
+ {\noexpand#3}{\noexpand#4}}%
+ \expandafter\def\expandafter\@iterate\expandafter%
+ {\expandafter\@cref@stack@insert\@tmpa}%
+ \fi%
+ \fi%
+ \@iterate}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\if@cref@inresetlist}
+% \begin{macro}{\cref@isinresetlist}
+% \begin{macro}{\cref@resetby}
+% We need to be able to determine which counter is used to reset a
+% given counter. Usually, resets are done by sectioning counters, and
+% we assume that to be the case here. \cmd{\cref@isinresetlist}
+% searches through one counter's reset list, stored in
+% \cmd{\cl@\meta{counter}}, to determine whether another counter
+% appears there, and sets the new conditional
+% appropriately. \cmd{\cref@reset@by} searches through all the
+% sectioning counters' reset lists, from lowest-level (subsubsection)
+% to highest (part), checking whether the given counter is in the list,
+% and returns the first sectioning counter in whose list it appears.
+% (The value is returned by defining its second argument, which should
+% be a macro name.)
% \begin{macrocode}
\newif\if@cref@inresetlist
\def\cref@isinresetlist#1#2{%
- \def\@counter{#1}%
\begingroup%
+ \def\@counter{#1}%
+% \end{macrocode}
+% We locally redefine \cmd{\@elt}, which appears at the head of the
+% expansion of |\cl@|\meta{counter}, so that entries in the reset list
+% end up separated by commas, thus can be treated as a stack.
+% \begin{macrocode}
\def\@elt##1{##1,}%
\expandafter\ifx\csname cl@#2\endcsname\relax%
- \gdef\cref@resetstack{,\@nil}%
+ \def\cref@resetstack{,\@nil}%
\else%
- \xdef\cref@resetstack{\csname cl@#2\endcsname\noexpand\@nil}%
+ \edef\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%
+ \let\@nextcounter\relax%
+ \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%
+ \def\@next{\@cref@inresetlistfalse}%
\else%
- \let\@nextcounter\relax%
- \cref@stack@pop{\cref@resetstack}%
- \cref@isstackfull{\cref@resetstack}%
- \fi}%
- \ifx\@nextcounter\relax%
- \@cref@inresetlistfalse%
- \else%
- \@cref@inresetlisttrue%
- \fi}
+ \def\@next{\@cref@inresetlisttrue}%
+ \fi%
+ \expandafter%
+ \endgroup%
+ \@next}
+% \end{macrocode}
%
+% FIXME: We could easily remove the hard-coded search order in
+% \cmd{\cref@resetby} and, say, replace it with a customisable list of
+% counters to search in order. But so far I've yet to encounter a need
+% for anything other than the hard-coded default.
+% \begin{macrocode}
\def\cref@resetby#1#2{%
- \cref@isinresetlist{#1}{subsubsubsection}%
- \if@cref@inresetlist%
- \def#2{subsubsubsection}%
- \else%
- \cref@isinresetlist{#1}{subsubsection}%
+ \let#2\relax%
+ \def\@tmpa{#1}%
+% \end{macrocode}
+% If counter in question is |subfigure| or |subtable|, check if it's
+% reset by |figure| or |table|, respectively.
+% \begin{macrocode}
+ \def\@tmpb{subfigure}%
+ \ifx\@tmpa\@tmpb%
+ \cref@isinresetlist{#1}{figure}%
\if@cref@inresetlist%
- \def#2{subsubsection}%
+ \def#2{figure}%
+ \fi%
+ \fi%
+ \def\@tmpa{#1}%
+ \def\@tmpb{subtable}%
+ \ifx\@tmpa\@tmpb%
+ \cref@isinresetlist{#1}{table}%
+ \if@cref@inresetlist%
+ \def#2{table}%
+ \fi%
+ \fi%
+% \end{macrocode}
+% If counter in question is |enum|\meta{x}, check if it's reset by a
+% higher-level |enum|\meta{x}.
+% \begin{macrocode}
+ \def\@tmpa{#1}%
+ \def\@tmpb{enumii}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumiii}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumiv}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumv}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enum}%
+ \ifx#2\@tmpb%
+ \cref@isinresetlist{#1}{enumiv}%
+ \if@cref@inresetlist%
+ \def#2{enumiv}%
\else%
- \cref@isinresetlist{#1}{subsection}%
+ \cref@isinresetlist{#1}{enumiii}%
\if@cref@inresetlist%
- \def#2{subsection}%
+ \def#2{enumiii}%
\else%
- \cref@isinresetlist{#1}{section}%
+ \cref@isinresetlist{#1}{enumii}%
\if@cref@inresetlist%
- \def#2{section}%
+ \def#2{enumii}%
\else%
- \cref@isinresetlist{#1}{chapter}%
+ \cref@isinresetlist{#1}{enumi}%
\if@cref@inresetlist%
- \def#2{chapter}%
+ \def#2{enumi}%
\else%
- \cref@isinresetlist{#1}{part}%
+ \cref@isinresetlist{#1}{part}%
\if@cref@inresetlist%
\def#2{part}%
\else%
@@ -1260,367 +1938,529 @@
\fi%
\fi%
\fi%
- \fi}
+ \fi%
% \end{macrocode}
-%
-%
-% \subsection{Referencing Commands}
-% Define the main referencing macros \cmd{\cref} and the
-% start-of-sentence variant \cmd{\Cref}.
+% If we haven't found anything so far, check if it's reset by a
+% sectioning command.
% \begin{macrocode}
-\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}{}}
+ \ifx#2\relax%
+ \cref@isinresetlist{#1}{table}%
+ \if@cref@inresetlist%
+ \def#2{table}%
+ \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%
+ \fi}
% \end{macrocode}
-% To save duplicating code, the referencing macros pass an argument
-% determining the variant to an auxilliary macro \cmd{\@cref}, which does
-% the real work. The \cmd{\@cref} macro is the behemoth at the heart of
-% all the smart referencing features. It deals with grouping references
-% by type, typesetting the conjunctions between groups, choosing the
-% right formatting macro to use for each reference, and collapsing
-% consecutive references into ranges.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\if@cref@refconsecutive}
+% \begin{macro}{\cref@isrefconsecutive}
+% Define a new conditional to test whether two references are
+% consecutive (needed when type-setting reference ranges). This uses the
+% counter and prefix (i.e. formatted version of the counter that resets
+% the label's counter) information provided by \cmd{\r@\meta{label}}
+% (via the aux file) to check if the prefices are identical (i.e. the
+% references come from the same chapter, section or whatever), and that
+% the label counters differ by 0 or 1.
% \begin{macrocode}
-\def\@cref#1#2{%
+\newif\if@cref@refconsecutive%
+\def\cref@isrefconsecutive#1#2{%
\begingroup%
-% \end{macrocode}
-% Initialise some things, and put all the references into a stack called
-% \cmd{\@refstack}.
-% \begin{macrocode}
- \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}%
-% \end{macrocode}
-% Loop until the reference stack is empty.
-% \begin{macrocode}
- \@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}%
+ \countdef\refa@counter=0%
+ \countdef\refb@counter=1%
+ \cref@getcounter{#1}{\@result}%
+ \refa@counter=\@result%
+ \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\relax%
+ \def\@after{\@cref@refconsecutivetrue}%
+ \else%
+ \advance\refa@counter 1\relax%
+ \ifnum\refa@counter=\refb@counter\relax%
+ \def\@after{\@cref@refconsecutivetrue}%
+ \fi%
+ \fi%
\fi%
- \let\@nexttype\@currenttype%
+ \expandafter\endgroup\@after}
% \end{macrocode}
-% Move references from \cmd{\@refstack} into a different stack called
-% \cmd{\@refsubstack}, until we encounter a reference that has a
-% different type to those that came before.
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cref@processgroup}
+% \cmd{\cref@processgroup} processes the first group of references from
+% the stack passed in argument |#1|, by moving references to the stack
+% passed in argument |#2| until it encounters a reference that has a
+% different type to those that came before. Note that empty references
+% are treated as having the same type as the preceding one.
% \begin{macrocode}
- \@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}%
+\def\cref@processgroup#1#2{%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@groupformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@grouptype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
+ \fi%
+ \let\@nexttype\@grouptype%
+ \let\@nextformat\@groupformat%
+%
+ \@whilesw\ifx\@nextformat\@groupformat\fi{%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@nexttype\relax%
+ \let\@nextformat\relax%
+ \else%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \ifx\@nextref\@empty%
+ \let\@nexttype\@grouptype%
+ \let\@nextforamt\@groupformat%
\else%
- \edef\@nextref{\cref@stack@top{\@refstack}}%
- \ifx\@nextref\@empty%
- \let\@currenttype\@nexttype%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@nexttype{\@undefined}%
+ \def\@nextformat{\@undefined}%
\else%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
- \def\@currenttype{\@undefined}%
+ \expandafter\cref@gettype\expandafter%
+ {\@nextref}{\@nexttype}%
+ \def\@tmpa{\@undefined}%
+ \ifx\@nexttype\@tmpa%
+ \def\@nextformat{\@undefined}%
\else%
- \expandafter\cref@gettype\expandafter%
- {\@nextref}{\@currenttype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@nextformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@nexttype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
\fi%
\fi%
- \fi}%
+ \fi%
+ \fi}%
+}
% \end{macrocode}
+% \end{macro}
%
-% Typeset appropriate conjunction between groups of reference types.
+% \begin{macro}{\cref@processgroupall}
+% \cmd{\cref@processgroupall} processes the first group of references
+% from the stack passed in argument |#1|, by moving all references with
+% the same type as the first one into the stack passed in argument
+% |#2|.
% \begin{macrocode}
- \if@firstgroup%
- \@firstgroupfalse%
- \@secondgrouptrue%
+\def\cref@processgroupall#1#2{%
+ \cref@stack@init{\@tmpstack}%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@groupformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@grouptype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
+ \fi%
+ \let\@lasttype\@grouptype%
+ \let\@lastformat\@groupformat%
+ \cref@isstackfull{#1}%
+%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \ifx\@nextref\@empty%
+ \ifx\@lastformat\@groupformat%
+ \let\@nexttype\@grouptype%
+ \let\@nextformat\@groupformat%
+ \else%
+ \let\@nexttype\relax%
+ \let\@nextformat\relax%
+ \fi%
\else%
- \cref@isstackfull{\@refstack}%
- \if@cref@stackfull%
- \@setcref@middlegroupconjunction%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@nexttype{\@undefined}%
+ \def\@nextformat{\@undefined}%
\else%
- \if@secondgroup%
- \@setcref@pairgroupconjunction%
+ \expandafter\cref@gettype\expandafter%
+ {\@nextref}{\@nexttype}%
+ \def\@tmpa{\@undefined}%
+ \ifx\@nexttype\@tmpa%
+ \def\@nextformat{\@undefined}%
\else%
- \@setcref@lastgroupconjunction%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@nextformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@nexttype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
\fi%
\fi%
- \@secondgroupfalse%
\fi%
-% \end{macrocode}
%
-% Process first group of consecutive references from substack.
+ \ifx\@nextformat\@groupformat%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}%
+ \else%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{\@tmpstack}%
+ \fi%
+ \cref@stack@pop{#1}%
+ \let\@lasttype\@nexttype%
+ \let\@lastformat\@nextformat%
+ \cref@isstackfull{#1}}%
+ \let#1\@tmpstack}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\cref@processconsecutive}
+% \cmd{\cref@processconsecutive} processes the first sequence of
+% consecutive references from the stack passed in |#1|, sets the macro
+% passed as |#2| to the first reference in the sequence, sets |#3| to
+% the last reference, and sets the counter passed in |#4| to the number
+% of consecutive references in the sequence.
% \begin{macrocode}
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \cref@stack@pop{\@refsubstack}%
+\def\cref@processconsecutive#1#2#3#4{%
+ #4=0%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
% \end{macrocode}
-% If the substack only contains one reference, typeset it,
+% If stack only contains one reference, set appropriate return values.
% \begin{macrocode}
- \cref@isstackempty{\@refsubstack}%
- \if@cref@stackempty%
- \expandafter\@setcref\expandafter{\@nextref}{#1}{}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ #4=1\relax%
% \end{macrocode}
-% otherwise, find end of consecutive references.
+% If stack contains multiple references, find end of consecutive references.
% \begin{macrocode}
+ \else%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ #4=1\relax%
+ \expandafter\ifx\csname r@#2\endcsname\relax%
+ \@cref@refconsecutivefalse%
\else%
- \edef\@beginref{\@nextref}%
- \let\@endref\relax%
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \count@consecutive=1%
- \expandafter\ifx\csname r@\@beginref\endcsname\relax%
+% \end{macrocode}
+% If next reference in substack is empty, it indicates that no
+% further compression should take place. Having served its purpose,
+% the empty reference and any consecutive empty references are
+% removed from the stack.
+% \begin{macrocode}
+ \ifx\@nextref\@empty%
+ \@cref@refconsecutivefalse%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \fi}%
+% \end{macrocode}
+% Otherwise, test whether next reference is consecutive or not.
+% \begin{macrocode}
+ \else%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \@cref@refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{#2}{\@nextref}}%
+ \expandafter\cref@isrefconsecutive\@tmpa%
+ \fi%
+ \fi%
+ \fi%
+% \end{macrocode}
+% Remove references from the stack until we find end of consecutive
+% sequence.
+% \begin{macrocode}
+ \@whilesw\if@cref@refconsecutive\fi{%
+ \advance#4 1%
+ \let#3\@nextref%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
\@cref@refconsecutivefalse%
\else%
+ \edef\@nextref{\cref@stack@top{#1}}%
% \end{macrocode}
-% If next reference in substack is empty, it indicates that no further
-% collapsing should take place. Having served its purpose, the empty
-% reference and any consecutive empty references are removed from the
-% substack.
+% If next reference is empty, remove any consecutive empty
+% references and we're done.
% \begin{macrocode}
\ifx\@nextref\@empty%
\@cref@refconsecutivefalse%
\@whilesw\ifx\@nextref\@empty\fi{%
- \cref@stack@pop{\@refsubstack}%
- \cref@isstackempty{\@refsubstack}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
\if@cref@stackempty%
\let\@nextref\relax%
\else%
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \fi%
- }%
- \ifnum\count@consecutive=2%
- \edef\@endref{\@endref,}%
- \fi%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \fi}%
% \end{macrocode}
-% Otherwise, test whether next reference is consecutive or not.
+% Otherwise, test whether next reference is consecutive or not.
% \begin{macrocode}
\else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\@cref@refconsecutivefalse%
\else%
- \edef\@tmpa{{\@beginref}{\@nextref}}%
+ \edef\@tmpa{{#3}{\@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}}%
+ \fi}%
+ \fi}
% \end{macrocode}
-% Test whether next reference is empty;
+% \end{macro}
+%
+%
+%
+% \subsection{Referencing Commands}
+% \begin{macro}{\cref}
+% \begin{macro}{\Cref}
+% \begin{macro}{\crefrange}
+% \begin{macro}{\Crefrange}
+% Define the main referencing command \cmd{\cref} and the
+% start-of-sentence variant \cmd{\Cref}, along with the reference range
+% commands \cmd{\crefrange} and \cmd{\Crefrange}.
% \begin{macrocode}
- \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%
+\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}{}}
% \end{macrocode}
-% otherwise, test whether next reference is consecutive or not.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@cref}
+% To save duplicating code, the referencing macros pass an argument
+% determining the variant to an auxilliary macro \cmd{\@cref}, which
+% does the real work. The \cmd{\@cref} macro is the behemoth at the
+% heart of all the clever referencing features. It deals with grouping
+% references by type, type-setting the conjunctions between groups,
+% choosing the right formatting macro to use for each reference, and
+% compressing consecutive references into ranges.
% \begin{macrocode}
- \else%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
- \@cref@refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@endref}{\@nextref}}%
- \expandafter\cref@isrefconsecutive\@tmpa%
- \fi%
- \fi%
- \fi}%
+\def\@cref#1#2{%
+ \begingroup%
% \end{macrocode}
-% If there were no consecutive references, typeset the first
-% reference;
+% Initialise some things, and put all the references into a stack called
+% \cmd{\@refstack}.
% \begin{macrocode}
- \ifx\@endref\relax%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
+ \countdef\count@consecutive=0%
+ \countdef\count@group=1%
+ \count@group=1%
+ \newif\if@secondref%
+ \cref@stack@init{\@refstack}%
+ \cref@stack@push{#2}{\@refstack}%
+ \cref@isstackfull{\@refstack}%
% \end{macrocode}
-% if there were only two consecutive references, typeset the first
-% one and return the second to the substack;
+% Loop until the reference stack is empty.
% \begin{macrocode}
- \else%
- \ifnum\count@consecutive=2%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
- \expandafter\cref@stack@push\expandafter%
- {\@endref}{\@refsubstack}%
+ \@whilesw\if@cref@stackfull\fi{%
% \end{macrocode}
-% otherwise, typeset a reference range.
+% Move next group of references with same type into \cmd{\@refsubstack}.
% \begin{macrocode}
+ \cref@stack@init{\@refsubstack}%
+ \if@cref@sort%
+ \cref@processgroupall{\@refstack}{\@refsubstack}%
+ \cref@stack@sort{\@refsubstack}{\cref@countercmp}%
+ \else%
+ \cref@processgroup{\@refstack}{\@refsubstack}%
+ \fi%
+% \end{macrocode}
+%
+% Type-set appropriate conjunction between groups of reference types.
+% \begin{macrocode}
+ \ifnum\count@group=1\relax%
+ \advance\count@group 1%
+ \else%
+ \cref@isstackfull{\@refstack}%
+ \if@cref@stackfull%
+ \@setcref@middlegroupconjunction%
+ \else%
+ \ifnum\count@group=2\relax%
+ \@setcref@pairgroupconjunction%
\else%
- \edef\@tmpa{{\@beginref}{\@endref}}%
- \if@cref@stackempty%
- \expandafter\@setcrefrange\@tmpa{#1}{}%
- \else%
- \expandafter\@setcrefrange\@tmpa{#1}{@first}%
- \fi%
+ \@setcref@lastgroupconjunction%
\fi%
\fi%
+ \advance\count@group 1%
+ \fi%
% \end{macrocode}
%
-% Process further groups of consecutive references, until substack
-% is empty.
+% Process first group of consecutive references.
% \begin{macrocode}
- \@secondreftrue%
- \cref@isstackfull{\@refsubstack}%
- \@whilesw\if@cref@stackfull\fi{%
- \edef\@beginref{\cref@stack@top{\@refsubstack}}%
- \cref@stack@pop{\@refsubstack}%
- \let\@endref\relax%
+ \if@cref@compress%
+ \cref@processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}%
+ \else%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \cref@stack@pop{\@refsubstack}%
% \end{macrocode}
-% If substack only contains only one reference, typeset it,
+% Empty references serve no purpose when we're not compressing
+% consecutive references, so we simply remove them.
% \begin{macrocode}
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref@stack@pop{\@refsubstack}%
\cref@isstackempty{\@refsubstack}%
\if@cref@stackempty%
- \if@secondref%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@second}%
- \else%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
- \fi%
+ \let\@beginref\relax%
+ \else%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count@consecutive=1\relax%
+ \fi%
% \end{macrocode}
-% otherwise, find end of consecutive references.
+% If there were no consecutive references, type-set the first reference;
% \begin{macrocode}
- \else%
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \count@consecutive=1%
+ \ifnum\count@consecutive=1\relax%
+ \cref@isstackfull{\@refsubstack}%
+ \if@cref@stackfull%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
+ \else%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{}%
+ \fi%
% \end{macrocode}
-% Test whether next reference is empty;
+% if there were only two consecutive references, type-set the first one
+% and return the second to the substack (we add an empty reference
+% after it just to make sure there's no further compression);
% \begin{macrocode}
- \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%
+ \ifnum\count@consecutive=2\relax%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
+ \expandafter\cref@stack@push\expandafter%
+ {\@endref,}{\@refsubstack}%
% \end{macrocode}
-% otherwise, test whether next reference is consecutive or not.
+% otherwise, type-set a reference range.
% \begin{macrocode}
- \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}}%
-% \end{macrocode}
-% Test whether next reference is empty;
-% \begin{macrocode}
- \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%
+ \edef\@tmpa{{\@beginref}{\@endref}}%
+ \if@cref@stackempty%
+ \expandafter\@setcrefrange\@tmpa{#1}{}%
+ \else%
+ \expandafter\@setcrefrange\@tmpa{#1}{@first}%
+ \fi%
+ \fi%
+ \fi%
% \end{macrocode}
-% otherwise, test whether next reference is consecutive or not.
+%
+% Process further groups of consecutive references, until substack is
+% empty.
% \begin{macrocode}
- \else%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
- \@cref@refconsecutivefalse%
- \else%
- \edef\@tmpa{{\@endref}{\@nextref}}%
- \expandafter\cref@isrefconsecutive\@tmpa%
- \fi%
- \fi%
- \fi}%
+ \@secondreftrue%
+ \cref@isstackfull{\@refsubstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \if@cref@compress%
+ \cref@processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}%
+ \else%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \cref@stack@pop{\@refsubstack}%
% \end{macrocode}
-% If the substack is now empty, we will need to typeset an
-% ``end'' reference, otherwise we will need to typeset a
-% ``middle'' reference.
+% Empty references serve no purpose when we're not compressing
+% consecutive references, so we simply remove them.
% \begin{macrocode}
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref@stack@pop{\@refsubstack}%
\cref@isstackempty{\@refsubstack}%
\if@cref@stackempty%
- \if@secondref%
- \def\@pos{@second}%
- \else%
- \def\@pos{@last}%
- \fi%
+ \let\@beginref\relax%
\else%
- \def\@pos{@middle}%
- \fi%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count@consecutive=1\relax%
+ \fi%
% \end{macrocode}
-% If there were no consecutive references, just typeset the
-% next reference;
+% If the substack is now empty, we will need to type-set an ``end''
+% reference, otherwise we will need to type-set a ``middle''
+% reference.
% \begin{macrocode}
- \ifx\@endref\relax%
- \edef\@tmpa{{\@beginref}{#1}{\@pos}}%
- \expandafter\@setcref\@tmpa%
- \else%
+ \cref@isstackempty{\@refsubstack}%
+ \if@cref@stackempty%
+ \if@secondref%
+ \def\@pos{@second}%
+ \else%
+ \def\@pos{@last}%
+ \fi%
+ \else%
+ \def\@pos{@middle}%
+ \fi%
% \end{macrocode}
-% if there were only two consecutive references, typeset the
-% first one, and return the second one to the substack,
+% If there were no consecutive references, just type-set the next
+% reference;
% \begin{macrocode}
- \ifnum\count@consecutive=2%
- \expandafter\@setcref\expandafter%
- {\@beginref}{#1}{@middle}%
- \expandafter\cref@stack@push\expandafter%
- {\@endref}{\@refsubstack}%
+ \ifnum\count@consecutive=1\relax%
+ \edef\@tmpa{{\@beginref}{#1}{\@pos}}%
+ \expandafter\@setcref\@tmpa%
+ \else%
% \end{macrocode}
-% otherwise, typeset a reference range.
+% if there were only two consecutive references, type-set the first
+% one, and return the second one to the substack,
% \begin{macrocode}
- \else%
- \edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
- \expandafter\@setcrefrange\@tmpa%
- \fi%
- \fi%
+ \ifnum\count@consecutive=2\relax%
+ \expandafter\@setcref\expandafter%
+ {\@beginref}{#1}{@middle}%
+ \expandafter\cref@stack@push\expandafter%
+ {\@endref}{\@refsubstack}%
+% \end{macrocode}
+% otherwise, type-set a reference range.
+% \begin{macrocode}
+ \else%
+ \edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
+ \expandafter\@setcrefrange\@tmpa%
\fi%
- \@secondreffalse%
- \cref@isstackfull{\@refsubstack}%
- }% end loop over reference substack
- \fi%
+ \fi%
+ \@secondreffalse%
+ \cref@isstackfull{\@refsubstack}%
+ }% end loop over reference substack
\cref@isstackfull{\@refstack}%
}% end loop over main reference stack
\endgroup}
% \end{macrocode}
+% \end{macro}
%
%
-% The internal \cmd{\@setcref} macro deals with actually typesetting the
-% reference, by calling the appropriate type-dependent formatting macro
-% defined by \cmd{\crefformat} etc.
+% \begin{macro}{\@setcref}
+% The internal \cmd{\@setcref} macro deals with actually type-setting
+% the reference, by calling the appropriate type-dependent formatting
+% macro defined by \cmd{\crefformat} etc.
% \begin{macrocode}
\def\@setcref#1#2#3{%
\expandafter\ifx\csname r@#1\endcsname\relax%
@@ -1641,50 +2481,26 @@
\fi%
\fi}
% \end{macrocode}
+% \end{macro}
%
-% We separate out the very final typesetting step into a separate macro,
-% in order to make it easier to redefine things later to make them work
-% with the \package{hyperref} package.
+% \begin{macro}{\@@setcref}
+% We separate out the very final type-setting step into a separate
+% macro, in order to make it easier to redefine things later to make
+% them work with the \package{hyperref} package.
% \begin{macrocode}
\def\@@setcref#1#2{\cref@getlabel{#2}{\@templabel}#1{\@templabel}{}{}}
% \end{macrocode}
-%
-% Define a new conditional to test whether two references are consecutive
-% (needed when typesetting reference ranges). This uses the counter and
-% prefix (i.e. formatted version of the counter that resets the label's
-% counter) information provided by \cmd{\r@\meta{label}} (via the aux
-% file) to check if the prefices are identical (i.e. the references come
-% from the same chapter, section or whatever), and that the label
-% counters differ by 1.
-% \begin{macrocode}
-\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}
-% \end{macrocode}
-%
-% The internal \cmd{\@setcrefrange} macro deals with typesetting
-% reference ranges, just as \cmd{\@setcref} does for normal
-% references. The actual typesetting is no more complicated in the range
-% case; it's the error checking that makes the code so much longer. We
-% now have to check whether \emph{two} references are undefined, whether
-% \emph{two} reference formats are undefined, whether the reference types
-% are consistent, and also combinations of these various errors.
+% \end{macro}
+%
+% \begin{macro}{\@setcrefrange}
+% The internal \cmd{\@setcrefrange} macro deals with type-setting
+% reference ranges, just as \cmd{\@setcref} does for normal
+% references. The actual type-setting is no more complicated in the
+% range case; it's the error checking that makes the code so much
+% longer. We now have to check whether \emph{two} references are
+% undefined, whether \emph{two} reference formats are undefined,
+% whether the reference types are consistent, and also combinations of
+% these various errors.
% \begin{macrocode}
\def\@setcrefrange#1#2#3#4{%
\begingroup%
@@ -1709,7 +2525,8 @@
\protect\G@refundefinedtrue%
\cref@getlabel{#1}{\@labela}%
\@labela--\nfss@text{\reset@font\bfseries ??}%
- \@latex@warning{Reference `#2' on page \thepage \space undefined}%
+ \@latex@warning{Reference `#2' on page \thepage %
+ \space undefined}%
% \end{macrocode}
% If both references are defined, check that the reference format is
% defined.
@@ -1730,7 +2547,7 @@
type `\@typea' undefined}%
\else%
% \end{macrocode}
-% If reference types are identical, typeset reference range,
+% If reference types are identical, type-set reference range,
% otherwise display warning.\\
% (Note: there's no need to check if reference format for second type
% is defined, since if it isn't it will be caught here as a
@@ -1749,19 +2566,22 @@
\fi%
\endgroup}
% \end{macrocode}
+% \end{macro}
%
-% We again separate out the very final typesetting step into a separate
-% macro, in order to make it easier to redefine things later to make them
-% work with the \package{hyperref} package.
+% \begin{macro}{\@@setcrefrange}
+% We again separate out the very final type-setting step into a separate
+% macro, in order to make it easier to redefine things later to make
+% them work with the \package{hyperref} package.
% \begin{macrocode}
\def\@@setcrefrange#1#2#3{%
\cref@getlabel{#2}{\@labela}%
\cref@getlabel{#3}{\@labelb}%
#1{\@labela}{\@labelb}{}{}{}{}}
% \end{macrocode}
+% \end{macro}
%
%
-% The typesetting of conjunctions is also separated out into separate
+% The type-setting of conjunctions is also separated out into separate
% macros, for the same reason.
% \begin{macrocode}
\def\@setcref@pairgroupconjunction{\crefpairgroupconjunction}
@@ -1774,47 +2594,82 @@
% \subsection{Reference Format Customisation Commands}
%
% \subsubsection{Format Component Commands}
-% The reference formats are usually constructed out of components defined
-% by the user-level \cmd{\crefname}, \cmd{\Crefname}, \cmd{\creflabel}
-% and \cmd{\crefrangelabel} commands. They simply use the supplied
-% arguments to define appropriately named macros containing the
-% formatting components. If the corresponding \cmd{\Crefname} or
-% \cmd{\crefname} variant is not already defined, \cmd{\crefname} and
-% \cmd{\Crefname} define it to be a version with the first letter
-% capitalised or lower-cased, respectively. \cmd{\@crefdefineallformats}
-% is then called to define all the formats from the new components.
+% \begin{macro}{\cref@label@types}
+% The reference formats are usually constructed out of components
+% defined by the user-level \cmd{\crefname}, \cmd{\Crefname},
+% \cmd{\creflabel} and \cmd{\crefrangelabel} commands.
+% \cmd{\cref@label@types} keeps track of label types for which
+% components have been defined, and therefore need constructing at
+% \cmd{\begindocument} (see below).
+%
+% FIXME: we don't check if the label type is already in the list, so some
+% formats may needlessly be redefined identically, multiple times.
+%
+% \begin{macrocode}
+\cref@stack@init{\cref@label@types}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\crefdefaultlabelformat}
+% \begin{macro}{\crefname}
+% \begin{macro}{\Crefname}
+% \begin{macro}{\creflabelformat}
+% \begin{macro}{\crefrangelabelformat}
+% The component customisation commands simply use the supplied
+% arguments to define appropriately named macros containing the
+% formatting components. If the corresponding \cmd{\Crefname} or
+% \cmd{\crefname} variant is not already defined, \cmd{\crefname} and
+% \cmd{\Crefname} define it to be a version with the first letter
+% capitalised or lower-cased, respectively.
% \begin{macrocode}
\newcommand{\crefdefaultlabelformat}[1]{%
\def\cref@default@label##1##2##3{#1}}
\newcommand{\crefname}[3]{%
- \@crefname{cref}{#1}{#2}{#3}%
- \@crefdefineallformats{#1}}
+ \@crefname{cref}{#1}{#2}{#3}{}}
\newcommand{\Crefname}[3]{%
- \@crefname{Cref}{#1}{#2}{#3}%
- \@crefdefineallformats{#1}}
+ \@crefname{Cref}{#1}{#2}{#3}{}}
\newcommand{\creflabelformat}[2]{%
- \@creflabelformat{#1}{#2}%
- \@crefdefineallformats{#1}}
+ \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}%
+ \cref@stack@add{#1}{\cref@label@types}}
\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}}
+ ##1##2##3##4##5##6{#2}%
+ \cref@stack@add{#1}{\cref@label@types}}
% \end{macrocode}
-%
-% The \cmd{\@crefname} utility macro does the real work of defining
-% format names, by defining an appropriately named command to contain the
-% format component, and using the first argument (``cref'' of ``Cref'')
-% to determine how to define the corresponding command with the other
-% capitalisation.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\crefname@preamble}
+% \begin{macro}{\Crefname@preamble}
+% The \cmd{\crefname@preamble} and \cmd{\Crefname@preamble} commands
+% are very like the \cmd{\crefname} and \cmd{\Crefname} commands, but
+% they tag ``|@preamble|'' onto the end of the generated macro
+% names. They are used when defining the formats for different
+% languages (see \cref{sec:code:babel}).
+%\begin{macrocode}
+\newcommand{\crefname@preamble}[3]{%
+ \@crefname{cref}{#1}{#2}{#3}{@preamble}}
+\newcommand{\Crefname@preamble}[3]{%
+ \@crefname{Cref}{#1}{#2}{#3}{@preamble}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@crefname}
+% The \cmd{\@crefname} utility macro does the real work of defining
+% format names, by defining an appropriately named command to contain
+% the format component, and using the additional first argument
+% (``cref'' or ``Cref'') to determine how to define the corresponding
+% command with the other capitalisation. The extra fifth argument
+% tagged onto the end of the generated macro names.
% \begin{macrocode}
-\def\@crefname#1#2#3#4{%
+\def\@crefname#1#2#3#4#5{%
\begingroup%
- \expandafter\gdef\csname #1@#2@name\endcsname{#3}%
- \expandafter\gdef\csname #1@#2@name@plural\endcsname{#4}%
+ \expandafter\gdef\csname #1@#2@name#5\endcsname{#3}%
+ \expandafter\gdef\csname #1@#2@name@plural#5\endcsname{#4}%
% \end{macrocode}
% The following \cmd{\@tmpa} macro makes use of the fact that the first
% character of \#1 is ``c'' for lower-case and ``C'' for upper-case, in
@@ -1833,7 +2688,7 @@
% \end{macrocode}
% If the other capitalisation variant is not already defined...
% \begin{macrocode}
- \@ifundefined{\@other @#2@name}{%
+ \@ifundefined{\@other @#2@name#5}{%
% \end{macrocode}
% Define \cmd{\@tmpa} and \cmd{@tmpb} to be partial expansions (expanded
% just once) of the macros for the capitalisation variant we've just
@@ -1866,29 +2721,42 @@
% \begin{macrocode}
\toksdef\@toksa=0%
\@toksa={%
- \expandafter\gdef\csname\@other @#2@name\endcsname}%
+ \expandafter\gdef\csname\@other @#2@name#5\endcsname}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpa}%
\@toksa={%
- \expandafter\gdef\csname\@other @#2@name@plural\endcsname}%
+ \expandafter\gdef\csname\@other @#2@name@plural#5\endcsname}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpb}%
}{}%
- \endgroup}
+ \endgroup%
+% \end{macrocode}
+% Add label type to list of types that need defining from components.
+% \begin{macrocode}
+ \cref@stack@add{#2}{\cref@label@types}}
% \end{macrocode}
+% \end{macro}
%
%
-% \cmd{\@crefconstructcomponents} utility macro puts the reference format
-% components for the specified reference type into temporary macros, for
-% use by later macros. The ridiculous number of ``\#'' characters ensure
-% that enough are left when they come to be used later (pairs ``\#\#''
-% are collapsed to a single ``\#'' each time the code is expanded).
+% \begin{macro}{\@crefconstructcomponents}
+% The \cmd{\@crefconstructcomponents} utility macro puts the reference
+% format components for the specified reference type into temporary
+% macros, for use by later macros. The ridiculous number of ``\#''
+% characters ensure that the correct number remain when they come to be
+% used later (pairs ``\#\#'' are collapsed to a single ``\#'' each time
+% the code is expanded).
% \begin{macrocode}
\def\@crefconstructcomponents#1{%
+% \end{macrocode}
+% Single cross-reference label format.
+% \begin{macrocode}
\@ifundefined{cref@#1@label}{%
\let\@tmplabel\cref@default@label%
}{%
\expandafter\let\expandafter\@tmplabel%
\csname cref@#1@label\endcsname%
}%
+% \end{macrocode}
+% Reference range label format.
+% \begin{macrocode}
\@ifundefined{cref@#1@rangelabel}{%
\expandafter\def\expandafter\@tmpa\expandafter{%
\@tmplabel{####1}{####3}{####4}}%
@@ -1896,51 +2764,72 @@
\@tmplabel{####2}{####5}{####6}}%
\toksdef\@toksa=0%
\@toksa={\def\@tmprangelabel##1##2##3##4##5##6}%
- \expandafter\expandafter\expandafter\expandafter%
+ % \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\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\@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}%
+% \end{macrocode}
+% Get the correct number of ``\#'''s into the label format definitions.
+% \begin{macrocode}
\expandafter\def\expandafter\@tmplabel\expandafter{%
\@tmplabel{########1}{########2}{########3}}%
\expandafter\def\expandafter\@tmprangelabel\expandafter{%
\@tmprangelabel{########1}{########2}{########3}%
{########4}{########5}{########6}}%
+% \end{macrocode}
+% Lower-case singular cross-reference name.
+% \begin{macrocode}
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpname%
+ % \expandafter\expandafter\expandafter{%
+ % \csname cref@#1@name\endcsname}%
+ \expandafter\def\expandafter\@tmpname\expandafter{%
+ \csname cref@#1@name\endcsname}%
+% \end{macrocode}
+% Upper-case singular cross-reference name.
+% \begin{macrocode}
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpName%
+ % \expandafter\expandafter\expandafter{%
+ % \csname Cref@#1@name\endcsname}%
+ \expandafter\def\expandafter\@tmpName\expandafter{%
+ \csname Cref@#1@name\endcsname}%
+% \end{macrocode}
+% Lower-case plural cross-reference name.
+% \begin{macrocode}
+ \expandafter\def\expandafter\@tmpnameplural\expandafter{%
+ \csname cref@#1@name@plural\endcsname}%
+% \end{macrocode}
+% Upper-case plural cross-reference name.
+% \begin{macrocode}
+ \expandafter\def\expandafter\@tmpNameplural\expandafter{%
+ \csname Cref@#1@name@plural\endcsname}%
}
% \end{macrocode}
+% \end{macro}
%
-% The \cmd{\@crefdefineformat} et al.\ macros construct calls to
-% \cmd{\crefformat} et al.\ for the supplied reference type that define
-% the corresponding formats in terms of the format components. This is
-% mostly just an arduous exercise in controlling macro expansion order.
+% \begin{macro}{\@crefdefineformat}
+% The \cmd{\@crefdefineformat} et al.\ macros construct calls to
+% \cmd{\crefformat} et al.\ for the supplied reference type that define
+% the corresponding formats in terms of the format components. This is
+% mostly just an arduous exercise in controlling macro expansion order.
% \begin{macrocode}
\def\@crefdefineformat#1{%
\begingroup%
% \end{macrocode}
-% put format components into tmp macros
+% Put format components into tmp macros.
% \begin{macrocode}
\@crefconstructcomponents{#1}%
% \end{macrocode}
@@ -1964,11 +2853,16 @@
\@toksa={\Crefformat{#1}}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
\endgroup}
+% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\@crefrangedefineformat}
+% Construct call to \cmd{\crefrangeformat}.
+% \begin{macrocode}
\def\@crefrangedefineformat#1{%
\begingroup%
% \end{macrocode}
-% put format components into tmp macros
+% Put format components into tmp macros.
% \begin{macrocode}
\@crefconstructcomponents{#1}%
% \end{macrocode}
@@ -1992,11 +2886,16 @@
\@toksa={\Crefrangeformat{#1}}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
\endgroup}
+% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\@crefdefinemultiformat}
+% Construct call to \cmd{\crefmultiformat}.
+% \begin{macrocode}
\def\@crefdefinemultiformat#1{%
\begingroup%
% \end{macrocode}
-% put format components into tmp macros
+% Put format components into tmp macros.
% \begin{macrocode}
\@crefconstructcomponents{#1}%
% \end{macrocode}
@@ -2011,17 +2910,23 @@
\expandafter\expandafter\expandafter\@tmpFirst%
\expandafter\expandafter\expandafter{%
\expandafter\@tmpNameplural\expandafter~\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpsecond%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpsecond%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefpairconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmpsecond\expandafter{%
\expandafter\crefpairconjunction\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpmiddle%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpmiddle%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefmiddleconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmpmiddle\expandafter{%
\expandafter\crefmiddleconjunction\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmplast%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmplast%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\creflastconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmplast\expandafter{%
\expandafter\creflastconjunction\@tmplabel}%
% \end{macrocode}
% Bundle all four arguments for \cmd{\crefmultiformat} in token register
@@ -2056,11 +2961,16 @@
\@toksa={\Crefmultiformat{#1}}%
\expandafter\the\expandafter\@toksa\the\@toksb%
\endgroup}
+% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\@crefrangedefinemultiformat}
+% Construct call to \cmd{\crefrangemultiformat}.
+% \begin{macrocode}
\def\@crefrangedefinemultiformat#1{%
\begingroup%
% \end{macrocode}
-% put format components into tmp macros
+% Put format components into tmp macros.
% \begin{macrocode}
\@crefconstructcomponents{#1}%
% \end{macrocode}
@@ -2076,17 +2986,23 @@
\expandafter\expandafter\expandafter\@tmpFirst%
\expandafter\expandafter\expandafter{%
\expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpsecond%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpsecond%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefpairconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmpsecond\expandafter{%
\expandafter\crefpairconjunction\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpmiddle%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpmiddle%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefmiddleconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmpmiddle\expandafter{%
\expandafter\crefmiddleconjunction\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmplast%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmplast%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\creflastconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmplast\expandafter{%
\expandafter\creflastconjunction\@tmprangelabel}%
% \end{macrocode}
% Bundle all four arguments for \cmd{\crefrangemultiformat} in token
@@ -2122,9 +3038,11 @@
\expandafter\the\expandafter\@toksa\the\@toksb%
\endgroup}
% \end{macrocode}
+% \end{macro}
%
-% \cmd{\@crefdefineallformats} calls each of the above, to define all
-% formats for the given type from the corresponding components.
+% \begin{macro}{\@crefdefineallformats}
+% \cmd{\@crefdefineallformats} calls each of the above, to define all
+% formats for the given type from the corresponding components.
% \begin{macrocode}
\def\@crefdefineallformats#1{%
\@crefdefineformat{#1}%
@@ -2132,17 +3050,25 @@
\@crefdefinemultiformat{#1}%
\@crefrangedefinemultiformat{#1}}
% \end{macrocode}
+% \end{macro}
%
%
% \subsubsection{Format Definition Commands}\label{sec:crefformat}
-% \cmd{\crefformat} et al.\ are lower-level user commands that give
-% complete control over the format of different reference types. They
-% override the component-based formats, simply using the supplied
-% arguments to define appropriately named formatting macros, which are
-% called by \cmd{\@setcref}. The only moderately interesting part is that
-% if the corresponding \cmd{\Crefformat} or \cmd{\crefformat} variant is
-% not already defined, they define it to be a version with the first
-% letter capitalised or lower-cased.
+% \begin{macro}{\crefformat}
+% \begin{macro}{\Crefformat}
+% \begin{macro}{\crefrangeformat}
+% \begin{macro}{\Crefrangeformat}
+% \begin{macro}{\crefmultiformat}
+% \begin{macro}{\Crefmultiformat}
+% \begin{macro}{\crefrangemultiformat}
+% \begin{macro}{\Crefrangemultiformat}
+% \cmd{\crefformat} et al.\ are lower-level commands that give complete
+% control over the format of different reference types. They override
+% the component-based formats, simply using the supplied arguments to
+% define appropriately named formatting macros, which are called by
+% \cmd{\@setcref}. If the corresponding \cmd{\Crefformat} or
+% \cmd{\crefformat} variant is not already defined, they define it to
+% be a version with the first letter capitalised or lower-cased.
% \begin{macrocode}
\newcommand{\crefformat}[2]{\@crefformat{cref}{#1}{#2}}
\newcommand{\Crefformat}[2]{\@crefformat{Cref}{#1}{#2}}
@@ -2157,10 +3083,21 @@
\newcommand{\Crefrangemultiformat}[5]{%
\@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}{#5}}
% \end{macrocode}
-%
-% The utility macros do the real work, by using the first argument
-% (``cref'' or ``Cref'', and ``crefrange'' or ``Crefrange'') to determine
-% how to define the corresponding command with the other capitalisation.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% The utility macros do the real work, by using the first argument
+% (``cref'' or ``Cref'', and ``crefrange'' or ``Crefrange'') to
+% determine how to define the corresponding command with the other
+% capitalisation.
+% \begin{macro}{\@crefformat}
+% \cmd{\@crefformat} defines the macros for single references.
% \begin{macrocode}
\def\@crefformat#1#2#3{%
\begingroup%
@@ -2213,7 +3150,12 @@
\@tmpa{##1}{##2}{##3}}%
}{}%
\endgroup}
+% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\@crefrangeformat}
+% \cmd{\@crefrangeformat} defines the macros for single reference ranges.
+% \begin{macrocode}
\def\@crefrangeformat#1#2#3{%
\begingroup%
\expandafter\gdef\csname #1@#2@format\endcsname%
@@ -2266,7 +3208,12 @@
\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
}{}%
\endgroup}
+% \end{macrocode}
+% \end{macro}
%
+% \begin{macro}{\@crefmultiformat}
+% \cmd{\@crefmultiformat} defines the macros for multiple references.
+% \begin{macrocode}
\def\@crefmultiformat#1#2#3#4#5#6{%
\begingroup%
\expandafter\gdef\csname #1@#2@format@first\endcsname##1##2##3{#3}%
@@ -2348,7 +3295,13 @@
\csname #1@#2@format@last\endcsname%
}{}%
\endgroup}
+% \end{macrocode}
+%\end{macro}
%
+% \begin{macro}{\@crefrangemultiformat}
+% \cmd{\@crefmultiformat} defines the macros for reference ranges
+% within multiple references.
+% \begin{macrocode}
\def\@crefrangemultiformat#1#2#3#4#5#6{%
\begingroup%
\expandafter\gdef\csname #1@#2@format@first\endcsname%
@@ -2436,411 +3389,269 @@
}{}%
\endgroup}
% \end{macrocode}
+% \end{macro}
%
%
-% \subsection{Default Reference Formats}
-% We define default reference format components appropriate for
-% \LaTeX{} documents written in English.\\
-% FIXME: add babel support
-%
-% The following must be defined before the user has the chance to
-% customise anything, otherwise the component commands will not work.
+% \subsection{\package{hyperref} Support}
+% \begin{macro}{hyperref}
+% \begin{macro}{backref}
+% If the \package{hyperref} package is loaded, we add hyper-link
+% support to \package{cleveref}. Since \package{hyperref} messes around
+% with some of the same \LaTeX{} internals as we do, we also have to
+% override some of its redefinitions so that they work with
+% \package{cleveref}.
% \begin{macrocode}
-\newcommand{\crefrangeconjunction}{ to~}
-\newcommand{\crefpairconjunction}{ and~}
-\newcommand{\crefmiddleconjunction}{, }
-\newcommand{\creflastconjunction}{ and~}
-\crefdefaultlabelformat{#2#1#3}
+\@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'}}{}
% \end{macrocode}
-%
-% Define default format components. We want don't want these to be
-% defined during the document preamble in case the user defines them
-% themselves (automatic definition of the other capitalisation variant
-% would fail). Therefore, we postpone actual definition of the formats
-% until the beginning of the document, and only define those
-% that haven't already been defined.\\
-% FIXME: add babel support
+% \begin{macro}{\cref@reflabel}
+% \begin{macro}{\cref@getlabel}
+% \begin{macro}{\cref@gettype}
+% \begin{macro}{\cref@getcounter}
+% \begin{macro}{\cref@getprefix}
+% We redefine the utility macros to cope with the extra arguments
+% supplied by hyperref (via the aux file).
% \begin{macrocode}
-\AtBeginDocument{%
+ \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}
% \end{macrocode}
-% If the group conjunctions haven't been defined, define them to be
-% identical to the reference conjunctions.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\H@refstepcounter}
+% The \package{hyperref} package stores the original
+% \cmd{\refstepcounter} definition as\linebreak[4]
+% \cmd{\H@refstepcounter}, which we therefore need to modify so that it
+% adds the extra information to \cmd{\@currentlabel}.
% \begin{macrocode}
- \@ifundefined{crefpairgroupconjunction}{%
- \let\crefpairgroupconjunction\crefpairconjunction}{}%
- \@ifundefined{crefmiddlegroupconjunction}{%
- \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
+ \def\H@refstepcounter#1{%
+ \stepcounter{#1}%
+ \cref@constructprefix{#1}{\@result}%
+ \protected@edef\@currentlabel{%
+ [#1][\arabic{#1}][\@result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}
% \end{macrocode}
-% If the last reference conjunction hasn't been modified from its
-% default, define the last group conjunction to include an extra
-% comma. However, if the user has modified the last reference conjunction
-% but hasn't defined the last group conjunction, they will expect the
-% last group conjunction to be identical to their last reference
-% conjunction definition, so do that.
+% \end{macro}
+%
+% \begin{macro}{\refstepcounter@noarg}
+% \begin{macro}{\refstepcounter@optarg}
+% The original \cmd{\refstepcounter}, as stored earlier in\linebreak[4]
+% \cmd{\cref@old@refstepcounter}, already calls \cmd{\H@refstepcounter}
+% if \package{hyperref} is loaded, and we just redefined the latter to
+% store the type information. So we only need to change
+% \cmd{\@currentlabel} in our \cmd{\refstepcounter} if an optional
+% argument was supplied.
% \begin{macrocode}
- \@ifundefined{creflastgroupconjunction}{%
- \def\@tmpa{ and~}%
- \ifx\creflastconjunction\@tmpa%
- \def\creflastgroupconjunction{, and~}%
- \else%
- \let\creflastgroupconjunction\creflastconjunction%
- \fi}{}%
-% \end{macrocode}
-% Define default names (and in the case of equations, also the label
-% format). We define the lowercase and capitalised versions separately,
-% rather than relying on the automatic definitions, because the code
-% produced by the poor man's sed script is then slightly tidier.
-% \begin{macrocode}
- \@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}}{}%
-% \end{macrocode}
-% Define any undefined formats using the components.
-% \begin{macrocode}
- \@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}}{}%
-}
+ \def\refstepcounter@noarg#1{\cref@old@refstepcounter{#1}}
+ \def\refstepcounter@optarg[#1]#2{%
+ \cref@old@refstepcounter{#2}%
+ \expandafter\@cref@getlabel\@currentlabel\@nil{\@tmplabel}%
+ \cref@constructprefix{#2}{\@tmpreset}%
+ \protected@edef\@currentlabel{%
+ [#1][\arabic{#2}][\@tmpreset]\@tmplabel}}
% \end{macrocode}
-%
-%
-% \subsection{\package{hyperref} Support}
-% If the \package{hyperref} package is loaded, we add hyper-link support
-% to \package{cleveref}. Since \package{hyperref} messes around with some
-% of the same \LaTeX{} internals as \package{cleveref}, we also have to
-% override some of its redefinitions so that they work with
-% \package{cleveref}.
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\appendix}
+% We again make \cmd{\appendix} redefine things so that the label type
+% for chapters or sections is exceptionally overridden and set to
+% ``appendix'' instead. But this time, it is \cmd{\H@refstepcounter}
+% that needs to be redefined.
% \begin{macrocode}
-\@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'}}{}
-% \end{macrocode}
-% We redefine the utility macros to cope with the extra arguments
-% supplied by hyperref (via the aux file).
-% \begin{macrocode}
-\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}
+ \renewcommand\appendix{%
+ \cref@old@appendix%
+ \@ifundefined{chapter}{%
+ \def\H@refstepcounter##1{%
+ \stepcounter{##1}%
+ \cref@constructprefix{##1}{\@result}%
% \end{macrocode}
-%
-% The \package{hyperref} package stores the original
-% \cmd{\refstepcounter} definition as \cmd{\H@refstepcounter}, which we
-% therefore need to modify so that it adds the extra information to
-% \cmd{\@currentlabel}.
+% We add a large value to the front of the counter data, to force
+% references to anything in appendices to be sorted after
+% everything else.
% \begin{macrocode}
-\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}}
+ \edef\@result{{2147483647}\@result}%
% \end{macrocode}
-%
-% The original \cmd{\refstepcounter}, as stored earlier in
-% \cmd{\cref@old@refstepcounter}, already calls \H@refstepcounter if
-% \package{hyperref} is loaded, and we just redefined it to store the
-% type information. So we only need to change \cmd{\@currentlabel} in our
-% \cmd{\refstepcounter} if an optional argument was supplied.
+% Override the cross-reference type of sectioning commands.
% \begin{macrocode}
-\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}}
+ \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%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\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%
+ \fi%
+ \fi}%
+ }{%
+ \def\H@refstepcounter##1{%
+ \stepcounter{##1}%
+ \cref@constructprefix{##1}{\@result}%
% \end{macrocode}
-%
-% We again make \cmd{\appendix} redefine things so that the label type
-% for chapters or sections is exceptionally overridden and set to
-% ``appendix'' instead. But this time, it is \cmd{\H@refstepcounter} that
-% needs to be redefined.
+% Again, the large value added to the front of the counter data
+% forces references to appendix items to be sorted last.
% \begin{macrocode}
-\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}%
- }%
-}
+ \edef\@result{{2147483647}\@result}%
% \end{macrocode}
-%
-% Redefine \cmd{\cref} and all the others to allow starred variants,
-% which don't create hyper-links. The starred variants simply set a flag,
-% which is tested in \cmd{\@@setcref} and \cmd{\@@setrangeref} (below).
-% \begin{macrocode}
-\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}
-% \end{macrocode}
-%
-% Redefine \cmd{\@@setcref} and \cmd{\@@setrangeref} to create
-% hyper-links (unless the starred flag is set), using the extra arguments
-% supplied in \cmd{\r@\meta{label}} (via the aux file) by
-% \package{hyperref}.
-% \begin{macrocode}
-\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}
-}{}
+% Override the cross-reference type of sectioning commands.
+% \begin{macrocode}
+ \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%
+ \def\@tmpa{##1}%
+ \def\@tmpb{section}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubsubappendix][\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%
+ \fi%
+ \fi%
+ \fi}%
+ }%
+ }
% \end{macrocode}
-%
-% Redefine \cmd{\ref} command to provide a starred variant with the same
-% behaviour as \package{hyperref}'s \cmd{\ref*}. As before, we defer the
-% redefinition until the beginning of the document, to ensure it
-% `takes'. \package{hyperref} stores the original \cmd{\@setref} in
-% \cmd{real@setref}.
+% \end{macro}
+%
+% \begin{macro}{\cref*}
+% \begin{macro}{\Cref*}
+% \begin{macro}{\crefrange*}
+% \begin{macro}{\Crefrange*}
+% \begin{macro}{\@crefstar}
+% \begin{macro}{\@crefrangestar}
+% \begin{macro}{\@crefrangenostar}
+% Redefine \cmd{\cref} and all the others to allow starred variants,
+% which don't create hyper-links. The starred variants simply set a
+% flag, which is tested in \cmd{\@@setcref} and \cmd{\@@setrangeref}
+% (below).
+% \begin{macrocode}
+ \newif\if@crefstarred
+ \DeclareRobustCommand{\cref}{%
+ \@ifstar{\@crefstar{cref}}{\@crefnostar{cref}}}
+ \DeclareRobustCommand{\Cref}{%
+ \@ifstar{\@crefstar{Cref}}{\@crefnostar{Cref}}}
+ \def\@crefnostar#1#2{\@cref{#1}{#2}}
+ \def\@crefstar#1#2{%
+ \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse}
+ \DeclareRobustCommand{\crefrange}{%
+ \@ifstar{\@crefrangestar{cref}}{\@crefrangenostar{cref}}}
+ \DeclareRobustCommand{\Crefrange}{%
+ \@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}}
+ \def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}}
+ \def\@crefrangestar#1#2#3{%
+ \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@@setcref}
+% \begin{macro}{\@@setcrefrange}
+% Redefine \cmd{\@@setcref} and \cmd{\@@setrangeref} to create
+% hyper-links (unless the starred flag is set), using the extra
+% arguments supplied in \cmd{\r@\meta{label}} (via the aux file) by
+% \package{hyperref}.
% \begin{macrocode}
+ \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}%
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ref*}
+% Redefine \cmd{\ref} command to provide a starred variant with the
+% same behaviour as \package{hyperref}'s \cmd{\ref*}. As before, we
+% defer the redefinition until the beginning of the document, to ensure
+% it `takes'. (\package{hyperref} stores the original \cmd{\@setref} in
+% \cmd{\real@setref}.)
+% \begin{macrocode}
\AtBeginDocument{%
\DeclareRobustCommand{\ref}{\@ifstar\cref@refstar\cref@ref}
\def\cref@refstar#1{%
@@ -2852,134 +3663,468 @@
\expandafter\real@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
}
% \end{macrocode}
+% \end{macro}
+%
+% \end{macro}
+% \end{macro}
%
%
% \subsection{\package{ntheorem} Support}
-% If \package{ntheorem} is loaded, we need to modify its theorem
-% referencing features so that they work with \package{cleveref}.
+% \begin{macro}{ntheorem}
+% \begin{macro}{thref}
+% If \package{ntheorem} is loaded, we need to modify its theorem
+% referencing features so that they work with \package{cleveref}.
% \begin{macrocode}
-\@ifpackageloaded{ntheorem}{%
-\PackageInfo{cleveref}{`ntheorem' support loaded}
-\@ifpackagewith{ntheorem}{thref}{%
- \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref'
- option}%
- \renewcommand{\thref}{\cref}}{}
+ \@ifpackageloaded{ntheorem}{%
+ \PackageInfo{cleveref}{`ntheorem' support loaded}
+ \@ifpackagewith{ntheorem}{thref}{%
+ \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref'
+ option}%
+ \renewcommand{\thref}{\cref}}{}
% \end{macrocode}
%
-% Newer versions of \package{ntheorem} require a call to
-% \cmd{\theorem@prework} when typesetting theorems. If an older version
-% of \package{ntheorem} is being used, we just \cmd{\let} it to
-% \cmd{\relax} to make sure it's defined.
+% \begin{macro}{\theorem@prework}
+% Newer versions of \package{ntheorem} require a call to
+% \cmd{\theorem@prework} when type-setting theorems. If an older version
+% of \package{ntheorem} is being used, we just \cmd{\let} it to
+% \cmd{\relax} to make sure it's defined.
% \begin{macrocode}
-\@ifundefined{theorem@prework}{\let\theorem@prework\relax}{}
+ \@ifundefined{theorem@prework}{\let\theorem@prework\relax}{}
% \end{macrocode}
+% \end{macro}
%
-% We modify \package{ntheorem}'s version of the \cmd{\@thm} macro very
-% slightly, to have it call \cmd{\refstepcounter} with an optional
-% argument containing the theorem type.
+% \begin{macro}{\@thm}
+% We modify \package{ntheorem}'s version of the \cmd{\@thm} macro very
+% slightly, to have it call \cmd{\refstepcounter} with an optional
+% argument containing the theorem type.
% \begin{macrocode}
-\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}}%]
- }
-% \end{macrocode}
-%
-% Default formats for new theorem-like environments defined by ntheorem.
+ \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}}%]
+ }}{}% end of \@ifpackageloaded
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \subsection{\package{varioref} Support}
+% \begin{macro}{varioref}
+% If \package{varioref} is loaded, we redefine its commands to use
+% \cmd{\cref} instead of \cmd{\ref} to produce the reference. Since
+% \cmd{\cref} can cope with multiple references, We extend the page
+% referencing magic of \cmd{\vref} et al.\ so that they check whether
+% they need to use \cmd{\vpagerefrange} instead of \cmd{\vpageref}.
+% \end{macro}
% \begin{macrocode}
-\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}}{}%
-% \end{macrocode}
-% Define any undefined formats using the components.
-% \begin{macrocode}
- \@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}}{}%
-}%
-}{}
+\@ifpackageloaded{varioref}{%
+ \PackageInfo{cleveref}{`varioref' support loaded}
+ \PackageInfo{cleveref}{`cleveref' supersedes `varioref's %
+ $\backslash$\labelformat command, which will not work}
+ \AtBeginDocument{%
+ \def\cref@vref#1#2{%
+% \end{macrocode}
+% Since we're modifying the \package{varioref} commands anyway, we also
+% (by default) take this opportunity to get rid of the irritating spacing
+% issues of \cmd{\vref} et al. However, this breaks strict compatibility
+% with the original \package{varioref} spacing behaviour, so we also
+% provide a \option{legacyvarioref} option to restore the spacing
+% behaviour, in case full compatibility is required.
+% \begin{macrocode}
+ \if@cref@legacyvarioref%
+ \leavevmode\unskip\vref@space
+ \fi%
+ \@cref{#1}{#2} % space here is deliberate
+ \begingroup%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \vpageref{#2}%
+ \else%
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\vpagerefrange\@tmpa%
+ \fi%
+ \endgroup}
+ \def\cref@vrefrange#1#2#3{%
+ \@setcrefrange{#2}{#3}{#1}{} \vpagerefrange{#2}{#3}}
+ \def\cref@fullref#1#2{%
+ \@cref{#1}{#2} % space here is deliberate
+ \begingroup%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \reftextfaraway{#2}%
+ \else%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpa\expandafter{\@firstref}%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpb\expandafter{\@lastref}%
+ \ifx\@tmpa\@tmpb
+ \expandafter\reftextfaraway\expandafter{\@firstref}%
+ \else
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\reftextpagerange\@tmpa%
+ \fi%
+ \fi%
+ \endgroup}
% \end{macrocode}
%
+% \begin{macro}{\vref}
+% \begin{macro}{\vref*}
+% \begin{macro}{\vrefrange}
+% \begin{macro}{\fullref}
+% \begin{macro}{\vr@f}
+% \begin{macro}{\Vr@f}
+% If \option{legacyvarioref} is set, we only modify the original
+% \package{varioref} commands, and don't define any new ones.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macrocode}
+ \if@cref@legacyvarioref%
+ \def\vr@f#1{\cref@vref{cref}{#1}}
+ \def\Vr@f#1{\cref@vref{Cref}{#1}}
+ \renewcommand\vrefrange[3][\reftextcurrent]{%
+ \crefrange{#2}{#3} \vpagerefrange{#2}{#3}}
+ \def\fullref#1{\cref@fullref{cref}{#1}}
+% \end{macrocode}
+%
+% \begin{macro}{\vref}
+% \begin{macro}{\vref*}
+% \begin{macro}{\Vref}
+% \begin{macro}{\Vref*}
+% \begin{macro}{\vrefrange}
+% \begin{macro}{\vrefrange*}
+% \begin{macro}{\Vrefrange}
+% \begin{macro}{\Vrefrange*}
+% \begin{macro}{\fullref}
+% \begin{macro}{\fullref*}
+% \begin{macro}{\Fullref}
+% \begin{macro}{\Fullref*}
+% If we're not providing legacy compatibility with \package{varioref},
+% we define \cmd{\vref} et al. to be consistent with the other
+% \package{cleveref} referencing commands. This frees up the starred
+% variants to be used to suppress hyperlinks when \package{hyperref} is
+% loaded, as usual.
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \begin{macrocode}
+ \else%
+ \@ifpackageloaded{hyperref}{%
+ \DeclareRobustCommand{\vref}{%
+ \@ifstar{\cref@vrefstar{cref}}{\cref@vref{cref}}}
+ \DeclareRobustCommand{\Vref}{%
+ \@ifstar{\cref@vrefstar{Cref}}{\cref@vref{Cref}}}
+ \DeclareRobustCommand{\vrefrange}{%
+ \@ifstar{\cref@vrefrangestar{cref}}{\cref@vrefrange{cref}}}
+ \DeclareRobustCommand{\Vrefrange}{%
+ \@ifstar{\cref@vrefrangestar{Cref}}{\cref@vrefrange{Cref}}}%
+ \DeclareRobustCommand{\fullref}{%
+ \@ifstar{\cref@fullrefstar{cref}}{\cref@fullref{cref}}}
+ \DeclareRobustCommand{\Fullref}{%
+ \@ifstar{\cref@fullrefstar{Cref}}{\cref@fullref{Cref}}}
+ \def\cref@vrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref@vref{#1}{#2}%
+ \@crefstarredfalse}
+ \def\cref@vrefrangestar#1#2#3{%
+ \@crefstarredtrue%
+ \cref@vrefrange{#1}{#2}{#3}%
+ \@crefstarredfalse}
+ \def\cref@fullrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref@fullref{#1}{#2}%
+ \@crefstarredfalse}
+ }{%
+ \DeclareRobustCommand{\vref}{\cref@vref{cref}}
+ \DeclareRobustCommand{\Vref}{\cref@vref{Cref}}
+ \DeclareRobustCommand{\vrefrange}{\cref@vrefrange{cref}}
+ \DeclareRobustCommand{\Vrefrange}{\cref@vrefrange{Cref}}
+ \DeclareRobustCommand{\fullref}{\cref@fullref{cref}}
+ \DeclareRobustCommand{\Fullref}{\cref@fullref{Cref}}
+ }
+ \fi%
+ }% end of \AtBeginDocument
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
+%
+% \begin{macro}{legacyvarioref}
+% The \option{legacyvarioref} option just sets a flag, checked in the
+% redefinitions set up at the beginning of the document, above.
+% \end{macro}
+% \begin{macrocode}
+\let\if@cref@legacyvarioref\iffalse
+\DeclareOption{legacyvarioref}{%
+ \PackageInfo{cleveref}{legacy `varioref' compatibility enabled}
+ \let\if@cref@legacyvarioref\iftrue}
+% \end{macrocode}
+%
+%
%
% \subsection{Poor Man's \package{cleveref}}
+% \begin{macro}{poorman}
+% The \option{poorman} option causes a |sed| script to automatically be
+% written. When the original \LaTeX{} source file is processed through
+% this script, it strips out all the \package{cleveref} commands,
+% type-setting all the reference formatting explicitly, and using the
+% standard \cmd{\ref} command to produce the references themselves.
% \begin{macrocode}
\DeclareOption{poorman}{%
-\PackageInfo{cleveref}{option `poorman' loaded}
+ \PackageInfo{cleveref}{option `poorman' loaded}
% \end{macrocode}
%
%
-% Define global macro \cmd{\cref@text} to store the text produced by the
-% \cmd{\cref} commands, and open an output stream for writing the script
-% before starting to process to document body.
+% \begin{macro}{\cref@poorman@text}
+% Define global macro \cmd{\cref@poorman@text} to store the text produced by
+% the \cmd{\cref} commands, and open an output stream for writing the
+% script before starting to process the document body.
% \begin{macrocode}
-\edef\cref@text{}
-\AtBeginDocument{%
- \newwrite\@crefscript%
- \immediate\openout\@crefscript=\jobname.sed%
-}
+ \gdef\cref@poorman@text{}
+ \AtBeginDocument{%
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{select@language}
+% \begin{macro}{forreign@language}
+% If \package{babel} is loaded, we add to the \cmd{\select@language}
+% and \cmd{\forreign@language} commands to make them write substitution
+% rules to the script that replace the cross-reference name and
+% conjunction component macros with the appropriate language-dependent
+% names. We use |sed| line-number addresses in the rules to ensure they
+% are only applied to the regions in which that particular language was
+% in use.
+%
+% Note that we write substitution rules for the \emph{previou} language
+% block when the language is changed, because we need the rules to
+% appear in the script \emph{after} all the cross-reference
+% substitution rules for that language block. \cmd{cref@inputlineno}
+% stores the input-file line-number of the start of the previous
+% language block.
+%
+% We postpone the redefinitions until the beginning of the document not
+% only to ensure that they don't get clobbered by other package's
+% redefinitions, but also because we don't want the redefenitions to
+% take effect until after \package{babel} has called
+% \cmd{\selectlanguage} for the main language (remember, the
+% substitution rules for this first language block will get written at
+% the next language change).
+%
+% Note that, since we're writing to the script file within
+% \cmd{\AtBeginDocument} and \cmd{\AtEndDocument}, this code has to
+% come \emph{after} the above \cmd{\AtBeginDocument} code which opens
+% the script file for writing, and \emph{before} the later
+% \cmd{\AtEndDocument} code (below) which closes it.
+%
+% The |\if@cref@switched@language| flag is set when a \package{babel}
+% language switching command is called. It is checked by
+% \cmd{\cref@writelanguagerules} when writing substitution rules.
+% \begin{macrocode}
+ \newif\if@cref@switched@language
+ \@ifpackageloaded{babel}{%
+ \AtBeginDocument{%
+ \let\cref@old@select@language\select@language
+ \def\select@language{%
+ \@cref@switched@languagetrue%
+ \cref@writelanguagerules%
+ \cref@old@select@language}
+ \let\cref@old@forreign@language\forreign@language
+ \def\forreign@language{%
+ \@cref@switched@languagetrue%
+ \cref@writelanguagerules%
+ \cref@old@forreign@language}
+ \edef\cref@inputlineno{\the\inputlineno}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% The final set of substitution rules gets written at the end of the
+% document.
+% \begin{macrocode}
+ \AtEndDocument{%
+ \let\select@language\cref@old@select@language%
+ \let\forreign@language\cref@old@forreign@language%
+ \cref@writelanguagerules}
+% \end{macrocode}
+%
+% \begin{macro}{\cref@writelanguagerules}
+% \cmd{\cref@writelanguagerules} does the grunt work of writing out the
+% necessary substitution rules.
+% \begin{macrocode}
+ \def\cref@writelanguagerules{%
+ \begingroup%
+% \end{macrocode}
+% If |\if@cref@switched@language| hasn't been set, then we must be
+% writing the final set of substitution rules at the end of a document,
+% in which no language switching command was ever used. In which case,
+% the substitution rules don't specify a line-number address.
+% \begin{macrocode}
+ \if@cref@switched@language%
+ \edef\@address{\cref@inputlineno,\the\inputlineno}%
+ \else%
+ \def\@address{}%
+ \fi%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefrangeconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefrangeconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefpairconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefpairconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefmiddleconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddleconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \creflastconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\creflastconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefpairgroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefpairgroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefmiddlegroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddlegroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \creflastgroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\creflastgroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
% \end{macrocode}
+% We write substitution rules for all component-derived cross-reference
+% formats, as listed in \cmd{\cref@label@types}.
+% \begin{macrocode}
+ \let\@tmpstack\cref@label@types%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+% \end{macrocode}
+% \cmd{\cref@}\meta{type}|@name| substitution rules.
+% \begin{macrocode}
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}%
+ \edef\@tmpa{%
+ \string\cref@\expandafter\noexpand\@tmpa @name\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+% \end{macrocode}
+% \cmd{\cref@}\meta{type}|@name@plural| substitution rules.
+% \begin{macrocode}
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}%
+ \edef\@tmpa{%
+ \string\cref@\expandafter\noexpand\@tmpa%
+ @name@plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+% \end{macrocode}
+% \cmd{\Cref@}\meta{type}|@name| substitution rules.
+% \begin{macrocode}
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}%
+ \edef\@tmpa{%
+ \string\Cref@\expandafter\noexpand\@tmpa @name\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+% \end{macrocode}
+% \cmd{\Cref@}\meta{type}|@name@plural| substitution rules.
+% \begin{macrocode}
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}%
+ \edef\@tmpa{%
+ \string\Cref@\expandafter\noexpand\@tmpa%
+ @name@plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+% \end{macrocode}
+% After the loop over cross-reference types, we set
+% \cmd{\cref@inputlineno} to the current input-file line, in preparation
+% for the next language block.
+% \begin{macrocode}
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}}%
+ \endgroup%
+ \edef\cref@inputlineno{\the\inputlineno}}%
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
+% \end{macro}
%
%
% After processing the document body, we re-read in the temporary script
-% file, and write it out again to the final sed script file, escaping
+% file, and write it out again to the final |sed| script file, escaping
% regexp special characters in the process. The escaping is carried out
% by turning the regexp special characters into active characters, and
% defining them to expand to their escaped form. This involves a lot of
@@ -3006,224 +4151,1882 @@
% expanded and evaluated, the \cmd{\lowercase} commands create tokens
% with the correct char- and catcodes.
% \begin{macrocode}
-\AtEndDocument{%
- \immediate\closeout\@crefscript%
- \newread\@crefscript%
- \immediate\openin\@crefscript=\jobname.sed%
- \begingroup%
- \newif\if@not@eof%
- \def\@eof{\par }%
+ \AtEndDocument{%
+ \immediate\closeout\@crefscript%
+ \newread\@crefscript%
+ \immediate\openin\@crefscript=\jobname.sed%
+ \begingroup%
+ \newif\if@not@eof%
+ \def\@eof{\par }%
% \end{macrocode}
% Change catcodes of regexp special characters to make them active
% characters and define them to expand to their escaped forms. Change
% those of \TeX special characters to make them normal letters.
% \begin{macrocode}
- \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
+ \catcode`.=13 \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`~=42\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
% \end{macrocode}
% Read lines from the temporary script file, expand them to escape regexp
-% special characters, and store them in \cmd{\cref@text}.
+% special characters, and store them in \cmd{\cref@poorman@text}.
% \begin{macrocode}
- \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}%
+ \def\cref@poorman@text{}%
\immediate\read\@crefscript to \@tmpa%
\ifx\@tmpa\@eof%
\@not@eoffalse%
\else%
\@not@eoftrue%
\edef\@tmpa{\@tmpa}%
- \fi}%
- \endgroup%
- \immediate\closein\@crefscript%
+ \fi%
+ \@whilesw\if@not@eof\fi{%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@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%
% \end{macrocode}
-% Add some rules to remove likely \package{cleveref} preamble
-% commands. We use the \cmd{\lowercase} trick again for writing the
-% $\backslash$, \{ and \} characters. (This could be done in other ways,
-% but since we're in \cmd{\lowercase} mood, why not go with it!)
+% Add some rules to remove other \package{cleveref} commands. We use the
+% \cmd{\lowercase} trick again for writing the $\backslash$, \{ and \}
+% characters. (This could be done in other ways, but since we're in
+% \cmd{\lowercase} mood, why not stick with it.)
% \begin{macrocode}
- \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%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\def\@tmpa{%[
+ s/||label|[[^]]*|]/||label/g}}
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||usepackage|(|[.*|]|)|?<cleveref>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refname<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]reflabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refdefaultlabelformat<.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]ref><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \endgroup%
% \end{macrocode}
% Overwrite the script file with the new, escaped regexp rules.
% \begin{macrocode}
- \newwrite\@crefscript%
- \immediate\openout\@crefscript=\jobname.sed%
- \immediate\write\@crefscript{\cref@text}%
- \immediate\closeout\@crefscript%
-}
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed%
+ \immediate\write\@crefscript{\cref@poorman@text}%
+ \immediate\closeout\@crefscript%
+ }
% \end{macrocode}
%
%
-% Redefine the user-level referencing commands so that they write a
-% substitution rule for the reference to the script, as well as
-% typesetting the reference itself.
+% \begin{macro}{\cref@writescript}
+% The \cmd{\cref@writescript} utility macro does the actual writing of
+% the substitution rule to the script. The first argument is the
+% ``address'', the second argument is the regexp pattern to match,
+% whilst the substitution must be stored in \cmd{\cref@poorman@text}.
% \begin{macrocode}
-\@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@getmeaning#1{\expandafter\@cref@getmeaning\meaning#1\@nil}
+ \def\@cref@getmeaning#1->#2\@nil{#2}
+ \def\cref@writescript#1#2{%
+ \edef\@tmpa{\cref@getmeaning{\cref@poorman@text}}%
+ \immediate\write\@crefscript{#1 s/#2/\@tmpa/g}}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\cref}
+% \begin{macro}{\Cref}
+% \begin{macro}{\crefrange}
+% \begin{macro}{\Crefrange}
+% \begin{macro}{\@crefstar}
+% \begin{macro}{\@crefnostar}
+% \begin{macro}{\@crefrangestar}
+% \begin{macro}{\@crefrangenostar}
+% Redefine the user-level referencing commands so that they write a
+% substitution rule for the reference to the script, as well as
+% type-setting the reference itself.
+% \begin{macrocode}
+ \@ifpackageloaded{hyperref}{%
+ \def\@crefnostar#1#2{%
+ \gdef\cref@poorman@text{}%
+ \@cref{#1}{#2}%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1<#2>}}%
+ \endgroup}
+ \def\@crefstar#1#2{%
+ \gdef\cref@poorman@text{}%
+ \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1*<#2>}}%
+ \endgroup}
+ \def\@crefrangenostar#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@setcrefrange{#2}{#3}{#1}{}%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1range<#2><#3>}}%
+ \endgroup}
+ \def\@crefrangestar#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1range*<#2><#3>}}%
+ \endgroup}
+%
+ }{%
+ \DeclareRobustCommand{\cref}[1]{%
+ \edef\cref@poorman@text{}%
+ \@cref{cref}{#1}%
+ \cref@writescript{}{\string\cref\string{#1\string}}}
+ \DeclareRobustCommand{\Cref}[1]{%
+ \edef\cref@poorman@text{}%
+ \@cref{Cref}{#1}%
+ \cref@writescript{}{\string\Cref\string{#1\string}}}
+ \DeclareRobustCommand{\crefrange}[2]{%
+ \edef\cref@poorman@text{}%
+ \@setcrefrange{#1}{#2}{cref}{}%
+ \cref@writescript{}{%
+ \string\crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Crefrange}[2]{%
+ \edef\cref@poorman@text{}%
+ \@setcrefrange{#1}{#2}{Cref}{}%
+ \cref@writescript{}{%
+ \string\Crefrange\string{#1\string}\string{#2\string}}}
+ }
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\vref}
+% \begin{macro}{\vref*}
+% \begin{macro}{\Vref}
+% \begin{macro}{\Vref*}
+% \begin{macro}{\vrefrange}
+% \begin{macro}{\vrefrange*}
+% \begin{macro}{\Vrefrange}
+% \begin{macro}{\Vrefrange*}
+% \begin{macro}{\fullref}
+% \begin{macro}{\fullref*}
+% \begin{macro}{\Fullref}
+% \begin{macro}{\Fullref*}
+% If \package{varioref} is loaded, do the same for the \cmd{\vref} et
+% al.\ commands. Note that we now need to set the |\if@crefstarred|
+% flag for the starred variant \cmd{\vref*} even if
+% \option{legacyvarioef} is set and it changes the spacing rather than
+% suppressing hyper-links, so that we can write the correct
+% substitution rule.
+% \begin{macrocode}
+ \@ifpackageloaded{varioref}{%
+ \AtBeginDocument{%
+ \if@cref@legacyvarioref%
+ \DeclareRobustCommand{\vref}{%
+ \@ifstar{\cref@vrefstar{cref}}{\cref@vref{cref}}}
+ \def\cref@vrefstar#1#2{%
+ \@crefstarredtrue\cref@vref{#1}{#2}\@crefstarredfalse}
+ \fi
+ \def\cref@vref#1#2{%
+ \gdef\cref@poorman@text{}%
+ \if@cref@legacyvarioref%
+ \leavevmode\unskip\vref@space
+ \fi%
+ \begingroup%
+% \end{macrocode}
+% If \option{legacyvarioref} is set, \cmd{\vref*} shouldn't suppress
+% hyper-links, so temporarily disable then restore the flag whilst
+% type-setting the cross-reference.
+% \begin{macrocode}
+ \let\if@tmp\if@crefstarred%
+ \if@cref@legacyvarioref\@crefstarredfalse\fi%
+ \@cref{#1}{#2} % space here is deliberate
+ \let\if@crefstarred\if@tmp%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \vpageref{#2}%
+ \g@addto@macro\cref@poorman@text{ \vpageref{#2}}%
+ \else%
+ \g@addto@macro\cref@poorman@text{ }%
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\vpagerefrange\@tmpa%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\expandafter\vpagerefrange\@tmpa}%
+ \fi%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{\string\vref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\vref\string{#2\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{\string\Vref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\Vref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil%
+ \endgroup}
+%
+ \def\cref@vrefrange#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@setcrefrange{#2}{#3}{#1}{} \vpagerefrange{#2}{#3}%
+ \g@addto@macro\cref@poorman@text{ \vpagerefrange{#2}{#3}}%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{%
+ \string\vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref@writescript{}{%
+ \string\vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{%
+ \string\Vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref@writescript{}{%
+ \string\Vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil}
+%
+ \def\cref@fullref#1#2{%
+ \gdef\cref@poorman@text{}%
+ \begingroup%
+ \@cref{#1}{#2} % space here is deliberate
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \reftextfaraway{#2}%
+ \def\@pageref{\reftextfaraway{#1}}%
+ \else%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpa\expandafter{\@firstref}%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpb\expandafter{\@lastref}%
+ \ifx\@tmpa\@tmpb
+ \expandafter\reftextfaraway\expandafter{\@firstref}%
+ \expandafter\def\expandafter\@pageref\expandafter{%
+ \expandafter\reftextfaraway\expandafter{\@firstref}}%
+ \else
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\reftextpagerange\@tmpa%
+ \expandafter\def\expandafter\@pageref\expandafter{%
+ \expandafter\reftextpagerange\@tmpa}%
+ \fi%
+ \fi%
+ \g@addto@macro\cref@poorman@text{ }%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\@pageref}%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{\string\fullref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\fullref\string{#2\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{\string\Fullref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\Fullref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil
+ \endgroup}
+ }% end of \AtBeginDocument
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\@@setcref}
+% \begin{macro}{\@@setcrefrange}
+% Redefine \cmd{\@@setcref} and \cmd{\@@setrangeref}, as well as the
+% conjunction macros \cmd{\@setcref@middlegroupconjunction},
+% \cmd{\@setcref@lastgroupconjunction} and
+% \cmd{\@setcref@pairgroupconjunction}, to append text they type-set
+% to\linebreak[4] the \cmd{\cref@poorman@text} macro, as well as
+% actually doing the type-setting.
+% \begin{macrocode}
+ \def\@setcref@pairgroupconjunction{%
+ \crefpairgroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\crefpairgroupconjunction}}
+ \def\@setcref@middlegroupconjunction{%
+ \crefmiddlegroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\crefmiddlegroupconjunction}}
+ \def\@setcref@lastgroupconjunction{%
+ \creflastgroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\creflastgroupconjunction}}
+ \@ifpackageloaded{hyperref}{%
+ \def\@@setcref#1#2{%
+ \cref@getlabel{#2}{\@tmplabel}%
+ \if@crefstarred%
+ #1{\@tmplabel}{}{}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref*{#2}}{}{}}%
+ \else%
+ \edef\@tmplink{\cref@hyperref{#2}}%
+ #1{\@tmplabel}{\hyper@linkstart{link}{\@tmplink}}%
+ {\hyper@linkend}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref{#2}}{}{}}%
+ \fi}
+ \def\@@setcrefrange#1#2#3{%
+ \cref@getlabel{#2}{\@labela}%
+ \cref@getlabel{#3}{\@labelb}%
+ \if@crefstarred%
+ #1{\@labela}{\@labelb}{}{}{}{}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref*{#2}}{\ref*{#3}}{}{}{}{}}%
+ \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}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}%
+ \fi}
+ }{%
+ \def\@@setcref#1#2{%
+ \old@@setcref{#1}{#2}%
+ \expandafter\g@addto@macro\expandafter{%
+ \expandafter\cref@poorman@text\expandafter}\expandafter{%
+ #1{\ref{#2}}{}{}}}
+ \def\@@setcrefrange#1#2#3{%
+ \old@@setcrefrange{#1}{#2}{#3}%
+ \expandafter\g@addto@macro%
+ \expandafter{\expandafter\cref@poorman@text\expandafter}%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
+ }
+}% end of poorman option
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \subsection{Sort and Compress options}
+% \begin{macro}{sort}
+% \begin{macro}{compress}
+% \begin{macro}{nosort}
+% \begin{macro}{\if@cref@sort}
+% \begin{macro}{\if@cref@compress}
+% The \option{sort}, \option{compress} or \option{nosort} options
+% determine whether to sort and/or compress lists of multiple
+% references (default is to do both). They work simply by setting the
+% |\if@cref@sort| and |\if@cref@compress| flags appropriately.
+% \begin{macrocode}
+\newif\if@cref@sort
+\newif\if@cref@compress
+% \end{macrocode}
+% Default is to both sort and compress references.
+% \begin{macrocode}
+\@cref@sorttrue
+\@cref@compresstrue
+% \end{macrocode}
+% Options override default.
+% \begin{macrocode}
+\DeclareOption{sort}{%
+ \PackageInfo{cleveref}{sorting but not compressing references}
+ \@cref@sorttrue
+ \@cref@compressfalse}
+\DeclareOption{compress}{%
+ \PackageInfo{cleveref}{compressing but not sorting references}
+ \@cref@sortfalse
+ \@cref@compresstrue}
+\DeclareOption{sort&compress}{%
+ \PackageInfo{cleveref}{sorting and compressing references}
+ \@cref@sorttrue
+ \@cref@compresstrue}
+\DeclareOption{nosort}{%
+ \PackageInfo{cleveref}{neither sorting nor compressing references}
+ \@cref@sortfalse
+ \@cref@compressfalse}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+% \subsection{Language and \package{babel} Support}
+% \label{sec:code:babel}
+% Default reference formats for different languages are supported via
+% package options, in the usual way.
+%
+% Any contributions of translations for missing languages are most
+% welcome! If you can contribute definitions for a missing language,
+% ideally you should add them below the existing ones (using those as a
+% model), generate a patch against the original \package{cleveref.dtx}
+% file, and send the patch by email to the package author. However, if
+% you don't know how to produce a patch, you can instead just send the
+% translations as a plain text file.
+%
+%
+% \begin{macro}{\crefdefaultlabelformat}
+% \begin{macro}{\creflabelformat}
+% We first define the default label formats, which don't depend on
+% language. We override the default format for equations, to follow the
+% near universal convention of enclosing equation labels in brackets.
+% \begin{macrocode}
+\crefdefaultlabelformat{#2#1#3}
+\creflabelformat{equation}{\textup{(#2#1#3)}}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\cref@addto}
+% Utility macro to use instead of \package{babel}'s flawed \cmd{\addto}
+% (copied and modified from \package{varioref}).
+% \begin{macrocode}
+\def\cref@addto#1#2{%
+ \@temptokena{#2}%
+ \ifx#1\undefined
+ \edef#1{\the\@temptokena}%
+ \else
+ \toks@\expandafter{#1}%
+ \edef#1{\the\toks@\the\@temptokena}%
+ \fi
+ \@temptokena{}\toks@\@temptokena%
}
+\@onlypreamble\cref@addto
+% \end{macrocode}
+% \end{macro}
+%
+%
+% Passing a language option to \package{cleveref} defines the
+% cross-reference names and conjunctions as appropriate for that
+% lanauge. We can't make the definitions straight away, since they would
+% prevent the automatic definition of the other capitalisation variant
+% from working if the user chooses to change a default definition in the
+% preamble, so we postpone them until the beginning of the
+% document. However, if each language option were to simply to define any
+% formats that aren't already defined by the end of the preamble, the
+% \emph{first} language option would override all the
+% others. Unfortunately, the convention in \LaTeX{} and \package{babel}
+% is for the \emph{last} language option to take precedence. So we
+% instead used the \cmd{\crefname@preamble} command to save the
+% definitions in |\cref@\meta{type}@name@preamble| etc., and after all
+% the language options have been processed, use the contents of these to
+% set the default definitions for any undefined formats.
+%
+% For \package{babel} support, we add the appropriate redefinitions to
+% the\linebreak[4] |\extras|\meta{language} macro, which is called by
+% \package{babel}'s \cmd{\selectlanguage} at al.\ commands. The main
+% language (the last one listed in the options) is set up by an automatic
+% call to \cmd{\selectlanguage} at the beginning of the document, which
+% would clobber any redefinitions made by the user in the preamble. To
+% avoid this, we postpone adding the redefinitions to
+% |\extras|\meta{language} until the beginning of the document. Since
+% \package{cleveref} must always be loaded \emph{after} \package{babel},
+% the redefinitions won't be added to |\extras|\meta{language} until
+% \emph{after} \package{babel} has already called \cmd{\selectlanguage}
+% for the main language. Thus the redefinitions will only be in effect
+% when \cmd{\selectlanguage} is called explicitly within the
+% document. (The definitions for the main language are taken care of by
+% the language options passed to \package{cleveref}, independently of
+% \package{babel}.)
+%
+% Note that we define both capitalisation variants explicitly throughout,
+% rather than relying on the automatic definition of the other variant,
+% in order to make the code produced by the poor man's |sed| script
+% slightly cleaner.
+%
+% \begin{macro}{english}
+% English definitions (these are used by default).
+% \end{macro}
+% \begin{macrocode}
+\DeclareOption{english}{%
+ \PackageInfo{cleveref}{loaded `english' language definitions}
+% \end{macrocode}
+% First, we set up the definitions used at the beginning of the document to
+% define the formats created by the document preamble.
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ to~}
+ \def\crefpairconjunction@preamble{ and~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ and~}
+% \end{macrocode}
+% We have to define the group conjunctions explicitly here, rather than
+% relying on fall-back definitions in terms of the above conjunctions
+% (see \cref{sec:code:default_formats}), in case any other language
+% option defines them explicitly and we need to override those.
+% \begin{macrocode}
+ \def\crefpairgroupconjunction@preamble{ and~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{, and~}
+ \crefname@preamble{equation}{eq.}{eqs.}
+ \Crefname@preamble{equation}{Equation}{Equations}
+ \crefname@preamble{chapter}{chapter}{chapters}
+ \Crefname@preamble{chapter}{Chapter}{Chapters}
+ \crefname@preamble{section}{section}{sections}
+ \Crefname@preamble{section}{Section}{Sections}
+ \crefname@preamble{appendix}{appendix}{appendices}
+ \Crefname@preamble{appendix}{Appendix}{Appendices}
+ \crefname@preamble{figure}{fig.}{figs.}
+ \Crefname@preamble{figure}{Figure}{Figures}
+ \crefname@preamble{table}{table}{tables}
+ \Crefname@preamble{table}{Table}{Tables}
+ \crefname@preamble{theorem}{theorem}{theorems}
+ \Crefname@preamble{theorem}{Theorem}{Theorems}
+ \crefname@preamble{enumi}{item}{items}
+ \Crefname@preamble{enumi}{Item}{Items}
+ \crefname@preamble{lemma}{lemma}{lemmas}
+ \Crefname@preamble{lemma}{Lemma}{Lemmas}
+ \crefname@preamble{corollary}{corollary}{corollaries}
+ \Crefname@preamble{corollary}{Corollary}{Corollaries}
+ \crefname@preamble{proposition}{proposition}{propositions}
+ \Crefname@preamble{proposition}{Proposition}{Propositions}
+ \crefname@preamble{definition}{definition}{definitions}
+ \Crefname@preamble{definition}{Definition}{Definitions}
+ \crefname@preamble{result}{result}{results}
+ \Crefname@preamble{result}{Result}{Results}
+ \def\cref@language{english}%
% \end{macrocode}
%
+% Next, we add the definitions to \cmd{\extras}\dots so that
+% \package{babel}'s \cmd{\selectlanguage} command will change the format
+% appropriately.
+% \begin{macrocode}
+ \cref@addto\extrasenglish{%
+ \renewcommand{\crefrangeconjunction}{ to~}
+ \renewcommand{\crefpairconjunction}{ and~}
+ \renewcommand{\crefmiddleconjunction}{, }
+ \renewcommand{\creflastconjunction}{ and~}
+ \renewcommand{\crefpairgroupconjunction}{ and~}
+ \renewcommand{\crefmiddlegroupconjunction}{, }
+ \renewcommand{\creflastgroupconjunction}{, and~}
+ \crefname{equation}{eq.}{eqs.}
+ \Crefname{equation}{Equation}{Equations}
+ \crefname{chapter}{chapter}{chapters}
+ \Crefname{chapter}{Chapter}{Chapters}
+ \crefname{section}{section}{sections}
+ \Crefname{section}{Section}{Sections}
+ \crefname{subsection}{section}{sections}
+ \Crefname{subsection}{Section}{Sections}
+ \crefname{subsubsection}{section}{sections}
+ \Crefname{subsubsection}{Section}{Sections}
+ \crefname{appendix}{appendix}{appendices}
+ \Crefname{appendix}{Appendix}{Appendices}
+ \crefname{subappendix}{appendix}{appendices}
+ \Crefname{subappendix}{Appendix}{Appendices}
+ \crefname{subsubappendix}{appendix}{appendices}
+ \Crefname{subsubappendix}{Appendix}{Appendices}
+ \crefname{subsubsubappendix}{appendix}{appendices}
+ \Crefname{subsubsubappendix}{Appendix}{Appendices}
+ \crefname{figure}{fig.}{figs.}
+ \Crefname{figure}{Figure}{Figures}
+ \crefname{subfigure}{fig.}{figs.}
+ \Crefname{subfigure}{Figure}{Figures}
+ \crefname{table}{table}{tables}
+ \Crefname{table}{Table}{Tables}
+ \crefname{subtable}{table}{tables}
+ \Crefname{subtable}{Table}{Tables}
+ \crefname{theorem}{theorem}{theorems}
+ \Crefname{theorem}{Theorem}{Theorems}
+ \crefname{enumi}{item}{items}
+ \Crefname{enumi}{Item}{Items}
+ \crefname{enumii}{item}{items}
+ \Crefname{enumii}{Item}{Items}
+ \crefname{enumiii}{item}{items}
+ \Crefname{enumiii}{Item}{Items}
+ \crefname{enumiv}{item}{items}
+ \Crefname{enumiv}{Item}{Items}
+ \crefname{enumv}{item}{items}
+ \Crefname{enumv}{Item}{Items}
+ \crefname{lemma}{lemma}{lemmas}
+ \Crefname{lemma}{Lemma}{Lemmas}
+ \crefname{corollary}{corollary}{corollaries}
+ \Crefname{corollary}{Corollary}{Corollaries}
+ \crefname{proposition}{proposition}{propositions}
+ \Crefname{proposition}{Proposition}{Propositions}
+ \crefname{definition}{definition}{definitions}
+ \Crefname{definition}{Definition}{Definitions}
+ \crefname{result}{result}{results}
+ \Crefname{result}{Result}{Results}%
+ }}}
+% \end{macrocode}
%
-% The \cmd{\cref@writescript} utility macro does the actual writing of
-% the substitution rule to the script.
+% \begin{macro}{german}
+% German translations kindly provided by Stefan Pinnow, with a few
+% additions by the package author (so you know to blame the latter for
+% any errors!).
+% \end{macro}
+% \begin{macrocode}
+\DeclareOption{german}{%
+ \PackageInfo{cleveref}{loaded `german' language definitions}
+% \end{macrocode}
+% First, we set up the definitions used at the beginning of the document to
+% define the formats created by the document preamble.
% \begin{macrocode}
-\def\cref@writescript#1{%
- \edef\@tmpa{\cref@getmeaning{\cref@text}}%
- \immediate\write\@crefscript{s/#1/\@tmpa/g}}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ bis~}
+ \def\crefpairconjunction@preamble{ und~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ und~}
+% \end{macrocode}
+% We don't want the extra comma before ``und'' that would be added by the
+% default fall-back definitions in terms of the above conjunctions, so we
+% define \cmd{\crefpairgroupconjunction} explicitly. In fact, we have to
+% define the other group conjunctions explicitly too here, in case any
+% other language option defines them explicitly and we need to override
+% them .
+% \begin{macrocode}
+ \def\crefpairgroupconjunction@preamble{ und~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{ und~}
+ \crefname@preamble{equation}{Gleichung}{Gleichungen}
+ \Crefname@preamble{equation}{Gleichung}{Gleichungen}
+ \crefname@preamble{chapter}{Kapitel}{Kapitel}
+ \Crefname@preamble{chapter}{Kapitel}{Kapitel}
+ \crefname@preamble{section}{Abschnitt}{Abschnitte}
+ \Crefname@preamble{section}{Abschnitt}{Abschnitte}
+ \crefname@preamble{appendix}{Anhang}{Anh\"ange}
+ \Crefname@preamble{appendix}{Anhang}{Anh\"ange}
+ \crefname@preamble{figure}{Abbildung}{Abbildungen}
+ \Crefname@preamble{figure}{Abbildung}{Abbildungen}
+ \crefname@preamble{table}{Tabelle}{Tabellen}
+ \Crefname@preamble{table}{Tabelle}{Tabellen}
+ \crefname@preamble{theorem}{Theorem}{Theoremen}
+ \Crefname@preamble{theorem}{Theorem}{Theoremen}
+ \crefname@preamble{enumi}{Punkt}{Punkte}
+ \Crefname@preamble{enumi}{Punkt}{Punkte}
+ \crefname@preamble{lemma}{Lemma}{Lemmata}
+ \Crefname@preamble{lemma}{Lemma}{Lemmata}
+ \crefname@preamble{corollary}{Korollar}{Korollaren}
+ \Crefname@preamble{corollary}{Korollar}{Korollaren}
+ \crefname@preamble{proposition}{Satz}{S\"atze}
+ \Crefname@preamble{proposition}{Satz}{S\"atze}
+ \crefname@preamble{definition}{Definition}{Definitionen}
+ \Crefname@preamble{definition}{Definition}{Definitionen}
+ \crefname@preamble{result}{Ergebnis}{Ergebnisse}
+ \Crefname@preamble{result}{Ergebnis}{Ergebnisse}%
+ \def\cref@language{german}%
+% \end{macrocode}
+%
+% Next, we add the definitions to \cmd{\extras}\dots so that
+% \package{babel}'s \cmd{\selectlanguage} command will change the format
+% appropriately.
+% \begin{macrocode}
+ \cref@addto\extrasgerman{%
+ \renewcommand{\crefrangeconjunction}{ bis~}%
+ \renewcommand{\crefpairconjunction}{ und~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ und~}%
+ \renewcommand{\crefpairgroupconjunction}{ und~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ und~}%
+ \crefname{equation}{Gleichung}{Gleichungen}%
+ \Crefname{equation}{Gleichung}{Gleichungen}%
+ \crefname{chapter}{Kapitel}{Kapitel}%
+ \Crefname{chapter}{Kapitel}{Kapitel}%
+ \crefname{section}{Abschnitt}{Abschnitte}%
+ \Crefname{section}{Abschnitt}{Abschnitte}%
+ \crefname{subsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsection}{Abschnitt}{Abschnitte}%
+ \crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \crefname{appendix}{Anhang}{Anh\"ange}%
+ \Crefname{appendix}{Anhang}{Anh\"ange}%
+ \crefname{subappendix}{Anhang}{Anh\"ange}
+ \Crefname{subappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \crefname{figure}{Abbildung}{Abbildungen}%
+ \Crefname{figure}{Abbildung}{Abbildungen}%
+ \crefname{subfigure}{Abbildung}{Abbildungen}%
+ \Crefname{subfigure}{Abbildung}{Abbildungen}%
+ \crefname{table}{Tabelle}{Tabellen}%
+ \Crefname{table}{Tabelle}{Tabellen}%
+ \crefname{subtable}{Tabelle}{Tabellen}%
+ \Crefname{subtable}{Tabelle}{Tabellen}%
+ \crefname{theorem}{Theorem}{Theoremen}%
+ \Crefname{theorem}{Theorem}{Theoremen}%
+ \crefname{enumi}{Punkt}{Punkte}%
+ \Crefname{enumi}{Punkt}{Punkte}%
+ \crefname{enumii}{Punkt}{Punkte}%
+ \Crefname{enumii}{Punkt}{Punkte}%
+ \crefname{enumiii}{Punkt}{Punkte}%
+ \Crefname{enumiii}{Punkt}{Punkte}%
+ \crefname{enumiv}{Punkt}{Punkte}%
+ \Crefname{enumiv}{Punkt}{Punkte}%
+ \crefname{enumv}{Punkt}{Punkte}%
+ \Crefname{enumv}{Punkt}{Punkte}%
+ \crefname{lemma}{Lemma}{Lemmata}%
+ \Crefname{lemma}{Lemma}{Lemmata}%
+ \crefname{corollary}{Korollar}{Korollaren}%
+ \Crefname{corollary}{Korollar}{Korollaren}%
+ \crefname{proposition}{Satz}{S\"atze}%
+ \Crefname{proposition}{Satz}{S\"atze}%
+ \crefname{definition}{Definition}{Definitionen}%
+ \Crefname{definition}{Definition}{Definitionen}%
+ \crefname{result}{Ergebnis}{Ergebnisse}%
+ \Crefname{result}{Ergebnis}{Ergebnisse}%
+ }}}
% \end{macrocode}
%
%
-% Redefine \cmd{\@@setcref} and \cmd{\@@setrangeref}, as well as the
-% conjunction macros \cmd{\@setcref@middlegroupconjunction},
-% \cmd{\@setcref@lastgroupconjunction} and
-% \cmd{\@setcref@pairgroupconjunction}, to append text they typeset to
-% \cmd{\cref@text}, as well as actually doing the typesetting.
+% \begin{macro}{ngerman}
+% It so happens that none of the cross-reference names differ in the
+% ``Neuerechtschreibung'', so we make \option{ngerman} execute
+% \option{german}. However, we still need to add the definitions to
+% \cmd{\extrasngerman} (note the ``n'') so that \cmd{\selectlanguage}
+% etc.\ will work.
+% \end{macro}
% \begin{macrocode}
-\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
-% \end{macrocode}
-%
-%
-% Process options.
-% \begin{macrocode}
-\ProcessOptions\relax
+\DeclareOption{ngerman}{%
+ \PackageInfo{cleveref}{loaded `ngerman' language definitions}
+ \ExecuteOptions{german}
+ \def\cref@language{ngerman}
+ \AtBeginDocument{%
+ \cref@addto\extrasngerman{%
+ \renewcommand{\crefrangeconjunction}{ bis~}%
+ \renewcommand{\crefpairconjunction}{ und~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ und~}%
+ \renewcommand{\crefpairgroupconjunction}{ und~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ und~}%
+ \crefname{equation}{Gleichung}{Gleichungen}%
+ \Crefname{equation}{Gleichung}{Gleichungen}%
+ \crefname{chapter}{Kapitel}{Kapitel}%
+ \Crefname{chapter}{Kapitel}{Kapitel}%
+ \crefname{section}{Abschnitt}{Abschnitte}%
+ \Crefname{section}{Abschnitt}{Abschnitte}%
+ \crefname{subsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsection}{Abschnitt}{Abschnitte}%
+ \crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \crefname{appendix}{Anhang}{Anh\"ange}%
+ \Crefname{appendix}{Anhang}{Anh\"ange}%
+ \crefname{subappendix}{Anhang}{Anh\"ange}
+ \Crefname{subappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \crefname{figure}{Abbildung}{Abbildungen}%
+ \Crefname{figure}{Abbildung}{Abbildungen}%
+ \crefname{subfigure}{Abbildung}{Abbildungen}%
+ \Crefname{subfigure}{Abbildung}{Abbildungen}%
+ \crefname{table}{Tabelle}{Tabellen}%
+ \Crefname{table}{Tabelle}{Tabellen}%
+ \crefname{subtable}{Tabelle}{Tabellen}%
+ \Crefname{subtable}{Tabelle}{Tabellen}%
+ \crefname{theorem}{Theorem}{Theoremen}%
+ \Crefname{theorem}{Theorem}{Theoremen}%
+ \crefname{enumi}{Punkt}{Punkte}%
+ \Crefname{enumi}{Punkt}{Punkte}%
+ \crefname{enumii}{Punkt}{Punkte}%
+ \Crefname{enumii}{Punkt}{Punkte}%
+ \crefname{enumiii}{Punkt}{Punkte}%
+ \Crefname{enumiii}{Punkt}{Punkte}%
+ \crefname{enumiv}{Punkt}{Punkte}%
+ \Crefname{enumiv}{Punkt}{Punkte}%
+ \crefname{enumv}{Punkt}{Punkte}%
+ \Crefname{enumv}{Punkt}{Punkte}%
+ \crefname{lemma}{Lemma}{Lemmata}%
+ \Crefname{lemma}{Lemma}{Lemmata}%
+ \crefname{corollary}{Korollar}{Korollaren}%
+ \Crefname{corollary}{Korollar}{Korollaren}%
+ \crefname{proposition}{Satz}{S\"atze}%
+ \Crefname{proposition}{Satz}{S\"atze}%
+ \crefname{definition}{Definition}{Definitionen}%
+ \Crefname{definition}{Definition}{Definitionen}%
+ \crefname{result}{Ergebnis}{Ergebnisse}%
+ \Crefname{result}{Ergebnis}{Ergebnisse}%
+ }}}
+% \end{macrocode}
+%
+%
+% \begin{macro}{french}
+% French translations attempted by the package author (please report
+% any corrections that might be needed!).
+% \end{macro}
+% \begin{macrocode}
+\DeclareOption{french}{%
+ \PackageInfo{cleveref}{loaded `french' language definitions}
+% \end{macrocode}
+% First, we set up the definitions used at the beginning of the document to
+% define the formats created by the document preamble.
+% \begin{macrocode}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ \`a~}
+ \def\crefpairconjunction@preamble{ et~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ et~}
+% \end{macrocode}
+% Erring on the side of caution, I've left off the extra comma before
+% ``et'' between groups, pending more knowledgeable input on punctuation
+% rules from a native Franch speaker.
+% \begin{macrocode}
+ \def\crefpairgroupconjunction@preamble{ et~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{, et~}
+ \crefname@preamble{equation}{{\'e}quation}{{\'e}quations}
+ \Crefname@preamble{equation}{{\'E}quation}{{\'E}quations}
+ \crefname@preamble{chapter}{chapitre}{chapitres}
+ \Crefname@preamble{chapter}{Chapitre}{Chapitres}
+ \crefname@preamble{section}{section}{sections}
+ \Crefname@preamble{section}{Section}{Sections}
+ \crefname@preamble{appendix}{appendice}{appendices}
+ \Crefname@preamble{appendix}{Appendice}{Appendices}
+ \crefname@preamble{figure}{figure}{figures}
+ \Crefname@preamble{figure}{Figure}{Figures}
+ \crefname@preamble{table}{tableau}{tableaux}
+ \Crefname@preamble{table}{Tableau}{Tableaux}
+ \crefname@preamble{theorem}{th\'eor\`eme}{th\'eor\`emes}
+ \Crefname@preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}
+ \crefname@preamble{enumi}{point}{points}
+ \Crefname@preamble{enumi}{Point}{Points}
+ \crefname@preamble{lemma}{lemme}{lemmes}
+ \Crefname@preamble{lemma}{Lemme}{Lemmes}
+ \crefname@preamble{corollary}{corollaire}{corollaires}
+ \Crefname@preamble{corollary}{Corollaire}{Corollaires}
+ \crefname@preamble{proposition}{proposition}{propositions}
+ \Crefname@preamble{proposition}{Proposition}{Propositions}
+ \crefname@preamble{definition}{d\'efinition}{d\'efinitions}
+ \Crefname@preamble{definition}{D\'efinition}{D\'efinitions}
+ \crefname@preamble{result}{r\'esultat}{r\'esultats}
+ \Crefname@preamble{result}{R\'esultat}{R\'esultats}
+ \def\cref@language{french}%
+% \end{macrocode}
+%
+% Next, we add the definitions to \cmd{\extras}\dots so that
+% \package{babel}'s \cmd{\selectlanguage} command will change the format
+% appropriately.
+% \begin{macrocode}
+ \cref@addto\extrasfrench{%
+ \renewcommand{\crefrangeconjunction}{ \`a~}%
+ \renewcommand{\crefpairconjunction}{ et~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ et~}%
+ \renewcommand{\crefpairgroupconjunction}{ et~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ et~}%
+ \crefname{equation}{{\'e}quation}{{\'e}quations}%
+ \Crefname{equation}{{\'E}quation}{{\'E}quations}%
+ \crefname{chapter}{chapitre}{chapitres}%
+ \Crefname{chapter}{Chapitre}{Chapitres}%
+ \crefname{section}{section}{sections}%
+ \Crefname{section}{Section}{Sections}%
+ \crefname{subsection}{section}{sections}%
+ \Crefname{subsection}{Section}{Sections}%
+ \crefname{subsubsection}{section}{sections}%
+ \Crefname{subsubsection}{Section}{Sections}%
+ \crefname{appendix}{appendice}{appendices}%
+ \Crefname{appendix}{Appendice}{Appendices}%
+ \crefname{subappendix}{appendice}{appendices}
+ \Crefname{subappendix}{Appendice}{Appendices}
+ \crefname{subsubappendix}{appendice}{appendices}
+ \Crefname{subsubappendix}{Appendice}{Appendices}
+ \crefname{subsubsubappendix}{appendice}{appendices}
+ \Crefname{subsubsubappendix}{Appendice}{Appendices}
+ \crefname{figure}{figure}{figures}%
+ \Crefname{figure}{Figure}{Figures}%
+ \crefname{subfigure}{figure}{figures}%
+ \Crefname{subfigure}{Figure}{Figures}%
+ \crefname{table}{tableau}{tableaux}%
+ \Crefname{table}{Tableau}{Tableaux}%
+ \crefname{subtable}{tableau}{tableaux}%
+ \Crefname{subtable}{Tableau}{Tableaux}%
+ \crefname{theorem}{th\'eor\`eme}{th\'eor\`emes}%
+ \Crefname{theorem}{Th\'eor\`eme}{Th\'eor\`emes}%
+ \crefname{enumi}{point}{points}%
+ \Crefname{enumi}{Point}{Points}%
+ \crefname{enumii}{point}{points}%
+ \Crefname{enumii}{Point}{Points}%
+ \crefname{enumiii}{point}{points}%
+ \Crefname{enumiii}{Point}{Points}%
+ \crefname{enumiv}{point}{points}%
+ \Crefname{enumiv}{Point}{Points}%
+ \crefname{enumv}{point}{points}%
+ \Crefname{enumv}{Point}{Points}%
+ \crefname{lemma}{lemme}{lemmes}%
+ \Crefname{lemma}{Lemme}{Lemmes}%
+ \crefname{corollary}{corollaire}{corollaires}%
+ \Crefname{corollary}{Corollaire}{Corollaires}%
+ \crefname{proposition}{proposition}{propositions}%
+ \Crefname{proposition}{Proposition}{Propositions}%
+ \crefname{definition}{d\'efinition}{d\'efinitions}%
+ \Crefname{definition}{D\'efinition}{D\'efinitions}%
+ \crefname{result}{r\'esultat}{r\'esultats}%
+ \Crefname{result}{R\'esultat}{R\'esultats}%
+ }}}
+% \end{macrocode}
+%
+%
+%
+% \subsubsection{Default Cross-Reference Formats}
+% \label{sec:code:default_formats}
+% Setup default English format definitions, then process options in
+% the order they were supplied.
+% \begin{macrocode}
+\ExecuteOptions{english}
+\ProcessOptions*\relax
% \end{macrocode}
%
+%
+% Define the component-derived formats.
+% \begin{macrocode}
+\AtBeginDocument{%
+% \end{macrocode}
+% Use whatever's in the \dots|@preamble| definitions at the beginning of
+% the document to set up the default cross-reference names.
+% \begin{macrocode}
+ \edef\@tmpa{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \@ifundefined{crefrangeconjunction}{%
+ \let\crefrangeconjunction\crefrangeconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefrangeconjunction\expandafter}%
+ \expandafter{\crefrangeconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefpairconjunction}{%
+ \let\crefpairconjunction\crefpairconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairconjunction\expandafter}%
+ \expandafter{\crefpairconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefmiddleconjunction}{%
+ \let\crefmiddleconjunction\crefmiddleconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefmiddleconjunction\expandafter}%
+ \expandafter{\crefmiddleconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{creflastconjunction}{%
+ \let\creflastconjunction\creflastconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\creflastconjunction\expandafter}%
+ \expandafter{\creflastconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction%
+ \crefpairgroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairgroupconjunction\expandafter}%
+ \expandafter{\crefpairgroupconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction%
+ \crefmiddlegroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairmiddleconjunction\expandafter}%
+ \expandafter{\crefpairmiddleconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{creflastgroupconjunction}{%
+ \let\creflastgroupconjunction%
+ \creflastgroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairlastconjunction\expandafter}%
+ \expandafter{\crefpairlastconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+% \end{macrocode}
+% If the group conjunctions haven't been defined, define them to be
+% identical to the reference conjunctions.
+% \begin{macrocode}
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction\crefpairconjunction}{}%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
+% \end{macrocode}
+% Define the last group conjunction to include an extra comma.
+% \begin{macrocode}
+ \@ifundefined{creflastgroupconjunction}{%
+ \edef\creflastgroupconjunction{, \creflastconjunction}}{}%
+% \end{macrocode}
+%
+% Define any undefined formats listed in \cmd{\cref@label@types} using
+% the components.
+% \begin{macrocode}
+ \let\@tmpstack\cref@label@types%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \@ifundefined{cref@\@tmpa @name}{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname cref@\@tmpa @name@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname cref@\@tmpa @name@plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc
+ }{%
+ \edef\@tmpb{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \expandafter\crefname\expandafter{\@tmpa}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpb\expandafter{\@tmpc}%
+ }%
+ \@ifundefined{Cref@\@tmpa @name}{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname Cref@\@tmpa @name@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname Cref@\@tmpa @name@plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc
+ }{%
+ \edef\@tmpb{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \expandafter\Crefname\expandafter{\@tmpa}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpb\expandafter{\@tmpc}%
+ }%
+ \@ifundefined{cref@\@tmpa @format}{%
+ \expandafter\@crefdefineformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{crefrange@\@tmpa @format}{%
+ \expandafter\@crefrangedefineformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{cref@\@tmpa @format@first}{%
+ \expandafter\@crefdefinemultiformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{crefrange@\@tmpa @format@first}{%
+ \expandafter\@crefrangedefinemultiformat\expandafter{\@tmpa}}{}%
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}}%
+% \end{macrocode}
+%
+% If formats for subsections are undefined, define them to be identical
+% to the formats for sections.
+% \begin{macrocode}
+ \@ifundefined{cref@subsection@format}{%
+ \let\cref@subsection@format%
+ \cref@section@format}{}%
+ \@ifundefined{Cref@subsection@format}{%
+ \let\Cref@subsection@format%
+ \Cref@section@format}{}%
+ \@ifundefined{crefrange@subsection@format}{%
+ \let\crefrange@subsection@format%
+ \crefrange@section@format}{}%
+ \@ifundefined{Crefrange@subsection@format}{%
+ \let\Crefrange@subsection@format%
+ \Crefrange@section@format}{}%
+ \@ifundefined{cref@subsection@format@first}{%
+ \let\cref@subsection@format@first%
+ \cref@section@format@first}{}%
+ \@ifundefined{Cref@subsection@format@first}{%
+ \let\Cref@subsection@format@first%
+ \Cref@section@format@first}{}%
+ \@ifundefined{cref@subsection@format@second}{%
+ \let\cref@subsection@format@second%
+ \cref@section@format@second}{}%
+ \@ifundefined{Cref@subsection@format@second}{%
+ \let\Cref@subsection@format@second%
+ \Cref@section@format@second}{}%
+ \@ifundefined{cref@subsection@format@middle}{%
+ \let\cref@subsection@format@middle%
+ \cref@section@format@middle}{}%
+ \@ifundefined{Cref@subsection@format@middle}{%
+ \let\Cref@subsection@format@middle%
+ \Cref@section@format@middle}{}%
+ \@ifundefined{cref@subsection@format@last}{%
+ \let\cref@subsection@format@last%
+ \cref@section@format@last}{}%
+ \@ifundefined{Cref@subsection@format@last}{%
+ \let\Cref@subsection@format@last%
+ \Cref@section@format@last}{}%
+ \@ifundefined{crefrange@subsection@format@first}{%
+ \let\crefrange@subsection@format@first%
+ \crefrange@section@format@first}{}%
+ \@ifundefined{Crefrange@subsection@format@first}{%
+ \let\Crefrange@subsection@format@first%
+ \Crefrange@section@format@first}{}%
+ \@ifundefined{crefrange@subsection@format@second}{%
+ \let\crefrange@subsection@format@second%
+ \crefrange@section@format@second}{}%
+ \@ifundefined{Crefrange@subsection@format@second}{%
+ \let\Crefrange@subsection@format@second%
+ \Crefrange@section@format@second}{}%
+ \@ifundefined{crefrange@subsection@format@middle}{%
+ \let\crefrange@subsection@format@middle%
+ \crefrange@section@format@middle}{}%
+ \@ifundefined{Crefrange@subsection@format@middle}{%
+ \let\Crefrange@subsection@format@middle%
+ \Crefrange@section@format@middle}{}%
+ \@ifundefined{crefrange@subsection@format@last}{%
+ \let\crefrange@subsection@format@last%
+ \crefrange@section@format@last}{}%
+ \@ifundefined{Crefrange@subsection@format@last}{%
+ \let\Crefrange@subsection@format@last%
+ \Crefrange@section@format@last}{}%
+%
+ \@ifundefined{cref@subsubsection@format}{%
+ \let\cref@subsubsection@format%
+ \cref@subsection@format}{}%
+ \@ifundefined{Cref@subsubsection@format}{%
+ \let\Cref@subsubsection@format%
+ \Cref@subsection@format}{}%
+ \@ifundefined{crefrange@subsubsection@format}{%
+ \let\crefrange@subsubsection@format%
+ \crefrange@subsection@format}{}%
+ \@ifundefined{Crefrange@subsubsection@format}{%
+ \let\Crefrange@subsubsection@format%
+ \Crefrange@subsection@format}{}%
+ \@ifundefined{cref@subsubsection@format@first}{%
+ \let\cref@subsubsection@format@first%
+ \cref@subsection@format@first}{}%
+ \@ifundefined{Cref@subsubsection@format@first}{%
+ \let\Cref@subsubsection@format@first%
+ \Cref@subsection@format@first}{}%
+ \@ifundefined{cref@subsubsection@format@second}{%
+ \let\cref@subsubsection@format@second%
+ \cref@subsection@format@second}{}%
+ \@ifundefined{Cref@subsubsection@format@second}{%
+ \let\Cref@subsubsection@format@second%
+ \Cref@subsection@format@second}{}%
+ \@ifundefined{cref@subsubsection@format@middle}{%
+ \let\cref@subsubsection@format@middle%
+ \cref@subsection@format@middle}{}%
+ \@ifundefined{Cref@subsubsection@format@middle}{%
+ \let\Cref@subsubsection@format@middle%
+ \Cref@subsection@format@middle}{}%
+ \@ifundefined{cref@subsubsection@format@last}{%
+ \let\cref@subsubsection@format@last%
+ \cref@subsection@format@last}{}%
+ \@ifundefined{Cref@subsubsection@format@last}{%
+ \let\Cref@subsubsection@format@last%
+ \Cref@subsection@format@last}{}%
+ \@ifundefined{crefrange@subsubsection@format@first}{%
+ \let\crefrange@subsubsection@format@first%
+ \crefrange@subsection@format@first}{}%
+ \@ifundefined{Crefrange@subsubsection@format@first}{%
+ \let\Crefrange@subsubsection@format@first%
+ \Crefrange@subsection@format@first}{}%
+ \@ifundefined{crefrange@subsubsection@format@second}{%
+ \let\crefrange@subsubsection@format@second%
+ \crefrange@subsection@format@second}{}%
+ \@ifundefined{Crefrange@subsubsection@format@second}{%
+ \let\Crefrange@subsubsection@format@second%
+ \Crefrange@subsection@format@second}{}%
+ \@ifundefined{crefrange@subsubsection@format@middle}{%
+ \let\crefrange@subsubsection@format@middle%
+ \crefrange@subsection@format@middle}{}%
+ \@ifundefined{Crefrange@subsubsection@format@middle}{%
+ \let\Crefrange@subsubsection@format@middle%
+ \Crefrange@subsection@format@middle}{}%
+ \@ifundefined{crefrange@subsubsection@format@last}{%
+ \let\crefrange@subsubsection@format@last%
+ \crefrange@subsection@format@last}{}%
+ \@ifundefined{Crefrange@subsubsection@format@last}{%
+ \let\Crefrange@subsubsection@format@last%
+ \Crefrange@subsection@format@last}{}%
+% \end{macrocode}
+% Similarly for subsections within appendices.
+% \begin{macrocode}
+% \begin{macrocode}
+ \@ifundefined{cref@subappendix@format}{%
+ \let\cref@subappendix@format%
+ \cref@appendix@format}{}%
+ \@ifundefined{Cref@subappendix@format}{%
+ \let\Cref@subappendix@format%
+ \Cref@appendix@format}{}%
+ \@ifundefined{crefrange@subappendix@format}{%
+ \let\crefrange@subappendix@format%
+ \crefrange@appendix@format}{}%
+ \@ifundefined{Crefrange@subappendix@format}{%
+ \let\Crefrange@subappendix@format%
+ \Crefrange@appendix@format}{}%
+ \@ifundefined{cref@subappendix@format@first}{%
+ \let\cref@subappendix@format@first%
+ \cref@appendix@format@first}{}%
+ \@ifundefined{Cref@subappendix@format@first}{%
+ \let\Cref@subappendix@format@first%
+ \Cref@appendix@format@first}{}%
+ \@ifundefined{cref@subappendix@format@second}{%
+ \let\cref@subappendix@format@second%
+ \cref@appendix@format@second}{}%
+ \@ifundefined{Cref@subappendix@format@second}{%
+ \let\Cref@subappendix@format@second%
+ \Cref@appendix@format@second}{}%
+ \@ifundefined{cref@subappendix@format@middle}{%
+ \let\cref@subappendix@format@middle%
+ \cref@appendix@format@middle}{}%
+ \@ifundefined{Cref@subappendix@format@middle}{%
+ \let\Cref@subappendix@format@middle%
+ \Cref@appendix@format@middle}{}%
+ \@ifundefined{cref@subappendix@format@last}{%
+ \let\cref@subappendix@format@last%
+ \cref@appendix@format@last}{}%
+ \@ifundefined{Cref@subappendix@format@last}{%
+ \let\Cref@subappendix@format@last%
+ \Cref@appendix@format@last}{}%
+ \@ifundefined{crefrange@subappendix@format@first}{%
+ \let\crefrange@subappendix@format@first%
+ \crefrange@appendix@format@first}{}%
+ \@ifundefined{Crefrange@subappendix@format@first}{%
+ \let\Crefrange@subappendix@format@first%
+ \Crefrange@appendix@format@first}{}%
+ \@ifundefined{crefrange@subappendix@format@second}{%
+ \let\crefrange@subappendix@format@second%
+ \crefrange@appendix@format@second}{}%
+ \@ifundefined{Crefrange@subappendix@format@second}{%
+ \let\Crefrange@subappendix@format@second%
+ \Crefrange@appendix@format@second}{}%
+ \@ifundefined{crefrange@subappendix@format@middle}{%
+ \let\crefrange@subappendix@format@middle%
+ \crefrange@appendix@format@middle}{}%
+ \@ifundefined{Crefrange@subappendix@format@middle}{%
+ \let\Crefrange@subappendix@format@middle%
+ \Crefrange@appendix@format@middle}{}%
+ \@ifundefined{crefrange@subappendix@format@last}{%
+ \let\crefrange@subappendix@format@last%
+ \crefrange@appendix@format@last}{}%
+ \@ifundefined{Crefrange@subappendix@format@last}{%
+ \let\Crefrange@subappendix@format@last%
+ \Crefrange@appendix@format@last}{}%
+%
+ \@ifundefined{cref@subsubappendix@format}{%
+ \let\cref@subsubappendix@format%
+ \cref@subappendix@format}{}%
+ \@ifundefined{Cref@subsubappendix@format}{%
+ \let\Cref@subsubappendix@format%
+ \Cref@subappendix@format}{}%
+ \@ifundefined{crefrange@subsubappendix@format}{%
+ \let\crefrange@subsubappendix@format%
+ \crefrange@subappendix@format}{}%
+ \@ifundefined{Crefrange@subsubappendix@format}{%
+ \let\Crefrange@subsubappendix@format%
+ \Crefrange@subappendix@format}{}%
+ \@ifundefined{cref@subsubappendix@format@first}{%
+ \let\cref@subsubappendix@format@first%
+ \cref@subappendix@format@first}{}%
+ \@ifundefined{Cref@subsubappendix@format@first}{%
+ \let\Cref@subsubappendix@format@first%
+ \Cref@subappendix@format@first}{}%
+ \@ifundefined{cref@subsubappendix@format@second}{%
+ \let\cref@subsubappendix@format@second%
+ \cref@subappendix@format@second}{}%
+ \@ifundefined{Cref@subsubappendix@format@second}{%
+ \let\Cref@subsubappendix@format@second%
+ \Cref@subappendix@format@second}{}%
+ \@ifundefined{cref@subsubappendix@format@middle}{%
+ \let\cref@subsubappendix@format@middle%
+ \cref@subappendix@format@middle}{}%
+ \@ifundefined{Cref@subsubappendix@format@middle}{%
+ \let\Cref@subsubappendix@format@middle%
+ \Cref@subappendix@format@middle}{}%
+ \@ifundefined{cref@subsubappendix@format@last}{%
+ \let\cref@subsubappendix@format@last%
+ \cref@subappendix@format@last}{}%
+ \@ifundefined{Cref@subsubappendix@format@last}{%
+ \let\Cref@subsubappendix@format@last%
+ \Cref@subappendix@format@last}{}%
+ \@ifundefined{crefrange@subsubappendix@format@first}{%
+ \let\crefrange@subsubappendix@format@first%
+ \crefrange@subappendix@format@first}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@first}{%
+ \let\Crefrange@subsubappendix@format@first%
+ \Crefrange@subappendix@format@first}{}%
+ \@ifundefined{crefrange@subsubappendix@format@second}{%
+ \let\crefrange@subsubappendix@format@second%
+ \crefrange@subappendix@format@second}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@second}{%
+ \let\Crefrange@subsubappendix@format@second%
+ \Crefrange@subappendix@format@second}{}%
+ \@ifundefined{crefrange@subsubappendix@format@middle}{%
+ \let\crefrange@subsubappendix@format@middle%
+ \crefrange@subappendix@format@middle}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@middle}{%
+ \let\Crefrange@subsubappendix@format@middle%
+ \Crefrange@subappendix@format@middle}{}%
+ \@ifundefined{crefrange@subsubappendix@format@last}{%
+ \let\crefrange@subsubappendix@format@last%
+ \crefrange@subappendix@format@last}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@last}{%
+ \let\Crefrange@subsubappendix@format@last%
+ \Crefrange@subappendix@format@last}{}%
+%
+ \@ifundefined{cref@subsubsubappendix@format}{%
+ \let\cref@subsubsubappendix@format%
+ \cref@subsubappendix@format}{}%
+ \@ifundefined{Cref@subsubsubappendix@format}{%
+ \let\Cref@subsubsubappendix@format%
+ \Cref@subsubappendix@format}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format}{%
+ \let\crefrange@subsubsubappendix@format%
+ \crefrange@subsubappendix@format}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format}{%
+ \let\Crefrange@subsubsubappendix@format%
+ \Crefrange@subsubappendix@format}{}%
+ \@ifundefined{cref@subsubsubappendix@format@first}{%
+ \let\cref@subsubsubappendix@format@first%
+ \cref@subsubappendix@format@first}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@first}{%
+ \let\Cref@subsubsubappendix@format@first%
+ \Cref@subsubappendix@format@first}{}%
+ \@ifundefined{cref@subsubsubappendix@format@second}{%
+ \let\cref@subsubsubappendix@format@second%
+ \cref@subsubappendix@format@second}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@second}{%
+ \let\Cref@subsubsubappendix@format@second%
+ \Cref@subsubappendix@format@second}{}%
+ \@ifundefined{cref@subsubsubappendix@format@middle}{%
+ \let\cref@subsubsubappendix@format@middle%
+ \cref@subsubappendix@format@middle}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@middle}{%
+ \let\Cref@subsubsubappendix@format@middle%
+ \Cref@subsubappendix@format@middle}{}%
+ \@ifundefined{cref@subsubsubappendix@format@last}{%
+ \let\cref@subsubsubappendix@format@last%
+ \cref@subsubappendix@format@last}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@last}{%
+ \let\Cref@subsubsubappendix@format@last%
+ \Cref@subsubappendix@format@last}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@first}{%
+ \let\crefrange@subsubsubappendix@format@first%
+ \crefrange@subsubappendix@format@first}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@first}{%
+ \let\Crefrange@subsubsubappendix@format@first%
+ \Crefrange@subsubappendix@format@first}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@second}{%
+ \let\crefrange@subsubsubappendix@format@second%
+ \crefrange@subsubappendix@format@second}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@second}{%
+ \let\Crefrange@subsubsubappendix@format@second%
+ \Crefrange@subsubappendix@format@second}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@middle}{%
+ \let\crefrange@subsubsubappendix@format@middle%
+ \crefrange@subsubappendix@format@middle}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@middle}{%
+ \let\Crefrange@subsubsubappendix@format@middle%
+ \Crefrange@subsubappendix@format@middle}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@last}{%
+ \let\crefrange@subsubsubappendix@format@last%
+ \crefrange@subsubappendix@format@last}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@last}{%
+ \let\Crefrange@subsubsubappendix@format@last%
+ \Crefrange@subsubappendix@format@last}{}%
+% \end{macrocode}
+% Ditto for subfigures and subtables.
+% \begin{macrocode}
+ \@ifundefined{cref@subfigure@format}{%
+ \let\cref@subfigure@format%
+ \cref@figure@format}{}%
+ \@ifundefined{Cref@subfigure@format}{%
+ \let\Cref@subfigure@format%
+ \Cref@figure@format}{}%
+ \@ifundefined{crefrange@subfigure@format}{%
+ \let\crefrange@subfigure@format%
+ \crefrange@figure@format}{}%
+ \@ifundefined{Crefrange@subfigure@format}{%
+ \let\Crefrange@subfigure@format%
+ \Crefrange@figure@format}{}%
+ \@ifundefined{cref@subfigure@format@first}{%
+ \let\cref@subfigure@format@first%
+ \cref@figure@format@first}{}%
+ \@ifundefined{Cref@subfigure@format@first}{%
+ \let\Cref@subfigure@format@first%
+ \Cref@figure@format@first}{}%
+ \@ifundefined{cref@subfigure@format@second}{%
+ \let\cref@subfigure@format@second%
+ \cref@figure@format@second}{}%
+ \@ifundefined{Cref@subfigure@format@second}{%
+ \let\Cref@subfigure@format@second%
+ \Cref@figure@format@second}{}%
+ \@ifundefined{cref@subfigure@format@middle}{%
+ \let\cref@subfigure@format@middle%
+ \cref@figure@format@middle}{}%
+ \@ifundefined{Cref@subfigure@format@middle}{%
+ \let\Cref@subfigure@format@middle%
+ \Cref@figure@format@middle}{}%
+ \@ifundefined{cref@subfigure@format@last}{%
+ \let\cref@subfigure@format@last%
+ \cref@figure@format@last}{}%
+ \@ifundefined{Cref@subfigure@format@last}{%
+ \let\Cref@subfigure@format@last%
+ \Cref@figure@format@last}{}%
+ \@ifundefined{crefrange@subfigure@format@first}{%
+ \let\crefrange@subfigure@format@first%
+ \crefrange@figure@format@first}{}%
+ \@ifundefined{Crefrange@subfigure@format@first}{%
+ \let\Crefrange@subfigure@format@first%
+ \Crefrange@figure@format@first}{}%
+ \@ifundefined{crefrange@subfigure@format@second}{%
+ \let\crefrange@subfigure@format@second%
+ \crefrange@figure@format@second}{}%
+ \@ifundefined{Crefrange@subfigure@format@second}{%
+ \let\Crefrange@subfigure@format@second%
+ \Crefrange@figure@format@second}{}%
+ \@ifundefined{crefrange@subfigure@format@middle}{%
+ \let\crefrange@subfigure@format@middle%
+ \crefrange@figure@format@middle}{}%
+ \@ifundefined{Crefrange@subfigure@format@middle}{%
+ \let\Crefrange@subfigure@format@middle%
+ \Crefrange@figure@format@middle}{}%
+ \@ifundefined{crefrange@subfigure@format@last}{%
+ \let\crefrange@subfigure@format@last%
+ \crefrange@figure@format@last}{}%
+ \@ifundefined{Crefrange@subfigure@format@last}{%
+ \let\Crefrange@subfigure@format@last%
+ \Crefrange@figure@format@last}{}%
+%
+% \begin{macrocode}
+ \@ifundefined{cref@subtable@format}{%
+ \let\cref@subtable@format%
+ \cref@table@format}{}%
+ \@ifundefined{Cref@subtable@format}{%
+ \let\Cref@subtable@format%
+ \Cref@table@format}{}%
+ \@ifundefined{crefrange@subtable@format}{%
+ \let\crefrange@subtable@format%
+ \crefrange@table@format}{}%
+ \@ifundefined{Crefrange@subtable@format}{%
+ \let\Crefrange@subtable@format%
+ \Crefrange@table@format}{}%
+ \@ifundefined{cref@subtable@format@first}{%
+ \let\cref@subtable@format@first%
+ \cref@table@format@first}{}%
+ \@ifundefined{Cref@subtable@format@first}{%
+ \let\Cref@subtable@format@first%
+ \Cref@table@format@first}{}%
+ \@ifundefined{cref@subtable@format@second}{%
+ \let\cref@subtable@format@second%
+ \cref@table@format@second}{}%
+ \@ifundefined{Cref@subtable@format@second}{%
+ \let\Cref@subtable@format@second%
+ \Cref@table@format@second}{}%
+ \@ifundefined{cref@subtable@format@middle}{%
+ \let\cref@subtable@format@middle%
+ \cref@table@format@middle}{}%
+ \@ifundefined{Cref@subtable@format@middle}{%
+ \let\Cref@subtable@format@middle%
+ \Cref@table@format@middle}{}%
+ \@ifundefined{cref@subtable@format@last}{%
+ \let\cref@subtable@format@last%
+ \cref@table@format@last}{}%
+ \@ifundefined{Cref@subtable@format@last}{%
+ \let\Cref@subtable@format@last%
+ \Cref@table@format@last}{}%
+ \@ifundefined{crefrange@subtable@format@first}{%
+ \let\crefrange@subtable@format@first%
+ \crefrange@table@format@first}{}%
+ \@ifundefined{Crefrange@subtable@format@first}{%
+ \let\Crefrange@subtable@format@first%
+ \Crefrange@table@format@first}{}%
+ \@ifundefined{crefrange@subtable@format@second}{%
+ \let\crefrange@subtable@format@second%
+ \crefrange@table@format@second}{}%
+ \@ifundefined{Crefrange@subtable@format@second}{%
+ \let\Crefrange@subtable@format@second%
+ \Crefrange@table@format@second}{}%
+ \@ifundefined{crefrange@subtable@format@middle}{%
+ \let\crefrange@subtable@format@middle%
+ \crefrange@table@format@middle}{}%
+ \@ifundefined{Crefrange@subtable@format@middle}{%
+ \let\Crefrange@subtable@format@middle%
+ \Crefrange@table@format@middle}{}%
+ \@ifundefined{crefrange@subtable@format@last}{%
+ \let\crefrange@subtable@format@last%
+ \crefrange@table@format@last}{}%
+ \@ifundefined{Crefrange@subtable@format@last}{%
+ \let\Crefrange@subtable@format@last%
+ \Crefrange@table@format@last}{}%
+% \end{macrocode}
+% Ditto for enums.
+% \begin{macrocode}
+% \begin{macrocode}
+ \@ifundefined{cref@enumii@format}{%
+ \let\cref@enumii@format%
+ \cref@enumi@format}{}%
+ \@ifundefined{Cref@enumii@format}{%
+ \let\Cref@enumii@format%
+ \Cref@enumi@format}{}%
+ \@ifundefined{crefrange@enumii@format}{%
+ \let\crefrange@enumii@format%
+ \crefrange@enumi@format}{}%
+ \@ifundefined{Crefrange@enumii@format}{%
+ \let\Crefrange@enumii@format%
+ \Crefrange@enumi@format}{}%
+ \@ifundefined{cref@enumii@format@first}{%
+ \let\cref@enumii@format@first%
+ \cref@enumi@format@first}{}%
+ \@ifundefined{Cref@enumii@format@first}{%
+ \let\Cref@enumii@format@first%
+ \Cref@enumi@format@first}{}%
+ \@ifundefined{cref@enumii@format@second}{%
+ \let\cref@enumii@format@second%
+ \cref@enumi@format@second}{}%
+ \@ifundefined{Cref@enumii@format@second}{%
+ \let\Cref@enumii@format@second%
+ \Cref@enumi@format@second}{}%
+ \@ifundefined{cref@enumii@format@middle}{%
+ \let\cref@enumii@format@middle%
+ \cref@enumi@format@middle}{}%
+ \@ifundefined{Cref@enumii@format@middle}{%
+ \let\Cref@enumii@format@middle%
+ \Cref@enumi@format@middle}{}%
+ \@ifundefined{cref@enumii@format@last}{%
+ \let\cref@enumii@format@last%
+ \cref@enumi@format@last}{}%
+ \@ifundefined{Cref@enumii@format@last}{%
+ \let\Cref@enumii@format@last%
+ \Cref@enumi@format@last}{}%
+ \@ifundefined{crefrange@enumii@format@first}{%
+ \let\crefrange@enumii@format@first%
+ \crefrange@enumi@format@first}{}%
+ \@ifundefined{Crefrange@enumii@format@first}{%
+ \let\Crefrange@enumii@format@first%
+ \Crefrange@enumi@format@first}{}%
+ \@ifundefined{crefrange@enumii@format@second}{%
+ \let\crefrange@enumii@format@second%
+ \crefrange@enumi@format@second}{}%
+ \@ifundefined{Crefrange@enumii@format@second}{%
+ \let\Crefrange@enumii@format@second%
+ \Crefrange@enumi@format@second}{}%
+ \@ifundefined{crefrange@enumii@format@middle}{%
+ \let\crefrange@enumii@format@middle%
+ \crefrange@enumi@format@middle}{}%
+ \@ifundefined{Crefrange@enumii@format@middle}{%
+ \let\Crefrange@enumii@format@middle%
+ \Crefrange@enumi@format@middle}{}%
+ \@ifundefined{crefrange@enumii@format@last}{%
+ \let\crefrange@enumii@format@last%
+ \crefrange@enumi@format@last}{}%
+ \@ifundefined{Crefrange@enumii@format@last}{%
+ \let\Crefrange@enumii@format@last%
+ \Crefrange@enumi@format@last}{}%
+%
+% \begin{macrocode}
+ \@ifundefined{cref@enumiii@format}{%
+ \let\cref@enumiii@format%
+ \cref@enumii@format}{}%
+ \@ifundefined{Cref@enumiii@format}{%
+ \let\Cref@enumiii@format%
+ \Cref@enumii@format}{}%
+ \@ifundefined{crefrange@enumiii@format}{%
+ \let\crefrange@enumiii@format%
+ \crefrange@enumii@format}{}%
+ \@ifundefined{Crefrange@enumiii@format}{%
+ \let\Crefrange@enumiii@format%
+ \Crefrange@enumii@format}{}%
+ \@ifundefined{cref@enumiii@format@first}{%
+ \let\cref@enumiii@format@first%
+ \cref@enumii@format@first}{}%
+ \@ifundefined{Cref@enumiii@format@first}{%
+ \let\Cref@enumiii@format@first%
+ \Cref@enumii@format@first}{}%
+ \@ifundefined{cref@enumiii@format@second}{%
+ \let\cref@enumiii@format@second%
+ \cref@enumii@format@second}{}%
+ \@ifundefined{Cref@enumiii@format@second}{%
+ \let\Cref@enumiii@format@second%
+ \Cref@enumii@format@second}{}%
+ \@ifundefined{cref@enumiii@format@middle}{%
+ \let\cref@enumiii@format@middle%
+ \cref@enumii@format@middle}{}%
+ \@ifundefined{Cref@enumiii@format@middle}{%
+ \let\Cref@enumiii@format@middle%
+ \Cref@enumii@format@middle}{}%
+ \@ifundefined{cref@enumiii@format@last}{%
+ \let\cref@enumiii@format@last%
+ \cref@enumii@format@last}{}%
+ \@ifundefined{Cref@enumiii@format@last}{%
+ \let\Cref@enumiii@format@last%
+ \Cref@enumii@format@last}{}%
+ \@ifundefined{crefrange@enumiii@format@first}{%
+ \let\crefrange@enumiii@format@first%
+ \crefrange@enumii@format@first}{}%
+ \@ifundefined{Crefrange@enumiii@format@first}{%
+ \let\Crefrange@enumiii@format@first%
+ \Crefrange@enumii@format@first}{}%
+ \@ifundefined{crefrange@enumiii@format@second}{%
+ \let\crefrange@enumiii@format@second%
+ \crefrange@enumii@format@second}{}%
+ \@ifundefined{Crefrange@enumiii@format@second}{%
+ \let\Crefrange@enumiii@format@second%
+ \Crefrange@enumii@format@second}{}%
+ \@ifundefined{crefrange@enumiii@format@middle}{%
+ \let\crefrange@enumiii@format@middle%
+ \crefrange@enumii@format@middle}{}%
+ \@ifundefined{Crefrange@enumiii@format@middle}{%
+ \let\Crefrange@enumiii@format@middle%
+ \Crefrange@enumii@format@middle}{}%
+ \@ifundefined{crefrange@enumiii@format@last}{%
+ \let\crefrange@enumiii@format@last%
+ \crefrange@enumii@format@last}{}%
+ \@ifundefined{Crefrange@enumiii@format@last}{%
+ \let\Crefrange@enumiii@format@last%
+ \Crefrange@enumii@format@last}{}%
+%
+ \@ifundefined{cref@enumiv@format}{%
+ \let\cref@enumiv@format%
+ \cref@enumiii@format}{}%
+ \@ifundefined{Cref@enumiv@format}{%
+ \let\Cref@enumiv@format%
+ \Cref@enumiii@format}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \let\crefrange@enumiv@format%
+ \crefrange@enumiii@format}{}%
+ \@ifundefined{Crefrange@enumiv@format}{%
+ \let\Crefrange@enumiv@format%
+ \Crefrange@enumiii@format}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \let\cref@enumiv@format@first%
+ \cref@enumiii@format@first}{}%
+ \@ifundefined{Cref@enumiv@format@first}{%
+ \let\Cref@enumiv@format@first%
+ \Cref@enumiii@format@first}{}%
+ \@ifundefined{cref@enumiv@format@second}{%
+ \let\cref@enumiv@format@second%
+ \cref@enumiii@format@second}{}%
+ \@ifundefined{Cref@enumiv@format@second}{%
+ \let\Cref@enumiv@format@second%
+ \Cref@enumiii@format@second}{}%
+ \@ifundefined{cref@enumiv@format@middle}{%
+ \let\cref@enumiv@format@middle%
+ \cref@enumiii@format@middle}{}%
+ \@ifundefined{Cref@enumiv@format@middle}{%
+ \let\Cref@enumiv@format@middle%
+ \Cref@enumiii@format@middle}{}%
+ \@ifundefined{cref@enumiv@format@last}{%
+ \let\cref@enumiv@format@last%
+ \cref@enumiii@format@last}{}%
+ \@ifundefined{Cref@enumiv@format@last}{%
+ \let\Cref@enumiv@format@last%
+ \Cref@enumiii@format@last}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \let\crefrange@enumiv@format@first%
+ \crefrange@enumiii@format@first}{}%
+ \@ifundefined{Crefrange@enumiv@format@first}{%
+ \let\Crefrange@enumiv@format@first%
+ \Crefrange@enumiii@format@first}{}%
+ \@ifundefined{crefrange@enumiv@format@second}{%
+ \let\crefrange@enumiv@format@second%
+ \crefrange@enumiii@format@second}{}%
+ \@ifundefined{Crefrange@enumiv@format@second}{%
+ \let\Crefrange@enumiv@format@second%
+ \Crefrange@enumiii@format@second}{}%
+ \@ifundefined{crefrange@enumiv@format@middle}{%
+ \let\crefrange@enumiv@format@middle%
+ \crefrange@enumiii@format@middle}{}%
+ \@ifundefined{Crefrange@enumiv@format@middle}{%
+ \let\Crefrange@enumiv@format@middle%
+ \Crefrange@enumiii@format@middle}{}%
+ \@ifundefined{crefrange@enumiv@format@last}{%
+ \let\crefrange@enumiv@format@last%
+ \crefrange@enumiii@format@last}{}%
+ \@ifundefined{Crefrange@enumiv@format@last}{%
+ \let\Crefrange@enumiv@format@last%
+ \Crefrange@enumiii@format@last}{}%
+%
+ \@ifundefined{cref@enumv@format}{%
+ \let\cref@enumv@format%
+ \cref@enumiv@format}{}%
+ \@ifundefined{Cref@enumv@format}{%
+ \let\Cref@enumv@format%
+ \Cref@enumiv@format}{}%
+ \@ifundefined{crefrange@enumv@format}{%
+ \let\crefrange@enumv@format%
+ \crefrange@enumiv@format}{}%
+ \@ifundefined{Crefrange@enumv@format}{%
+ \let\Crefrange@enumv@format%
+ \Crefrange@enumiv@format}{}%
+ \@ifundefined{cref@enumv@format@first}{%
+ \let\cref@enumv@format@first%
+ \cref@enumiv@format@first}{}%
+ \@ifundefined{Cref@enumv@format@first}{%
+ \let\Cref@enumv@format@first%
+ \Cref@enumiv@format@first}{}%
+ \@ifundefined{cref@enumv@format@second}{%
+ \let\cref@enumv@format@second%
+ \cref@enumiv@format@second}{}%
+ \@ifundefined{Cref@enumv@format@second}{%
+ \let\Cref@enumv@format@second%
+ \Cref@enumiv@format@second}{}%
+ \@ifundefined{cref@enumv@format@middle}{%
+ \let\cref@enumv@format@middle%
+ \cref@enumiv@format@middle}{}%
+ \@ifundefined{Cref@enumv@format@middle}{%
+ \let\Cref@enumv@format@middle%
+ \Cref@enumiv@format@middle}{}%
+ \@ifundefined{cref@enumv@format@last}{%
+ \let\cref@enumv@format@last%
+ \cref@enumiv@format@last}{}%
+ \@ifundefined{Cref@enumv@format@last}{%
+ \let\Cref@enumv@format@last%
+ \Cref@enumiv@format@last}{}%
+ \@ifundefined{crefrange@enumv@format@first}{%
+ \let\crefrange@enumv@format@first%
+ \crefrange@enumiv@format@first}{}%
+ \@ifundefined{Crefrange@enumv@format@first}{%
+ \let\Crefrange@enumv@format@first%
+ \Crefrange@enumiv@format@first}{}%
+ \@ifundefined{crefrange@enumv@format@second}{%
+ \let\crefrange@enumv@format@second%
+ \crefrange@enumiv@format@second}{}%
+ \@ifundefined{Crefrange@enumv@format@second}{%
+ \let\Crefrange@enumv@format@second%
+ \Crefrange@enumiv@format@second}{}%
+ \@ifundefined{crefrange@enumv@format@middle}{%
+ \let\crefrange@enumv@format@middle%
+ \crefrange@enumiv@format@middle}{}%
+ \@ifundefined{Crefrange@enumv@format@middle}{%
+ \let\Crefrange@enumv@format@middle%
+ \Crefrange@enumiv@format@middle}{}%
+ \@ifundefined{crefrange@enumv@format@last}{%
+ \let\crefrange@enumv@format@last%
+ \crefrange@enumiv@format@last}{}%
+ \@ifundefined{Crefrange@enumv@format@last}{%
+ \let\Crefrange@enumv@format@last%
+ \Crefrange@enumiv@format@last}{}%
+%
+ \let\cref@language\relax%
+}
+% \end{macrocode}
+%
+%
% \Finale
\endinput
%%
diff --git a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty
index 9c571406374..5dc50fcd937 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}
- [2009/11/02 v0.12 Intelligent cross-referencing]
+ [2009/17/04 v0.13 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
@@ -44,16 +44,13 @@
}
\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%
+ \cref@constructprefix{#1}{\@result}%
\protected@edef\@currentlabel{%
- [#1][\arabic{#1}][\@result]\@currentlabel}}
+ [#1][\arabic{#1}][\@result]%
+ \csname p@#1\endcsname\csname the#1\endcsname}}
\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%
+ \cref@constructprefix{#2}{\@result}%
\protected@edef\@currentlabel{%
[#1][\arabic{#2}][\@result]\@currentlabel}}
\def\cref@override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
@@ -65,14 +62,22 @@
\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%
+ \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\ltx@label#1{\cref@label#1}
+ \let\cref@old@make@df@tag@@\make@df@tag@@
+ \def\make@df@tag@@#1{%
+ \gdef\df@tag{\maketag@@@{#1}%
+ \def\@currentlabel{[equation][][]#1}}}
+ \def\make@df@tag@@@#1{%
+ \gdef\df@tag{\tagform@{#1}%
+ \toks@\@xp{\p@equation{#1}}%
+ \edef\@currentlabel{[equation][][]\the\toks@}}}
}{}%
}
\def\cref@reflabel#1#2{\@result}
@@ -90,34 +95,70 @@
\renewcommand\appendix{%
\cref@old@appendix%
\@ifundefined{chapter}{%
- \def\refstepcounter@noarg##1{%
+ \gdef\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}
+ \cref@constructprefix{##1}{\@result}%
+ \edef\@result{{2147483647}\@result}%
+ \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}
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]\@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \@currentlabel}%
+ \else%
+ \protected@edef\@currentlabel{%
+ [##1][\arabic{##1}][\@result]\@currentlabel}%
+ \fi%
+ \fi%
+ \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}
+ \cref@constructprefix{##1}{\@result}%
+ \edef\@result{{2147483647}\@result}%
+ \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}
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{section}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]\@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \@currentlabel}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubsubappendix][\arabic{##1}]%
+ [\@result]\@currentlabel}%
+ \else%
+ \protected@edef\@currentlabel{%
+ [##1][\arabic{##1}][\@result]\@currentlabel}%
+ \fi%
+ \fi%
+ \fi%
\fi}%
}%
}
@@ -149,19 +190,127 @@
\def\@cref@getprefix{\@ifnextchar[%]
\@@cref@getprefix{\@@cref@getprefix[][][]}}
\def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
+\def\cref@constructprefix#1#2{%
+ \edef\@tmpa{\noexpand{\noexpand}\noexpand{#1\noexpand}}%
+ \expandafter\def\expandafter\@tmpa\expandafter{\@tmpa{#2}}%
+ \expandafter\@cref@constructprefix\@tmpa}
+\def\@cref@constructprefix#1#2#3{%
+ \cref@resetby{#2}{#3}%
+ \ifx#3\relax%
+ \edef#3{#1}%
+ \else%
+ \edef\@tmpa{{{\the\csname c@#3\endcsname}#1}{#3}}%
+ \expandafter\expandafter\expandafter\@cref@constructprefix%
+ \expandafter\@tmpa\expandafter{\expandafter#3\expandafter}%
+ \fi}
+\def\cref@counter@first#1#2\@nil{#1}
+\def\cref@counter@rest#1#2\@nil{#2}
+\def\cref@countercmp#1#2#3{%
+ \begingroup%
+ \def\@tmpa{#1}%
+ \ifx\@tmpa\@empty%
+ \def\@result{1}%
+ \else%
+ \def\@tmpa{#2}%
+ \ifx\@tmpa\@empty%
+ \def\@result{2}%
+ \else%
+ \expandafter\ifx\csname r@#1\endcsname\relax%
+ \def\@result{2}%
+ \else%
+ \expandafter\ifx\csname r@#2\endcsname\relax%
+ \def\@result{1}%
+ \else%
+ \cref@getcounter{#1}{\@countera}%
+ \cref@getprefix{#1}{\@prefixa}%
+ \cref@getcounter{#2}{\@counterb}%
+ \cref@getprefix{#2}{\@prefixb}%
+ \edef\@tmpa{{\@prefixa{\@countera}}{\@prefixb{\@counterb}}}%
+ \expandafter\@cref@countercmp\@tmpa%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \expandafter\endgroup\expandafter%
+ \chardef\expandafter#3\expandafter=\@result\relax}
+\def\@cref@countercmp#1#2{%
+ \let\@iterate\relax%
+ \def\@counta{#1}%
+ \def\@countb{#2}%
+ \ifx\@counta\@empty%
+ \ifx\@countb\@empty%
+ \def\@result{0}%
+ \else%
+ \def\@result{1}%
+ \fi%
+ \else%
+ \ifx\@countb\@empty%
+ \def\@result{2}%
+ \else%
+ \edef\@counta{\cref@counter@first#1\@nil}%
+ \edef\@countb{\cref@counter@first#2\@nil}%
+ \ifnum\@counta<\@countb\relax%
+ \def\@result{1}%
+ \else%
+ \ifnum\@counta>\@countb\relax%
+ \def\@result{2}%
+ \else%
+ \edef\@counta{\cref@counter@rest#1\@nil}%
+ \edef\@countb{\cref@counter@rest#2\@nil}%
+ \edef\@counta{{\@counta}{\@countb}}%
+ \expandafter\def\expandafter\@iterate\expandafter{%
+ \expandafter\@cref@countercmp\@counta}%
+ \fi%
+ \fi%
+ \fi%
+ \fi%
+ \@iterate}
\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@top#1{\expandafter\@cref@stack@top#1}
+\def\@cref@stack@top#1,#2\@nil{#1}
+\def\cref@stack@pop#1{\expandafter\@cref@stack@pop#1#1}
+\def\@cref@stack@pop#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}}
+ \expandafter\@cref@stack@push\expandafter{#2}{#1}{#2}}
+\def\@cref@stack@push#1#2#3{\def#3{#2,#1}}
+\def\cref@stack@pull#1#2{\expandafter\@cref@stack@pull#2{#1}{#2}}
+\def\@cref@stack@pull#1\@nil#2#3{\def#3{#1#2,\@nil}}
+\def\cref@stack@topandbottom#1#2#3{%
+ \def#2{}%
+ \def#3{}%
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef#2{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \cref@isstackfull{#1}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef#3{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \cref@isstackfull{#1}}%
+ \fi}
+\def\cref@stack@add#1#2{%
+ \begingroup%
+ \def\@arg1{#1}%
+ \let\@tmpstack#2%
+ \newif\if@notthere%
+ \@nottheretrue%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@tmpb{\cref@stack@top{\@tmpstack}}%
+ \def\@tmpa{#1}%
+ \ifx\@tmpa\@tmpb%
+ \@cref@stackfullfalse%
+ \@nottherefalse%
+ \else%
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}%
+ \fi
+ }%
+ \expandafter\endgroup%
+ \if@notthere\cref@stack@push{#1}{#2}\fi}
\newif\if@cref@stackempty
\newif\if@cref@stackfull
\def\cref@isstackempty#1{%
@@ -172,54 +321,156 @@
\def\@tmpa{\@nil}%
\ifx#1\@tmpa\@cref@stackfullfalse%
\else\@cref@stackfulltrue\fi}
+\def\cref@stack@sort#1#2{%
+ \begingroup%
+ \cref@stack@init{\@sortstack}%
+ \edef\@element{\cref@stack@top{#1}}%
+ \expandafter\cref@stack@push\expandafter{\@element}{\@sortstack}%
+ \cref@stack@pop{#1}%
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \@whilesw\ifx\@tmpa\@empty\fi{%
+ \cref@stack@pull{}{\@sortstack}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@tmpa\relax%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \fi}%
+ \fi%
+ \cref@isstackfull{#1}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@element{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \def\@empties{}%
+ \cref@isstackfull{#1}%
+ \if@cref@stackfull%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \@whilesw\ifx\@tmpa\@empty\fi{%
+ \edef\@empties{\@empties,}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@tmpa\relax%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#1}}%
+ \fi}%
+ \fi%
+ \edef\@tmpa{{\expandafter\noexpand\@element}%
+ {\expandafter\noexpand\@empties}%
+ {\noexpand\@sortstack}{\noexpand#2}}%
+ \expandafter\cref@stack@insert\@tmpa%
+ \cref@isstackfull{#1}}%
+ \expandafter\endgroup\expandafter%
+ \def\expandafter#1\expandafter{\@sortstack}}
+\def\cref@stack@insert#1#2#3#4{%
+ \let\@cmp#4%
+ \@cref@stack@insert{}{#1}{#2}{#3}%
+ \cref@stack@pop{#3}}
+\def\@cref@stack@insert#1#2#3#4{%
+ \let\@iterate\relax%
+ \cref@isstackempty{#4}%
+ \if@cref@stackempty%
+ \cref@stack@push{#1,#2#3}{#4}%
+ \else%
+ \edef\@tmpa{\cref@stack@top{#4}}%
+ \expandafter\@cmp\expandafter{\@tmpa}{#2}{\@result}%
+ \ifnum\@result=2\relax%
+ \cref@stack@push{#1,#2#3}{#4}%
+ \else%
+ \cref@stack@pop{#4}%
+ \edef\@tmpa{{\noexpand#1,\@tmpa}{\noexpand#2}%
+ {\noexpand#3}{\noexpand#4}}%
+ \expandafter\def\expandafter\@iterate\expandafter%
+ {\expandafter\@cref@stack@insert\@tmpa}%
+ \fi%
+ \fi%
+ \@iterate}
\newif\if@cref@inresetlist
\def\cref@isinresetlist#1#2{%
- \def\@counter{#1}%
\begingroup%
+ \def\@counter{#1}%
\def\@elt##1{##1,}%
\expandafter\ifx\csname cl@#2\endcsname\relax%
- \gdef\cref@resetstack{,\@nil}%
+ \def\cref@resetstack{,\@nil}%
\else%
- \xdef\cref@resetstack{\csname cl@#2\endcsname\noexpand\@nil}%
+ \edef\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%
+ \let\@nextcounter\relax%
+ \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%
+ \def\@next{\@cref@inresetlistfalse}%
\else%
- \let\@nextcounter\relax%
- \cref@stack@pop{\cref@resetstack}%
- \cref@isstackfull{\cref@resetstack}%
- \fi}%
- \ifx\@nextcounter\relax%
- \@cref@inresetlistfalse%
- \else%
- \@cref@inresetlisttrue%
- \fi}
+ \def\@next{\@cref@inresetlisttrue}%
+ \fi%
+ \expandafter%
+ \endgroup%
+ \@next}
\def\cref@resetby#1#2{%
- \cref@isinresetlist{#1}{subsubsubsection}%
- \if@cref@inresetlist%
- \def#2{subsubsubsection}%
- \else%
- \cref@isinresetlist{#1}{subsubsection}%
+ \let#2\relax%
+ \def\@tmpa{#1}%
+ \def\@tmpb{subfigure}%
+ \ifx\@tmpa\@tmpb%
+ \cref@isinresetlist{#1}{figure}%
+ \if@cref@inresetlist%
+ \def#2{figure}%
+ \fi%
+ \fi%
+ \def\@tmpa{#1}%
+ \def\@tmpb{subtable}%
+ \ifx\@tmpa\@tmpb%
+ \cref@isinresetlist{#1}{table}%
\if@cref@inresetlist%
- \def#2{subsubsection}%
+ \def#2{table}%
+ \fi%
+ \fi%
+ \def\@tmpa{#1}%
+ \def\@tmpb{enumii}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumiii}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumiv}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enumv}%
+ \ifx\@tmpa\@tmpb%
+ \def#2{enum}%
+ \fi%
+ \def\@tmpb{enum}%
+ \ifx#2\@tmpb%
+ \cref@isinresetlist{#1}{enumiv}%
+ \if@cref@inresetlist%
+ \def#2{enumiv}%
\else%
- \cref@isinresetlist{#1}{subsection}%
+ \cref@isinresetlist{#1}{enumiii}%
\if@cref@inresetlist%
- \def#2{subsection}%
+ \def#2{enumiii}%
\else%
- \cref@isinresetlist{#1}{section}%
+ \cref@isinresetlist{#1}{enumii}%
\if@cref@inresetlist%
- \def#2{section}%
+ \def#2{enumii}%
\else%
- \cref@isinresetlist{#1}{chapter}%
+ \cref@isinresetlist{#1}{enumi}%
\if@cref@inresetlist%
- \def#2{chapter}%
+ \def#2{enumi}%
\else%
- \cref@isinresetlist{#1}{part}%
+ \cref@isinresetlist{#1}{part}%
\if@cref@inresetlist%
\def#2{part}%
\else%
@@ -229,251 +480,353 @@
\fi%
\fi%
\fi%
+ \fi%
+ \ifx#2\relax%
+ \cref@isinresetlist{#1}{table}%
+ \if@cref@inresetlist%
+ \def#2{table}%
+ \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%
\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{%
+\newif\if@cref@refconsecutive%
+\def\cref@isrefconsecutive#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}%
+ \countdef\refa@counter=0%
+ \countdef\refb@counter=1%
+ \cref@getcounter{#1}{\@result}%
+ \refa@counter=\@result%
+ \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\relax%
+ \def\@after{\@cref@refconsecutivetrue}%
+ \else%
+ \advance\refa@counter 1\relax%
+ \ifnum\refa@counter=\refb@counter\relax%
+ \def\@after{\@cref@refconsecutivetrue}%
+ \fi%
+ \fi%
\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}%
+ \expandafter\endgroup\@after}
+\def\cref@processgroup#1#2{%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@groupformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@grouptype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
+ \fi%
+ \let\@nexttype\@grouptype%
+ \let\@nextformat\@groupformat%
+ \@whilesw\ifx\@nextformat\@groupformat\fi{%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@nexttype\relax%
+ \let\@nextformat\relax%
+ \else%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \ifx\@nextref\@empty%
+ \let\@nexttype\@grouptype%
+ \let\@nextforamt\@groupformat%
\else%
- \edef\@nextref{\cref@stack@top{\@refstack}}%
- \ifx\@nextref\@empty%
- \let\@currenttype\@nexttype%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@nexttype{\@undefined}%
+ \def\@nextformat{\@undefined}%
\else%
- \expandafter\ifx\csname r@\@nextref\endcsname\relax%
- \def\@currenttype{\@undefined}%
+ \expandafter\cref@gettype\expandafter%
+ {\@nextref}{\@nexttype}%
+ \def\@tmpa{\@undefined}%
+ \ifx\@nexttype\@tmpa%
+ \def\@nextformat{\@undefined}%
\else%
- \expandafter\cref@gettype\expandafter%
- {\@nextref}{\@currenttype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@nextformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@nexttype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
\fi%
\fi%
- \fi}%
- \if@firstgroup%
- \@firstgroupfalse%
- \@secondgrouptrue%
+ \fi%
+ \fi}%
+}
+\def\cref@processgroupall#1#2{%
+ \cref@stack@init{\@tmpstack}%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@grouptype{\@undefined}%
+ \def\@groupformat{\@undefined}%
+ \else%
+ \expandafter\cref@gettype\expandafter{\@nextref}{\@grouptype}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@groupformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@grouptype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
+ \fi%
+ \let\@lasttype\@grouptype%
+ \let\@lastformat\@groupformat%
+ \cref@isstackfull{#1}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \ifx\@nextref\@empty%
+ \ifx\@lastformat\@groupformat%
+ \let\@nexttype\@grouptype%
+ \let\@nextformat\@groupformat%
+ \else%
+ \let\@nexttype\relax%
+ \let\@nextformat\relax%
+ \fi%
\else%
- \cref@isstackfull{\@refstack}%
- \if@cref@stackfull%
- \@setcref@middlegroupconjunction%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \def\@nexttype{\@undefined}%
+ \def\@nextformat{\@undefined}%
\else%
- \if@secondgroup%
- \@setcref@pairgroupconjunction%
+ \expandafter\cref@gettype\expandafter%
+ {\@nextref}{\@nexttype}%
+ \def\@tmpa{\@undefined}%
+ \ifx\@nexttype\@tmpa%
+ \def\@nextformat{\@undefined}%
\else%
- \@setcref@lastgroupconjunction%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@nextformat%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@nexttype @format\endcsname%
+ {\@dummya}{\@dummyb}{\@dummyc}}%
\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}{}%
+ \ifx\@nextformat\@groupformat%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{#2}%
\else%
- \edef\@beginref{\@nextref}%
- \let\@endref\relax%
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \count@consecutive=1%
- \expandafter\ifx\csname r@\@beginref\endcsname\relax%
+ \expandafter\cref@stack@pull\expandafter{\@nextref}{\@tmpstack}%
+ \fi%
+ \cref@stack@pop{#1}%
+ \let\@lasttype\@nexttype%
+ \let\@lastformat\@nextformat%
+ \cref@isstackfull{#1}}%
+ \let#1\@tmpstack}
+\def\cref@processconsecutive#1#2#3#4{%
+ #4=0%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ #4=1\relax%
+ \else%
+ \edef#2{\@nextref}%
+ \let#3\relax%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ #4=1\relax%
+ \expandafter\ifx\csname r@#2\endcsname\relax%
+ \@cref@refconsecutivefalse%
+ \else%
+ \ifx\@nextref\@empty%
+ \@cref@refconsecutivefalse%
+ \@whilesw\ifx\@nextref\@empty\fi{%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
+ \let\@nextref\relax%
+ \else%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \fi}%
+ \else%
+ \expandafter\ifx\csname r@\@nextref\endcsname\relax%
+ \@cref@refconsecutivefalse%
+ \else%
+ \edef\@tmpa{{#2}{\@nextref}}%
+ \expandafter\cref@isrefconsecutive\@tmpa%
+ \fi%
+ \fi%
+ \fi%
+ \@whilesw\if@cref@refconsecutive\fi{%
+ \advance#4 1%
+ \let#3\@nextref%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
+ \if@cref@stackempty%
\@cref@refconsecutivefalse%
\else%
+ \edef\@nextref{\cref@stack@top{#1}}%
\ifx\@nextref\@empty%
\@cref@refconsecutivefalse%
\@whilesw\ifx\@nextref\@empty\fi{%
- \cref@stack@pop{\@refsubstack}%
- \cref@isstackempty{\@refsubstack}%
+ \cref@stack@pop{#1}%
+ \cref@isstackempty{#1}%
\if@cref@stackempty%
\let\@nextref\relax%
\else%
- \edef\@nextref{\cref@stack@top{\@refsubstack}}%
- \fi%
- }%
- \ifnum\count@consecutive=2%
- \edef\@endref{\@endref,}%
- \fi%
+ \edef\@nextref{\cref@stack@top{#1}}%
+ \fi}%
\else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\@cref@refconsecutivefalse%
\else%
- \edef\@tmpa{{\@beginref}{\@nextref}}%
+ \edef\@tmpa{{#3}{\@nextref}}%
\expandafter\cref@isrefconsecutive\@tmpa%
\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%
+ \countdef\count@group=1%
+ \count@group=1%
+ \newif\if@secondref%
+ \cref@stack@init{\@refstack}%
+ \cref@stack@push{#2}{\@refstack}%
+ \cref@isstackfull{\@refstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \cref@stack@init{\@refsubstack}%
+ \if@cref@sort%
+ \cref@processgroupall{\@refstack}{\@refsubstack}%
+ \cref@stack@sort{\@refsubstack}{\cref@countercmp}%
+ \else%
+ \cref@processgroup{\@refstack}{\@refsubstack}%
+ \fi%
+ \ifnum\count@group=1\relax%
+ \advance\count@group 1%
+ \else%
+ \cref@isstackfull{\@refstack}%
+ \if@cref@stackfull%
+ \@setcref@middlegroupconjunction%
+ \else%
+ \ifnum\count@group=2\relax%
+ \@setcref@pairgroupconjunction%
+ \else%
+ \@setcref@lastgroupconjunction%
+ \fi%
\fi%
- \@whilesw\if@cref@refconsecutive\fi{%
- \advance\count@consecutive 1%
- \let\@endref\@nextref%
+ \advance\count@group 1%
+ \fi%
+ \if@cref@compress%
+ \cref@processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}%
+ \else%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \cref@stack@pop{\@refsubstack}%
+ \@whilesw\ifx\@beginref\@empty\fi{%
\cref@stack@pop{\@refsubstack}%
\cref@isstackempty{\@refsubstack}%
\if@cref@stackempty%
- \@cref@refconsecutivefalse%
+ \let\@beginref\relax%
\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%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
\fi}%
- \ifx\@endref\relax%
+ \let\@endref\relax%
+ \count@consecutive=1\relax%
+ \fi%
+ \ifnum\count@consecutive=1\relax%
+ \cref@isstackfull{\@refsubstack}%
+ \if@cref@stackfull%
\expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
\else%
- \ifnum\count@consecutive=2%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
- \expandafter\cref@stack@push\expandafter%
- {\@endref}{\@refsubstack}%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{}%
+ \fi%
+ \else%
+ \ifnum\count@consecutive=2\relax%
+ \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%
- \edef\@tmpa{{\@beginref}{\@endref}}%
- \if@cref@stackempty%
- \expandafter\@setcrefrange\@tmpa{#1}{}%
- \else%
- \expandafter\@setcrefrange\@tmpa{#1}{@first}%
- \fi%
+ \expandafter\@setcrefrange\@tmpa{#1}{@first}%
\fi%
\fi%
- \@secondreftrue%
- \cref@isstackfull{\@refsubstack}%
- \@whilesw\if@cref@stackfull\fi{%
+ \fi%
+ \@secondreftrue%
+ \cref@isstackfull{\@refsubstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \if@cref@compress%
+ \cref@processconsecutive%
+ {\@refsubstack}{\@beginref}{\@endref}{\count@consecutive}%
+ \else%
\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}%
+ \@whilesw\ifx\@beginref\@empty\fi{%
+ \cref@stack@pop{\@refsubstack}%
\cref@isstackempty{\@refsubstack}%
\if@cref@stackempty%
- \if@secondref%
- \def\@pos{@second}%
- \else%
- \def\@pos{@last}%
- \fi%
+ \let\@beginref\relax%
\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%
+ \edef\@beginref{\cref@stack@top{\@refsubstack}}%
+ \fi}%
+ \let\@endref\relax%
+ \count@consecutive=1\relax%
+ \fi%
+ \cref@isstackempty{\@refsubstack}%
+ \if@cref@stackempty%
+ \if@secondref%
+ \def\@pos{@second}%
+ \else%
+ \def\@pos{@last}%
\fi%
- \@secondreffalse%
- \cref@isstackfull{\@refsubstack}%
- }% end loop over reference substack
- \fi%
+ \else%
+ \def\@pos{@middle}%
+ \fi%
+ \ifnum\count@consecutive=1\relax%
+ \edef\@tmpa{{\@beginref}{#1}{\@pos}}%
+ \expandafter\@setcref\@tmpa%
+ \else%
+ \ifnum\count@consecutive=2\relax%
+ \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%
+ \@secondreffalse%
+ \cref@isstackfull{\@refsubstack}%
+ }% end loop over reference substack
\cref@isstackfull{\@refstack}%
}% end loop over main reference stack
\endgroup}
@@ -496,25 +849,6 @@
\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%
@@ -535,7 +869,8 @@
\protect\G@refundefinedtrue%
\cref@getlabel{#1}{\@labela}%
\@labela--\nfss@text{\reset@font\bfseries ??}%
- \@latex@warning{Reference `#2' on page \thepage \space undefined}%
+ \@latex@warning{Reference `#2' on page \thepage %
+ \space undefined}%
\else%
\cref@gettype{#1}{\@typea}%
\cref@gettype{#2}{\@typeb}%
@@ -570,29 +905,28 @@
\def\@setcref@pairgroupconjunction{\crefpairgroupconjunction}
\def\@setcref@middlegroupconjunction{\crefmiddlegroupconjunction}
\def\@setcref@lastgroupconjunction{\creflastgroupconjunction}
+\cref@stack@init{\cref@label@types}
\newcommand{\crefdefaultlabelformat}[1]{%
\def\cref@default@label##1##2##3{#1}}
\newcommand{\crefname}[3]{%
- \@crefname{cref}{#1}{#2}{#3}%
- \@crefdefineallformats{#1}}
+ \@crefname{cref}{#1}{#2}{#3}{}}
\newcommand{\Crefname}[3]{%
- \@crefname{Cref}{#1}{#2}{#3}%
- \@crefdefineallformats{#1}}
+ \@crefname{Cref}{#1}{#2}{#3}{}}
\newcommand{\creflabelformat}[2]{%
- \@creflabelformat{#1}{#2}%
- \@crefdefineallformats{#1}}
+ \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}%
+ \cref@stack@add{#1}{\cref@label@types}}
\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{%
+ ##1##2##3##4##5##6{#2}%
+ \cref@stack@add{#1}{\cref@label@types}}
+\newcommand{\crefname@preamble}[3]{%
+ \@crefname{cref}{#1}{#2}{#3}{@preamble}}
+\newcommand{\Crefname@preamble}[3]{%
+ \@crefname{Cref}{#1}{#2}{#3}{@preamble}}
+\def\@crefname#1#2#3#4#5{%
\begingroup%
- \expandafter\gdef\csname #1@#2@name\endcsname{#3}%
- \expandafter\gdef\csname #1@#2@name@plural\endcsname{#4}%
+ \expandafter\gdef\csname #1@#2@name#5\endcsname{#3}%
+ \expandafter\gdef\csname #1@#2@name@plural#5\endcsname{#4}%
\def\@tmpa##1##2\@nil{%
\if##1c%
\def\@other{C##2}%
@@ -602,7 +936,7 @@
\def\@changecase{\MakeLowercase}%
\fi}%
\@tmpa#1\@nil%
- \@ifundefined{\@other @#2@name}{%
+ \@ifundefined{\@other @#2@name#5}{%
\expandafter\expandafter\expandafter\def%
\expandafter\expandafter\expandafter\@tmpa%
\expandafter\expandafter\expandafter{%
@@ -621,13 +955,14 @@
\expandafter\@changecase\@tmpb}%
\toksdef\@toksa=0%
\@toksa={%
- \expandafter\gdef\csname\@other @#2@name\endcsname}%
+ \expandafter\gdef\csname\@other @#2@name#5\endcsname}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpa}%
\@toksa={%
- \expandafter\gdef\csname\@other @#2@name@plural\endcsname}%
+ \expandafter\gdef\csname\@other @#2@name@plural#5\endcsname}%
\expandafter\the\expandafter\@toksa\expandafter{\@tmpb}%
}{}%
- \endgroup}
+ \endgroup%
+ \cref@stack@add{#2}{\cref@label@types}}
\def\@crefconstructcomponents#1{%
\@ifundefined{cref@#1@label}{%
\let\@tmplabel\cref@default@label%
@@ -642,39 +977,43 @@
\@tmplabel{####2}{####5}{####6}}%
\toksdef\@toksa=0%
\@toksa={\def\@tmprangelabel##1##2##3##4##5##6}%
- \expandafter\expandafter\expandafter\expandafter%
+ % \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\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\@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}}%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpname%
+ % \expandafter\expandafter\expandafter{%
+ % \csname cref@#1@name\endcsname}%
+ \expandafter\def\expandafter\@tmpname\expandafter{%
+ \csname cref@#1@name\endcsname}%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpName%
+ % \expandafter\expandafter\expandafter{%
+ % \csname Cref@#1@name\endcsname}%
+ \expandafter\def\expandafter\@tmpName\expandafter{%
+ \csname Cref@#1@name\endcsname}%
+ \expandafter\def\expandafter\@tmpnameplural\expandafter{%
+ \csname cref@#1@name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmpNameplural\expandafter{%
+ \csname Cref@#1@name@plural\endcsname}%
}
\def\@crefdefineformat#1{%
\begingroup%
@@ -721,17 +1060,23 @@
\expandafter\expandafter\expandafter\@tmpFirst%
\expandafter\expandafter\expandafter{%
\expandafter\@tmpNameplural\expandafter~\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpsecond%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpsecond%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefpairconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmpsecond\expandafter{%
\expandafter\crefpairconjunction\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpmiddle%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpmiddle%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefmiddleconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmpmiddle\expandafter{%
\expandafter\crefmiddleconjunction\@tmplabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmplast%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmplast%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\creflastconjunction\@tmplabel}%
+ \expandafter\def\expandafter\@tmplast\expandafter{%
\expandafter\creflastconjunction\@tmplabel}%
\toksdef\@toksa=0%
\toksdef\@toksb=1%
@@ -769,17 +1114,23 @@
\expandafter\expandafter\expandafter\@tmpFirst%
\expandafter\expandafter\expandafter{%
\expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpsecond%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpsecond%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefpairconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmpsecond\expandafter{%
\expandafter\crefpairconjunction\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmpmiddle%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmpmiddle%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\crefmiddleconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmpmiddle\expandafter{%
\expandafter\crefmiddleconjunction\@tmprangelabel}%
- \expandafter\expandafter\expandafter\def%
- \expandafter\expandafter\expandafter\@tmplast%
- \expandafter\expandafter\expandafter{%
+ % \expandafter\expandafter\expandafter\def%
+ % \expandafter\expandafter\expandafter\@tmplast%
+ % \expandafter\expandafter\expandafter{%
+ % \expandafter\creflastconjunction\@tmprangelabel}%
+ \expandafter\def\expandafter\@tmplast\expandafter{%
\expandafter\creflastconjunction\@tmprangelabel}%
\toksdef\@toksa=0%
\toksdef\@toksb=1%
@@ -995,313 +1346,156 @@
\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}
-}{}
+ \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@constructprefix{#1}{\@result}%
+ \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@constructprefix{#2}{\@tmpreset}%
+ \protected@edef\@currentlabel{%
+ [#1][\arabic{#2}][\@tmpreset]\@tmplabel}}
+ \renewcommand\appendix{%
+ \cref@old@appendix%
+ \@ifundefined{chapter}{%
+ \def\H@refstepcounter##1{%
+ \stepcounter{##1}%
+ \cref@constructprefix{##1}{\@result}%
+ \edef\@result{{2147483647}\@result}%
+ \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%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\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%
+ \fi%
+ \fi}%
+ }{%
+ \def\H@refstepcounter##1{%
+ \stepcounter{##1}%
+ \cref@constructprefix{##1}{\@result}%
+ \edef\@result{{2147483647}\@result}%
+ \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%
+ \def\@tmpa{##1}%
+ \def\@tmpb{section}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubappendix][\arabic{##1}][\@result]%
+ \csname p@##1\endcsname\csname the##1\endcsname}%
+ \else%
+ \def\@tmpa{##1}%
+ \def\@tmpb{subsubsection}%
+ \ifx\@tmpa\@tmpb%
+ \protected@edef\@currentlabel{%
+ [subsubsubappendix][\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%
+ \fi%
+ \fi%
+ \fi}%
+ }%
+ }
+ \newif\if@crefstarred
+ \DeclareRobustCommand{\cref}{%
+ \@ifstar{\@crefstar{cref}}{\@crefnostar{cref}}}
+ \DeclareRobustCommand{\Cref}{%
+ \@ifstar{\@crefstar{Cref}}{\@crefnostar{Cref}}}
+ \def\@crefnostar#1#2{\@cref{#1}{#2}}
+ \def\@crefstar#1#2{%
+ \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse}
+ \DeclareRobustCommand{\crefrange}{%
+ \@ifstar{\@crefrangestar{cref}}{\@crefrangenostar{cref}}}
+ \DeclareRobustCommand{\Crefrange}{%
+ \@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}}
+ \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}{\@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}%
+ }{}% end of \@ifpackageloaded
\AtBeginDocument{%
\DeclareRobustCommand{\ref}{\@ifstar\cref@refstar\cref@ref}
\def\cref@refstar#1{%
@@ -1312,262 +1506,1785 @@
\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%
+ \@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}}%]
+ }}{}% end of \@ifpackageloaded
+\@ifpackageloaded{varioref}{%
+ \PackageInfo{cleveref}{`varioref' support loaded}
+ \PackageInfo{cleveref}{`cleveref' supersedes `varioref's %
+ $\backslash$\labelformat command, which will not work}
+ \AtBeginDocument{%
+ \def\cref@vref#1#2{%
+ \if@cref@legacyvarioref%
+ \leavevmode\unskip\vref@space
+ \fi%
+ \@cref{#1}{#2} % space here is deliberate
+ \begingroup%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \vpageref{#2}%
+ \else%
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\vpagerefrange\@tmpa%
+ \fi%
+ \endgroup}
+ \def\cref@vrefrange#1#2#3{%
+ \@setcrefrange{#2}{#3}{#1}{} \vpagerefrange{#2}{#3}}
+ \def\cref@fullref#1#2{%
+ \@cref{#1}{#2} % space here is deliberate
+ \begingroup%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \reftextfaraway{#2}%
+ \else%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpa\expandafter{\@firstref}%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpb\expandafter{\@lastref}%
+ \ifx\@tmpa\@tmpb
+ \expandafter\reftextfaraway\expandafter{\@firstref}%
+ \else
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\reftextpagerange\@tmpa%
+ \fi%
+ \fi%
+ \endgroup}
+ \if@cref@legacyvarioref%
+ \def\vr@f#1{\cref@vref{cref}{#1}}
+ \def\Vr@f#1{\cref@vref{Cref}{#1}}
+ \renewcommand\vrefrange[3][\reftextcurrent]{%
+ \crefrange{#2}{#3} \vpagerefrange{#2}{#3}}
+ \def\fullref#1{\cref@fullref{cref}{#1}}
\else%
- \@not@eoftrue%
- \edef\@tmpa{\@tmpa}%
+ \@ifpackageloaded{hyperref}{%
+ \DeclareRobustCommand{\vref}{%
+ \@ifstar{\cref@vrefstar{cref}}{\cref@vref{cref}}}
+ \DeclareRobustCommand{\Vref}{%
+ \@ifstar{\cref@vrefstar{Cref}}{\cref@vref{Cref}}}
+ \DeclareRobustCommand{\vrefrange}{%
+ \@ifstar{\cref@vrefrangestar{cref}}{\cref@vrefrange{cref}}}
+ \DeclareRobustCommand{\Vrefrange}{%
+ \@ifstar{\cref@vrefrangestar{Cref}}{\cref@vrefrange{Cref}}}%
+ \DeclareRobustCommand{\fullref}{%
+ \@ifstar{\cref@fullrefstar{cref}}{\cref@fullref{cref}}}
+ \DeclareRobustCommand{\Fullref}{%
+ \@ifstar{\cref@fullrefstar{Cref}}{\cref@fullref{Cref}}}
+ \def\cref@vrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref@vref{#1}{#2}%
+ \@crefstarredfalse}
+ \def\cref@vrefrangestar#1#2#3{%
+ \@crefstarredtrue%
+ \cref@vrefrange{#1}{#2}{#3}%
+ \@crefstarredfalse}
+ \def\cref@fullrefstar#1#2{%
+ \@crefstarredtrue%
+ \cref@fullref{#1}{#2}%
+ \@crefstarredfalse}
+ }{%
+ \DeclareRobustCommand{\vref}{\cref@vref{cref}}
+ \DeclareRobustCommand{\Vref}{\cref@vref{Cref}}
+ \DeclareRobustCommand{\vrefrange}{\cref@vrefrange{cref}}
+ \DeclareRobustCommand{\Vrefrange}{\cref@vrefrange{Cref}}
+ \DeclareRobustCommand{\fullref}{\cref@fullref{cref}}
+ \DeclareRobustCommand{\Fullref}{\cref@fullref{Cref}}
+ }
\fi%
- \@whilesw\if@not@eof\fi{%
- \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}%
+ }% end of \AtBeginDocument
+ }{}% end of \@ifpackageloaded
+\let\if@cref@legacyvarioref\iffalse
+\DeclareOption{legacyvarioref}{%
+ \PackageInfo{cleveref}{legacy `varioref' compatibility enabled}
+ \let\if@cref@legacyvarioref\iftrue}
+\DeclareOption{poorman}{%
+ \PackageInfo{cleveref}{option `poorman' loaded}
+ \gdef\cref@poorman@text{}
+ \AtBeginDocument{%
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed}
+ \newif\if@cref@switched@language
+ \@ifpackageloaded{babel}{%
+ \AtBeginDocument{%
+ \let\cref@old@select@language\select@language
+ \def\select@language{%
+ \@cref@switched@languagetrue%
+ \cref@writelanguagerules%
+ \cref@old@select@language}
+ \let\cref@old@forreign@language\forreign@language
+ \def\forreign@language{%
+ \@cref@switched@languagetrue%
+ \cref@writelanguagerules%
+ \cref@old@forreign@language}
+ \edef\cref@inputlineno{\the\inputlineno}}
+ \AtEndDocument{%
+ \let\select@language\cref@old@select@language%
+ \let\forreign@language\cref@old@forreign@language%
+ \cref@writelanguagerules}
+ \def\cref@writelanguagerules{%
+ \begingroup%
+ \if@cref@switched@language%
+ \edef\@address{\cref@inputlineno,\the\inputlineno}%
+ \else%
+ \def\@address{}%
+ \fi%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefrangeconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefrangeconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefpairconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefpairconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefmiddleconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddleconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \creflastconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\creflastconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefpairgroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefpairgroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \crefmiddlegroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\crefmiddlegroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \expandafter\def\expandafter\cref@poorman@text\expandafter{%
+ \creflastgroupconjunction}%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \expandafter{\@address}{\string\creflastgroupconjunction}}
+ \expandafter\cref@writescript\@tmpa%
+ \let\@tmpstack\cref@label@types%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}%
+ \edef\@tmpa{%
+ \string\cref@\expandafter\noexpand\@tmpa @name\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}%
+ \edef\@tmpa{%
+ \string\cref@\expandafter\noexpand\@tmpa%
+ @name@plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}%
+ \edef\@tmpa{%
+ \string\Cref@\expandafter\noexpand\@tmpa @name\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\cref@poorman@text%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}%
+ \edef\@tmpa{%
+ \string\Cref@\expandafter\noexpand\@tmpa%
+ @name@plural\space}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter%
+ {\expandafter\@address\expandafter}%
+ \expandafter{\@tmpa}}
+ \expandafter\cref@writescript\@tmpa%
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}}%
+ \endgroup%
+ \edef\cref@inputlineno{\the\inputlineno}}%
+ }{}% end of \@ifpackageloaded
+ \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`$=13 %$
+ \catcode`\=0 \catcode`<=1 \catcode`>=2
+ \catcode`\\=13 \catcode`\{=12 \catcode`\}=12 \catcode`_=12
+ \lccode`/=92
+ \lccode`~=92\lowercase{\def~{\string/\string/}}%
+ \lccode`~=42\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@poorman@text{}%
\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%
+ \fi%
+ \@whilesw\if@not@eof\fi{%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@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{\def\@tmpa{%[
+ s/||label|[[^]]*|]/||label/g}}
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||usepackage|(|[.*|]|)|?<cleveref>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refname<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]reflabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refdefaultlabelformat<.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]ref><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter%
+ \cref@poorman@text\expandafter{\@tmpa^^J}%
+ \endgroup%
+ \newwrite\@crefscript%
+ \immediate\openout\@crefscript=\jobname.sed%
+ \immediate\write\@crefscript{\cref@poorman@text}%
+ \immediate\closeout\@crefscript%
+ }
+ \def\cref@getmeaning#1{\expandafter\@cref@getmeaning\meaning#1\@nil}
+ \def\@cref@getmeaning#1->#2\@nil{#2}
+ \def\cref@writescript#1#2{%
+ \edef\@tmpa{\cref@getmeaning{\cref@poorman@text}}%
+ \immediate\write\@crefscript{#1 s/#2/\@tmpa/g}}
+ \@ifpackageloaded{hyperref}{%
+ \def\@crefnostar#1#2{%
+ \gdef\cref@poorman@text{}%
+ \@cref{#1}{#2}%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1<#2>}}%
+ \endgroup}
+ \def\@crefstar#1#2{%
+ \gdef\cref@poorman@text{}%
+ \@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1*<#2>}}%
+ \endgroup}
+ \def\@crefrangenostar#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@setcrefrange{#2}{#3}{#1}{}%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1range<#2><#3>}}%
+ \endgroup}
+ \def\@crefrangestar#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse%
+ \begingroup%
+ \lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
+ \lowercase{\cref@writescript{}{|#1range*<#2><#3>}}%
+ \endgroup}
+ }{%
+ \DeclareRobustCommand{\cref}[1]{%
+ \edef\cref@poorman@text{}%
+ \@cref{cref}{#1}%
+ \cref@writescript{}{\string\cref\string{#1\string}}}
+ \DeclareRobustCommand{\Cref}[1]{%
+ \edef\cref@poorman@text{}%
+ \@cref{Cref}{#1}%
+ \cref@writescript{}{\string\Cref\string{#1\string}}}
+ \DeclareRobustCommand{\crefrange}[2]{%
+ \edef\cref@poorman@text{}%
+ \@setcrefrange{#1}{#2}{cref}{}%
+ \cref@writescript{}{%
+ \string\crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Crefrange}[2]{%
+ \edef\cref@poorman@text{}%
+ \@setcrefrange{#1}{#2}{Cref}{}%
+ \cref@writescript{}{%
+ \string\Crefrange\string{#1\string}\string{#2\string}}}
+ }
+ \@ifpackageloaded{varioref}{%
+ \AtBeginDocument{%
+ \if@cref@legacyvarioref%
+ \DeclareRobustCommand{\vref}{%
+ \@ifstar{\cref@vrefstar{cref}}{\cref@vref{cref}}}
+ \def\cref@vrefstar#1#2{%
+ \@crefstarredtrue\cref@vref{#1}{#2}\@crefstarredfalse}
+ \fi
+ \def\cref@vref#1#2{%
+ \gdef\cref@poorman@text{}%
+ \if@cref@legacyvarioref%
+ \leavevmode\unskip\vref@space
+ \fi%
+ \begingroup%
+ \let\if@tmp\if@crefstarred%
+ \if@cref@legacyvarioref\@crefstarredfalse\fi%
+ \@cref{#1}{#2} % space here is deliberate
+ \let\if@crefstarred\if@tmp%
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \vpageref{#2}%
+ \g@addto@macro\cref@poorman@text{ \vpageref{#2}}%
+ \else%
+ \g@addto@macro\cref@poorman@text{ }%
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\vpagerefrange\@tmpa%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\expandafter\vpagerefrange\@tmpa}%
+ \fi%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{\string\vref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\vref\string{#2\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{\string\Vref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\Vref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil%
+ \endgroup}
+ \def\cref@vrefrange#1#2#3{%
+ \gdef\cref@poorman@text{}%
+ \@setcrefrange{#2}{#3}{#1}{} \vpagerefrange{#2}{#3}%
+ \g@addto@macro\cref@poorman@text{ \vpagerefrange{#2}{#3}}%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{%
+ \string\vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref@writescript{}{%
+ \string\vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{%
+ \string\Vrefrange*\string{#2\string}\string{#3\string}}%
+ \else%
+ \cref@writescript{}{%
+ \string\Vrefrange\string{#2\string}\string{#3\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil}
+ \def\cref@fullref#1#2{%
+ \gdef\cref@poorman@text{}%
+ \begingroup%
+ \@cref{#1}{#2} % space here is deliberate
+ \def\@tmpstack{#2,\@nil}%
+ \cref@stack@topandbottom{\@tmpstack}{\@firstref}{\@lastref}%
+ \ifx\@lastref\@empty%
+ \reftextfaraway{#2}%
+ \def\@pageref{\reftextfaraway{#1}}%
+ \else%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpa\expandafter{\@firstref}%
+ \expandafter\vrefpagenum\expandafter%
+ \@tmpb\expandafter{\@lastref}%
+ \ifx\@tmpa\@tmpb
+ \expandafter\reftextfaraway\expandafter{\@firstref}%
+ \expandafter\def\expandafter\@pageref\expandafter{%
+ \expandafter\reftextfaraway\expandafter{\@firstref}}%
+ \else
+ \edef\@tmpa{{\@firstref}{\@lastref}}%
+ \expandafter\reftextpagerange\@tmpa%
+ \expandafter\def\expandafter\@pageref\expandafter{%
+ \expandafter\reftextpagerange\@tmpa}%
+ \fi%
+ \fi%
+ \g@addto@macro\cref@poorman@text{ }%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\@pageref}%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \if@crefstarred%
+ \cref@writescript{}{\string\fullref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\fullref\string{#2\string}}%
+ \fi%
+ \else%
+ \if@crefstarred%
+ \cref@writescript{}{\string\Fullref*\string{#2\string}}%
+ \else%
+ \cref@writescript{}{\string\Fullref\string{#2\string}}%
+ \fi%
+ \fi}%
+ \@tmpa#1\@nil
+ \endgroup}
+ }% end of \AtBeginDocument
+ }{}% end of \@ifpackageloaded
+ \def\@setcref@pairgroupconjunction{%
+ \crefpairgroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\crefpairgroupconjunction}}
+ \def\@setcref@middlegroupconjunction{%
+ \crefmiddlegroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\crefmiddlegroupconjunction}}
+ \def\@setcref@lastgroupconjunction{%
+ \creflastgroupconjunction%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{\creflastgroupconjunction}}
+ \@ifpackageloaded{hyperref}{%
+ \def\@@setcref#1#2{%
+ \cref@getlabel{#2}{\@tmplabel}%
+ \if@crefstarred%
+ #1{\@tmplabel}{}{}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref*{#2}}{}{}}%
+ \else%
+ \edef\@tmplink{\cref@hyperref{#2}}%
+ #1{\@tmplabel}{\hyper@linkstart{link}{\@tmplink}}%
+ {\hyper@linkend}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref{#2}}{}{}}%
+ \fi}
+ \def\@@setcrefrange#1#2#3{%
+ \cref@getlabel{#2}{\@labela}%
+ \cref@getlabel{#3}{\@labelb}%
+ \if@crefstarred%
+ #1{\@labela}{\@labelb}{}{}{}{}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref*{#2}}{\ref*{#3}}{}{}{}{}}%
+ \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}%
+ \expandafter\g@addto@macro\expandafter\cref@poorman@text%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}%
+ \fi}
+ }{%
+ \def\@@setcref#1#2{%
+ \old@@setcref{#1}{#2}%
+ \expandafter\g@addto@macro\expandafter{%
+ \expandafter\cref@poorman@text\expandafter}\expandafter{%
+ #1{\ref{#2}}{}{}}}
+ \def\@@setcrefrange#1#2#3{%
+ \old@@setcrefrange{#1}{#2}{#3}%
+ \expandafter\g@addto@macro%
+ \expandafter{\expandafter\cref@poorman@text\expandafter}%
+ \expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
+ }
+}% end of poorman option
+\newif\if@cref@sort
+\newif\if@cref@compress
+\@cref@sorttrue
+\@cref@compresstrue
+\DeclareOption{sort}{%
+ \PackageInfo{cleveref}{sorting but not compressing references}
+ \@cref@sorttrue
+ \@cref@compressfalse}
+\DeclareOption{compress}{%
+ \PackageInfo{cleveref}{compressing but not sorting references}
+ \@cref@sortfalse
+ \@cref@compresstrue}
+\DeclareOption{sort&compress}{%
+ \PackageInfo{cleveref}{sorting and compressing references}
+ \@cref@sorttrue
+ \@cref@compresstrue}
+\DeclareOption{nosort}{%
+ \PackageInfo{cleveref}{neither sorting nor compressing references}
+ \@cref@sortfalse
+ \@cref@compressfalse}
+\crefdefaultlabelformat{#2#1#3}
+\creflabelformat{equation}{\textup{(#2#1#3)}}
+\def\cref@addto#1#2{%
+ \@temptokena{#2}%
+ \ifx#1\undefined
+ \edef#1{\the\@temptokena}%
+ \else
+ \toks@\expandafter{#1}%
+ \edef#1{\the\toks@\the\@temptokena}%
+ \fi
+ \@temptokena{}\toks@\@temptokena%
}
-\@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}}}%
+\@onlypreamble\cref@addto
+\DeclareOption{english}{%
+ \PackageInfo{cleveref}{loaded `english' language definitions}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ to~}
+ \def\crefpairconjunction@preamble{ and~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ and~}
+ \def\crefpairgroupconjunction@preamble{ and~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{, and~}
+ \crefname@preamble{equation}{eq.}{eqs.}
+ \Crefname@preamble{equation}{Equation}{Equations}
+ \crefname@preamble{chapter}{chapter}{chapters}
+ \Crefname@preamble{chapter}{Chapter}{Chapters}
+ \crefname@preamble{section}{section}{sections}
+ \Crefname@preamble{section}{Section}{Sections}
+ \crefname@preamble{appendix}{appendix}{appendices}
+ \Crefname@preamble{appendix}{Appendix}{Appendices}
+ \crefname@preamble{figure}{fig.}{figs.}
+ \Crefname@preamble{figure}{Figure}{Figures}
+ \crefname@preamble{table}{table}{tables}
+ \Crefname@preamble{table}{Table}{Tables}
+ \crefname@preamble{theorem}{theorem}{theorems}
+ \Crefname@preamble{theorem}{Theorem}{Theorems}
+ \crefname@preamble{enumi}{item}{items}
+ \Crefname@preamble{enumi}{Item}{Items}
+ \crefname@preamble{lemma}{lemma}{lemmas}
+ \Crefname@preamble{lemma}{Lemma}{Lemmas}
+ \crefname@preamble{corollary}{corollary}{corollaries}
+ \Crefname@preamble{corollary}{Corollary}{Corollaries}
+ \crefname@preamble{proposition}{proposition}{propositions}
+ \Crefname@preamble{proposition}{Proposition}{Propositions}
+ \crefname@preamble{definition}{definition}{definitions}
+ \Crefname@preamble{definition}{Definition}{Definitions}
+ \crefname@preamble{result}{result}{results}
+ \Crefname@preamble{result}{Result}{Results}
+ \def\cref@language{english}%
+ \cref@addto\extrasenglish{%
+ \renewcommand{\crefrangeconjunction}{ to~}
+ \renewcommand{\crefpairconjunction}{ and~}
+ \renewcommand{\crefmiddleconjunction}{, }
+ \renewcommand{\creflastconjunction}{ and~}
+ \renewcommand{\crefpairgroupconjunction}{ and~}
+ \renewcommand{\crefmiddlegroupconjunction}{, }
+ \renewcommand{\creflastgroupconjunction}{, and~}
+ \crefname{equation}{eq.}{eqs.}
+ \Crefname{equation}{Equation}{Equations}
+ \crefname{chapter}{chapter}{chapters}
+ \Crefname{chapter}{Chapter}{Chapters}
+ \crefname{section}{section}{sections}
+ \Crefname{section}{Section}{Sections}
+ \crefname{subsection}{section}{sections}
+ \Crefname{subsection}{Section}{Sections}
+ \crefname{subsubsection}{section}{sections}
+ \Crefname{subsubsection}{Section}{Sections}
+ \crefname{appendix}{appendix}{appendices}
+ \Crefname{appendix}{Appendix}{Appendices}
+ \crefname{subappendix}{appendix}{appendices}
+ \Crefname{subappendix}{Appendix}{Appendices}
+ \crefname{subsubappendix}{appendix}{appendices}
+ \Crefname{subsubappendix}{Appendix}{Appendices}
+ \crefname{subsubsubappendix}{appendix}{appendices}
+ \Crefname{subsubsubappendix}{Appendix}{Appendices}
+ \crefname{figure}{fig.}{figs.}
+ \Crefname{figure}{Figure}{Figures}
+ \crefname{subfigure}{fig.}{figs.}
+ \Crefname{subfigure}{Figure}{Figures}
+ \crefname{table}{table}{tables}
+ \Crefname{table}{Table}{Tables}
+ \crefname{subtable}{table}{tables}
+ \Crefname{subtable}{Table}{Tables}
+ \crefname{theorem}{theorem}{theorems}
+ \Crefname{theorem}{Theorem}{Theorems}
+ \crefname{enumi}{item}{items}
+ \Crefname{enumi}{Item}{Items}
+ \crefname{enumii}{item}{items}
+ \Crefname{enumii}{Item}{Items}
+ \crefname{enumiii}{item}{items}
+ \Crefname{enumiii}{Item}{Items}
+ \crefname{enumiv}{item}{items}
+ \Crefname{enumiv}{Item}{Items}
+ \crefname{enumv}{item}{items}
+ \Crefname{enumv}{Item}{Items}
+ \crefname{lemma}{lemma}{lemmas}
+ \Crefname{lemma}{Lemma}{Lemmas}
+ \crefname{corollary}{corollary}{corollaries}
+ \Crefname{corollary}{Corollary}{Corollaries}
+ \crefname{proposition}{proposition}{propositions}
+ \Crefname{proposition}{Proposition}{Propositions}
+ \crefname{definition}{definition}{definitions}
+ \Crefname{definition}{Definition}{Definitions}
+ \crefname{result}{result}{results}
+ \Crefname{result}{Result}{Results}%
+ }}}
+\DeclareOption{german}{%
+ \PackageInfo{cleveref}{loaded `german' language definitions}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ bis~}
+ \def\crefpairconjunction@preamble{ und~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ und~}
+ \def\crefpairgroupconjunction@preamble{ und~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{ und~}
+ \crefname@preamble{equation}{Gleichung}{Gleichungen}
+ \Crefname@preamble{equation}{Gleichung}{Gleichungen}
+ \crefname@preamble{chapter}{Kapitel}{Kapitel}
+ \Crefname@preamble{chapter}{Kapitel}{Kapitel}
+ \crefname@preamble{section}{Abschnitt}{Abschnitte}
+ \Crefname@preamble{section}{Abschnitt}{Abschnitte}
+ \crefname@preamble{appendix}{Anhang}{Anh\"ange}
+ \Crefname@preamble{appendix}{Anhang}{Anh\"ange}
+ \crefname@preamble{figure}{Abbildung}{Abbildungen}
+ \Crefname@preamble{figure}{Abbildung}{Abbildungen}
+ \crefname@preamble{table}{Tabelle}{Tabellen}
+ \Crefname@preamble{table}{Tabelle}{Tabellen}
+ \crefname@preamble{theorem}{Theorem}{Theoremen}
+ \Crefname@preamble{theorem}{Theorem}{Theoremen}
+ \crefname@preamble{enumi}{Punkt}{Punkte}
+ \Crefname@preamble{enumi}{Punkt}{Punkte}
+ \crefname@preamble{lemma}{Lemma}{Lemmata}
+ \Crefname@preamble{lemma}{Lemma}{Lemmata}
+ \crefname@preamble{corollary}{Korollar}{Korollaren}
+ \Crefname@preamble{corollary}{Korollar}{Korollaren}
+ \crefname@preamble{proposition}{Satz}{S\"atze}
+ \Crefname@preamble{proposition}{Satz}{S\"atze}
+ \crefname@preamble{definition}{Definition}{Definitionen}
+ \Crefname@preamble{definition}{Definition}{Definitionen}
+ \crefname@preamble{result}{Ergebnis}{Ergebnisse}
+ \Crefname@preamble{result}{Ergebnis}{Ergebnisse}%
+ \def\cref@language{german}%
+ \cref@addto\extrasgerman{%
+ \renewcommand{\crefrangeconjunction}{ bis~}%
+ \renewcommand{\crefpairconjunction}{ und~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ und~}%
+ \renewcommand{\crefpairgroupconjunction}{ und~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ und~}%
+ \crefname{equation}{Gleichung}{Gleichungen}%
+ \Crefname{equation}{Gleichung}{Gleichungen}%
+ \crefname{chapter}{Kapitel}{Kapitel}%
+ \Crefname{chapter}{Kapitel}{Kapitel}%
+ \crefname{section}{Abschnitt}{Abschnitte}%
+ \Crefname{section}{Abschnitt}{Abschnitte}%
+ \crefname{subsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsection}{Abschnitt}{Abschnitte}%
+ \crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \crefname{appendix}{Anhang}{Anh\"ange}%
+ \Crefname{appendix}{Anhang}{Anh\"ange}%
+ \crefname{subappendix}{Anhang}{Anh\"ange}
+ \Crefname{subappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \crefname{figure}{Abbildung}{Abbildungen}%
+ \Crefname{figure}{Abbildung}{Abbildungen}%
+ \crefname{subfigure}{Abbildung}{Abbildungen}%
+ \Crefname{subfigure}{Abbildung}{Abbildungen}%
+ \crefname{table}{Tabelle}{Tabellen}%
+ \Crefname{table}{Tabelle}{Tabellen}%
+ \crefname{subtable}{Tabelle}{Tabellen}%
+ \Crefname{subtable}{Tabelle}{Tabellen}%
+ \crefname{theorem}{Theorem}{Theoremen}%
+ \Crefname{theorem}{Theorem}{Theoremen}%
+ \crefname{enumi}{Punkt}{Punkte}%
+ \Crefname{enumi}{Punkt}{Punkte}%
+ \crefname{enumii}{Punkt}{Punkte}%
+ \Crefname{enumii}{Punkt}{Punkte}%
+ \crefname{enumiii}{Punkt}{Punkte}%
+ \Crefname{enumiii}{Punkt}{Punkte}%
+ \crefname{enumiv}{Punkt}{Punkte}%
+ \Crefname{enumiv}{Punkt}{Punkte}%
+ \crefname{enumv}{Punkt}{Punkte}%
+ \Crefname{enumv}{Punkt}{Punkte}%
+ \crefname{lemma}{Lemma}{Lemmata}%
+ \Crefname{lemma}{Lemma}{Lemmata}%
+ \crefname{corollary}{Korollar}{Korollaren}%
+ \Crefname{corollary}{Korollar}{Korollaren}%
+ \crefname{proposition}{Satz}{S\"atze}%
+ \Crefname{proposition}{Satz}{S\"atze}%
+ \crefname{definition}{Definition}{Definitionen}%
+ \Crefname{definition}{Definition}{Definitionen}%
+ \crefname{result}{Ergebnis}{Ergebnisse}%
+ \Crefname{result}{Ergebnis}{Ergebnisse}%
+ }}}
+\DeclareOption{ngerman}{%
+ \PackageInfo{cleveref}{loaded `ngerman' language definitions}
+ \ExecuteOptions{german}
+ \def\cref@language{ngerman}
+ \AtBeginDocument{%
+ \cref@addto\extrasngerman{%
+ \renewcommand{\crefrangeconjunction}{ bis~}%
+ \renewcommand{\crefpairconjunction}{ und~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ und~}%
+ \renewcommand{\crefpairgroupconjunction}{ und~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ und~}%
+ \crefname{equation}{Gleichung}{Gleichungen}%
+ \Crefname{equation}{Gleichung}{Gleichungen}%
+ \crefname{chapter}{Kapitel}{Kapitel}%
+ \Crefname{chapter}{Kapitel}{Kapitel}%
+ \crefname{section}{Abschnitt}{Abschnitte}%
+ \Crefname{section}{Abschnitt}{Abschnitte}%
+ \crefname{subsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsection}{Abschnitt}{Abschnitte}%
+ \crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \Crefname{subsubsection}{Abschnitt}{Abschnitte}%
+ \crefname{appendix}{Anhang}{Anh\"ange}%
+ \Crefname{appendix}{Anhang}{Anh\"ange}%
+ \crefname{subappendix}{Anhang}{Anh\"ange}
+ \Crefname{subappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubappendix}{Anhang}{Anh\"ange}
+ \crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \Crefname{subsubsubappendix}{Anhang}{Anh\"ange}
+ \crefname{figure}{Abbildung}{Abbildungen}%
+ \Crefname{figure}{Abbildung}{Abbildungen}%
+ \crefname{subfigure}{Abbildung}{Abbildungen}%
+ \Crefname{subfigure}{Abbildung}{Abbildungen}%
+ \crefname{table}{Tabelle}{Tabellen}%
+ \Crefname{table}{Tabelle}{Tabellen}%
+ \crefname{subtable}{Tabelle}{Tabellen}%
+ \Crefname{subtable}{Tabelle}{Tabellen}%
+ \crefname{theorem}{Theorem}{Theoremen}%
+ \Crefname{theorem}{Theorem}{Theoremen}%
+ \crefname{enumi}{Punkt}{Punkte}%
+ \Crefname{enumi}{Punkt}{Punkte}%
+ \crefname{enumii}{Punkt}{Punkte}%
+ \Crefname{enumii}{Punkt}{Punkte}%
+ \crefname{enumiii}{Punkt}{Punkte}%
+ \Crefname{enumiii}{Punkt}{Punkte}%
+ \crefname{enumiv}{Punkt}{Punkte}%
+ \Crefname{enumiv}{Punkt}{Punkte}%
+ \crefname{enumv}{Punkt}{Punkte}%
+ \Crefname{enumv}{Punkt}{Punkte}%
+ \crefname{lemma}{Lemma}{Lemmata}%
+ \Crefname{lemma}{Lemma}{Lemmata}%
+ \crefname{corollary}{Korollar}{Korollaren}%
+ \Crefname{corollary}{Korollar}{Korollaren}%
+ \crefname{proposition}{Satz}{S\"atze}%
+ \Crefname{proposition}{Satz}{S\"atze}%
+ \crefname{definition}{Definition}{Definitionen}%
+ \Crefname{definition}{Definition}{Definitionen}%
+ \crefname{result}{Ergebnis}{Ergebnisse}%
+ \Crefname{result}{Ergebnis}{Ergebnisse}%
+ }}}
+\DeclareOption{french}{%
+ \PackageInfo{cleveref}{loaded `french' language definitions}
+ \AtBeginDocument{%
+ \def\crefrangeconjunction@preamble{ \`a~}
+ \def\crefpairconjunction@preamble{ et~}
+ \def\crefmiddleconjunction@preamble{, }
+ \def\creflastconjunction@preamble{ et~}
+ \def\crefpairgroupconjunction@preamble{ et~}
+ \def\crefmiddlegroupconjunction@preamble{, }
+ \def\creflastgroupconjunction@preamble{, et~}
+ \crefname@preamble{equation}{{\'e}quation}{{\'e}quations}
+ \Crefname@preamble{equation}{{\'E}quation}{{\'E}quations}
+ \crefname@preamble{chapter}{chapitre}{chapitres}
+ \Crefname@preamble{chapter}{Chapitre}{Chapitres}
+ \crefname@preamble{section}{section}{sections}
+ \Crefname@preamble{section}{Section}{Sections}
+ \crefname@preamble{appendix}{appendice}{appendices}
+ \Crefname@preamble{appendix}{Appendice}{Appendices}
+ \crefname@preamble{figure}{figure}{figures}
+ \Crefname@preamble{figure}{Figure}{Figures}
+ \crefname@preamble{table}{tableau}{tableaux}
+ \Crefname@preamble{table}{Tableau}{Tableaux}
+ \crefname@preamble{theorem}{th\'eor\`eme}{th\'eor\`emes}
+ \Crefname@preamble{theorem}{Th\'eor\`eme}{Th\'eor\`emes}
+ \crefname@preamble{enumi}{point}{points}
+ \Crefname@preamble{enumi}{Point}{Points}
+ \crefname@preamble{lemma}{lemme}{lemmes}
+ \Crefname@preamble{lemma}{Lemme}{Lemmes}
+ \crefname@preamble{corollary}{corollaire}{corollaires}
+ \Crefname@preamble{corollary}{Corollaire}{Corollaires}
+ \crefname@preamble{proposition}{proposition}{propositions}
+ \Crefname@preamble{proposition}{Proposition}{Propositions}
+ \crefname@preamble{definition}{d\'efinition}{d\'efinitions}
+ \Crefname@preamble{definition}{D\'efinition}{D\'efinitions}
+ \crefname@preamble{result}{r\'esultat}{r\'esultats}
+ \Crefname@preamble{result}{R\'esultat}{R\'esultats}
+ \def\cref@language{french}%
+ \cref@addto\extrasfrench{%
+ \renewcommand{\crefrangeconjunction}{ \`a~}%
+ \renewcommand{\crefpairconjunction}{ et~}%
+ \renewcommand{\crefmiddleconjunction}{, }%
+ \renewcommand{\creflastconjunction}{ et~}%
+ \renewcommand{\crefpairgroupconjunction}{ et~}%
+ \renewcommand{\crefmiddlegroupconjunction}{, }%
+ \renewcommand{\creflastgroupconjunction}{ et~}%
+ \crefname{equation}{{\'e}quation}{{\'e}quations}%
+ \Crefname{equation}{{\'E}quation}{{\'E}quations}%
+ \crefname{chapter}{chapitre}{chapitres}%
+ \Crefname{chapter}{Chapitre}{Chapitres}%
+ \crefname{section}{section}{sections}%
+ \Crefname{section}{Section}{Sections}%
+ \crefname{subsection}{section}{sections}%
+ \Crefname{subsection}{Section}{Sections}%
+ \crefname{subsubsection}{section}{sections}%
+ \Crefname{subsubsection}{Section}{Sections}%
+ \crefname{appendix}{appendice}{appendices}%
+ \Crefname{appendix}{Appendice}{Appendices}%
+ \crefname{subappendix}{appendice}{appendices}
+ \Crefname{subappendix}{Appendice}{Appendices}
+ \crefname{subsubappendix}{appendice}{appendices}
+ \Crefname{subsubappendix}{Appendice}{Appendices}
+ \crefname{subsubsubappendix}{appendice}{appendices}
+ \Crefname{subsubsubappendix}{Appendice}{Appendices}
+ \crefname{figure}{figure}{figures}%
+ \Crefname{figure}{Figure}{Figures}%
+ \crefname{subfigure}{figure}{figures}%
+ \Crefname{subfigure}{Figure}{Figures}%
+ \crefname{table}{tableau}{tableaux}%
+ \Crefname{table}{Tableau}{Tableaux}%
+ \crefname{subtable}{tableau}{tableaux}%
+ \Crefname{subtable}{Tableau}{Tableaux}%
+ \crefname{theorem}{th\'eor\`eme}{th\'eor\`emes}%
+ \Crefname{theorem}{Th\'eor\`eme}{Th\'eor\`emes}%
+ \crefname{enumi}{point}{points}%
+ \Crefname{enumi}{Point}{Points}%
+ \crefname{enumii}{point}{points}%
+ \Crefname{enumii}{Point}{Points}%
+ \crefname{enumiii}{point}{points}%
+ \Crefname{enumiii}{Point}{Points}%
+ \crefname{enumiv}{point}{points}%
+ \Crefname{enumiv}{Point}{Points}%
+ \crefname{enumv}{point}{points}%
+ \Crefname{enumv}{Point}{Points}%
+ \crefname{lemma}{lemme}{lemmes}%
+ \Crefname{lemma}{Lemme}{Lemmes}%
+ \crefname{corollary}{corollaire}{corollaires}%
+ \Crefname{corollary}{Corollaire}{Corollaires}%
+ \crefname{proposition}{proposition}{propositions}%
+ \Crefname{proposition}{Proposition}{Propositions}%
+ \crefname{definition}{d\'efinition}{d\'efinitions}%
+ \Crefname{definition}{D\'efinition}{D\'efinitions}%
+ \crefname{result}{r\'esultat}{r\'esultats}%
+ \Crefname{result}{R\'esultat}{R\'esultats}%
+ }}}
+\ExecuteOptions{english}
+\ProcessOptions*\relax
+\AtBeginDocument{%
+ \edef\@tmpa{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \@ifundefined{crefrangeconjunction}{%
+ \let\crefrangeconjunction\crefrangeconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefrangeconjunction\expandafter}%
+ \expandafter{\crefrangeconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefpairconjunction}{%
+ \let\crefpairconjunction\crefpairconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairconjunction\expandafter}%
+ \expandafter{\crefpairconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefmiddleconjunction}{%
+ \let\crefmiddleconjunction\crefmiddleconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefmiddleconjunction\expandafter}%
+ \expandafter{\crefmiddleconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{creflastconjunction}{%
+ \let\creflastconjunction\creflastconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\creflastconjunction\expandafter}%
+ \expandafter{\creflastconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction%
+ \crefpairgroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairgroupconjunction\expandafter}%
+ \expandafter{\crefpairgroupconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction%
+ \crefmiddlegroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairmiddleconjunction\expandafter}%
+ \expandafter{\crefpairmiddleconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{creflastgroupconjunction}{%
+ \let\creflastgroupconjunction%
+ \creflastgroupconjunction@preamble%
+ }{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \expandafter\renewcommand\expandafter%
+ {\expandafter\crefpairlastconjunction\expandafter}%
+ \expandafter{\crefpairlastconjunction}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpa\expandafter{\@tmpb}%
+ }%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction\crefpairconjunction}{}%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
+ \@ifundefined{creflastgroupconjunction}{%
+ \edef\creflastgroupconjunction{, \creflastconjunction}}{}%
+ \let\@tmpstack\cref@label@types%
+ \cref@isstackfull{\@tmpstack}%
+ \@whilesw\if@cref@stackfull\fi{%
+ \edef\@tmpa{\cref@stack@top{\@tmpstack}}%
+ \@ifundefined{cref@\@tmpa @name}{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname cref@\@tmpa @name@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname cref@\@tmpa @name@plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc
+ }{%
+ \edef\@tmpb{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \expandafter\crefname\expandafter{\@tmpa}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@\@tmpa @name@plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpb\expandafter{\@tmpc}%
+ }%
+ \@ifundefined{Cref@\@tmpa @name}{%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname Cref@\@tmpa @name@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \csname Cref@\@tmpa @name@plural@preamble\endcsname}%
+ \expandafter\expandafter\expandafter\let\expandafter\@tmpb\@tmpc
+ }{%
+ \edef\@tmpb{%
+ \expandafter\noexpand\csname extras\cref@language\endcsname}%
+ \expandafter\def\expandafter\@tmpc\expandafter{%
+ \expandafter\Crefname\expandafter{\@tmpa}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\expandafter\expandafter\@tmpc%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@\@tmpa @name@plural\endcsname}}%
+ \expandafter\expandafter\expandafter\cref@addto%
+ \expandafter\@tmpb\expandafter{\@tmpc}%
+ }%
+ \@ifundefined{cref@\@tmpa @format}{%
+ \expandafter\@crefdefineformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{crefrange@\@tmpa @format}{%
+ \expandafter\@crefrangedefineformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{cref@\@tmpa @format@first}{%
+ \expandafter\@crefdefinemultiformat\expandafter{\@tmpa}}{}%
+ \@ifundefined{crefrange@\@tmpa @format@first}{%
+ \expandafter\@crefrangedefinemultiformat\expandafter{\@tmpa}}{}%
+ \cref@stack@pop{\@tmpstack}%
+ \cref@isstackfull{\@tmpstack}}%
+ \@ifundefined{cref@subsection@format}{%
+ \let\cref@subsection@format%
+ \cref@section@format}{}%
+ \@ifundefined{Cref@subsection@format}{%
+ \let\Cref@subsection@format%
+ \Cref@section@format}{}%
+ \@ifundefined{crefrange@subsection@format}{%
+ \let\crefrange@subsection@format%
+ \crefrange@section@format}{}%
+ \@ifundefined{Crefrange@subsection@format}{%
+ \let\Crefrange@subsection@format%
+ \Crefrange@section@format}{}%
+ \@ifundefined{cref@subsection@format@first}{%
+ \let\cref@subsection@format@first%
+ \cref@section@format@first}{}%
+ \@ifundefined{Cref@subsection@format@first}{%
+ \let\Cref@subsection@format@first%
+ \Cref@section@format@first}{}%
+ \@ifundefined{cref@subsection@format@second}{%
+ \let\cref@subsection@format@second%
+ \cref@section@format@second}{}%
+ \@ifundefined{Cref@subsection@format@second}{%
+ \let\Cref@subsection@format@second%
+ \Cref@section@format@second}{}%
+ \@ifundefined{cref@subsection@format@middle}{%
+ \let\cref@subsection@format@middle%
+ \cref@section@format@middle}{}%
+ \@ifundefined{Cref@subsection@format@middle}{%
+ \let\Cref@subsection@format@middle%
+ \Cref@section@format@middle}{}%
+ \@ifundefined{cref@subsection@format@last}{%
+ \let\cref@subsection@format@last%
+ \cref@section@format@last}{}%
+ \@ifundefined{Cref@subsection@format@last}{%
+ \let\Cref@subsection@format@last%
+ \Cref@section@format@last}{}%
+ \@ifundefined{crefrange@subsection@format@first}{%
+ \let\crefrange@subsection@format@first%
+ \crefrange@section@format@first}{}%
+ \@ifundefined{Crefrange@subsection@format@first}{%
+ \let\Crefrange@subsection@format@first%
+ \Crefrange@section@format@first}{}%
+ \@ifundefined{crefrange@subsection@format@second}{%
+ \let\crefrange@subsection@format@second%
+ \crefrange@section@format@second}{}%
+ \@ifundefined{Crefrange@subsection@format@second}{%
+ \let\Crefrange@subsection@format@second%
+ \Crefrange@section@format@second}{}%
+ \@ifundefined{crefrange@subsection@format@middle}{%
+ \let\crefrange@subsection@format@middle%
+ \crefrange@section@format@middle}{}%
+ \@ifundefined{Crefrange@subsection@format@middle}{%
+ \let\Crefrange@subsection@format@middle%
+ \Crefrange@section@format@middle}{}%
+ \@ifundefined{crefrange@subsection@format@last}{%
+ \let\crefrange@subsection@format@last%
+ \crefrange@section@format@last}{}%
+ \@ifundefined{Crefrange@subsection@format@last}{%
+ \let\Crefrange@subsection@format@last%
+ \Crefrange@section@format@last}{}%
+ \@ifundefined{cref@subsubsection@format}{%
+ \let\cref@subsubsection@format%
+ \cref@subsection@format}{}%
+ \@ifundefined{Cref@subsubsection@format}{%
+ \let\Cref@subsubsection@format%
+ \Cref@subsection@format}{}%
+ \@ifundefined{crefrange@subsubsection@format}{%
+ \let\crefrange@subsubsection@format%
+ \crefrange@subsection@format}{}%
+ \@ifundefined{Crefrange@subsubsection@format}{%
+ \let\Crefrange@subsubsection@format%
+ \Crefrange@subsection@format}{}%
+ \@ifundefined{cref@subsubsection@format@first}{%
+ \let\cref@subsubsection@format@first%
+ \cref@subsection@format@first}{}%
+ \@ifundefined{Cref@subsubsection@format@first}{%
+ \let\Cref@subsubsection@format@first%
+ \Cref@subsection@format@first}{}%
+ \@ifundefined{cref@subsubsection@format@second}{%
+ \let\cref@subsubsection@format@second%
+ \cref@subsection@format@second}{}%
+ \@ifundefined{Cref@subsubsection@format@second}{%
+ \let\Cref@subsubsection@format@second%
+ \Cref@subsection@format@second}{}%
+ \@ifundefined{cref@subsubsection@format@middle}{%
+ \let\cref@subsubsection@format@middle%
+ \cref@subsection@format@middle}{}%
+ \@ifundefined{Cref@subsubsection@format@middle}{%
+ \let\Cref@subsubsection@format@middle%
+ \Cref@subsection@format@middle}{}%
+ \@ifundefined{cref@subsubsection@format@last}{%
+ \let\cref@subsubsection@format@last%
+ \cref@subsection@format@last}{}%
+ \@ifundefined{Cref@subsubsection@format@last}{%
+ \let\Cref@subsubsection@format@last%
+ \Cref@subsection@format@last}{}%
+ \@ifundefined{crefrange@subsubsection@format@first}{%
+ \let\crefrange@subsubsection@format@first%
+ \crefrange@subsection@format@first}{}%
+ \@ifundefined{Crefrange@subsubsection@format@first}{%
+ \let\Crefrange@subsubsection@format@first%
+ \Crefrange@subsection@format@first}{}%
+ \@ifundefined{crefrange@subsubsection@format@second}{%
+ \let\crefrange@subsubsection@format@second%
+ \crefrange@subsection@format@second}{}%
+ \@ifundefined{Crefrange@subsubsection@format@second}{%
+ \let\Crefrange@subsubsection@format@second%
+ \Crefrange@subsection@format@second}{}%
+ \@ifundefined{crefrange@subsubsection@format@middle}{%
+ \let\crefrange@subsubsection@format@middle%
+ \crefrange@subsection@format@middle}{}%
+ \@ifundefined{Crefrange@subsubsection@format@middle}{%
+ \let\Crefrange@subsubsection@format@middle%
+ \Crefrange@subsection@format@middle}{}%
+ \@ifundefined{crefrange@subsubsection@format@last}{%
+ \let\crefrange@subsubsection@format@last%
+ \crefrange@subsection@format@last}{}%
+ \@ifundefined{Crefrange@subsubsection@format@last}{%
+ \let\Crefrange@subsubsection@format@last%
+ \Crefrange@subsection@format@last}{}%
+ \@ifundefined{cref@subappendix@format}{%
+ \let\cref@subappendix@format%
+ \cref@appendix@format}{}%
+ \@ifundefined{Cref@subappendix@format}{%
+ \let\Cref@subappendix@format%
+ \Cref@appendix@format}{}%
+ \@ifundefined{crefrange@subappendix@format}{%
+ \let\crefrange@subappendix@format%
+ \crefrange@appendix@format}{}%
+ \@ifundefined{Crefrange@subappendix@format}{%
+ \let\Crefrange@subappendix@format%
+ \Crefrange@appendix@format}{}%
+ \@ifundefined{cref@subappendix@format@first}{%
+ \let\cref@subappendix@format@first%
+ \cref@appendix@format@first}{}%
+ \@ifundefined{Cref@subappendix@format@first}{%
+ \let\Cref@subappendix@format@first%
+ \Cref@appendix@format@first}{}%
+ \@ifundefined{cref@subappendix@format@second}{%
+ \let\cref@subappendix@format@second%
+ \cref@appendix@format@second}{}%
+ \@ifundefined{Cref@subappendix@format@second}{%
+ \let\Cref@subappendix@format@second%
+ \Cref@appendix@format@second}{}%
+ \@ifundefined{cref@subappendix@format@middle}{%
+ \let\cref@subappendix@format@middle%
+ \cref@appendix@format@middle}{}%
+ \@ifundefined{Cref@subappendix@format@middle}{%
+ \let\Cref@subappendix@format@middle%
+ \Cref@appendix@format@middle}{}%
+ \@ifundefined{cref@subappendix@format@last}{%
+ \let\cref@subappendix@format@last%
+ \cref@appendix@format@last}{}%
+ \@ifundefined{Cref@subappendix@format@last}{%
+ \let\Cref@subappendix@format@last%
+ \Cref@appendix@format@last}{}%
+ \@ifundefined{crefrange@subappendix@format@first}{%
+ \let\crefrange@subappendix@format@first%
+ \crefrange@appendix@format@first}{}%
+ \@ifundefined{Crefrange@subappendix@format@first}{%
+ \let\Crefrange@subappendix@format@first%
+ \Crefrange@appendix@format@first}{}%
+ \@ifundefined{crefrange@subappendix@format@second}{%
+ \let\crefrange@subappendix@format@second%
+ \crefrange@appendix@format@second}{}%
+ \@ifundefined{Crefrange@subappendix@format@second}{%
+ \let\Crefrange@subappendix@format@second%
+ \Crefrange@appendix@format@second}{}%
+ \@ifundefined{crefrange@subappendix@format@middle}{%
+ \let\crefrange@subappendix@format@middle%
+ \crefrange@appendix@format@middle}{}%
+ \@ifundefined{Crefrange@subappendix@format@middle}{%
+ \let\Crefrange@subappendix@format@middle%
+ \Crefrange@appendix@format@middle}{}%
+ \@ifundefined{crefrange@subappendix@format@last}{%
+ \let\crefrange@subappendix@format@last%
+ \crefrange@appendix@format@last}{}%
+ \@ifundefined{Crefrange@subappendix@format@last}{%
+ \let\Crefrange@subappendix@format@last%
+ \Crefrange@appendix@format@last}{}%
+ \@ifundefined{cref@subsubappendix@format}{%
+ \let\cref@subsubappendix@format%
+ \cref@subappendix@format}{}%
+ \@ifundefined{Cref@subsubappendix@format}{%
+ \let\Cref@subsubappendix@format%
+ \Cref@subappendix@format}{}%
+ \@ifundefined{crefrange@subsubappendix@format}{%
+ \let\crefrange@subsubappendix@format%
+ \crefrange@subappendix@format}{}%
+ \@ifundefined{Crefrange@subsubappendix@format}{%
+ \let\Crefrange@subsubappendix@format%
+ \Crefrange@subappendix@format}{}%
+ \@ifundefined{cref@subsubappendix@format@first}{%
+ \let\cref@subsubappendix@format@first%
+ \cref@subappendix@format@first}{}%
+ \@ifundefined{Cref@subsubappendix@format@first}{%
+ \let\Cref@subsubappendix@format@first%
+ \Cref@subappendix@format@first}{}%
+ \@ifundefined{cref@subsubappendix@format@second}{%
+ \let\cref@subsubappendix@format@second%
+ \cref@subappendix@format@second}{}%
+ \@ifundefined{Cref@subsubappendix@format@second}{%
+ \let\Cref@subsubappendix@format@second%
+ \Cref@subappendix@format@second}{}%
+ \@ifundefined{cref@subsubappendix@format@middle}{%
+ \let\cref@subsubappendix@format@middle%
+ \cref@subappendix@format@middle}{}%
+ \@ifundefined{Cref@subsubappendix@format@middle}{%
+ \let\Cref@subsubappendix@format@middle%
+ \Cref@subappendix@format@middle}{}%
+ \@ifundefined{cref@subsubappendix@format@last}{%
+ \let\cref@subsubappendix@format@last%
+ \cref@subappendix@format@last}{}%
+ \@ifundefined{Cref@subsubappendix@format@last}{%
+ \let\Cref@subsubappendix@format@last%
+ \Cref@subappendix@format@last}{}%
+ \@ifundefined{crefrange@subsubappendix@format@first}{%
+ \let\crefrange@subsubappendix@format@first%
+ \crefrange@subappendix@format@first}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@first}{%
+ \let\Crefrange@subsubappendix@format@first%
+ \Crefrange@subappendix@format@first}{}%
+ \@ifundefined{crefrange@subsubappendix@format@second}{%
+ \let\crefrange@subsubappendix@format@second%
+ \crefrange@subappendix@format@second}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@second}{%
+ \let\Crefrange@subsubappendix@format@second%
+ \Crefrange@subappendix@format@second}{}%
+ \@ifundefined{crefrange@subsubappendix@format@middle}{%
+ \let\crefrange@subsubappendix@format@middle%
+ \crefrange@subappendix@format@middle}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@middle}{%
+ \let\Crefrange@subsubappendix@format@middle%
+ \Crefrange@subappendix@format@middle}{}%
+ \@ifundefined{crefrange@subsubappendix@format@last}{%
+ \let\crefrange@subsubappendix@format@last%
+ \crefrange@subappendix@format@last}{}%
+ \@ifundefined{Crefrange@subsubappendix@format@last}{%
+ \let\Crefrange@subsubappendix@format@last%
+ \Crefrange@subappendix@format@last}{}%
+ \@ifundefined{cref@subsubsubappendix@format}{%
+ \let\cref@subsubsubappendix@format%
+ \cref@subsubappendix@format}{}%
+ \@ifundefined{Cref@subsubsubappendix@format}{%
+ \let\Cref@subsubsubappendix@format%
+ \Cref@subsubappendix@format}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format}{%
+ \let\crefrange@subsubsubappendix@format%
+ \crefrange@subsubappendix@format}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format}{%
+ \let\Crefrange@subsubsubappendix@format%
+ \Crefrange@subsubappendix@format}{}%
+ \@ifundefined{cref@subsubsubappendix@format@first}{%
+ \let\cref@subsubsubappendix@format@first%
+ \cref@subsubappendix@format@first}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@first}{%
+ \let\Cref@subsubsubappendix@format@first%
+ \Cref@subsubappendix@format@first}{}%
+ \@ifundefined{cref@subsubsubappendix@format@second}{%
+ \let\cref@subsubsubappendix@format@second%
+ \cref@subsubappendix@format@second}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@second}{%
+ \let\Cref@subsubsubappendix@format@second%
+ \Cref@subsubappendix@format@second}{}%
+ \@ifundefined{cref@subsubsubappendix@format@middle}{%
+ \let\cref@subsubsubappendix@format@middle%
+ \cref@subsubappendix@format@middle}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@middle}{%
+ \let\Cref@subsubsubappendix@format@middle%
+ \Cref@subsubappendix@format@middle}{}%
+ \@ifundefined{cref@subsubsubappendix@format@last}{%
+ \let\cref@subsubsubappendix@format@last%
+ \cref@subsubappendix@format@last}{}%
+ \@ifundefined{Cref@subsubsubappendix@format@last}{%
+ \let\Cref@subsubsubappendix@format@last%
+ \Cref@subsubappendix@format@last}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@first}{%
+ \let\crefrange@subsubsubappendix@format@first%
+ \crefrange@subsubappendix@format@first}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@first}{%
+ \let\Crefrange@subsubsubappendix@format@first%
+ \Crefrange@subsubappendix@format@first}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@second}{%
+ \let\crefrange@subsubsubappendix@format@second%
+ \crefrange@subsubappendix@format@second}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@second}{%
+ \let\Crefrange@subsubsubappendix@format@second%
+ \Crefrange@subsubappendix@format@second}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@middle}{%
+ \let\crefrange@subsubsubappendix@format@middle%
+ \crefrange@subsubappendix@format@middle}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@middle}{%
+ \let\Crefrange@subsubsubappendix@format@middle%
+ \Crefrange@subsubappendix@format@middle}{}%
+ \@ifundefined{crefrange@subsubsubappendix@format@last}{%
+ \let\crefrange@subsubsubappendix@format@last%
+ \crefrange@subsubappendix@format@last}{}%
+ \@ifundefined{Crefrange@subsubsubappendix@format@last}{%
+ \let\Crefrange@subsubsubappendix@format@last%
+ \Crefrange@subsubappendix@format@last}{}%
+ \@ifundefined{cref@subfigure@format}{%
+ \let\cref@subfigure@format%
+ \cref@figure@format}{}%
+ \@ifundefined{Cref@subfigure@format}{%
+ \let\Cref@subfigure@format%
+ \Cref@figure@format}{}%
+ \@ifundefined{crefrange@subfigure@format}{%
+ \let\crefrange@subfigure@format%
+ \crefrange@figure@format}{}%
+ \@ifundefined{Crefrange@subfigure@format}{%
+ \let\Crefrange@subfigure@format%
+ \Crefrange@figure@format}{}%
+ \@ifundefined{cref@subfigure@format@first}{%
+ \let\cref@subfigure@format@first%
+ \cref@figure@format@first}{}%
+ \@ifundefined{Cref@subfigure@format@first}{%
+ \let\Cref@subfigure@format@first%
+ \Cref@figure@format@first}{}%
+ \@ifundefined{cref@subfigure@format@second}{%
+ \let\cref@subfigure@format@second%
+ \cref@figure@format@second}{}%
+ \@ifundefined{Cref@subfigure@format@second}{%
+ \let\Cref@subfigure@format@second%
+ \Cref@figure@format@second}{}%
+ \@ifundefined{cref@subfigure@format@middle}{%
+ \let\cref@subfigure@format@middle%
+ \cref@figure@format@middle}{}%
+ \@ifundefined{Cref@subfigure@format@middle}{%
+ \let\Cref@subfigure@format@middle%
+ \Cref@figure@format@middle}{}%
+ \@ifundefined{cref@subfigure@format@last}{%
+ \let\cref@subfigure@format@last%
+ \cref@figure@format@last}{}%
+ \@ifundefined{Cref@subfigure@format@last}{%
+ \let\Cref@subfigure@format@last%
+ \Cref@figure@format@last}{}%
+ \@ifundefined{crefrange@subfigure@format@first}{%
+ \let\crefrange@subfigure@format@first%
+ \crefrange@figure@format@first}{}%
+ \@ifundefined{Crefrange@subfigure@format@first}{%
+ \let\Crefrange@subfigure@format@first%
+ \Crefrange@figure@format@first}{}%
+ \@ifundefined{crefrange@subfigure@format@second}{%
+ \let\crefrange@subfigure@format@second%
+ \crefrange@figure@format@second}{}%
+ \@ifundefined{Crefrange@subfigure@format@second}{%
+ \let\Crefrange@subfigure@format@second%
+ \Crefrange@figure@format@second}{}%
+ \@ifundefined{crefrange@subfigure@format@middle}{%
+ \let\crefrange@subfigure@format@middle%
+ \crefrange@figure@format@middle}{}%
+ \@ifundefined{Crefrange@subfigure@format@middle}{%
+ \let\Crefrange@subfigure@format@middle%
+ \Crefrange@figure@format@middle}{}%
+ \@ifundefined{crefrange@subfigure@format@last}{%
+ \let\crefrange@subfigure@format@last%
+ \crefrange@figure@format@last}{}%
+ \@ifundefined{Crefrange@subfigure@format@last}{%
+ \let\Crefrange@subfigure@format@last%
+ \Crefrange@figure@format@last}{}%
+ \@ifundefined{cref@subtable@format}{%
+ \let\cref@subtable@format%
+ \cref@table@format}{}%
+ \@ifundefined{Cref@subtable@format}{%
+ \let\Cref@subtable@format%
+ \Cref@table@format}{}%
+ \@ifundefined{crefrange@subtable@format}{%
+ \let\crefrange@subtable@format%
+ \crefrange@table@format}{}%
+ \@ifundefined{Crefrange@subtable@format}{%
+ \let\Crefrange@subtable@format%
+ \Crefrange@table@format}{}%
+ \@ifundefined{cref@subtable@format@first}{%
+ \let\cref@subtable@format@first%
+ \cref@table@format@first}{}%
+ \@ifundefined{Cref@subtable@format@first}{%
+ \let\Cref@subtable@format@first%
+ \Cref@table@format@first}{}%
+ \@ifundefined{cref@subtable@format@second}{%
+ \let\cref@subtable@format@second%
+ \cref@table@format@second}{}%
+ \@ifundefined{Cref@subtable@format@second}{%
+ \let\Cref@subtable@format@second%
+ \Cref@table@format@second}{}%
+ \@ifundefined{cref@subtable@format@middle}{%
+ \let\cref@subtable@format@middle%
+ \cref@table@format@middle}{}%
+ \@ifundefined{Cref@subtable@format@middle}{%
+ \let\Cref@subtable@format@middle%
+ \Cref@table@format@middle}{}%
+ \@ifundefined{cref@subtable@format@last}{%
+ \let\cref@subtable@format@last%
+ \cref@table@format@last}{}%
+ \@ifundefined{Cref@subtable@format@last}{%
+ \let\Cref@subtable@format@last%
+ \Cref@table@format@last}{}%
+ \@ifundefined{crefrange@subtable@format@first}{%
+ \let\crefrange@subtable@format@first%
+ \crefrange@table@format@first}{}%
+ \@ifundefined{Crefrange@subtable@format@first}{%
+ \let\Crefrange@subtable@format@first%
+ \Crefrange@table@format@first}{}%
+ \@ifundefined{crefrange@subtable@format@second}{%
+ \let\crefrange@subtable@format@second%
+ \crefrange@table@format@second}{}%
+ \@ifundefined{Crefrange@subtable@format@second}{%
+ \let\Crefrange@subtable@format@second%
+ \Crefrange@table@format@second}{}%
+ \@ifundefined{crefrange@subtable@format@middle}{%
+ \let\crefrange@subtable@format@middle%
+ \crefrange@table@format@middle}{}%
+ \@ifundefined{Crefrange@subtable@format@middle}{%
+ \let\Crefrange@subtable@format@middle%
+ \Crefrange@table@format@middle}{}%
+ \@ifundefined{crefrange@subtable@format@last}{%
+ \let\crefrange@subtable@format@last%
+ \crefrange@table@format@last}{}%
+ \@ifundefined{Crefrange@subtable@format@last}{%
+ \let\Crefrange@subtable@format@last%
+ \Crefrange@table@format@last}{}%
+ \@ifundefined{cref@enumii@format}{%
+ \let\cref@enumii@format%
+ \cref@enumi@format}{}%
+ \@ifundefined{Cref@enumii@format}{%
+ \let\Cref@enumii@format%
+ \Cref@enumi@format}{}%
+ \@ifundefined{crefrange@enumii@format}{%
+ \let\crefrange@enumii@format%
+ \crefrange@enumi@format}{}%
+ \@ifundefined{Crefrange@enumii@format}{%
+ \let\Crefrange@enumii@format%
+ \Crefrange@enumi@format}{}%
+ \@ifundefined{cref@enumii@format@first}{%
+ \let\cref@enumii@format@first%
+ \cref@enumi@format@first}{}%
+ \@ifundefined{Cref@enumii@format@first}{%
+ \let\Cref@enumii@format@first%
+ \Cref@enumi@format@first}{}%
+ \@ifundefined{cref@enumii@format@second}{%
+ \let\cref@enumii@format@second%
+ \cref@enumi@format@second}{}%
+ \@ifundefined{Cref@enumii@format@second}{%
+ \let\Cref@enumii@format@second%
+ \Cref@enumi@format@second}{}%
+ \@ifundefined{cref@enumii@format@middle}{%
+ \let\cref@enumii@format@middle%
+ \cref@enumi@format@middle}{}%
+ \@ifundefined{Cref@enumii@format@middle}{%
+ \let\Cref@enumii@format@middle%
+ \Cref@enumi@format@middle}{}%
+ \@ifundefined{cref@enumii@format@last}{%
+ \let\cref@enumii@format@last%
+ \cref@enumi@format@last}{}%
+ \@ifundefined{Cref@enumii@format@last}{%
+ \let\Cref@enumii@format@last%
+ \Cref@enumi@format@last}{}%
+ \@ifundefined{crefrange@enumii@format@first}{%
+ \let\crefrange@enumii@format@first%
+ \crefrange@enumi@format@first}{}%
+ \@ifundefined{Crefrange@enumii@format@first}{%
+ \let\Crefrange@enumii@format@first%
+ \Crefrange@enumi@format@first}{}%
+ \@ifundefined{crefrange@enumii@format@second}{%
+ \let\crefrange@enumii@format@second%
+ \crefrange@enumi@format@second}{}%
+ \@ifundefined{Crefrange@enumii@format@second}{%
+ \let\Crefrange@enumii@format@second%
+ \Crefrange@enumi@format@second}{}%
+ \@ifundefined{crefrange@enumii@format@middle}{%
+ \let\crefrange@enumii@format@middle%
+ \crefrange@enumi@format@middle}{}%
+ \@ifundefined{Crefrange@enumii@format@middle}{%
+ \let\Crefrange@enumii@format@middle%
+ \Crefrange@enumi@format@middle}{}%
+ \@ifundefined{crefrange@enumii@format@last}{%
+ \let\crefrange@enumii@format@last%
+ \crefrange@enumi@format@last}{}%
+ \@ifundefined{Crefrange@enumii@format@last}{%
+ \let\Crefrange@enumii@format@last%
+ \Crefrange@enumi@format@last}{}%
+ \@ifundefined{cref@enumiii@format}{%
+ \let\cref@enumiii@format%
+ \cref@enumii@format}{}%
+ \@ifundefined{Cref@enumiii@format}{%
+ \let\Cref@enumiii@format%
+ \Cref@enumii@format}{}%
+ \@ifundefined{crefrange@enumiii@format}{%
+ \let\crefrange@enumiii@format%
+ \crefrange@enumii@format}{}%
+ \@ifundefined{Crefrange@enumiii@format}{%
+ \let\Crefrange@enumiii@format%
+ \Crefrange@enumii@format}{}%
+ \@ifundefined{cref@enumiii@format@first}{%
+ \let\cref@enumiii@format@first%
+ \cref@enumii@format@first}{}%
+ \@ifundefined{Cref@enumiii@format@first}{%
+ \let\Cref@enumiii@format@first%
+ \Cref@enumii@format@first}{}%
+ \@ifundefined{cref@enumiii@format@second}{%
+ \let\cref@enumiii@format@second%
+ \cref@enumii@format@second}{}%
+ \@ifundefined{Cref@enumiii@format@second}{%
+ \let\Cref@enumiii@format@second%
+ \Cref@enumii@format@second}{}%
+ \@ifundefined{cref@enumiii@format@middle}{%
+ \let\cref@enumiii@format@middle%
+ \cref@enumii@format@middle}{}%
+ \@ifundefined{Cref@enumiii@format@middle}{%
+ \let\Cref@enumiii@format@middle%
+ \Cref@enumii@format@middle}{}%
+ \@ifundefined{cref@enumiii@format@last}{%
+ \let\cref@enumiii@format@last%
+ \cref@enumii@format@last}{}%
+ \@ifundefined{Cref@enumiii@format@last}{%
+ \let\Cref@enumiii@format@last%
+ \Cref@enumii@format@last}{}%
+ \@ifundefined{crefrange@enumiii@format@first}{%
+ \let\crefrange@enumiii@format@first%
+ \crefrange@enumii@format@first}{}%
+ \@ifundefined{Crefrange@enumiii@format@first}{%
+ \let\Crefrange@enumiii@format@first%
+ \Crefrange@enumii@format@first}{}%
+ \@ifundefined{crefrange@enumiii@format@second}{%
+ \let\crefrange@enumiii@format@second%
+ \crefrange@enumii@format@second}{}%
+ \@ifundefined{Crefrange@enumiii@format@second}{%
+ \let\Crefrange@enumiii@format@second%
+ \Crefrange@enumii@format@second}{}%
+ \@ifundefined{crefrange@enumiii@format@middle}{%
+ \let\crefrange@enumiii@format@middle%
+ \crefrange@enumii@format@middle}{}%
+ \@ifundefined{Crefrange@enumiii@format@middle}{%
+ \let\Crefrange@enumiii@format@middle%
+ \Crefrange@enumii@format@middle}{}%
+ \@ifundefined{crefrange@enumiii@format@last}{%
+ \let\crefrange@enumiii@format@last%
+ \crefrange@enumii@format@last}{}%
+ \@ifundefined{Crefrange@enumiii@format@last}{%
+ \let\Crefrange@enumiii@format@last%
+ \Crefrange@enumii@format@last}{}%
+ \@ifundefined{cref@enumiv@format}{%
+ \let\cref@enumiv@format%
+ \cref@enumiii@format}{}%
+ \@ifundefined{Cref@enumiv@format}{%
+ \let\Cref@enumiv@format%
+ \Cref@enumiii@format}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \let\crefrange@enumiv@format%
+ \crefrange@enumiii@format}{}%
+ \@ifundefined{Crefrange@enumiv@format}{%
+ \let\Crefrange@enumiv@format%
+ \Crefrange@enumiii@format}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \let\cref@enumiv@format@first%
+ \cref@enumiii@format@first}{}%
+ \@ifundefined{Cref@enumiv@format@first}{%
+ \let\Cref@enumiv@format@first%
+ \Cref@enumiii@format@first}{}%
+ \@ifundefined{cref@enumiv@format@second}{%
+ \let\cref@enumiv@format@second%
+ \cref@enumiii@format@second}{}%
+ \@ifundefined{Cref@enumiv@format@second}{%
+ \let\Cref@enumiv@format@second%
+ \Cref@enumiii@format@second}{}%
+ \@ifundefined{cref@enumiv@format@middle}{%
+ \let\cref@enumiv@format@middle%
+ \cref@enumiii@format@middle}{}%
+ \@ifundefined{Cref@enumiv@format@middle}{%
+ \let\Cref@enumiv@format@middle%
+ \Cref@enumiii@format@middle}{}%
+ \@ifundefined{cref@enumiv@format@last}{%
+ \let\cref@enumiv@format@last%
+ \cref@enumiii@format@last}{}%
+ \@ifundefined{Cref@enumiv@format@last}{%
+ \let\Cref@enumiv@format@last%
+ \Cref@enumiii@format@last}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \let\crefrange@enumiv@format@first%
+ \crefrange@enumiii@format@first}{}%
+ \@ifundefined{Crefrange@enumiv@format@first}{%
+ \let\Crefrange@enumiv@format@first%
+ \Crefrange@enumiii@format@first}{}%
+ \@ifundefined{crefrange@enumiv@format@second}{%
+ \let\crefrange@enumiv@format@second%
+ \crefrange@enumiii@format@second}{}%
+ \@ifundefined{Crefrange@enumiv@format@second}{%
+ \let\Crefrange@enumiv@format@second%
+ \Crefrange@enumiii@format@second}{}%
+ \@ifundefined{crefrange@enumiv@format@middle}{%
+ \let\crefrange@enumiv@format@middle%
+ \crefrange@enumiii@format@middle}{}%
+ \@ifundefined{Crefrange@enumiv@format@middle}{%
+ \let\Crefrange@enumiv@format@middle%
+ \Crefrange@enumiii@format@middle}{}%
+ \@ifundefined{crefrange@enumiv@format@last}{%
+ \let\crefrange@enumiv@format@last%
+ \crefrange@enumiii@format@last}{}%
+ \@ifundefined{Crefrange@enumiv@format@last}{%
+ \let\Crefrange@enumiv@format@last%
+ \Crefrange@enumiii@format@last}{}%
+ \@ifundefined{cref@enumv@format}{%
+ \let\cref@enumv@format%
+ \cref@enumiv@format}{}%
+ \@ifundefined{Cref@enumv@format}{%
+ \let\Cref@enumv@format%
+ \Cref@enumiv@format}{}%
+ \@ifundefined{crefrange@enumv@format}{%
+ \let\crefrange@enumv@format%
+ \crefrange@enumiv@format}{}%
+ \@ifundefined{Crefrange@enumv@format}{%
+ \let\Crefrange@enumv@format%
+ \Crefrange@enumiv@format}{}%
+ \@ifundefined{cref@enumv@format@first}{%
+ \let\cref@enumv@format@first%
+ \cref@enumiv@format@first}{}%
+ \@ifundefined{Cref@enumv@format@first}{%
+ \let\Cref@enumv@format@first%
+ \Cref@enumiv@format@first}{}%
+ \@ifundefined{cref@enumv@format@second}{%
+ \let\cref@enumv@format@second%
+ \cref@enumiv@format@second}{}%
+ \@ifundefined{Cref@enumv@format@second}{%
+ \let\Cref@enumv@format@second%
+ \Cref@enumiv@format@second}{}%
+ \@ifundefined{cref@enumv@format@middle}{%
+ \let\cref@enumv@format@middle%
+ \cref@enumiv@format@middle}{}%
+ \@ifundefined{Cref@enumv@format@middle}{%
+ \let\Cref@enumv@format@middle%
+ \Cref@enumiv@format@middle}{}%
+ \@ifundefined{cref@enumv@format@last}{%
+ \let\cref@enumv@format@last%
+ \cref@enumiv@format@last}{}%
+ \@ifundefined{Cref@enumv@format@last}{%
+ \let\Cref@enumv@format@last%
+ \Cref@enumiv@format@last}{}%
+ \@ifundefined{crefrange@enumv@format@first}{%
+ \let\crefrange@enumv@format@first%
+ \crefrange@enumiv@format@first}{}%
+ \@ifundefined{Crefrange@enumv@format@first}{%
+ \let\Crefrange@enumv@format@first%
+ \Crefrange@enumiv@format@first}{}%
+ \@ifundefined{crefrange@enumv@format@second}{%
+ \let\crefrange@enumv@format@second%
+ \crefrange@enumiv@format@second}{}%
+ \@ifundefined{Crefrange@enumv@format@second}{%
+ \let\Crefrange@enumv@format@second%
+ \Crefrange@enumiv@format@second}{}%
+ \@ifundefined{crefrange@enumv@format@middle}{%
+ \let\crefrange@enumv@format@middle%
+ \crefrange@enumiv@format@middle}{}%
+ \@ifundefined{Crefrange@enumv@format@middle}{%
+ \let\Crefrange@enumv@format@middle%
+ \Crefrange@enumiv@format@middle}{}%
+ \@ifundefined{crefrange@enumv@format@last}{%
+ \let\crefrange@enumv@format@last%
+ \crefrange@enumiv@format@last}{}%
+ \@ifundefined{Crefrange@enumv@format@last}{%
+ \let\Crefrange@enumv@format@last%
+ \Crefrange@enumiv@format@last}{}%
+ \let\cref@language\relax%
}
-\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'.