-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrtthesis-theorems.sty
263 lines (233 loc) · 9.34 KB
/
rtthesis-theorems.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
\ProvidesPackage{rtthesis-theorems}[2010/02/18 Theorem-like environments for the rtthesis class]
\@ifpackageloaded{rtthesis-captions}{}{% If not loaded...
\PackageError{rtthesis-theorems}{%
The package rtthesis-captions must be loaded\MessageBreak
before rtthesis-theorems. Since\MessageBreak
rtthesis-theorems cannot guess which\MessageBreak
character encoding you prefer, it won't\MessageBreak
load rtthesis-captions for you, so you have\MessageBreak
to do it yourself%
}{%
The package rtthesis-captions must be loaded\MessageBreak
before rtthesis-theorems. Since\MessageBreak
rtthesis-theorems cannot guess which\MessageBreak
character encoding you prefer, it won't\MessageBreak
load rtthesis-captions for you, so you have\MessageBreak
to do it yourself%
}
}
% Use same counter for theorem-like environments?
\newif\ifrtthm@shareTheoremCounter
\DeclareOption{sharecounter}{\rtthm@shareTheoremCountertrue}
\DeclareOption{nosharecounter}{\rtthm@shareTheoremCounterfalse}
\ExecuteOptions{nosharecounter}
% Put breaks after theorem (and similar) labels?
\newif\ifrtthm@break
\DeclareOption{break}{\rtthm@breaktrue}
\DeclareOption{nobreak}{\rtthm@breakfalse}
\ExecuteOptions{nobreak}
% Choice of definition style
\newif\ifrt@definitionNotTheorem
\newif\ifrt@definitionMarks
\DeclareOption{definition=theorem}{\rt@definitionNotTheoremfalse}
\DeclareOption{definition=naked}{\rt@definitionNotTheoremtrue\rt@definitionMarksfalse}
\DeclareOption{definition=marks}{\rt@definitionNotTheoremtrue\rt@definitionMarkstrue}
\ExecuteOptions{definition=naked}
% Should we use italics or slanted text in theorems?
\newif\ifrtthm@slanted
\DeclareOption{slanted}{\rtthm@slantedtrue}
\DeclareOption{italics}{\rtthm@slantedfalse}
\ExecuteOptions{italics}
% Use parskip.sty and adjust sectioning commands?
\newif\ifrtthm@parskipDefault
\rtthm@parskipDefaulttrue
\newif\ifrtthm@parskip
\DeclareOption{noparskip}{\rtthm@parskipfalse\rtthm@parskipDefaultfalse}
\DeclareOption{parskip}{\rtthm@parskiptrue\rtthm@parskipDefaultfalse}
\@ifpackageloaded{parskip}{%
\rtthm@parskiptrue
}{% In case KpFonts was not loaded:
\rtthm@parskipfalse
\AtBeginDocument{%
\ifrtthm@parskipDefault
\@ifpackageloaded{parskip}{%
\PackageWarningNoLine{rtthesis-theorems}{%
The default setting regarding `parskip' or\MessageBreak
`noparskip' is `noparskip' since package\MessageBreak
parskip was loaded after \MessageBreak
rtthesis-theorems. This is probably not\MessageBreak
what you want. Avoid this warning by\MessageBreak
explicitly passing one of the options\MessageBreak
`parskip' or `noparskip', or change the\MessageBreak
package loading order
}}{}%
\fi
}
}
% When should counters be reset?
% Use same counter for theorem-like environments?
\DeclareOption{reset=chapter}{\def\rtthm@reset{chapter}}
\DeclareOption{reset=section}{\def\rtthm@reset{section}}
\@ifundefined{thechapter}{%
\ExecuteOptions{reset=section}}{%
\ExecuteOptions{reset=chapter}}
\ProcessOptions\relax
\RequirePackage{amsthm}
\ifrtthm@slanted
% It's dangerous to use the italic shape, since italic small caps seem hard to find.
\let\theoremshape\slshape
\else
\let\theoremshape\itshape
\fi
\newlength{\rt@theoremtopskip}
\ifrtthm@parskip
\setlength{\rt@theoremtopskip}{1.5\parskip plus 1.5pt}
\else
\setlength{\rt@theoremtopskip}{0.5em plus 1.5pt}
\fi
% In case the user adjusts this length, and later decides not to use marks, we define the following length no matter whether marks are used or not.
\newlength{\rt@definitionlinewidth}
\setlength{\rt@definitionlinewidth}{0.3pt}
\ifrt@definitionMarks
\newcommand{\rt@definitionBeginMark}{%
\begin{picture}(0,0)
\settoheight{\unitlength}{(D)}
\linethickness{\rt@definitionlinewidth}
\put(-0.3,1.3){\line(0,-1){0.5}}
\put(-0.3,1.3){\line(1,0){4}}
\end{picture}%
}
\newcommand{\rt@definitionEndMark}{%
\unskip
% Whether we are in vmode here seems to depend on whether we are using parskip...
\ifrtthm@parskip
\ifvmode
\nopagebreak\vspace{-\baselineskip}%
\fi
\fi
\ifhmode
\nopagebreak\\[-1\baselineskip]%
\fi
\nopagebreak\hspace*{\linewidth}%
\begin{picture}(0,0)
\settoheight{\unitlength}{(D)}
\linethickness{\rt@definitionlinewidth}
\put(0.3,-0.3){\line(0,1){0.5}}
\put(0.3,-0.3){\line(-1,0){4}}
\end{picture}%
}
\newcommand{\rt@topmarkskip}{%
\settoheight{\unitlength}{(D)}%
\ifhmode
\par\vspace{-\rt@theoremtopskip}\vspace{0.3\unitlength}%
\else
\setlength{\unitlength}{0.3\unitlength}%
\addtolength{\unitlength}{\parskip}
\addvspace{\unitlength}%
\fi
}
\newcommand{\rt@botmarkskip}{%
\settoheight{\unitlength}{(D)}%
\setlength{\unitlength}{0.3\unitlength}%
\addtolength{\unitlength}{\parskip}
\addvspace{\unitlength}%
%%% The following line does more than just cancelling the \addtolength{\unitlength}{\parskip} above.
\rt@unparskip% Next thing that happens will probably be a \par, but we don't want that extra \parskip.
%
%%% By leaving TeX in hmode, it might be possible to continue the paragraph right after the environment...
%%% but how exactly should this be done?!
%%% One should probably redefine \par temporarily so that it produces the correct after-theorem space and then
%%% resets itself to the usual \par. This would work as long as a \par is actually the first thing that follows
%%% the environment. However, if the user really continues to add stuff in hmode, then this must be detected so that
%%% we can reset \par to its usual meaning before the user leaves hmode. The important question seems to be:
%%% How can we detect that the user is adding stuff in hmode before we reach the next \par?
}
\else
\newcommand{\rt@definitionBeginMark}{\relax}
\newcommand{\rt@definitionEndMark}{\relax}
\newcommand{\rt@topmarkskip}{%
\ifhmode
\par\vspace{-\rt@theoremtopskip}%
\fi
}
\newcommand{\rt@botmarkskip}{%
\rt@unparskip
%
%%% By leaving TeX in hmode, it might be possible to continue the paragraph right after the environment...
%%% See comments above.
}
\fi
\ifrtthm@shareTheoremCounter
\newtheoremstyle{break}{\rt@theoremtopskip}{\rt@theoremtopskip}{\theoremshape}{}{\bfseries}{}
{\newline}{\thmnumber{#2}\enspace\thmname{#1}\thmnote{~(#3)}}
\newtheoremstyle{nobreak}{\rt@theoremtopskip}{\rt@theoremtopskip}{\theoremshape}{}{\bfseries}{.}
{.75em}{\thmnumber{#2}\enspace\thmname{#1}\thmnote{~(#3)}}
\newtheoremstyle{definition}{\rt@theoremtopskip}{\rt@theoremtopskip}{\normalfont}{}{\bfseries}{.}
{.75em}{\rt@definitionBeginMark\thmnumber{#2}\enspace\thmname{#1}\thmnote{~(#3)}}
\newtheoremstyle{remark}{\rt@theoremtopskip}{\rt@theoremtopskip}{\normalfont\small}{}{\slshape}{.}
{.75em}{\rt@definitionBeginMark\thmnumber{#2}\enspace\thmname{#1}\thmnote{~(#3)}}
\else
\newtheoremstyle{break}{\rt@theoremtopskip}{\rt@theoremtopskip}{\theoremshape}{}{\bfseries}{}
{\newline}{\thmname{#1}~\thmnumber{#2}\thmnote{~(#3)}}
\newtheoremstyle{nobreak}{\rt@theoremtopskip}{\rt@theoremtopskip}{\theoremshape}{}{\bfseries}{.}
{.75em}{\thmname{#1}~\thmnumber{#2}\thmnote{~(#3)}}
\newtheoremstyle{definition}{\rt@theoremtopskip}{\rt@theoremtopskip}{\normalfont}{}{\bfseries}{.}
{.75em}{\rt@definitionBeginMark\thmname{#1}~\thmnumber{#2}\thmnote{~(#3)}}
\newtheoremstyle{remark}{\rt@theoremtopskip}{\rt@theoremtopskip}{\normalfont\small}{}{\slshape}{.}
{.75em}{\rt@definitionBeginMark\thmname{#1}~\thmnumber{#2}\thmnote{~(#3)}}
\fi
\ifrtthm@break
\theoremstyle{break}
\else
\theoremstyle{nobreak}
\fi
\ifrtthm@shareTheoremCounter
\newtheorem{theorem}{\theoremname}[\rtthm@reset]
\newtheorem{lemma}[theorem]{\lemmaname}
\newtheorem{corollary}[theorem]{\corollaryname}
\newtheorem{proposition}[theorem]{\propositionname}
\else
\newtheorem{theorem}{\theoremname}[\rtthm@reset]
\newtheorem{lemma}{\lemmaname}[\rtthm@reset]
\newtheorem{corollary}{\corollaryname}[\rtthm@reset]
\newtheorem{proposition}{\propositionname}[\rtthm@reset]
\fi
\ifrt@definitionNotTheorem
\theoremstyle{definition}% Change theorem style unless the user prefers to use the break/nobreak style also for definitions.
\fi
\ifrtthm@shareTheoremCounter
\newtheorem{rt@definition}[theorem]{\definitionname}
\newtheorem{rt@assumption}[theorem]{\assumptionname}
\else
\newtheorem{rt@definition}{\definitionname}[\rtthm@reset]
\newtheorem{rt@assumption}{\assumptionname}[\rtthm@reset]
\fi
\renewcommand*{\thert@assumption}{A\arabic{rt@assumption}}
\newenvironment{definition}{\rt@topmarkskip\begin{rt@definition}}{\rt@definitionEndMark\end{rt@definition}\rt@botmarkskip}
\newenvironment{assumption}{\rt@topmarkskip\begin{rt@assumption}}{\rt@definitionEndMark\end{rt@assumption}\rt@botmarkskip}
\theoremstyle{remark}
\ifrtthm@shareTheoremCounter
\newtheorem{rt@remark}[theorem]{\remarkname}
\else
\newtheorem{rt@remark}{\remarkname}[\rtthm@reset]
\fi
\newenvironment{remark}{\rt@topmarkskip\begin{rt@remark}}{\rt@definitionEndMark\end{rt@remark}\rt@botmarkskip}
\renewenvironment{proof}[1][\proofname]{\par
\pushQED{\qed}%
\normalfont \topsep6\p@\@plus6\p@\relax
\trivlist
\item[\hskip\labelsep\bfseries#1\@addpunct{:}]\ignorespaces
}{%
\popQED\endtrivlist\@endpefalse
}
\ifrtthm@parskip
\newcommand{\rt@unparskip}{%
\vspace{-\parskip}% It's hard to know which is best of \addvspace and \vspace here...
}
%%% Adjust space before proof environment
\let\ams@proof\proof
\let\ams@endproof\endproof
\renewenvironment{proof}{\rt@unparskip\ams@proof}{\ams@endproof}
\else
\newcommand{\rt@unparskip}{\relax}
\fi