1 % MJ's TeX Macro Collection
2 % (c) 1995--2004 Martin Mares <mj@ucw.cz>
3 % Freely distributable as long as the author's copyright is left intact
6 % 2.0 (05-11-95) Itemization and list system completely rewritten. Hopefully
8 % 2.1 (11-05-96) Added \fixfont.
9 % 2.2 (15-02-97) Modified \fixfont not to leave extra spaces.
10 % Added \relax at the end of \tt.
11 % Added a very limited support for picture drawing.
12 % 2.3 (21-05-01) Modified \fixfont to use \fntdesignsize,
13 % Added \fntmath(|s|ss)size and used it in \setmath
15 % 2.4 (10-07-03) Added \bo
16 % 2.5 (27-09-03) Added \verblocaldefs
17 % 2.6 (21-03-04) Added \itemspacingrules
18 % 2.7 (10-04-04) There were collisions between our \[bB]ig and the same
19 % macro used in plain to implement \bigl et al. Now we rename
20 % the original \[bB]ig to \plain[bB]ig and re-define \[bB]ig[lrm]
21 % to call the renamed version instead.
23 % We'll use internal macros of plain TeX
29 % Page size definition
30 % --------------------
32 % Standard A4 dimensions are used. For different set of dimensions, redefine the
33 % \setpagesize macro to set everything you want in true units. Don't forget to
34 % call the macro immediately to refresh current setting. \magnification can be
35 % set prior to inclusion of these macros.
37 \def\setpagesize{\hsize=7truein\vsize=9.2truein}
38 \def\m@g{\mag\count@\setpagesize\dimen\footins8truein}
45 \parskip=3pt plus 1pt minus 1pt
47 % We want to override \[bB]ig in plain, so save the original definition
48 % ---------------------------------------------------------------------
52 \def\bigl{\mathopen\plainbig}
53 \def\bigm{\mathrel\plainbig}
54 \def\bigr{\mathclose\plainbig}
55 \def\Bigl{\mathopen\plainBig}
56 \def\Bigm{\mathrel\plainBig}
57 \def\Bigr{\mathclose\plainBig}
59 % Font selection system
60 % ---------------------
62 % The heart of the font selection system is the \setfont macro which selects
63 % the current font according to the following settings:
64 % \fntprefix - font name prefix (usually cm or cs)
65 % \fntdesignsize - font design size in points (normally 10)
66 % \fnttokprefix - prefix of control sequence the font is assigned to ('ten')
67 % \fntmag - font magnification factor
68 % \fnttoksuffix - control sequence suffix ('A' to 'G' according to mag)
69 % \fntstyle - font name suffix determining font style ('bx', 'r' etc.)
72 \def\fntdesignsize{10}
73 \def\fnttokprefix{ten}
74 \def\fntmag{\magstep0}
79 \toks0=\expandafter{\csname\fnttokprefix\fntstyle\fnttoksuffix\endcsname}%
80 \expandafter\ifx\the\toks0\relax%
81 %\immediate\write-1{aa \the\toks0=\fntprefix\fntstyle\fntdesignsize\space scaled \fntmag}%
82 \global\expandafter\font\the\toks0=\fntprefix\fntstyle\fntdesignsize\space scaled \fntmag%
84 \edef\currentfont{\the\toks0}\currentfont}
86 \setfont % Initialize the whole mechanism
88 \def\mathf@nt#1#2#3#4{%
89 \toks0=\expandafter{\csname#1#2\fnttoksuffix\endcsname}%
90 \expandafter\ifx\the\toks0\relax%
91 %\immediate\write-1{bb \the\toks0=#4#2#3\space scaled \fntmag}%
92 \global\expandafter\font\the\toks0=#4#2#3\space scaled \fntmag%
94 \edef\m@@f{\the\toks0}}
99 \def\fntmathstok{seven}
100 \def\fntmathsssize{5}
101 \def\fntmathsstok{five}
104 \mathf@nt{\fntmathtok}{r}{\fntmathsize}{cs}\textfont0=\m@@f
105 \mathf@nt{\fntmathstok}{r}{\fntmathssize}{cs}\scriptfont0=\m@@f
106 \mathf@nt{\fntmathsstok}{r}{\fntmathsssize}{cs}\scriptscriptfont0=\m@@f
107 \mathf@nt{\fntmathtok}{mi}{\fntmathsize}{cm}\skewchar\m@@f='177\textfont1=\m@@f
108 \mathf@nt{\fntmathstok}{mi}{\fntmathssize}{cm}\skewchar\m@@f='177\scriptfont1=\m@@f
109 \mathf@nt{\fntmathsstok}{mi}{\fntmathsssize}{cm}\skewchar\m@@f='177\scriptscriptfont1=\m@@f
110 \mathf@nt{\fntmathtok}{sy}{\fntmathsize}{cm}\skewchar\m@@f='60\textfont2=\m@@f
111 \mathf@nt{\fntmathstok}{sy}{\fntmathssize}{cm}\skewchar\m@@f='60\scriptfont2=\m@@f
112 \mathf@nt{\fntmathsstok}{sy}{\fntmathsssize}{cm}\skewchar\m@@f='60\scriptscriptfont2=\m@@f
113 \mathf@nt{\fntmathtok}{ex}{\fntmathsize}{cm}\textfont3=\m@@f\scriptfont3=\m@@f\scriptscriptfont3=\m@@f
114 \mathf@nt{\fntmathtok}{ti}{\fntmathsize}{cs}\textfont\itfam=\m@@f
115 \mathf@nt{\fntmathtok}{sl}{\fntmathsize}{cs}\textfont\slfam=\m@@f
116 \mathf@nt{\fntmathtok}{bx}{\fntmathsize}{cs}\textfont\bffam=\m@@f
117 \mathf@nt{\fntmathtok}{tt}{\fntmathsize}{cs}\hyphenchar\m@@f=-1\textfont\ttfam=\m@@f
120 % Call \fixfont to fix lineskip, math fonts and the strut box
122 \def\fixfont{\setfont\setmath
123 \mjtempcount=\fntdesignsize
124 \multiply\mjtempcount by \fntmag
125 \normalbaselineskip=0.12pt
126 \multiply\normalbaselineskip by \mjtempcount
127 \divide\normalbaselineskip by 100
128 \normallineskip=0.01pt
129 \multiply\normallineskip by \mjtempcount
130 \divide\normallineskip by 100
133 \multiply\dimen0 by \mjtempcount
134 \divide\dimen0 by 100
136 \multiply\dimen1 by \mjtempcount
137 \divide\dimen1 by 100
138 \setbox\strutbox=\hbox{\vrule height\dimen0 depth\dimen1 width\z@}}
140 % You can use the following macros to change the magnification:
142 \def\normal{\def\fntmag{\magstep0}\def\fnttoksuffix{A}\setfont} % Normal size
143 \def\halflarge{\def\fntmag{\magstephalf}\def\fnttoksuffix{b}\setfont} % Magstephalf
144 \def\large{\def\fntmag{\magstep1}\def\fnttoksuffix{B}\setfont} % Magstep 1
145 \def\Large{\def\fntmag{\magstep2}\def\fnttoksuffix{C}\setfont}
146 \def\big{\def\fntmag{\magstep3}\def\fnttoksuffix{D}\setfont}
147 \def\Big{\def\fntmag{\magstep4}\def\fnttoksuffix{E}\setfont}
148 \def\huge{\def\fntmag{\magstep5}\def\fnttoksuffix{F}\setfont}
149 \def\Huge{\def\fntmag{\magstep6}\def\fnttoksuffix{G}\setfont} % Magstep 6
150 \def\fm#1{\def\fntmag{\magstep#1}\edef\fnttoksuffix{\ifcase #1 A\or B\or C%
151 \or D\or E\or F\or G\fi}\setfont} % User mag
153 % And to change the style:
155 \def\rm{\fam\z@\def\fntstyle{r}\setfont} % Roman
156 \def\it{\fam\itfam\def\fntstyle{ti}\setfont} % Italic
157 \def\bo{\fam\bffam\def\fntstyle{b}\setfont} % Bold
158 \def\bf{\fam\bffam\def\fntstyle{bx}\setfont} % Bold extended
159 \def\ss{\def\fntstyle{ss}\setfont} % Sans serif
160 \def\tt{\fam\ttfam\def\fntstyle{tt}\setfont%
161 \hyphenchar\currentfont=-1\relax} % Typewriter
162 \def\sc{\def\fntstyle{csc}\setfont} % Caps and small caps
163 \def\ssi{\def\fntstyle{ssi}\setfont} % Sans serif italic
164 \def\sl{\fam\slfam\def\fntstyle{sl}\setfont} % Slanted
165 \def\ssbf{\def\fntstyle{ssbx}\setfont} % Sans serif bold
166 \def\ssdc{\def\fntstyle{ssdc}\setfont} % Sans serif demi condensed
168 % Switch to large font set
171 \def\fntdesignsize{12}
172 \def\fnttokprefix{twelve}
173 \def\fntmathsize{12}\def\fntmathtok{twelve}
174 \def\fntmathssize{8}\def\fntmathstok{eight}
175 \def\fntmathsssize{6}\def\fntmathsstok{six}
182 \newif\ifitem\itemtrue
186 \def\interlistskip{\vskip 3pt plus 2pt minus 1pt}
188 \def\itemspacingrules{\ifitem\advance\leftskip by \parindent\parindent=0pt\itemfalse\fi
189 \advance\leftskip by 2.5em}
191 \def\inititemize{\interlistskip\begingroup
192 \parskip=1pt plus 0.3pt minus 0.1pt
195 \def\itemize#1{\inititemize\setbox\itembox\llap{#1\hskip 0.4em}%
198 \def\singleitem{\par\leavevmode\copy\itembox}
200 \def\endlist{\interlistskip\endgroup}
202 \def\ibull{\raise0.2ex\hbox{$\bullet$}} % Signs frequently used for \itemize
203 \def\idot{\raise0.2ex\hbox{$\cdot$}}
204 \def\istar{\raise0.2ex\hbox{$\ast$}}
206 \def\numlist#1{\inititemize\itemcount=0\let\:=\numbereditem
207 \let\itemnumbering=#1}
209 \def\numbereditem{\par\leavevmode\advance\itemcount by 1
210 \llap{\itemnumbering\hskip 0.4em}}
212 \def\nnorm{\the\itemcount}
213 \def\ndotted{\nnorm.}
215 \def\nroman{\romannumeral\itemcount}
216 \def\nromanp{\nroman)}
217 \def\nalpha{\count@=96\advance\count@ by\itemcount\char\count@)}
218 \def\nAlpha{\count@=64\advance\count@ by\itemcount\char\count@)}
219 \def\ngreek{$\ifcase\itemcount\or\alpha\or\beta\or\gamma\or\delta\or\epsilon\or
220 \zeta\or\eta\or\theta\or\iota\or\kappa\or\lambda\or\mu\or\nu\or\xi\or\pi\or\rho
221 \or\sigma\or\tau\or\upsilon\or\phi\or\chi\or\psi\or\omega\fi$)}
225 % Additional math functions
226 % -------------------------
228 \def\mod{\;{\rm mod}\;}
229 \def\div{\;{\rm div}\;}
230 \def\xor{\;{\rm xor}\;}
232 \def\mathbox#1{ % Typeset math formula enclosed in a box.
235 \hbox{\vrule height 10pt depth 5pt\hskip3mm\hbox{$#1$}\hskip3mm\vrule }
239 % Italic typesetting (automatic \/)
242 \def\I{\it\aftergroup\/}
244 % New \frenchspacing, which doesn't leave unwanted spaces in text.
246 \def\frenchsp@cing{\sfcode`\.\@m \sfcode`\?\@m \sfcode`\!\@m%
247 \sfcode`\:\@m \sfcode`\;\@m \sfcode`\,\@m}
249 % Typesetting of one verbatim word
250 % --------------------------------
252 \def\make@ther#1{\catcode`#1=12\relax}
253 \def\setverb@tim{\tt\frenchsp@cing\catcode`\`=13\catcode`\'=13\n@ligs%
254 \let\do=\make@ther\dospecials\obeyspaces}
258 \gdef\n@ligs{\def`{\relax\lq}\def'{\relax\rq}}}
261 \global\chardef\sp@ce=32
262 \gdef\showspaces{\let =\sp@ce}
265 \catcode124=\active % Make | active
266 \def\ttst@rt{\begingroup\setverb@tim\let|=\endgroup}
269 % Typesetting of verbatim text (enclosed in { } )
270 % ----------------------------
272 \newskip\verbglue\newskip\verblineglue
273 \verbglue=3pt plus 1pt minus 0.3pt
274 \verblineglue=0pt plus 1.5pt
283 \def\v@rbend{\par\endgroup\vskip\verbglue}
284 \def\v@rbl{\ifnum\vercnt>0\{\fi\global\advance\vercnt by 1\relax}
285 \def\v@rbr{\ifnum\vercnt>1\}\else\v@rbend\fi\global\advance\vercnt by -1\relax}
286 \def\v@rbparams{\setverb@tim\parskip=\verblineglue\parindent=0pt\raggedbottom%
287 \rightskip\z@ plus1fil\pretolerance=10000\tolerance=10000\vercnt=0%
288 \catcode124=12\setupt@bs\vskip\verbglue\defb@x\obeylines}
290 \def\startb@x{\setbox0=\hbox\bgroup}
291 \def\defb@x{\def\par{\leavevmode\egroup\box0\endgraf}%
292 \everypar{\startb@x}}
294 {\catcode`\^^I=\active
295 \gdef\setupt@bs{\catcode`\^^I=\active
296 \setbox0=\hbox{\tt\ }\tabwidth=\wd0\multiply\tabwidth by \tabsize
297 \def^^I{\leavevmode\egroup\t@b=\wd0\divide\t@b by \tabwidth%
298 \multiply\t@b by \tabwidth%
299 \advance\t@b by \tabwidth\advance\t@b by -\wd0\box0\hbox to \t@b{}\startb@x}
303 \catcode`[=1\catcode`]=2\catcode123=\active\catcode125=\active
304 \gdef\verbatim[\begingroup\v@rbparams\catcode123=\active\catcode125=\active%
305 \let{=\v@rbl\let}=\v@rbr\chardef\{=123\chardef\}=125\verblocaldefs
308 % Input file verbatim
309 % -------------------
311 \def\verbinput#1{\begingroup\v@rbparams\input #1\endgroup}
315 % Allowed direction vectors are 0<=x<=6, -6<=y<=6, GCD(x,y)=1
317 \def\initlines{\font\lif=line10}
318 \def\linechar#1#2{\ifnum #1=0 \hbox to 0pt{\hss\vrule height 10pt\hss}\else
319 \ifnum #2=0 \vbox to 0pt{\vss\hrule width 10pt\vss}\else
320 {\count255=#1\multiply\count255 by 8
321 \ifnum #2>0 \advance\count255 by #2 \advance\count255 by -9
322 \else\advance\count255 by -#2 \advance\count255 by 55\fi
323 \lif\char\count255}\fi\fi}
324 \def\picture#1#2#3{\initlines\medskip\centerline{\vbox to #2{\hbox to #1{#3\hss}\vss}}\medskip}
325 \def\place#1#2#3{{\setbox0=\hbox to 0pt{#3 \hss}\ht0=0pt\dp0=0pt
326 \hbox to 0pt{\hskip #1\lower #2\box0\hss}}}
327 \def\pl@celine{\ifnum \count255>0 \place{\dimen0}{\dimen1}{\copy0}\advance\dimen0 by \wd0
328 \advance\dimen1 by -\ht0 \advance\count255 by -1 \pl@celine\fi}
329 \def\placeline#1#2#3#4#5{{\setbox0=\hbox{\linechar{#3}{#4}}\ifnum #4<0\setbox0=\hbox to -\wd0{\hss\box0}\fi
330 \dimen0=#1\dimen1=#2\count255=#5\pl@celine}}
331 \def\cplace#1#2#3{\place{#1}{#2}{\hss #3}}
333 % Let's hide all internal macros