From 48c669283bcfe3ab1b61b37bced62cd3ef0bc7b5 Mon Sep 17 00:00:00 2001 From: mdw Date: Sat, 6 Sep 2003 11:25:54 +0000 Subject: [PATCH] Allow configuration of theorem numbering. --- mdwthm.dtx | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/mdwthm.dtx b/mdwthm.dtx index f7ddba5..c90ca23 100644 --- a/mdwthm.dtx +++ b/mdwthm.dtx @@ -1,6 +1,6 @@ % \begin{meta-comment} % -% $Id: mdwthm.dtx,v 1.3 2003/09/05 16:16:20 mdw Exp $ +% $Id: mdwthm.dtx,v 1.4 2003/09/06 11:25:54 mdw Exp $ % % Standard theorem typesetting % @@ -9,6 +9,9 @@ %----- Revision history ----------------------------------------------------- % % $Log: mdwthm.dtx,v $ +% Revision 1.4 2003/09/06 11:25:54 mdw +% Allow configuration of theorem numbering. +% % Revision 1.3 2003/09/05 16:16:20 mdw % Various nips and tucks. Redefine theorem styles from scratch now. % @@ -50,7 +53,7 @@ %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style] % \end{meta-comment} % -% \CheckSum{187} +% \CheckSum{203} %% \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 @@ -115,6 +118,13 @@ % \env{proof} environment then it uses your symbol; otherwise it adds its own % at the end. % +% \subsection{Options} +% +% The package takes an option \syntax{"within="} -- number theorems +% within \. If this isn't given, a default is chosen -- either +% numbering in chapters, or global numbering. The \lit*{notwithin} option +% forces global numbering. +% % \subsection{The \package{mdwmargin} style} % % This package also provides a pretty `number-hanging-in-the-margin' theorem @@ -128,8 +138,23 @@ % % \begin{macrocode} %<*package> -\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsthm}} -\ProcessOptions\relax +\RequirePackage{mdwkey} +\if1% + \ifx\if@article\iftrue0 + \else\ifx\chapter\@@undefined0 + \else\ifx\chapter\relax0 + \else1\fi\fi\fi + \def\mt@within{[chapter]} +\else + \def\mt@within{} +\fi +\mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}} +\mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}} +\mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}} +\mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}} +\def\mt@opt#1{\mkparse{mdwthm:opt}{#1}} +\DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}} +\ProcessOptions \RequirePackage{amsthm} % \end{macrocode} % @@ -140,13 +165,7 @@ % Do the right thing with the numbering rules. % % \begin{macrocode} -\toks@{\newtheorem{theorem}{Theorem}} -\@tempswatrue% -\ifx\if@article\iftrue\@tempswafalse\fi -\ifx\chapter\@@undefined\@tempswafalse\fi -\ifx\chapter\relax\@tempswafalse\fi -\if@tempswa\toks@\expandafter{\the\toks@[chapter]}\fi -\the\toks@ +\edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@ \newtheorem*{theorem*}{Theorem} % \end{macrocode} % @@ -342,7 +361,7 @@ % Ah, but nobody actually does anything with |\after@thm|. Let's fix that. % % \begin{macrocode} -\def\@endtheorem{\after@thm\endtrivlist\@endpefalse} +\AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist\@endpefalse}} % \end{macrocode} % \end{macro} % \end{macro} -- 2.11.0