Fix dates and version numbers in the package files.
[mdwtools] / mdwthm.dtx
index f7ddba5..145dca1 100644 (file)
@@ -1,42 +1,18 @@
-% \begin{meta-comment}
-%
-% $Id: mdwthm.dtx,v 1.3 2003/09/05 16:16:20 mdw Exp $
-%
-% Standard theorem typesetting
-%
-% (c) 2001 Mark Wooding
-%
-%----- Revision history -----------------------------------------------------
-%
-% $Log: mdwthm.dtx,v $
-% Revision 1.3  2003/09/05 16:16:20  mdw
-% Various nips and tucks.  Redefine theorem styles from scratch now.
-%
-% Revision 1.2  2002/02/24 12:35:55  mdw
-% Fix handling of \chapter, in case some idiot has said `\csname
-% chapter\endcsname'.
-%
-% Revision 1.1  2002/02/03 20:49:03  mdw
-% Checkin for new build system.
-%
-%
-% \end{meta-comment}
-%
 % \begin{meta-comment} <general public licence>
 %%
 %% mdwthm package -- standard theorem stuff
-%% Copyright (c) 2001 Mark Wooding
+%% Copyright (c) 2001--2003, 2006, 2008 Mark Wooding
 %%
 %% This program is free software; you can redistribute it and/or modify
 %% it under the terms of the GNU General Public License as published by
 %% the Free Software Foundation; either version 2 of the License, or
 %% (at your option) any later version.
-%% 
+%%
 %% This program is distributed in the hope that it will be useful,
 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 %% GNU General Public License for more details.
-%% 
+%%
 %% You should have received a copy of the GNU General Public License
 %% along with this program; if not, write to the Free Software Foundation,
 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 % \begin{meta-comment} <Package preambles>
 %<+package>\NeedsTeXFormat{LaTeX2e}
 %<+package>\ProvidesPackage{mdwthm}
-%<+package>                [2001/09/16 1.0 theorem typesetting]
+%<+package>                [2020/09/06 1.14.0 Theorem typesetting]
 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
-%<+thmstyle>             [2001/09/16 1.0 numbers-in-the-margin theorem style]
+%<+thmstyle>             [2020/09/06 1.14.0 Numbers-in-the-margin theorem style]
 % \end{meta-comment}
 %
-% \CheckSum{187}
+% \CheckSum{204}
 %% \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.
 %
+% \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
 %
 %    \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}
 %
 % 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}
 %
 % 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}}
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}