Debian Codegraph @

texmf-dist/tex/plain/zztex/zzdoc.tex

raw
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %
3 % Module: ZzTeX Document Facilities
4 %
5 % Synopsis:
6 %
7 % Author: Paul C. Anagnostopoulos
8 % Created: 9 September 1989
9 %
10 % Copyright 1989--2020 by Paul C. Anagnostopoulos
11 % under The MIT License (opensource.org/licenses/MIT)
12 %
13 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
14
15 % Loading Design Files
16 % ------- ------ -----
17
18
19 \def \bookauthor {}
20 \def \booktitle {}
21 \def \bookpublisher {}
22 \def \bookISBN {}
23
24
25 \def \loaddesign #1{% {file-list}
26 \zdtinit
27 \zloadinifile
28 \global\divisionname = \expandafter{\jobname}%
29 \setfoliostyle{\arabic}% % Initialize various options that
30 \setsentencespacing{\false}% $ might be set in the design file.
31 \setmathspaces{4mu plus .4mu minus .75mu}
32 {4mu plus .4mu minus .75mu}
33 {4mu plus .4mu minus .75mu}%
34 \protectcitecommands
35 \commalist{\zdeslist}{#1}%
36 \maplist{\zinputdes{##1}}{\zdeslist}%
37 \textsize\rm % In case \documentdesign resets
38 % \normallineskip[limit].
39 \if \DVIWindorules \setflag \DVIWindoinuse = \true \fi %%% Temporary.
40 \if \newbiblio \input zzbiblio \else \input zzbibtex \fi
41 \if \rangep{\newmath}{1}{2}\input zznewmath\relax \fi
42 \if \newrunners \input zzrunner\relax \fi
43 \if \zerop{\tabularversion}%
44 \tabularversion = \if \newtabular 2\else 1\fi\relax
45 \fi
46 \if \neqlp{\tabularversion}{3}\input zztabularv\the\tabularversion\relax \fi
47 \if \newtitleadjustment \input zzttladj\relax \fi}
48
49 \def \zinputdes #1{% {design-file}
50 \checkfile{\znext}{#1.zzd}%
51 \if \znext
52 \input #1.zzd\relax
53 \else
54 \error{nodesfile}{The design file `#1.zzd' is missing}
55 \zend
56 \fi
57 \if \orp{\hmodep}{\posp{\pagetotal}}
58 \error{desjunk}
59 {The design file `#1.zzd' has some spurious junk in it}
60 \fi
61 \textsize\rm % So \documentdesign macro can use it.
62 \documentdesign}
63
64 \def \announcedesign #1{% {title}
65 \remark{Loading design file `#1'._}}
66
67 \def \bookdata #1#2#3#4{% {author}{title}{publisher}{ISBN}
68 \gdef \bookauthor {#1}%
69 \gdef \booktitle {#2}%
70 \gdef \bookpublisher {#3}%
71 \gdef \bookISBN {#4}}
72
73 %~ Deprecated in favor of |\bookdata|.
74
75 \def \bookinfo #1#2#3{% {author}{title}{publisher}
76 \gdef \bookauthor {#1}%
77 \gdef \booktitle {#2}%
78 \gdef \bookpublisher {#3}}
79
80 \def \commonencoding {%
81 \input zzcomenc\relax
82 \global\setflag \zcommonencoding = \true}
83
84 \def \protectcitecommands {%
85 \let \cite = \citeleterror
86 \let \citeauthr = \citeleterror
87 \let \citeyear = \citeleterror
88 \let \nocite = \citeleterror}
89
90 \def \citeleterror {%
91 \error{citelet}{Cannot use \noexpand\let to define \noexpand\cite commands}}
92
93 % Design Alternatives
94 % ------ ------------
95
96
97 % Design alternatives are deprecated.
98
99 \def \designalternative #1#2{% {\name}{choice}
100 \withname\gdef{\=zA:\string#1}{#2}}
101
102 \def \definedesignalternative #1#2#3{% {\name}{required?}{choice1,...}
103 \definecount{#1}{-1}%
104 \if \undefinedp{\=zA:\string#1}%
105 \if #2%
106 \error{altreq}{The design alternative `\string#1' must be specified}%
107 \else
108 \zdefalt{#1}#3,\zmark
109 \fi
110 \fi
111 \commalist{\zaltlist}{#3}%
112 \tcounta = -1\relax
113 \maplist{\zcompalt{#1}{##1}}{\zaltlist}%
114 \if \negp{#1}%
115 \error{altinv}{The design alternative `\string#1' is invalid}%
116 \fi}
117
118 \def \zdefalt #1#2,#3\zmark{% {\name}choice1,...\zmark
119 \designalternative{#1}{#2}}
120
121 \def \zcompalt #1#2{% {\name}{choice}
122 \increment \tcounta
123 \stringeql{\znext}{\name{\=zA:\string#1}}{#2}%
124 \if \znext \global#1 = \tcounta \fi \relax}
125
126 \let \altcase = \ifcase
127
128 % Document Parameters
129 % -------- ----------
130
131
132 % The following PDF document information options are available.
133
134 \chardef \PDFinfodefault = 0
135 \chardef \PDFinfofull = 1
136 \chardef \PDFinfocomp = 2
137 \chardef \PDFinfonone = 3
138
139
140 % Integer parameters:
141
142 \adjdemerits = 10000 % Adjacent incompatible lines.
143 \binoppenalty = 700 % Line break after binary operator.
144 %\brokenpenalty = 0 % See \even and \oddbrokenpenalty.
145 \clubpenalty = 500 % Club line at bottom of page.
146 \defaulthyphenchar = `\- % Default hyphen character.
147 \defaultskewchar = -1 % Default skew character.
148 \delimiterfactor = 941 % Math delimiter size factor.
149 \displaywidowpenalty = 500 % Widow line above math display.
150 \definecount{\dollarhyph}{0} % 0: no hyphenation after dollar signs;
151 % 1: hyphenate after, but nowhere else;
152 % 2: hyphenate after and other places.
153 \doublehyphendemerits = 80000 % Consecutive hyphenated lines.
154 \errorcontextlines = 8 % Maximum error context line pairs.
155 \definecount{\evenbrokenpenalty}{3000} % Column breaks after hyphenated
156 % line, but on same spread.
157 \exhyphenpenalty = 0 % Line break after explicit hyphen.
158 \finalhyphendemerits = 10000 % Penultimate hyphenated line.
159 \hbadness = 1000 % Above which bad hboxes are shown.
160 \hyphenpenalty = 50 % Line break after discretionary hyphen.
161 \interlinepenalty = 0 % Between lines of a paragraph.
162 \language = 0 % Current set of hyphenation rules.
163 \lefthyphenmin = 2 % Shortest fragment at beginning of
164 % hyphenated word.
165 \linepenalty = 10 % Increment at each line break.
166 \definecount{\lineslong}{0} % Number of lines page can go long.
167 \definecount{\linesperpage}{0} % Number of lines per page.
168 \definecount{\linesshort}{0} % Number of lines page can go short.
169 \definecount{\maxbottomcolumnfloats}{1} % Floats at column bottom.
170 \definecount{\maxbottompagefloats}{1} % Floats at page bottom.
171 \definecount{\maxtopcolumnfloats}{1} % Floats at column top.
172 \definecount{\maxtoppagefloats}{1} % Floats at page top.
173 \definecount{\mintextpercent}{10} % Percent of page that must have text.
174 \newlinechar = -1 % Newline character for \write.
175 \definecount{\newmath}{0} % Revision level of math---DEPRECATED.
176 \definecount{\oddbrokenpenalty}{10000} % Spread breaks after
177 % hyphenated line.
178 \definecount{\PDFinfo}{\PDFinfodefault} % Include document info in final PDF file.
179 \pretolerance = 400 % Badness tolerated before hyphenation.
180 \relpenalty = 500 % Line break after relation operator.
181 \righthyphenmin = 3 % Shortest fragment at end of hypenated word.
182 \definecount{\shrinkpercent}{10} % Percentage shrink is of nominal.
183 \definecount{\stretchpercent}{25} % Percentage of the maximum stretch.
184 \definecount{\tabularversion}{0} % Version of tabular facility.
185 \tolerance = \pretolerance % Badness tolerated after hyphenation.
186 \tracinglostchars = 1 % Positive to trace lost characters.
187 \definecount{\tracingpagemakeup}{0} % Positive to trace page makeup.
188 \tracingstats = 1 % Positive to trace memory statistics.
189 \uchyph = 1 % Positive to hyphenate Capitalized words.
190 \definecount{\underscorehyph}{1} % See \dollarhyph.
191 \vbadness = 2000 % Above which bad vboxes are shown.
192 \widowpenalty = 10000 % Widow line at top of page.
193 \definecount{\xrefcites}{0} % Cross-reference \cite's:
194 % 0: no
195 % 1: simple xref entry
196 % 2: custom xref entry
197
198 % Flag Parameters:
199
200 \setflag \allowcolor = \true % Allow color specials?
201 \setflag \allowreftitle = \false % Allow use of \reftitle?
202 \setflag \baselinetoprules = \true % Rules at page top sit on baseline?
203 \setflag \DVIWindoinuse = \false % Generate DVIWindo-specific goodies?
204 \setflag \DVIWindorules = \false % Display page makeup rules? [deprecated]
205 \setflag \forceepsbb = \false % Force reading of EPS bounding box?
206 \setflag \indexcites = \false % \cite generates indexing command?
207 \setflag \newbiblio = \false % Use new biblio facility?
208 \setflag \newdots = \false % Use new \xdots commands?
209 \setflag \newrunners = \false % Use new runners scheme?
210 \setflag \newtabular = \false % Use new tabular module? [deprecated]
211 \setflag \newtitleadjustment = \false % Use new title adjustment scheme?
212 \setflag \PDFhyperlinks = \false % Generate PDF hyperlinks?
213 \setflag \raggedbottom = \false % Ragged-bottom pages?
214 \setflag \risingbottomfloats = \false % Bottom floats rise up on page?
215 \setflag \risingfootnotes = \false % Footnotes rise up on page?
216 \setflag \topdeltaadjustment = \false % Use \topdelta?
217 \setflag \zcommonencoding = \false % Set with \commonencoding command.
218
219 % Dimension Parameters:
220
221 \boxmaxdepth = \maxdimen % Maximum depth of explicit vboxes.
222 \delimitershortfall = 4pt % Maximum math delimiter shortfall.
223 \emergencystretch = 4pt % Emergency stretchability of each line.
224 \definedimen{\evenbleedshift}{0pt} % Bleed shift for versos.
225 \definedimen{\eveninnermargin}{0pt} % Inner margin (gutter) for versos.
226 \definedimen{\evenlefttextmargin}{0pt} % Left text margin for versos.
227 \definedimen{\evenoutermargin}{0pt} % Outer margin for versos.
228 \definedimen{\evenrighttextmargin}{0pt} % Right text margin for versos.
229 \definedimen{\footerheight}{0pt} % Height of footer box.
230 \definedimen{\headerheight}{0pt} % Height of running head.
231 \definedimen{\headmargin}{0in} % Head (top) margin.
232 \hfuzz = 0.33pt % Overrun before overfull hbox messages.
233 \hoffset = 0pt % Overall horizontal offset.
234 \zremovePlaindef \jot
235 \definedimen{\jot}{3pt} % Increment for opening up math displays.
236 \lineskiplimit = 0pt % Threshold where \lineskip is used
237 % instead of \baselineskip.
238 \let \linewidth = \hsize % Alternate name for \hsize.
239 \maxdepth = 4pt % Maximum depth of boxes on main pages.
240 \zremovePlaindef \normallineskiplimit
241 \definedimen{\normallineskiplimit}{0pt} % Normal line skip limit.
242 \nulldelimiterspace = 1.2pt % Width of a null delimiter.
243 \definedimen{\oddbleedshift}{0pt} % Bleed shift for rectos.
244 \definedimen{\oddinnermargin}{0pt} % Inner margin (gutter) for rectos.
245 \definedimen{\oddlefttextmargin}{0pt} % Left text margin for rectos.
246 \definedimen{\oddoutermargin}{0pt} % Outer margin for rectos.
247 \definedimen{\oddrighttextmargin}{0pt} % Right text margin for rectos.
248 \overfullrule = 6pt % Width of rule appended to overfull boxes.
249 \parindent = 0pt % Width of paragraph indent.
250 \definedimen{\parrag}{0pt} % Raggedness of paragraph lines.
251 \scriptspace = .25pt % Extra space after a sub/superscript.
252 \splitmaxdepth = \maxdimen % Maximum depth of boxes on split pages.
253 \definedimen{\standardbleed}{.125in} % Standard bleed required by press.
254 \definedimen{\standardindent}{0pt} % Standard indentation amount.
255 \definedimen{\textareaheight}{\mindimen}% Height of text area.
256 \definedimen{\textmeasure}{0pc} % Width of text area.
257 \let \textareawidth = \textmeasure
258 \definedimen{\topdelta}{0pt} % \topskip - height(first line).
259 \definedimen{\trimheight}{0in} % Trimmed paper height.
260 \definedimen{\trimwidth}{0in} % Trimmed paper width.
261 \definedimen{\trimplusbleedheight}{0in} % Trim plus bleed top and bottom.
262 \definedimen{\trimplusbleedwidth}{0in} % Trim plus bleed both sides.
263 \definedimen{\typeareaheight}{\mindimen}% Height of type area.
264 \definedimen{\typeareawidth}{0pt} % Width of type area.
265 \vfuzz = 0.5pt % Overrun before overfull vbox messages.
266 \voffset = 0pt % Overall vertical offset.
267
268 % Skip (glue) Parameters:
269
270 \leftskip = 0pt % At left end of paragraph lines.
271 \lineskip = 0pt % When \baselineskip isn't possible.
272 \zremovePlaindef \normalbaselineskip
273 \defineskip{\normalbaselineskip}{0pt} % Normal baseline distance.
274 \zremovePlaindef \normallineskip
275 \defineskip{\normallineskip}{0pt} % Normal line skip limit.
276 \parfillskip = 0pt plus 1fil % Additional \rightskip at paragraph end.
277 \parskip = 0pt % Above paragraphs.
278 \rightskip = 0pt % At right end of lines.
279 \spaceskip = 0pt % Between words (if nonzero).
280 \splittopskip = 10pt % At top of split pages.
281 \defineskip{\standardskip}{0pt} % Standard skip above/below elements.
282 \topskip = \mindimen % At top of main pages.
283 \xspaceskip = 0pt % Between sentences (if nonzero).
284
285 % Muskip (mu glue) Parameters:
286
287 \definemuskip{\fracbarhang}{0mu} % Fraction bar overhang.
288 \thinmuskip = 0mu % Math space after punctuation.
289 \medmuskip = 0mu % Math space around binary operators.
290 \thickmuskip = 0mu % Math space around relational operators.
291
292 % Token list parameters:
293
294 \definetoks{\annotationfont} % Font for annotations (e.g., proof identification).
295 \annotationfont = {cmssi10 at 7pt}
296 \definetoks{\baselinemultiplier}% Multiplier for baselines.
297 \baselinemultiplier = {1}
298 \definetoks{\decimalpoint} % Decimal point character.
299 \decimalpoint = {.}
300 \definetoks{\PDFbuttoncolor} % Color of hyperlinked text.
301 \definetoks{\matrixspread} % Baseline multiplier for matrices.
302 \matrixspread = {1.0}
303
304 % The following parameters are fixed and hidden from the user.
305
306 \mathsurround = 0pt % Space around a math formula in text.
307
308 % Parameter Calculation
309 % --------- -----------
310
311
312 \def \calculatetextareaheight #1{% {lines}
313 \relax
314 \if \dimnegp{\topskip}%
315 \error{misstopskip}{The value of \string\topskip must be set}%
316 \fi
317 {\global\linesperpage = #1\relax
318 \tcounta = #1\relax
319 \decrement \tcounta
320 \textareaheight = \the\tcounta\baselineskip
321 \global\advance \textareaheight by \topskip
322 \measurecapheight{\topdelta}%
323 \measureascenderheight{\tdimena}%
324 \if \dimgtrp{\tdimena}{\topdelta}\topdelta = \tdimena \fi
325 \advance \topdelta by -\topskip
326 \global\negate \topdelta}}
327
328 \def \calculatetypeareaheight #1#2{% {head-height}{head-b/b}
329 \relax
330 \if \dimnegp{\textareaheight}%
331 \error{misstah}{The value of \string\textareaheight must be set}%
332 \fi
333 {\typeareaheight = \textareaheight
334 \advance \typeareaheight by -\topskip
335 \advance \typeareaheight by #1\relax
336 \advance \typeareaheight by #2\relax
337 \global\advance \typeareaheight by \footerheight
338 \headerheight = #1\relax
339 \advance \headerheight by #2\relax
340 \global\advance \headerheight by -\topskip}}
341
342 \def \calculateoffsets #1#2{% {sheet-width}{sheet-height}
343 \relax
344 \if \andp{\dimposp{\trimwidth}}{\dimposp{\trimheight}}%
345 \hoffset = #1\relax
346 \advance \hoffset by -\trimwidth
347 \divide \hoffset by 2
348 \advance \hoffset by -1in
349 \voffset = #2\relax
350 \advance \voffset by -\trimheight
351 \divide \voffset by 2
352 \advance \voffset by -1in\relax
353 \else
354 \error{misstrim}{The values of \string\trimwidth and
355 \string\trimheight must be set}%
356 \fi}
357
358 \def \calculatepdfoffsets #1#2#3{% {virtual-width}{virtual-height}{bleeds?}
359 \relax
360 \if \andp{\dimposp{\trimwidth}}{\dimposp{\trimheight}}%
361 \hoffset = -1in
362 \if #3\advance \hoffset by \standardbleed \fi
363 \calculate \voffset = {#2,-,\trimheight,-,1in}%
364 \if #3\advance \voffset by -\standardbleed \fi
365 \else
366 \error{misstrim}{The values of \string\trimwidth and
367 \string\trimheight must be set}%
368 \fi}
369
370 \def \setskip #1=#2#3#4{% \parameter = {nominal}{max-stretch}{[shrink]}
371 \tdimena = #2\relax
372 \calculate \tdimenb = {#3,P,\stretchpercent}%
373 \if \emptyargp{#4}%
374 \calculate \tdimenc = {\tdimena,P,\shrinkpercent}%
375 \else
376 \tdimenc = #4\relax
377 \fi
378 #1 = \the\tdimena plus \the\tdimenb minus \the\tdimenc\relax}
379
380 \def \fromtrim #1{% \setskip or \register
381 \if \tokeqlp{#1}{\setskip}%
382 \let \znext = \zfromtrima
383 \else
384 \def \zfromtrimreg {#1}%
385 \let \znext = \zfromtrimb
386 \fi
387 \znext}
388
389 \def \zfromtrima #1=#2#3#4{%
390 \setskip #1={#2}{#3}{#4}%
391 \advance #1 by -\headmargin}
392
393 \def \zfromtrimb {%
394 \afterassignment\zfromtrimc \zfromtrimreg}
395
396 \def \zfromtrimc {%
397 \advance \zfromtrimreg by -\headmargin}
398
399 % Document Block
400 % -------- -----
401
402
403 \def \document {%
404 % There is no point to embedding the entire document in a group.
405 % \documentdesign was already invoked by \loaddesign.
406 \zpushblock{document}%
407 \xdef \znext {%
408 \noexpand\definefont \noexpand\zannofont{\the\annotationfont}}
409 \znext
410 \zfontsummary{\false}%
411 \zopentfmlist
412 \zwritePDFinfo
413 \zpageinit
414 \zpushvcontext
415 \setparrag{\parrag}%
416 \zxrefinit
417 \zbiblioinit
418 \zindexinit
419 \zfloatinit
420 \setpagecolumns{}{1}{0pt}%
421 \if \definedp{\documentprolog}\documentprolog \fi}
422
423 \def \enddocument {%
424 \endgraf
425 \if \definedp{\documentepilog}\documentepilog \fi
426 \closeanychapter
427 \closeanysection
428 \zpopblock{document}%
429 \freshpage{\short\floats\any}%
430 \zindexfinal
431 \zxreffinal
432 %%% \zbibfinal
433 \zmissingartmsg
434 \ztagsummary
435 \zpopvcontext
436 \zlayoutsummary
437 \zfontsummary{\true}%
438 \zwritetfmlist
439 \if \posp{\tracingstats}\zregstats \fi
440 \zfeaturewarns
441 \ztodomsg
442 \zdivmsg
443 \zproofidfile
444 \zend}
445
446 \def \zfeaturewarns {%
447 \messagenl{_}%
448 \if \zoverlayset
449 \remark{Overlays are present on each page.}%
450 \fi
451 \zproofident}
452
453 \def \zproofident {%
454 \zproofidentline
455 \if \emptytoksp{\zproofid}%
456 \messagenl{| No proof identification.}%
457 \else
458 \messagenl{| \the\zproofid\space\space
459 \number\year/\number\month/\number\day\space
460 \formattime\space\space\space
461 \inicompositor}%
462 \fi
463 \zproofidentline}
464
465 \def \zproofidentline {%
466 \messagenl{+-----------------------------------------------------------------------------_}}
467
468 % Write PDF Document Information
469 % ----- --- -------- -----------
470
471
472 \def \zwritePDFinfo {%
473 \ifcase \PDFinfo
474 \relax
475 \or
476 \special{PDF: Title \booktitle}%
477 \special{PDF: Author \bookauthor}%
478 \special{PDF: Subject}%
479 \special{PDF: Keywords Publisher: \bookpublisher,
480 Compositor: \inicompositor}%
481 \or
482 \special{PDF: Title}%
483 \special{PDF: Author}%
484 \special{PDF: Subject}%
485 \special{PDF: Keywords Compositor: \inicompositor}%
486 \or
487 \special{PDF: Title}%
488 \special{PDF: Author}%
489 \special{PDF: Subject}%
490 \special{PDF: Keywords}%
491 \fi}
492
493 % Disable \end
494 % ------- ----
495
496
497 \let \zend = \end
498
499 \def \end {%
500 \error{noend}{Do not use the TeX \string\end\space command}}