]> mj.ucw.cz Git - saga.git/blob - macros.tex
Partitioning done.
[saga.git] / macros.tex
1 % TeX macros for typesetting my PhD thesis
2 % (c) 2008 Martin Mares <mj@ucw.cz>
3
4 \input epsf.tex
5 \input btxmac.tex
6 \input amssym.tex
7
8 \catcode`@=11
9
10 %%% Basic parameters %%%
11
12 % A4 with 1in margins, leaving 20pt for page numbering at the bottom
13 \hsize=159mm
14 \vsize=246mm
15 \advance\vsize by -20pt
16 \parindent=0.8cm
17 \parskip=3pt plus 1pt minus 1pt
18
19 \smallskipamount=4pt plus 1.2pt minus 1.2pt
20 \medskipamount=7pt plus 2.5pt minus 2pt
21 \bigskipamount=15pt plus 5pt minus 4pt
22
23 \abovedisplayskip=15pt plus 4pt minus 10pt
24 \abovedisplayshortskip=0pt plus 3pt
25 \belowdisplayskip=15pt plus 4pt minus 10pt
26 \belowdisplayshortskip=8.5pt plus 3.5pt minus 4.5pt
27
28 %%% Miscellanea %%%
29
30 \def\em#1{{\it #1\/}}
31 \def\df#1{{\it #1\/}}   % when we define something
32 \def\O{{\cal O}}
33 \def\<#1>{\ifmmode
34     \mathchoice{\hbox{\it #1\/}}{\hbox{\it #1\/}}{\hbox{\eightti #1\/}}{\hbox{\sixti #1\/}}%
35   \else\leavevmode\hbox{\it #1\/}\fi}
36 \let\>=\noindent
37 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\spadesuit$\par}}
38 \def\qeditem{{\parfillskip=0pt\hfill\rlap{\hskip\rightskip\llap{$\spadesuit$}}\par}}
39 \def\qedmath{\eqno{\spadesuit}}
40 \def\FIXME#1{\>{\bo TODO:} #1}
41 \def\symdiff{\mathbin{\Delta}}
42 \def\rack#1#2{\setbox0=\hbox{#1}\hbox to \wd0{#2}}
43 \def\o#1{\accent23 #1}
44 \def\mst{\mathop{\rm mst}}
45 \def\msf{\mathop{\rm msf}}
46 \def\deg{\mathop{\rm deg}}
47 \def\timesalpha{\mskip2mu\alpha}
48 \def\timesbeta{\mskip2mu\beta}
49 \def\tower{\mathop\uparrow}
50 \def\Forb{{\rm Forb}}
51 \def\minorof{\preccurlyeq}
52 \def\per{\mathop{\rm per}}
53 \def\poly{\mathop{\rm poly}}
54 \def\E{{\bb E}}
55 \def\crpt{\mathop{\Uparrow}}
56
57 \def\brk{\hfil\break}
58
59 % Bit strings
60 \def\0{{\bf 0}}
61 \def\1{{\bf 1}}
62 \def\(#1){\mathord{\left<#1\right>}}
63
64 % Bitwise operations
65 \def\shl{\mathbin{<\!<}}
66 \def\shr{\mathbin{>\!>}}
67 \def\bop#1{\mathbin{\hbox{\sc #1}}}
68 \def\band{\bop{and}}
69 \def\bor{\bop{or}}
70 \def\bxor{\bop{xor}}
71 \def\bnot{\mathop{\hbox{\sc not}}}
72
73 % A reversed version of \ddots with extra space at the top to get good alignment of exponents.
74 \def\rddots{\mathinner{\mkern1mu\raise\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
75     \raise4\p@\hbox{.}\mkern2mu\raise7\p@\hbox{.}\raise11\p@\hbox{}\mkern1mu}}
76
77 % Footnotes
78 \newcount\footcnt
79 \footcnt=0
80 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\bf\the\footcnt}$}{#1}}}
81
82 %%% Fonts %%%
83
84 \font\twelverm=cmr12
85 \font\twelveit=cmti12
86 \font\twelvebf=cmbx12
87
88 %\font\twelverm=pplr8z at 12pt
89 %\font\twelveit=pplri8z at 12pt
90 %\font\twelvebf=pplb8z at 12pt
91
92 \font\twelvesl=cmsl12
93 \font\twelveb=cmb12
94 \font\twelvesc=cmcsc12
95
96 \def\mathf@nt#1#2#3#4{%
97 \toks0=\expandafter{\csname#1#2\endcsname}%
98 \expandafter\ifx\the\toks0\relax%
99 %\immediate\write-1{bb \the\toks0=#4#2#3}%
100 \global\expandafter\font\the\toks0=#4#2#3%
101 \fi%
102 \edef\m@@f{\the\toks0}}
103
104 \def\fntmathsize{12}
105 \def\fntmathtok{twelve}
106 \def\fntmathssize{8}
107 \def\fntmathstok{eight}
108 \def\fntmathsssize{6}
109 \def\fntmathsstok{six}
110
111 \mathf@nt{\fntmathtok}{r}{\fntmathsize}{cm}\textfont0=\m@@f
112 \mathf@nt{\fntmathstok}{r}{\fntmathssize}{cm}\scriptfont0=\m@@f
113 \mathf@nt{\fntmathsstok}{r}{\fntmathsssize}{cm}\scriptscriptfont0=\m@@f
114 \mathf@nt{\fntmathtok}{mi}{\fntmathsize}{cm}\skewchar\m@@f='177\textfont1=\m@@f
115 \mathf@nt{\fntmathstok}{mi}{\fntmathssize}{cm}\skewchar\m@@f='177\scriptfont1=\m@@f
116 \mathf@nt{\fntmathsstok}{mi}{\fntmathsssize}{cm}\skewchar\m@@f='177\scriptscriptfont1=\m@@f
117 \mathf@nt{\fntmathtok}{sy}{\fntmathsize}{cm}\skewchar\m@@f='60\textfont2=\m@@f
118 \mathf@nt{\fntmathstok}{sy}{\fntmathssize}{cm}\skewchar\m@@f='60\scriptfont2=\m@@f
119 \mathf@nt{\fntmathsstok}{sy}{\fntmathsssize}{cm}\skewchar\m@@f='60\scriptscriptfont2=\m@@f
120 \mathf@nt{\fntmathtok}{ex}{\fntmathsize}{cm}\textfont3=\m@@f\scriptfont3=\m@@f\scriptscriptfont3=\m@@f
121 \mathf@nt{\fntmathtok}{ti}{\fntmathsize}{cm}\textfont\itfam=\m@@f
122 \mathf@nt{\fntmathstok}{ti}{\fntmathssize}{cm}\scriptfont\itfam=\m@@f
123 \mathf@nt{\fntmathsstok}{ti}{\fntmathssize}{cm}\scriptscriptfont\itfam=\m@@f
124 \mathf@nt{\fntmathtok}{sl}{\fntmathsize}{cm}\textfont\slfam=\m@@f
125 \mathf@nt{\fntmathtok}{bx}{\fntmathsize}{cm}\textfont\bffam=\m@@f
126 \mathf@nt{\fntmathtok}{tt}{\fntmathsize}{cm}\hyphenchar\m@@f=-1\textfont\ttfam=\m@@f
127 \mathf@nt{\fntmathtok}{msam}{\fntmathsize}{}\textfont\msafam=\m@@f
128 \mathf@nt{\fntmathstok}{msam}{\fntmathssize}{}\scriptfont\msafam=\m@@f
129 \mathf@nt{\fntmathsstok}{msam}{\fntmathsssize}{}\scriptscriptfont\msafam=\m@@f
130 \mathf@nt{\fntmathtok}{msbm}{\fntmathsize}{}\textfont\msbfam=\m@@f
131 \mathf@nt{\fntmathstok}{msbm}{\fntmathssize}{}\scriptfont\msbfam=\m@@f
132 \mathf@nt{\fntmathsstok}{msbm}{\fntmathsssize}{}\scriptscriptfont\msbfam=\m@@f
133
134 % Blackboard bold font
135 \newfam\bbfam
136 \font\bbtwelve=bbm12
137 \font\bbeight=bbm8
138 \font\bbsix=bbm6
139 \textfont\bbfam=\bbtwelve
140 \scriptfont\bbfam=\bbeight
141 \scriptscriptfont\bbfam=\bbsix
142 \def\bb{\bbtwelve\fam\bbfam}
143
144 % Font switches
145 \def\rm{\fam\z@\twelverm}
146 \def\it{\fam\itfam\twelveit}
147 \def\bo{\fam\bffam\twelveb}
148 \def\bf{\fam\bffam\twelvebf}
149 \def\tt{\fam\ttfam\twelvett\hyphenchar\twelvett=-1\relax}
150 \def\sc{\twelvesc}
151 \def\sl{\fam\slfam\twelvesl}
152
153 % Switch to 12pt baselines
154 \rm
155 \baselineskip=14.4pt
156 \lineskip=1.2pt
157 \setbox\strutbox=\hbox{\vrule height 10.2pt depth 4.2pt width 0pt}
158
159 % Other fonts
160 \font\chapfont=csssdc17 scaled \magstep1
161 \font\secfont=csb14
162 \font\secitfont=csbxti14
163
164 %%% FIXME
165 \footline={\hss\twelverm\folio\hss}
166
167 % We have to redefine \big and friends as we are using 12pt symbols
168 \def\big#1{{\hbox{$\left#1\vbox to11.5\p@{}\right.\n@space$}}}
169 \def\Big#1{{\hbox{$\left#1\vbox to14.5\p@{}\right.\n@space$}}}
170 \def\bigg#1{{\hbox{$\left#1\vbox to17.5\p@{}\right.\n@space$}}}
171 \def\Bigg#1{{\hbox{$\left#1\vbox to20.5\p@{}\right.\n@space$}}}
172
173 %%% Enumerated lists %%%
174
175 \newif\ifitem\itemtrue
176 \newbox\itembox
177 \newcount\itemcount
178
179 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
180
181 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\else
182 \advance\leftskip by 2.5em\fi\rightskip=\leftskip}
183
184 \def\inititemize{\interlistskip\begingroup
185 \parskip=1pt plus 0.3pt minus 0.1pt
186 \itemspacingrules}
187
188 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
189 \let\:=\singleitem}
190
191 \def\singleitem{\par\leavevmode\copy\itembox}
192
193 \def\endlist{\interlistskip\endgroup}
194
195 \def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
196 \def\idot{\raise0.2ex\hbox{$\cdot$}}
197 \def\istar{\raise0.2ex\hbox{$\ast$}}
198
199 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
200 \let\itemnumbering=#1}
201
202 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
203 \llap{\itemnumbering\hskip 0.4em}}
204
205 \def\nnorm{\the\itemcount}
206 \def\ndotted{\nnorm.}
207 \def\nparen{\nnorm)}
208 \def\nroman{\romannumeral\itemcount}
209 \def\nromanp{\nroman)}
210 \def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
211 \def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
212 \def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
213 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
214 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
215
216 % New \frenchspacing, which doesn't leave unwanted spaces in text.
217 \def\frenchsp@cing{\sfcode`\.\@m \sfcode`\?\@m \sfcode`\!\@m%
218 \sfcode`\:\@m \sfcode`\;\@m \sfcode`\,\@m}
219
220 %%% Local verbatim mode %%%
221
222 \def\make@ther#1{\catcode`#1=12\relax}
223 \def\setverb@tim{\tt\frenchsp@cing\catcode`\`=13\catcode`\'=13\n@ligs%
224 \let\do=\make@ther\dospecials\obeyspaces}
225
226 {\catcode`'=13
227 \catcode``=13
228 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
229
230 {\obeyspaces
231 \global\chardef\sp@ce=32
232 \gdef\showspaces{\let =\sp@ce}
233 \global\let =\ }
234
235 \catcode124=\active % Make | active
236 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
237 \let|=\ttst@rt
238
239 %%% Verbatim mode for text in { } %%%
240
241 \newskip\verbglue\newskip\verblineglue
242 \verbglue=3pt plus 1pt minus 0.3pt
243 \verblineglue=0pt plus 1.5pt
244 \def\verblocaldefs{}
245
246 \newdimen\tabwidth
247 \newcount\tabsize
248 \tabsize=8
249 \newdimen\t@b
250
251 \newcount\vercnt
252 \def\v@rbend{\par\endgroup\vskip\verbglue}
253 \def\v@rbl{\ifnum\vercnt>0\{\fi\global\advance\vercnt by 1\relax}
254 \def\v@rbr{\ifnum\vercnt>1\}\else\v@rbend\fi\global\advance\vercnt by -1\relax}
255 \def\v@rbparams{\setverb@tim\parskip=\verblineglue\parindent=0pt\raggedbottom%
256 \rightskip\z@ plus1fil\pretolerance=10000\tolerance=10000\vercnt=0%
257 \catcode124=12\setupt@bs\vskip\verbglue\defb@x\obeylines}
258
259 \def\startb@x{\setbox0=\hbox\bgroup}
260 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
261 \everypar{\startb@x}}
262
263 {\catcode`\^^I=\active
264 \gdef\setupt@bs{\catcode`\^^I=\active
265 \setbox0=\hbox{\tt\ }\tabwidth=\wd0\multiply\tabwidth by \tabsize
266 \def^^I{\leavevmode\egroup\t@b=\wd0\divide\t@b by \tabwidth%
267 \multiply\t@b by \tabwidth%
268 \advance\t@b by \tabwidth\advance\t@b by -\wd0\box0\hbox to \t@b{}\startb@x}
269 }}
270
271 {
272 \catcode`[=1\catcode`]=2\catcode123=\active\catcode125=\active
273 \gdef\verbatim[\begingroup\v@rbparams\catcode123=\active\catcode125=\active%
274 \let{=\v@rbl\let}=\v@rbr\chardef\{=123\chardef\}=125\verblocaldefs
275 ]]
276
277 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
278
279 %%% Algorithms %%%
280
281 %       \algo{jmeno algoritmu}
282 %       \algin popis vstupu
283 %       \:krok
284 %       \:krok
285 %       \::vnoreny krok
286 %       \algout popis vystupu
287 %       \endalgo
288
289 \def\algo{
290 \interlistskip
291 \begingroup
292 \let\:=\algoitem
293 \parskip=1pt plus 1pt minus 0.3pt
294 \rightskip=2em
295 \itemcount=0
296 \smallskip
297 }
298 \def\endalgo{\interlistskip\endgroup}
299 \def\algopar{\par
300 \parindent=2em
301 \hangindent=4em
302 \hangafter=1
303 \leavevmode
304 }
305 \def\algoitem{
306 \algopar\advance\itemcount by 1
307 \hbox to 2em{\hss \the\itemcount. }%
308 \futurelet\next\algoitemh}
309 \def\algoitemh{\ifx\next:\let\next=\algohang\else\let\next=\relax\fi\next}
310 \def\algohang:{\advance\hangindent by 2em \hskip 2em\futurelet\next\algoitemh}
311 \def\algin{\par{\sl Input:\/} }
312 \def\algout{\par{\sl Output:\/} }
313
314 %%% Constructs used in algorithms %%%
315
316 \def\={\leftarrow}
317 \def\cmt#1{~~{\sl (#1)}}
318
319 %%% Chapters, sections and proclamations %%%
320
321 \newcount\chapcount
322 \newcount\seccount
323 \newcount\thmcount
324 \chapcount=0
325 \seccount=0
326 \thmcount=0
327 \def\currentid{??}
328
329 \def\chapter#1{\vfill\supereject
330 \advance\chapcount by 1
331 \seccount=0
332 \thmcount=0
333 \footcnt=0
334 \edef\currentid{\the\chapcount}
335 \leftline{\chapfont\currentid. #1}
336 \bigskip
337 }
338
339 \def\section#1{\bigskip
340 \advance\seccount by 1
341 \thmcount=0
342 \edef\currentid{\the\chapcount.\the\seccount}
343 \leftline{\secfont\currentid. #1}
344 \medskip
345 }
346
347 \def\para{\advance\thmcount by 1
348 \edef\currentid{\the\chapcount.\the\seccount.\the\thmcount}
349 \noindent {\bo \currentid.\enspace}}
350
351 \def\proclaim#1{\para {\bo #1.\enspace}}
352
353 \def\thm{\proclaim{Theorem}}
354 \def\lemma{\proclaim{Lemma}}
355 \def\defn{\proclaim{Definition}}
356 \def\problem{\proclaim{Problem}}
357 \def\obs{\proclaim{Observation}}
358 \def\rem{\proclaim{Remark}}
359 \def\alg{\proclaim{Algorithm}}
360 \def\impl{\proclaim{Implementation}}
361 \def\cor{\proclaim{Corollary}}
362 \def\nota{\proclaim{Notation}}
363 \def\example{\proclaim{Example}}
364
365 \def\label#1{{\sl (#1)\/}\enspace}
366 \def\labelx#1{\label{#1}\hfil\break\kern 0pt}   % Eat spaces
367
368 \def\thmn{\thm\labelx}
369 \def\lemman{\lemma\labelx}
370 \def\defnn{\defn\labelx}
371 \def\corn{\cor\labelx}
372 \def\algn{\alg\label}
373 \def\notan{\nota\labelx}
374 \def\examplen{\example\labelx}
375 \def\problemn{\problem\labelx}
376 \def\remn{\rem\labelx}
377
378 \def\paran#1{\para {\sl #1:}}
379
380 \def\proof{\noindent {\sl Proof.}\enspace}
381 \def\proofsketch{\noindent {\sl Proof sketch.}\enspace}
382
383 %%% References %%%
384
385 \newwrite\ids
386 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
387
388 \immediate\openin\ids=\jobname.ids
389 \ifeof\ids
390 \else
391 \input \jobname.ids
392 \fi
393 \immediate\closein\ids
394 \immediate\openout\ids=\jobname.ids
395
396 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
397 {\bo ??}%
398 \immediate\write16{*** Warning: Reference #1 undefined ***}%
399 \else
400 \csname id#1\endcsname
401 \fi
402 }
403
404 \def\id#1{\writeid{#1}{\currentid}}
405
406 %%% Bibliography %%%
407
408 %\bibliographystyle{abbrv}
409 \bibliographystyle{alpha}
410 \def\dumpbib{
411   \def\bblhook{\parskip=2pt plus 1pt minus 0.5pt}
412   \bibliography{biblio}
413 }
414
415 %%% Figures %%%
416
417 \def\figure#1#2#3{\midinsert
418 \medskip
419 \centerline{\epsfxsize=#2\epsfbox{pic/#1}}
420 \medskip
421 \smallskip
422 \centerline{#3}
423 \endinsert}
424
425 \def\multicap#1{
426 \let\\=\break
427 \vbox{\hsize=0.7\hsize
428 \parindent=0pt
429 \leftskip=0pt plus 0.3\hsize
430 \rightskip=\leftskip
431 \parfillskip=0pt
432 #1
433 }}
434
435 %%% Stand-alone chapters %%%
436
437 \def\endpart{
438   \section{Bibliography}
439   \dumpbib
440   \vfill\supereject\end
441 }
442
443 %%% The End %%%
444
445 \catcode`@=12