summaryrefslogtreecommitdiff
path: root/macros/plain/contrib/zztex/tex/zzdoc.tex
blob: 072436a43ad742de0304e98dfc864fbf88fe632f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Module:    ZzTeX Document Facilities
%
% Synopsis:
%
% Author:    Paul C. Anagnostopoulos
% Created:   9 September 1989
%
% Copyright 1989--2020 by Paul C. Anagnostopoulos
% under The MIT License (opensource.org/licenses/MIT)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%                       Loading Design Files
%                       ------- ------ -----


\def \bookauthor {}
\def \booktitle {}
\def \bookpublisher {}
\def \bookISBN {}


\def \loaddesign #1{%                                   {file-list}
  \zdtinit
  \zloadinifile
  \global\divisionname = \expandafter{\jobname}%
  \setfoliostyle{\arabic}%              % Initialize various options that
  \setsentencespacing{\false}%          $ might be set in the design file.
  \setmathspaces{4mu plus .4mu minus .75mu}
                {4mu plus .4mu minus .75mu}
                {4mu plus .4mu minus .75mu}%
  \protectcitecommands
  \commalist{\zdeslist}{#1}%
  \maplist{\zinputdes{##1}}{\zdeslist}%
  \textsize\rm                          % In case \documentdesign resets
                                        % \normallineskip[limit].
  \if \DVIWindorules \setflag \DVIWindoinuse = \true \fi %%% Temporary.
  \if \newbiblio \input zzbiblio \else \input zzbibtex \fi
  \if \rangep{\newmath}{1}{2}\input zznewmath\relax \fi
  \if \newrunners \input zzrunner\relax \fi
  \if \zerop{\tabularversion}%
    \tabularversion = \if \newtabular 2\else 1\fi\relax
  \fi
  \if \neqlp{\tabularversion}{3}\input zztabularv\the\tabularversion\relax \fi
  \if \newtitleadjustment \input zzttladj\relax \fi}

\def \zinputdes #1{%                            {design-file}
  \checkfile{\znext}{#1.zzd}%
  \if \znext
    \input #1.zzd\relax
  \else
    \error{nodesfile}{The design file `#1.zzd' is missing}
    \zend
  \fi
  \if \orp{\hmodep}{\posp{\pagetotal}}
    \error{desjunk}
          {The design file `#1.zzd' has some spurious junk in it}
  \fi
  \textsize\rm                  % So \documentdesign macro can use it.
  \documentdesign}

\def \announcedesign #1{%                       {title}
  \remark{Loading design file `#1'._}}

\def \bookdata #1#2#3#4{%                       {author}{title}{publisher}{ISBN}
  \gdef \bookauthor {#1}%
  \gdef \booktitle {#2}%
  \gdef \bookpublisher {#3}%
  \gdef \bookISBN {#4}}

%~ Deprecated in favor of |\bookdata|.

\def \bookinfo #1#2#3{%                         {author}{title}{publisher}
  \gdef \bookauthor {#1}%
  \gdef \booktitle {#2}%
  \gdef \bookpublisher {#3}}

\def \commonencoding {%
  \input zzcomenc\relax
  \global\setflag \zcommonencoding = \true}

\def \protectcitecommands {%
  \let \cite      = \citeleterror
  \let \citeauthr = \citeleterror
  \let \citeyear  = \citeleterror
  \let \nocite    = \citeleterror}

\def \citeleterror {%
  \error{citelet}{Cannot use \noexpand\let to define \noexpand\cite commands}}

%                       Design Alternatives
%                       ------ ------------


% Design alternatives are deprecated.

\def \designalternative #1#2{%                  {\name}{choice}
  \withname\gdef{\=zA:\string#1}{#2}}

\def \definedesignalternative #1#2#3{%          {\name}{required?}{choice1,...}
  \definecount{#1}{-1}%
  \if \undefinedp{\=zA:\string#1}%
    \if #2%
      \error{altreq}{The design alternative `\string#1' must be specified}%
    \else
      \zdefalt{#1}#3,\zmark
    \fi
  \fi
  \commalist{\zaltlist}{#3}%
  \tcounta = -1\relax
  \maplist{\zcompalt{#1}{##1}}{\zaltlist}%
  \if \negp{#1}%
    \error{altinv}{The design alternative `\string#1' is invalid}%
  \fi}

\def \zdefalt #1#2,#3\zmark{%                   {\name}choice1,...\zmark
  \designalternative{#1}{#2}}

\def \zcompalt #1#2{%                           {\name}{choice}
  \increment \tcounta
  \stringeql{\znext}{\name{\=zA:\string#1}}{#2}%
  \if \znext \global#1 = \tcounta \fi \relax}

\let \altcase = \ifcase

%                       Document Parameters
%                       -------- ----------


% The following PDF document information options are available.

\chardef \PDFinfodefault = 0
\chardef \PDFinfofull    = 1
\chardef \PDFinfocomp    = 2
\chardef \PDFinfonone    = 3


% Integer parameters:

\adjdemerits = 10000            % Adjacent incompatible lines.
\binoppenalty = 700             % Line break after binary operator.
%\brokenpenalty = 0             % See \even and \oddbrokenpenalty.
\clubpenalty = 500              % Club line at bottom of page.
\defaulthyphenchar = `\-        % Default hyphen character.
\defaultskewchar = -1           % Default skew character.
\delimiterfactor = 941          % Math delimiter size factor.
\displaywidowpenalty = 500      % Widow line above math display.
\definecount{\dollarhyph}{0}    % 0: no hyphenation after dollar signs;
                                % 1: hyphenate after, but nowhere else;
                                % 2: hyphenate after and other places.
\doublehyphendemerits = 80000   % Consecutive hyphenated lines.
\errorcontextlines = 8          % Maximum error context line pairs.
\definecount{\evenbrokenpenalty}{3000}  % Column breaks after hyphenated
                                        % line, but on same spread.
\exhyphenpenalty = 0            % Line break after explicit hyphen.
\finalhyphendemerits = 10000    % Penultimate hyphenated line.
\hbadness = 1000                % Above which bad hboxes are shown.
\hyphenpenalty = 50             % Line break after discretionary hyphen.
\interlinepenalty = 0           % Between lines of a paragraph.
\language = 0                   % Current set of hyphenation rules.
\lefthyphenmin = 2              % Shortest fragment at beginning of
                                % hyphenated word.
\linepenalty = 10               % Increment at each line break.
\definecount{\lineslong}{0}     % Number of lines page can go long.
\definecount{\linesperpage}{0}  % Number of lines per page.
\definecount{\linesshort}{0}    % Number of lines page can go short.
\definecount{\maxbottomcolumnfloats}{1} % Floats at column bottom.
\definecount{\maxbottompagefloats}{1}   % Floats at page bottom.
\definecount{\maxtopcolumnfloats}{1}    % Floats at column top.
\definecount{\maxtoppagefloats}{1}      % Floats at page top.
\definecount{\mintextpercent}{10} % Percent of page that must have text.
\newlinechar = -1               % Newline character for \write.
\definecount{\newmath}{0}       % Revision level of math---DEPRECATED.
\definecount{\oddbrokenpenalty}{10000}  % Spread breaks after
                                        % hyphenated line.
\definecount{\PDFinfo}{\PDFinfodefault} % Include document info in final PDF file.
\pretolerance = 400             % Badness tolerated before hyphenation.
\relpenalty = 500               % Line break after relation operator.
\righthyphenmin = 3             % Shortest fragment at end of hypenated word.
\definecount{\shrinkpercent}{10}        % Percentage shrink is of nominal.
\definecount{\stretchpercent}{25}       % Percentage of the maximum stretch.
\definecount{\tabularversion}{0}        % Version of tabular facility.
\tolerance = \pretolerance      % Badness tolerated after hyphenation.
\tracinglostchars = 1           % Positive to trace lost characters.
\definecount{\tracingpagemakeup}{0}     % Positive to trace page makeup.
\tracingstats = 1               % Positive to trace memory statistics.
\uchyph = 1                     % Positive to hyphenate Capitalized words.
\definecount{\underscorehyph}{1}        % See \dollarhyph.
\vbadness = 2000                % Above which bad vboxes are shown.
\widowpenalty = 10000           % Widow line at top of page.
\definecount{\xrefcites}{0}     % Cross-reference \cite's:
                                %   0: no
                                %   1: simple xref entry
                                %   2: custom xref entry

% Flag Parameters:

\setflag \allowcolor = \true            % Allow color specials?
\setflag \allowreftitle = \false        % Allow use of \reftitle?
\setflag \baselinetoprules = \true      % Rules at page top sit on baseline?
\setflag \DVIWindoinuse = \false        % Generate DVIWindo-specific goodies?
\setflag \DVIWindorules = \false        % Display page makeup rules? [deprecated]
\setflag \forceepsbb = \false           % Force reading of EPS bounding box?
\setflag \indexcites = \false           % \cite generates indexing command?
\setflag \newbiblio = \false            % Use new biblio facility?
\setflag \newdots = \false              % Use new \xdots commands?
\setflag \newrunners = \false           % Use new runners scheme?
\setflag \newtabular = \false           % Use new tabular module? [deprecated]
\setflag \newtitleadjustment = \false   % Use new title adjustment scheme?
\setflag \PDFhyperlinks = \false        % Generate PDF hyperlinks?
\setflag \raggedbottom = \false         % Ragged-bottom pages?
\setflag \risingbottomfloats = \false   % Bottom floats rise up on page?
\setflag \risingfootnotes = \false      % Footnotes rise up on page?
\setflag \topdeltaadjustment = \false   % Use \topdelta?
\setflag \zcommonencoding = \false      % Set with \commonencoding command.

% Dimension Parameters:

\boxmaxdepth = \maxdimen        % Maximum depth of explicit vboxes.
\delimitershortfall = 4pt       % Maximum math delimiter shortfall.
\emergencystretch = 4pt         % Emergency stretchability of each line.
\definedimen{\evenbleedshift}{0pt}      % Bleed shift for versos.
\definedimen{\eveninnermargin}{0pt}     % Inner margin (gutter) for versos.
\definedimen{\evenlefttextmargin}{0pt}  % Left text margin for versos.
\definedimen{\evenoutermargin}{0pt}     % Outer margin for versos.
\definedimen{\evenrighttextmargin}{0pt} % Right text margin for versos.
\definedimen{\footerheight}{0pt}        % Height of footer box.
\definedimen{\headerheight}{0pt}        % Height of running head.
\definedimen{\headmargin}{0in}          % Head (top) margin.
\hfuzz = 0.33pt                 % Overrun before overfull hbox messages.
\hoffset = 0pt                  % Overall horizontal offset.
\zremovePlaindef \jot
\definedimen{\jot}{3pt}         % Increment for opening up math displays.
\lineskiplimit = 0pt            % Threshold where \lineskip is used
                                % instead of \baselineskip.
\let \linewidth = \hsize        % Alternate name for \hsize.
\maxdepth = 4pt                 % Maximum depth of boxes on main pages.
\zremovePlaindef \normallineskiplimit
\definedimen{\normallineskiplimit}{0pt} % Normal line skip limit.
\nulldelimiterspace = 1.2pt             % Width of a null delimiter.
\definedimen{\oddbleedshift}{0pt}       % Bleed shift for rectos.
\definedimen{\oddinnermargin}{0pt}      % Inner margin (gutter) for rectos.
\definedimen{\oddlefttextmargin}{0pt}   % Left text margin for rectos.
\definedimen{\oddoutermargin}{0pt}      % Outer margin for rectos.
\definedimen{\oddrighttextmargin}{0pt}  % Right text margin for rectos.
\overfullrule = 6pt             % Width of rule appended to overfull boxes.
\parindent = 0pt                % Width of paragraph indent.
\definedimen{\parrag}{0pt}      % Raggedness of paragraph lines.
\scriptspace = .25pt            % Extra space after a sub/superscript.
\splitmaxdepth = \maxdimen      % Maximum depth of boxes on split pages.
\definedimen{\standardbleed}{.125in}    % Standard bleed required by press.
\definedimen{\standardindent}{0pt}      % Standard indentation amount.
\definedimen{\textareaheight}{\mindimen}% Height of text area.
\definedimen{\textmeasure}{0pc}         % Width of text area.
\let \textareawidth = \textmeasure
\definedimen{\topdelta}{0pt}            % \topskip - height(first line).
\definedimen{\trimheight}{0in}          % Trimmed paper height.
\definedimen{\trimwidth}{0in}           % Trimmed paper width.
\definedimen{\trimplusbleedheight}{0in} % Trim plus bleed top and bottom.
\definedimen{\trimplusbleedwidth}{0in}  % Trim plus bleed both sides.
\definedimen{\typeareaheight}{\mindimen}% Height of type area.
\definedimen{\typeareawidth}{0pt}       % Width of type area.
\vfuzz = 0.5pt                  % Overrun before overfull vbox messages.
\voffset = 0pt                  % Overall vertical offset.

% Skip (glue) Parameters:

\leftskip = 0pt                 % At left end of paragraph lines.
\lineskip = 0pt                 % When \baselineskip isn't possible.
\zremovePlaindef \normalbaselineskip
\defineskip{\normalbaselineskip}{0pt}   % Normal baseline distance.
\zremovePlaindef \normallineskip
\defineskip{\normallineskip}{0pt}       % Normal line skip limit.
\parfillskip = 0pt plus 1fil    % Additional \rightskip at paragraph end.
\parskip = 0pt                  % Above paragraphs.
\rightskip = 0pt                % At right end of lines.
\spaceskip = 0pt                % Between words (if nonzero).
\splittopskip = 10pt            % At top of split pages.
\defineskip{\standardskip}{0pt} % Standard skip above/below elements.
\topskip = \mindimen            % At top of main pages.
\xspaceskip = 0pt               % Between sentences (if nonzero).

% Muskip (mu glue) Parameters:

\definemuskip{\fracbarhang}{0mu}        % Fraction bar overhang.
\thinmuskip = 0mu               % Math space after punctuation.
\medmuskip = 0mu                % Math space around binary operators.
\thickmuskip = 0mu              % Math space around relational operators.

% Token list parameters:

\definetoks{\annotationfont}    % Font for annotations (e.g., proof identification).
\annotationfont = {cmssi10 at 7pt}
\definetoks{\baselinemultiplier}% Multiplier for baselines.
\baselinemultiplier = {1}
\definetoks{\decimalpoint}      % Decimal point character.
\decimalpoint = {.}
\definetoks{\PDFbuttoncolor}    % Color of hyperlinked text.
\definetoks{\matrixspread}      % Baseline multiplier for matrices.
\matrixspread = {1.0}

% The following parameters are fixed and hidden from the user.

\mathsurround = 0pt             % Space around a math formula in text.

%                       Parameter Calculation
%                       --------- -----------


\def \calculatetextareaheight #1{%                              {lines}
  \relax
  \if \dimnegp{\topskip}%
    \error{misstopskip}{The value of \string\topskip must be set}%
  \fi
  {\global\linesperpage = #1\relax
   \tcounta = #1\relax
   \decrement \tcounta
   \textareaheight = \the\tcounta\baselineskip
   \global\advance \textareaheight by \topskip
   \measurecapheight{\topdelta}%
   \measureascenderheight{\tdimena}%
   \if \dimgtrp{\tdimena}{\topdelta}\topdelta = \tdimena \fi
   \advance \topdelta by -\topskip
   \global\negate \topdelta}}

\def \calculatetypeareaheight #1#2{%                    {head-height}{head-b/b}
  \relax
  \if \dimnegp{\textareaheight}%
    \error{misstah}{The value of \string\textareaheight must be set}%   
  \fi
  {\typeareaheight = \textareaheight
   \advance \typeareaheight by -\topskip
   \advance \typeareaheight by #1\relax
   \advance \typeareaheight by #2\relax
   \global\advance \typeareaheight by \footerheight
   \headerheight = #1\relax
   \advance \headerheight by #2\relax
   \global\advance \headerheight by -\topskip}}

\def \calculateoffsets #1#2{%                   {sheet-width}{sheet-height}
  \relax
  \if \andp{\dimposp{\trimwidth}}{\dimposp{\trimheight}}%
    \hoffset = #1\relax
    \advance \hoffset by -\trimwidth
    \divide \hoffset by 2
    \advance \hoffset by -1in
    \voffset = #2\relax
    \advance \voffset by -\trimheight
    \divide \voffset by 2
    \advance \voffset by -1in\relax
  \else
    \error{misstrim}{The values of \string\trimwidth and
                     \string\trimheight must be set}%
  \fi}

\def \calculatepdfoffsets #1#2#3{%      {virtual-width}{virtual-height}{bleeds?}
  \relax
  \if \andp{\dimposp{\trimwidth}}{\dimposp{\trimheight}}%
    \hoffset = -1in
    \if #3\advance \hoffset by \standardbleed \fi
    \calculate \voffset = {#2,-,\trimheight,-,1in}%
    \if #3\advance \voffset by -\standardbleed \fi
  \else
    \error{misstrim}{The values of \string\trimwidth and
                     \string\trimheight must be set}%
  \fi}

\def \setskip #1=#2#3#4{%        \parameter = {nominal}{max-stretch}{[shrink]}
  \tdimena = #2\relax
  \calculate \tdimenb = {#3,P,\stretchpercent}%
  \if \emptyargp{#4}%
    \calculate \tdimenc = {\tdimena,P,\shrinkpercent}%
  \else
    \tdimenc = #4\relax
  \fi
  #1 = \the\tdimena plus \the\tdimenb minus \the\tdimenc\relax}

\def \fromtrim #1{%                             \setskip or \register
  \if \tokeqlp{#1}{\setskip}%
    \let \znext = \zfromtrima
  \else
    \def \zfromtrimreg {#1}%
    \let \znext = \zfromtrimb
  \fi
  \znext}

\def \zfromtrima #1=#2#3#4{%
  \setskip #1={#2}{#3}{#4}%
  \advance #1 by -\headmargin}
  
\def \zfromtrimb {%
  \afterassignment\zfromtrimc \zfromtrimreg}

\def \zfromtrimc {%
  \advance \zfromtrimreg by -\headmargin}

%                       Document Block
%                       -------- -----


\def \document {%
  % There is no point to embedding the entire document in a group.
  % \documentdesign was already invoked by \loaddesign.
  \zpushblock{document}%
  \xdef \znext {%
    \noexpand\definefont \noexpand\zannofont{\the\annotationfont}}
  \znext
  \zfontsummary{\false}%
  \zopentfmlist
  \zwritePDFinfo
  \zpageinit
  \zpushvcontext
  \setparrag{\parrag}%
  \zxrefinit
  \zbiblioinit
  \zindexinit
  \zfloatinit
  \setpagecolumns{}{1}{0pt}%
  \if \definedp{\documentprolog}\documentprolog \fi}

\def \enddocument {%
  \endgraf
  \if \definedp{\documentepilog}\documentepilog \fi
  \closeanychapter
  \closeanysection
  \zpopblock{document}%
  \freshpage{\short\floats\any}%
  \zindexfinal
  \zxreffinal
%%%  \zbibfinal
  \zmissingartmsg
  \ztagsummary
  \zpopvcontext
  \zlayoutsummary
  \zfontsummary{\true}%
  \zwritetfmlist
  \if \posp{\tracingstats}\zregstats \fi
  \zfeaturewarns
  \ztodomsg
  \zdivmsg
  \zproofidfile
  \zend}

\def \zfeaturewarns {%
  \messagenl{_}%
  \if \zoverlayset
    \remark{Overlays are present on each page.}%
  \fi
  \zproofident}

\def \zproofident {%
  \zproofidentline
  \if \emptytoksp{\zproofid}%
    \messagenl{|  No proof identification.}%
  \else
    \messagenl{|  \the\zproofid\space\space
                  \number\year/\number\month/\number\day\space
                  \formattime\space\space\space
                  \inicompositor}%
  \fi
  \zproofidentline}

\def \zproofidentline {%
  \messagenl{+-----------------------------------------------------------------------------_}}

%                       Write PDF Document Information
%                       ----- --- -------- -----------


\def \zwritePDFinfo {%
  \ifcase \PDFinfo
    \relax
  \or
    \special{PDF: Title \booktitle}%
    \special{PDF: Author \bookauthor}%
    \special{PDF: Subject}%
    \special{PDF: Keywords Publisher: \bookpublisher,
                           Compositor: \inicompositor}%
  \or
    \special{PDF: Title}%
    \special{PDF: Author}%
    \special{PDF: Subject}%
    \special{PDF: Keywords Compositor: \inicompositor}%
  \or
    \special{PDF: Title}%
    \special{PDF: Author}%
    \special{PDF: Subject}%
    \special{PDF: Keywords}%
  \fi}

%                       Disable \end
%                       ------- ----


\let \zend = \end

\def \end {%
  \error{noend}{Do not use the TeX \string\end\space command}}