diff options
author | Karl Berry <karl@freefriends.org> | 2010-06-09 22:20:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2010-06-09 22:20:52 +0000 |
commit | ade959d5f7adbbef896062a4245725f1369e1b1f (patch) | |
tree | 6890ee291e0535e02d4ff77abd23a5cf802e4f76 /Master/texmf-dist/source/latex | |
parent | 4b653b7509fc5880c21ce05b56562dda6e8e12f2 (diff) |
thmtools update (9jun10)
git-svn-id: svn://tug.org/texlive/trunk@18850 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex')
10 files changed, 225 insertions, 73 deletions
diff --git a/Master/texmf-dist/source/latex/thmtools/thm-amsthm.dtx b/Master/texmf-dist/source/latex/thmtools/thm-amsthm.dtx index cd61adfbe21..7ff3b98249d 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-amsthm.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-amsthm.dtx @@ -134,6 +134,19 @@ }% } +\def\thmt@amsthmlistbreakhack{% + \leavevmode + \vspace{-\baselineskip}% + \par + \everypar{\setbox\z@\lastbox\everypar{}}% +} + +\define@key{thmuse}{listhack}[\relax]{% + \addtotheorempostheadhook[local]{% + \thmt@amsthmlistbreakhack + }% +} + % \end{macrocode} %\iffalse (hide this from DocInput) %</amsthm> diff --git a/Master/texmf-dist/source/latex/thmtools/thm-autoref.dtx b/Master/texmf-dist/source/latex/thmtools/thm-autoref.dtx index 0d8a23dc010..ea775854de8 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-autoref.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-autoref.dtx @@ -97,11 +97,22 @@ \AtBeginDocument{% \@ifpackageloaded{nameref}{% \addtotheorempostheadhook{% - \expandafter\NR@gettitle\expandafter{\thmt@optarg}% + \expandafter\NR@gettitle\expandafter{\thmt@shortoptarg}% }}{} } - +\AtBeginDocument{% + \@ifpackageloaded{cleveref}{% + \@ifpackagelater{cleveref}{2010/04/30}{% + % OK, new enough + }{% + \PackageWarningNoLine{thmtools}{% + Your version of cleveref is too old!\MessageBreak + Update to version 0.16.1 or later% + } + } + }{} +} % \end{macrocode} %\iffalse %</autoref> diff --git a/Master/texmf-dist/source/latex/thmtools/thm-beamer.dtx b/Master/texmf-dist/source/latex/thmtools/thm-beamer.dtx index 8ac7adba100..7c56099ce69 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-beamer.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-beamer.dtx @@ -12,7 +12,9 @@ \def\thmt@parsetheoremargs#1{% \parse{% {\parseOpt<>{\thmt@hasoverlaytrue\def\thmt@overlay{##1}}{}}% - {\parseOpt[]{\def\thmt@optarg{##1}}{\let\thmt@optarg\@empty}}% + {\parseOpt[]{\def\thmt@optarg{##1}}{% + \let\thmt@shortoptarg\@empty + \let\thmt@optarg\@empty}}% {\ifthmt@hasoverlay\expandafter\@gobble\else\expandafter\@firstofone\fi {\parseOpt<>{\thmt@hasoverlaytrue\def\thmt@overlay{##1}}{}}% }% diff --git a/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx b/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx index a1aa79fbc29..fb1dc723eac 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-kv.dtx @@ -20,6 +20,51 @@ \let\@nx\noexpand \RequirePackage{keyval,kvsetkeys,thm-patch} +% useful key handler defaults. +\newcommand\thmt@mkignoringkeyhandler[1]{% + \kv@set@family@handler{#1}{% + \thmt@debug{Key `##1' with value `##2' ignored by #1.}% + }% +} +\newcommand\thmt@mkextendingkeyhandler[3]{% +% #1: family +% #2: prefix for file +% #3: key hint for error + \kv@set@family@handler{#1}{% + \thmt@selfextendingkeyhandler{#1}{#2}{#3}% + {##1}{##2}% + }% +} + +\newcommand\thmt@selfextendingkeyhandler[5]{% + % #1: family + % #2: prefix for file + % #3: key hint for error + % #4: actual key + % #5: actual value + \IfFileExists{#2-#4.sty}{% + \PackageInfo{thmtools}% + {Automatically pulling in `#2-#4'}% + \RequirePackage{#2-#4}% + \ifcsname KV@#1@#4\endcsname + \csname KV@#1@#4\endcsname{#5}% + \else + \PackageError{thmtools}% + {#3 `#4' not known} + {I don't know what that key does.\MessageBreak + I've even loaded the file `#2-#4.sty', but that didn't help. + }% + \fi + }{% + \PackageError{thmtools}% + {#3 `#4' not known} + {I don't know what that key does by myself,\MessageBreak + and no file `#2-#4.sty' to tell me seems to exist. + }% + }% +} + + \newif\if@thmt@firstkeyset % many keys are evaluated twice, because we don't know @@ -93,7 +138,7 @@ \csname thmt@style #1@defaultkeys\endcsname}% \fi } -\kv@set@family@handler{thmdef0}{}% ignore everything else. +\thmt@mkignoringkeyhandler{thmdef0} % fallback definition. % actually, only the kernel does not provide \theoremstyle. @@ -159,6 +204,7 @@ \kvsetkeys{thmdef0}{#1}% \kvsetkeys{thmdef}{#1}% } +\@onlypreamble\declaretheorem \providecommand\thmt@quark{\thmt@quark} @@ -170,30 +216,28 @@ \ifx\thmt@optarg\@empty\else \@xa\thmt@garbleoptarg\@xa{\thmt@optarg}\fi }% + +\newif\ifthmt@thmuse@iskv + \providecommand\thmt@garbleoptarg[1]{% - \thmt@splitopt#1=\thmt@quark - \ifcsname KV@thmuse@\thmt@tmpkey\endcsname - % looks like a keyval-style argument - \PackageInfo{thmtools}{kv-style argument to `\thmt@envname'} - %\typeout{dbg: new-style arg `#1'}% - \let\thmt@newoptarg\@empty - \kvsetkeys{thmuse}{#1}% - \let\thmt@optarg\thmt@newoptarg - %\else - % \typeout{dbg: old-style arg `#1'}% + \thmt@thmuse@iskvfalse + \def\thmt@newoptarg{\@gobble}% + \def\thmt@newoptargextra{}% + \def\thmt@warn@unusedkeys{}% + \@for\thmt@fam:=\thmt@thmuse@families\do{% + \kvsetkeys{\thmt@fam}{#1}% + }% + \ifthmt@thmuse@iskv + \protected@edef\thmt@optarg{% + \@xa\thmt@newoptarg + \thmt@newoptargextra\@empty + }% + \protected@edef\thmt@shortoptarg{\thmt@newoptarg\@empty}% + \thmt@warn@unusedkeys + \else + \def\thmt@optarg{#1}% + \def\thmt@shortoptarg{#1}% \fi -% % optarg present, check if it's newstyle -% % a newstyle kv args starts with =. -% %\tracingall -% \if\expandafter\noexpand\@car #1\@nil= -% \let\thmt@newoptarg\@empty -% \@xa\def\@xa\thmt@optarg\@xa{\@cdr #1\@nil}% -% \def\thmt@tempa{\setkeys{thmt-optarg}}% -% \@xa\thmt@tempa\@xa{\thmt@optarg}% expansion! -% \let\thmt@optarg\thmt@newoptarg -% \else -% \typeout{(dbg: old-style arg `#1')}% -% \fi } \def\thmt@splitopt#1=#2\thmt@quark{% \def\thmt@tmpkey{#1}% @@ -203,13 +247,32 @@ \@onelevel@sanitize\thmt@tmpkey } -\define@key{thmuse}{label}{% - %\typeout{setting label: #1}% +\def\thmt@thmuse@families{thm@track@keys} + +\kv@set@family@handler{thm@track@keys}{% + \@onelevel@sanitize\kv@key + \@namedef{thmt@unusedkey@\kv@key}{% + \PackageWarning{thmtools}{Unused key `#1'}% + }% + \@xa\g@addto@macro\@xa\thmt@warn@unusedkeys\@xa{% + \csname thmt@unusedkey@\kv@key\endcsname + } +} + +% key, code. +\def\thmt@define@thmuse@key#1#2{% + \g@addto@macro\thmt@thmuse@families{,#1}% + \define@key{#1}{#1}{\thmt@thmuse@iskvtrue + \@namedef{thmt@unusedkey@#1}{}% + #2}% + \thmt@mkignoringkeyhandler{#1}% +} + +\thmt@define@thmuse@key{label}{% \addtotheorempostheadhook[local]{\label{#1}}% } -\define@key{thmuse}{name}{% - %\typeout{optarg: #1}% - \def\thmt@newoptarg{#1}% +\thmt@define@thmuse@key{name}{% + \def\thmt@newoptarg{#1\@iden}% } % \end{macrocode} @@ -231,6 +294,7 @@ \kvsetkeys{thmstyle}{#1}% \thmt@declaretheoremstyle{#2}% } +\@onlypreamble\declaretheoremstyle \kv@set@family@handler{thmstyle}{% \PackageInfo{thmtools}{% diff --git a/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx b/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx index 85790f4eac6..c10c81d817f 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-listof.dtx @@ -79,6 +79,11 @@ \def\contentsline##1{% \csname thmt@contentsline@##1\endcsname{##1}% }% + \@for\thmt@envname:=\thmt@allenvs\do{% + \@xa\protected@edef\csname l@\thmt@envname\endcsname{% CHECK: why p@edef? + \@nx\@dottedtocline{1}{1.5em}{\@nx\thmt@listnumwidth}% + }% + }% \let\thref@starttoc\@starttoc \def\@starttoc##1{\thref@starttoc{loe}}% % new hack: to allow multiple calls, we defer the opening of the @@ -94,7 +99,8 @@ }{}% \fi }% - \expandafter\listoffigures + %\expandafter + \listoffigures \egroup } @@ -120,13 +126,13 @@ \@xa\def\csname ll@\thmt@envname\endcsname{% \protect\numberline{\protect\let\protect\autodot\protect\@empty}% \thmt@thmname - \ifx\@empty\thmt@optarg\else\protect\thmtformatoptarg{\thmt@optarg}\fi + \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi }% \else \@xa\def\csname ll@\thmt@envname\endcsname{% \protect\numberline{\csname the\thmt@envname\endcsname}% \thmt@thmname - \ifx\@empty\thmt@optarg\else\protect\thmtformatoptarg{\thmt@optarg}\fi + \ifx\@empty\thmt@shortoptarg\else\protect\thmtformatoptarg{\thmt@shortoptarg}\fi }% \fi \@xa\gdef\csname thmt@contentsline@\thmt@envname\endcsname{% diff --git a/Master/texmf-dist/source/latex/thmtools/thm-ntheorem.dtx b/Master/texmf-dist/source/latex/thmtools/thm-ntheorem.dtx index 0e62613fa6d..09f528cb001 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-ntheorem.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-ntheorem.dtx @@ -61,7 +61,13 @@ } % sorry, only style, not def with ntheorem. \define@key{thmstyle}{qed}[\qedsymbol]{% - \theoremsymbol{#1}% + \@ifpackagewith{ntheorem}{thmmarks}{% + \theoremsymbol{#1}% + }{% + \thmt@notsupported + {ntheorem without thmmarks option}% + {headindent}% + }% } \let\@upn=\textup diff --git a/Master/texmf-dist/source/latex/thmtools/thm-patch.dtx b/Master/texmf-dist/source/latex/thmtools/thm-patch.dtx index 9b0c03d1ef7..3cb6a6fcd1d 100644 --- a/Master/texmf-dist/source/latex/thmtools/thm-patch.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thm-patch.dtx @@ -53,7 +53,9 @@ \def\thmt@parsetheoremargs#1{% \parse{% - {\parseOpt[]{\def\thmt@optarg{##1}}{\let\thmt@optarg\@empty}}% + {\parseOpt[]{\def\thmt@optarg{##1}}{% + \let\thmt@shortoptarg\@empty + \let\thmt@optarg\@empty}}% {% \def\thmt@local@preheadhook{}% \def\thmt@local@postheadhook{}% @@ -66,9 +68,11 @@ \ifx\@empty\thmt@optarg\else [{\thmt@optarg}]\fi }% \csname thmt@original@#1\@xa\endcsname\tmp@args - \thmt@local@postheadhook + %%moved down: \thmt@local@postheadhook + %% (give postheadhooks a chance to re-set nameref data) \csname thmt@#1@postheadhook\endcsname \thmt@generic@postheadhook + \thmt@local@postheadhook \let\@parsecmd\@empty }% }% diff --git a/Master/texmf-dist/source/latex/thmtools/thmdef-shaded.dtx b/Master/texmf-dist/source/latex/thmtools/thmdef-shaded.dtx index 55559b3a1f8..f7f78050673 100644 --- a/Master/texmf-dist/source/latex/thmtools/thmdef-shaded.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thmdef-shaded.dtx @@ -7,6 +7,11 @@ %\iffalse (hide this from DocInput) %<*shaded> %\fi +% +% Mostly, this key wraps the theorem in a shadebox environment. +% The parameters are set by treating the value we are given as +% a new key-val list, see below. +% % \begin{macrocode} \define@key{thmdef}{shaded}[{}]{% \thmt@trytwice{}{% @@ -18,23 +23,44 @@ \addtotheorempostfoothook[\thmt@envname]{\end{shadebox}}% }% } +% \end{macrocode} +% The docs for shadethm say: +% \begin{quote} % There are some parameters you could set the default for (try them as is, % first). -% (i) shadethmcolor The shading color of the background. See the +% \begin{itemize} +% \item shadethmcolor The shading color of the background. See the % documentation for the color package, but with a `gray' model, I find .97 % looks good out of my printer, while a darker shade like .92 is needed % to make it copy well. (Black is 0, white is 1.) -% (i*) shaderulecolor The shading color of the border of the shaded box. -% See (i). If \shadeboxrule is set to 0pt then this won't print anyway. -% (i**) shadeboxrule The width of the border around the shading. Set it to +% \item shaderulecolor The shading color of the border of the shaded box. +% See (i). If shadeboxrule is set to 0pt then this won't print anyway. +% \item shadeboxrule The width of the border around the shading. Set it to % 0pt (not just 0) to make it disappear. -% (i***) shadeboxsep The length by which the shade box surrounds the text. +% \item shadeboxsep The length by which the shade box surrounds the text. +% \end{itemize} +% \end{quote} +% +% So, let's just define keys for all of these. +% +% \begin{macrocode} \define@key{thmt@shade}{textwidth}{\setlength\shadedtextwidth{#1}} \define@key{thmt@shade}{bgcolor}{\thmt@definecolor{shadethmcolor}{#1}} \define@key{thmt@shade}{rulecolor}{\thmt@definecolor{shaderulecolor}{#1}} \define@key{thmt@shade}{rulewidth}{\setlength\shadeboxrule{#1}} \define@key{thmt@shade}{margin}{\setlength\shadeboxsep{#1}} - +% \end{macrocode} +% +% What follows is wizardry you don't have to understand. In essence, +% we want to support two notions of color: one is ``everything that goes +% after \lstinline|\definecolor{shadethmcolor}|'', such as +% \lstinline|{rgb}{0.8,0.85,1}|. On the other hand, we'd also like +% to recognize an already defined color name such as \lstinline|blue|. +% +% To handle the latter case, we need to copy the definition of one color +% into another. The xcolor package offers \lstinline|\colorlet| for that, +% for the color package, we just cross our fingers. +% \begin{macrocode} \def\thmt@colorlet#1#2{% %\typeout{don't know how to let color `#1' be like color `#2'!}% \@xa\let\csname\string\color@#1\@xa\endcsname @@ -46,7 +72,25 @@ \let\thmt@colorlet\colorlet \fi } - +% \end{macrocode} +% Now comes the interesting part: we assume that a simple color name +% must not be in braces, and a color definition starts with an opening +% curly brace. (So, if \lstinline|\definecolor| ever gets an optional arg, +% we are in a world of pain.) +% +% If the second argument to \lstinline|\thmt@definecolor| (the key) starts +% with a brace, +% then \lstinline|\thmt@def@color| will have an empty second argument, +% delimited by the brace of the key. Hopefully, the key will have exactly +% enough arguments to satisfy \lstinline|\definecolor|. Then, +% \lstinline|thmt@drop@relax| will be executed and gobble the fallback +% values and the \lstinline|\thmt@colorlet|. +% +% If the key does not contain an opening brace, \lstinline|\thmt@def@color| +% will drop everything up to \lstinline|{gray}{0.5}|. So, first the color +% gets defined to a medium gray, but then, it immediately gets overwritten +% with the definition corresponding to the color name. +% \begin{macrocode} \def\thmt@drop@relax#1\relax{} \def\thmt@definecolor#1#2{% \thmt@def@color{#1}#2\thmt@drop@relax diff --git a/Master/texmf-dist/source/latex/thmtools/thmdef-thmbox.dtx b/Master/texmf-dist/source/latex/thmtools/thmdef-thmbox.dtx index 8da999bfdaa..ea22cbae977 100644 --- a/Master/texmf-dist/source/latex/thmtools/thmdef-thmbox.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thmdef-thmbox.dtx @@ -7,8 +7,17 @@ %\iffalse (hide this from DocInput) %<*thmbox> %\fi +% The thmbox package does something else: instead of having a separate +% environment, we have to use a command different from +% \lstinline|\newtheorem| to get the boxed style. Fortunately, +% \thmtools stores the command as \lstinline|\thmt@theoremdefiner|, so we +% can modify it. (One of the perks if extension writer and framework writer +% are the same person.) So, in contrast to the previous example, this time +% we need to do something before the actual \lstinline|\newtheorem| is +% called. % \begin{macrocode} \define@key{thmdef}{thmbox}[L]{% + \thmt@trytwice{% \let\oldproof=\proof \let\oldendproof=\endproof \let\oldexample=\example @@ -19,6 +28,7 @@ \let\example=\oldexample \let\endexample=\oldendexample \def\thmt@theoremdefiner{\newboxtheorem[#1]}% + }{}% }% % \end{macrocode} %\iffalse (hide this from DocInput) diff --git a/Master/texmf-dist/source/latex/thmtools/thmtools.dtx b/Master/texmf-dist/source/latex/thmtools/thmtools.dtx index 0cb1696e9ff..80782f0fb76 100644 --- a/Master/texmf-dist/source/latex/thmtools/thmtools.dtx +++ b/Master/texmf-dist/source/latex/thmtools/thmtools.dtx @@ -28,45 +28,23 @@ %<*thmtools> %\fi % \begin{macrocode} +\DeclareOption{debug}{% + \def\thmt@debug{\typeout}% +} % common abbreviations and marker macros. \let\@xa\expandafter \let\@nx\noexpand +\def\thmt@debug{\@gobble} \def\thmt@quark{\thmt@quark} \newtoks\thmt@toks +\ProcessOptions\relax % a scratch counter, mostly for fake hyperlinks \newcounter{thmt@dummyctr}% \def\theHthmt@dummyctr{dummy.\arabic{thmt@dummyctr}}% \def\thethmt@dummyctr{}% -\newcommand\thmt@mkextendingkeyhandler[3]{% -% #1: family -% #2: prefix for file -% #3: key hint for error - \kv@set@family@handler{#1}{% - \IfFileExists{#2-##1.sty}{% - \PackageInfo{thmtools}% - {Automatically pulling in `#2-##1'}% - \RequirePackage{#2-##1}% - \ifcsname KV@#1@##1\endcsname - \csname KV@#1@##1\endcsname{##2}% - \else - \PackageError{thmtools}% - {#3 `##1' not known} - {I don't know what that key does.\MessageBreak - I've even loaded the file `#2-##1.sty', but that didn't help. - }% - \fi - }{% - \PackageError{thmtools}% - {#3 `##1' not known} - {I don't know what that key does by myself,\MessageBreak - and no file `#2-##1.sty' to tell me seems to exist. - }% - }% - } -} \RequirePackage{thm-patch, thm-kv, thm-autoref, thm-listof, @@ -75,10 +53,24 @@ % Glue code for the big players. \@ifpackageloaded{amsthm}{% \RequirePackage{thm-amsthm} -}{} +}{% + \AtBeginDocument{% + \@ifpackageloaded{amsthm}{% + \PackageWarningNoLine{thmtools}{% + amsthm loaded after thmtools + }{}% + }}% +} \@ifpackageloaded{ntheorem}{% \RequirePackage{thm-ntheorem} -}{} +}{% + \AtBeginDocument{% + \@ifpackageloaded{ntheorem}{% + \PackageWarningNoLine{thmtools}{% + ntheorem loaded after thmtools + }{}% + }}% +} \@ifclassloaded{beamer}{% \RequirePackage{thm-beamer} }{} |