]> mj.ucw.cz Git - saga.git/blob - macros.tex
Added bibliography.
[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
7 \catcode`@=11
8
9 %%% Basic parameters %%%
10
11 % A4 with 1in margins, leaving 20pt for page numbering at the bottom
12 \hsize=159mm
13 \vsize=246mm
14 \advance\vsize by -20pt
15 \parindent=0.8cm
16 \parskip=3pt plus 1pt minus 1pt
17
18 \smallskipamount=4pt plus 1.2pt minus 1.2pt
19 \medskipamount=7pt plus 2.5pt minus 2pt
20 \bigskipamount=15pt plus 5pt minus 4pt
21
22 \abovedisplayskip=15pt plus 4pt minus 10pt
23 \abovedisplayshortskip=0pt plus 3pt
24 \belowdisplayskip=15pt plus 4pt minus 10pt
25 \belowdisplayshortskip=8.5pt plus 3.5pt minus 4.5pt
26
27 %%% Miscellanea %%%
28
29 \def\em#1{{\it #1\/}}
30 \def\O{{\cal O}}
31 \def\<#1>{\leavevmode\hbox{\it #1\/}}
32 \let\>=\noindent
33 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\spadesuit$\par}}
34
35 % Footnotes
36 \newcount\footcnt
37 \footcnt=0
38 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\left<\the\footcnt\right>}$}{#1}}}
39
40 %%% Fonts %%%
41
42 \font\twelverm=cmr12
43 \font\twelveit=cmti12
44 \font\twelvebf=cmbx12
45
46 %\font\twelverm=pplr8z at 12pt
47 %\font\twelveit=pplri8z at 12pt
48 %\font\twelvebf=pplb8z at 12pt
49
50 \font\twelvesl=cmsl12
51 \font\twelveb=cmb12
52 \font\twelvesc=cmcsc12
53
54 \def\mathf@nt#1#2#3#4{%
55 \toks0=\expandafter{\csname#1#2\endcsname}%
56 \expandafter\ifx\the\toks0\relax%
57 %\immediate\write-1{bb \the\toks0=#4#2#3}%
58 \global\expandafter\font\the\toks0=#4#2#3%
59 \fi%
60 \edef\m@@f{\the\toks0}}
61
62 \def\fntmathsize{12}
63 \def\fntmathtok{twelve}
64 \def\fntmathssize{8}
65 \def\fntmathstok{eight}
66 \def\fntmathsssize{6}
67 \def\fntmathsstok{six}
68
69 \mathf@nt{\fntmathtok}{r}{\fntmathsize}{cm}\textfont0=\m@@f
70 \mathf@nt{\fntmathstok}{r}{\fntmathssize}{cm}\scriptfont0=\m@@f
71 \mathf@nt{\fntmathsstok}{r}{\fntmathsssize}{cm}\scriptscriptfont0=\m@@f
72 \mathf@nt{\fntmathtok}{mi}{\fntmathsize}{cm}\skewchar\m@@f='177\textfont1=\m@@f
73 \mathf@nt{\fntmathstok}{mi}{\fntmathssize}{cm}\skewchar\m@@f='177\scriptfont1=\m@@f
74 \mathf@nt{\fntmathsstok}{mi}{\fntmathsssize}{cm}\skewchar\m@@f='177\scriptscriptfont1=\m@@f
75 \mathf@nt{\fntmathtok}{sy}{\fntmathsize}{cm}\skewchar\m@@f='60\textfont2=\m@@f
76 \mathf@nt{\fntmathstok}{sy}{\fntmathssize}{cm}\skewchar\m@@f='60\scriptfont2=\m@@f
77 \mathf@nt{\fntmathsstok}{sy}{\fntmathsssize}{cm}\skewchar\m@@f='60\scriptscriptfont2=\m@@f
78 \mathf@nt{\fntmathtok}{ex}{\fntmathsize}{cm}\textfont3=\m@@f\scriptfont3=\m@@f\scriptscriptfont3=\m@@f
79 \mathf@nt{\fntmathtok}{ti}{\fntmathsize}{cm}\textfont\itfam=\m@@f
80 \mathf@nt{\fntmathtok}{sl}{\fntmathsize}{cm}\textfont\slfam=\m@@f
81 \mathf@nt{\fntmathtok}{bx}{\fntmathsize}{cm}\textfont\bffam=\m@@f
82 \mathf@nt{\fntmathtok}{tt}{\fntmathsize}{cm}\hyphenchar\m@@f=-1\textfont\ttfam=\m@@f
83
84 % Blackboard bold font
85 \newfam\bbfam
86 \font\bbtwelve=bbm12
87 \font\bbeight=bbm8
88 \font\bbsix=bbm6
89 \textfont\bbfam=\bbtwelve
90 \scriptfont\bbfam=\bbeight
91 \scriptscriptfont\bbfam=\bbsix
92 \def\bb{\bbtwelve\fam\bbfam}
93
94 % Font switches
95 \def\rm{\fam\z@\twelverm}
96 \def\it{\fam\itfam\twelveit}
97 \def\bo{\fam\bffam\twelveb}
98 \def\bf{\fam\bffam\twelvebf}
99 \def\tt{\fam\ttfam\twelvett\hyphenchar\twelvett=-1\relax}
100 \def\sc{\twelvesc}
101 \def\sl{\fam\slfam\twelvesl}
102
103 % Switch to 12pt baselines
104 \rm
105 \baselineskip=14.4pt
106 \lineskip=1.2pt
107 \setbox\strutbox=\hbox{\vrule height 10.2pt depth 4.2pt width 0pt}
108
109 % Other fonts
110 \font\chapfont=csssdc17 scaled \magstep1
111 \font\secfont=csb14
112
113 %%% FIXME
114 \footline={\hss\twelverm\folio\hss}
115
116 %%% Enumerated lists %%%
117
118 \newif\ifitem\itemtrue
119 \newbox\itembox
120 \newcount\itemcount
121
122 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
123
124 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\else
125 \advance\leftskip by 2.5em\fi\rightskip=\leftskip}
126
127 \def\inititemize{\interlistskip\begingroup
128 \parskip=1pt plus 0.3pt minus 0.1pt
129 \itemspacingrules}
130
131 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
132 \let\:=\singleitem}
133
134 \def\singleitem{\par\leavevmode\copy\itembox}
135
136 \def\endlist{\interlistskip\endgroup}
137
138 \def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
139 \def\idot{\raise0.2ex\hbox{$\cdot$}}
140 \def\istar{\raise0.2ex\hbox{$\ast$}}
141
142 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
143 \let\itemnumbering=#1}
144
145 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
146 \llap{\itemnumbering\hskip 0.4em}}
147
148 \def\nnorm{\the\itemcount}
149 \def\ndotted{\nnorm.}
150 \def\nparen{\nnorm)}
151 \def\nroman{\romannumeral\itemcount}
152 \def\nromanp{\nroman)}
153 \def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
154 \def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
155 \def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
156 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
157 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
158
159 % New \frenchspacing, which doesn't leave unwanted spaces in text.
160 \def\frenchsp@cing{\sfcode`\.\@m \sfcode`\?\@m \sfcode`\!\@m%
161 \sfcode`\:\@m \sfcode`\;\@m \sfcode`\,\@m}
162
163 %%% Local verbatim mode %%%
164
165 \def\make@ther#1{\catcode`#1=12\relax}
166 \def\setverb@tim{\tt\frenchsp@cing\catcode`\`=13\catcode`\'=13\n@ligs%
167 \let\do=\make@ther\dospecials\obeyspaces}
168
169 {\catcode`'=13
170 \catcode``=13
171 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
172
173 {\obeyspaces
174 \global\chardef\sp@ce=32
175 \gdef\showspaces{\let =\sp@ce}
176 \global\let =\ }
177
178 \catcode124=\active % Make | active
179 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
180 \let|=\ttst@rt
181
182 %%% Verbatim mode for text in { } %%%
183
184 \newskip\verbglue\newskip\verblineglue
185 \verbglue=3pt plus 1pt minus 0.3pt
186 \verblineglue=0pt plus 1.5pt
187 \def\verblocaldefs{}
188
189 \newdimen\tabwidth
190 \newcount\tabsize
191 \tabsize=8
192 \newdimen\t@b
193
194 \newcount\vercnt
195 \def\v@rbend{\par\endgroup\vskip\verbglue}
196 \def\v@rbl{\ifnum\vercnt>0\{\fi\global\advance\vercnt by 1\relax}
197 \def\v@rbr{\ifnum\vercnt>1\}\else\v@rbend\fi\global\advance\vercnt by -1\relax}
198 \def\v@rbparams{\setverb@tim\parskip=\verblineglue\parindent=0pt\raggedbottom%
199 \rightskip\z@ plus1fil\pretolerance=10000\tolerance=10000\vercnt=0%
200 \catcode124=12\setupt@bs\vskip\verbglue\defb@x\obeylines}
201
202 \def\startb@x{\setbox0=\hbox\bgroup}
203 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
204 \everypar{\startb@x}}
205
206 {\catcode`\^^I=\active
207 \gdef\setupt@bs{\catcode`\^^I=\active
208 \setbox0=\hbox{\tt\ }\tabwidth=\wd0\multiply\tabwidth by \tabsize
209 \def^^I{\leavevmode\egroup\t@b=\wd0\divide\t@b by \tabwidth%
210 \multiply\t@b by \tabwidth%
211 \advance\t@b by \tabwidth\advance\t@b by -\wd0\box0\hbox to \t@b{}\startb@x}
212 }}
213
214 {
215 \catcode`[=1\catcode`]=2\catcode123=\active\catcode125=\active
216 \gdef\verbatim[\begingroup\v@rbparams\catcode123=\active\catcode125=\active%
217 \let{=\v@rbl\let}=\v@rbr\chardef\{=123\chardef\}=125\verblocaldefs
218 ]]
219
220 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
221
222 %%% Algorithms %%%
223
224 %       \algo{jmeno algoritmu}
225 %       \algin popis vstupu
226 %       \:krok
227 %       \:krok
228 %       \::vnoreny krok
229 %       \algout popis vystupu
230 %       \endalgo
231
232 \def\algo#1{
233 \interlistskip
234 \begingroup
235 \let\:=\algoitem
236 \parskip=1pt plus 1pt minus 0.3pt
237 \rightskip=2em
238 \itemcount=0
239 {\bo Algoritmus\/} {\sc #1}
240 }
241 \def\endalgo{\interlistskip\endgroup}
242 \def\algopar{\par
243 \parindent=2em
244 \hangindent=4em
245 \hangafter=1
246 \leavevmode
247 }
248 \def\algoitem{
249 \ifnum\itemcount=0\smallskip\fi
250 \algopar\advance\itemcount by 1
251 \hbox to 2em{\hss \the\itemcount. }%
252 \futurelet\next\algoitemh}
253 \def\algoitemh{\ifx\next:\let\next=\algohang\else\let\next=\relax\fi\next}
254 \def\algohang:{\advance\hangindent by 2em \hskip 2em\futurelet\next\algoitemh}
255 \def\algin{\par{\it Vstup:\/} }
256 \def\algout{\par{\it VĂ˝stup:\/} }
257
258 %%% Constructs used in algorithms %%%
259
260 \def\={\leftarrow}
261 \def\cmt#1{~~{\sl (#1)}}
262
263 %%% Chapters, sections and proclamations %%%
264
265 \newcount\chapcount
266 \newcount\seccount
267 \newcount\thmcount
268 \chapcount=0
269 \seccount=0
270 \thmcount=0
271
272 \def\chapter#1{\vfill\eject
273 \advance\chapcount by 1
274 \seccount=0
275 \thmcount=0
276 \leftline{\chapfont\the\chapcount. #1}
277 \bigskip
278 }
279
280 \def\section#1{\bigskip
281 \advance\seccount by 1
282 \thmcount=0
283 \leftline{\secfont\the\chapcount.\the\seccount. #1}
284 \medskip
285 }
286
287 \def\proclaim#1{\advance\thmcount by 1
288 \noindent {\bf #1 \the\chapcount.\the\seccount.\the\thmcount. }
289 }
290
291 \def\theorem{\proclaim{Theorem}}
292 \def\lemma{\proclaim{Lemma}}
293 \def\defn{\proclaim{Definition}}
294
295 \def\proof{\noindent {\sl Proof.} }
296
297 %%% References %%%
298
299 \newwrite\ids
300 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
301
302 \immediate\openin\ids=ids.aux
303 \ifeof\ids
304 \else
305 \input ids.aux
306 \fi
307 \immediate\closein\ids
308 \immediate\openout\ids=ids.aux
309
310 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
311 {\bo ??}%
312 \immediate\write16{*** Warning: Reference #1 undefined ***}%
313 \else
314 \csname id#1\endcsname
315 \fi
316 }
317
318 \def\chapid#1{\writeid{ch#1}{\the\chapcount}}
319 \def\secid#1{\writeid{sec#1}{\the\chapcount.\the\seccount}}
320 \def\thmid#1{\writeid{thm#1}{\the\chapcount.\the\seccount.\the\thmcount}}
321
322 \def\chapref#1{\ref{ch#1}}
323 \def\secref#1{\ref{sec#1}}
324 \def\thmref#1{\ref{thm#1}}
325
326 %%% Bibliography %%%
327
328 \bibliographystyle{abbrv}
329 \def\dumpbib{
330   \def\bblhook{\parskip=2pt plus 1pt minus 0.5pt}
331   \bibliography{biblio}
332 }
333
334 %%% Stand-alone chapters %%%
335
336 \def\endpart{
337   \section{Bibliography}
338   \dumpbib
339   \vfill\supereject\end
340 }
341
342 %%% The End %%%
343
344 \catcode`@=12