3 % $Id: mdwthm.dtx,v 1.3 2003/09/05 16:16:20 mdw Exp $
5 % Standard theorem typesetting
7 % (c) 2001 Mark Wooding
9 %----- Revision history -----------------------------------------------------
11 % $Log: mdwthm.dtx,v $
12 % Revision 1.3 2003/09/05 16:16:20 mdw
13 % Various nips and tucks. Redefine theorem styles from scratch now.
15 % Revision 1.2 2002/02/24 12:35:55 mdw
16 % Fix handling of \chapter, in case some idiot has said `\csname
19 % Revision 1.1 2002/02/03 20:49:03 mdw
20 % Checkin for new build system.
25 % \begin{meta-comment} <general public licence>
27 %% mdwthm package -- standard theorem stuff
28 %% Copyright (c) 2001 Mark Wooding
30 %% This program is free software; you can redistribute it and/or modify
31 %% it under the terms of the GNU General Public License as published by
32 %% the Free Software Foundation; either version 2 of the License, or
33 %% (at your option) any later version.
35 %% This program is distributed in the hope that it will be useful,
36 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
37 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
38 %% GNU General Public License for more details.
40 %% You should have received a copy of the GNU General Public License
41 %% along with this program; if not, write to the Free Software Foundation,
42 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45 % \begin{meta-comment} <Package preambles>
46 %<+package>\NeedsTeXFormat{LaTeX2e}
47 %<+package>\ProvidesPackage{mdwthm}
48 %<+package> [2001/09/16 1.0 theorem typesetting]
49 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
50 %<+thmstyle> [2001/09/16 1.0 numbers-in-the-margin theorem style]
55 %% {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
56 %% 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
57 %% Digits \0\1\2\3\4\5\6\7\8\9
58 %% Exclamation \! Double quote \" Hash (number) \#
59 %% Dollar \$ Percent \% Ampersand \&
60 %% Acute accent \' Left paren \( Right paren \)
61 %% Asterisk \* Plus \+ Comma \,
62 %% Minus \- Point \. Solidus \/
63 %% Colon \: Semicolon \; Less than \<
64 %% Equals \= Greater than \> Question mark \?
65 %% Commercial at \@ Left bracket \[ Backslash \\
66 %% Right bracket \] Circumflex \^ Underscore \_
67 %% Grave accent \` Left brace \{ Vertical bar \|
68 %% Right brace \} Tilde \~}
71 % \begin{meta-comment}
75 \describespackage{mdwthm}
81 %^^A-------------------------------------------------------------------------
82 % \section{User guide}
84 % \subsection{Environments provided}
86 % \DescribeEnv{theorem}
88 % \DescribeEnv{proposition}
89 % \DescribeEnv{corollary}
90 % \DescribeEnv{definition}
91 % \DescribeEnv{example}
93 % \DescribeEnv{remark}
95 % The package defines a collection of theorem environments, declared in the
96 % usual way. All of them except \env{claim} share the same counter. If the
97 % document class has a |\chapter| command, then they are numbered within the
98 % chapter; otherwise there is a single numbering system throughout the
101 % Every environment has a $*$-version, which doesn't print a number. This
102 % might be useful every now and then.
104 % The environments \env{theorem}, \env{lemma}, \env{proposition},
105 % \env{claim}and \env{corollary} are set using the `plain' style, with the
106 % body text in \textit{italics}. The environments \env{definition} and
107 % \env{example} are set in the `definition' style, with body text in roman.
108 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
109 % set in the `remark' style.
111 % \DescribeEnv{claim}
112 % \DescribeEnv{proof}
113 % The \env{claim} environment has its own counter, which is reset at the
114 % beginning of the \env{proof} environment. If you say |\qed| in a
115 % \env{proof} environment then it uses your symbol; otherwise it adds its own
118 % \subsection{The \package{mdwmargin} style}
120 % This package also provides a pretty `number-hanging-in-the-margin' theorem
121 % style collection, available under the name \env{mdwmargin}.
126 %^^A-------------------------------------------------------------------------
127 % \section{Implementation of the environments}
131 \DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsthm}}
132 \ProcessOptions\relax
133 \RequirePackage{amsthm}
136 % \subsection{The simple bits}
138 % \begin{environment}{theorem}
140 % Do the right thing with the numbering rules.
143 \toks@{\newtheorem{theorem}{Theorem}}
145 \ifx\if@article\iftrue\@tempswafalse\fi
146 \ifx\chapter\@@undefined\@tempswafalse\fi
147 \ifx\chapter\relax\@tempswafalse\fi
148 \if@tempswa\toks@\expandafter{\the\toks@[chapter]}\fi
150 \newtheorem*{theorem*}{Theorem}
155 % \begin{environment}{lemma}
156 % \begin{environment}{proposition}
157 % \begin{environment}{corollary}
158 % \begin{environment}{claim}
159 % \begin{environment}{definition}
160 % \begin{environment}{example}
161 % \begin{environment}{fact}
162 % \begin{environment}{remark}
164 % Most of this is very easy.
168 \newtheorem{lemma}[theorem]{Lemma}
169 \newtheorem*{lemma*}{Lemma}
170 \newtheorem{proposition}[theorem]{Proposition}
171 \newtheorem*{proposition*}{Proposition}
172 \newtheorem{corollary}[theorem]{Corollary}
173 \newtheorem*{corollary*}{Corollary}
174 \newtheorem{fact}[theorem]{Fact}
175 \newtheorem*{fact*}{Fact}
176 \newtheorem{claim}{Claim}
177 \newtheorem*{claim*}{Claim}
181 \theoremstyle{definition}
182 \newtheorem{definition}[theorem]{Definition}
183 \newtheorem*{definition*}{Definition}
184 \newtheorem{example}[theorem]{Example}
185 \newtheorem*{example*}{Example}
189 \theoremstyle{remark}
190 \newtheorem{remark}[theorem]{Remark}
191 \newtheorem*{remark*}{Remark}
203 % \begin{environment}{note}
205 % Someone else might also have a \env{note} environment. Be careful.
208 \ifx\note\@@undefined
209 \newtheorem{note}[theorem]{Note}
210 \newtheorem*{note*}{Note}
216 % \begin{macro}{\@qedhack}
218 % Make |\qed| idempotent.
225 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
231 % \begin{environment}{proof}
233 % Now to hack the proof environment.
236 \renewenvironment{proof}[1][\proofname]{%
237 \setcounter{claim}{0}%
239 \ifdim\topsep<\parskip\topsep\parskip\fi%
240 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
241 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
242 \advance\@topsep-\parskip%
243 \advance\@topsepadd-\parskip%
252 % \begin{macro}{\proofstyle}
254 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
258 \providecommand\proofstyle[1]{\textit{#1.}}
269 %^^A-------------------------------------------------------------------------
270 % \section{Implementation of the theorem style}
276 % \begin{macro}{\thmhead@margin}
278 % Firstly, a macro to typeset the theorem environment header, with the number
282 \def\thmhead@margin#1#2#3{%
283 \thmnumber{\llap{#2{\normalsize\quad}}}%
285 \thmnote{ \the\thm@notefont(#3)}%
290 % \begin{macro}{\thm@headfont@margin}
292 % Now to decide on the header font. Definitely we want boldface; if the
293 % documentclass (or \package{mdwfonts}) has decided on a different font
294 % family for the headings, then we use that.
297 \def\thm@headfont@margin{%
298 \fontseries{\bfdefault}%
299 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
305 % \begin{macro}{\qedsymbol}
307 % Use the nice symbol if available.
310 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
314 % \begin{macro}{\proofstyle}
316 % Typeset `Proof' in bold face.
319 \def\proofstyle#1{{\thm@headfont@margin#1}}
324 % \begin{macro}{\th@base}
325 % \begin{macro}{\@endtheorem}
327 % The |\th@base| macro provides the basis for our theorem style. The
328 % argument is something to do at the end of the environment.
332 \let\thmhead\thmhead@margin%
333 \thm@headfont{\thm@headfont@margin}%
335 \advance\thm@postskip-\parskip%
342 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
345 \def\@endtheorem{\after@thm\endtrivlist\@endpefalse}
350 % \begin{macro}{\th@plain}
351 % \begin{macro}{\th@definition}
352 % \begin{macro}{\th@remark}
354 % Now this is easy. The space hacking in |\th@remark| is straight from
359 \def\th@plain{\th@base\relax\itshape}
360 \def\th@definition{\th@base\qed}
363 \thm@preskip\topsep\divide\thm@preskip\tw@%
364 \thm@postskip\thm@preskip%
373 % \hfill Mark Wooding, \today