]> mj.ucw.cz Git - saga.git/blob - macros.tex
The first pieces.
[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
6 \catcode`@=11
7
8 %%% Basic parameters %%%
9
10 % A4 with 1in margins, leaving 20pt for page numbering at the bottom
11 \hsize=159mm
12 \vsize=246mm
13 \advance\vsize by -20pt
14 \parindent=0.8cm
15 \parskip=3pt plus 1pt minus 1pt
16
17 %%% Miscellanea %%%
18
19 \def\em#1{{\it #1\/}}
20 \def\O{{\cal O}}
21 \def\<#1>{\leavevmode\hbox{\it #1\/}}
22 \let\>=\noindent
23 \def\qed{{\parfillskip=0pt\allowbreak\hfill\nobreak $\heartsuit$\par}}
24 \let\endpart=\bye
25
26 % Footnotes
27 \newcount\footcnt
28 \footcnt=0
29 \def\foot#1{\global\advance\footcnt by 1{\parindent=0.25in\parskip=0pt\footnote{$^{\left<\the\footcnt\right>}$}{#1}}}
30
31 %%% Fonts %%%
32
33 \font\twelverm=cmr12
34 \font\twelveit=cmti12
35 \font\twelvesl=cmsl12
36 \font\twelvebf=cmbx12
37 \font\twelveb=csb12
38 \font\twelvesc=cscsc12
39
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%
45 \fi%
46 \edef\m@@f{\the\toks0}}
47
48 \def\fntmathsize{12}
49 \def\fntmathtok{twelve}
50 \def\fntmathssize{8}
51 \def\fntmathstok{eight}
52 \def\fntmathsssize{6}
53 \def\fntmathsstok{six}
54
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
69
70 % Blackboard bold font
71 \newfam\bbfam
72 \font\bbtwelve=bbm12
73 \font\bbeight=bbm8
74 \font\bbsix=bbm6
75 \textfont\bbfam=\bbtwelve
76 \scriptfont\bbfam=\bbeight
77 \scriptscriptfont\bbfam=\bbsix
78 \def\bb{\bbtwelve\fam\bbfam}
79
80 % Font switches
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}
86 \def\sc{\twelvesc}
87 \def\sl{\fam\slfam\twelvesl}
88
89 % Switch to 12pt baselines
90 \rm
91 \baselineskip=14.4pt
92 \lineskip=1.2pt
93 \setbox\strutbox=\hbox{\vrule height 10.2pt depth 4.2pt width 0pt}
94
95 % Other fonts
96 \font\chapfont=csssdc17 scaled \magstep1
97 \font\secfont=csb14
98
99 %%% FIXME
100 \footline={\hss\twelverm\folio\hss}
101
102 %%% Vycty s odrazkami i cislovane %%%
103
104 \newif\ifitem\itemtrue
105 \newbox\itembox
106 \newcount\itemcount
107
108 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
109
110 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\else
111 \advance\leftskip by 2.5em\fi\rightskip=\leftskip}
112
113 \def\inititemize{\interlistskip\begingroup
114 \parskip=1pt plus 0.3pt minus 0.1pt
115 \itemspacingrules}
116
117 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
118 \let\:=\singleitem}
119
120 \def\singleitem{\par\leavevmode\copy\itembox}
121
122 \def\endlist{\interlistskip\endgroup}
123
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$}}
127
128 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
129 \let\itemnumbering=#1}
130
131 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
132 \llap{\itemnumbering\hskip 0.4em}}
133
134 \def\nnorm{\the\itemcount}
135 \def\ndotted{\nnorm.}
136 \def\nparen{\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$)}
144
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}
148
149 %%% Verbatim mod na jednotliva slova %%%
150
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}
154
155 {\catcode`'=13
156 \catcode``=13
157 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
158
159 {\obeyspaces
160 \global\chardef\sp@ce=32
161 \gdef\showspaces{\let =\sp@ce}
162 \global\let =\ }
163
164 \catcode124=\active % Make | active
165 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
166 \let|=\ttst@rt
167
168 %%% Verbatim mod na delsi text uzavreny v { } %%%
169
170 \newskip\verbglue\newskip\verblineglue
171 \verbglue=3pt plus 1pt minus 0.3pt
172 \verblineglue=0pt plus 1.5pt
173 \def\verblocaldefs{}
174
175 \newdimen\tabwidth
176 \newcount\tabsize
177 \tabsize=8
178 \newdimen\t@b
179
180 \newcount\vercnt
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}
187
188 \def\startb@x{\setbox0=\hbox\bgroup}
189 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
190 \everypar{\startb@x}}
191
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}
198 }}
199
200 {
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
204 ]]
205
206 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
207
208 %%% Sazba algoritmu %%%
209
210 %       \algo{jmeno algoritmu}
211 %       \algin popis vstupu
212 %       \:krok
213 %       \:krok
214 %       \::vnoreny krok
215 %       \algout popis vystupu
216 %       \endalgo
217
218 \def\algo#1{
219 \interlistskip
220 \begingroup
221 \let\:=\algoitem
222 \parskip=1pt plus 1pt minus 0.3pt
223 \rightskip=2em
224 \itemcount=0
225 {\bo Algoritmus\/} {\sc #1}
226 }
227 \def\endalgo{\interlistskip\endgroup}
228 \def\algopar{\par
229 \parindent=2em
230 \hangindent=4em
231 \hangafter=1
232 \leavevmode
233 }
234 \def\algoitem{
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:\/} }
243
244 %%% Konstrukce pouzivane v algoritmech %%%
245
246 % Priraditko
247 \def\={\leftarrow}
248
249 % Komentar
250 \def\cmt#1{~~{\sl (#1)}}
251
252 %%% Kapitoly %%%
253
254 \newcount\chapcount
255 \newcount\seccount
256 \chapcount=0
257 \seccount=0
258
259 \def\chapter#1{\vfill\eject
260 \advance\chapcount by 1
261 \seccount=0
262 \leftline{\chapfont\the\chapcount. #1}
263 \bigskip
264 }
265
266 \def\section#1{\bigskip
267 \advance\seccount by 1
268 \leftline{\secfont\the\chapcount.\the\seccount. #1}
269 \medskip
270 }
271
272 %%% Odkazy na kapitoly a jine objekty %%%
273
274 % Poridime si soubor, do ktereho budeme zapisovat identifikatory
275 \newwrite\ids
276 \def\writeid#1#2{\immediate\write\ids{\string\def\expandafter\string\csname id#1\endcsname{#2}}}
277
278 \immediate\openin\ids=ids.aux
279 \ifeof\ids
280 \else
281 \input ids.aux
282 \fi
283 \immediate\closein\ids
284 \immediate\openout\ids=ids.aux
285
286 \def\ref#1{\expandafter\ifx\csname id#1\endcsname\relax
287 {\bo ??}%
288 \immediate\write16{*** Warning: Reference #1 undefined ***}%
289 \else
290 \csname id#1\endcsname
291 \fi
292 }
293
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}}
297
298 % Odkazovani na objekty
299 \def\chapref#1{\ref{ch#1}}
300 \def\secref#1{\ref{sec#1}}
301
302 %%% The End %%%
303
304 \catcode`@=12