86f6a31e |
1 | % \begin{meta-comment} |
2 | % |
48c66928 |
3 | % $Id: mdwthm.dtx,v 1.4 2003/09/06 11:25:54 mdw Exp $ |
86f6a31e |
4 | % |
5 | % Standard theorem typesetting |
6 | % |
7 | % (c) 2001 Mark Wooding |
8 | % |
9 | %----- Revision history ----------------------------------------------------- |
10 | % |
11 | % $Log: mdwthm.dtx,v $ |
48c66928 |
12 | % Revision 1.4 2003/09/06 11:25:54 mdw |
13 | % Allow configuration of theorem numbering. |
14 | % |
fe474f79 |
15 | % Revision 1.3 2003/09/05 16:16:20 mdw |
16 | % Various nips and tucks. Redefine theorem styles from scratch now. |
17 | % |
6c811756 |
18 | % Revision 1.2 2002/02/24 12:35:55 mdw |
19 | % Fix handling of \chapter, in case some idiot has said `\csname |
20 | % chapter\endcsname'. |
21 | % |
86f6a31e |
22 | % Revision 1.1 2002/02/03 20:49:03 mdw |
23 | % Checkin for new build system. |
24 | % |
25 | % |
26 | % \end{meta-comment} |
27 | % |
28 | % \begin{meta-comment} <general public licence> |
29 | %% |
30 | %% mdwthm package -- standard theorem stuff |
31 | %% Copyright (c) 2001 Mark Wooding |
32 | %% |
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. |
37 | %% |
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. |
42 | %% |
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. |
46 | % \end{meta-comment} |
47 | % |
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] |
54 | % \end{meta-comment} |
55 | % |
48c66928 |
56 | % \CheckSum{203} |
86f6a31e |
57 | %% \CharacterTable |
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 \~} |
72 | %% |
73 | % |
74 | % \begin{meta-comment} |
75 | % |
76 | %<*driver> |
77 | \input{mdwtools} |
78 | \describespackage{mdwthm} |
79 | \mdwdoc |
80 | %</driver> |
81 | % |
82 | % \end{meta-comment} |
83 | % |
84 | %^^A------------------------------------------------------------------------- |
85 | % \section{User guide} |
86 | % |
87 | % \subsection{Environments provided} |
88 | % |
89 | % \DescribeEnv{theorem} |
90 | % \DescribeEnv{lemma} |
91 | % \DescribeEnv{proposition} |
92 | % \DescribeEnv{corollary} |
93 | % \DescribeEnv{definition} |
94 | % \DescribeEnv{example} |
95 | % \DescribeEnv{fact} |
96 | % \DescribeEnv{remark} |
97 | % \DescribeEnv{note} |
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 |
102 | % document. |
103 | % |
104 | % Every environment has a $*$-version, which doesn't print a number. This |
105 | % might be useful every now and then. |
106 | % |
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. |
113 | % |
114 | % \DescribeEnv{claim} |
115 | % \DescribeEnv{proof} |
116 | % The \env{claim} environment has its own counter, which is reset at the |
fe474f79 |
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 |
119 | % at the end. |
86f6a31e |
120 | % |
48c66928 |
121 | % \subsection{Options} |
122 | % |
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. |
127 | % |
86f6a31e |
128 | % \subsection{The \package{mdwmargin} style} |
129 | % |
130 | % This package also provides a pretty `number-hanging-in-the-margin' theorem |
131 | % style collection, available under the name \env{mdwmargin}. |
132 | % |
133 | % \implementation |
134 | % |
135 | % |
136 | %^^A------------------------------------------------------------------------- |
137 | % \section{Implementation of the environments} |
138 | % |
139 | % \begin{macrocode} |
140 | %<*package> |
48c66928 |
141 | \RequirePackage{mdwkey} |
142 | \if1% |
143 | \ifx\if@article\iftrue0 |
144 | \else\ifx\chapter\@@undefined0 |
145 | \else\ifx\chapter\relax0 |
146 | \else1\fi\fi\fi |
147 | \def\mt@within{[chapter]} |
148 | \else |
149 | \def\mt@within{} |
150 | \fi |
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}} |
157 | \ProcessOptions |
86f6a31e |
158 | \RequirePackage{amsthm} |
159 | % \end{macrocode} |
160 | % |
161 | % \subsection{The simple bits} |
162 | % |
163 | % \begin{environment}{theorem} |
164 | % |
165 | % Do the right thing with the numbering rules. |
166 | % |
167 | % \begin{macrocode} |
48c66928 |
168 | \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@ |
86f6a31e |
169 | \newtheorem*{theorem*}{Theorem} |
170 | % \end{macrocode} |
171 | % |
172 | % \end{environment} |
173 | % |
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} |
182 | % |
183 | % Most of this is very easy. |
184 | % |
185 | % \begin{macrocode} |
186 | \theoremstyle{plain} |
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} |
197 | % \end{macrocode} |
198 | % |
199 | % \begin{macrocode} |
200 | \theoremstyle{definition} |
201 | \newtheorem{definition}[theorem]{Definition} |
202 | \newtheorem*{definition*}{Definition} |
203 | \newtheorem{example}[theorem]{Example} |
204 | \newtheorem*{example*}{Example} |
205 | % \end{macrocode} |
206 | % |
207 | % \begin{macrocode} |
208 | \theoremstyle{remark} |
209 | \newtheorem{remark}[theorem]{Remark} |
210 | \newtheorem*{remark*}{Remark} |
211 | % \end{macrocode} |
212 | % |
213 | % \end{environment} |
214 | % \end{environment} |
215 | % \end{environment} |
216 | % \end{environment} |
217 | % \end{environment} |
218 | % \end{environment} |
219 | % \end{environment} |
220 | % \end{environment} |
221 | % |
222 | % \begin{environment}{note} |
223 | % |
224 | % Someone else might also have a \env{note} environment. Be careful. |
225 | % |
226 | % \begin{macrocode} |
227 | \ifx\note\@@undefined |
228 | \newtheorem{note}[theorem]{Note} |
229 | \newtheorem*{note*}{Note} |
230 | \fi |
231 | % \end{macrocode} |
232 | % |
233 | % \end{environment} |
234 | % |
fe474f79 |
235 | % \begin{macro}{\@qedhack} |
236 | % |
237 | % Make |\qed| idempotent. |
238 | % |
239 | % \begin{macrocode} |
240 | \newif\if@qedsw |
241 | \def\@qedhack{% |
242 | \let\@qed@\qed% |
243 | \global\@qedswtrue% |
244 | \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}% |
245 | } |
246 | % \end{macrocode} |
247 | % |
248 | % \end{macro} |
249 | % |
86f6a31e |
250 | % \begin{environment}{proof} |
251 | % |
252 | % Now to hack the proof environment. |
253 | % |
254 | % \begin{macrocode} |
255 | \renewenvironment{proof}[1][\proofname]{% |
256 | \setcounter{claim}{0}% |
257 | \par\normalfont% |
fe474f79 |
258 | \ifdim\topsep<\parskip\topsep\parskip\fi% |
259 | \ifdim\@topsepadd<\z@\@topsepadd\z@\fi% |
260 | \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle% |
86f6a31e |
261 | \advance\@topsep-\parskip% |
262 | \advance\@topsepadd-\parskip% |
fe474f79 |
263 | \@qedhack% |
264 | \item[#1]% |
86f6a31e |
265 | }{% |
266 | \qed\endtrivlist% |
267 | } |
86f6a31e |
268 | % \end{macrocode} |
269 | % \end{environment} |
270 | % |
fe474f79 |
271 | % \begin{macro}{\proofstyle} |
272 | % |
273 | % The |\proofstyle| macro is just a style hook for typesetting the `Proof' |
274 | % label. |
275 | % |
276 | % \begin{macrocode} |
277 | \providecommand\proofstyle[1]{\textit{#1.}} |
278 | % \end{macrocode} |
279 | % |
280 | % \end{macro} |
281 | % |
86f6a31e |
282 | % Done. |
283 | % |
284 | % \begin{macrocode} |
285 | %</package> |
286 | % \end{macrocode} |
287 | % |
288 | %^^A------------------------------------------------------------------------- |
289 | % \section{Implementation of the theorem style} |
290 | % |
291 | % \begin{macrocode} |
292 | %<*thmstyle> |
293 | % \end{macrocode} |
294 | % |
295 | % \begin{macro}{\thmhead@margin} |
296 | % |
297 | % Firstly, a macro to typeset the theorem environment header, with the number |
298 | % in the margin. |
299 | % |
300 | % \begin{macrocode} |
301 | \def\thmhead@margin#1#2#3{% |
302 | \thmnumber{\llap{#2{\normalsize\quad}}}% |
303 | \thmname{#1}% |
304 | \thmnote{ \the\thm@notefont(#3)}% |
305 | } |
306 | % \end{macrocode} |
307 | % \end{macro} |
308 | % |
309 | % \begin{macro}{\thm@headfont@margin} |
310 | % |
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. |
314 | % |
315 | % \begin{macrocode} |
316 | \def\thm@headfont@margin{% |
fe474f79 |
317 | \fontseries{\bfdefault}% |
86f6a31e |
318 | \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi% |
319 | \selectfont% |
320 | } |
321 | % \end{macrocode} |
322 | % \end{macro} |
323 | % |
324 | % \begin{macro}{\qedsymbol} |
325 | % |
326 | % Use the nice symbol if available. |
327 | % |
328 | % \begin{macrocode} |
329 | \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi} |
330 | % \end{macrocode} |
331 | % \end{macro} |
332 | % |
fe474f79 |
333 | % \begin{macro}{\proofstyle} |
86f6a31e |
334 | % |
fe474f79 |
335 | % Typeset `Proof' in bold face. |
86f6a31e |
336 | % |
337 | % \begin{macrocode} |
fe474f79 |
338 | \def\proofstyle#1{{\thm@headfont@margin#1}} |
339 | % \end{macrocode} |
340 | % |
341 | % \end{macro} |
342 | % |
343 | % \begin{macro}{\th@base} |
344 | % \begin{macro}{\@endtheorem} |
345 | % |
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. |
348 | % |
349 | % \begin{macrocode} |
350 | \def\th@base#1{% |
351 | \let\thmhead\thmhead@margin% |
352 | \thm@headfont{\thm@headfont@margin}% |
353 | \thm@headpunct{}% |
354 | \advance\thm@postskip-\parskip% |
355 | \@qedhack% |
356 | \def\after@thm{#1}% |
357 | \normalfont% |
86f6a31e |
358 | } |
fe474f79 |
359 | % \end{macrocode} |
360 | % |
361 | % Ah, but nobody actually does anything with |\after@thm|. Let's fix that. |
362 | % |
363 | % \begin{macrocode} |
48c66928 |
364 | \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist\@endpefalse}} |
fe474f79 |
365 | % \end{macrocode} |
366 | % \end{macro} |
367 | % \end{macro} |
368 | % |
369 | % \begin{macro}{\th@plain} |
370 | % \begin{macro}{\th@definition} |
371 | % \begin{macro}{\th@remark} |
372 | % |
373 | % Now this is easy. The space hacking in |\th@remark| is straight from |
374 | % \package{amsthm}. |
375 | % |
376 | % \begin{macrocode} |
377 | \AtBeginDocument{ |
378 | \def\th@plain{\th@base\relax\itshape} |
379 | \def\th@definition{\th@base\qed} |
380 | \def\th@remark{% |
381 | \th@base\qed% |
382 | \thm@preskip\topsep\divide\thm@preskip\tw@% |
383 | \thm@postskip\thm@preskip% |
384 | } |
385 | } |
86f6a31e |
386 | %</thmstyle> |
387 | % \end{macrocode} |
388 | % \end{macro} |
fe474f79 |
389 | % \end{macro} |
390 | % \end{macro} |
86f6a31e |
391 | % |
392 | % \hfill Mark Wooding, \today |
393 | % \Finale |
394 | % |
395 | \endinput |