3 % $Id: mdwthm.dtx,v 1.5 2003/12/01 00:47:56 mdw Exp $
5 % Standard theorem typesetting
7 % (c) 2001 Mark Wooding
9 %----- Revision history -----------------------------------------------------
11 % $Log: mdwthm.dtx,v $
12 % Revision 1.5 2003/12/01 00:47:56 mdw
15 % Revision 1.4 2003/09/06 11:25:54 mdw
16 % Allow configuration of theorem numbering.
18 % Revision 1.3 2003/09/05 16:16:20 mdw
19 % Various nips and tucks. Redefine theorem styles from scratch now.
21 % Revision 1.2 2002/02/24 12:35:55 mdw
22 % Fix handling of \chapter, in case some idiot has said `\csname
25 % Revision 1.1 2002/02/03 20:49:03 mdw
26 % Checkin for new build system.
31 % \begin{meta-comment} <general public licence>
33 %% mdwthm package -- standard theorem stuff
34 %% Copyright (c) 2001 Mark Wooding
36 %% This program is free software; you can redistribute it and/or modify
37 %% it under the terms of the GNU General Public License as published by
38 %% the Free Software Foundation; either version 2 of the License, or
39 %% (at your option) any later version.
41 %% This program is distributed in the hope that it will be useful,
42 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
43 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
44 %% GNU General Public License for more details.
46 %% You should have received a copy of the GNU General Public License
47 %% along with this program; if not, write to the Free Software Foundation,
48 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51 % \begin{meta-comment} <Package preambles>
52 %<+package>\NeedsTeXFormat{LaTeX2e}
53 %<+package>\ProvidesPackage{mdwthm}
54 %<+package> [2001/09/16 1.0 theorem typesetting]
55 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
56 %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style]
61 %% {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
62 %% 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
63 %% Digits \0\1\2\3\4\5\6\7\8\9
64 %% Exclamation \! Double quote \" Hash (number) \#
65 %% Dollar \$ Percent \% Ampersand \&
66 %% Acute accent \' Left paren \( Right paren \)
67 %% Asterisk \* Plus \+ Comma \,
68 %% Minus \- Point \. Solidus \/
69 %% Colon \: Semicolon \; Less than \<
70 %% Equals \= Greater than \> Question mark \?
71 %% Commercial at \@ Left bracket \[ Backslash \\
72 %% Right bracket \] Circumflex \^ Underscore \_
73 %% Grave accent \` Left brace \{ Vertical bar \|
74 %% Right brace \} Tilde \~}
77 % \begin{meta-comment}
81 \describespackage{mdwthm}
87 %^^A-------------------------------------------------------------------------
88 % \section{User guide}
90 % \subsection{Environments provided}
92 % \DescribeEnv{theorem}
94 % \DescribeEnv{proposition}
95 % \DescribeEnv{corollary}
96 % \DescribeEnv{definition}
97 % \DescribeEnv{example}
99 % \DescribeEnv{remark}
101 % The package defines a collection of theorem environments, declared in the
102 % usual way. All of them except \env{claim} share the same counter. If the
103 % document class has a |\chapter| command, then they are numbered within the
104 % chapter; otherwise there is a single numbering system throughout the
107 % Every environment has a $*$-version, which doesn't print a number. This
108 % might be useful every now and then.
110 % The environments \env{theorem}, \env{lemma}, \env{proposition},
111 % \env{claim}and \env{corollary} are set using the `plain' style, with the
112 % body text in \textit{italics}. The environments \env{definition} and
113 % \env{example} are set in the `definition' style, with body text in roman.
114 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
115 % set in the `remark' style.
117 % \DescribeEnv{claim}
118 % \DescribeEnv{proof}
119 % The \env{claim} environment has its own counter, which is reset at the
120 % beginning of the \env{proof} environment. If you say |\qed| in a
121 % \env{proof} environment then it uses your symbol; otherwise it adds its own
124 % \subsection{Options}
126 % The package takes an option \syntax{"within="<counter>} -- number theorems
127 % within \<counter>. If this isn't given, a default is chosen -- either
128 % numbering in chapters, or global numbering. The \lit*{notwithin} option
129 % forces global numbering.
131 % \subsection{The \package{mdwmargin} style}
133 % This package also provides a pretty `number-hanging-in-the-margin' theorem
134 % style collection, available under the name \env{mdwmargin}.
139 %^^A-------------------------------------------------------------------------
140 % \section{Implementation of the environments}
144 \RequirePackage{mdwkey}
146 \ifx\if@article\iftrue0
147 \else\ifx\chapter\@@undefined0
148 \else\ifx\chapter\relax0
150 \def\mt@within{[chapter]}
154 \mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}}
155 \mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}}
156 \mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}}
157 \mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}}
158 \def\mt@opt#1{\mkparse{mdwthm:opt}{#1}}
159 \DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}}
161 \RequirePackage{amsthm}
164 % \subsection{The simple bits}
166 % \begin{environment}{theorem}
168 % Do the right thing with the numbering rules.
171 \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@
172 \newtheorem*{theorem*}{Theorem}
177 % \begin{environment}{lemma}
178 % \begin{environment}{proposition}
179 % \begin{environment}{corollary}
180 % \begin{environment}{claim}
181 % \begin{environment}{definition}
182 % \begin{environment}{example}
183 % \begin{environment}{fact}
184 % \begin{environment}{remark}
186 % Most of this is very easy.
190 \newtheorem{lemma}[theorem]{Lemma}
191 \newtheorem*{lemma*}{Lemma}
192 \newtheorem{proposition}[theorem]{Proposition}
193 \newtheorem*{proposition*}{Proposition}
194 \newtheorem{corollary}[theorem]{Corollary}
195 \newtheorem*{corollary*}{Corollary}
196 \newtheorem{fact}[theorem]{Fact}
197 \newtheorem*{fact*}{Fact}
198 \newtheorem{claim}{Claim}
199 \newtheorem*{claim*}{Claim}
203 \theoremstyle{definition}
204 \newtheorem{definition}[theorem]{Definition}
205 \newtheorem*{definition*}{Definition}
206 \newtheorem{example}[theorem]{Example}
207 \newtheorem*{example*}{Example}
211 \theoremstyle{remark}
212 \newtheorem{remark}[theorem]{Remark}
213 \newtheorem*{remark*}{Remark}
225 % \begin{environment}{note}
227 % Someone else might also have a \env{note} environment. Be careful.
230 \ifx\note\@@undefined
231 \newtheorem{note}[theorem]{Note}
232 \newtheorem*{note*}{Note}
238 % \begin{macro}{\@qedhack}
240 % Make |\qed| idempotent.
247 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
253 % \begin{environment}{proof}
255 % Now to hack the proof environment.
258 \renewenvironment{proof}[1][\proofname]{%
259 \setcounter{claim}{0}%
261 \ifdim\topsep<\parskip\topsep\parskip\fi%
262 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
263 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
264 \advance\@topsep-\parskip%
265 \advance\@topsepadd-\parskip%
274 % \begin{macro}{\proofstyle}
276 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
280 \providecommand\proofstyle[1]{\textit{#1.}}
291 %^^A-------------------------------------------------------------------------
292 % \section{Implementation of the theorem style}
298 % \begin{macro}{\thmhead@margin}
300 % Firstly, a macro to typeset the theorem environment header, with the number
304 \def\thmhead@margin#1#2#3{%
305 \thmnumber{\llap{#2{\normalsize\quad}}}%
307 \thmnote{ \the\thm@notefont(#3)}%
312 % \begin{macro}{\thm@headfont@margin}
314 % Now to decide on the header font. Definitely we want boldface; if the
315 % documentclass (or \package{mdwfonts}) has decided on a different font
316 % family for the headings, then we use that.
319 \def\thm@headfont@margin{%
320 \fontseries{\bfdefault}%
321 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
327 % \begin{macro}{\qedsymbol}
329 % Use the nice symbol if available.
332 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
336 % \begin{macro}{\proofstyle}
338 % Typeset `Proof' in bold face.
341 \def\proofstyle#1{{\thm@headfont@margin#1}}
346 % \begin{macro}{\th@base}
347 % \begin{macro}{\@endtheorem}
349 % The |\th@base| macro provides the basis for our theorem style. The
350 % argument is something to do at the end of the environment.
354 \let\thmhead\thmhead@margin%
355 \thm@headfont{\thm@headfont@margin}%
357 \advance\thm@postskip-\parskip%
364 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
367 \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist\@endpefalse}}
372 % \begin{macro}{\th@plain}
373 % \begin{macro}{\th@definition}
374 % \begin{macro}{\th@remark}
376 % Now this is easy. The space hacking in |\th@remark| is straight from
381 \def\th@plain{\th@base\relax\itshape}
382 \def\th@definition{\th@base\qed}
385 \thm@preskip\topsep\divide\thm@preskip\tw@%
386 \thm@postskip\thm@preskip%
395 % \hfill Mark Wooding, \today