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