3 % $Id: mdwthm.dtx,v 1.5 2003/12/01 00:47:56 mdw Exp $
5 % Standard theorem typesetting
7 % (c) 2001 Mark Wooding
11 % \begin{meta-comment} <general public licence>
13 %% mdwthm package -- standard theorem stuff
14 %% Copyright (c) 2001 Mark Wooding
16 %% This program is free software; you can redistribute it and/or modify
17 %% it under the terms of the GNU General Public License as published by
18 %% the Free Software Foundation; either version 2 of the License, or
19 %% (at your option) any later version.
21 %% This program is distributed in the hope that it will be useful,
22 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
23 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 %% GNU General Public License for more details.
26 %% You should have received a copy of the GNU General Public License
27 %% along with this program; if not, write to the Free Software Foundation,
28 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 % \begin{meta-comment} <Package preambles>
32 %<+package>\NeedsTeXFormat{LaTeX2e}
33 %<+package>\ProvidesPackage{mdwthm}
34 %<+package> [2001/09/16 1.0 theorem typesetting]
35 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
36 %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style]
41 %% {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
42 %% 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
43 %% Digits \0\1\2\3\4\5\6\7\8\9
44 %% Exclamation \! Double quote \" Hash (number) \#
45 %% Dollar \$ Percent \% Ampersand \&
46 %% Acute accent \' Left paren \( Right paren \)
47 %% Asterisk \* Plus \+ Comma \,
48 %% Minus \- Point \. Solidus \/
49 %% Colon \: Semicolon \; Less than \<
50 %% Equals \= Greater than \> Question mark \?
51 %% Commercial at \@ Left bracket \[ Backslash \\
52 %% Right bracket \] Circumflex \^ Underscore \_
53 %% Grave accent \` Left brace \{ Vertical bar \|
54 %% Right brace \} Tilde \~}
57 % \begin{meta-comment}
61 \describespackage{mdwthm}
67 %^^A-------------------------------------------------------------------------
68 % \section{User guide}
70 % \subsection{Environments provided}
72 % \DescribeEnv{theorem}
74 % \DescribeEnv{proposition}
75 % \DescribeEnv{corollary}
76 % \DescribeEnv{definition}
77 % \DescribeEnv{example}
79 % \DescribeEnv{remark}
81 % The package defines a collection of theorem environments, declared in the
82 % usual way. All of them except \env{claim} share the same counter. If the
83 % document class has a |\chapter| command, then they are numbered within the
84 % chapter; otherwise there is a single numbering system throughout the
87 % Every environment has a $*$-version, which doesn't print a number. This
88 % might be useful every now and then.
90 % The environments \env{theorem}, \env{lemma}, \env{proposition},
91 % \env{claim}and \env{corollary} are set using the `plain' style, with the
92 % body text in \textit{italics}. The environments \env{definition} and
93 % \env{example} are set in the `definition' style, with body text in roman.
94 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
95 % set in the `remark' style.
99 % The \env{claim} environment has its own counter, which is reset at the
100 % beginning of the \env{proof} environment. If you say |\qed| in a
101 % \env{proof} environment then it uses your symbol; otherwise it adds its own
104 % \subsection{Options}
106 % The package takes an option \syntax{"within="<counter>} -- number theorems
107 % within \<counter>. If this isn't given, a default is chosen -- either
108 % numbering in chapters, or global numbering. The \lit*{notwithin} option
109 % forces global numbering.
111 % \subsection{The \package{mdwmargin} style}
113 % This package also provides a pretty `number-hanging-in-the-margin' theorem
114 % style collection, available under the name \env{mdwmargin}.
119 %^^A-------------------------------------------------------------------------
120 % \section{Implementation of the environments}
124 \RequirePackage{mdwkey}
126 \ifx\if@article\iftrue0
127 \else\ifx\chapter\@@undefined0
128 \else\ifx\chapter\relax0
130 \def\mt@within{[chapter]}
134 \mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}}
135 \mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}}
136 \mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}}
137 \mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}}
138 \def\mt@opt#1{\mkparse{mdwthm:opt}{#1}}
139 \DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}}
141 \RequirePackage{amsthm}
144 % \subsection{The simple bits}
146 % \begin{environment}{theorem}
148 % Do the right thing with the numbering rules.
151 \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@
152 \newtheorem*{theorem*}{Theorem}
157 % \begin{environment}{lemma}
158 % \begin{environment}{proposition}
159 % \begin{environment}{corollary}
160 % \begin{environment}{claim}
161 % \begin{environment}{definition}
162 % \begin{environment}{example}
163 % \begin{environment}{fact}
164 % \begin{environment}{remark}
166 % Most of this is very easy.
170 \newtheorem{lemma}[theorem]{Lemma}
171 \newtheorem*{lemma*}{Lemma}
172 \newtheorem{proposition}[theorem]{Proposition}
173 \newtheorem*{proposition*}{Proposition}
174 \newtheorem{corollary}[theorem]{Corollary}
175 \newtheorem*{corollary*}{Corollary}
176 \newtheorem{fact}[theorem]{Fact}
177 \newtheorem*{fact*}{Fact}
178 \newtheorem{claim}{Claim}
179 \newtheorem*{claim*}{Claim}
183 \theoremstyle{definition}
184 \newtheorem{definition}[theorem]{Definition}
185 \newtheorem*{definition*}{Definition}
186 \newtheorem{example}[theorem]{Example}
187 \newtheorem*{example*}{Example}
191 \theoremstyle{remark}
192 \newtheorem{remark}[theorem]{Remark}
193 \newtheorem*{remark*}{Remark}
205 % \begin{environment}{note}
207 % Someone else might also have a \env{note} environment. Be careful.
210 \ifx\note\@@undefined
211 \newtheorem{note}[theorem]{Note}
212 \newtheorem*{note*}{Note}
218 % \begin{macro}{\@qedhack}
220 % Make |\qed| idempotent.
227 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
233 % \begin{environment}{proof}
235 % Now to hack the proof environment.
238 \renewenvironment{proof}[1][\proofname]{%
239 \setcounter{claim}{0}%
241 \ifdim\topsep<\parskip\topsep\parskip\fi%
242 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
243 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
244 \advance\@topsep-\parskip%
245 \advance\@topsepadd-\parskip%
254 % \begin{macro}{\proofstyle}
256 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
260 \providecommand\proofstyle[1]{\textit{#1.}}
271 %^^A-------------------------------------------------------------------------
272 % \section{Implementation of the theorem style}
278 % \begin{macro}{\thmhead@margin}
280 % Firstly, a macro to typeset the theorem environment header, with the number
284 \def\thmhead@margin#1#2#3{%
285 \thmnumber{\llap{#2{\normalsize\quad}}}%
287 \thmnote{ \the\thm@notefont(#3)}%
292 % \begin{macro}{\thm@headfont@margin}
294 % Now to decide on the header font. Definitely we want boldface; if the
295 % documentclass (or \package{mdwfonts}) has decided on a different font
296 % family for the headings, then we use that.
299 \def\thm@headfont@margin{%
300 \fontseries{\bfdefault}%
301 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
307 % \begin{macro}{\qedsymbol}
309 % Use the nice symbol if available.
312 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
316 % \begin{macro}{\proofstyle}
318 % Typeset `Proof' in bold face.
321 \def\proofstyle#1{{\thm@headfont@margin#1}}
326 % \begin{macro}{\th@base}
327 % \begin{macro}{\@endtheorem}
329 % The |\th@base| macro provides the basis for our theorem style. The
330 % argument is something to do at the end of the environment.
334 \let\thmhead\thmhead@margin%
335 \thm@headfont{\thm@headfont@margin}%
337 \advance\thm@postskip-\parskip%
344 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
347 \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist}}
352 % \begin{macro}{\th@plain}
353 % \begin{macro}{\th@definition}
354 % \begin{macro}{\th@remark}
356 % Now this is easy. The space hacking in |\th@remark| is straight from
361 \def\th@plain{\th@base\relax\itshape}
362 \def\th@definition{\th@base\qed}
365 \thm@preskip\topsep\divide\thm@preskip\tw@%
366 \thm@postskip\thm@preskip%
375 % \hfill Mark Wooding, \today