3 % $Id: mdwthm.dtx,v 1.4 2003/09/06 11:25:54 mdw Exp $
5 % Standard theorem typesetting
7 % (c) 2001 Mark Wooding
9 %----- Revision history -----------------------------------------------------
11 % $Log: mdwthm.dtx,v $
12 % Revision 1.4 2003/09/06 11:25:54 mdw
13 % Allow configuration of theorem numbering.
15 % Revision 1.3 2003/09/05 16:16:20 mdw
16 % Various nips and tucks. Redefine theorem styles from scratch now.
18 % Revision 1.2 2002/02/24 12:35:55 mdw
19 % Fix handling of \chapter, in case some idiot has said `\csname
22 % Revision 1.1 2002/02/03 20:49:03 mdw
23 % Checkin for new build system.
28 % \begin{meta-comment} <general public licence>
30 %% mdwthm package -- standard theorem stuff
31 %% Copyright (c) 2001 Mark Wooding
33 %% This program is free software; you can redistribute it and/or modify
34 %% it under the terms of the GNU General Public License as published by
35 %% the Free Software Foundation; either version 2 of the License, or
36 %% (at your option) any later version.
38 %% This program is distributed in the hope that it will be useful,
39 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
40 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
41 %% GNU General Public License for more details.
43 %% You should have received a copy of the GNU General Public License
44 %% along with this program; if not, write to the Free Software Foundation,
45 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
48 % \begin{meta-comment} <Package preambles>
49 %<+package>\NeedsTeXFormat{LaTeX2e}
50 %<+package>\ProvidesPackage{mdwthm}
51 %<+package> [2001/09/16 1.0 theorem typesetting]
52 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
53 %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style]
58 %% {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
59 %% 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
60 %% Digits \0\1\2\3\4\5\6\7\8\9
61 %% Exclamation \! Double quote \" Hash (number) \#
62 %% Dollar \$ Percent \% Ampersand \&
63 %% Acute accent \' Left paren \( Right paren \)
64 %% Asterisk \* Plus \+ Comma \,
65 %% Minus \- Point \. Solidus \/
66 %% Colon \: Semicolon \; Less than \<
67 %% Equals \= Greater than \> Question mark \?
68 %% Commercial at \@ Left bracket \[ Backslash \\
69 %% Right bracket \] Circumflex \^ Underscore \_
70 %% Grave accent \` Left brace \{ Vertical bar \|
71 %% Right brace \} Tilde \~}
74 % \begin{meta-comment}
78 \describespackage{mdwthm}
84 %^^A-------------------------------------------------------------------------
85 % \section{User guide}
87 % \subsection{Environments provided}
89 % \DescribeEnv{theorem}
91 % \DescribeEnv{proposition}
92 % \DescribeEnv{corollary}
93 % \DescribeEnv{definition}
94 % \DescribeEnv{example}
96 % \DescribeEnv{remark}
98 % The package defines a collection of theorem environments, declared in the
99 % usual way. All of them except \env{claim} share the same counter. If the
100 % document class has a |\chapter| command, then they are numbered within the
101 % chapter; otherwise there is a single numbering system throughout the
104 % Every environment has a $*$-version, which doesn't print a number. This
105 % might be useful every now and then.
107 % The environments \env{theorem}, \env{lemma}, \env{proposition},
108 % \env{claim}and \env{corollary} are set using the `plain' style, with the
109 % body text in \textit{italics}. The environments \env{definition} and
110 % \env{example} are set in the `definition' style, with body text in roman.
111 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
112 % set in the `remark' style.
114 % \DescribeEnv{claim}
115 % \DescribeEnv{proof}
116 % The \env{claim} environment has its own counter, which is reset at the
117 % beginning of the \env{proof} environment. If you say |\qed| in a
118 % \env{proof} environment then it uses your symbol; otherwise it adds its own
121 % \subsection{Options}
123 % The package takes an option \syntax{"within="<counter>} -- number theorems
124 % within \<counter>. If this isn't given, a default is chosen -- either
125 % numbering in chapters, or global numbering. The \lit*{notwithin} option
126 % forces global numbering.
128 % \subsection{The \package{mdwmargin} style}
130 % This package also provides a pretty `number-hanging-in-the-margin' theorem
131 % style collection, available under the name \env{mdwmargin}.
136 %^^A-------------------------------------------------------------------------
137 % \section{Implementation of the environments}
141 \RequirePackage{mdwkey}
143 \ifx\if@article\iftrue0
144 \else\ifx\chapter\@@undefined0
145 \else\ifx\chapter\relax0
147 \def\mt@within{[chapter]}
151 \mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}}
152 \mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}}
153 \mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}}
154 \mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}}
155 \def\mt@opt#1{\mkparse{mdwthm:opt}{#1}}
156 \DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}}
158 \RequirePackage{amsthm}
161 % \subsection{The simple bits}
163 % \begin{environment}{theorem}
165 % Do the right thing with the numbering rules.
168 \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@
169 \newtheorem*{theorem*}{Theorem}
174 % \begin{environment}{lemma}
175 % \begin{environment}{proposition}
176 % \begin{environment}{corollary}
177 % \begin{environment}{claim}
178 % \begin{environment}{definition}
179 % \begin{environment}{example}
180 % \begin{environment}{fact}
181 % \begin{environment}{remark}
183 % Most of this is very easy.
187 \newtheorem{lemma}[theorem]{Lemma}
188 \newtheorem*{lemma*}{Lemma}
189 \newtheorem{proposition}[theorem]{Proposition}
190 \newtheorem*{proposition*}{Proposition}
191 \newtheorem{corollary}[theorem]{Corollary}
192 \newtheorem*{corollary*}{Corollary}
193 \newtheorem{fact}[theorem]{Fact}
194 \newtheorem*{fact*}{Fact}
195 \newtheorem{claim}{Claim}
196 \newtheorem*{claim*}{Claim}
200 \theoremstyle{definition}
201 \newtheorem{definition}[theorem]{Definition}
202 \newtheorem*{definition*}{Definition}
203 \newtheorem{example}[theorem]{Example}
204 \newtheorem*{example*}{Example}
208 \theoremstyle{remark}
209 \newtheorem{remark}[theorem]{Remark}
210 \newtheorem*{remark*}{Remark}
222 % \begin{environment}{note}
224 % Someone else might also have a \env{note} environment. Be careful.
227 \ifx\note\@@undefined
228 \newtheorem{note}[theorem]{Note}
229 \newtheorem*{note*}{Note}
235 % \begin{macro}{\@qedhack}
237 % Make |\qed| idempotent.
244 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
250 % \begin{environment}{proof}
252 % Now to hack the proof environment.
255 \renewenvironment{proof}[1][\proofname]{%
256 \setcounter{claim}{0}%
258 \ifdim\topsep<\parskip\topsep\parskip\fi%
259 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
260 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
261 \advance\@topsep-\parskip%
262 \advance\@topsepadd-\parskip%
271 % \begin{macro}{\proofstyle}
273 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
277 \providecommand\proofstyle[1]{\textit{#1.}}
288 %^^A-------------------------------------------------------------------------
289 % \section{Implementation of the theorem style}
295 % \begin{macro}{\thmhead@margin}
297 % Firstly, a macro to typeset the theorem environment header, with the number
301 \def\thmhead@margin#1#2#3{%
302 \thmnumber{\llap{#2{\normalsize\quad}}}%
304 \thmnote{ \the\thm@notefont(#3)}%
309 % \begin{macro}{\thm@headfont@margin}
311 % Now to decide on the header font. Definitely we want boldface; if the
312 % documentclass (or \package{mdwfonts}) has decided on a different font
313 % family for the headings, then we use that.
316 \def\thm@headfont@margin{%
317 \fontseries{\bfdefault}%
318 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
324 % \begin{macro}{\qedsymbol}
326 % Use the nice symbol if available.
329 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
333 % \begin{macro}{\proofstyle}
335 % Typeset `Proof' in bold face.
338 \def\proofstyle#1{{\thm@headfont@margin#1}}
343 % \begin{macro}{\th@base}
344 % \begin{macro}{\@endtheorem}
346 % The |\th@base| macro provides the basis for our theorem style. The
347 % argument is something to do at the end of the environment.
351 \let\thmhead\thmhead@margin%
352 \thm@headfont{\thm@headfont@margin}%
354 \advance\thm@postskip-\parskip%
361 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
364 \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist\@endpefalse}}
369 % \begin{macro}{\th@plain}
370 % \begin{macro}{\th@definition}
371 % \begin{macro}{\th@remark}
373 % Now this is easy. The space hacking in |\th@remark| is straight from
378 \def\th@plain{\th@base\relax\itshape}
379 \def\th@definition{\th@base\qed}
382 \thm@preskip\topsep\divide\thm@preskip\tw@%
383 \thm@postskip\thm@preskip%
392 % \hfill Mark Wooding, \today