summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2007-11-03 23:59:08 +0000
committerKarl Berry <karl@freefriends.org>2007-11-03 23:59:08 +0000
commit971d67d195a21a89798b1204d3fc7b8553a631d9 (patch)
treee796443ba276081cef7eb6d8c1684885441eb51c
parenta335315e96e045d8d7fb154d641a61284234cbd7 (diff)
cleveref update (1nov07)
git-svn-id: svn://tug.org/texlive/trunk@5329 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/cleveref/README62
-rw-r--r--Master/texmf-dist/doc/latex/cleveref/cleveref.pdfbin208189 -> 274325 bytes
-rw-r--r--Master/texmf-dist/source/latex/cleveref/cleveref.dtx2263
-rw-r--r--Master/texmf-dist/tex/latex/cleveref/cleveref.sty1123
4 files changed, 2303 insertions, 1145 deletions
diff --git a/Master/texmf-dist/doc/latex/cleveref/README b/Master/texmf-dist/doc/latex/cleveref/README
index 95b77c9ac5c..28c77cfada7 100644
--- a/Master/texmf-dist/doc/latex/cleveref/README
+++ b/Master/texmf-dist/doc/latex/cleveref/README
@@ -1,31 +1,31 @@
-cleveref, a LaTeX package for intelligent cross-referencing
-Copyright (C) 2007 Toby Cubitt
-
-Files:
-cleveref.ins Batch file, run through LaTeX
-cleveref.dtx Docstrip archive, run through LaTeX
-cleveref.sty LaTeX package, generated by cleveref.ins from cleveref.dtx
-cleveref.dvi Package documentation, generated from cleveref.dtx
-cleveref.pdf Package documentation; can also be generated from cleveref.dtx
-README This file
-
-E-mail: toby-cleveref@dr-qubit.org
-Address: Department of Mathematics, University of Bristol, UK
-
-This material is subject to the LaTeX Project Public License. See
-http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the
-details of that license.
-
-
-Abstract:
----------
-The 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.). The formatting for each 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 formatting is fully customisable. Though a number of other
-packages provide similar features, all have certain deficiencies which
-cleveref attempts to overcome.
+cleveref, a LaTeX package for intelligent cross-referencing
+Copyright (C) 2007 Toby Cubitt
+
+Files:
+cleveref.ins Batch file, run through LaTeX
+cleveref.dtx Docstrip archive, run through LaTeX
+cleveref.sty LaTeX package, generated by cleveref.ins from cleveref.dtx
+cleveref.dvi Package documentation, generated from cleveref.dtx
+cleveref.pdf Package documentation; can also be generated from cleveref.dtx
+README This file
+
+E-mail: toby-cleveref@dr-qubit.org
+Address: Department of Mathematics, University of Bristol, UK
+
+This material is subject to the LaTeX Project Public License. See
+http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html for the
+details of that license.
+
+
+Abstract:
+---------
+The 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.). The formatting for each 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 formatting is fully customisable. Though a number of other
+packages provide similar features, all have certain deficiencies which
+cleveref attempts to overcome.
diff --git a/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf b/Master/texmf-dist/doc/latex/cleveref/cleveref.pdf
index 70b3e40b22a..fc36fac8d75 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 0c5ddd3fa12..cbaec876b2e 100644
--- a/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
+++ b/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
@@ -21,18 +21,18 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{cleveref}
-%<package> [2007/10/07 v0.8 Automatic cross-reference formatting]
+%<package> [2007/30/10 v0.10 Automatic cross-reference formatting]
%
%<*driver>
\documentclass{ltxdoc}
%\documentclass[draft]{ltxdoc}
\usepackage{url}
+\usepackage{hyperref}
\usepackage{cleveref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
-%%\newcomman{\package}[1]{\texttt{#1.sty}}
-%\newcommand{\package}[1]{\texttt{#1}}
+%%\newcommand{\package}[1]{\texttt{#1.sty}}
\newcommand{\package}[1]{\texttt{#1}}
\newcommand{\file}{\texttt}
\newcommand{\option}{\texttt}
@@ -60,7 +60,7 @@
%</driver>
% \fi
%
-% \CheckSum{2163}
+% \CheckSum{3165}
%% \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
@@ -89,14 +89,25 @@
% 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}%
+% {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}%
+% {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.}
%
%
% \GetFileInfo{cleveref.sty}
%
-% \def\fileversion{0.8}
-% \def\filedate{10/07/2007}
+% \def\fileversion{0.10}
+% \def\filedate{30/10/2007}
%
-% \title{The \textsf{cleveref} package\thanks{This document
+% \title{The \package{cleveref} package\thanks{This document
% corresponds to \textsf{cleveref}~\fileversion, dated
% \filedate.}}
% \author{Toby Cubitt \\ \texttt{toby-cleveref@dr-qubit.org}}
@@ -108,30 +119,27 @@
% 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.). 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.
+% (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.
% \end{abstract}
%
%
%
% \section{Introduction}
-%
% When ``clever'' is used in the name of a computer program, it
-% usually signifies that the programmer is overly smug! Or, to take a
-% more charitable attitude, that the programmer is pleased with the
-% sophisticated processing that he has managed to encapsulate in code,
-% relieving the user of some complicated by tedious task. On the other
-% hand, at the heart of the \LaTeX{} philosophy is the idea that it is
-% clever to delegate as much of the typesetting as possible to the
-% computer, in order to achieve a beautiful, but above all consistent,
-% visual appearance.
+% usually signifies that the programmer is overly smug about his
+% achievements! On the other hand, at the heart of the \LaTeX{}
+% philosophy is the idea that it is clever to delegate as much of the
+% typesetting as possible to the computer, in order to achieve a
+% beautiful, but above all consistent, visual appearance.
%
-% Both these points of view are valid with respect to the
+% 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
% information that \LaTeX{} inherently has about labels as
% intelligently as possible in order to type-set references to them
@@ -140,24 +148,27 @@
% the minimum of effort (you'd be clever to use it!).
%
% The \package{cleveref} package enhances \LaTeX{}'s cross-referencing
-% facility by allowing references to be formatted automatically
+% facilities by allowing references to be formatted automatically
% according to the type of object they refer to (chapter, section,
-% equation, theorem, etc.). It can also automatically format
-% references to multiple labels.
+% 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.
%
% In standard \LaTeX{}, you have almost certainly found yourself
-% writing things like |Eq.~(\ref{eq1})| and |Theorem~\ref{thm1}| over
-% and over again. This isn't just tedious. What happens if you later
-% decide you want equation references to be typeset 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|.
-%
-% \package{cleveref} 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 typesetting of equation references, you only
-% have to change one preamble definition. If you later decide to
+% writing things like |Eq.~(\ref{eq1})| and
+% |Theorems~\ref{thm1} to~\ref{thm2}| 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 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|.
+%
+% 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 typesetting of equation references, you
+% only have to change one preamble definition. If you later decide to
% change 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
@@ -165,8 +176,8 @@
% whole document, as well as saving repetitively typing the same text
% for each and every reference.
%
-% A number of other packages provide similar features, most notably
-% \package{varioref}, \package{fancyref}, \package{hyperref}'s
+% 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
@@ -193,36 +204,35 @@
% 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 automatic
-% collapsing of consecutive references, \package{ntheorem} support, or
-% any of the other additional \package{cleveref} features.)
-%
-% The \package{hyperref} package's |\autoref| command typesets a
-% (customisable) name before a reference, based on 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, etc.
+% |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, 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 telling it the label
+% 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}. \package{cleveref} also provides a number extra
-% features too, such as multiple references, automatic collapsing of
-% reference ranges, control over the placement of hyper-links, etc.
+% type of object, as well as fully supporting \package{ntheorem}. And
+% \package{cleveref} provides a number additional features, such as
+% multiple references, automatic collapsing of reference ranges,
+% control over the placement of hyper-links, etc.
%
%
%
% \section{Usage}
-%
% The \package{cleveref} package is loaded in the usual way, by
% putting the line
% \begin{quote}
@@ -230,45 +240,50 @@
% \end{quote}
% in your document's preamble. However, care must be taken when using
% \package{cleveref} in conjunction with other packages that modify
-% \LaTeX{}'s referencing system (see \cref{sec:other_packages}).
-%
-%
-%
-% \subsection{Typesetting References}
-%
+% \LaTeX{}'s referencing system (see
+% \cref{sec:other_packages}). Basically, \package{cleveref} must be
+% loaded \emph{last}.
+%
+% If you just want to get going quickly with \package{cleveref}, and
+% come back later to read up on all the features it provides in more
+% detail, then here's what you need to do. Wherever you would
+% previously have used |\ref|, use |\cref| instead. (Except that at
+% the beginning of a sentence, 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 \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}|. Finally, if you want to refer to multiple
+% things at once, you can now combine them all into one reference and
+% leave \package{cleveref} to sort it out: e.g.\
+% |\cref{eq1,eq2,eq4,thm2,def1}|.
+%
+%
+% \section{Typesetting References}
% \DescribeMacro\cref
-% To automatically typeset a reference according to the type of object
-% referred to, simply refer to it using |\cref{|\meta{label}|}|.
-% \package{cleveref} imposes just one restriction on the names of
-% labels: they are no longer allowed to contain commas ``,''. These
-% can instead be used to typeset multiple references (see below).
+% To automatically typeset a cross-reference according to the type of
+% object 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).
%
% \DescribeMacro\Cref
-% As it is very difficult for \LaTeX{} to determine whether a
-% 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
-% customised independently (see \cref{sec:customising}).
+% 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}.)
%
% \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 correct
+% \package{cleveref} redefines it to recover the original
% behaviour.}, so you can still use it to typeset the formatted
-% label counter alone, without any additional text or formatting. If
-% you would like to use \package{cleveref}'s enhanced features, but
-% want to continue to use |\ref| for referencing, simply redefine the
-% |\ref| command in your document's preamble, thus:
-% \begin{quote}
-% |\renewcommand{\ref}{\cref}|
-% \end{quote}
-% Similarly, if you decide you would like all references capitalised,
-% you can redefine the |\cref| command:
-% \begin{quote}
-% |\renewcommand{\cref}{\Cref}|
-% \end{quote}
+% label counter alone, without any additional text or formatting.
%
% \DescribeMacro\crefrange
% \DescribeMacro\Crefrange
@@ -300,7 +315,7 @@
% \end{quote}
% will be typeset as
% \begin{quote}
-% Eqs.~(1)--(3), and Theorems~1 and~2
+% eqs.~(1)--(3), and Theorems~1 and~2
% \end{quote}
% whereas
% \begin{quote}
@@ -308,19 +323,20 @@
% \end{quote}
% will be typeset as
% \begin{quote}
-% Eqs.~(1) and~(2), Theorems~1 and~2, and Eq.~(3)
+% 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 where you want to prevent
-% collapsing. For example,
+% one or more empty references, at the point at which you want to
+% prevent collapsing. For example,
% \begin{quote}
% |\cref{eq1,eq2,eq3,,eq4}|
% \end{quote}
% will be typeset as
% \begin{quote}
-% Eqs.~(1)--(3), and (4)
+% eqs.~(1)--(3) and (4)
% \end{quote}
% or
% \begin{quote}
@@ -328,10 +344,10 @@
% \end{quote}
% will be typeset as
% \begin{quote}
-% Eqs.~(1), (2), (3)--(5), and (6)--(7)
+% eqs.~(1), (2), (3)--(5) and (6)--(7)
% \end{quote}
-% You can safely put an empty references between references that would
-% never be collapsed anyway; they will simply be ignored.
+% You can safely put an empty reference between references that would
+% never be collapsed anyway; it will simply be ignored.
%
% \DescribeMacro{\cref*}
% \DescribeMacro{\Cref*}
@@ -345,17 +361,22 @@
% but without creating hyper-links.
%
%
-% \subsection{Customising the Reference Formats}
+% \section{Customising the Reference Format}
% \label{sec:customising}
-%
-% \subsubsection{Single References}
-% \label{sec:ref_format}
% 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 reference types. But if you
-% don't like them, or are writing in a different language, or you are
-% using an environment for which no default format is defined, you
-% will need to define your own.
+% documents are provided for the standard reference 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 used 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
@@ -364,54 +385,234 @@
% {\bf ??}~|\ref{|\meta{label}|}|
% \end{quote}
% i.e.\ it will typeset the reference as the label counter preceded by
-% a double question mark. References to undefined labels still produce
-% a ``reference undefined'' warning and are typeset as a double
-% question mark, as usual.
+% 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}
+% \label{sec:global_customisation}
+% \DescribeMacro\crefdefaultlabelformat
+% The label format can be customised globally using
+% \begin{quote}
+% |\crefdefaultlabelformat{|\meta{format}|}|
+% \end{quote}
+% The \meta{format} argument can be any valid \LaTeX{} code, though
+% you will need to |\protect| fragile commands. It can (and almost
+% certainly 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:other_packages}.)
+%
+% \DescribeMacro\crefrangeconjunction
+% The conjunction used in a reference range can be customised by
+% redefining |\crefrangeconjunction|:
+% \begin{quote}
+% |\renewcommand{\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{eq1}{eq2}| is typeset as
+% \begin{quote}
+% |eqs.~\ref{eq1}\crefrangeconjunction\ref{eq2}|
+% \end{quote}
+% (assuming the default equation name hasn't been customised). So you
+% may or may not want to include surrounding space, depending on the
+% formatting you desire. For example,
+% \begin{quote}
+% |\renewcommand{\crefrangeconjunction}{ and~}|
+% \end{quote}
+% does require surrounding space, whereas
+% \begin{quote}
+% |\renewcommand{\crefrangeconjunction}{--}|
+% \end{quote}
+% does not.
+%
+% \DescribeMacro\crefpairconjunction
+% \DescribeMacro\crefmiddleconjunction
+% \DescribeMacro\creflastconjunction
+% The conjunctions used in lists of references can be customised by
+% redefining |\crefpairconjunction|, |\crefmiddleconjunction| and
+% |\creflastconjunction|:
+% \begin{quote}
+% |\renewcommand{\crefpairconjunction}{|\meta{conjunction}|}|\\
+% |\renewcommand{\crefmiddleconjunction}{|\meta{conjunction}|}|\\
+% |\renewcommand{\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
+% |\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
+% |\crefrangeconjunction|. For example, the default definition of
+% |\crefmiddleconjunction| is:
+% \begin{quote}
+% |\renewcommand{\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 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|,
+% |\crefmiddlegroupconjunction| and |\creflastgroupconjunction|.
%
+% For example, if |eq*|, |thm*| and |fig*| are respectively equation,
+% theorem and figure labels,
+% \begin{quote}
+% |\cref{eq1,eq2,eq3,thm1,thm2,fig1,thm3}|
+% \end{quote}
+% is typeset as
+% \begin{quote}
+% eqs.~(1)|\crefrangeconjunction|(3)|\crefmiddlegroupconjunction|%\\
+% theorems~1|\crefpairconjunction|2|\crefmiddlegroupconjunction|%\\
+% fig.~1|\creflastgroupconjunction|Theorem~3
+% \end{quote}
+%
+%
+% \subsection{Customising Individual Reference Types}
+% \DescribeMacro\creflabelformat
+% \DescribeMacro\crefname
+% \DescribeMacro\Crefname
+% The reference name for a given 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}|}|
+% \end{quote}
+% used by the |\cref| and |\Cref| commands, respectively. You must
+% supply both \meta{singular} and \meta{plural} forms of the name. If
+% the corresponding |\Crefname| is undefined when |\crefname| is
+% called, it will define |\Crefname| to be a capitalised version of
+% |\crefname|, using |\MakeUppercase|. Conversely, if the
+% corresponding |\crefname| is undefined when |\Crefname| is called,
+% it will define |\Crefname| to be a lower-case version of
+% |\Crefname|, using |\MakeLowercase|. Obviously, this will only work
+% properly if the names begin with a letter. If the first letter is a
+% special character construct, such as an accented character, you will
+% need to surround it by braces. If the first thing in the name is
+% \emph{not} a letter at all (e.g.\ if it is a \LaTeX{} command), you
+% \emph{must} define both capitalisation variants
+% 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
+% exception is 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.
+%
+% 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
+% \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.
+%
+% \DescribeMacro\crefrangelabelformat
+% Normally, the start and end references in a reference range are
+% typeset using 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
+% \begin{quote}
+% |\crefrangelabelformat{|\meta{type}|}{|\meta{format}|}|
+% \end{quote}
+% The \meta{format} argument should contain six arguments: |#1|, |#2|,
+% |#3|, |#4|, |#5|, |#6|. The first two (|#1| and |#2|) are the
+% formatted versions of the start and end label counters. 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:
+% \begin{quote}
+% |\crefrangelabelformat{equation}{(#3#1#4)--(#5#2#6)}|
+% \end{quote}
+%
+%
+%
+% \subsection{Taking Full Control}
+% If you need more precise control over the 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 be constructed from components as usual.
+%
+% \subsubsection{Single References}
+% \label{sec:ref_format}
% \DescribeMacro\crefformat
% \DescribeMacro\Crefformat
% Reference formats for \emph{single} references are defined or
-% redefined using the |\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:
+% 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:
% \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
+% theorem-like environments when \package{ntheorem} is loaded, in
+% which case it is the environment name.
%
-% If the corresponding |\Crefformat| is undefined when |\crefformat|
-% is called, it will define the |\Crefformat| to produce a capitalised
+% As in the case of the |\crefname| and |\Crefname| commands, if the
+% corresponding |\Crefformat| is undefined when |\crefformat| is
+% called, it will define the |\Crefformat| to produce a capitalised
% version of |\crefformat|, using |\MakeUppercase|. Conversely, if the
% corresponding |\crefformat| is undefined whe |\Crefformat| is
% called, if will define the |\Crefformat| to produce a lower-case
-% version of |\Crefformat|, using |\MakeLowercase|. Obviously, this
-% will only work properly if the formats have a letter at the
-% start. If the first letter is a special construct, such as an
-% accented character, you will need to surround everything whose case
-% should be changed by braces. If the first thing in the format is not
-% a letter (e.g.\ if it is a \LaTeX{} command, or a hyper-link
-% argument, see below), 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
-% exception is theorem-like environments when the \package{ntheorem}
-% package is loaded, for which \meta{type} should instead be the
-% environment name (lemma, corollary, definition, etc.). This is
-% because \package{ntheorem} allows different theorem-like
-% environments to use a common counter.
+% version of |\Crefformat|, using |\MakeLowercase|. This will only
+% work if the format starts with a letter, and the same comments apply
+% as in the case of |\crefname| (see \cref{sec:global_customisation}).
%
% The \meta{format} argument can be any valid \LaTeX{} code, though
-% you will need to |\protect| fragile commands. It can (and almost
-% certainly 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 will mean that no hyper-link will be created
-% when \package{hyperref} is used.
+% you 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}).
%
% As an example,
% \begin{quote}
@@ -421,11 +622,15 @@
% \begin{quote}
% Eq.~(\meta{counter})
% \end{quote}
-% with the counter (excluding the brackets) forming the hyper-links.
-% Note that the hyper-link arguments are \emph{not} letters, so if you
-% want to make the ``Eq.'' part of the hyper-link by putting |#2| at
-% the start of the formatting code, you will have to define both
-% capitalisation variants independently:
+% with the counter (excluding the brackets) forming the hyper-link.
+%
+% Note that the hyper-link arguments are \emph{not} letters, so if
+% |#2| appears at the beginning of \meta{format}, \package{cleveref}
+% will not be able to automatically define the other capitalisation
+% variant automatically using |\MakeUppercase| or |\MakeLowercase|. In
+% this case, you will have to define both variants separately. For
+% example, if you wanted to the ``Eq.'' to be part of the hyper-link,
+% you would have to define:
% \begin{quote}
% |\crefformat{equation}{#2eq.~(#1)#3}|\\
% |\Crefformat{equation}{#2Eq.~(#1)#3}|
@@ -437,22 +642,18 @@
% \DescribeMacro\crefrangeformat
% \DescribeMacro\Crefrangeformat
% The format for reference ranges is defined by |\crefrangeformat|
-% and\linebreak[4] |\Crefrangeformat|. You do not have to define it if
-% you don't plan to use any reference ranges, i.e. you never use the
-% |\crefrange| and |\Crefrange| commands, and you never use multiple
-% references (see \cref{sec:multiple_ref_format}). However, you will
-% get ``reference format undefined'' errors if you later change your
-% mind and forget to define the format. Like |\creformat| and
+% and\linebreak[4] |\Crefrangeformat|. Like |\creformat| and
% |\Crefformat|, the commands take two arguments: the reference type,
% and the formatting code.
% \begin{quote}
% |\crefrangeformat{|\meta{type}|}{|\meta{format}|}|\\
% |\Crefrangeformat{|\meta{type}|}{|\meta{format}|}|
% \end{quote}
-% The same comments apply: the \meta{type} is usually the name of the
-% counter, except for theorem-like environments, and if the
-% corresponding other-capitalisation variant is not already defined,
-% it will be defined automatically.
+% 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 \meta{format} argument can again be any valid \LaTeX{} code,
% with fragile commands |\protect|ed. However, this time it should
@@ -465,11 +666,11 @@
%
% As an example,
% \begin{quote}
-% |\crefrangeformat{equation}{Eqs.~(#3#1#4)--(#5#2#6)}|
+% |\crefrangeformat{equation}{eqs.~(#3#1#4)--(#5#2#6)}|
% \end{quote}
% will typeset equation reference ranges as
% \begin{quote}
-% Eqs.~(\meta{counter1})--(\meta{counter2})
+% eqs.~(\meta{counter1})--(\meta{counter2})
% \end{quote}
% with the counters (excluding the brackets) forming the hyper-links.
%
@@ -483,78 +684,109 @@
% 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|. If you don't use any multiple references
-% for a particular reference type, you are not obliged to define the
-% multi-formats. However, you will get ``reference format undefined''
-% errors if you later decide to use a multiple reference without
-% ensuring the multi-formats are defined. You will also need to define
-% \emph{all} the other reference formats (see
-% \cref{sec:ref_format,sec:ref_range_format}), including the reference
-% range formats, even if you never use the |\crefrange| 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
+% reference range formats, even if you never use the |\crefrange| and
% |\Crefrange| commands.
%
-% The commands all take four arguments: the reference type, the format
-% for the first reference in a list, the format for the middle
-% references in a list, and the format for the last reference in a
-% list.
+% 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.
% \begin{quote}
-% |\crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{middle}|}{|\meta{last}|}|\\
-% |\Crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{middle}|}{|\meta{last}|}|\\
-% |\crefrangemultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{middle}|}{|\meta{last}|}|\\
-% |\Crefrangemultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{middle}|}{|\meta{last}|}|
+% |\crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|\\
+% |\Crefmultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|\\
+% |\crefrangemultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|\\
+% |\Crefrangemultiformat{|\meta{type}|}{|\meta{first}|}{|\meta{second}|}{|\meta{middle}|}{|\meta{last}|}|
% \end{quote}
%
-% The same considerations apply to the \meta{type} and formatting
-% arguments \meta{first}, \meta{middle} and \meta{last} as for the
-% \meta{format} argument of |\crefformat| and |\Crefformat| or
-% |\crefrangeformat| and |\Crefrangeformat|, including the meaning of
-% the arguments that should appear in the formatting code. However,
-% when the corresponding other-capitalisation variant is automatically
-% defined, only the first letter of the \meta{first} argument is
-% upper- or lower-cased.
+% 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 |\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 lower-cased;
+% the other arguments are defined to be identical for both variants.
%
% Be careful to get the spaces at the beginning and end of the
-% formatting code correct: the \meta{first}, \meta{middle} and
-% \meta{last} \LaTeX{} code is typeset 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, with the
-% default format
+% formatting code correct: the \meta{first} and {|\meta{second}|}, or
+% \meta{first}, \meta{middle} and \meta{last}, \LaTeX{} code is
+% typeset 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
% \begin{quote}
% |\crefmultiformat{equation}%|\\
-% |{Eqs.~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}|\\
+% |{eqs.~(#2#1#3)}{ and~(#2#1#3)}{, (#2#1#3)}{ and~(#2#1#3)}|
% \end{quote}
-% the \meta{middle} arguments should \emph{not} have a space at the
-% beginning, whereas the \meta{last} arguments \emph{should} have a
-% space.
-%
-% \DescribeMacro{\crefmiddleconjunction}
-% \DescribeMacro{\creflastconjunction}
-% The |\crefmiddleconjunction| and |\creflastconjunction| commands are
-% used in between sub-lists of different types of references that
-% occur in a multiple reference. If there are two or more reference
-% types in the list, |\creflastconjunction| is used between the
-% penultimate and final group of references, whereas
-% |\crefmiddleconjunction| is used between all others. You can
-% redefine them with |\renewcommand| in the usual way:
+% the \meta{middle} argument should \emph{not} have a space at the
+% beginning, whereas the \meta{second} and \meta{last} arguments
+% \emph{should} have a space.
+%
+%
+%
+% \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 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:
% \begin{quote}
-% |\renewcommand{\crefmiddleconjunction}{|\meta{conjunction}|}|\\
-% |\renewcommand{\creflastconjunction}{|\meta{conjunction}|}|
+% |\label[|\meta{type}|]{|\meta{label}|}|
% \end{quote}
-% For example, if |eq*|, |thm*| and |fig*| are respectively equation,
-% theorem and figure labels,
+%
+% 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:
% \begin{quote}
-% |\cref{eq1,eq2,eq3,thm1,thm2,fig1,thm3}|
+% |\crefname{pluralequation}{eqs.}{eqs.}|\\
+% \dots\\
+% |\label[pluralequation]{eq1}|
% \end{quote}
-% is typeset (assuming the default |\crefformat|s) as
+% You can of course reuse this format for other plural equations, too.
+%
+% If you need to do this frequently, it can become tedious specifying
+% the label explicitly each time. An alternative is to use the
+% \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 reference 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{Thanks to Anand Deopurkar for
+% suggesting this neat trick.}. For example,
% \begin{quote}
-% Eqs.~(1)--(3)|\crefmiddleconjunction| Theorems~1\\
-% and~2|\crefmiddleconjunction| Fig.~1|\creflastconjunction|
-% Theorem~3
+% |\usepackage{aliascnt}|\\
+% |\usepackage{cleveref}|\\
+% |\newaliascnt{lemma}{theorem}|\\
+% |\newtheorem{lemma}[lemma]{Lemma}|\\
+% |\aliascntresetthe{lemma}|\\
+% |\crefname{lemma}{lemma}{lemmas}|
% \end{quote}
%
%
-% \subsection{Poor Man's \package{cleveref}}
+%
+% \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
@@ -574,15 +806,17 @@
% 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 script to remove the \package{cleveref} dependency.
-%
-% The script is written to the same directory as the \LaTeX{} source
-% file, and given the same name as the 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:
+% the 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
+% \LaTeX{} source file, and given the same name as the 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:
% \begin{quote}
% sed -f \meta{name}\file{.sed} \
-% \meta{name}\file{.tex} > \meta{newname}\file{.tex}
+% \meta{name}\file{.tex} \textgreater \meta{newname}\file{.tex}
% \end{quote}
% where \meta{name} is the name of the file containing your \LaTeX{}
% source file minus the \file{.tex} extension, and \meta{newname} is
@@ -598,41 +832,34 @@
%
% \section{Interaction with Other Packages}
% \label{sec:other_packages}
-% Since \package{cleveref} redefines many internal commands involved
-% in \LaTeX{}'s referencing system, it can interact badly with other
-% packages that do the same. In general, \package{cleveref} should be
-% loaded \emph{last}, and the appropriate options must be supplied if
-% the \package{hyperref} and/or \package{ntheorem} packages are also
-% used. E.g.
+% The \package{cleveref} package \emph{must} be loaded \emph{after}
+% all other packages that don't specifically support it\footnote{At
+% the time of writing, I'm not aware of any that do.}, i.e.\ the
% \begin{quote}
-% |\usepackage{hyperref}|\\
-% |\usepackage[hyperref]{cleveref}|
-% \end{quote}
-% or
-% \begin{quote}
-% |\usepackage{ntheorem}|\\
-% |\usepackage[ntheorem]{cleveref}|
-% \end{quote}
-% or
-% \begin{quote}
-% |\usepackage{hyperref}|\\
-% |\usepackage[hyperref]{ntheorem}|\\
-% |\usepackage[hyperref,ntheorem]{cleveref}|
+% |\usepackage{cleveref}|
% \end{quote}
+% line should always be the last |\usepackage| command in your
+% document's preamble.
%
-% \package{varioref}'s enhanced referencing features (which 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 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:
+% 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}
-% Note that you can still use the other features of \package{varioref}
-% and \package{ntheorem} whilst using \package{cleveref}.
+% 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}.
%
% Other packages which alter the \LaTeX{} referencing system are
% unlikely to work properly with \package{cleveref}.
@@ -640,6 +867,7 @@
%
%
% \section{Known Bugs}
+% In no particular order.
% \begin{itemize}
% \item \package{cleveref} will not work properly with the standard
% \LaTeX{} |eqnarray| environment. The |eqnarray| environment is
@@ -649,6 +877,12 @@
% |align|, |multine| and |split|, which \emph{do} work properly with
% \package{cleveref}. (See
% \url{http://www.tug.org/pracjourn/2006-4/madsen/}).
+% \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
+% version.)
+% \item \package{cleveref} provides no \package{babel} support. (This
+% should be fixed in a future version.)
% \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
@@ -657,15 +891,28 @@
% 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 \package{cleveref} provides no \package{babel} support.
+% \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 \LaTeX{} cross-reference commands that are guaranteed to
+% work with any \LaTeX{} installation. Although it would be simple
+% to fix this bug, it's not obvious how best to do it without
+% compromising on the underlying philosophy.
% \end{itemize}
%
%
%
-% \section{Future Improvements}
+% \section{Possible Future 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?).
% \end{itemize}
%
%
@@ -675,26 +922,26 @@
%
%
% \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 an \cmd{\cref} command which uses this
-% extra information to typeset the reference.
+% the aux file, and defining \cmd{\cref} commands which use this extra
+% information to typeset the reference.
%
% The least invasive implementation 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 contains the additional information (in fact, we write
-% three extra pieces of information: the type, the counter value
+% 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
+% 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 required package).
+% to, given that \package{varioref} is a \texttt{required} \LaTeX{}
+% package).
%
%
% \subsection{Redefinitions of \LaTeX{} kernel macros}
@@ -723,6 +970,52 @@
\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 till the
+% beginning of the document because other packages do, and we need to
+% override their redefinitions.
+% \begin{macrocode}
+\AtBeginDocument{%
+ \let\old@label\label
+ \def\label{\@ifnextchar[\label@optarg\old@label}%]
+ \def\override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
+ \def\label@optarg[#1]{%
+ \protected@edef\@currentlabel{%
+ \expandafter\override@label@type\@currentlabel\@nil{#1}}%
+ \old@label}%
+% \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 \{\}. These are stripped
+% away again by \cmd{\ltx@label} before calling the \cmd{\label} macro
+% we defined above (save in \cmd{\cref@label}.
+% \begin{macrocode}
+ \@ifpackageloaded{amsmath}{%
+ \let\cref@label\label%
+ \let\old@label@in@display\label@in@display%
+ \def\label@in@display{%
+ \@ifnextchar[\label@in@display@optarg\label@in@display@noarg}%]
+ \def\label@in@display@noarg#1{\old@label@in@display{{#1}}}
+ \def\label@in@display@optarg[#1]#2{\old@label@in@display{[#1]{#2}}}
+ \def\ltx@label#1{\cref@label#1}%
+ }{}%
+}
+% \end{macrocode}
%
% The standard \cmd{\ref} macro spits out whatever was in
% \cmd{\@currentlabel} when the label was written to the aux file, but
@@ -734,7 +1027,7 @@
% loaded. For some reason, \cmd{\DeclareRobustCommand} doesn't work
% here, so we make it robust manually.
% \begin{macrocode}
-\def\cref@label#1#2{\@result}
+\def\cref@reflabel#1#2{\@result}
\AtBeginDocument{%
\expandafter\def\csname ref \endcsname#1{%
\expandafter\ifx\csname r@#1\endcsname\relax%
@@ -742,25 +1035,25 @@
\else%
\cref@getlabel{#1}{\@result}%
\fi%
- \expandafter\@setref\csname r@#1\endcsname{\cref@label}{#1}}%
- \def\ref{\expandafter\protect\csname ref \endcsname}
+ \expandafter\@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
+ \def\ref{\expandafter\protect\csname ref \endcsname}%
}
% \end{macrocode}
%
% \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 macro \emph{will} then be fully
-% expandable, and can be used e.g.\ inside an \cmd{\edef} or
+% 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{%
@@ -793,7 +1086,14 @@
\def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
% \end{macrocode}
%
-% We treate multiple references, supplied as a comma-separated list to
+% A basic utility macro for appending tokens to a token register.
+% \begin{macrocode}
+\def\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).
@@ -812,8 +1112,7 @@
\def\isstackempty#1{%
\def\@tmpa{\@nil}%
\ifx#1\@tmpa\stackemptytrue%
- \else\stackemptyfalse\fi
-}
+ \else\stackemptyfalse\fi}
\def\isstackfull#1{%
\def\@tmpa{\@nil}%
\ifx#1\@tmpa\stackfullfalse%
@@ -919,9 +1218,12 @@
\countdef\count@consecutive=0%
\def\@empty{}%
\newif\if@firstgroup%
+ \newif\if@secondgroup%
+ \newif\if@secondref%
\stack@init{\@refstack}%
\stack@push{#2}{\@refstack}%
\@firstgrouptrue%
+ \@secondgroupfalse%
\isstackfull{\@refstack}%
% \end{macrocode}
% Loop until the reference stack is empty.
@@ -964,15 +1266,21 @@
% Typeset appropriate conjunction between groups of reference types.
% \begin{macrocode}
\if@firstgroup%
+ \@firstgroupfalse%
+ \@secondgrouptrue%
\else%
\isstackfull{\@refstack}%
\ifstackfull%
- \@setcref@middleconjunction%
+ \@setcref@middlegroupconjunction%
\else%
- \@setcref@lastconjunction%
+ \if@secondgroup%
+ \@setcref@pairgroupconjunction%
+ \else%
+ \@setcref@lastgroupconjunction%
+ \fi%
\fi%
+ \@secondgroupfalse%
\fi%
- \@firstgroupfalse%
% \end{macrocode}
%
% Process first group of consecutive references from substack.
@@ -1019,7 +1327,7 @@
% \end{macrocode}
% Otherwise, test whether next reference is consecutive or not.
% \begin{macrocode}
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -1057,7 +1365,7 @@
% \end{macrocode}
% otherwise, test whether next reference is consecutive or not.
% \begin{macrocode}
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -1083,7 +1391,7 @@
% \end{macrocode}
% otherwise, typeset a reference range.
% \begin{macrocode}
- \else
+ \else%
\edef\@tmpa{{\@beginref}{\@endref}}%
\ifstackempty%
\expandafter\@setcrefrange\@tmpa{#1}{}%
@@ -1097,6 +1405,7 @@
% Process further groups of consecutive references, until substack
% is empty.
% \begin{macrocode}
+ \@secondreftrue%
\isstackfull{\@refsubstack}%
\@whilesw\ifstackfull\fi{%
\edef\@beginref{\stack@top{\@refsubstack}}%
@@ -1107,7 +1416,11 @@
% \begin{macrocode}
\isstackempty{\@refsubstack}%
\ifstackempty%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
+ \if@secondref%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@second}%
+ \else%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
+ \fi%
% \end{macrocode}
% otherwise, find end of consecutive references.
% \begin{macrocode}
@@ -1134,7 +1447,7 @@
% \end{macrocode}
% otherwise, test whether next reference is consecutive or not.
% \begin{macrocode}
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -1171,7 +1484,7 @@
% \end{macrocode}
% otherwise, test whether next reference is consecutive or not.
% \begin{macrocode}
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -1187,7 +1500,11 @@
% \begin{macrocode}
\isstackempty{\@refsubstack}%
\ifstackempty%
- \def\@pos{@last}%
+ \if@secondref%
+ \def\@pos{@second}%
+ \else%
+ \def\@pos{@last}%
+ \fi%
\else%
\def\@pos{@middle}%
\fi%
@@ -1211,12 +1528,13 @@
% \end{macrocode}
% otherwise, typeset a reference range.
% \begin{macrocode}
- \else
+ \else%
\edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
\expandafter\@setcrefrange\@tmpa%
\fi%
\fi%
\fi%
+ \@secondreffalse%
\isstackfull{\@refsubstack}%
}% end loop over reference substack
\fi%
@@ -1287,7 +1605,7 @@
% \end{macrocode}
%
% The internal \cmd{\@setcrefrange} macro deals with typesetting
-% reference ranges, just as \cmd{\setcref} does for normal
+% 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
@@ -1332,7 +1650,7 @@
\expandafter\ifx\@formata\relax%
\protect\G@refundefinedtrue%
\nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb%
- \@latex@warning{#3 \space reference format for label
+ \@latex@warning{#3\space reference range format for label
type `\@typea' undefined}%
\else%
% \end{macrocode}
@@ -1369,18 +1687,370 @@
% The typesetting of conjunctions is also separated out into separate
% macros, for the same reason.
% \begin{macrocode}
-\def\@setcref@middleconjunction{\crefmiddleconjunction}
-\def\@setcref@lastconjunction{\creflastconjunction}
+\def\@setcref@pairgroupconjunction{\crefpairgroupconjunction}
+\def\@setcref@middlegroupconjunction{\crefmiddlegroupconjunction}
+\def\@setcref@lastgroupconjunction{\creflastgroupconjunction}
% \end{macrocode}
%
%
%
% \subsection{Reference Format Customisation Commands}
-% \cmd{\crefformat} et al.\ are user-level commands used to define the
-% format of different reference types. They simply use the supplied
-% argument(s) to define appropriately named formatting macro(s), which
-% are called by \cmd{\@setcref}. The only moderately interesting part
-% is that if the corresponding \cmd{\Crefformat} or \cmd{\crefformat}
+%
+% \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{macrocode}
+\newcommand{\crefdefaultlabelformat}[1]{%
+ \def\cref@default@label##1##2##3{#1}}
+\newcommand{\crefname}[3]{%
+ \@crefname{cref}{#1}{#2}{#3}%
+ \@crefdefineallformats{#1}}
+\newcommand{\Crefname}[3]{%
+ \@crefname{Cref}{#1}{#2}{#3}%
+ \@crefdefineallformats{#1}}
+\newcommand{\creflabelformat}[2]{%
+ \@creflabelformat{#1}{#2}%
+ \@crefdefineallformats{#1}}
+\newcommand{\crefrangelabelformat}[2]{%
+ \@crefrangelabelformat{#1}{#2}%
+ \@crefdefineallformats{#1}}
+\def\@creflabelformat#1#2{%
+ \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}}
+\def\@crefrangelabelformat#1#2{%
+ \expandafter\def\csname cref@#1@rangelabel\endcsname%
+ ##1##2##3##4##5##6{#2}}
+% \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.
+% \begin{macrocode}
+\def\@crefname#1#2#3#4{%
+ \expandafter\def\csname #1@#2@name\endcsname{#3}%
+ \expandafter\def\csname #1@#2@name@plural\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 order to wrap the capitalisation-dependent parts in
+% macros so that the rest of the code can be capitalisation-variant
+% agnostic.
+% \begin{macrocode}
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
+ \@tmpa#1\@nil%
+% \end{macrocode}
+% If the other capitalisation variant is not already defined...
+% \begin{macrocode}
+ \@ifundefined{\@other @#2@name}{%
+% \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 defined above. The \cmd{\@toska} token register just
+% makes the code less verbose.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpb%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2@name@plural\endcsname}%
+% \end{macrocode}
+% Add the \cmd{\@changecase} command to the front of the definitions of
+% \cmd{\@tmpa} and \cmd{\}tmpb}.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpb%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpb}%
+% \end{macrocode}
+% Define the other capitalisation variants to be the partial expansions
+% (expanded just once) of \cmd{\@tmpa} and \cmd{\@tmpb}.
+% \begin{macrocode}
+ \newtoks\@toksa%
+ \@toksa={%
+ \expandafter\def\csname\@other @#2@name\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpa}%
+ \@toksa={%
+ \expandafter\def\csname\@other @#2@name@plural\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpb}%
+ }{}%
+}
+% \end{macrocode}
+%
+%
+% \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{macrocode}
+\def\@crefconstructcomponents#1{%
+ \@ifundefined{cref@#1@label}{%
+ \let\@tmplabel\cref@default@label%
+ }{%
+ \expandafter\let\expandafter\@tmplabel%
+ \csname cref@#1@label\endcsname%
+ }%
+ \@ifundefined{cref@#1@rangelabel}{%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \@tmplabel{####1}{####3}{####4}}%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \@tmplabel{####2}{####5}{####6}}%
+ \@toksa={\def\@tmprangelabel##1##2##3##4##5##6}%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\crefrangeconjunction\@tmpb}%
+ }{%
+ \expandafter\let\expandafter\@tmprangelabel%
+ \csname cref@#1@rangelabel\endcsname%
+ }%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpname%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@#1@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpName%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@#1@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpnameplural%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@#1@name@plural\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpNameplural%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@#1@name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmplabel\expandafter{%
+ \@tmplabel{########1}{########2}{########3}}%
+ \expandafter\def\expandafter\@tmprangelabel\expandafter{%
+ \@tmprangelabel{########1}{########2}{########3}%
+ {########4}{########5}{########6}}%
+}
+% \end{macrocode}
+%
+% 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{%
+ \newtoks\@toksa%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+% \end{macrocode}
+% Assemble the arguments for \cmd{\crefformat} and \cmd{\Crefformat}
+% from the components.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpname\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpName\expandafter~\@tmplabel}%
+% \end{macrocode}
+% Define \cmd{\crefformat} and \cmd{\Crefformat}.
+% \begin{macrocode}
+ \@toksa={\crefformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
+ \@toksa={\Crefformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
+}
+%
+\def\@crefrangedefineformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+% \end{macrocode}
+% Assemble the arguments for \cmd{\crefrangeformat} and
+% \cmd{\Crefrangeformat} from the components.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
+% \end{macrocode}
+% Define \cmd{\crefrangeformat} and \cmd{\Crefrangeformat}.
+% \begin{macrocode}
+ \@toksa={\crefrangeformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
+ \@toksa={\Crefrangeformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
+}
+%
+\def\@crefdefinemultiformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+% \end{macrocode}
+% Assemble the arguments for \cmd{\crefmultiformat} and
+% \cmd{\Crefmultiformat} from the components.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpsecond%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefpairconjunction\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpmiddle%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefmiddleconjunction\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmplast%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\creflastconjunction\@tmplabel}%
+% \end{macrocode}
+% Bundle all four arguments for \cmd{\crefmultiformat} in token
+% register \cmd{\@toksb}, then call it.
+% \begin{macrocode}
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpfirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+% \end{macrocode}
+% Bundle all four arguments for \cmd{\Crefmultiformat} in token
+% register \cmd{\@toksb}, then call it.
+% \begin{macrocode}
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpFirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\Crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+}
+%
+\def\@crefrangedefinemultiformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+% \end{macrocode}
+% Assemble the arguments that need to be passed to
+% \cmd{\crefrangemultiformat} and \cmd{\Crefrangemultiformat} from the
+% reference components.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpsecond%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefpairconjunction\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpmiddle%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefmiddleconjunction\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmplast%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\creflastconjunction\@tmprangelabel}%
+% \end{macrocode}
+% Bundle all four arguments for \cmd{\crefrangemultiformat} in token
+% register \cmd{\@toksb}, then call it.
+% \begin{macrocode}
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpfirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+% \end{macrocode}
+% Bundle all four arguments for \cmd{\Crefrangemultiformat} in token
+% register \cmd{\@toksb}, then call it.
+% \begin{macrocode}
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpFirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\Crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+}
+% \end{macrocode}
+%
+% \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}%
+ \@crefrangedefineformat{#1}%
+ \@crefdefinemultiformat{#1}%
+ \@crefrangedefinemultiformat{#1}}
+% \end{macrocode}
+%
+%
+% \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{macrocode}
@@ -1388,44 +2058,66 @@
\newcommand{\Crefformat}[2]{\@crefformat{Cref}{#1}{#2}}
\newcommand{\crefrangeformat}[2]{\@crefrangeformat{crefrange}{#1}{#2}}
\newcommand{\Crefrangeformat}[2]{\@crefrangeformat{Crefrange}{#1}{#2}}
-\newcommand{\crefmultiformat}[4]{%
- \@crefmultiformat{cref}{#1}{#2}{#3}{#4}}
-\newcommand{\Crefmultiformat}[4]{%
- \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}}
-\newcommand{\crefrangemultiformat}[4]{%
- \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}}
-\newcommand{\Crefrangemultiformat}[4]{%
- \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}}
+\newcommand{\crefmultiformat}[5]{%
+ \@crefmultiformat{cref}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\Crefmultiformat}[5]{%
+ \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\crefrangemultiformat}[5]{%
+ \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\Crefrangemultiformat}[5]{%
+ \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}{#5}}
% \end{macrocode}
+%
% The utility macros do the real work, by using the first argument
-% (``cref'', ``Cref'', ``crefrange'' or ``Crefrange'') to determine
-% how to define the corresponding command with the other
+% (``cref'' or ``Cref'', and ``crefrange'' or ``Crefrange'') to
+% determine how to define the corresponding command with the other
% capitalisation.
% \begin{macrocode}
\def\@crefformat#1#2#3{%
\expandafter\def\csname #1@#2@format\endcsname##1##2##3{#3}%
% \end{macrocode}
-% Note that these \cmd{\@tmpa} macros makes use of the fact that the
-% first character of \#1 is ``c'' for lower-case, ``C'' for
-% upper-case.
+% 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 order to wrap the capitalisation-dependent parts in
+% macros so that the rest of the code can be capitalisation-variant
+% agnostic.
% \begin{macrocode}
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
+% \end{macrocode}
+% If the other capitalisation variant is not already defined...
+% \begin{macrocode}
\@ifundefined{\@other @#2@format}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
+% \end{macrocode}
+% Define \cmd{\@tmpa} to be a partial expansion (expanded just once)
+% of the capitalisation variant we've just defined above. The
+% \cmd{\@toska} token register just makes the code less verbose.
+% \begin{macrocode}
\newtoks\@toksa%
\@toksa={\def\@tmpa##1##2##3}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format\endcsname{##1}{##2}{##3}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}%
+% \end{macrocode}
+% Add the \cmd{\@changecase} command to the front of the definition of
+% \cmd{\@tmpa}.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
+% \end{macrocode}
+% Define the other capitalisation variant to be the partial expansion
+% (expanded just once) of \cmd{\@tmpa}.
+% \begin{macrocode}
\@toksa={%
\expandafter\def\csname\@other @#2@format\endcsname##1##2##3}%
\expandafter\the\expandafter\@toksa\expandafter{%
@@ -1437,27 +2129,48 @@
\expandafter\def\csname #1@#2@format\endcsname%
##1##2##3##4##5##6{#3}%
% \end{macrocode}
-% Note that these \cmd{\@tmpa} macros make use of the fact that the
-% first character of \#1 is ``c'' for lower-case, ``C'' for
-% upper-case.
+% 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 order to wrap the capitalisation-dependent parts in
+% macros so that the rest of the code can be capitalisation-variant
+% agnostic.
% \begin{macrocode}
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
+% \end{macrocode}
+% If the other capitalisation variant is not already defined...
+% \begin{macrocode}
\@ifundefined{\@other @#2@format}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
+% \end{macrocode}
+% Define \cmd{\@tmpa} to be a partial expansion (expanded just once)
+% of the capitalisation variant we've just defined above. The
+% \cmd{\@toska} token register just makes the code less verbose.
+% \begin{macrocode}
\newtoks\@toksa%
\@toksa={\def\@tmpa##1##2##3##4##5##6}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format\endcsname{##1}{##2}{##3}{##4}{##5}{##6}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}
+% \end{macrocode}
+% Add the \cmd{\@changecase} command to the front of the definition of
+% \cmd{\@tmpa}.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
+% \end{macrocode}
+% Define the other capitalisation variant to be the partial expansion
+% (expanded just once) of \cmd{\@tmpa}.
+% \begin{macrocode}
\@toksa={\expandafter\def%
\csname\@other @#2@format\endcsname##1##2##3##4##5##6}%
\expandafter\the\expandafter\@toksa\expandafter{%
@@ -1465,38 +2178,70 @@
}{}%
}
%
-\def\@crefmultiformat#1#2#3#4#5{%
+\def\@crefmultiformat#1#2#3#4#5#6{%
\expandafter\def\csname #1@#2@format@first\endcsname##1##2##3{#3}%
- \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#4}%
- \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#5}%
+ \expandafter\def\csname #1@#2@format@second\endcsname##1##2##3{#4}%
+ \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#5}%
+ \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#6}%
% \end{macrocode}
-% Note that these \cmd{\@tmpa} macros make use of the fact that the
-% first character of \#1 is ``c'' for lower-case, ``C'' for
-% upper-case.
+% 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 order to wrap the capitalisation-dependent parts in
+% macros so that the rest of the code can be capitalisation-variant
+% agnostic.
% \begin{macrocode}
- \newtoks\@toksa%
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
+% \end{macrocode}
+% If the other capitalisation variant of the first part of the
+% multi-format definition is not already defined...
+% \begin{macrocode}
\@ifundefined{\@other @#2@format@first}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
+% \end{macrocode}
+% Define \cmd{\@tmpa} to be a partial expansion (expanded just once)
+% of the capitalisation variant we've just defined above. The
+% \cmd{\@toska} token register just makes the code less verbose.
+% \begin{macrocode}
\@toksa={\def\@tmpa##1##2##3}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format@first\endcsname{##1}{##2}{##3}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}%
+% \end{macrocode}
+% Add the \cmd{\@changecase} command to the front of the definition of
+% \cmd{\@tmpa}.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
+% \end{macrocode}
+% Define the other capitalisation variant to be the partial expansion
+% (expanded just once) of \cmd{\@tmpa}.
+% \begin{macrocode}
\@toksa={%
\expandafter\def\csname\@other @#2@format@first\endcsname%
##1##2##3}%
\expandafter\the\expandafter\@toksa\expandafter{%
\@tmpa{##1}{##2}{##3}}%
- }{}
+ }{}%
+% \end{macrocode}
+% The other parts of the multi-format definition are defined to be
+% identical for both capitalisation variants.
+% \begin{macrocode}
+ \@ifundefined{\@other @#2@format@second}{%
+ \@toksa={%
+ \expandafter\let\csname\@other @#2@format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2@format@second\endcsname%
+ }{}%
\@ifundefined{\@other @#2@format@middle}{%
\@toksa={%
\expandafter\let\csname\@other @#2@format@middle\endcsname}%
@@ -1511,41 +2256,75 @@
}{}%
}
%
-\def\@crefrangemultiformat#1#2#3#4#5{%
+\def\@crefrangemultiformat#1#2#3#4#5#6{%
\expandafter\def\csname #1@#2@format@first\endcsname%
##1##2##3##4##5##6{#3}%
- \expandafter\def\csname #1@#2@format@middle\endcsname%
+ \expandafter\def\csname #1@#2@format@second\endcsname%
##1##2##3##4##5##6{#4}%
- \expandafter\def\csname #1@#2@format@last\endcsname%
+ \expandafter\def\csname #1@#2@format@middle\endcsname%
##1##2##3##4##5##6{#5}%
+ \expandafter\def\csname #1@#2@format@last\endcsname%
+ ##1##2##3##4##5##6{#6}%
% \end{macrocode}
-% Note that these \cmd{\@tmpa} macros make use of the fact that the
-% first character of \#1 is ``c'' for lower-case, ``C'' for
-% upper-case.
+% 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 order to wrap the capitalisation-dependent parts in
+% macros so that the rest of the code can be capitalisation-variant
+% agnostic.
% \begin{macrocode}
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
+% \end{macrocode}
+% If the other capitalisation variant of the first part of the
+% multi-format definition is not already defined...
+% \begin{macrocode}
\@ifundefined{\@other @#2@format@first}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\MakeLowercase}\fi}%
- \@tmpa#1\@nil%
+% \end{macrocode}
+% Define \cmd{\@tmpa} to be a partial expansion (expanded just once)
+% of the capitalisation variant we've just defined above. The
+% \cmd{\@toska} token register just makes the code less verbose.
+% \begin{macrocode}
\@toksa={\def\@tmpa##1##2##3##4##5##6}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format@first\endcsname%
{##1}{##2}{##3}{##4}{##5}{##6}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
+% \end{macrocode}
+% Add the \cmd{\@changecase} command to the front of the definition of
+% \cmd{\@tmpa}.
+% \begin{macrocode}
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
+% \end{macrocode}
+% Define the other capitalisation variant to be the partial expansion
+% (expanded just once) of \cmd{\@tmpa}.
+% \begin{macrocode}
\@toksa={%
\expandafter\def\csname\@other @#2@format@first\endcsname%
##1##2##3##4##5##6}%
\expandafter\the\expandafter\@toksa\expandafter{%
\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
}{}%
+% \end{macrocode}
+% The other parts of the multi-format definition are defined to be
+% identical for both capitalisation variants.
+% \begin{macrocode}
+ \@ifundefined{\@other @#2@format@second}{%
+ \@toksa={%
+ \expandafter\let\csname\@other @#2@format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2@format@second\endcsname%
+ }{}%
\@ifundefined{\@other @#2@format@middle}{%
\@toksa={%
\expandafter\let\csname\@other @#2@format@middle\endcsname}%
@@ -1563,229 +2342,237 @@
%
%
% \subsection{Default Reference Formats}
-% Define the default reference formats, appropriate for \LaTeX{}
-% documents written in English. 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.\\
-% To-Do: add babel support
-% \begin{macrocode}
-\crefformat{equation}{eq.~\textup{(#2#1#3)}}
-\Crefformat{equation}{Equation~\textup{(#2#1#3)}}
-\crefformat{chapter}{chapter~#2#1#3}
-\Crefformat{chapter}{Chapter~#2#1#3}
-\crefformat{section}{section~#2#1#3}
-\Crefformat{section}{Section~#2#1#3}
-\crefformat{subsection}{section~#2#1#3}
-\Crefformat{subsection}{Section~#2#1#3}
-\crefformat{subsubsection}{section~#2#1#3}
-\Crefformat{subsubsection}{Section~#2#1#3}
-\crefformat{subsubsubsection}{section~#2#1#3}
-\Crefformat{subsubsubsection}{Section~#2#1#3}
-\crefformat{figure}{fig.~#2#1#3}
-\Crefformat{figure}{Figure~#2#1#3}
-\crefformat{theorem}{theorem~#2#1#3}
-\Crefformat{theorem}{Theorem~#2#1#3}
-\crefformat{enumi}{item~#2#1#3}
-\Crefformat{enumi}{Item~#2#1#3}
-\crefformat{enumii}{item~#2#1#3}
-\Crefformat{enumii}{Item~#2#1#3}
-\crefformat{enumiii}{item~#2#1#3}
-\Crefformat{enumiii}{Item~#2#1#3}
-\crefformat{enumiv}{item~#2#1#3}
-\Crefformat{enumiv}{Item~#2#1#3}
-%
-\crefmultiformat{equation}%
- {eqs.~\textup{(#2#1#3)}}%
- {, \textup{(#2#1#3)}}%
- { and~\textup{(#2#1#3)}}
-\Crefmultiformat{equation}%
- {Equations~\textup{(#2#1#3)}}%
- {, \textup{(#2#1#3)}}%
- { and~\textup{(#2#1#3)}}
-\crefmultiformat{chapter}%
- {chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{chapter}%
- {Chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{section}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{section}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsubsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsubsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsubsubsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsubsubsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{figure}%
- {figs.~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{figure}%
- {Figures~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{theorem}%
- {theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{theorem}%
- {Theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumi}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumi}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumii}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumii}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumiii}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumiii}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumiv}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumiv}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-%
-\crefrangeformat{equation}{%
- eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\Crefrangeformat{equation}{%
- Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\crefrangeformat{chapter}{chapters~#3#1#4--#5#2#6}
-\Crefrangeformat{chapter}{Chapters~#3#1#4--#5#2#6}
-\crefrangeformat{section}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{section}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsubsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsubsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsubsubsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsubsubsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{figure}{figs.~#3#1#4--#5#2#6}
-\Crefrangeformat{figure}{Figures~#3#1#4--#5#2#6}
-\crefrangeformat{theorem}{theorems~#3#1#4--#5#2#6}
-\Crefrangeformat{theorem}{Theorems~#3#1#4--#5#2#6}
-\crefrangeformat{enumi}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumi}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumii}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumii}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumiii}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumiii}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumiv}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumiv}{Items~#3#1#4--#5#2#6}
-%
-\crefrangemultiformat{equation}%
- {eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\Crefrangemultiformat{equation}%
- {Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\crefrangemultiformat{chapter}%
- {chapters~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{chapter}%
- {Chapters~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{section}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{section}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsubsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsubsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsubsubsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsubsubsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{figure}%
- {figs.~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{figure}%
- {Figures~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{theorem}%
- {theorems~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{theorem}%
- {Theorems~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumi}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumi}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumii}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumii}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumiii}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumiii}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumiv}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumiv}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-%
-\def\crefmiddleconjunction{, }
-\def\creflastconjunction{, and }
+% 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.
+% \begin{macrocode}
+\newcommand{\crefrangeconjunction}{ to~}
+\newcommand{\crefpairconjunction}{ and~}
+\newcommand{\crefmiddleconjunction}{, }
+\newcommand{\creflastconjunction}{ and~}
+\crefdefaultlabelformat{#2#1#3}
+% \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{macrocode}
+\AtBeginDocument{%
+% \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}
+% 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.
+% \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@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@figure@format}{%
+ \@crefdefineformat{figure}}{}%
+ \@ifundefined{crefrange@figure@format}{%
+ \@crefrangedefineformat{figure}}{}%
+ \@ifundefined{cref@figure@format@first}{%
+ \@crefdefinemultiformat{figure}}{}%
+ \@ifundefined{crefrange@figure@format@first}{%
+ \@crefrangedefinemultiformat{figure}}{}%
+ \@ifundefined{cref@theorem@format}{%
+ \@crefdefineformat{theorem}}{}%
+ \@ifundefined{crefrange@theorem@format}{%
+ \@crefrangedefineformat{theorem}}{}%
+ \@ifundefined{cref@theorem@format@first}{%
+ \@crefdefinemultiformat{theorem}}{}%
+ \@ifundefined{crefrange@theorem@format@first}{%
+ \@crefrangedefinemultiformat{theorem}}{}%
+ \@ifundefined{cref@enumi@format}{%
+ \@crefdefineformat{enumi}}{}%
+ \@ifundefined{crefrange@enumi@format}{%
+ \@crefrangedefineformat{enumi}}{}%
+ \@ifundefined{cref@enumi@format@first}{%
+ \@crefdefinemultiformat{enumi}}{}%
+ \@ifundefined{crefrange@enumi@format@first}{%
+ \@crefrangedefinemultiformat{enumi}}{}%
+ \@ifundefined{cref@enumii@format}{%
+ \@crefdefineformat{enumii}}{}%
+ \@ifundefined{crefrange@enumii@format}{%
+ \@crefrangedefineformat{enumii}}{}%
+ \@ifundefined{cref@enumii@format@first}{%
+ \@crefdefinemultiformat{enumii}}{}%
+ \@ifundefined{crefrange@enumii@format@first}{%
+ \@crefrangedefinemultiformat{enumii}}{}%
+ \@ifundefined{cref@enumiii@format}{%
+ \@crefdefineformat{enumiii}}{}%
+ \@ifundefined{crefrange@enumiii@format}{%
+ \@crefrangedefineformat{enumiii}}{}%
+ \@ifundefined{cref@enumiii@format@first}{%
+ \@crefdefinemultiformat{enumiii}}{}%
+ \@ifundefined{crefrange@enumiii@format@first}{%
+ \@crefrangedefinemultiformat{enumiii}}{}%
+ \@ifundefined{cref@enumiv@format}{%
+ \@crefdefineformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \@crefrangedefineformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \@crefdefinemultiformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \@crefrangedefinemultiformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format}{%
+ \@crefdefineformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \@crefrangedefineformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \@crefdefinemultiformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \@crefrangedefinemultiformat{enumiv}}{}%
+}
% \end{macrocode}
%
%
% \subsection{\package{hyperref} Support}
-% \begin{macrocode}
-\DeclareOption{hyperref}{%
-\PackageInfo{cleveref}{option `hyperref' loaded}
+% 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}.
+% \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@label#1#2#3#4#5{\@result}
+\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{%
@@ -1793,15 +2580,15 @@
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getlabel\@tempa\@nil#2}
\def\cref@gettype#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@gettype\@tempa\@nil#2}
\def\cref@getcounter#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getcounter\@tempa\@nil#2}
\def\cref@getprefix#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getprefix\@tempa\@nil#2}
% \end{macrocode}
@@ -1853,15 +2640,17 @@
\DeclareRobustCommand{\Crefrange}{%
\@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}}
\def\@crefnostar#1#2{\@cref{#1}{#2}}
-\def\@crefstar#1#2{\@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse}
+\def\@crefstar#1#2{%
+ \@crefstarredtrue\@crefnostar{#1}{#2}\@crefstarredfalse}
\def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}}
\def\@crefrangestar#1#2#3{%
- \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse}
+ \@crefstarredtrue\@crefrangenostar{#1}{#2}{#3}\@crefstarredfalse}
% \end{macrocode}
%
-% Redefine \@@setcref and \@@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}.
+% 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}{\@templabel}%
@@ -1883,14 +2672,28 @@
{\hyper@linkstart{link}{\@linka}}{\hyper@linkend}%
{\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}%
\fi}
-} % end of hyperref option
+}{}
% \end{macrocode}
%
%
% \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{macrocode}
-\DeclareOption{ntheorem}{%
-\PackageInfo{cleveref}{option `ntheorem' loaded}
+\@ifpackageloaded{ntheorem}{%
+\PackageInfo{cleveref}{`ntheorem' support loaded}
+\@ifpackagewith{ntheorem}{thref}{%
+ \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref'
+ option}%
+ \renewcommand{\thref}{\cref}}{}
+% \end{macrocode}
+%
+% Newer versions of \package{ntheorem} require a call to
+% \cmd{\theorem@prework} when typesetting theorems. If an older
+% version of \package{ntheorem} if 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}{}
% \end{macrocode}
%
% We modify \package{ntheorem}'s version of the \cmd{\@thm} macro very
@@ -1898,100 +2701,83 @@
% argument containing the theorem type.
% \begin{macrocode}
\gdef\@thm#1#2#3{%
- \if@thmmarks
+ \if@thmmarks%
\stepcounter{end\InTheoType ctr}%
- \fi
+ \fi%
\renewcommand{\InTheoType}{#1}%
- \if@thmmarks
+ \if@thmmarks%
\stepcounter{curr#1ctr}%
\setcounter{end#1ctr}{0}%
- \fi
+ \fi%
\refstepcounter[#1]{#2}% <<<<<
- \thm@topsepadd \theorempostskipamount
- \ifvmode \advance\thm@topsepadd\partopsep\fi
- \trivlist
- \@topsep \theorempreskipamount
- \@topsepadd \thm@topsepadd
- \advance\linewidth -\theorem@indent
- \advance\@totalleftmargin \theorem@indent
- \parshape \@ne \@totalleftmargin \linewidth
+ \theorem@prework%
+ \thm@topsepadd \theorempostskipamount%
+ \ifvmode \advance\thm@topsepadd\partopsep\fi%
+ \trivlist%
+ \@topsep \theorempreskipamount%
+ \@topsepadd \thm@topsepadd%
+ \advance\linewidth -\theorem@indent%
+ \advance\@totalleftmargin \theorem@indent%
+ \parshape \@ne \@totalleftmargin \linewidth%
\@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}%]
}
% \end{macrocode}
%
% Default formats for new theorem-like environments defined by ntheorem.
% \begin{macrocode}
-\crefformat{lemma}{lemma~#2#1#3}
-\Crefformat{lemma}{Lemma~#2#1#3}
-\crefformat{corrollary}{corrollary~#2#1#3}
-\Crefformat{corrollary}{Corrollary~#2#1#3}
-\crefformat{proposition}{proposition~#2#1#3}
-\Crefformat{proposition}{Proposition~#2#1#3}
-\crefformat{definition}{definition~#2#1#3}
-\Crefformat{definition}{Definition~#2#1#3}
-\crefformat{result}{result~#2#1#3}
-\Crefformat{result}{Result~#2#1#3}
-\crefrangeformat{lemma}{lemma~#3#1#4--#5#2#6}
-\Crefrangeformat{lemma}{Lemma~#3#1#4--#5#2#6}
-\crefrangeformat{corrollary}{corrollary~#3#1#4--#5#2#6}
-\Crefrangeformat{corrollary}{Corrollary~#3#1#4--#5#2#6}
-\crefrangeformat{proposition}{proposition~#3#1#4--#5#2#6}
-\Crefrangeformat{proposition}{Proposition~#3#1#4--#5#2#6}
-\crefrangeformat{definition}{definition~#3#1#4--#5#2#6}
-\Crefrangeformat{definition}{Definition~#3#1#4--#5#2#6}
-\crefrangeformat{result}{result~#3#1#4--#5#2#6}
-\Crefrangeformat{result}{Result~#3#1#4--#5#2#6}
-\crefmultiformat{lemma}%
- {lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{lemma}%
- {Lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{corrollary}%
- {corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{corrollary}%
- {Corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{proposition}%
- {propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{proposition}%
- {Propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{definition}%
- {definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{definition}%
- {Definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{result}%
- {results~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{result}%
- {Results~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefrangemultiformat{lemma}%
- {lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}%
-\Crefrangemultiformat{lemma}%
- {Lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{corrollary}%
- {corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{corrollary}%
- {Corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{proposition}%
- {propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{proposition}%
- {Propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{definition}%
- {definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{definition}%
- {Definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{result}%
- {results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{result}%
- {Results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-} % end of ntheorem option
+\AtBeginDocument{%
+ \@ifundefined{cref@lemma@name}{%
+ \@crefname{cref}{lemma}{lemma}{lemmas}%
+ \@crefname{Cref}{lemma}{Lemma}{Lemmas}}{}%
+ \@ifundefined{cref@corollary@name}{%
+ \@crefname{cref}{corollary}{corollary}{corollaries}%
+ \@crefname{Cref}{corollary}{Corollary}{Corollaries}}{}%
+ \@ifundefined{cref@proposition@name}{%
+ \@crefname{cref}{proposition}{proposition}{propositions}%
+ \@crefname{Cref}{proposition}{Proposition}{Proposition}}{}%
+ \@ifundefined{cref@definition@name}{%
+ \@crefname{cref}{definition}{definition}{definitions}%
+ \@crefname{Cref}{definition}{Definition}{Definitions}}{}%
+ \@ifundefined{cref@result@name}{%
+ \@crefname{cref}{result}{result}{results}%
+ \@crefname{cref}{result}{Result}{Results}}{}%
+% \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}}{}%
+}%
+}{}
% \end{macrocode}
%
%
@@ -2024,7 +2810,7 @@
% Both \cmd{\DeclareOption} and \cmd{\AtEndDocument} store their
% arguments in token lists, so all the following \TeX code is already
% tokenised long before it is expanded and evaluated. Thus there is no
-% (easy) way to change the catcodes of the characters appearning here
+% (easy) way to change the catcodes of the characters appearing here
% before they are tokenised. In one way this is convenient: the
% catcode changes we make don't ``take'' until evaluated, so we can
% continue to use the standard \TeX characters ($\backslash$, \{, \}
@@ -2072,21 +2858,21 @@
% \begin{macrocode}
\def\cref@text{}%
\immediate\read\@crefscript to \@tmpa%
- \edef\@tmpa{\@tmpa}%
\ifx\@tmpa\@eof%
\@not@eoffalse%
\else%
\@not@eoftrue%
+ \edef\@tmpa{\@tmpa}%
\fi%
\@whilesw\if@not@eof\fi{%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
\@tmpa^^J}%
\immediate\read\@crefscript to \@tmpa%
- \edef\@tmpa{\@tmpa}%
\ifx\@tmpa\@eof%
\@not@eoffalse%
\else%
\@not@eoftrue%
+ \edef\@tmpa{\@tmpa}%
\fi}%
\endgroup%
\immediate\closein\@crefscript%
@@ -2100,27 +2886,63 @@
\lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
\lowercase{\edef\@tmpa{s/||usepackage|(|[.*|]|)|?<cleveref>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{%
s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refname<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]reflabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refdefaultlabelformat<.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||renewcommand<||[cC]ref><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}%
- \expandafter\g@addto@macro\expandafter\cref@text\%
- expandafter{\@tmpa}
- \endgroup
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \endgroup%
% \end{macrocode}
% Overwrite the script file with the new, escaped regexp rules.
% \begin{macrocode}
@@ -2128,7 +2950,7 @@
\immediate\openout\@crefscript=\jobname.sed%
\immediate\write\@crefscript{\cref@text}%
\immediate\closeout\@crefscript%
-}%
+}
% \end{macrocode}
%
%
@@ -2136,24 +2958,38 @@
% substitution rule for the reference to the script, as well as
% typesetting the reference itself.
% \begin{macrocode}
-\renewcommand{\cref}[1]{%
- \edef\cref@text{}%
- \@cref{cref}{#1}%
- \cref@writescript{\string\cref\string{#1\string}}}
-\renewcommand{\Cref}[1]{%
- \edef\cref@text{}%
- \@cref{Cref}{#1}%
- \cref@writescript{\string\Cref\string{#1\string}}}
-\renewcommand{\crefrange}[2]{%
- \edef\cref@text{}%
- \@setcrefrange{#1}{#2}{cref}{}%
- \cref@writescript{%
- \string\crefrange\string{#1\string}\string{#2\string}}}
-\renewcommand{\Crefrange}[2]{%
- \edef\cref@text{}%
- \@setcrefrange{#1}{#2}{Cref}{}%
- \cref@writescript{%
- \string\Crefrange\string{#1\string}\string{#2\string}}}
+\@ifpackageloaded{hyperref}{%
+ \def\@crefnostar#1#2{%
+ \edef\cref@text{}%
+ \@cref{#1}{#2}%
+ \cref@writescript{%
+ \expandafter\string\csname#1\endcsname\string{#2\string}}}
+ \def\@crefrangenostar#1#2#3{%
+ \edef\cref@text{}%
+ \@setcrefrange{#2}{#3}{#1}{}%
+ \cref@writescript{%
+ \expandafter\string\csname#1range\endcsname%
+ \string{#2\string}\string{#3\string}}}%
+}{%
+ \DeclareRobustCommand{\cref}[1]{%
+ \edef\cref@text{}%
+ \@cref{cref}{#1}%
+ \cref@writescript{\string\cref\string{#1\string}}}
+ \DeclareRobustCommand{\Cref}[1]{%
+ \edef\cref@text{}%
+ \@cref{Cref}{#1}%
+ \cref@writescript{\string\Cref\string{#1\string}}}
+ \DeclareRobustCommand{\crefrange}[2]{%
+ \edef\cref@text{}%
+ \@setcrefrange{#1}{#2}{cref}{}%
+ \cref@writescript{%
+ \string\crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Crefrange}[2]{%
+ \edef\cref@text{}%
+ \@setcrefrange{#1}{#2}{Cref}{}%
+ \cref@writescript{%
+ \string\Crefrange\string{#1\string}\string{#2\string}}}%
+}
% \end{macrocode}
%
%
@@ -2162,15 +2998,15 @@
% \begin{macrocode}
\def\cref@writescript#1{%
\edef\@tmpa{\cref@getmeaning{\cref@text}}%
- \immediate\write\@crefscript{s/#1/\@tmpa/g}%
-}
+ \immediate\write\@crefscript{s/#1/\@tmpa/g}}
% \end{macrocode}
%
%
-% Redefine \cmd{\@@setcref}, \cmd{\@@setrangeref},
-% \cmd{\@setcref@middleconjunction} and
-% \cmd{\@setcref@lastconjunction} to append the text they typeset to
-% \cmd{\cref@text}, as well as actually typesetting it.
+% 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{macrocode}
\let\old@@setcref\@@setcref
\let\old@@setcrefrange\@@setcrefrange
@@ -2183,19 +3019,24 @@
#1{\ref{#2}}{}{}}}
\def\@@setcrefrange#1#2#3{%
\old@@setcrefrange{#1}{#2}{#3}%
- \expandafter\g@addto@macro
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
\expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
-\def\@setcref@middleconjunction{%
- \crefmiddleconjunction%
- \expandafter\g@addto@macro
+\def\@setcref@pairgroupconjunction{%
+ \crefpairgroupconjunction%
+ \expandafter\g@addto@macro%
+ \expandafter{\expandafter\cref@text\expandafter}%
+ \expandafter{\crefpairgroupconjunction}}
+\def\@setcref@middlegroupconjunction{%
+ \crefmiddlegroupconjunction%
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
- \expandafter{\crefmiddleconjunction}}
-\def\@setcref@lastconjunction{%
- \creflastconjunction%
- \expandafter\g@addto@macro
+ \expandafter{\crefmiddlegroupconjunction}}
+\def\@setcref@lastgroupconjunction{%
+ \creflastgroupconjunction%
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
- \expandafter{\creflastconjunction}}
+ \expandafter{\creflastgroupconjunction}}
} % end of poorman option
% \end{macrocode}
%
diff --git a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty
index 4568bca3429..71d7d2a4690 100644
--- a/Master/texmf-dist/tex/latex/cleveref/cleveref.sty
+++ b/Master/texmf-dist/tex/latex/cleveref/cleveref.sty
@@ -22,7 +22,7 @@
%% version 1999/12/01 or later.
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{cleveref}
- [2007/10/07 v0.8 Automatic cross-reference formatting]
+ [2007/30/10 v0.10 Automatic cross-reference formatting]
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
@@ -55,7 +55,25 @@
\else\edef\@result{\csname the\@result\endcsname}\fi%
\protected@edef\@currentlabel{%
[#1][\arabic{#2}][\@result]\@currentlabel}}
-\def\cref@label#1#2{\@result}
+\AtBeginDocument{%
+ \let\old@label\label
+ \def\label{\@ifnextchar[\label@optarg\old@label}%]
+ \def\override@label@type[#1][#2][#3]#4\@nil#5{[#5][#2][#3]#4}
+ \def\label@optarg[#1]{%
+ \protected@edef\@currentlabel{%
+ \expandafter\override@label@type\@currentlabel\@nil{#1}}%
+ \old@label}%
+ \@ifpackageloaded{amsmath}{%
+ \let\cref@label\label%
+ \let\old@label@in@display\label@in@display%
+ \def\label@in@display{%
+ \@ifnextchar[\label@in@display@optarg\label@in@display@noarg}%]
+ \def\label@in@display@noarg#1{\old@label@in@display{{#1}}}
+ \def\label@in@display@optarg[#1]#2{\old@label@in@display{[#1]{#2}}}
+ \def\ltx@label#1{\cref@label#1}%
+ }{}%
+}
+\def\cref@reflabel#1#2{\@result}
\AtBeginDocument{%
\expandafter\def\csname ref \endcsname#1{%
\expandafter\ifx\csname r@#1\endcsname\relax%
@@ -63,8 +81,8 @@
\else%
\cref@getlabel{#1}{\@result}%
\fi%
- \expandafter\@setref\csname r@#1\endcsname{\cref@label}{#1}}%
- \def\ref{\expandafter\protect\csname ref \endcsname}
+ \expandafter\@setref\csname r@#1\endcsname{\cref@reflabel}{#1}}%
+ \def\ref{\expandafter\protect\csname ref \endcsname}%
}
\def\cref@getlabel#1#2{%
\expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
@@ -94,6 +112,9 @@
\def\@cref@getprefix{\@ifnextchar[%]
\@@cref@getprefix{\@@cref@getprefix[][][]}}
\def\@@cref@getprefix[#1][#2][#3]#4\@nil#5{\def#5{#3}}
+\def\append@toks#1#2{\toks0={#2}%
+ \edef\act{\noexpand#1={\the#1\the\toks0}}%
+ \act}%
\def\stack@init#1{\def#1{\@nil}}
\def\stack@top#1{\expandafter\stack@top@aux#1}
\def\stack@top@aux#1,#2\@nil{#1}
@@ -108,8 +129,7 @@
\def\isstackempty#1{%
\def\@tmpa{\@nil}%
\ifx#1\@tmpa\stackemptytrue%
- \else\stackemptyfalse\fi
-}
+ \else\stackemptyfalse\fi}
\def\isstackfull#1{%
\def\@tmpa{\@nil}%
\ifx#1\@tmpa\stackfullfalse%
@@ -181,9 +201,12 @@
\countdef\count@consecutive=0%
\def\@empty{}%
\newif\if@firstgroup%
+ \newif\if@secondgroup%
+ \newif\if@secondref%
\stack@init{\@refstack}%
\stack@push{#2}{\@refstack}%
\@firstgrouptrue%
+ \@secondgroupfalse%
\isstackfull{\@refstack}%
\@whilesw\ifstackfull\fi{%
\stack@init{\@refsubstack}%
@@ -214,15 +237,21 @@
\fi%
\fi}%
\if@firstgroup%
+ \@firstgroupfalse%
+ \@secondgrouptrue%
\else%
\isstackfull{\@refstack}%
\ifstackfull%
- \@setcref@middleconjunction%
+ \@setcref@middlegroupconjunction%
\else%
- \@setcref@lastconjunction%
+ \if@secondgroup%
+ \@setcref@pairgroupconjunction%
+ \else%
+ \@setcref@lastgroupconjunction%
+ \fi%
\fi%
+ \@secondgroupfalse%
\fi%
- \@firstgroupfalse%
\edef\@nextref{\stack@top{\@refsubstack}}%
\stack@pop{\@refsubstack}%
\isstackempty{\@refsubstack}%
@@ -250,7 +279,7 @@
\ifnum\count@consecutive=2%
\edef\@endref{\@endref,}%
\fi%
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -282,7 +311,7 @@
\ifnum\count@consecutive=2%
\edef\@endref{\@endref,}%
\fi%
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -297,7 +326,7 @@
\ifnum\count@consecutive=2%
\expandafter\@setcref\expandafter{\@beginref}{#1}{@first}%
\expandafter\stack@push\expandafter{\@endref}{\@refsubstack}%
- \else
+ \else%
\edef\@tmpa{{\@beginref}{\@endref}}%
\ifstackempty%
\expandafter\@setcrefrange\@tmpa{#1}{}%
@@ -306,6 +335,7 @@
\fi%
\fi%
\fi%
+ \@secondreftrue%
\isstackfull{\@refsubstack}%
\@whilesw\ifstackfull\fi{%
\edef\@beginref{\stack@top{\@refsubstack}}%
@@ -313,7 +343,11 @@
\let\@endref\relax%
\isstackempty{\@refsubstack}%
\ifstackempty%
- \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
+ \if@secondref%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@second}%
+ \else%
+ \expandafter\@setcref\expandafter{\@beginref}{#1}{@last}%
+ \fi%
\else%
\edef\@nextref{\stack@top{\@refsubstack}}%
\count@consecutive=1%
@@ -331,7 +365,7 @@
\ifnum\count@consecutive=2%
\edef\@endref{\@endref,}%
\fi%
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -362,7 +396,7 @@
\ifnum\count@consecutive=2%
\edef\@endref{\@endref,}%
\fi%
- \else
+ \else%
\expandafter\ifx\csname r@\@nextref\endcsname\relax%
\refconsecutivefalse%
\else%
@@ -373,7 +407,11 @@
\fi}%
\isstackempty{\@refsubstack}%
\ifstackempty%
- \def\@pos{@last}%
+ \if@secondref%
+ \def\@pos{@second}%
+ \else%
+ \def\@pos{@last}%
+ \fi%
\else%
\def\@pos{@middle}%
\fi%
@@ -386,12 +424,13 @@
{\@beginref}{#1}{@middle}%
\expandafter\stack@push\expandafter%
{\@endref}{\@refsubstack}%
- \else
+ \else%
\edef\@tmpa{{\@beginref}{\@endref}{#1}{\@pos}}%
\expandafter\@setcrefrange\@tmpa%
\fi%
\fi%
\fi%
+ \@secondreffalse%
\isstackfull{\@refsubstack}%
}% end loop over reference substack
\fi%
@@ -466,7 +505,7 @@
\expandafter\ifx\@formata\relax%
\protect\G@refundefinedtrue%
\nfss@text{\reset@font\bfseries ??}~\@labela--\@labelb%
- \@latex@warning{#3 \space reference format for label
+ \@latex@warning{#3\space reference range format for label
type `\@typea' undefined}%
\else%
\ifx\formata\formatb%
@@ -484,39 +523,279 @@
\cref@getlabel{#2}{\@labela}%
\cref@getlabel{#3}{\@labelb}%
#1{\@labela}{\@labelb}{}{}{}{}}
-\def\@setcref@middleconjunction{\crefmiddleconjunction}
-\def\@setcref@lastconjunction{\creflastconjunction}
+\def\@setcref@pairgroupconjunction{\crefpairgroupconjunction}
+\def\@setcref@middlegroupconjunction{\crefmiddlegroupconjunction}
+\def\@setcref@lastgroupconjunction{\creflastgroupconjunction}
+\newcommand{\crefdefaultlabelformat}[1]{%
+ \def\cref@default@label##1##2##3{#1}}
+\newcommand{\crefname}[3]{%
+ \@crefname{cref}{#1}{#2}{#3}%
+ \@crefdefineallformats{#1}}
+\newcommand{\Crefname}[3]{%
+ \@crefname{Cref}{#1}{#2}{#3}%
+ \@crefdefineallformats{#1}}
+\newcommand{\creflabelformat}[2]{%
+ \@creflabelformat{#1}{#2}%
+ \@crefdefineallformats{#1}}
+\newcommand{\crefrangelabelformat}[2]{%
+ \@crefrangelabelformat{#1}{#2}%
+ \@crefdefineallformats{#1}}
+\def\@creflabelformat#1#2{%
+ \expandafter\def\csname cref@#1@label\endcsname##1##2##3{#2}}
+\def\@crefrangelabelformat#1#2{%
+ \expandafter\def\csname cref@#1@rangelabel\endcsname%
+ ##1##2##3##4##5##6{#2}}
+\def\@crefname#1#2#3#4{%
+ \expandafter\def\csname #1@#2@name\endcsname{#3}%
+ \expandafter\def\csname #1@#2@name@plural\endcsname{#4}%
+ \def\@tmpa##1##2\@nil{%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
+ \@tmpa#1\@nil%
+ \@ifundefined{\@other @#2@name}{%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpb%
+ \expandafter\expandafter\expandafter{%
+ \csname#1@#2@name@plural\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpb%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpb}%
+ \newtoks\@toksa%
+ \@toksa={%
+ \expandafter\def\csname\@other @#2@name\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpa}%
+ \@toksa={%
+ \expandafter\def\csname\@other @#2@name@plural\endcsname}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpb}%
+ }{}%
+}
+\def\@crefconstructcomponents#1{%
+ \@ifundefined{cref@#1@label}{%
+ \let\@tmplabel\cref@default@label%
+ }{%
+ \expandafter\let\expandafter\@tmplabel%
+ \csname cref@#1@label\endcsname%
+ }%
+ \@ifundefined{cref@#1@rangelabel}{%
+ \expandafter\def\expandafter\@tmpa\expandafter{%
+ \@tmplabel{####1}{####3}{####4}}%
+ \expandafter\def\expandafter\@tmpb\expandafter{%
+ \@tmplabel{####2}{####5}{####6}}%
+ \@toksa={\def\@tmprangelabel##1##2##3##4##5##6}%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter\expandafter%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\expandafter\expandafter\@tmpa%
+ \expandafter\crefrangeconjunction\@tmpb}%
+ }{%
+ \expandafter\let\expandafter\@tmprangelabel%
+ \csname cref@#1@rangelabel\endcsname%
+ }%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpname%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@#1@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpName%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@#1@name\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpnameplural%
+ \expandafter\expandafter\expandafter{%
+ \csname cref@#1@name@plural\endcsname}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpNameplural%
+ \expandafter\expandafter\expandafter{%
+ \csname Cref@#1@name@plural\endcsname}%
+ \expandafter\def\expandafter\@tmplabel\expandafter{%
+ \@tmplabel{########1}{########2}{########3}}%
+ \expandafter\def\expandafter\@tmprangelabel\expandafter{%
+ \@tmprangelabel{########1}{########2}{########3}%
+ {########4}{########5}{########6}}%
+}
+\def\@crefdefineformat#1{%
+ \newtoks\@toksa%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpname\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpName\expandafter~\@tmplabel}%
+ \@toksa={\crefformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
+ \@toksa={\Crefformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
+}
+\def\@crefrangedefineformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
+ \@toksa={\crefrangeformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpfirst}%
+ \@toksa={\Crefrangeformat{#1}}%
+ \expandafter\the\expandafter\@toksa\expandafter{\@tmpFirst}%
+}
+\def\@crefdefinemultiformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpsecond%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefpairconjunction\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpmiddle%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefmiddleconjunction\@tmplabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmplast%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\creflastconjunction\@tmplabel}%
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpfirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpFirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\Crefmultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+}
+\def\@crefrangedefinemultiformat#1{%
+ \newtoks\@toksa%
+ \newtoks\@toksb%
+ \@crefconstructcomponents{#1}% puts format components into tmp macros
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpfirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpnameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpFirst%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@tmpNameplural\expandafter~\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpsecond%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefpairconjunction\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmpmiddle%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\crefmiddleconjunction\@tmprangelabel}%
+ \expandafter\expandafter\expandafter\def%
+ \expandafter\expandafter\expandafter\@tmplast%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\creflastconjunction\@tmprangelabel}%
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpfirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+ \@toksb={}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpFirst}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpsecond}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmpmiddle}}%
+ \expandafter\append@toks\expandafter\@toksb\expandafter{%
+ \expandafter{\@tmplast}}%
+ \@toksa={\Crefrangemultiformat{#1}}%
+ \expandafter\the\expandafter\@toksa\the\@toksb%
+}
+\def\@crefdefineallformats#1{%
+ \@crefdefineformat{#1}%
+ \@crefrangedefineformat{#1}%
+ \@crefdefinemultiformat{#1}%
+ \@crefrangedefinemultiformat{#1}}
\newcommand{\crefformat}[2]{\@crefformat{cref}{#1}{#2}}
\newcommand{\Crefformat}[2]{\@crefformat{Cref}{#1}{#2}}
\newcommand{\crefrangeformat}[2]{\@crefrangeformat{crefrange}{#1}{#2}}
\newcommand{\Crefrangeformat}[2]{\@crefrangeformat{Crefrange}{#1}{#2}}
-\newcommand{\crefmultiformat}[4]{%
- \@crefmultiformat{cref}{#1}{#2}{#3}{#4}}
-\newcommand{\Crefmultiformat}[4]{%
- \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}}
-\newcommand{\crefrangemultiformat}[4]{%
- \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}}
-\newcommand{\Crefrangemultiformat}[4]{%
- \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}}
+\newcommand{\crefmultiformat}[5]{%
+ \@crefmultiformat{cref}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\Crefmultiformat}[5]{%
+ \@crefmultiformat{Cref}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\crefrangemultiformat}[5]{%
+ \@crefrangemultiformat{crefrange}{#1}{#2}{#3}{#4}{#5}}
+\newcommand{\Crefrangemultiformat}[5]{%
+ \@crefrangemultiformat{Crefrange}{#1}{#2}{#3}{#4}{#5}}
\def\@crefformat#1#2#3{%
\expandafter\def\csname #1@#2@format\endcsname##1##2##3{#3}%
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
\@ifundefined{\@other @#2@format}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
\newtoks\@toksa%
\@toksa={\def\@tmpa##1##2##3}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format\endcsname{##1}{##2}{##3}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
\@toksa={%
\expandafter\def\csname\@other @#2@format\endcsname##1##2##3}%
\expandafter\the\expandafter\@toksa\expandafter{%
@@ -527,55 +806,67 @@
\expandafter\def\csname #1@#2@format\endcsname%
##1##2##3##4##5##6{#3}%
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
\@ifundefined{\@other @#2@format}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
\newtoks\@toksa%
\@toksa={\def\@tmpa##1##2##3##4##5##6}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format\endcsname{##1}{##2}{##3}{##4}{##5}{##6}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
\@toksa={\expandafter\def%
\csname\@other @#2@format\endcsname##1##2##3##4##5##6}%
\expandafter\the\expandafter\@toksa\expandafter{%
\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
}{}%
}
-\def\@crefmultiformat#1#2#3#4#5{%
+\def\@crefmultiformat#1#2#3#4#5#6{%
\expandafter\def\csname #1@#2@format@first\endcsname##1##2##3{#3}%
- \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#4}%
- \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#5}%
- \newtoks\@toksa%
+ \expandafter\def\csname #1@#2@format@second\endcsname##1##2##3{#4}%
+ \expandafter\def\csname #1@#2@format@middle\endcsname##1##2##3{#5}%
+ \expandafter\def\csname #1@#2@format@last\endcsname##1##2##3{#6}%
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
\@ifundefined{\@other @#2@format@first}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\Makelowercase}\fi}%
- \@tmpa#1\@nil%
\@toksa={\def\@tmpa##1##2##3}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format@first\endcsname{##1}{##2}{##3}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}}%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}}%
\@toksa={%
\expandafter\def\csname\@other @#2@format@first\endcsname%
##1##2##3}%
\expandafter\the\expandafter\@toksa\expandafter{%
\@tmpa{##1}{##2}{##3}}%
- }{}
+ }{}%
+ \@ifundefined{\@other @#2@format@second}{%
+ \@toksa={%
+ \expandafter\let\csname\@other @#2@format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2@format@second\endcsname%
+ }{}%
\@ifundefined{\@other @#2@format@middle}{%
\@toksa={%
\expandafter\let\csname\@other @#2@format@middle\endcsname}%
@@ -589,36 +880,47 @@
\csname #1@#2@format@last\endcsname%
}{}%
}
-\def\@crefrangemultiformat#1#2#3#4#5{%
+\def\@crefrangemultiformat#1#2#3#4#5#6{%
\expandafter\def\csname #1@#2@format@first\endcsname%
##1##2##3##4##5##6{#3}%
- \expandafter\def\csname #1@#2@format@middle\endcsname%
+ \expandafter\def\csname #1@#2@format@second\endcsname%
##1##2##3##4##5##6{#4}%
- \expandafter\def\csname #1@#2@format@last\endcsname%
+ \expandafter\def\csname #1@#2@format@middle\endcsname%
##1##2##3##4##5##6{#5}%
+ \expandafter\def\csname #1@#2@format@last\endcsname%
+ ##1##2##3##4##5##6{#6}%
\def\@tmpa##1##2\@nil{%
- \if##1c \def\@other{C##2}%
- \else\def\@other{c##2}\fi}%
+ \if##1c%
+ \def\@other{C##2}%
+ \def\@changecase{\MakeUppercase}%
+ \else%
+ \def\@other{c##2}%
+ \def\@changecase{\MakeLowercase}%
+ \fi}%
\@tmpa#1\@nil%
\@ifundefined{\@other @#2@format@first}{%
- \def\@tmpa##1##2\@nil{%
- \if##1c\def\@changecase{\MakeUppercase}%
- \else\def\@changecase{\MakeLowercase}\fi}%
- \@tmpa#1\@nil%
\@toksa={\def\@tmpa##1##2##3##4##5##6}%
\expandafter\expandafter\expandafter\the%
\expandafter\expandafter\expandafter\@toksa%
\expandafter\expandafter\expandafter{%
\csname#1@#2@format@first\endcsname%
{##1}{##2}{##3}{##4}{##5}{##6}}%
- \expandafter\the\expandafter\@toksa\expandafter{%
- \expandafter\MakeUppercase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
+ \expandafter\expandafter\expandafter\the%
+ \expandafter\expandafter\expandafter\@toksa%
+ \expandafter\expandafter\expandafter{%
+ \expandafter\@changecase\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
\@toksa={%
\expandafter\def\csname\@other @#2@format@first\endcsname%
##1##2##3##4##5##6}%
\expandafter\the\expandafter\@toksa\expandafter{%
\@tmpa{##1}{##2}{##3}{##4}{##5}{##6}}%
}{}%
+ \@ifundefined{\@other @#2@format@second}{%
+ \@toksa={%
+ \expandafter\let\csname\@other @#2@format@second\endcsname}%
+ \expandafter\the\expandafter\@toksa%
+ \csname #1@#2@format@second\endcsname%
+ }{}%
\@ifundefined{\@other @#2@format@middle}{%
\@toksa={%
\expandafter\let\csname\@other @#2@format@middle\endcsname}%
@@ -632,209 +934,184 @@
\csname #1@#2@format@last\endcsname%
}{}%
}
-\crefformat{equation}{eq.~\textup{(#2#1#3)}}
-\Crefformat{equation}{Equation~\textup{(#2#1#3)}}
-\crefformat{chapter}{chapter~#2#1#3}
-\Crefformat{chapter}{Chapter~#2#1#3}
-\crefformat{section}{section~#2#1#3}
-\Crefformat{section}{Section~#2#1#3}
-\crefformat{subsection}{section~#2#1#3}
-\Crefformat{subsection}{Section~#2#1#3}
-\crefformat{subsubsection}{section~#2#1#3}
-\Crefformat{subsubsection}{Section~#2#1#3}
-\crefformat{subsubsubsection}{section~#2#1#3}
-\Crefformat{subsubsubsection}{Section~#2#1#3}
-\crefformat{figure}{fig.~#2#1#3}
-\Crefformat{figure}{Figure~#2#1#3}
-\crefformat{theorem}{theorem~#2#1#3}
-\Crefformat{theorem}{Theorem~#2#1#3}
-\crefformat{enumi}{item~#2#1#3}
-\Crefformat{enumi}{Item~#2#1#3}
-\crefformat{enumii}{item~#2#1#3}
-\Crefformat{enumii}{Item~#2#1#3}
-\crefformat{enumiii}{item~#2#1#3}
-\Crefformat{enumiii}{Item~#2#1#3}
-\crefformat{enumiv}{item~#2#1#3}
-\Crefformat{enumiv}{Item~#2#1#3}
-\crefmultiformat{equation}%
- {eqs.~\textup{(#2#1#3)}}%
- {, \textup{(#2#1#3)}}%
- { and~\textup{(#2#1#3)}}
-\Crefmultiformat{equation}%
- {Equations~\textup{(#2#1#3)}}%
- {, \textup{(#2#1#3)}}%
- { and~\textup{(#2#1#3)}}
-\crefmultiformat{chapter}%
- {chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{chapter}%
- {Chapters~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{section}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{section}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsubsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsubsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{subsubsubsection}%
- {sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{subsubsubsection}%
- {Sections~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{figure}%
- {figs.~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{figure}%
- {Figures~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{theorem}%
- {theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{theorem}%
- {Theorems~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumi}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumi}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumii}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumii}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumiii}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumiii}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{enumiv}%
- {items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{enumiv}%
- {Items~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefrangeformat{equation}{%
- eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\Crefrangeformat{equation}{%
- Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\crefrangeformat{chapter}{chapters~#3#1#4--#5#2#6}
-\Crefrangeformat{chapter}{Chapters~#3#1#4--#5#2#6}
-\crefrangeformat{section}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{section}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsubsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsubsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{subsubsubsection}{sections~#3#1#4--#5#2#6}
-\Crefrangeformat{subsubsubsection}{Sections~#3#1#4--#5#2#6}
-\crefrangeformat{figure}{figs.~#3#1#4--#5#2#6}
-\Crefrangeformat{figure}{Figures~#3#1#4--#5#2#6}
-\crefrangeformat{theorem}{theorems~#3#1#4--#5#2#6}
-\Crefrangeformat{theorem}{Theorems~#3#1#4--#5#2#6}
-\crefrangeformat{enumi}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumi}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumii}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumii}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumiii}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumiii}{Items~#3#1#4--#5#2#6}
-\crefrangeformat{enumiv}{items~#3#1#4--#5#2#6}
-\Crefrangeformat{enumiv}{Items~#3#1#4--#5#2#6}
-\crefrangemultiformat{equation}%
- {eqs.~\textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\Crefrangemultiformat{equation}%
- {Equations~\textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- {, \textup{(#3#1#4)}--\textup{(#5#2#6)}}%
- { and~\textup{(#3#1#4)}--\textup{(#5#2#6)}}
-\crefrangemultiformat{chapter}%
- {chapters~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{chapter}%
- {Chapters~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{section}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{section}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsubsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsubsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{subsubsubsection}%
- {sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{subsubsubsection}%
- {Sections~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{figure}%
- {figs.~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{figure}%
- {Figures~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{theorem}%
- {theorems~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{theorem}%
- {Theorems~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumi}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumi}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumii}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumii}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumiii}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumiii}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{enumiv}%
- {items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{enumiv}%
- {Items~#3#1#4--#5#2#6}%
- {, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\def\crefmiddleconjunction{, }
-\def\creflastconjunction{, and }
-\DeclareOption{hyperref}{%
-\PackageInfo{cleveref}{option `hyperref' loaded}
-\def\cref@label#1#2#3#4#5{\@result}
+\newcommand{\crefrangeconjunction}{ to~}
+\newcommand{\crefpairconjunction}{ and~}
+\newcommand{\crefmiddleconjunction}{, }
+\newcommand{\creflastconjunction}{ and~}
+\crefdefaultlabelformat{#2#1#3}
+\AtBeginDocument{%
+ \@ifundefined{crefpairgroupconjunction}{%
+ \let\crefpairgroupconjunction\crefpairconjunction}{}%
+ \@ifundefined{crefmiddlegroupconjunction}{%
+ \let\crefmiddlegroupconjunction\crefmiddleconjunction}{}%
+ \@ifundefined{creflastgroupconjunction}{%
+ \def\@tmpa{ and~}%
+ \ifx\creflastconjunction\@tmpa%
+ \def\creflastgroupconjunction{, and~}%
+ \else%
+ \let\creflastgroupconjunction\creflastconjunction%
+ \fi}{}%
+ \@ifundefined{cref@equation@name}{%
+ \@crefname{cref}{equation}{eq.}{eqs.}%
+ \@crefname{Cref}{equation}{Equation}{Equations}}{}%
+ \@ifundefined{cref@equation@label}{%
+ \@creflabelformat{equation}{\textup{(#2#1#3)}}%
+ \@ifundefined{cref@equation@rangelabel}{%
+ \@crefrangelabelformat{equation}{%
+ \textup{(#3#1#4)}--\textup{(#5#2#6)}}}{}}{}%
+ \@ifundefined{cref@chapter@name}{%
+ \@crefname{cref}{chapter}{chapter}{chapters}%
+ \@crefname{Cref}{chapter}{Chapter}{Chapters}}{}%
+ \@ifundefined{cref@section@name}{%
+ \@crefname{cref}{section}{section}{sections}%
+ \@crefname{Cref}{section}{Section}{Sections}}{}%
+ \@ifundefined{cref@subsection@name}{%
+ \@crefname{cref}{subsection}{section}{sections}%
+ \@crefname{Cref}{subsection}{Section}{Sections}}{}%
+ \@ifundefined{cref@subsubsection@name}{%
+ \@crefname{cref}{subsubsection}{section}{sections}%
+ \@crefname{Cref}{subsubsection}{Section}{Sections}}{}%
+ \@ifundefined{cref@subsubsubsection@name}{%
+ \@crefname{cref}{subsubsubsection}{section}{sections}%
+ \@crefname{Cref}{subsubsubsection}{Section}{Sections}}{}%
+ \@ifundefined{cref@figure@name}{%
+ \@crefname{cref}{figure}{fig.}{figs.}%
+ \@crefname{Cref}{figure}{Figure}{Figures}}{}%
+ \@ifundefined{cref@figure@rangelabel}{%
+ \@crefrangelabelformat{figure}{#3#1#4--#5#2#6}}{}%
+ \@ifundefined{cref@table@name}{%
+ \@crefname{cref}{table}{table}{tables}%
+ \@crefname{Cref}{table}{Table}{Tables}}{}%
+ \@ifundefined{cref@theorem@name}{%
+ \@crefname{cref}{theorem}{theorem}{theorems}%
+ \@crefname{Cref}{theorem}{Theorem}{Theorems}}{}%
+ \@ifundefined{cref@enumi@name}{%
+ \@crefname{cref}{enumi}{item}{items}%
+ \@crefname{Cref}{enumi}{Item}{Items}}{}%
+ \@ifundefined{cref@enumii@name}{%
+ \@crefname{cref}{enumii}{item}{items}%
+ \@crefname{Cref}{enumii}{Item}{Items}}{}%
+ \@ifundefined{cref@enumiii@name}{%
+ \@crefname{cref}{enumiii}{item}{items}%
+ \@crefname{Cref}{enumiii}{Item}{Items}}{}%
+ \@ifundefined{cref@enumiv@name}{%
+ \@crefname{cref}{enumiv}{item}{items}%
+ \@crefname{Cref}{enumiv}{Item}{Items}}{}%
+ \@ifundefined{cref@enumv@name}{%
+ \@crefname{cref}{enumv}{item}{items}%
+ \@crefname{Cref}{enumv}{Item}{Items}}{}%
+ \@ifundefined{cref@equation@format}{%
+ \@crefdefineformat{equation}}{}%
+ \@ifundefined{crefrange@equation@format}{%
+ \@crefrangedefineformat{equation}}{}%
+ \@ifundefined{cref@equation@format@first}{%
+ \@crefdefinemultiformat{equation}}{}%
+ \@ifundefined{crefrange@equation@format@first}{%
+ \@crefrangedefinemultiformat{equation}}{}%
+ \@ifundefined{cref@chapter@format}{%
+ \@crefdefineformat{chapter}}{}%
+ \@ifundefined{crefrange@chapter@format}{%
+ \@crefrangedefineformat{chapter}}{}%
+ \@ifundefined{cref@chapter@format@first}{%
+ \@crefdefinemultiformat{chapter}}{}%
+ \@ifundefined{crefrange@chapter@format@first}{%
+ \@crefrangedefinemultiformat{chapter}}{}%
+ \@ifundefined{cref@section@format}{%
+ \@crefdefineformat{section}}{}%
+ \@ifundefined{crefrange@section@format}{%
+ \@crefrangedefineformat{section}}{}%
+ \@ifundefined{cref@section@format@first}{%
+ \@crefdefinemultiformat{section}}{}%
+ \@ifundefined{crefrange@section@format@first}{%
+ \@crefrangedefinemultiformat{section}}{}%
+ \@ifundefined{cref@subsection@format}{%
+ \@crefdefineformat{subsection}}{}%
+ \@ifundefined{crefrange@subsection@format}{%
+ \@crefrangedefineformat{subsection}}{}%
+ \@ifundefined{cref@subsection@format@first}{%
+ \@crefdefinemultiformat{subsection}}{}%
+ \@ifundefined{crefrange@subsection@format@first}{%
+ \@crefrangedefinemultiformat{subsection}}{}%
+ \@ifundefined{cref@subsubsection@format}{%
+ \@crefdefineformat{subsubsection}}{}%
+ \@ifundefined{crefrange@subsubsection@format}{%
+ \@crefrangedefineformat{subsubsection}}{}%
+ \@ifundefined{cref@subsubsection@format@first}{%
+ \@crefdefinemultiformat{subsubsection}}{}%
+ \@ifundefined{crefrange@subsubsection@format@first}{%
+ \@crefrangedefinemultiformat{subsubsection}}{}%
+ \@ifundefined{cref@subsubsubsection@format}{%
+ \@crefdefineformat{subsubsubsection}}{}%
+ \@ifundefined{crefrange@subsubsubsection@format}{%
+ \@crefrangedefineformat{subsubsubsection}}{}%
+ \@ifundefined{cref@subsubsubsection@format@first}{%
+ \@crefdefinemultiformat{subsubsubsection}}{}%
+ \@ifundefined{crefrange@subsubsubsection@format@first}{%
+ \@crefrangedefinemultiformat{subsubsubsection}}{}%
+ \@ifundefined{cref@figure@format}{%
+ \@crefdefineformat{figure}}{}%
+ \@ifundefined{crefrange@figure@format}{%
+ \@crefrangedefineformat{figure}}{}%
+ \@ifundefined{cref@figure@format@first}{%
+ \@crefdefinemultiformat{figure}}{}%
+ \@ifundefined{crefrange@figure@format@first}{%
+ \@crefrangedefinemultiformat{figure}}{}%
+ \@ifundefined{cref@theorem@format}{%
+ \@crefdefineformat{theorem}}{}%
+ \@ifundefined{crefrange@theorem@format}{%
+ \@crefrangedefineformat{theorem}}{}%
+ \@ifundefined{cref@theorem@format@first}{%
+ \@crefdefinemultiformat{theorem}}{}%
+ \@ifundefined{crefrange@theorem@format@first}{%
+ \@crefrangedefinemultiformat{theorem}}{}%
+ \@ifundefined{cref@enumi@format}{%
+ \@crefdefineformat{enumi}}{}%
+ \@ifundefined{crefrange@enumi@format}{%
+ \@crefrangedefineformat{enumi}}{}%
+ \@ifundefined{cref@enumi@format@first}{%
+ \@crefdefinemultiformat{enumi}}{}%
+ \@ifundefined{crefrange@enumi@format@first}{%
+ \@crefrangedefinemultiformat{enumi}}{}%
+ \@ifundefined{cref@enumii@format}{%
+ \@crefdefineformat{enumii}}{}%
+ \@ifundefined{crefrange@enumii@format}{%
+ \@crefrangedefineformat{enumii}}{}%
+ \@ifundefined{cref@enumii@format@first}{%
+ \@crefdefinemultiformat{enumii}}{}%
+ \@ifundefined{crefrange@enumii@format@first}{%
+ \@crefrangedefinemultiformat{enumii}}{}%
+ \@ifundefined{cref@enumiii@format}{%
+ \@crefdefineformat{enumiii}}{}%
+ \@ifundefined{crefrange@enumiii@format}{%
+ \@crefrangedefineformat{enumiii}}{}%
+ \@ifundefined{cref@enumiii@format@first}{%
+ \@crefdefinemultiformat{enumiii}}{}%
+ \@ifundefined{crefrange@enumiii@format@first}{%
+ \@crefrangedefinemultiformat{enumiii}}{}%
+ \@ifundefined{cref@enumiv@format}{%
+ \@crefdefineformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \@crefrangedefineformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \@crefdefinemultiformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \@crefrangedefinemultiformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format}{%
+ \@crefdefineformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format}{%
+ \@crefrangedefineformat{enumiv}}{}%
+ \@ifundefined{cref@enumiv@format@first}{%
+ \@crefdefinemultiformat{enumiv}}{}%
+ \@ifundefined{crefrange@enumiv@format@first}{%
+ \@crefrangedefinemultiformat{enumiv}}{}%
+}
+\@ifpackageloaded{hyperref}{%
+\PackageInfo{cleveref}{`hyperref' support loaded}
+\@ifpackagewith{hyperref}{backref}{%
+ \PackageError{cleveref}{`cleveref' is currently incompatible with
+ `hyperref's `backref' option}{Remove the `backref' option from
+ `hyperref' if you want to use `cleveref'}}{}
+\def\cref@reflabel#1#2#3#4#5{\@result}
\def\cref@hyperref#1{\expandafter\expandafter\expandafter%
\@fourthoffive\csname r@#1\endcsname}
\def\cref@getlabel#1#2{%
@@ -842,15 +1119,15 @@
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getlabel\@tempa\@nil#2}
\def\cref@gettype#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@gettype\@tempa\@nil#2}
\def\cref@getcounter#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getcounter\@tempa\@nil#2}
\def\cref@getprefix#1#2{%
- \expandafter\let\expandafter\@tempa\csname r@#1\endcsname
+ \expandafter\let\expandafter\@tempa\csname r@#1\endcsname%
\edef\@tempa{\expandafter\@firstoffive\@tempa}%
\expandafter\@cref@getprefix\@tempa\@nil#2}
\def\H@refstepcounter#1{%
@@ -880,10 +1157,11 @@
\DeclareRobustCommand{\Crefrange}{%
\@ifstar{\@crefrangestar{Cref}}{\@crefrangenostar{Cref}}}
\def\@crefnostar#1#2{\@cref{#1}{#2}}
-\def\@crefstar#1#2{\@crefstarredtrue\@cref{#1}{#2}\@crefstarredfalse}
+\def\@crefstar#1#2{%
+ \@crefstarredtrue\@crefnostar{#1}{#2}\@crefstarredfalse}
\def\@crefrangenostar#1#2#3{\@setcrefrange{#2}{#3}{#1}{}}
\def\@crefrangestar#1#2#3{%
- \@crefstarredtrue\@setcrefrange{#2}{#3}{#1}{}\@crefstarredfalse}
+ \@crefstarredtrue\@crefrangenostar{#1}{#2}{#3}\@crefstarredfalse}
\def\@@setcref#1#2{%
\cref@getlabel{#2}{\@templabel}%
\if@crefstarred%
@@ -904,100 +1182,85 @@
{\hyper@linkstart{link}{\@linka}}{\hyper@linkend}%
{\hyper@linkstart{link}{\@linkb}}{\hyper@linkend}%
\fi}
-} % end of hyperref option
-\DeclareOption{ntheorem}{%
-\PackageInfo{cleveref}{option `ntheorem' loaded}
+}{}
+\@ifpackageloaded{ntheorem}{%
+\PackageInfo{cleveref}{`ntheorem' support loaded}
+\@ifpackagewith{ntheorem}{thref}{%
+ \PackageWarning{cleveref}{`cleveref' supersedes `ntheorem's `thref'
+ option}%
+ \renewcommand{\thref}{\cref}}{}
+\@ifundefined{theorem@prework}{\let\theorem@prework\relax}{}
\gdef\@thm#1#2#3{%
- \if@thmmarks
+ \if@thmmarks%
\stepcounter{end\InTheoType ctr}%
- \fi
+ \fi%
\renewcommand{\InTheoType}{#1}%
- \if@thmmarks
+ \if@thmmarks%
\stepcounter{curr#1ctr}%
\setcounter{end#1ctr}{0}%
- \fi
+ \fi%
\refstepcounter[#1]{#2}% <<<<<
- \thm@topsepadd \theorempostskipamount
- \ifvmode \advance\thm@topsepadd\partopsep\fi
- \trivlist
- \@topsep \theorempreskipamount
- \@topsepadd \thm@topsepadd
- \advance\linewidth -\theorem@indent
- \advance\@totalleftmargin \theorem@indent
- \parshape \@ne \@totalleftmargin \linewidth
+ \theorem@prework%
+ \thm@topsepadd \theorempostskipamount%
+ \ifvmode \advance\thm@topsepadd\partopsep\fi%
+ \trivlist%
+ \@topsep \theorempreskipamount%
+ \@topsepadd \thm@topsepadd%
+ \advance\linewidth -\theorem@indent%
+ \advance\@totalleftmargin \theorem@indent%
+ \parshape \@ne \@totalleftmargin \linewidth%
\@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}%]
}
-\crefformat{lemma}{lemma~#2#1#3}
-\Crefformat{lemma}{Lemma~#2#1#3}
-\crefformat{corrollary}{corrollary~#2#1#3}
-\Crefformat{corrollary}{Corrollary~#2#1#3}
-\crefformat{proposition}{proposition~#2#1#3}
-\Crefformat{proposition}{Proposition~#2#1#3}
-\crefformat{definition}{definition~#2#1#3}
-\Crefformat{definition}{Definition~#2#1#3}
-\crefformat{result}{result~#2#1#3}
-\Crefformat{result}{Result~#2#1#3}
-\crefrangeformat{lemma}{lemma~#3#1#4--#5#2#6}
-\Crefrangeformat{lemma}{Lemma~#3#1#4--#5#2#6}
-\crefrangeformat{corrollary}{corrollary~#3#1#4--#5#2#6}
-\Crefrangeformat{corrollary}{Corrollary~#3#1#4--#5#2#6}
-\crefrangeformat{proposition}{proposition~#3#1#4--#5#2#6}
-\Crefrangeformat{proposition}{Proposition~#3#1#4--#5#2#6}
-\crefrangeformat{definition}{definition~#3#1#4--#5#2#6}
-\Crefrangeformat{definition}{Definition~#3#1#4--#5#2#6}
-\crefrangeformat{result}{result~#3#1#4--#5#2#6}
-\Crefrangeformat{result}{Result~#3#1#4--#5#2#6}
-\crefmultiformat{lemma}%
- {lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{lemma}%
- {Lemmas~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{corrollary}%
- {corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{corrollary}%
- {Corrollaries~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{proposition}%
- {propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{proposition}%
- {Propositions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{definition}%
- {definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{definition}%
- {Definitions~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefmultiformat{result}%
- {results~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\Crefmultiformat{result}%
- {Results~#2#1#3}{, #2#1#3}{ and~#2#1#3}
-\crefrangemultiformat{lemma}%
- {lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}%
-\Crefrangemultiformat{lemma}%
- {Lemmas~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{corrollary}%
- {corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{corrollary}%
- {Corrollaries~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{proposition}%
- {propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{proposition}%
- {Propositions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{definition}%
- {definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{definition}%
- {Definitions~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\crefrangemultiformat{result}%
- {results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-\Crefrangemultiformat{result}%
- {Results~#3#1#4--#5#2#6}{, #3#1#4--#5#2#6}%
- { and~#3#1#4--#5#2#6}
-} % end of ntheorem option
+\AtBeginDocument{%
+ \@ifundefined{cref@lemma@name}{%
+ \@crefname{cref}{lemma}{lemma}{lemmas}%
+ \@crefname{Cref}{lemma}{Lemma}{Lemmas}}{}%
+ \@ifundefined{cref@corollary@name}{%
+ \@crefname{cref}{corollary}{corollary}{corollaries}%
+ \@crefname{Cref}{corollary}{Corollary}{Corollaries}}{}%
+ \@ifundefined{cref@proposition@name}{%
+ \@crefname{cref}{proposition}{proposition}{propositions}%
+ \@crefname{Cref}{proposition}{Proposition}{Proposition}}{}%
+ \@ifundefined{cref@definition@name}{%
+ \@crefname{cref}{definition}{definition}{definitions}%
+ \@crefname{Cref}{definition}{Definition}{Definitions}}{}%
+ \@ifundefined{cref@result@name}{%
+ \@crefname{cref}{result}{result}{results}%
+ \@crefname{cref}{result}{Result}{Results}}{}%
+ \@ifundefined{cref@lemma@format}{%
+ \@crefdefineformat{lemma}}{}%
+ \@ifundefined{crefrange@lemma@format}{%
+ \@crefrangedefineformat{lemma}}{}%
+ \@ifundefined{cref@lemma@format@first}{%
+ \@crefdefinemultiformat{lemma}}{}%
+ \@ifundefined{crefrange@lemma@format@first}{%
+ \@crefrangedefinemultiformat{lemma}}{}%
+ \@ifundefined{cref@corollary@format}{%
+ \@crefdefineformat{corollary}}{}%
+ \@ifundefined{crefrange@corollary@format}{%
+ \@crefrangedefineformat{corollary}}{}%
+ \@ifundefined{cref@corollary@format@first}{%
+ \@crefdefinemultiformat{corollary}}{}%
+ \@ifundefined{crefrange@corollary@format@first}{%
+ \@crefrangedefinemultiformat{corollary}}{}%
+ \@ifundefined{cref@definition@format}{%
+ \@crefdefineformat{definition}}{}%
+ \@ifundefined{crefrange@definition@format}{%
+ \@crefrangedefineformat{definition}}{}%
+ \@ifundefined{cref@definition@format@first}{%
+ \@crefdefinemultiformat{definition}}{}%
+ \@ifundefined{crefrange@definition@format@first}{%
+ \@crefrangedefinemultiformat{definition}}{}%
+ \@ifundefined{cref@result@format}{%
+ \@crefdefineformat{result}}{}%
+ \@ifundefined{crefrange@result@format}{%
+ \@crefrangedefineformat{result}}{}%
+ \@ifundefined{cref@result@format@first}{%
+ \@crefdefinemultiformat{result}}{}%
+ \@ifundefined{crefrange@result@format@first}{%
+ \@crefrangedefinemultiformat{result}}{}%
+}%
+}{}
\DeclareOption{poorman}{%
\PackageInfo{cleveref}{option `poorman' loaded}
\edef\cref@text{}
@@ -1026,21 +1289,21 @@
\lccode`~=0 \lccode`/=0 \catcode`~=12
\def\cref@text{}%
\immediate\read\@crefscript to \@tmpa%
- \edef\@tmpa{\@tmpa}%
\ifx\@tmpa\@eof%
\@not@eoffalse%
\else%
\@not@eoftrue%
+ \edef\@tmpa{\@tmpa}%
\fi%
\@whilesw\if@not@eof\fi{%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
\@tmpa^^J}%
\immediate\read\@crefscript to \@tmpa%
- \edef\@tmpa{\@tmpa}%
\ifx\@tmpa\@eof%
\@not@eoffalse%
\else%
\@not@eoftrue%
+ \edef\@tmpa{\@tmpa}%
\fi}%
\endgroup%
\immediate\closein\@crefscript%
@@ -1048,54 +1311,103 @@
\lccode`|=92 \lccode`<=123 \lccode`>=125 \lccode`C=67
\lowercase{\edef\@tmpa{s/||usepackage|(|[.*|]|)|?<cleveref>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refformat<.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refrangeformat<.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||[cC]refmultiformat<.*><.*><.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{%
s/||[cC]refrangemultiformat<.*><.*><.*><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refname<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]reflabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refrangelabelformat<.*><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{s/||[cC]refdefaultlabelformat<.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefpairgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddleconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||crefmiddlegroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \lowercase{\edef\@tmpa{%
+ s/||renewcommand<||creflastgroupconjunction><.*>//g}}%
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||renewcommand<||[cC]ref><.*>//g}}%
\expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
- \@tmpa^^J}
+ \@tmpa^^J}%
\lowercase{\edef\@tmpa{s/||renewcommand<||[cC]refrange><.*>//g}}%
- \expandafter\g@addto@macro\expandafter\cref@text\%
- expandafter{\@tmpa}
- \endgroup
+ \expandafter\g@addto@macro\expandafter\cref@text\expandafter{%
+ \@tmpa^^J}%
+ \endgroup%
\newwrite\@crefscript%
\immediate\openout\@crefscript=\jobname.sed%
\immediate\write\@crefscript{\cref@text}%
\immediate\closeout\@crefscript%
-}%
-\renewcommand{\cref}[1]{%
- \edef\cref@text{}%
- \@cref{cref}{#1}%
- \cref@writescript{\string\cref\string{#1\string}}}
-\renewcommand{\Cref}[1]{%
- \edef\cref@text{}%
- \@cref{Cref}{#1}%
- \cref@writescript{\string\Cref\string{#1\string}}}
-\renewcommand{\crefrange}[2]{%
- \edef\cref@text{}%
- \@setcrefrange{#1}{#2}{cref}{}%
- \cref@writescript{%
- \string\crefrange\string{#1\string}\string{#2\string}}}
-\renewcommand{\Crefrange}[2]{%
- \edef\cref@text{}%
- \@setcrefrange{#1}{#2}{Cref}{}%
- \cref@writescript{%
- \string\Crefrange\string{#1\string}\string{#2\string}}}
+}
+\@ifpackageloaded{hyperref}{%
+ \def\@crefnostar#1#2{%
+ \edef\cref@text{}%
+ \@cref{#1}{#2}%
+ \cref@writescript{%
+ \expandafter\string\csname#1\endcsname\string{#2\string}}}
+ \def\@crefrangenostar#1#2#3{%
+ \edef\cref@text{}%
+ \@setcrefrange{#2}{#3}{#1}{}%
+ \cref@writescript{%
+ \expandafter\string\csname#1range\endcsname%
+ \string{#2\string}\string{#3\string}}}%
+}{%
+ \DeclareRobustCommand{\cref}[1]{%
+ \edef\cref@text{}%
+ \@cref{cref}{#1}%
+ \cref@writescript{\string\cref\string{#1\string}}}
+ \DeclareRobustCommand{\Cref}[1]{%
+ \edef\cref@text{}%
+ \@cref{Cref}{#1}%
+ \cref@writescript{\string\Cref\string{#1\string}}}
+ \DeclareRobustCommand{\crefrange}[2]{%
+ \edef\cref@text{}%
+ \@setcrefrange{#1}{#2}{cref}{}%
+ \cref@writescript{%
+ \string\crefrange\string{#1\string}\string{#2\string}}}
+ \DeclareRobustCommand{\Crefrange}[2]{%
+ \edef\cref@text{}%
+ \@setcrefrange{#1}{#2}{Cref}{}%
+ \cref@writescript{%
+ \string\Crefrange\string{#1\string}\string{#2\string}}}%
+}
\def\cref@writescript#1{%
\edef\@tmpa{\cref@getmeaning{\cref@text}}%
- \immediate\write\@crefscript{s/#1/\@tmpa/g}%
-}
+ \immediate\write\@crefscript{s/#1/\@tmpa/g}}
\let\old@@setcref\@@setcref
\let\old@@setcrefrange\@@setcrefrange
\def\cref@getmeaning#1{\expandafter\@cref@getmeaning\meaning#1\@nil}
@@ -1107,19 +1419,24 @@
#1{\ref{#2}}{}{}}}
\def\@@setcrefrange#1#2#3{%
\old@@setcrefrange{#1}{#2}{#3}%
- \expandafter\g@addto@macro
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
\expandafter{#1{\ref{#2}}{\ref{#3}}{}{}{}{}}}
-\def\@setcref@middleconjunction{%
- \crefmiddleconjunction%
- \expandafter\g@addto@macro
+\def\@setcref@pairgroupconjunction{%
+ \crefpairgroupconjunction%
+ \expandafter\g@addto@macro%
+ \expandafter{\expandafter\cref@text\expandafter}%
+ \expandafter{\crefpairgroupconjunction}}
+\def\@setcref@middlegroupconjunction{%
+ \crefmiddlegroupconjunction%
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
- \expandafter{\crefmiddleconjunction}}
-\def\@setcref@lastconjunction{%
- \creflastconjunction%
- \expandafter\g@addto@macro
+ \expandafter{\crefmiddlegroupconjunction}}
+\def\@setcref@lastgroupconjunction{%
+ \creflastgroupconjunction%
+ \expandafter\g@addto@macro%
\expandafter{\expandafter\cref@text\expandafter}%
- \expandafter{\creflastconjunction}}
+ \expandafter{\creflastgroupconjunction}}
} % end of poorman option
\ProcessOptions\relax
\endinput