1 % TeX macros for typesetting my PhD thesis
2 % (c) 2008 Martin Mares <mj@ucw.cz>
10 %%% Basic parameters %%%
12 % A4 with 1in margins, leaving 20pt for page numbering at the bottom
15 \advance\vsize by -20pt
17 \parskip=3pt plus 1pt minus 1pt
19 % Parameters for final typesetting (bigger inner margins etc.)
24 \advance\hsize by -10mm
29 \def\df#1{{\it #1\/}} % when we define something
32 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\spadesuit$\par}}
33 \def\qeditem{{\parfillskip=0pt\hfill\rlap{\hskip\rightskip\llap{$\spadesuit$}}\par}}
34 \def\qedmath{\eqno{\spadesuit}}
35 \def\FIXME#1{\>{\bo TODO:} #1}
36 \def\symdiff{\mathbin{\Delta}}
37 \def\rack#1#2{\setbox0=\hbox{#1}\hbox to \wd0{#2}}
38 \def\o#1{\accent23 #1}
39 \def\mst{\mathop{\rm mst}}
40 \def\msf{\mathop{\rm msf}}
41 \def\deg{\mathop{\rm deg}}
42 \def\timesalpha{\mskip2mu\alpha}
43 \def\timesbeta{\mskip2mu\beta}
44 \def\tower{\mathbin\uparrow}
46 \def\minorof{\preccurlyeq}
47 \def\per{\mathop{\rm per}}
48 \def\poly{\mathop{\rm poly}}
50 \def\crpt{\mathbin{\Uparrow}}
59 \def\(#1){\mathord{\left<#1\right>}}
62 \def\shl{\mathbin{<\!<}}
63 \def\shr{\mathbin{>\!>}}
64 \def\bop#1{\mathbin{\hbox{\sc #1}}}
68 \def\bnot{\mathop{\hbox{\sc not}}}
70 % A reversed version of \ddots with extra space at the top to get good alignment of exponents.
71 \def\rddots{\mathinner{\mkern1mu\raise\p@\vbox{\kern7\p@\hbox{.}}\mkern2mu
72 \raise4\p@\hbox{.}\mkern2mu\raise7\p@\hbox{.}\raise11\p@\hbox{}\mkern1mu}}
77 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\bf\the\footcnt}$}{#1}}}
79 %%% Font definition macros (used in fonts<size>.tex) %%%
81 \def\mathf@nt#1#2#3#4{%
82 \toks0=\expandafter{\csname#1#2\endcsname}%
83 \expandafter\ifx\the\toks0\relax%
84 %\immediate\write-1{bb \the\toks0=#4#2#3}%
85 \global\expandafter\font\the\toks0=#4#2#3%
87 \edef\m@@f{\the\toks0}}
89 %%% Enumerated lists %%%
91 \newif\ifitem\itemtrue
95 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
97 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\else
98 \advance\leftskip by 2.5em\fi\rightskip=\leftskip}
100 \def\inititemize{\interlistskip\begingroup
101 \parskip=1pt plus 0.3pt minus 0.1pt
104 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
107 \def\singleitem{\par\leavevmode\copy\itembox}
109 \def\endlist{\interlistskip\endgroup}
111 \def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
112 \def\icirc{\raise0.2ex\hbox{$\circ$}} % Signs frequently used for \itemize
113 \def\idot{\raise0.2ex\hbox{$\cdot$}}
114 \def\istar{\raise0.2ex\hbox{$\ast$}}
116 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
117 \let\itemnumbering=#1}
119 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
120 \llap{\itemnumbering\hskip 0.4em}}
122 \def\nnorm{\the\itemcount}
123 \def\ndotted{\nnorm.}
125 \def\nroman{\romannumeral\itemcount}
126 \def\nromanp{\nroman)}
127 \def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
128 \def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
129 \def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
130 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
131 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
133 % New \frenchspacing, which doesn't leave unwanted spaces in text.
134 \def\frenchsp@cing{\sfcode`\.\@m \sfcode`\?\@m \sfcode`\!\@m%
135 \sfcode`\:\@m \sfcode`\;\@m \sfcode`\,\@m}
137 %%% Local verbatim mode %%%
139 \def\make@ther#1{\catcode`#1=12\relax}
140 \def\setverb@tim{\tt\frenchsp@cing\catcode`\`=13\catcode`\'=13\n@ligs%
141 \let\do=\make@ther\dospecials\obeyspaces}
145 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
148 \global\chardef\sp@ce=32
149 \gdef\showspaces{\let =\sp@ce}
152 \catcode124=\active % Make | active
153 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
156 %%% Verbatim mode for text in { } %%%
158 \newskip\verbglue\newskip\verblineglue
159 \verbglue=3pt plus 1pt minus 0.3pt
160 \verblineglue=0pt plus 1.5pt
169 \def\v@rbend{\par\endgroup\vskip\verbglue}
170 \def\v@rbl{\ifnum\vercnt>0\{\fi\global\advance\vercnt by 1\relax}
171 \def\v@rbr{\ifnum\vercnt>1\}\else\v@rbend\fi\global\advance\vercnt by -1\relax}
172 \def\v@rbparams{\setverb@tim\parskip=\verblineglue\parindent=0pt\raggedbottom%
173 \rightskip\z@ plus1fil\pretolerance=10000\tolerance=10000\vercnt=0%
174 \catcode124=12\setupt@bs\vskip\verbglue\defb@x\obeylines}
176 \def\startb@x{\setbox0=\hbox\bgroup}
177 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
178 \everypar{\startb@x}}
180 {\catcode`\^^I=\active
181 \gdef\setupt@bs{\catcode`\^^I=\active
182 \setbox0=\hbox{\tt\ }\tabwidth=\wd0\multiply\tabwidth by \tabsize
183 \def^^I{\leavevmode\egroup\t@b=\wd0\divide\t@b by \tabwidth%
184 \multiply\t@b by \tabwidth%
185 \advance\t@b by \tabwidth\advance\t@b by -\wd0\box0\hbox to \t@b{}\startb@x}
189 \catcode`[=1\catcode`]=2\catcode123=\active\catcode125=\active
190 \gdef\verbatim[\begingroup\v@rbparams\catcode123=\active\catcode125=\active%
191 \let{=\v@rbl\let}=\v@rbr\chardef\{=123\chardef\}=125\verblocaldefs
194 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
198 % \algo{jmeno algoritmu}
199 % \algin popis vstupu
203 % \algout popis vystupu
210 \parskip=1pt plus 1pt minus 0.3pt
215 \def\endalgo{\interlistskip\endgroup}
223 \algopar\advance\itemcount by 1
224 \hbox to 2em{\hss \the\itemcount. }%
225 \futurelet\next\algoitemh}
226 \def\algoitemh{\ifx\next:\let\next=\algohang\else\let\next=\relax\fi\next}
227 \def\algohang:{\advance\hangindent by 2em \hskip 2em\futurelet\next\algoitemh}
228 \def\algin{\par{\sl Input:\/} }
229 \def\algout{\par{\sl Output:\/} }
231 %%% Constructs used in algorithms %%%
234 \def\cmt#1{~~{\sl (#1)}}
236 %%% Chapters, sections and proclamations %%%
248 \def\appendices{\chapcount=99}
254 \hglue 1in \vfill\supereject
259 \def\rawchapter#1{\vfill\supereject
261 \leftline{\chapfont #1}
267 \writetoc{unchap}{#1}
270 \def\chapter#1{\advance\chapcount by 1
277 \advance\tmpcount by -100
278 \edef\currentchap{\ifcase\tmpcount A\or B\or C\or D\or E\or ZZZ\fi}
280 \edef\currentchap{\the\chapcount}
282 \edef\currentid{\currentchap}
283 \rawchapter{\currentid. #1}
287 \def\vensure#1{\dimen0=#1
288 \vskip 0pt plus \dimen0
290 \vskip 0pt plus -\dimen0
293 \def\rawsection#1{\bigskip\vensure{0.5in}
294 \leftline{\secfont #1}
300 \def\section#1{\advance\seccount by 1
302 \edef\currentid{\currentchap.\the\seccount}
303 \rawsection{\currentid. #1}
307 \def\para{\advance\thmcount by 1
308 \edef\currentid{\currentchap.\the\seccount.\the\thmcount}
309 \noindent {\bo \currentid.\enspace}}
311 \def\proclaim#1{\para {\bo #1.\enspace}}
313 \def\thm{\proclaim{Theorem}}
314 \def\lemma{\proclaim{Lemma}}
315 \def\defn{\proclaim{Definition}}
316 \def\problem{\proclaim{Problem}}
317 \def\obs{\proclaim{Observation}}
318 \def\rem{\proclaim{Remark}}
319 \def\alg{\proclaim{Algorithm}}
320 \def\impl{\proclaim{Implementation}}
321 \def\cor{\proclaim{Corollary}}
322 \def\nota{\proclaim{Notation}}
323 \def\example{\proclaim{Example}}
325 \def\label#1{{\sl (#1)\/}\enspace}
326 \def\labelx#1{\label{#1}\hfil\break\eatspaces}
327 \def\eatspaces{\kern0pt}
329 \def\thmn{\thm\labelx}
330 \def\lemman{\lemma\labelx}
331 \def\defnn{\defn\labelx}
332 \def\corn{\cor\labelx}
333 \def\algn{\alg\label}
334 \def\notan{\nota\labelx}
335 \def\examplen{\example\labelx}
336 \def\problemn{\problem\labelx}
337 \def\remn{\rem\labelx}
339 \def\paran#1{\para {\sl #1.\/}\enspace\eatspaces}
341 \def\proof{\noindent {\sl Proof.}\enspace}
342 \def\proofsketch{\noindent {\sl Proof sketch.}\enspace}
344 %%% Table of contents %%%
347 \immediate\openout\toc=\jobname.toc
354 \edef\tocaux{\write\toc{\noexpand\expandafter\noexpand\string\noexpand\csname toc#1\noexpand\endcsname{\currentid}{#2}{\the\toks0}}}
361 \immediate\openin\tok=\jobname.tok
366 \immediate\closein\tok
369 \def\tocchap#1#2#3{\smallskip\line{\bo #1.~~#2 \dotfill ~#3}}
370 \def\tocsec#1#2#3{\line{#1.~~#2 \dotfill ~#3}}
371 \def\tocunchap#1#2#3{\smallskip\line{\bo #2 \dotfill ~#3}}
376 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
378 \immediate\openin\ids=\jobname.ids
383 \immediate\closein\ids
384 \immediate\openout\ids=\jobname.ids
386 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
388 \immediate\write16{*** Warning: Reference #1 undefined ***}%
390 \csname id#1\endcsname
394 \def\id#1{\writeid{#1}{\currentid}}
398 %\bibliographystyle{abbrv}
399 \bibliographystyle{mjalpha}
401 \def\bblhook{\parskip=2pt plus 1pt minus 0.5pt}
402 \bibliography{biblio}
407 \def\float#1#2{\midinsert
415 \def\figure#1#2#3{\float{\epsfxsize=#2\epsfbox{pic/#1}}{#3}}
419 \vbox{\hsize=0.7\hsize
421 \leftskip=0pt plus 0.3\hsize
427 %%% Stand-alone chapters %%%
430 \section{Bibliography}
432 \vfill\supereject\end
437 \hyphenation{Ra-ma-chan-dran}
439 %%% Output routine %%%
445 \ifodd\pageno \hoffset=\hwobble \else \hoffset=0pt \fi
449 \def\makefootline{\baselineskip30pt\lineskiplimit 0pt\line{\the\footline}}
451 \footline={\ifodd\pageno
452 {\hfil\mi\the\pageno}%
454 {\mi\the\pageno\hfil}%