Debian Codegraph @

texmf-dist/tex/psizzl/base/chapters.Psizzl

raw
1 % CHAPTERS PSIZZL - generate the body of the publication
2 %
3 % CHAPTER MACRO
4 %
5 % \chapter{title}
6 % This command numbers the chapter,
7 % generates part of the number to be
8 % used in defining equation numbers,
9 % centers the line and prints it in
10 % boldface type.
11 % When the above macro is to be used,
12 % you first set up with the macro
13 %
14 % \beginbody
15 %
16 % Then you define the chapters:
17 %
18 % \chapter{<chaptertitle>}%
19 %
20 % where <chaptertitle> may contain embedded \breaktitle macros
21 %
22 % After the \chapter for the last chapter, input the commnad:
23 %
24 % \beginappendices,
25 %
26 % then more \chapter's for the appendices:
27 %
28 % \chapter{<appendixtitle>}%
29 %
30 % Within each chapter, the current chapter name will be \chaptername
31 % (for appendices, this will be a letter).
32 %
33 % You may use macros to define sections and subsections within
34 % chapters:
35 %
36 % \section{<section name>}%
37 %
38 % \subsection{<subsection name>}%
39 %
40 % To output the tables of figures, etc. at the end, give the command:
41 %
42 % \endbody
43 %
44 %
45 \def\n@llout#1{\immediate\closeout#1\immediate\openout#1}%
46 \newcount\partcount
47 \def\p@rtinit{\partcount\@ne}%
48 \adddef\resd@c{\p@rtinit}%
49 \newcount\t@cpagecount\t@cpagecount\m@ne
50 \newcount\f@gpagecount\f@gpagecount\m@ne
51 \newcount\t@bpagecount\t@bpagecount\m@ne
52 \newcount\l@stpagecount\l@stpagecount\m@ne
53 \newif\ifpartapp
54 \newwrite\p@rtwrite
55 \def\p@rtfile{parts.psiztemp }%
56 \def\p@rthead{Table of Parts}%
57 \n@llout\p@rtwrite\p@rtfile
58 \def\part#1{%
59 \ifpartapp%
60 \xdef\p@rtname{Appendix\ \number\partcount}%
61 \else%
62 \xdef\p@rtname{Part\ \romannumeral\partcount}%
63 \fi%
64 \advance\partcount\@ne
65 \begingroup\c@tset%
66 \p@rttable%
67 }%
68 \def\p@rtname{}%
69 \def\p@rttable#1{%
70 \c@tMeoline\l@tMother
71 \xdef\writeit{%
72 \write\p@rtwrite{%
73 \line{%
74 \strut{\bf\p@rtname}\quad
75 \uppercase{%
76 \h@tMother#1\h@tMother
77 }%
78 \leaderfil\noexpand\number\p@gecount}%
79 }%
80 }%
81 \writeit\endgroup
82 \p@rtheader{#1}%
83 }%
84 \def\p@rtheader#1{%
85 \endpage%
86 \llap{}\vfill%
87 {\fortyss
88 \centerline{\p@rtname}%
89 \bigbreak%
90 \centertitle{\uppercase{#1}}%
91 }%
92 \endpage%
93 }%
94 \def\partout{%
95 \ifnum\partcount=\z@\else
96 \endpage\p@gefront
97 {\bf\centertitle\p@rthead}%
98 \immediate\closeout\p@rtwrite
99 \input\p@rtfile
100 \fi
101 }%
102 \newcount\ch@ptercount
103 \newif\if@ppendix% chapter/@ppendix switch
104 \newwrite\ch@pterwrite
105 \def\ch@pterfile{chapters.psiztemp }%
106 \def\ch@pterhead{Table of Contents}%
107 \def\ch@ptertext{}%
108 \def\@ppendixtext{Appendix }%
109 %
110 \def\beginbody{%
111 \b@dyreset
112 }%
113 \def\b@dyreset{%
114 \def\ch@ptername{}%
115 \ch@pterinit\ch@pterreset
116 \@ppendixfalse
117 \p@geclear
118 }%
119 \adddef\resd@c{\ch@pterclear\b@dyreset\fr@nttrue}%
120 \def\ch@pterinit{\ch@ptercount\@ne}%
121 \def\ch@pterclear{\ch@ptertot\z@\n@llout\ch@pterwrite\ch@pterfile}%
122 \def\ch@ptername{}%
123 \def\chapter{% title
124 \if@ppendix\xdef\ch@ptername{\char\number\ch@ptercount\relax}%
125 \let\temp\@ppendixtext
126 \else \xdef\ch@ptername{\number\ch@ptercount\relax}%
127 \let\temp\ch@ptertext
128 \fi\global\advance\ch@ptercount\@ne
129 \ch@ptereject \ch@pterreset
130 \ch@skiph
131 \vbox\bgroup\begingroup\c@tset\ch@ptertable%
132 }%
133 \def\ch@ptertable#1{%
134 \@ddch@pt{#1}{\strut{\temp\ch@ptername.}\quad}\endgroup
135 \vskip-\parskip
136 \bf\centertitle{\temp\ch@ptername.\quad#1}\egroup
137 \backpar\ch@skiph
138 }%
139 \def\ch@ptercite#1#2{% fig, tab citation style
140 \ifch@pterrenumber#1.#2\else#2\fi
141 }%
142 \def\equ@tioncite#1#2{% eqn citation style
143 \ifch@pterrenumber#1-#2\else#2\fi
144 }%
145 \def\r@fcite#1#2{% ref citation style
146 \ifr@frenumber#1.#2\else#2\fi
147 }%
148 \def\ch@pterreset{\s@ctioninit\s@ctionreset\c@teclear}%
149 \def\ch@ptereject{\ifch@pterrenumber\vfill\supereject\fi}%
150 \def\beginappendices{\@ppendixtrue\ch@ptercount`A}%
151 %
152 % build the table of contents,etc iteratively:
153 % 1) put out TOC to determine its length => list of tables, figures
154 % get the correct pagenumbers
155 % 2) put out list of tables and store its page number
156 % 3) put out list of figures and store its page number
157 % 4) put out TOC again, now using the correct page numbers for
158 % list of tables and list of figures
159 %
160 % (note: after \eject, the page number register contains the previous
161 % page number)
162 %
163 \newif\iff@gt@bhead
164 \def\f@gt@bhead{\f@gt@bheadfalse
165 \ifnum\t@btotal>\z@\f@gt@bheadtrue
166 \line{\strut\t@btabhead\leaderfil\romannumeral-\t@bpagecount}%
167 \fi
168 \ifnum\f@gtotal>\z@\f@gt@bheadtrue
169 \line{\strut\f@gtabhead\leaderfil\romannumeral-\f@gpagecount}%
170 \fi
171 }%
172 \newcount\blankcount
173 \def\rectoleaf{%
174 \ifquadside
175 \blankcount\pageno
176 \divide\blankcount4\multiply\blankcount4
177 \advance\blankcount-\pageno\blankcount-\blankcount
178 \ifnum\blankcount=\@ne\else\hrule height\z@\endleaf\fi\lock
179 \else\endpage
180 \fi
181 }%
182 \newif\ift@c
183 \newcount\t@cpages\t@cpages\@ne
184 \def\endbody{%
185 \vfill\supereject% is there an alternative?
186 \c@teout\endpage
187 \iffrontmatter
188 \immediate\closeout\ch@pterwrite
189 \ifproof\else\endpage\fi
190 %
191 \l@stpagecount=\number\p@gecount\p@gecount=\number\t@cpagecount
192 \t@bpagecount=\number\t@cpagecount\advance\t@bpagecount\t@cpages
193 \f@gpagecount=\number\t@bpagecount\advance\f@gpagecount\m@ne
194 \t@cfalse
195 {\bf\uppercase{\centertitle{\ch@pterhead}}}\bigbreak
196 \ifnum\ch@ptertot>\z@\unlock\input\ch@pterfile\lock\fi
197 \iff@gt@bhead
198 \ifnum\t@bpagecount=\p@gecount\else\t@ctrue\fi
199 \t@bpagecount=\number\p@gecount\advance\t@bpagecount\m@ne
200 \re@dback\t@btabwrite\t@btabfile\t@btabhead\t@btotal
201 %
202 \ifnum\f@gpagecount=\p@gecount\else\t@ctrue\fi
203 \f@gpagecount=\number\p@gecount\advance\f@gpagecount\m@ne
204 \re@dback\f@gtabwrite\f@gtabfile\f@gtabhead\f@gtotal
205 \endleaf
206 \ift@c
207 \rectoleaf
208 \l@stpagecount=\number\p@gecount\p@gecount=\number\t@cpagecount
209 {\bf\uppercase{\centertitle{\ch@pterhead}}}\bigbreak
210 \ifnum\ch@ptertot>\z@\unlock\input\ch@pterfile\lock\fi
211 %
212 \t@bpagecount=\number\p@gecount\advance\t@bpagecount\m@ne
213 \re@dback\t@btabwrite\t@btabfile\t@btabhead\t@btotal
214 %
215 \f@gpagecount=\number\p@gecount\advance\f@gpagecount\m@ne
216 \re@dback\f@gtabwrite\f@gtabfile\f@gtabhead\f@gtotal
217 \endleaf
218 \fi
219 \fi
220 \endleaf
221 \p@gecount=\number\l@stpagecount
222 \fi
223 }%
224 % SECTION MACRO
225 % The \section macro sets the name in upper
226 % and lower case capitals, prints the
227 % \section{Name}% section name and number (left adjusted)
228 % and skips the appropriate amount of space.
229 \newcount\s@ctioncount
230 \def\s@ctioninit{\global\s@ctioncount\@ne}%
231 \def\secskipt{\bigbreak}%
232 \def\s@ctionname{}%
233 \def\section{\xdef\s@ctionname{\ch@ptername.\number\s@ctioncount}%
234 \global\advance\s@ctioncount\@ne
235 \s@ctionreset
236 \ch@skiph
237 \vbox\bgroup\begingroup\c@tset\s@ctiontable%
238 }%
239 \def\s@ctiontable#1{%
240 \@ddch@pt{#1}{\quad\strut{\s@ctionname}\quad}\endgroup
241 \vskip-\parskip
242 \cp\noindent\s@ctionname\quad#1\par\egroup
243 \backpar\ch@skiph\sectionindent
244 }%
245 \def\s@ctionreset{\subs@ctioninit\subs@ctionreset}%
246 \let\sectionindent\relax
247 %
248 % SUBSECTION MACRO
249 %
250 % \subsection{name}% Subsections appear with a number and
251 % with the name in slant font.
252 %
253 \newcount\subs@ctioncount
254 \def\subs@ctioninit{\global\subs@ctioncount\@ne}%
255 \def\subs@ctionname{}%
256 \def\subsection{% subsection macro
257 \xdef\subs@ctionname{\s@ctionname.\number\subs@ctioncount}%
258 \global\advance\subs@ctioncount\@ne
259 \subs@ctionreset
260 \ch@skiph
261 \vbox\bgroup\begingroup\c@tset\subs@ctiontable%
262 }%
263 \def\subs@ctiontable#1{%
264 \@ddch@pt{#1}{\qquad\strut{\subs@ctionname}\quad}\endgroup
265 \sl\noindent\subs@ctionname\quad#1\par\egroup
266 \backpar\ch@skiph\subsectionindent
267 }%
268 \def\subs@ctionreset{\subsubs@ctioninit\subsubs@ctionreset}%
269 \let\subsectionindent\relax
270 %
271 % SUBSUBSECTION MACRO
272 %
273 % \subsubsection{name}% Subsubsections appear with a number and
274 % with the name in slant font.
275 %
276 \newcount\subsubs@ctioncount
277 \def\subsubs@ctioninit{\global\subsubs@ctioncount\@ne}%
278 \def\subsubsection{%
279 \xdef\subsubs@ctionname{\subs@ctionname.\number\subsubs@ctioncount}%
280 \global\advance\subsubs@ctioncount\@ne
281 \subsubs@ctionreset
282 \ch@skiph
283 \vbox\bgroup\begingroup\c@tset\subsubs@ctiontable%
284 }%
285 \def\subsubs@ctiontable#1{%
286 \@ddch@pt{#1}{\quad\qquad\strut{\subsubs@ctionname}\quad}\endgroup
287 \sl\noindent\subsubs@ctionname\quad#1\par\egroup
288 \backpar\ch@skiph\subsubsectionindent
289 }%
290 \def\subsubs@ctionreset{\p@ntinit\p@ntreset}%
291 \let\subsubsectionindent\relax
292 %
293 % Common to all macros: write into the table of contents file
294 %
295 \newcount\ch@ptertot\ch@ptertot\z@
296 \def\ch@skiph{\par\ifdim\lastskip<\bigskipamount
297 \removelastskip\vskip\bigskipamount\fi}%
298 \def\backpar{\nobreak\vskip-\parskip\nobreak\nointerlineskip}%
299 \def\t@bcontents{% line for table of contents in table of contents
300 \line{\strut\ch@pterhead\leaderfil\romannumeral-\t@cpagecount}%
301 }%
302 \def\@ddch@pt#1#2{\c@tMeoline\l@tMother
303 \xdef\next{%
304 \write\ch@pterwrite{%
305 \line{#2\h@tMother#1\h@tMother%
306 \noexpand\leaderfil\noexpand\numorroman\p@gecount%
307 }%
308 }%
309 }%
310 \next\global\advance\ch@ptertot\@ne
311 \l@tMspace
312 }%
313 % for setting the first letter of each word uppercase: make space active
314 % cause next token to be \uppercase{\next}