summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/cleveref
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2009-11-29 00:16:18 +0000
committerKarl Berry <karl@freefriends.org>2009-11-29 00:16:18 +0000
commit5ef2df8bfda41900423878ffa05270a76986718b (patch)
tree8be6bef569e9dc7980d7dceb974c77e989faf7dc /Master/texmf-dist/source/latex/cleveref
parent3cdbe4e7f17003d536fd9880ef7a1873e1b9be87 (diff)
cleveref 0.15 (28nov09)
git-svn-id: svn://tug.org/texlive/trunk@16225 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/cleveref')
-rw-r--r--Master/texmf-dist/source/latex/cleveref/cleveref.dtx185
1 files changed, 141 insertions, 44 deletions
diff --git a/Master/texmf-dist/source/latex/cleveref/cleveref.dtx b/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
index 8e4cf481010..4909c95ac0d 100644
--- a/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
+++ b/Master/texmf-dist/source/latex/cleveref/cleveref.dtx
@@ -21,7 +21,7 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{cleveref}
-%<package> [2009/09/22 v0.14.2 Intelligent cross-referencing]
+%<package> [2009/11/26 v0.15 Intelligent cross-referencing]
%
%<*driver>
%\documentclass{ltxdoc}
@@ -62,7 +62,7 @@
%</driver>
% \fi
%
-% \CheckSum{7724}
+% \CheckSum{7845}
%% \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
@@ -132,12 +132,19 @@
% in \option{poorman} when used without babel. \option{capitalise}
% option no longer uses \textbackslash{}Cref variant everywhere; it now
% redefines the \textbackslash{}cref variants instead.}
+% \changes{v0.14.3}{2009/10/17}{Bug-fix in \textbackslash{}appendix
+% code.}
+% \changes{v0.15}{2009/11/26}{Added \package{amsthm} support, contributed
+% by Michael Ummels. Added \textbackslash{}leavevmode before
+% \textbackslash{}begingroup in \textbackslash{}@cref to avoid subtle
+% bug that caused page count to be reset if the output routine was
+% triggered within \textbackslash{}@cref.}
%
%
% \GetFileInfo{cleveref.sty}
%
-% \def\fileversion{0.14.2}
-% \def\filedate{22/09/2009}
+% \def\fileversion{0.15}
+% \def\filedate{26/11/2009}
%
% \title{The \package{cleveref} package\thanks{This document
% corresponds to \textsf{cleveref}~\fileversion, dated
@@ -166,26 +173,25 @@
%
% \section{Introduction}
% When ``clever'' is used in the name of a computer program, it 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
+% signifies that the programmer is overly smug about his own
+% achievements! But 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.
+% the computer, in order to achieve a beautiful --- and above all
+% consistent --- visual appearance.
%
-% Both these points of view are probably valid when it comes to the
-% \package{cleveref} package. Its goals are two-fold: to use the
-% information that \LaTeX{} inherently has about labels as intelligently
-% as possible when type-setting cross-references to them (clever
-% processing); and to enable you to produce an attractive, consistent
-% formatting of cross-references throughout your document, with the
-% minimum of effort (you'd be clever to use it!).
+% Both these probably apply to the \package{cleveref} package. Its goals
+% are two-fold: to exploit everything that \LaTeX{} inherently knows
+% about labels as intelligently as possible (clever processing); and to
+% enable you to produce an attractive, consistent formatting of
+% cross-references throughout your document, with the minimum of effort
+% (you'd be clever to use it!).
%
% The \package{cleveref} package enhances \LaTeX{}'s cross-referencing
% facilities by allowing cross-references to be formatted automatically
% according to the type of thing they refer to (chapter, section,
% equation, theorem, etc.) and the context in which the cross-reference
-% is used. It can also automatically format cross-references to multiple
-% labels, sort lists of multiple cross-references, compres
+% is used. It can automatically format cross-references to multiple
+% labels, sort lists of multiple cross-references, compress
% cross-references to consecutive labels into a reference range, and all
% kinds of other clever wizardry.
%
@@ -193,10 +199,17 @@
% things like |Eq.~(\ref{eq1})| and |Theorems~\ref{thm1} to~\ref{thm3}|
% over and over again. Tedium isn't the only downside to this. What
% happens if you later decide you want equation references to be type-set
-% as |Equation~\ref{eq1}| instead? What happens if you decide to change
-% the theorem labelled |thm1| into a lemma? You have to search through
-% the entire \LaTeX{} source of your document, modifying all references
-% to equations, and changing all references to |thm1|.
+% as |Equation~\ref{eq1}| instead (i.e.\ without the brackets)? What
+% happens if you decide to change the theorem labelled |thm1| into a
+% lemma? What if you move |thm3| so that it appears (and is numbered)
+% before |thm1|, so that references to both should be ordered
+% |Theorems~\ref{thm3} to~\ref{thm1}| (i.e.\ the other way around)? What
+% if you decide you prefer references to multiple theorems to be written
+% as |Theorems~\ref{thm1}--\ref{thm3}|? You have to search through the
+% entire \LaTeX{} source of your document, modifying all references to
+% equations, updating all references to |thm1|, re-ordering all
+% references to |thm1| and |thm3|, and changing the formatting of all
+% references to multiple theorems.
%
% The \package{cleveref} package allows you to define the format for
% cross-references once-and-for-all in the preamble of your document. If
@@ -206,7 +219,7 @@
% \package{cleveref} will automatically type-set cross-references to it
% using the appropriate formatting. This makes it far easier to type-set
% cross-references uniformly across your whole document, as well as
-% avoiding repetitively typing the same text for each and every
+% avoiding repetitively typing similar text for each and every
% cross-reference.
%
% Given how useful this is, there are naturally a number of other
@@ -549,11 +562,11 @@
% \DescribeMacro\crefrangepreconjunction
% \DescribeMacro\crefrangepostconjunction
% There are two other ``conjunction'' commands available for customizing
-% the formatn for reference ranges. These are |\crefrangepreconjunction|
-% and |\crefrangepostconjunction|, which insert text before the first
-% label defining the range, and after the second label, respectively. For
-% example, when these commands are defined, |\crefrange{thm1}{thm2}| is
-% type-set as
+% the formating for reference ranges. These are
+% |\crefrangepreconjunction| and |\crefrangepostconjunction|, which
+% insert text before the first label defining the range, and after the
+% second label, respectively. For example, when these commands are
+% defined, |\crefrange{thm1}{thm2}| is type-set as
% \begin{quote}
% |theorems~\crefrangepreconjunction\ref{thm1}|\\
% | |\ding{229} |\crefrangeconjunction\ref{thm2}\crefrangepostconjunction|
@@ -591,17 +604,18 @@
%
% \DescribeMacro\crefpairgroupconjunction
% \DescribeMacro\crefmiddlegroupconjunction
-% \DescribeMacro\creflastgroupconjunction By default, the conjunctions
-% used to separate sub-lists of different cross-reference types in a
-% multi-reference are identical to those used to separate
-% cross-references of the same type\footnote{More accurately, if you
-% redefine $\backslash$crefpairconjunction etc.\ in your preamble,
-% $\backslash$crefpairgroupconjunction etc.\ are automatically
-% redefined so that they match. (In some languages, the default
-% definition of $\backslash$creflastgroupconjunction has an additional
-% comma lacking in $\backslash$creflastconjunction.)}. You can override
-% this by defining the conjunction commands |\crefpairgroupconjunction|,
-% |\crefmiddlegroupconjunction| and |\creflastgroupconjunction|.
+% \DescribeMacro\creflastgroupconjunction
+% By default, the conjunctions used to separate sub-lists of different
+% cross-reference types in a multi-reference are identical to those used
+% to separate cross-references of the same type\footnote{More accurately,
+% if you redefine $\backslash$crefpairconjunction etc.\ in your
+% preamble, $\backslash$crefpairgroupconjunction etc.\ are
+% automatically redefined so that they match. (In some languages, the
+% default definition of $\backslash$creflastgroupconjunction has an
+% additional comma lacking in $\backslash$creflastconjunction.)}. You
+% can override this by defining the conjunction commands
+% |\crefpairgroupconjunction|, |\crefmiddlegroupconjunction| and
+% |\creflastgroupconjunction|.
%
% For example,
% \begin{quote}
@@ -1236,7 +1250,6 @@
% \end{itemize}
%
%
-%
% \subsection{Possible Improvements}
% In no particular order:
% \begin{itemize}
@@ -1253,6 +1266,21 @@
%
%
%
+% \section{Thanks}
+% A number of people have helped improve \package{cleveref} by
+% contributing code and translations. Thanks to Michael Ummels for
+% contributing the \package{amsthm} support code, and to Stefan Pinnow,
+% Gonzalo Medina and Massimo Redaelli for contributing translations. Many
+% people have suggested improvements or reported bugs, indeed many have
+% spent significant effort in helping to investigate and fix them. So
+% thanks (in alphabetical order) to: Anand Deopurkar, Bas Ploeger, Dan
+% Luecking, David Gleich, Donald Arsenau, Hendrik Maryns, Jens Mueller,
+% Joel C. Salomon, Joris Pinkse, Leo Shidai Liu, Lev Bishop, Matej Batic,
+% Matthew Skala, Michael Gorven, Olivier Roy, Paul Gomme, Ricardo de
+% Aldama S\'anchez, Stefan Pinnow, Ted Pavlic, and Uwe L\"uck for their
+% help. (If I missed someone, please let me know!)
+%
+%
% \StopEventually{\clearpage\PrintChanges\clearpage\PrintIndex}
%
%
@@ -1465,7 +1493,7 @@
% references to anything in appendices to be sorted after everything
% else.
% \begin{macrocode}
- \edef\@result{{2147483647}\@result}%
+ \edef\@result{2147483647,\@result}%
% \end{macrocode}
% Override the cross-reference type of sectioning commands.
% \begin{macrocode}
@@ -1501,7 +1529,7 @@
% Again, the large value added to the front of the counter data forces
% references to appendix items to be sorted last.
% \begin{macrocode}
- \edef\@result{{2147483647}\@result}%
+ \edef\@result{2147483647,\@result}%
% \end{macrocode}
% Override the cross-reference type of sectioning commands.
% \begin{macrocode}
@@ -2475,6 +2503,7 @@
% compressing consecutive references into ranges.
% \begin{macrocode}
\def\@cref#1#2{%
+ \leavevmode%
\begingroup%
% \end{macrocode}
% Initialise some things, and put all the references into a stack called
@@ -3726,7 +3755,7 @@
% references to anything in appendices to be sorted after
% everything else.
% \begin{macrocode}
- \edef\@result{{2147483647}\@result}%
+ \edef\@result{2147483647,\@result}%
% \end{macrocode}
% Override the cross-reference type of sectioning commands.
% \begin{macrocode}
@@ -3765,7 +3794,7 @@
% Again, the large value added to the front of the counter data
% forces references to appendix items to be sorted last.
% \begin{macrocode}
- \edef\@result{{2147483647}\@result}%
+ \edef\@result{2147483647,\@result}%
% \end{macrocode}
% Override the cross-reference type of sectioning commands.
% \begin{macrocode}
@@ -3951,9 +3980,77 @@
\advance\@totalleftmargin \theorem@indent%
\parshape \@ne \@totalleftmargin \linewidth%
\@ifnextchar[{\@ythm{#1}{#2}{#3}}{\@xthm{#1}{#2}{#3}}%]
- }}{}% end of \@ifpackageloaded
+ }
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
+%
+% \subsection{\package{amsthm} Support}
+% \begin{macro}{amsthm}
+% \begin{macro}{\@thm}
+% If \package{amsthm} is loaded, we need to modify its theorem
+% referencing features so that they work with \package{cleveref}.
+% \begin{macrocode}
+ \@ifpackageloaded{amsthm}{%
+ \PackageInfo{cleveref}{`amsthm' support loaded}
+% We modify \package{amsthm}'s version of the \cmd{\@thm} macro very
+% slightly, to have it call \cmd{\refstepcounter} with an optional
+% argument containing the theorem type.
+% \begin{macrocode}
+\let\@thmnoarg\@thm
+\def\@thm{\@ifnextchar[{\@thmoptarg}{\@thmnoarg}}%]
+\def\@thmoptarg[#1]#2#3#4{%
+ \ifhmode\unskip\unskip\par\fi
+ \normalfont
+ \trivlist
+ \let\thmheadnl\relax
+ \let\thm@swap\@gobble
+ \thm@notefont{\fontseries\mddefault\upshape}%
+ \thm@headpunct{.}% add period after heading
+ \thm@headsep 5\p@ plus\p@ minus\p@\relax
+ \thm@space@setup
+ #2% style overrides
+ \@topsep \thm@preskip % used by thm head
+ \@topsepadd \thm@postskip % used by \@endparenv
+ \def\@tempa{#3}\ifx\@empty\@tempa
+ \def\@tempa{\@oparg{\@begintheorem{#4}{}}[]}%
+ \else
+ \refstepcounter[#1]{#3}%
+ \def\@tempa{\@oparg{\@begintheorem{#4}{\csname the#3\endcsname}}[]}%
+ \fi
+ \@tempa}
% \end{macrocode}
% \end{macro}
+%
+% \begin{macro}{\@ynthm}
+% We also have to modify \package{amsthm}'s \cmd{\@ynthm} command so
+% that it passes the optional argument to \cmd{\@thm}.
+% \begin{macrocode}
+\def\@ynthm#1[#2]#3{%
+ \ifx\relax#2\relax
+ \def\@tempa{\@oparg{\@xthm{#1}{#3}}[]}%
+ \else
+ \@ifundefined{c@#2}{%
+ \def\@tempa{\@nocounterr{#2}}%
+ }{%
+ \@xp\xdef\csname the#1\endcsname{\@xp\@nx\csname the#2\endcsname}%
+ \toks@{#3}%
+ \@xp\xdef\csname#1\endcsname{%
+ \@nx\@thm[#1]{% <<<<< new optional argument for theorem name
+ \let\@nx\thm@swap
+ \if S\thm@swap\@nx\@firstoftwo\else\@nx\@gobble\fi
+ \@xp\@nx\csname th@\the\thm@style\endcsname}%
+ {#2}{\the\toks@}}%
+ \let\@tempa\relax
+ }%
+ \fi
+ \@tempa}
+ }{}% end of \@ifpackageloaded
+% \end{macrocode}
% \end{macro}
% \end{macro}
%