1 % \begin{meta-comment} <general public licence>
3 %% mdwthm package -- standard theorem stuff
4 %% Copyright (c) 2001--2003, 2006, 2008 Mark Wooding
6 %% This file is part of the `mdwtools' LaTeX package collection.
8 %% `mdwtools' is free software: you can redistribute it and/or modify it
9 %% under the terms of the GNU General Public License as published by the
10 %% Free Software Foundation; either version 2 of the License, or (at your
11 %% option) any later version.
13 %% `mdwtools' is distributed in the hope that it will be useful, but
14 %% WITHOUT ANY WARRANTY; without even the implied warranty of
15 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 %% General Public License for more details.
18 %% You should have received a copy of the GNU General Public License
19 %% along with `mdwtools'. If not, write to the Free Software Foundation,
20 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 % \begin{meta-comment} <Package preambles>
25 %<+package>\NeedsTeXFormat{LaTeX2e}
26 %<+package>\ProvidesPackage{mdwthm}
27 %<+package> [2020/09/06 1.14.0 Theorem typesetting]
28 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
29 %<+thmstyle> [2020/09/06 1.14.0 Numbers-in-the-margin theorem style]
34 %% {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
35 %% 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
36 %% Digits \0\1\2\3\4\5\6\7\8\9
37 %% Exclamation \! Double quote \" Hash (number) \#
38 %% Dollar \$ Percent \% Ampersand \&
39 %% Acute accent \' Left paren \( Right paren \)
40 %% Asterisk \* Plus \+ Comma \,
41 %% Minus \- Point \. Solidus \/
42 %% Colon \: Semicolon \; Less than \<
43 %% Equals \= Greater than \> Question mark \?
44 %% Commercial at \@ Left bracket \[ Backslash \\
45 %% Right bracket \] Circumflex \^ Underscore \_
46 %% Grave accent \` Left brace \{ Vertical bar \|
47 %% Right brace \} Tilde \~}
50 % \begin{meta-comment}
54 \describespackage{mdwthm}
60 %^^A-------------------------------------------------------------------------
61 % \section{User guide}
63 % \subsection{Environments provided}
65 % \DescribeEnv{theorem}
67 % \DescribeEnv{proposition}
68 % \DescribeEnv{corollary}
69 % \DescribeEnv{definition}
70 % \DescribeEnv{example}
72 % \DescribeEnv{remark}
74 % The package defines a collection of theorem environments, declared in the
75 % usual way. All of them except \env{claim} share the same counter. If the
76 % document class has a |\chapter| command, then they are numbered within the
77 % chapter; otherwise there is a single numbering system throughout the
80 % Every environment has a $*$-version, which doesn't print a number. This
81 % might be useful every now and then.
83 % The environments \env{theorem}, \env{lemma}, \env{proposition},
84 % \env{claim}and \env{corollary} are set using the `plain' style, with the
85 % body text in \textit{italics}. The environments \env{definition} and
86 % \env{example} are set in the `definition' style, with body text in roman.
87 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
88 % set in the `remark' style.
92 % The \env{claim} environment has its own counter, which is reset at the
93 % beginning of the \env{proof} environment. If you say |\qed| in a
94 % \env{proof} environment then it uses your symbol; otherwise it adds its own
97 % \subsection{Options}
99 % The package takes an option \syntax{"within="<counter>} -- number theorems
100 % within \<counter>. If this isn't given, a default is chosen -- either
101 % numbering in chapters, or global numbering. The \lit*{notwithin} option
102 % forces global numbering.
104 % \subsection{The \package{mdwmargin} style}
106 % This package also provides a pretty `number-hanging-in-the-margin' theorem
107 % style collection, available under the name \env{mdwmargin}.
112 %^^A-------------------------------------------------------------------------
113 % \section{Implementation of the environments}
117 \RequirePackage{mdwkey}
119 \ifx\if@article\iftrue0
120 \else\ifx\chapter\@@undefined0
121 \else\ifx\chapter\relax0
123 \def\mt@within{[chapter]}
127 \mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}}
128 \mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}}
129 \mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}}
130 \mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}}
131 \def\mt@opt#1{\mkparse{mdwthm:opt}{#1}}
132 \DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}}
134 \RequirePackage{amsthm}
137 % \subsection{The simple bits}
139 % \begin{environment}{theorem}
141 % Do the right thing with the numbering rules.
144 \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@
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{macro}{\@qedhack}
213 % Make |\qed| idempotent.
220 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
226 % \begin{environment}{proof}
228 % Now to hack the proof environment.
231 \renewenvironment{proof}[1][\proofname]{%
232 \setcounter{claim}{0}%
234 \ifdim\topsep<\parskip\topsep\parskip\fi%
235 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
236 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
237 \advance\@topsep-\parskip%
238 \advance\@topsepadd-\parskip%
247 % \begin{macro}{\proofstyle}
249 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
253 \providecommand\proofstyle[1]{\textit{#1.}}
264 %^^A-------------------------------------------------------------------------
265 % \section{Implementation of the theorem style}
271 % \begin{macro}{\thmhead@margin}
273 % Firstly, a macro to typeset the theorem environment header, with the number
277 \def\thmhead@margin#1#2#3{%
278 \thmnumber{\llap{#2{\normalsize\quad}}}%
280 \thmnote{ \the\thm@notefont(#3)}%
285 % \begin{macro}{\thm@headfont@margin}
287 % Now to decide on the header font. Definitely we want boldface; if the
288 % documentclass (or \package{mdwfonts}) has decided on a different font
289 % family for the headings, then we use that.
292 \def\thm@headfont@margin{%
293 \fontseries{\bfdefault}%
294 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
300 % \begin{macro}{\qedsymbol}
302 % Use the nice symbol if available.
305 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
309 % \begin{macro}{\proofstyle}
311 % Typeset `Proof' in bold face.
314 \def\proofstyle#1{{\thm@headfont@margin#1}}
319 % \begin{macro}{\th@base}
320 % \begin{macro}{\@endtheorem}
322 % The |\th@base| macro provides the basis for our theorem style. The
323 % argument is something to do at the end of the environment.
327 \let\thmhead\thmhead@margin%
328 \thm@headfont{\thm@headfont@margin}%
330 \advance\thm@postskip-\parskip%
337 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
340 \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist}}
345 % \begin{macro}{\th@plain}
346 % \begin{macro}{\th@definition}
347 % \begin{macro}{\th@remark}
349 % Now this is easy. The space hacking in |\th@remark| is straight from
354 \def\th@plain{\th@base\relax\itshape}
355 \def\th@definition{\th@base\qed}
358 \thm@preskip\topsep\divide\thm@preskip\tw@%
359 \thm@postskip\thm@preskip%
368 % \hfill Mark Wooding, \today