Allow configuration of theorem numbering.
authormdw <mdw>
Sat, 6 Sep 2003 11:25:54 +0000 (11:25 +0000)
committermdw <mdw>
Sat, 6 Sep 2003 11:25:54 +0000 (11:25 +0000)
mdwthm.dtx

index f7ddba5..c90ca23 100644 (file)
@@ -1,6 +1,6 @@
 % \begin{meta-comment}
 %
 % \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
 %
 %
 % Standard theorem typesetting
 %
@@ -9,6 +9,9 @@
 %----- Revision history -----------------------------------------------------
 %
 % $Log: mdwthm.dtx,v $
 %----- 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.
 %
 % 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}
 %
 %<+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
 %% \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
 % \env{proof} environment then it uses your symbol; otherwise it adds its own
 % at the end.
 %
 % \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
 % \subsection{The \package{mdwmargin} style}
 %
 % This package also provides a pretty `number-hanging-in-the-margin' theorem
 %
 %    \begin{macrocode}
 %<*package>
 %
 %    \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}
 %
 \RequirePackage{amsthm}
 %    \end{macrocode}
 %
 % Do the right thing with the numbering rules.
 %
 %    \begin{macrocode}
 % 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}
 %
 \newtheorem*{theorem*}{Theorem}
 %    \end{macrocode}
 %
 % Ah, but nobody actually does anything with |\after@thm|.  Let's fix that.
 %
 %    \begin{macrocode}
 % 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}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}