3 % $Id: mdwthm.dtx,v 1.2 2002/02/24 12:35:55 mdw Exp $
5 % Standard theorem typesetting
7 % (c) 2001 Mark Wooding
9 %----- Revision history -----------------------------------------------------
11 % $Log: mdwthm.dtx,v $
12 % Revision 1.2 2002/02/24 12:35:55 mdw
13 % Fix handling of \chapter, in case some idiot has said `\csname
16 % Revision 1.1 2002/02/03 20:49:03 mdw
17 % Checkin for new build system.
22 % \begin{meta-comment} <general public licence>
24 %% mdwthm package -- standard theorem stuff
25 %% Copyright (c) 2001 Mark Wooding
27 %% This program is free software; you can redistribute it and/or modify
28 %% it under the terms of the GNU General Public License as published by
29 %% the Free Software Foundation; either version 2 of the License, or
30 %% (at your option) any later version.
32 %% This program is distributed in the hope that it will be useful,
33 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
34 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 %% GNU General Public License for more details.
37 %% You should have received a copy of the GNU General Public License
38 %% along with this program; if not, write to the Free Software Foundation,
39 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
42 % \begin{meta-comment} <Package preambles>
43 %<+package>\NeedsTeXFormat{LaTeX2e}
44 %<+package>\ProvidesPackage{mdwthm}
45 %<+package> [2001/09/16 1.0 theorem typesetting]
46 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
47 %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style]
52 %% {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
53 %% 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
54 %% Digits \0\1\2\3\4\5\6\7\8\9
55 %% Exclamation \! Double quote \" Hash (number) \#
56 %% Dollar \$ Percent \% Ampersand \&
57 %% Acute accent \' Left paren \( Right paren \)
58 %% Asterisk \* Plus \+ Comma \,
59 %% Minus \- Point \. Solidus \/
60 %% Colon \: Semicolon \; Less than \<
61 %% Equals \= Greater than \> Question mark \?
62 %% Commercial at \@ Left bracket \[ Backslash \\
63 %% Right bracket \] Circumflex \^ Underscore \_
64 %% Grave accent \` Left brace \{ Vertical bar \|
65 %% Right brace \} Tilde \~}
68 % \begin{meta-comment}
72 \describespackage{mdwthm}
78 %^^A-------------------------------------------------------------------------
79 % \section{User guide}
81 % \subsection{Environments provided}
83 % \DescribeEnv{theorem}
85 % \DescribeEnv{proposition}
86 % \DescribeEnv{corollary}
87 % \DescribeEnv{definition}
88 % \DescribeEnv{example}
90 % \DescribeEnv{remark}
92 % The package defines a collection of theorem environments, declared in the
93 % usual way. All of them except \env{claim} share the same counter. If the
94 % document class has a |\chapter| command, then they are numbered within the
95 % chapter; otherwise there is a single numbering system throughout the
98 % Every environment has a $*$-version, which doesn't print a number. This
99 % might be useful every now and then.
101 % The environments \env{theorem}, \env{lemma}, \env{proposition},
102 % \env{claim}and \env{corollary} are set using the `plain' style, with the
103 % body text in \textit{italics}. The environments \env{definition} and
104 % \env{example} are set in the `definition' style, with body text in roman.
105 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
106 % set in the `remark' style.
108 % \DescribeEnv{claim}
109 % \DescribeEnv{proof}
110 % The \env{claim} environment has its own counter, which is reset at the
111 % beginning of the \env{proof} environment.
113 % \subsection{The \package{mdwmargin} style}
115 % This package also provides a pretty `number-hanging-in-the-margin' theorem
116 % style collection, available under the name \env{mdwmargin}.
121 %^^A-------------------------------------------------------------------------
122 % \section{Implementation of the environments}
126 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsthm}}
127 \ProcessOptions\relax
128 \RequirePackage{amsthm}
131 % \subsection{The simple bits}
133 % \begin{environment}{theorem}
135 % Do the right thing with the numbering rules.
138 \toks@{\newtheorem{theorem}{Theorem}}
140 \ifx\if@article\iftrue\@tempswafalse\fi
141 \ifx\chapter\@@undefined\@tempswafalse\fi
142 \ifx\chapter\relax\@tempswafalse\fi
143 \if@tempswa\toks@\expandafter{\the\toks@[chapter]}\fi
145 \newtheorem*{theorem*}{Theorem}
150 % \begin{environment}{lemma}
151 % \begin{environment}{proposition}
152 % \begin{environment}{corollary}
153 % \begin{environment}{claim}
154 % \begin{environment}{definition}
155 % \begin{environment}{example}
156 % \begin{environment}{fact}
157 % \begin{environment}{remark}
159 % Most of this is very easy.
163 \newtheorem{lemma}[theorem]{Lemma}
164 \newtheorem*{lemma*}{Lemma}
165 \newtheorem{proposition}[theorem]{Proposition}
166 \newtheorem*{proposition*}{Proposition}
167 \newtheorem{corollary}[theorem]{Corollary}
168 \newtheorem*{corollary*}{Corollary}
169 \newtheorem{fact}[theorem]{Fact}
170 \newtheorem*{fact*}{Fact}
171 \newtheorem{claim}{Claim}
172 \newtheorem*{claim*}{Claim}
176 \theoremstyle{definition}
177 \newtheorem{definition}[theorem]{Definition}
178 \newtheorem*{definition*}{Definition}
179 \newtheorem{example}[theorem]{Example}
180 \newtheorem*{example*}{Example}
184 \theoremstyle{remark}
185 \newtheorem{remark}[theorem]{Remark}
186 \newtheorem*{remark*}{Remark}
198 % \begin{environment}{note}
200 % Someone else might also have a \env{note} environment. Be careful.
203 \ifx\note\@@undefined
204 \newtheorem{note}[theorem]{Note}
205 \newtheorem*{note*}{Note}
211 % \begin{environment}{proof}
213 % Now to hack the proof environment.
216 \renewenvironment{proof}[1][\proofname]{%
217 \setcounter{claim}{0}%
219 \trivlist\advance\itemindent\labelsep\let\makelabel\textit%
220 \advance\@topsep-\parskip%
221 \advance\@topsepadd-\parskip%
236 %^^A-------------------------------------------------------------------------
237 % \section{Implementation of the theorem style}
243 % \begin{macro}{\thmhead@margin}
245 % Firstly, a macro to typeset the theorem environment header, with the number
249 \def\thmhead@margin#1#2#3{%
250 \thmnumber{\llap{#2{\normalsize\quad}}}%
252 \thmnote{ \the\thm@notefont(#3)}%
257 % \begin{macro}{\thm@headfont@margin}
259 % Now to decide on the header font. Definitely we want boldface; if the
260 % documentclass (or \package{mdwfonts}) has decided on a different font
261 % family for the headings, then we use that.
264 \def\thm@headfont@margin{%
266 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
272 % \begin{macro}{\qedsymbol}
274 % Use the nice symbol if available.
277 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
281 % \begin{macro}{\hack@thm}
283 % Now we hack the standard theorem styles to do what we want. This is a
284 % tedious enough game with |\expandafter|.
288 \expandafter\def\expandafter#1\expandafter{#1%
289 \let\thmhead\thmhead@margin%
290 \thm@headfont{\thm@headfont@margin}%
292 \advance\thm@postskip-\parskip%
296 \def\@endtheorem{\after@thm\endtrivlist\@endpefalse}
299 \hack@thm\th@definition{\qed}
300 \hack@thm\th@remark{\qed}
305 % \hfill Mark Wooding, \today