X-Git-Url: https://git.distorted.org.uk/~mdw/mdwtools/blobdiff_plain/86f6a31e4b41acb71ba37f3838a9ce75f7743330..f5a14467558d34dabf42e936ff435eb31a631723:/mdwthm.dtx diff --git a/mdwthm.dtx b/mdwthm.dtx index f4a17d2..63baaea 100644 --- a/mdwthm.dtx +++ b/mdwthm.dtx @@ -1,18 +1,11 @@ % \begin{meta-comment} % -% $Id: mdwthm.dtx,v 1.1 2002/02/03 20:49:03 mdw Exp $ +% $Id: mdwthm.dtx,v 1.5 2003/12/01 00:47:56 mdw Exp $ % % Standard theorem typesetting % % (c) 2001 Mark Wooding % -%----- Revision history ----------------------------------------------------- -% -% $Log: mdwthm.dtx,v $ -% Revision 1.1 2002/02/03 20:49:03 mdw -% Checkin for new build system. -% -% % \end{meta-comment} % % \begin{meta-comment} @@ -43,7 +36,7 @@ %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style] % \end{meta-comment} % -% \CheckSum{140} +% \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 @@ -104,7 +97,16 @@ % \DescribeEnv{claim} % \DescribeEnv{proof} % The \env{claim} environment has its own counter, which is reset at the -% beginning of the \env{proof} environment. +% beginning of the \env{proof} environment. If you say |\qed| in a +% \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} % @@ -119,8 +121,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} % @@ -131,12 +148,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 -\if@tempswa\toks@\expandafter{\the\toks@[chapter]}\fi -\the\toks@ +\edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@ \newtheorem*{theorem*}{Theorem} % \end{macrocode} % @@ -203,6 +215,21 @@ % % \end{environment} % +% \begin{macro}{\@qedhack} +% +% Make |\qed| idempotent. +% +% \begin{macrocode} +\newif\if@qedsw +\def\@qedhack{% + \let\@qed@\qed% + \global\@qedswtrue% + \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}% +} +% \end{macrocode} +% +% \end{macro} +% % \begin{environment}{proof} % % Now to hack the proof environment. @@ -211,17 +238,30 @@ \renewenvironment{proof}[1][\proofname]{% \setcounter{claim}{0}% \par\normalfont% - \trivlist\advance\itemindent\labelsep\let\makelabel\textit% + \ifdim\topsep<\parskip\topsep\parskip\fi% + \ifdim\@topsepadd<\z@\@topsepadd\z@\fi% + \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle% \advance\@topsep-\parskip% \advance\@topsepadd-\parskip% - \item[#1\@proofdot]% + \@qedhack% + \item[#1]% }{% \qed\endtrivlist% } -\def\@proofdot{.} % \end{macrocode} % \end{environment} % +% \begin{macro}{\proofstyle} +% +% The |\proofstyle| macro is just a style hook for typesetting the `Proof' +% label. +% +% \begin{macrocode} +\providecommand\proofstyle[1]{\textit{#1.}} +% \end{macrocode} +% +% \end{macro} +% % Done. % % \begin{macrocode} @@ -257,7 +297,7 @@ % % \begin{macrocode} \def\thm@headfont@margin{% - \fontseries{b}% + \fontseries{\bfdefault}% \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi% \selectfont% } @@ -273,29 +313,64 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}{\hack@thm} +% \begin{macro}{\proofstyle} % -% Now we hack the standard theorem styles to do what we want. This is a -% tedious enough game with |\expandafter|. +% Typeset `Proof' in bold face. % % \begin{macrocode} -\def\hack@thm#1#2{% - \expandafter\def\expandafter#1\expandafter{#1% - \let\thmhead\thmhead@margin% - \thm@headfont{\thm@headfont@margin}% - \thm@headpunct{}% - \advance\thm@postskip-\parskip% - \def\after@thm{#2}% +\def\proofstyle#1{{\thm@headfont@margin#1}} +% \end{macrocode} +% +% \end{macro} +% +% \begin{macro}{\th@base} +% \begin{macro}{\@endtheorem} +% +% The |\th@base| macro provides the basis for our theorem style. The +% argument is something to do at the end of the environment. +% +% \begin{macrocode} +\def\th@base#1{% + \let\thmhead\thmhead@margin% + \thm@headfont{\thm@headfont@margin}% + \thm@headpunct{}% + \advance\thm@postskip-\parskip% + \@qedhack% + \def\after@thm{#1}% + \normalfont% +} +% \end{macrocode} +% +% Ah, but nobody actually does anything with |\after@thm|. Let's fix that. +% +% \begin{macrocode} +\AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\th@plain} +% \begin{macro}{\th@definition} +% \begin{macro}{\th@remark} +% +% Now this is easy. The space hacking in |\th@remark| is straight from +% \package{amsthm}. +% +% \begin{macrocode} +\AtBeginDocument{ + \def\th@plain{\th@base\relax\itshape} + \def\th@definition{\th@base\qed} + \def\th@remark{% + \th@base\qed% + \thm@preskip\topsep\divide\thm@preskip\tw@% + \thm@postskip\thm@preskip% } } -\def\@endtheorem{\after@thm\endtrivlist\@endpefalse} -\let\@proofdot\relax -\hack@thm\th@plain{} -\hack@thm\th@definition{\qed} -\hack@thm\th@remark{\qed} % % \end{macrocode} % \end{macro} +% \end{macro} +% \end{macro} % % \hfill Mark Wooding, \today % \Finale