X-Git-Url: https://git.distorted.org.uk/~mdw/mdwtools/blobdiff_plain/fe474f79ee06f9b78a1875cbf7e633c0b1313643..92e479d5f352161303477592d096f0fbb22ae288:/mdwthm.dtx

diff --git a/mdwthm.dtx b/mdwthm.dtx
index f7ddba5..d21854d 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.5 2003/12/01 00:47:56 mdw Exp $
 %
 % Standard theorem typesetting
 %
@@ -9,6 +9,12 @@
 %----- Revision history -----------------------------------------------------
 %
 % $Log: mdwthm.dtx,v $
+% Revision 1.5  2003/12/01 00:47:56  mdw
+% Fix checksum.
+%
+% 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 +56,7 @@
 %<+thmstyle>             [2001/09/16 1.0 numbers-in-the-margin theorem style]
 % \end{meta-comment}
 %
-% \CheckSum{187}
+% \CheckSum{205}
 %% \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 +121,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="<counter>} -- number theorems
+% within \<counter>.  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 +141,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 +168,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 +364,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}
