summaryrefslogtreecommitdiff
path: root/info/digests/tex88/hoenig/h0.tex
blob: ef6878c0f1f3006901fb39deb5ba8b9519789235 (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
%%
%% 
%%  STRUTS and miscellaneous macros. 
%%   
%\newdimen\strutheight \newdimen\strutdepth 
%\strutheight=\ht\strutbox \strutdepth=\dp\strutbox 
\newdimen\fudgedimen \fudgedimen=1.944444pt 
\font\specialfont=cmbxsl10 scaled\magstep1 \def\z{0pt} 
%% 
%%  WHERE AM I? 
%%    Macro a la Reid to determine current position 
%%    on the page.  \NEWOUTPUT is the temporary new 
%%    output that we use in this macro to get position. 
%%    Normal output routine is stored as \SAVEDOUTPUT. 
%% 
\newtoks\savedoutput  \savedoutput={\the\output} 
\newbox\partialpage \newdimen\currentheight 
\def\newoutput{\setbox\partialpage=\vbox{\unvbox255}% 
\global\currentheight=\ht\partialpage \unvbox\partialpage} 
%% 
\def\whereami{\global\savedoutput=\output % 
\global\output={\newoutput}% 
\par \penalty-10000 % huge reward for doing output 
\global\output=\savedoutput} 
%% 
%% COMPUTEGOALHEIGHT  
%% =================  
%%    
%%   Computes space we want to allocate for page 1 
%%   of story.  \GOALHEIGHT stores the computed goad 
%%   height.  This macro uses the following rule:  If  
%%   the space left on page is > .5\vsize, then half of  
%%   that will be the goal height.  Otherwise, all the re- 
%%   maining space is allocated to \goalheight.  Users and  
%%   editors can code their own space allocation scheme into  
%%   this macro.  This macro has no arguments. 
%% 
\newdimen\goalheight 
\def\computegoalheight{% 
\goalheight=\vsize %% 
\advance\goalheight by-\currentheight 
\ifdim\currentheight>.5\vsize \else \divide\goalheight by2 
\fi 
\advance\goalheight by-2\baselineskip % adjust for title 
\count10=\goalheight %% compute goalheight equiv in lines 
\divide\count10 by\baselineskip  
\advance\count10 by1 %% adjust for truncation in division 
} 
%%  
%% \BEGINSTORY, \ENDSTORY Macros 
%% ======================  
%% Use these macros to typeset the article.  Begin 
%% with \beginstory and frame the end with \endstory. 
%%  
\newcount\n %% used by \createparshapespec 
\newbox\currentpage %% to hold the article lead 
\newtoks\parshapespec %% used by \createparshapespec 
\newtoks\keyword %% will contain keyword identifier 
\newdimen\leadhsize % \hsize of lead 
\newdimen\jumphsize % \hsize of jump 
\newdimen\shortsize % width of last line of lead 
%%  
\def\beginstory[title:#1][key:#2][lead hsize:#3][lead 
height:#4lines][jump hsize:#5]{% 
%% #1: the title of the story 
%% #2: a single word for ident purposes 
%% #3: width (hsize) of story lead 
%% #4: depth of first part of story in LINES (1line 
%%     = \baselineskip); let it be -1 (or any negative num) 
%%       if you want \TeX to compute it as the goalheight 
%% #5: width of second part (jump) of story 
%% \BEGINSTORY will always typeset the lead part of the  
%% story. Complete the story with the command \ENDSTORY 
%% You have to explicitly give the command to typeset the  
%% JUMP.  Do this via ``\printjump[key]'' where the `key' is 
%% the parameter #2. 
%%  
%% Because the determination of the forward and backward  
%% page references requires a 2-pass compilation, you will 
%% have to typeset your story TWICE. Otherwise, the page  
%% references will appear as question marks `???'. 
%% 
\setbox0=\hbox{\quad\it Please see {\bf #2} on page ??} 
\shortsize=#3 %% to hold width of last line of lead 
\advance\shortsize by-\wd0 %% reduce by space for xref 
%%  
\leadhsize=#3 \jumphsize=#5  
\setbox0=\vbox to2\baselineskip{\hbox 
to\leadhsize{\hss\specialfont #1\hss}\vss}% 
%%  assume title occupies 2\baselineskip of space 
\box0 %% typeset title info 
\count10=#4 \advance\count10 by-2 %% adjust for title 
%% 
\ifnum\count10>0 %% User specified space for lead? 
    \goalheight=\count10\baselineskip %% yes 
    \n=\count10 %% set numerical argument for \parshape 
    \else %% no 
    \whereami \computegoalheight  
    \n=\count10 %%set numerical argument for \parshape 
\fi %\n is the number of lines in the lead 
\advance\n by1 % \n is the parameter for \parshape 
%% \box0 will contain title 
\createparshapespec 
\makeboxident{#2}% 
\global\keyword={#2}% 
\partoks=% will contain `stuff' controlling typesetting 
{\tolerance=7000 \hsize=#3 \pageshape=\n \the\parshapespec} 
\putinvbox{#2}% 
}  %% END OF MACRO \BEGINSTORY  
%%
%%  
\newdimen\splitheight %% ht of article lead  
\def\endstory{%% \ENDSTORY Macro 
\shutbox %% close box containing lead 
\splittopskip=\strutheight 
\ifpasstwo %% then determine page reference 
\def\pageident{\expandafter\csname\the\keyword 
b\endcsname}% 
      \else %% first pass; for explanation of weird  
%%    \write convolutions, see TeXbook, ex 21.10 
\def\pageident{???}{\edef\mywrite{\write\xrefout{\{\csname\the\keyword 
a\endcsname:}} \mywrite}% 
{\let\the=0\edef\mywrite{\write\xrefout{\the\pageno:\} }} 
\mywrite}\fi  
\advance\n by-1 %% num of lines in lead 
\splitheight=\n\baselineskip %% how high will lead be? 
\setbox\currentpage=\vsplit\allocationnumber to\splitheight  
%% see TeXbook, pg 346 ff for \allocationnumber 
\vbox{% keep \box\currentpage & reference together 
\box\currentpage 
\vskip-\baselineskip \vskip-\strutdepth  
\vskip-\fudgedimen 
\hbox to\leadhsize{\hss\it \strut Please see 
{\bf\the\keyword} on page \pageident}% 
}% end of \vbox 
}%% End of \ENDSTORY 
%%  
%%  
%% \CREATEPARSHAPESPEC Macro 
%% =========================  
%%  
%% \n contains the numerical argument for \parshape. 
%% This macro called by \beginstory only. 
%%  
\def\createparshapespec{% 
\count10=\n %% use \count10 as scratch register 
\advance\count10 by-2 \global\parshapespec={}% 
\loop\ifnum\count10>0 
\parshapespec=\expandafter{\the\parshapespec \z\leadhsize} 
\advance\count10 by-1 \repeat  
\parshapespec=\expandafter{\the\parshapespec \z\shortsize} 
\parshapespec=\expandafter{\the\parshapespec \z\jumphsize}% 
} 
%% 
%%  PAGESHAPE Macros 
%% 
\newcount\linesdone %% tracks \prevgraf for each par 
\newtoks\oldeverypar \oldeverypar={} 
\let\oldparshape=\parshape 
\def\parshape{\prevgraf=0 \linesdone=0 \oldparshape} 
\def\par{{\endgraf \global\linesdone=\prevgraf}} 
\everypar={\the\oldeverypar \prevgraf=\linesdone} 
\def\pageshape{\global\linesdone=0 \oldparshape} 
%%  
%%  
%%  BOXIDENTS: How to use them. 
%%  =========================== 
%%    Any KEYWORD can refer to a box by first saying 
%%    \makeboxident{KEYWORD} (e.g., \makeboxident{Story1}, 
%%    etc.). TWO commands control placing text in the box. 
%%    Start with the \PUTINVBOX{KEYWORD} command.  KEYWORD  
%%    should be the same as in the corresponding  
%%    \makeboxident command.  Follow \PUTINVBOX with 
%%    the text.  Finish up with the \SHUTBOX command (no 
%%    arguments.)  \PUTINVBOX starts by expanding a \partoks 
%%    token list, so commands to control the text can be  
%%    placed in this token (e.g., \partoks={\noindent \hsize 
%%    3.5in \bf \parshape=3 0pt\hsize 0pt.75\hsize  
%%    0pt.5\hsize}).  In these macros, ``a'' refers to the  
%%    lead of an article, and ``b'' refers to the jump. 
%%     
%%    To typeset the material, enter the command 
%%    \printjump{KEYWORD}, e.g.,  
%%    \printjump{Story1}. 
%% 
%%  Redefine NEWBOX so as not to be OUTER. 
%%  WARNING: This is a deviation from Plain.Tex.  If 
%%  this offends you, please read no further.  If it  
%%  doesn't offend you, please beware of possible box 
%%  allocation problems that may arise. 
%% 
%%  See TeXbook, page 346 ff, for discussion of box and 
%%  register allocation. 
%% 
\catcode`\@=11 %% make @ a letter temporarily 
\def\newbox#1{%\alloc@4\box\chardef\insc@unt} 
\global\advance\count14 by1 
\ch@ck4\insc@unt\box% make sure there is still room 
\allocationnumber=\count14 
\global\expandafter\chardef#1=\allocationnumber 
\wlog{\string#1=\string\box\the\allocationnumber}} 
\catcode`\@=12 
%% 
\newtoks\partoks \partoks={}  
%%     
\def\makeboxident#1{\newbox{\csname#1box\endcsname}} 
%%     
\def\putinvbox#1{% 
%% single argument is keyword identifier 
%%  
\gdef\myident{\csname#1box\endcsname}% 
\setbox\myident=\vbox\bgroup \the\partoks  \strut% 
}  %% End of \PUTINVBOX. 
%%     
\def\shutbox{\strut\egroup} %% \SHUTBOX closes box opened 
%%  by \putinvbox. 
%%     
\def\printjump[#1]{%% to print the jump portion of article 
\gdef\myident{\csname#1box\endcsname}%  
\ifpasstwo \def\pageident{\csname#1a\endcsname}\else 
\def\pageident{???} 
{\edef\mywrite{\write\xrefout{\{\csname#1b\endcsname:}}\mywrite} 
{\let\the=0\edef\mywrite{\write\xrefout{\the\pageno:\}}}\mywrite} 
\fi  
\vtop{\hbox to\jumphsize{{\bf#1} {\it from page 
\pageident}\strut\hss}\box\myident}} 
%% 
%% 
%% INPUT, OUTPUT, CROSS_REFERENCE Section. 
%% ======================================= 
%% 
%%    In what follows, we provide the i/o and 
%%    cross-reference machinery for replacing the  
%%    `???' in the `Please see...' and `Continued  
%%    from...' messages.  As before, everything will be 
%%    keyed off the KEYWORD spec. 
%%     
%%     
%%  Temporary redefinition of group symbols so we can 
%%  redefine \{ and \} for use in output. 
%% 
\bgroup 
\catcode`\{=11 \catcode`\}=11 \catcode`\[=1 \catcode`\]=2 
\gdef\{[{] \gdef\}[}]  
\egroup 
%% 
\newread\xrefin \newwrite\xrefout 
\newif\ifpasstwo \passtwofalse 
\openin\xrefin=\jobname.xrf 
\ifeof\xrefin \passtwofalse \else\passtwotrue \fi 
\ifpasstwo  
\immediate\write16{**********************************}% 
\immediate\write16{I AM NOW INSERTING PAGE REFERENCES IN 
YOUR ARTICLES.}% 
\immediate\write16{**********************************}% 
\else  
\immediate\write16{**********************************}% 
\immediate\write16{PLEASE don't forget to typeset this a 
SECOND time!}% 
\immediate\write16{**********************************}%  
\openout\xrefout=\jobname.xrf \fi 
%%     
\newtoks\mytok  
\def\readxreffile{% 
\read\xrefin to\mykey  
\mytok=\mykey  
\ifeof\xrefin \let\next=\relax \else 
\expandafter\parse\the\mytok 
\let\next=\readxreffile \fi \next} 
 
%% 
\def\parse#1: #2:{\def#1{#2}} 
%% 
\ifpasstwo \readxreffile \fi 
 
%%     
\def\cleanup{\closein\xrefin \closeout\xrefout} 
%%     
%%    TESTING the macros. 
%%     
%%     
\font\bigbold=cmbx10 scaled \magstep3  
\def\warbond{\setbox0=\vbox to60.8pt{\bigbold\null\vfil 
\hbox to.25\hsize{\hss BUY\hss}\vfil \hbox to.25\hsize{\hss 
WAR\hss}\vfil \hbox to.25\hsize{\hss 
BONDS!\hss}\vfil}\setbox0=\vbox{\null 
\vskip6pt\hbox{\hskip6pt\box0\hskip6pt}\vskip6pt} 
\setbox0=\vbox{\hrule height3pt\hbox{\vrule 
width3pt\box0\vrule width3pt}\hrule height3pt} \box0}