1 % TeX macros for typesetting my PhD thesis
2 % (c) 2008 Martin Mares <mj@ucw.cz>
8 %%% Basic parameters %%%
10 % A4 with 1in margins, leaving 20pt for page numbering at the bottom
13 \advance\vsize by -20pt
15 \parskip=3pt plus 1pt minus 1pt
21 \def\<#1>{\leavevmode\hbox{\it #1\/}}
23 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\heartsuit$\par}}
29 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\left<\the\footcnt\right>}$}{#1}}}
38 \font\twelvesc=cscsc12
40 \def\mathf@nt#1#2#3#4{%
41 \toks0=\expandafter{\csname#1#2\endcsname}%
42 \expandafter\ifx\the\toks0\relax%
43 %\immediate\write-1{bb \the\toks0=#4#2#3}%
44 \global\expandafter\font\the\toks0=#4#2#3%
46 \edef\m@@f{\the\toks0}}
49 \def\fntmathtok{twelve}
51 \def\fntmathstok{eight}
53 \def\fntmathsstok{six}
55 \mathf@nt{\fntmathtok}{r}{\fntmathsize}{cs}\textfont0=\m@@f
56 \mathf@nt{\fntmathstok}{r}{\fntmathssize}{cs}\scriptfont0=\m@@f
57 \mathf@nt{\fntmathsstok}{r}{\fntmathsssize}{cs}\scriptscriptfont0=\m@@f
58 \mathf@nt{\fntmathtok}{mi}{\fntmathsize}{cm}\skewchar\m@@f='177\textfont1=\m@@f
59 \mathf@nt{\fntmathstok}{mi}{\fntmathssize}{cm}\skewchar\m@@f='177\scriptfont1=\m@@f
60 \mathf@nt{\fntmathsstok}{mi}{\fntmathsssize}{cm}\skewchar\m@@f='177\scriptscriptfont1=\m@@f
61 \mathf@nt{\fntmathtok}{sy}{\fntmathsize}{cm}\skewchar\m@@f='60\textfont2=\m@@f
62 \mathf@nt{\fntmathstok}{sy}{\fntmathssize}{cm}\skewchar\m@@f='60\scriptfont2=\m@@f
63 \mathf@nt{\fntmathsstok}{sy}{\fntmathsssize}{cm}\skewchar\m@@f='60\scriptscriptfont2=\m@@f
64 \mathf@nt{\fntmathtok}{ex}{\fntmathsize}{cm}\textfont3=\m@@f\scriptfont3=\m@@f\scriptscriptfont3=\m@@f
65 \mathf@nt{\fntmathtok}{ti}{\fntmathsize}{cs}\textfont\itfam=\m@@f
66 \mathf@nt{\fntmathtok}{sl}{\fntmathsize}{cs}\textfont\slfam=\m@@f
67 \mathf@nt{\fntmathtok}{bx}{\fntmathsize}{cs}\textfont\bffam=\m@@f
68 \mathf@nt{\fntmathtok}{tt}{\fntmathsize}{cs}\hyphenchar\m@@f=-1\textfont\ttfam=\m@@f
70 % Blackboard bold font
75 \textfont\bbfam=\bbtwelve
76 \scriptfont\bbfam=\bbeight
77 \scriptscriptfont\bbfam=\bbsix
78 \def\bb{\bbtwelve\fam\bbfam}
81 \def\rm{\fam\z@\twelverm}
82 \def\it{\fam\itfam\twelveit}
83 \def\bo{\fam\bffam\twelveb}
84 \def\bf{\fam\bffam\twelvebf}
85 \def\tt{\fam\ttfam\twelvett\hyphenchar\currentfont=-1\relax}
87 \def\sl{\fam\slfam\twelvesl}
89 % Switch to 12pt baselines
93 \setbox\strutbox=\hbox{\vrule height 10.2pt depth 4.2pt width 0pt}
96 \font\chapfont=csssdc17 scaled \magstep1
100 \footline={\hss\twelverm\folio\hss}
102 %%% Vycty s odrazkami i cislovane %%%
104 \newif\ifitem\itemtrue
108 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
110 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\else
111 \advance\leftskip by 2.5em\fi\rightskip=\leftskip}
113 \def\inititemize{\interlistskip\begingroup
114 \parskip=1pt plus 0.3pt minus 0.1pt
117 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
120 \def\singleitem{\par\leavevmode\copy\itembox}
122 \def\endlist{\interlistskip\endgroup}
124 \def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
125 \def\idot{\raise0.2ex\hbox{$\cdot$}}
126 \def\istar{\raise0.2ex\hbox{$\ast$}}
128 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
129 \let\itemnumbering=#1}
131 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
132 \llap{\itemnumbering\hskip 0.4em}}
134 \def\nnorm{\the\itemcount}
135 \def\ndotted{\nnorm.}
137 \def\nroman{\romannumeral\itemcount}
138 \def\nromanp{\nroman)}
139 \def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
140 \def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
141 \def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
142 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
143 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
145 % New \frenchspacing, which doesn't leave unwanted spaces in text.
146 \def\frenchsp@cing{\sfcode`\.\@m \sfcode`\?\@m \sfcode`\!\@m%
147 \sfcode`\:\@m \sfcode`\;\@m \sfcode`\,\@m}
149 %%% Verbatim mod na jednotliva slova %%%
151 \def\make@ther#1{\catcode`#1=12\relax}
152 \def\setverb@tim{\tt\frenchsp@cing\catcode`\`=13\catcode`\'=13\n@ligs%
153 \let\do=\make@ther\dospecials\obeyspaces}
157 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
160 \global\chardef\sp@ce=32
161 \gdef\showspaces{\let =\sp@ce}
164 \catcode124=\active % Make | active
165 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
168 %%% Verbatim mod na delsi text uzavreny v { } %%%
170 \newskip\verbglue\newskip\verblineglue
171 \verbglue=3pt plus 1pt minus 0.3pt
172 \verblineglue=0pt plus 1.5pt
181 \def\v@rbend{\par\endgroup\vskip\verbglue}
182 \def\v@rbl{\ifnum\vercnt>0\{\fi\global\advance\vercnt by 1\relax}
183 \def\v@rbr{\ifnum\vercnt>1\}\else\v@rbend\fi\global\advance\vercnt by -1\relax}
184 \def\v@rbparams{\setverb@tim\parskip=\verblineglue\parindent=0pt\raggedbottom%
185 \rightskip\z@ plus1fil\pretolerance=10000\tolerance=10000\vercnt=0%
186 \catcode124=12\setupt@bs\vskip\verbglue\defb@x\obeylines}
188 \def\startb@x{\setbox0=\hbox\bgroup}
189 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
190 \everypar{\startb@x}}
192 {\catcode`\^^I=\active
193 \gdef\setupt@bs{\catcode`\^^I=\active
194 \setbox0=\hbox{\tt\ }\tabwidth=\wd0\multiply\tabwidth by \tabsize
195 \def^^I{\leavevmode\egroup\t@b=\wd0\divide\t@b by \tabwidth%
196 \multiply\t@b by \tabwidth%
197 \advance\t@b by \tabwidth\advance\t@b by -\wd0\box0\hbox to \t@b{}\startb@x}
201 \catcode`[=1\catcode`]=2\catcode123=\active\catcode125=\active
202 \gdef\verbatim[\begingroup\v@rbparams\catcode123=\active\catcode125=\active%
203 \let{=\v@rbl\let}=\v@rbr\chardef\{=123\chardef\}=125\verblocaldefs
206 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
208 %%% Sazba algoritmu %%%
210 % \algo{jmeno algoritmu}
211 % \algin popis vstupu
215 % \algout popis vystupu
222 \parskip=1pt plus 1pt minus 0.3pt
225 {\bo Algoritmus\/} {\sc #1}
227 \def\endalgo{\interlistskip\endgroup}
235 \ifnum\itemcount=0\smallskip\fi
236 \algopar\advance\itemcount by 1
237 \hbox to 2em{\hss \the\itemcount. }%
238 \futurelet\next\algoitemh}
239 \def\algoitemh{\ifx\next:\let\next=\algohang\else\let\next=\relax\fi\next}
240 \def\algohang:{\advance\hangindent by 2em \hskip 2em\futurelet\next\algoitemh}
241 \def\algin{\par{\it Vstup:\/} }
242 \def\algout{\par{\it Výstup:\/} }
244 %%% Konstrukce pouzivane v algoritmech %%%
250 \def\cmt#1{~~{\sl (#1)}}
259 \def\chapter#1{\vfill\eject
260 \advance\chapcount by 1
262 \leftline{\chapfont\the\chapcount. #1}
266 \def\section#1{\bigskip
267 \advance\seccount by 1
268 \leftline{\secfont\the\chapcount.\the\seccount. #1}
272 %%% Odkazy na kapitoly a jine objekty %%%
274 % Poridime si soubor, do ktereho budeme zapisovat identifikatory
276 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
278 \immediate\openin\ids=ids.aux
283 \immediate\closein\ids
284 \immediate\openout\ids=ids.aux
286 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
288 \immediate\write16{*** Warning: Reference #1 undefined ***}%
290 \csname id#1\endcsname
294 % Pojmenovavani objektu
295 \def\chapid#1{\marginalie{#1}\writeid{ch#1}{\the\chapcount}}
296 \def\secid#1{\marginalie{#1}\writeid{sec#1}{\the\chapcount.\the\seccount}}
298 % Odkazovani na objekty
299 \def\chapref#1{\ref{ch#1}}
300 \def\secref#1{\ref{sec#1}}