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