1 % \begin{meta-comment} <general public licence>
3 %% mdwthm package -- standard theorem stuff
4 %% Copyright (c) 2001--2003, 2006, 2008 Mark Wooding
6 %% This program is free software; you can redistribute it and/or modify
7 %% it under the terms of the GNU General Public License as published by
8 %% the Free Software Foundation; either version 2 of the License, or
9 %% (at your option) any later version.
11 %% This program is distributed in the hope that it will be useful,
12 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
13 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 %% GNU General Public License for more details.
16 %% You should have received a copy of the GNU General Public License
17 %% along with this program; if not, write to the Free Software Foundation,
18 %% Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 % \begin{meta-comment} <Package preambles>
22 %<+package>\NeedsTeXFormat{LaTeX2e}
23 %<+package>\ProvidesPackage{mdwthm}
24 %<+package> [2020/09/06 1.14.0 Theorem typesetting]
25 %<+thmstyle>\ProvidesFile{mdwmargin.thm}
26 %<+thmstyle> [2020/09/06 1.14.0 Numbers-in-the-margin theorem style]
31 %% {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
32 %% 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
33 %% Digits \0\1\2\3\4\5\6\7\8\9
34 %% Exclamation \! Double quote \" Hash (number) \#
35 %% Dollar \$ Percent \% Ampersand \&
36 %% Acute accent \' Left paren \( Right paren \)
37 %% Asterisk \* Plus \+ Comma \,
38 %% Minus \- Point \. Solidus \/
39 %% Colon \: Semicolon \; Less than \<
40 %% Equals \= Greater than \> Question mark \?
41 %% Commercial at \@ Left bracket \[ Backslash \\
42 %% Right bracket \] Circumflex \^ Underscore \_
43 %% Grave accent \` Left brace \{ Vertical bar \|
44 %% Right brace \} Tilde \~}
47 % \begin{meta-comment}
51 \describespackage{mdwthm}
57 %^^A-------------------------------------------------------------------------
58 % \section{User guide}
60 % \subsection{Environments provided}
62 % \DescribeEnv{theorem}
64 % \DescribeEnv{proposition}
65 % \DescribeEnv{corollary}
66 % \DescribeEnv{definition}
67 % \DescribeEnv{example}
69 % \DescribeEnv{remark}
71 % The package defines a collection of theorem environments, declared in the
72 % usual way. All of them except \env{claim} share the same counter. If the
73 % document class has a |\chapter| command, then they are numbered within the
74 % chapter; otherwise there is a single numbering system throughout the
77 % Every environment has a $*$-version, which doesn't print a number. This
78 % might be useful every now and then.
80 % The environments \env{theorem}, \env{lemma}, \env{proposition},
81 % \env{claim}and \env{corollary} are set using the `plain' style, with the
82 % body text in \textit{italics}. The environments \env{definition} and
83 % \env{example} are set in the `definition' style, with body text in roman.
84 % The remaining environments, \env{fact}, \env{remark}, and \env{note} are
85 % set in the `remark' style.
89 % The \env{claim} environment has its own counter, which is reset at the
90 % beginning of the \env{proof} environment. If you say |\qed| in a
91 % \env{proof} environment then it uses your symbol; otherwise it adds its own
94 % \subsection{Options}
96 % The package takes an option \syntax{"within="<counter>} -- number theorems
97 % within \<counter>. If this isn't given, a default is chosen -- either
98 % numbering in chapters, or global numbering. The \lit*{notwithin} option
99 % forces global numbering.
101 % \subsection{The \package{mdwmargin} style}
103 % This package also provides a pretty `number-hanging-in-the-margin' theorem
104 % style collection, available under the name \env{mdwmargin}.
109 %^^A-------------------------------------------------------------------------
110 % \section{Implementation of the environments}
114 \RequirePackage{mdwkey}
116 \ifx\if@article\iftrue0
117 \else\ifx\chapter\@@undefined0
118 \else\ifx\chapter\relax0
120 \def\mt@within{[chapter]}
124 \mkdef{mdwthm:opt}{within}{\def\mt@within{[#1]}}
125 \mkdef{mdwthm:opt}{notwithin}*{\def\mt@within{}}
126 \mkdef*{mdwthm:opt}{\PassOptionsToPackage{#1=#2}{amsthm}}
127 \mkdef*{mdwthm:opt}*{\PassOptionsToPackage{#1}{amsthm}}
128 \def\mt@opt#1{\mkparse{mdwthm:opt}{#1}}
129 \DeclareOption*{\expandafter\mt@opt\expandafter{\CurrentOption}}
131 \RequirePackage{amsthm}
134 % \subsection{The simple bits}
136 % \begin{environment}{theorem}
138 % Do the right thing with the numbering rules.
141 \edef\next@{\noexpand\newtheorem{theorem}{Theorem}\mt@within}\next@
142 \newtheorem*{theorem*}{Theorem}
147 % \begin{environment}{lemma}
148 % \begin{environment}{proposition}
149 % \begin{environment}{corollary}
150 % \begin{environment}{claim}
151 % \begin{environment}{definition}
152 % \begin{environment}{example}
153 % \begin{environment}{fact}
154 % \begin{environment}{remark}
156 % Most of this is very easy.
160 \newtheorem{lemma}[theorem]{Lemma}
161 \newtheorem*{lemma*}{Lemma}
162 \newtheorem{proposition}[theorem]{Proposition}
163 \newtheorem*{proposition*}{Proposition}
164 \newtheorem{corollary}[theorem]{Corollary}
165 \newtheorem*{corollary*}{Corollary}
166 \newtheorem{fact}[theorem]{Fact}
167 \newtheorem*{fact*}{Fact}
168 \newtheorem{claim}{Claim}
169 \newtheorem*{claim*}{Claim}
173 \theoremstyle{definition}
174 \newtheorem{definition}[theorem]{Definition}
175 \newtheorem*{definition*}{Definition}
176 \newtheorem{example}[theorem]{Example}
177 \newtheorem*{example*}{Example}
181 \theoremstyle{remark}
182 \newtheorem{remark}[theorem]{Remark}
183 \newtheorem*{remark*}{Remark}
195 % \begin{environment}{note}
197 % Someone else might also have a \env{note} environment. Be careful.
200 \ifx\note\@@undefined
201 \newtheorem{note}[theorem]{Note}
202 \newtheorem*{note*}{Note}
208 % \begin{macro}{\@qedhack}
210 % Make |\qed| idempotent.
217 \def\qed{\if@qedsw\global\@qedswfalse\expandafter\@qed@\fi}%
223 % \begin{environment}{proof}
225 % Now to hack the proof environment.
228 \renewenvironment{proof}[1][\proofname]{%
229 \setcounter{claim}{0}%
231 \ifdim\topsep<\parskip\topsep\parskip\fi%
232 \ifdim\@topsepadd<\z@\@topsepadd\z@\fi%
233 \trivlist\advance\itemindent\labelsep\let\makelabel\proofstyle%
234 \advance\@topsep-\parskip%
235 \advance\@topsepadd-\parskip%
244 % \begin{macro}{\proofstyle}
246 % The |\proofstyle| macro is just a style hook for typesetting the `Proof'
250 \providecommand\proofstyle[1]{\textit{#1.}}
261 %^^A-------------------------------------------------------------------------
262 % \section{Implementation of the theorem style}
268 % \begin{macro}{\thmhead@margin}
270 % Firstly, a macro to typeset the theorem environment header, with the number
274 \def\thmhead@margin#1#2#3{%
275 \thmnumber{\llap{#2{\normalsize\quad}}}%
277 \thmnote{ \the\thm@notefont(#3)}%
282 % \begin{macro}{\thm@headfont@margin}
284 % Now to decide on the header font. Definitely we want boldface; if the
285 % documentclass (or \package{mdwfonts}) has decided on a different font
286 % family for the headings, then we use that.
289 \def\thm@headfont@margin{%
290 \fontseries{\bfdefault}%
291 \ifx\headdefault\@@undfined\else\fontfamily\headdefault\fi%
297 % \begin{macro}{\qedsymbol}
299 % Use the nice symbol if available.
302 \AtBeginDocument{\ifx\square\@@undefined\else\def\qedsymbol{$\square$}\fi}
306 % \begin{macro}{\proofstyle}
308 % Typeset `Proof' in bold face.
311 \def\proofstyle#1{{\thm@headfont@margin#1}}
316 % \begin{macro}{\th@base}
317 % \begin{macro}{\@endtheorem}
319 % The |\th@base| macro provides the basis for our theorem style. The
320 % argument is something to do at the end of the environment.
324 \let\thmhead\thmhead@margin%
325 \thm@headfont{\thm@headfont@margin}%
327 \advance\thm@postskip-\parskip%
334 % Ah, but nobody actually does anything with |\after@thm|. Let's fix that.
337 \AtEndOfPackage{\def\@endtheorem{\after@thm\endtrivlist}}
342 % \begin{macro}{\th@plain}
343 % \begin{macro}{\th@definition}
344 % \begin{macro}{\th@remark}
346 % Now this is easy. The space hacking in |\th@remark| is straight from
351 \def\th@plain{\th@base\relax\itshape}
352 \def\th@definition{\th@base\qed}
355 \thm@preskip\topsep\divide\thm@preskip\tw@%
356 \thm@postskip\thm@preskip%
365 % \hfill Mark Wooding, \today