| 1 |
\def\IDENT{01-016} |
| 2 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 |
% Copyright 1989--2004 by Hunter Goatley. |
| 4 |
% |
| 5 |
% Permission is granted to anyone to use this software for any purpose |
| 6 |
% on any computer system, and to redistribute it freely, subject to the |
| 7 |
% following restrictions: |
| 8 |
% |
| 9 |
% 1. This software is distributed in the hope that it will be useful, |
| 10 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 12 |
% |
| 13 |
% 2. Altered versions must be plainly marked as such, and must not be |
| 14 |
% misrepresented as being the original software. |
| 15 |
% |
| 16 |
% End |
| 17 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 18 |
% |
| 19 |
% File: NEWSLETTER_FORMAT.TEX |
| 20 |
% |
| 21 |
% Abstract: |
| 22 |
% |
| 23 |
% This file defines TeX control sequences required to produce a |
| 24 |
% newsletter. It assumes plain.tex has been loaded. |
| 25 |
% |
| 26 |
% Author: Hunter Goatley |
| 27 |
% E-mail: [email protected] |
| 28 |
% |
| 29 |
% Partially based on examples from _The TeXbook_, by |
| 30 |
% Donald E. Knuth, and various other sources. Virtually |
| 31 |
% all of the macros from other sources have been rewritten |
| 32 |
% or at least modified. |
| 33 |
% |
| 34 |
% Date: June 3, 1989 |
| 35 |
% |
| 36 |
% Modified by: |
| 37 |
% |
| 38 |
% 01-016 Hunter Goatley 22-JAN-2004 09:23 |
| 39 |
% Changed the license for the code to make it truly free. |
| 40 |
% |
| 41 |
% 01-015 Hunter Goatley 28-JAN-2001 15:45 |
| 42 |
% I'm back! Eliminate undesired whitespace in header and |
| 43 |
% footer macros. |
| 44 |
% |
| 45 |
% 01-014 Hunter Goatley 21-AUG-1991 10:47 |
| 46 |
% Rewrote double-quote macros (they work now!). Cleaned up |
| 47 |
% a little bit. Added \slant and \ital. |
| 48 |
% |
| 49 |
% 01-013 Hunter Goatley 25-JAN-1991 08:23 |
| 50 |
% Added \newpage. Added \tt definitions to \*point macros. |
| 51 |
% Fixed problem with \quotee (quotee name was getting split). |
| 52 |
% Added setting of \hyphenpenalty and \emergencystretch to |
| 53 |
% \newspage macro. |
| 54 |
% |
| 55 |
% 01-012 Hunter Goatley 15-JAN-1991 07:03 |
| 56 |
% Added macro \round to help with keeping page & figure heights |
| 57 |
% even. It helps some. Re-worked \beginquote and \endquote. |
| 58 |
% Add \Quote and \quotee. Added \listindent and dimens. |
| 59 |
% Modified \coltitle to include \noindent; changed amount of |
| 60 |
% \vglue. Modified \beginlist and \endlist to check for |
| 61 |
% a \parskip of 0pt; if 0, skip .5\baselineskip. Fixed |
| 62 |
% \centerbox (was \vbox, now \hbox). |
| 63 |
% |
| 64 |
% 01-011 Hunter Goatley 5-JAN-1991 23:40 |
| 65 |
% Changed \ednote macro so that \sl is redefined as \rm, not \ss. |
| 66 |
% Changed \say macro to look like LaTeX's \typeout macro. |
| 67 |
% |
| 68 |
% 01-010 Hunter Goatley 6-OCT-1990 02:55 |
| 69 |
% Commented out \ss calls at end of font macros. |
| 70 |
% Placed newsletter hsize commands in a macro (\newspage) |
| 71 |
% so that NEWTEX can be used like TeX normally is. |
| 72 |
% |
| 73 |
% 01-009 Hunter Goatley 10-MAR-1990 16:05 |
| 74 |
% Added \par to the beginning of definition of \endlist. |
| 75 |
% |
| 76 |
% 01-008 Hunter Goatley 7-DEC-1989 22:07 |
| 77 |
% Added \farright (place hbox flush right or on next line if it |
| 78 |
% won't fit). Modified definition of \eoa to call \farright. |
| 79 |
% Added \pmb -- "poor man's bold." Added font cmssxb. Added |
| 80 |
% \eldots and \edots. |
| 81 |
% |
| 82 |
% 01-007 Hunter Goatley 1-OCT-1989 03:41 |
| 83 |
% Added figure support for multiple column environment. |
| 84 |
% Added \centerbox. |
| 85 |
% |
| 86 |
% 01-006 Hunter Goatley 17-AUG-1989 10:11 |
| 87 |
% Modified so that "@" is an active character throughout the |
| 88 |
% format file. Added new header/footer commands that are more |
| 89 |
% flexible. Improved appearance of shadow box created by |
| 90 |
% \leftshadowbox. |
| 91 |
% |
| 92 |
% 01-005 Hunter Goatley 10-AUG-1989 22:09 |
| 93 |
% Modified \onepageout output routine so that it does not |
| 94 |
% disable interline skip (commented out \offinterlineskip). |
| 95 |
% This was causing the header and footer to appear flush |
| 96 |
% with the main body of text on the page. Added routine |
| 97 |
% \checkdqbalsub. Modified \include to automatically call |
| 98 |
% \checkdqbalsub after the file has been read in. |
| 99 |
% |
| 100 |
% 01-004 Hunter Goatley 30-JUL-1989 03:10 |
| 101 |
% Added macros to handle font size changes. Added code to |
| 102 |
% let " be used. |
| 103 |
% |
| 104 |
% 01-003 Hunter Goatley 29-JUL-1989 19:26 |
| 105 |
% Modified double column routines so that the number of columns |
| 106 |
% can be specified. The routines now work for 2 to 6 columns |
| 107 |
% of output. |
| 108 |
% |
| 109 |
% 01-002 Hunter Goatley 23-JUL-1989 22:21 |
| 110 |
% Added more comments. Fixed double column routines so that |
| 111 |
% page sizes are handled properly. |
| 112 |
% |
| 113 |
% 01-001 Hunter Goatley 2-JUL-1989 21:28 |
| 114 |
% Added macros to handle bibliographies. |
| 115 |
% |
| 116 |
% 01-000 Hunter Goatley 3-JUN-1989 14:56 |
| 117 |
% Original version. |
| 118 |
% |
| 119 |
|
| 120 |
\def\say#1{{\let\protect\string\immediate\write10{#1}}} |
| 121 |
|
| 122 |
\say{TeX Input file for Newsletter format - version \IDENT} |
| 123 |
\say{Copyright 1989-2004, Hunter Goatley} |
| 124 |
|
| 125 |
\everyjob{\say{TeX Newsletter version \IDENT. Copyright 1989-2004, Hunter Goatley}} |
| 126 |
|
| 127 |
% |
| 128 |
% The \catcode command below lets us use "@" as a letter. It can therefore |
| 129 |
% be used in command and variable names. PLAIN TeX uses this to avoid |
| 130 |
% conflicts with user code, so we'll do it, too. |
| 131 |
% |
| 132 |
\catcode`@=11 % borrow the private macros of PLAIN (with care) |
| 133 |
|
| 134 |
\say{Loading fonts...} |
| 135 |
% |
| 136 |
% Load fonts and define commands to switch between fonts |
| 137 |
% |
| 138 |
\font\twelverm=cmr12 \font\tenrm=cmr10 \font\ninerm=cmr9 \font\eightrm=cmr8 |
| 139 |
\font\twelvei=cmmi12 \font\teni=cmmi10 \font\ninei=cmmi9 \font\eighti=cmmi8 |
| 140 |
%\font\twelvesy=cmsy12 \font\tensy=cmsy10 \font\ninesy=cmsy9 \font\eightsy=cmsy8 |
| 141 |
\font\twelvebf=cmbx12 \font\tenbf=cmbx10 \font\ninebf=cmbx9 \font\eightbf=cmbx8 |
| 142 |
\font\twelvett=cmtt12 \font\tentt=cmtt10 \font\ninett=cmtt9 \font\eighttt=cmtt8 |
| 143 |
\font\twelveit=cmti12 \font\tenit=cmti10 \font\nineit=cmti9 \font\eightit=cmti8 |
| 144 |
\font\twelvesl=cmsl12 \font\tensl=cmsl10 \font\ninesl=cmsl9 \font\eightsl=cmsl8 |
| 145 |
\font\twelvess=cmss12 \font\tenss=cmss10 \font\niness=cmss9 \font\eightss=cmss8 |
| 146 |
\font\twelvessi=cmssi12 \font\tenssi=cmssi10 \font\ninessi=cmssi9 |
| 147 |
\font\eightssi=cmssi8 \font\tenssb=cmssbx10 |
| 148 |
% |
| 149 |
% 11-point font is scaled 10pt |
| 150 |
% |
| 151 |
\font\elevenrm=cmr10 scaled\magstephalf |
| 152 |
\font\eleveni=cmmi10 scaled\magstephalf |
| 153 |
\font\elevenbf=cmbx10 scaled\magstephalf |
| 154 |
\font\eleventt=cmtt10 scaled\magstephalf |
| 155 |
\font\elevenit=cmti10 scaled\magstephalf |
| 156 |
\font\elevensl=cmsl10 scaled\magstephalf |
| 157 |
\font\elevenss=cmss10 scaled\magstephalf |
| 158 |
\font\elevenssi=cmssi10 scaled\magstephalf |
| 159 |
|
| 160 |
\font\seventeenrm=cmr17 \font\seventeenss=cmss17 \font\seventeenssi=cmssi17 |
| 161 |
|
| 162 |
\def\seventeenpoint{% |
| 163 |
\def\sl{\seventeenssi}\def\it{\seventeenssi}\def\bf{\seventeenss}% |
| 164 |
\def\rm{\seventeenrm}\def\ss{\seventeenss}\def\ssi{\seventeenssi}% |
| 165 |
\baselineskip=19pt% % Change baselineskip |
| 166 |
\rm% % By default, use sans serif |
| 167 |
} |
| 168 |
\def\twelvepoint{% |
| 169 |
\def\sl{\twelvesl}\def\it{\twelveit}\def\bf{\twelvebf}% |
| 170 |
\def\rm{\twelverm\let\sl=\twelvesl}\def\ss{\twelvess\let\sl=\ssi}% |
| 171 |
\def\ssi{\twelvessi}\def\tt{\twelvett}% |
| 172 |
\baselineskip=14pt% % Change baselineskip |
| 173 |
\rm% % By default, use sans serif |
| 174 |
} |
| 175 |
\def\elevenpoint{% |
| 176 |
\def\sl{\elevensl}\def\it{\elevenit}\def\bf{\elevenbf}% |
| 177 |
\def\rm{\elevenrm\let\sl=\elevensl}\def\ss{\elevenss\let\sl=\ssi}% |
| 178 |
\def\ssi{\elevenssi}% |
| 179 |
\def\tt{\eleventt}% |
| 180 |
\baselineskip=13pt% % Change baselineskip |
| 181 |
\rm% % By default, use sans serif |
| 182 |
} |
| 183 |
\def\tenpoint{% |
| 184 |
\def\sl{\tensl}\def\it{\tenit}\def\bf{\tenbf}% |
| 185 |
\def\ssb{\tenssb}% |
| 186 |
\def\rm{\tenrm\let\sl=\tensl}\def\ss{\tenss\let\sl=\ssi}% |
| 187 |
\def\ssi{\tenssi}% |
| 188 |
\def\tt{\tentt}% |
| 189 |
\baselineskip=12pt% % Change baselineskip |
| 190 |
\rm% % By default, use sans serif |
| 191 |
} |
| 192 |
\def\ninepoint{% |
| 193 |
\def\sl{\ninesl}\def\it{\nineit}\def\bf{\ninebf}% |
| 194 |
\def\rm{\ninerm\let\sl=\ninesl}\def\ss{\niness\let\sl=\ssi}% |
| 195 |
\def\ssi{\ninessi}% |
| 196 |
\def\tt{\ninett}% |
| 197 |
\baselineskip=11pt% % Change baselineskip |
| 198 |
\rm% % By default, use sans serif |
| 199 |
} |
| 200 |
\def\eightpoint{% |
| 201 |
\def\sl{\eightsl}\def\it{\eightit}\def\bf{\eightbf}% |
| 202 |
\def\rm{\eightrm\let\sl=\eightsl}\def\ss{\eightss\let\sl=\ssi}% |
| 203 |
\def\ssi{\eightssi}% |
| 204 |
\def\tt{\eighttt}% |
| 205 |
\baselineskip=10pt% % Change baselineskip |
| 206 |
\rm% % By default, use sans serif |
| 207 |
} |
| 208 |
|
| 209 |
\font\HUGE=cmr17 %scaled\magstep2 |
| 210 |
\font\verysmallrm=cmr5 % Used to make small copyright "C" |
| 211 |
\font\smallsy=cmsy7 % Used to make small copyright circle |
| 212 |
\def\tiny{\eightpoint\ss} % Equate \tiny to \eightpoint |
| 213 |
\let\em=\eightssi |
| 214 |
\font\quotefont=cmss12 at 14.4truept % Quotation font |
| 215 |
\font\quoteefont=cmcsc10 % Font for quotee |
| 216 |
|
| 217 |
\say{Defining macros...} |
| 218 |
|
| 219 |
\newdimen\normalhsize % Create a new dimension |
| 220 |
\newdimen\normalvsize % Create a new dimension |
| 221 |
|
| 222 |
\normalhsize=\hsize |
| 223 |
|
| 224 |
% |
| 225 |
% \newspage |
| 226 |
% |
| 227 |
% Set up the page for a newsletter (7" by 9" of text, higher tolerance). |
| 228 |
% |
| 229 |
\def\newspage{% |
| 230 |
\global\topskip=0pt % Set 1 inch top margin |
| 231 |
\global\hoffset=-.25 true in % Move output .25 in to the left |
| 232 |
\global\pretolerance=1000 % Set tolerance up (before hyphenation) |
| 233 |
\global\tolerance=1500 % ... (after hyphenation) |
| 234 |
\global\hyphenpenalty=500 % Discourage hyphenation |
| 235 |
\global\emergencystretch=30pt |
| 236 |
\global\normalhsize=7in |
| 237 |
\global\hsize=\normalhsize % Pages are 7 inches wide |
| 238 |
\global\vsize=9in % ... and 9 inches tall |
| 239 |
\global\abovedisplayskip=\baselineskip |
| 240 |
\global\belowdisplayskip=\baselineskip |
| 241 |
\global\pagewidth=\hsize |
| 242 |
\global\pageheight=\vsize |
| 243 |
} |
| 244 |
|
| 245 |
\clubpenalty=500 %-1000 % Set penalties for club and widow lines |
| 246 |
\widowpenalty=1000 % ... |
| 247 |
|
| 248 |
% |
| 249 |
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 250 |
% Multiple Column Output |
| 251 |
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 252 |
% |
| 253 |
% Define macros to handle multiple column output |
| 254 |
% |
| 255 |
% These macros support figures, but the figures must be defined inside |
| 256 |
% the multiple-column environment. Each column can have up to 3 figures |
| 257 |
% of varying sizes; the figures are referred to as "top", "middle", and |
| 258 |
% "bottom". Figures are identified via page number, column number, and |
| 259 |
% the position. In addition, two special figures that span all columns |
| 260 |
% can be specified using column 0 with "top" and "bottom". |
| 261 |
% |
| 262 |
% For example, {3}{2}{middle} refers to the middle figure in column 2 |
| 263 |
% of output page 3. |
| 264 |
% |
| 265 |
% The figures are stored as temporary inserts (the inserts are freed |
| 266 |
% after \endcolumns). The inserts are treated as an array whose first |
| 267 |
% entry is \c@lfigstart. |
| 268 |
% |
| 269 |
% Note: column figures are not handled on the last page of column output. |
| 270 |
% \balancecolumns does not understand how to deal with them. |
| 271 |
% |
| 272 |
% While in X column mode, the text is arranged as one column |
| 273 |
% \columnwidth wide and \pageheight*X tall. This narrow column is |
| 274 |
% then split into X boxes of equal height. |
| 275 |
% |
| 276 |
%*************************************** |
| 277 |
% |
| 278 |
% Allocate a bunch of dimens, boxes, and counts for use in multiple-column |
| 279 |
% macros. |
| 280 |
% |
| 281 |
\newdimen\columnwidth % Width of a column |
| 282 |
\newdimen\columnseprule % Width of rule between columns |
| 283 |
\newdimen\columnsep % Width of whitespace between columns |
| 284 |
\newdimen\pagewidth % Total width of page |
| 285 |
\newdimen\pageheight % Total height of page |
| 286 |
\newdimen\pageheightkeep % Total height of page |
| 287 |
\newdimen\ruleht % Height of \hrules |
| 288 |
\newif\ifcolfigs % Create a new \if (true if figures) |
| 289 |
\newbox\partialpage % Box to hold partial page before cols. |
| 290 |
\newbox\partialpagetop % Box to hold figure for top of page |
| 291 |
\newbox\partialpagebottom % Box to hold figure for bottom of page |
| 292 |
\newcount\mulc@lbegin % Allocate a counter |
| 293 |
\newcount\mulc@lpart % Allocate a counter |
| 294 |
\newcount\numberofcols % Number of columns |
| 295 |
\newcount\c@lpageno % Current page # for column environment |
| 296 |
\newcount\maxcolfigs % Maximum # of figures |
| 297 |
\newcount\c@lfigstart % Starting array slot # for inserts |
| 298 |
\newcount\c@lslot % Work counter to hold current slot # |
| 299 |
\newcount\maxfigp@ges % Maximum # of pages of column output |
| 300 |
\newcount\figsperp@ge % Number of figures on each page |
| 301 |
% |
| 302 |
% Allocate multi-column work counters and dimens. |
| 303 |
% |
| 304 |
\newdimen\tmp@ % Dimen used to calculate pageheights, etc. |
| 305 |
\newdimen\tmp@one % Dimen used to calculate pageheights, etc. |
| 306 |
\newcount\tmp@two % Usually # of cols * 2 |
| 307 |
\newcount\tmp@three |
| 308 |
\newcount\tmp@four |
| 309 |
\newcount\tmp@five |
| 310 |
\newcount\tmp@six |
| 311 |
\newcount\tmp@seven |
| 312 |
\newdimen\rtmp@ % Dimen used in rounding |
| 313 |
% |
| 314 |
% Initialize the \column* dimens. If \columnwidth is still 0pt when |
| 315 |
% \begincolumns is called, the correct \columnwidth will be |
| 316 |
% calculated from the current \hsize. This lets the user set a column |
| 317 |
% width, without requiring that it be done. |
| 318 |
% |
| 319 |
\columnsep=20pt % Space between columns |
| 320 |
\columnseprule=.4pt % Width of rule between columns |
| 321 |
\columnwidth=0pt % Initialize columnwidth to 0pt |
| 322 |
% |
| 323 |
% Initialize pagewidth, pageheight, and ruleht |
| 324 |
% |
| 325 |
\pagewidth=\hsize \pageheight=\vsize \ruleht=.5pt |
| 326 |
% |
| 327 |
% Define constant values used to indicate type of figure stored in |
| 328 |
% figure boxes. Probably inefficient to store them as macros, but it's |
| 329 |
% easier that way (and they're not hardcoded in the macros below). |
| 330 |
% |
| 331 |
\def\TopFig@{500} % Figure is at top of page |
| 332 |
\def\BotFig@{600} % Figure is at bottom of page |
| 333 |
\def\RegFig@{321} % Figure is a corner figure |
| 334 |
\def\topc@lpos{1} % The top figure position (1) |
| 335 |
\def\middlec@lpos{2} % The middle figure position (2) |
| 336 |
\def\bottomc@lpos{3} % The bottom figure position (3) |
| 337 |
|
| 338 |
% |
| 339 |
% Macro \onepageout |
| 340 |
% |
| 341 |
% Output routine used to actually shipout pages to the DVI file. |
| 342 |
% |
| 343 |
\def\onepageout#1{\shipout\vbox{ % here we define one page of output |
| 344 |
{\hsize=\pagewidth\makeheadline} % Do normal width headline |
| 345 |
%\offinterlineskip % butt the boxes together |
| 346 |
\vbox to \pageheightkeep{ % Create a vbox big enough |
| 347 |
\boxmaxdepth=\maxdepth % Set boxmaxdepth |
| 348 |
#1 % Now insert the information |
| 349 |
} % \vbox to \pageheight |
| 350 |
{\hsize=\pagewidth\makefootline} % Do normal width footline |
| 351 |
} % End of \vbox |
| 352 |
\advancepageno % Advance current page number |
| 353 |
} % End of \def\onepageout |
| 354 |
|
| 355 |
%\output{\onepageout{\unvbox255}} % Send out any current output |
| 356 |
|
| 357 |
% |
| 358 |
% When \begincolumns is called: |
| 359 |
% |
| 360 |
% \output is set to perform the following functions: |
| 361 |
% Store the current vbox in the partialpage box (with some vskip) |
| 362 |
% Eject the page (executing \output - page is not really ejected) |
| 363 |
% Set new definition of output: |
| 364 |
% Call \multiplecolumnout to output the columns |
| 365 |
% Set \hsize = \columnwidth |
| 366 |
% Set \vsize = (\pageheight * X) - (\ht\partialpage * X) --- each column will |
| 367 |
% now be just as tall as the space below \partialpage |
| 368 |
% |
| 369 |
% Sometimes the first \output was executed twice in a row, which caused the |
| 370 |
% first \partialpage to be lost. The code below includes a counter that is |
| 371 |
% used to determine if the output routine is called a second time. If it |
| 372 |
% is, the routine ships the previously stored partial page and then creates |
| 373 |
% a new \partialpage. |
| 374 |
% |
| 375 |
% Originally, \begincolumns set \vsize = X * \pageheight (it did not |
| 376 |
% take the height of the \partialpage into account). If the complete text |
| 377 |
% would fit in the full \vsize, the balancing routine would have problems |
| 378 |
% balancing and you'd end up with lots of whitespace on a page and the |
| 379 |
% multiple columns would show up on the next page. Make sense? If not, |
| 380 |
% just trust me; it caused problems. |
| 381 |
% |
| 382 |
% The solution to the problem was to set |
| 383 |
% |
| 384 |
% \vsize = (\pageheight * X) - (\ht\partialpage * X) |
| 385 |
% |
| 386 |
% and then set \vsize back to (X*\pageheight) after the first page had been |
| 387 |
% ejected. This worked fine and dandy except for the fact that grouping was |
| 388 |
% causing the changes to not hold. The solution (and it is a little |
| 389 |
% dangerous) was to use \global\vsize so that the \vsize changes were never |
| 390 |
% local to the group. \endcolumns then resets \vsize = \pageheight. |
| 391 |
% Again, trust me; it seems to work OK. |
| 392 |
% |
| 393 |
\def\begincolumns#1{ |
| 394 |
\ifnum#1<2 \errmessage{Invalid number of columns -- #1; must be 1 < X < 7}\fi |
| 395 |
\ifnum#1>6 \errmessage{Invalid number of columns -- #1; must be 1 < X < 7}\fi |
| 396 |
\begingroup % Begin a new group |
| 397 |
\global\mulc@lbegin=1 % Set "first time" output counter |
| 398 |
\global\mulc@lpart=1 % Set "first time" outputting dbl cols. |
| 399 |
\global\pageheightkeep=\vsize % Initialize \pageheight |
| 400 |
\global\pageheight=\vsize % Initialize \pageheight |
| 401 |
\round{\pageheight}{\baselineskip}{<} % Round the pageheight down |
| 402 |
\global\pagewidth=\hsize % Initialize \pagewidth |
| 403 |
\global\tmp@two=#1 \global\advance\tmp@two by-1 |
| 404 |
\global\numberofcols=#1 % Initialize number of columns |
| 405 |
% Calculate column width unless user set a value |
| 406 |
\ifdim\columnwidth=0pt % If user did not set \columnwidth |
| 407 |
\columnwidth=\hsize % Set columnwidth = normal page width |
| 408 |
\tmp@=-\columnsep % Copy neg. amount of columnsep to tmp@ |
| 409 |
\multiply\tmp@ by\tmp@two % Multiply by X (total amount of colsep) |
| 410 |
\advance\columnwidth by\tmp@ % Subtract width space between columns |
| 411 |
\divide\columnwidth by\numberofcols % Divide by X to get X column output |
| 412 |
\fi % End of \columnwidth calculation |
| 413 |
\output={ |
| 414 |
\ifnum\mulc@lbegin=1 % 1st time through? |
| 415 |
\global\setbox\partialpage=\vbox{\unvbox255\bigskip} % Store partial |
| 416 |
\global\mulc@lbegin=2 % Increment counter |
| 417 |
\else % 2nd time through... |
| 418 |
\onepageout{\vbox{\unvbox\partialpage}} % Ship previous partial |
| 419 |
\global\setbox\partialpage=\vbox{\unvbox255\bigskip} % Make a new |
| 420 |
\fi % ... partial |
| 421 |
}\eject % Force the output routine to execute |
| 422 |
\output={\multiplecolumnout} % Output X columns |
| 423 |
\hsize=\columnwidth % Set hsize = col. width |
| 424 |
% Set \vsize = (\pageheight * X) - (\ht\partialpage * X) |
| 425 |
\global\vsize=\pageheight % Set \vsize=X*\pageht |
| 426 |
\global\multiply\vsize by\numberofcols % Multiply by X |
| 427 |
\tmp@=-\ht\partialpage \multiply\tmp@ by\numberofcols % Subtract (height of |
| 428 |
\global\advance\vsize by\tmp@ % ... partial page * X) |
| 429 |
\round{\vsize}{\baselineskip}{>} % Round it up |
| 430 |
} % End of \begincolumns |
| 431 |
|
| 432 |
% |
| 433 |
% \endcolumns performs the following functions: |
| 434 |
% |
| 435 |
% Sets \output to call \balancecolumns |
| 436 |
% \vfills page and ejects it |
| 437 |
% Terminates the group |
| 438 |
% Resets vsize to original size |
| 439 |
% Resets pagegoal = to original \vsize |
| 440 |
% Skips parskip vertical space |
| 441 |
% Signals that this is a good place for a break, if necessary |
| 442 |
% |
| 443 |
\def\endcolumns{\output={\balancecolumns} \eject |
| 444 |
\endgroup \global\vsize=\pageheightkeep \pagegoal=\vsize \bigskip \goodbreak} |
| 445 |
% |
| 446 |
% \multiplecolumnout |
| 447 |
% |
| 448 |
% Sets splittopskip = topskip |
| 449 |
% Sets splitmaxdepth = maxdepth |
| 450 |
% Sets TeX register \dimen@ = to height of the page |
| 451 |
% Subtracts the height of the partial page from \dimen@ |
| 452 |
% Subtracts the heights of the top & bottom figures from \dimen@ |
| 453 |
% Splits up the current output box into X boxes of size \dimen@, handling |
| 454 |
% figures, if present |
| 455 |
% Calls \onepageout to dump the new boxes |
| 456 |
% Resets \vsize = (X * \pageheight) if first time through macro |
| 457 |
% Frees up current output vbox (255) |
| 458 |
% |
| 459 |
\def\multiplecolumnout{\splittopskip=\topskip \splitmaxdepth=\maxdepth |
| 460 |
\dimen@=\pageheight \advance\dimen@ by-\ht\partialpage |
| 461 |
\advance\dimen@ by-\ht\partialpagetop % Subtract height of top figure |
| 462 |
\advance\dimen@ by-\ht\partialpagebottom % Subtract height of bottom fig. |
| 463 |
\tmp@four=\numberofcols \multiply\tmp@four by2 % Calculate upper box # |
| 464 |
\tmp@five=0 % Start boxes with box 0 |
| 465 |
\ifcolfigs % Are there figures defined? |
| 466 |
\splitfigc@ls % Yes - go handle text & figures |
| 467 |
\else % No - split \box255 into X cols |
| 468 |
% |
| 469 |
% Split box255 into a box of dimen@ height. Loop until X boxes created. |
| 470 |
% |
| 471 |
{\loop |
| 472 |
\global\setbox\tmp@five=\vsplit255 to\dimen@ \advance\tmp@five by2 |
| 473 |
\ifnum\tmp@five<\tmp@four \repeat} % Loop if not done |
| 474 |
\fi % \ifcolfigs |
| 475 |
\onepageout\pagesofar % Send this page to DVI file |
| 476 |
\ifnum\mulc@lpart=1 % Does vsize need to be reset? |
| 477 |
\global\mulc@lpart=2 % Yes - change counter |
| 478 |
\global\vsize=\pageheight % Set \vsize = X * \pageheight |
| 479 |
\global\multiply\vsize by\numberofcols % ... |
| 480 |
\fi % ... |
| 481 |
\ifcolfigs % If figures defined... |
| 482 |
\global\advance\c@lpageno by\@ne % Bump column output page no. |
| 483 |
\handlefigures % Handle next page's figures |
| 484 |
\fi % \ifcolfigs |
| 485 |
\unvbox255 \penalty\outputpenalty % Free current output vbox |
| 486 |
} % End of \multiplcolumnout |
| 487 |
|
| 488 |
% |
| 489 |
% \splitfigc@ls |
| 490 |
% |
| 491 |
% This macro splits \box255 into X columns, handling the figures. |
| 492 |
% |
| 493 |
% Get figure array slot number for figure 1, column 1 on current page |
| 494 |
% Loop for each column (starting with column in \tmp@five) |
| 495 |
% Make a copy of \dimen@ -> \tmp@ |
| 496 |
% If a figure is defined for top of column |
| 497 |
% Decrease \tmp@ by the height of the figure |
| 498 |
% Set box 1 = the figure |
| 499 |
% Else |
| 500 |
% Set box 1 = null vbox |
| 501 |
% Bump figure array slot number - now points to slot for middle figure |
| 502 |
% If a figure is defined for middle of column |
| 503 |
% Decrease \tmp@ by the height of the figure |
| 504 |
% Set box 5 = the figure |
| 505 |
% Else |
| 506 |
% Set box 5 = null vbox |
| 507 |
% Bump figure array slot number - now points to slot for bottom figure |
| 508 |
% If a figure is defined for bottom of column |
| 509 |
% Decrease \tmp@ by the height of the figure |
| 510 |
% Set box 9 = the figure |
| 511 |
% Else |
| 512 |
% Set box 9 = null vbox |
| 513 |
% Bump figure array slot number - now points to slot for next top figure |
| 514 |
% Split \box255 into 1 or 2 pieces (2 if there is a middle figure) |
| 515 |
% Set \box\tmp@five = \box1 + \box3 + \box5 + \box7 + \box9 |
| 516 |
% Advance \tmp@five by 2 and loop until X "columns" created |
| 517 |
% |
| 518 |
\def\splitfigc@ls{ |
| 519 |
% |
| 520 |
% Split box255 into a box of dimen@ height. Loop until X boxes created. |
| 521 |
% |
| 522 |
\tmp@two=1 % Figure counter |
| 523 |
\calcc@lslot{\c@lpageno}{1}{\tmp@two} % Get slot for figure 2 on current page |
| 524 |
{\loop % Start loop |
| 525 |
\tmp@=\dimen@ % Make a working copy of dimen@ |
| 526 |
% |
| 527 |
% Handle top figure |
| 528 |
% |
| 529 |
\ifnum\count\c@lslot=\RegFig@ % If this slot holds a single-column fig |
| 530 |
\advance\tmp@ by-\ht\c@lslot % Subtract figure's height from \tmp@ |
| 531 |
\setbox1=\vbox{\unvbox\c@lslot} % Copy figure to \box1 |
| 532 |
\say{Figure \the\tmp@two\space on page \the\c@lpageno, document page \folio} |
| 533 |
\else \setbox1=\vbox{} % Else set box 1 = null page |
| 534 |
\fi % \ifnum |
| 535 |
% |
| 536 |
% Handle middle figure |
| 537 |
% |
| 538 |
\advance\c@lslot by\@ne % Point to next figure |
| 539 |
\advance\tmp@two by\@ne % Advance figure counter |
| 540 |
\ifnum\count\c@lslot=\RegFig@ % If this slot holds a single-column fig |
| 541 |
\advance\tmp@ by-\ht\c@lslot % Subtract figure's height from \tmp@ |
| 542 |
\setbox5=\vbox{\unvbox\c@lslot} % Copy figure to \box3 |
| 543 |
\say{Figure \the\tmp@two\space on page \the\c@lpageno, document page \folio} |
| 544 |
\else \setbox5=\vbox{} % Else set box 3 = null page |
| 545 |
\fi % \ifnum |
| 546 |
% |
| 547 |
% Handle bottom figure |
| 548 |
% |
| 549 |
\advance\c@lslot by\@ne % Point to next figure |
| 550 |
\advance\tmp@two by\@ne % Advance figure counter |
| 551 |
\ifnum\count\c@lslot=\RegFig@ % If this slot holds a single-column fig |
| 552 |
\advance\tmp@ by-\ht\c@lslot % Subtract figure's height from \tmp@ |
| 553 |
\setbox9=\vbox{\unvbox\c@lslot} % Copy figure to \box3 |
| 554 |
\say{Figure \the\tmp@two\space on page \the\c@lpageno, document page \folio} |
| 555 |
\else \setbox9=\vbox{} % Else set box 3 = null page |
| 556 |
\fi % \ifnum |
| 557 |
\advance\c@lslot by\@ne % Point to next figure in array |
| 558 |
\advance\tmp@two by\@ne % Advance figure counter |
| 559 |
% |
| 560 |
% Here, top figure is in \box1, middle figure is in \box5, and bottom |
| 561 |
% figure is in \box9. |
| 562 |
% Split \box255 to fill the remaining column space, splitting in |
| 563 |
% half if there is a middle figure. |
| 564 |
% Special case: if height of \box1 = \pageheight, \box\tmp@five=null |
| 565 |
% |
| 566 |
\ifdim\ht1=\pageheight % Is top = whole column? |
| 567 |
\global\setbox3=\vbox{} % Yes - set \box3 to null |
| 568 |
\global\setbox7=\vbox{} % Yes - set \box7 to null |
| 569 |
\else % No - go ahead and do split |
| 570 |
\ifdim\ht5>0pt % Is there a middle figure? |
| 571 |
\divide\tmp@ by2 % Yes - break text to 2 pieces |
| 572 |
\global\setbox3=\vsplit255 to\tmp@ % Set \box3 = 1st piece |
| 573 |
\global\setbox7=\vsplit255 to\tmp@ % Set \box7 = 2nd piece |
| 574 |
\else % No middle column... |
| 575 |
\global\setbox3=\vsplit255 to\tmp@ % Put all text in \box3 |
| 576 |
\global\setbox7=\vbox{} % Set \box7 to null |
| 577 |
\fi % \ifdim\ht5... |
| 578 |
\fi % \ifdim |
| 579 |
% |
| 580 |
% Now put the 5 pieces together as one vbox in \box\tmp@five |
| 581 |
% |
| 582 |
\global\setbox\tmp@five=\vbox to\dimen@{\offinterlineskip% |
| 583 |
\ifdim\ht1=0pt\else\vbox{\unvbox1}\fi |
| 584 |
\ifdim\ht3=0pt\else\vbox{\unvbox3}\fi |
| 585 |
\ifdim\ht5=0pt\else\vbox{\unvbox5}\fi |
| 586 |
\ifdim\ht7=0pt\else\vbox{\unvbox7}\fi |
| 587 |
\ifdim\ht9=0pt\else\vbox{\unvbox9}\fi |
| 588 |
\vfil\vfilneg % Cancels spurious vglue ???? (it works) |
| 589 |
} |
| 590 |
\advance\tmp@five by2 % Bump column box # |
| 591 |
\ifnum\tmp@five<\tmp@four \repeat} % Loop if not done |
| 592 |
} % End of \splitc@lfigs |
| 593 |
|
| 594 |
% |
| 595 |
% \pagesofar |
| 596 |
% |
| 597 |
% Releases \partialpage box |
| 598 |
% Sets width of X boxes (from box 0 to box X) = to \columnwidth |
| 599 |
% Creates an hbox = pagewidth that consists of box0 + separator rule + box 2 |
| 600 |
% + separator rule + box X |
| 601 |
% This new hbox is \box255 and can be used to \shipout |
| 602 |
% |
| 603 |
\def\pagesofar{\unvbox\partialpage |
| 604 |
\unvbox\partialpagetop % Include top figure |
| 605 |
\tmp@four=\numberofcols \multiply\tmp@four by2 % Loop boundary number |
| 606 |
\tmp@five=0 % Start with box 0 |
| 607 |
% |
| 608 |
% For each box, set the width equal to the column width |
| 609 |
% |
| 610 |
{\loop \wd\tmp@five=\columnwidth \advance\tmp@five by2 |
| 611 |
\ifnum\tmp@five<\tmp@four \repeat} % Loop until X done |
| 612 |
% |
| 613 |
% Now put all the boxes together like this: |
| 614 |
% |
| 615 |
% box | box | ... | box |
| 616 |
% |
| 617 |
\tmp@five=0 % Start with box 0 again |
| 618 |
\hbox to\pagewidth{\box\tmp@five\advance\tmp@five by2% Do the left column |
| 619 |
\loop \hfil\vrule width\columnseprule \hfil \box\tmp@five% |
| 620 |
\advance\tmp@five by2 % Bump box counter |
| 621 |
\ifnum\tmp@five<\tmp@four \repeat % Loop if not done |
| 622 |
} % End of hbox |
| 623 |
\unvbox\partialpagebottom % Include bottom figure |
| 624 |
} % End of \pagesofar |
| 625 |
|
| 626 |
% |
| 627 |
% \balancecolumns - Balance both columns at end of X column page |
| 628 |
% |
| 629 |
% Sets box 0 = current page |
| 630 |
% Sets dimen@ = height of the vbox in box 0 |
| 631 |
% Adds topskip value to dimen@ |
| 632 |
% Subtracts X * \baselineskip from dimen@ |
| 633 |
% Divides dimen@ by X -- dimen@ now has target height of each column |
| 634 |
% Sets splittopskip = to topskip so it can be added to all columns |
| 635 |
% Loops |
| 636 |
% Copies box 0 to box 3 |
| 637 |
% Splits box 3 to dimen@ and stores in box 1 & 3 |
| 638 |
% Increments dimen@ by 1pt and loops if column in box 3 exceeds dimen@ |
| 639 |
% Note: Splitting of box is actually implemented as a loop that creates |
| 640 |
% X boxes |
| 641 |
% Moves columns in odd-numbered boxes to corresponding even-numbered boxes |
| 642 |
% Calls pagesofar to make the hbox for it |
| 643 |
% |
| 644 |
\def\balancecolumns{\setbox0=\vbox{\unvbox255} \dimen@=\ht0 |
| 645 |
% |
| 646 |
% Subtract X * \baselineskip from dimen@ and divide dimen@ by X |
| 647 |
% |
| 648 |
\tmp@two=\numberofcols \advance\tmp@two by-1 |
| 649 |
\tmp@=-\baselineskip \multiply\tmp@ by\tmp@two \advance\dimen@ by\tmp@ |
| 650 |
\divide\dimen@ by\numberofcols \splittopskip=\topskip % Dimen@/X |
| 651 |
% |
| 652 |
% Split the column X times so we have X columns of equal height. If our |
| 653 |
% last column is > dimen@, bump dimen@ by one and loop. |
| 654 |
% |
| 655 |
\tmp@four=\numberofcols \multiply\tmp@four by2 % X * 2 |
| 656 |
\tmp@seven=\tmp@four \advance\tmp@seven by-1 % Work box: (X*2)-1 |
| 657 |
{\vbadness=10000 \loop \global\setbox\tmp@seven=\copy0 |
| 658 |
\tmp@five=0 \tmp@six=1 % Work box starts with 1 |
| 659 |
{\loop % Loop for X boxes |
| 660 |
\global\setbox\tmp@six=\vsplit\tmp@seven to\dimen@ % Vsplit box |
| 661 |
\advance\tmp@six by2 % Bump box counter |
| 662 |
\ifnum\tmp@six<\tmp@seven \repeat} % Loop if not done |
| 663 |
\ifdim\ht\tmp@seven>\dimen@ \global\advance\dimen@ by1pt \repeat} |
| 664 |
% |
| 665 |
% Here we have X columns of equal height. Note that the last column may |
| 666 |
% not be equal to the others. |
| 667 |
% |
| 668 |
% Copy the columns to the even-numbered boxes in preparation for \pagesofar |
| 669 |
% |
| 670 |
\tmp@five=0 \tmp@six=1 |
| 671 |
{\loop \global\setbox\tmp@five=\vbox to\dimen@{\unvbox\tmp@six} |
| 672 |
\advance\tmp@five by2 \advance\tmp@six by2 |
| 673 |
\ifnum\tmp@five<\tmp@four \repeat} |
| 674 |
\pagesofar} % Call \pagesofar to build page |
| 675 |
% |
| 676 |
% \c@lnewinsert |
| 677 |
% |
| 678 |
% This macro is used to perform a \newinsert for temporary usage (inside a grp) |
| 679 |
% |
| 680 |
\def\c@lnewinsert{\advance\insc@unt by\m@ne % Decrement insert counter |
| 681 |
\ch@ck0\insc@unt\count % Make sure count is available |
| 682 |
\ch@ck1\insc@unt\dimen % Make sure dimen is available |
| 683 |
\ch@ck2\insc@unt\skip % Make sure skip is available |
| 684 |
\ch@ck4\insc@unt\box % Make sure box is available |
| 685 |
% NEED TO EMPTY BOX!!! |
| 686 |
\count\insc@unt=0 % Set the count to 0 |
| 687 |
\allocationnumber=\insc@unt % Set the allocation number |
| 688 |
} % End of \c@lnewinsert |
| 689 |
|
| 690 |
% |
| 691 |
% \definefigs |
| 692 |
% |
| 693 |
% This macro is called to establish the figure environment inside of the |
| 694 |
% multiple-column environment. It allocates (until \endcolumns) an array |
| 695 |
% of inserts (boxes, counts, dimens, and skips) to handle all of the |
| 696 |
% figures per page for the given number of pages. When the figures |
| 697 |
% are defined using \definefig, the proper box is filled with the figure. |
| 698 |
% |
| 699 |
% Inputs: |
| 700 |
% |
| 701 |
% #1 - Number of pages of multiple-column output (should be as large |
| 702 |
% as the total number of pages between \begincolumns and |
| 703 |
% \endcolumns) |
| 704 |
% |
| 705 |
\def\definefigs#1{ |
| 706 |
\colfigstrue % Set column figure flag |
| 707 |
\global\c@lpageno=1 % Get current page number |
| 708 |
\maxfigp@ges=#1 % Set maximum # of pages with figures |
| 709 |
\figsperp@ge=\numberofcols % Calculate # of figures per page |
| 710 |
\multiply\figsperp@ge by3 % Figs/Page = 2 + (3 * number of cols) |
| 711 |
\advance\figsperp@ge by2 % ... |
| 712 |
\maxcolfigs=\maxfigp@ges % Figure out how many inserts are needed |
| 713 |
\multiply\maxcolfigs by\figsperp@ge % ... for all of the figures |
| 714 |
\tmp@two=\maxcolfigs % Start there and work down to first box |
| 715 |
\loop \c@lnewinsert \advance\tmp@two by\m@ne |
| 716 |
\ifnum\tmp@two>0 \repeat |
| 717 |
\c@lfigstart=\insc@unt % Save starting array slot # |
| 718 |
% We've allocated all boxes now |
| 719 |
} % End of \definefigs |
| 720 |
|
| 721 |
% |
| 722 |
% \definefig |
| 723 |
% |
| 724 |
% This macro stores figure information in the appropriate slot in the insert |
| 725 |
% array. After calculating the proper slot number for the figure, it stores |
| 726 |
% the figure in the corresponding box and sets the corresponding \count to |
| 727 |
% a code identifying the box as holding a figure. |
| 728 |
% |
| 729 |
% Inputs: |
| 730 |
% |
| 731 |
% #1 Output page number |
| 732 |
% #2 Column Number |
| 733 |
% #3 Position (top, middle, bottom) |
| 734 |
% #4 The vbox for the figure |
| 735 |
% |
| 736 |
\def\definefig#1#2#3#4{ |
| 737 |
\ifcolfigs % Has \definefigs been called? |
| 738 |
\else |
| 739 |
\errmessage{Illegal use of \string\definefig\space before \string\definefigs} |
| 740 |
\fi % \ifnum |
| 741 |
\ifnum#2>\numberofcols % Illegal column number? |
| 742 |
\errmessage{Column number #2 exceeds number of columns} |
| 743 |
\fi % \ifnum |
| 744 |
\calcc@lslot{#1}{#2}{\csname #3c@lpos\endcsname} % Calculate slot # |
| 745 |
\ifcase\csname #3c@lpos\endcsname |
| 746 |
\or\setbox\c@lslot=\vbox{#4\vskip\belowdisplayskip} |
| 747 |
\or\setbox\c@lslot=\vbox{\vskip\abovedisplayskip#4% |
| 748 |
\vskip\belowdisplayskip} |
| 749 |
\or\setbox\c@lslot=\vbox{\vskip\abovedisplayskip#4} |
| 750 |
\tmp@=\ht\c@lslot % Round up the size |
| 751 |
\round{\tmp@}{\baselineskip}{>} % ... |
| 752 |
\tmp@one=\tmp@ \advance\tmp@one by-\ht\c@lslot |
| 753 |
\setbox\c@lslot=\vbox to\tmp@{\box\c@lslot} |
| 754 |
\fi |
| 755 |
\ifnum#2=0 % If column # is 0, special fig. |
| 756 |
\ifnum\csname #3c@lpos\endcsname=1\count\c@lslot=\TopFig@ |
| 757 |
\else\count\c@lslot=\BotFig@\fi % Top or Bottom figure that |
| 758 |
\else % ... spans all columns |
| 759 |
\count\c@lslot=\RegFig@ % Otherwise, identify the box |
| 760 |
\fi % ... as containing a figure |
| 761 |
\say{Processed #3 figure for column #2\space on page #1\space |
| 762 |
- slot \the\c@lslot} |
| 763 |
\say{The height is \the\ht\c@lslot} |
| 764 |
} |
| 765 |
|
| 766 |
% |
| 767 |
% \calcc@lslot |
| 768 |
% |
| 769 |
% This macro is called to calculate the array slot number for a figure. |
| 770 |
% The formula for normal figures is: |
| 771 |
% |
| 772 |
% ((column# - 1) * 3figs/column) + Position |
| 773 |
% |
| 774 |
% This macro assumes there can be 3 figures per column (top, middle, & bottom) |
| 775 |
% |
| 776 |
% Inputs: |
| 777 |
% |
| 778 |
% #1 - Page number |
| 779 |
% #2 - Column number (0 = special figure that spans all columns) |
| 780 |
% #3 - Figure number (1 = top, 2 = middle, 3 = bottom) |
| 781 |
% |
| 782 |
% Returns: |
| 783 |
% |
| 784 |
% \c@lslot - Slot number for given figure. This slot number |
| 785 |
% identifies the allocated insert for the figure. |
| 786 |
% |
| 787 |
\def\calcc@lslot#1#2#3{ |
| 788 |
\tmp@seven=#1 % Start with page # |
| 789 |
\advance\tmp@seven by\m@ne % (Page - 1) |
| 790 |
\multiply\tmp@seven by\figsperp@ge % (Page - 1) * # of figs |
| 791 |
\ifnum#2=0 % If column is 0, special one |
| 792 |
\ifnum#3=1\tmp@six=1\else\tmp@six=\figsperp@ge\fi |
| 793 |
\advance\tmp@six by\m@ne % Decrement for slot # |
| 794 |
\else |
| 795 |
\tmp@six=#2 % Column # |
| 796 |
\advance\tmp@six by\m@ne % (Column# - 1) |
| 797 |
\multiply\tmp@six by3 % (Column# - 1) * 3 |
| 798 |
\advance\tmp@six by#3 % (Column# - 1) * 3 + Position |
| 799 |
\fi % Really + 1, but -1 negates it |
| 800 |
\advance\tmp@seven by\tmp@six % Add figure # to page # |
| 801 |
\advance\tmp@seven by\c@lfigstart % Figure slot number |
| 802 |
\global\c@lslot=\tmp@seven % Set the slot number |
| 803 |
} % End of \calcc@lslot |
| 804 |
% |
| 805 |
% \handlefigures |
| 806 |
% |
| 807 |
% This macro is called to step through all of the figures for the current |
| 808 |
% page and subtract the height of each from the total \vsize. |
| 809 |
% |
| 810 |
% The two special figures (top (1) and bottom (\figsperp@ge)) are handled |
| 811 |
% differently; because each spans all of the columns on the page, the height |
| 812 |
% of each is multiplied by the number of columns before subtracting it from |
| 813 |
% \vsize. The top figure is then placed in \partialpagetop and the bottom |
| 814 |
% figure is placed in \partialpagebottom. |
| 815 |
% |
| 816 |
% Returns: Adjusted \vsize. |
| 817 |
% |
| 818 |
\def\handlefigures{ |
| 819 |
\global\vsize=\pageheight % \vsize to pageheight |
| 820 |
\global\multiply\vsize by\numberofcols % Multiply by # of columns |
| 821 |
\tmp@three=\figsperp@ge % Start with figure X |
| 822 |
\calcc@lslot{\c@lpageno}{0}{3} % Start with last figure box |
| 823 |
{\loop |
| 824 |
\ifnum\count\c@lslot=\TopFig@ % If box is top section of page |
| 825 |
\global\setbox\partialpagetop=\vbox{\unvbox\c@lslot} % Copy it |
| 826 |
\tmp@=\ht\partialpagetop % Get the height |
| 827 |
\multiply\tmp@ by\numberofcols % Multiply by number of columns |
| 828 |
\global\advance\vsize by-\tmp@ % (vsize - figure size) |
| 829 |
\else % Else |
| 830 |
\ifnum\count\c@lslot=\BotFig@ % If box is bottom section |
| 831 |
\global\setbox\partialpagebottom=\vbox{\unvbox\c@lslot} |
| 832 |
\tmp@=\ht\partialpagebottom |
| 833 |
\multiply\tmp@ by\numberofcols |
| 834 |
\global\advance\vsize by-\tmp@ % (vsize - figure size) |
| 835 |
\else % Else, see if regular figure |
| 836 |
\ifdim\ht\c@lslot>0pt\all@wfigure{\ht\c@lslot}\fi % \vsize |
| 837 |
\fi % End \ifnum |
| 838 |
\fi % End \ifnum |
| 839 |
\advance\tmp@three by\m@ne % Point to next box |
| 840 |
\advance\c@lslot by\m@ne % Point to next box |
| 841 |
\ifnum\tmp@three>0 \repeat} % Loop until done |
| 842 |
} % End of \handlefigures |
| 843 |
|
| 844 |
\def\all@wfigure#1{ |
| 845 |
\tmp@=#1 % Height of figure |
| 846 |
\global\advance\vsize by-\tmp@ % Subtract figure size from vsize |
| 847 |
} |
| 848 |
|
| 849 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 850 |
% Macro: \round#1#2#3 |
| 851 |
% |
| 852 |
% Purpose: Round a dimen parameter (#1) to the nearest even multiple of |
| 853 |
% parameter #2. Primarily used to ensure that the page height |
| 854 |
% or a figure height is an even multiple of the baselineskip. |
| 855 |
% |
| 856 |
% NOTE: this macro assumes there is no stretch or shrink to #2. |
| 857 |
% |
| 858 |
% Inputs: |
| 859 |
% #1 Dimen variable to change (e.g., \pageheight) |
| 860 |
% #2 Dimen variable to use as multiple (e.g., \baselineskip) |
| 861 |
% #3 Symbol indicating round up (>) or round down (<) |
| 862 |
% \tmp@ Work dimen (saved and restored) |
| 863 |
% |
| 864 |
% Example: |
| 865 |
% \pageheight=598.213pt \baselineskip=12pt |
| 866 |
% \round{\pageheight}{\baselineskip}{<} %yields \pageheight=588.0pt |
| 867 |
% \round{\pageheight}{\baselineskip}{>} %yields \pageheight=600.0pt |
| 868 |
% |
| 869 |
\def\round#1#2#3{\bgroup% %Keep \tmp@ changes local |
| 870 |
\rtmp@=0pt %Initialize \tmp@ |
| 871 |
\loop %Begin a loop |
| 872 |
\advance\rtmp@ by #2 %Bump \tmp@ by #2 |
| 873 |
\ifdim#1>\rtmp@ \repeat %Loop until \tmp@ > #1 |
| 874 |
\ifx<#3 %If #3 = "<" then |
| 875 |
\advance\rtmp@ by-#2 %... subtract #2 from \tmp@ |
| 876 |
\fi %... |
| 877 |
\global#1=\rtmp@ %Reset parameter #1 |
| 878 |
\egroup %End the group |
| 879 |
} %End of macro |
| 880 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 881 |
% |
| 882 |
% Define list macros |
| 883 |
% |
| 884 |
% Dimens: |
| 885 |
% |
| 886 |
% \llistindent - Amount of left indent (0pt by default) |
| 887 |
% \rlistindent - Amount of right indent (0pt by default) |
| 888 |
% |
| 889 |
% Macros: |
| 890 |
% |
| 891 |
% \beginlist - Begin list (skips space, sets indent) |
| 892 |
% \endlist - Terminates a list |
| 893 |
% \beginlistt - Begin list with glue (used for list headers) |
| 894 |
% \endlistt - Terminates a \beginlistt |
| 895 |
% \dotitem - Itemize with a dot "o" |
| 896 |
% |
| 897 |
\newdimen\llistindent \llistindent=0pt |
| 898 |
\newdimen\rlistindent \rlistindent=0pt |
| 899 |
\def\listindent#1{\llistindent=#1\rlistindent=#1} |
| 900 |
|
| 901 |
\def\beginlist{\begingroup% |
| 902 |
\ifdim\parskip=0pt \vskip.5\baselineskip % Skip 1/2 line |
| 903 |
\else \vskip\parskip % or the \parskip |
| 904 |
\fi % |
| 905 |
\parindent=10pt\parskip=0pt% % Reset parindent |
| 906 |
\leftskip=\llistindent \rightskip=\rlistindent} % Indent margins |
| 907 |
|
| 908 |
\def\endlist{\par\endgroup% |
| 909 |
\ifdim\parskip=0pt \vskip.5\baselineskip |
| 910 |
\else \vskip\parskip\fi} |
| 911 |
|
| 912 |
\def\dotitem#1\par{\item{$\bullet$} #1 \par} |
| 913 |
|
| 914 |
\def\beginlistt#1{#1\vglue0pt\begingroup% |
| 915 |
\divide\parskip by2\vskip\parskip\parindent=10pt\parskip=0pt% |
| 916 |
\leftskip=\llistindent \rightskip=\rlistindent} |
| 917 |
\def\endlistt{\par\endgroup} %\vskip\parskip} |
| 918 |
|
| 919 |
% |
| 920 |
% Define a small copyright (for use with 8-point type). |
| 921 |
% |
| 922 |
\def\smallcir{\smallsy\char13} |
| 923 |
\def\smallcopyright{\leavevmode\raise.25ex\hbox{ |
| 924 |
\ooalign{\hfil\raise.03ex\hbox{\kern .16em\verysmallrm C} |
| 925 |
\hfil\crcr\smallcir}}} |
| 926 |
|
| 927 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 928 |
% |
| 929 |
% Define macros to manipulate boxes |
| 930 |
% |
| 931 |
% Dimens: |
| 932 |
% |
| 933 |
% \boxitrule=Xpt - Width of rules used to draw boxes |
| 934 |
% \boxitspace=Xpt - Space between box rules and box contents |
| 935 |
% \boxshadowsize=Xpt - Width of shadow boxes |
| 936 |
% |
| 937 |
% Macros: |
| 938 |
% |
| 939 |
% \articletitle{Title}{byline} - Do article title in double box |
| 940 |
% \coltitle{Title} - Do a title box in a column |
| 941 |
% \shadowbox{some_box} - Draw a shadow box around an hbox or vbox |
| 942 |
% \leftshadowbox{somebox} - Draw a left-hand shadow box around a box |
| 943 |
% \centerbox{somebox} - Center a \vbox on a page |
| 944 |
% \boxit{some_box} - Draw a box around an hbox or vbox |
| 945 |
% \ednote - Do editor's note in a box |
| 946 |
% |
| 947 |
\newdimen\boxitspace \newdimen\boxitrule \newdimen\boxitwidth |
| 948 |
\boxitspace=3pt \boxitrule=1.2pt |
| 949 |
\boxitwidth=\boxitspace \advance\boxitwidth by\boxitspace |
| 950 |
\advance\boxitwidth by\boxitrule \advance\boxitwidth by\boxitrule |
| 951 |
|
| 952 |
% |
| 953 |
% Define macro to write an article title inside a double box |
| 954 |
% |
| 955 |
% Parameters: |
| 956 |
% |
| 957 |
% #1 - Title of article |
| 958 |
% #2 - Byline |
| 959 |
% |
| 960 |
% For both \articletitle and \coltitle, the width of the box(es) must be |
| 961 |
% subtracted from the current hsize in order for centering and justification |
| 962 |
% to work right (otherwise the letters will run into the lines of the box). |
| 963 |
% |
| 964 |
\def\articletitle#1#2{ |
| 965 |
\bestbreak{ % Say that this is best break |
| 966 |
\advance\hsize by -\boxitwidth % Bring margin in before \center |
| 967 |
\advance\hsize by -\boxitwidth % Do for both boxes! |
| 968 |
\vskip 10pt plus 5pt % Skip some space |
| 969 |
\boxit{ % Box the box |
| 970 |
\divide\boxitrule by 2 % Make inside box lines thinner |
| 971 |
\boxit{ % Box the text |
| 972 |
\vbox{\noindent % Create a box |
| 973 |
\centerline{\seventeenpoint\ss #1} % Print title of article |
| 974 |
\centerline{\ninepoint\ss #2} % Print article byline |
| 975 |
}}}}} % Create the text box |
| 976 |
|
| 977 |
\def\coltitle#1\par{{% % Swallow next paragraph |
| 978 |
\advance\hsize by -\boxitwidth % Bring margins in |
| 979 |
\boxit{% % Draw a box around the text |
| 980 |
\vbox{\ss\noindent #1}}}% % Create a vbox that contains |
| 981 |
\vglue.5\baselineskip% % Skip some non-breakable space |
| 982 |
\noindent} % Don't indent next paragraph |
| 983 |
|
| 984 |
\def\ednote#1{{ |
| 985 |
\sl % Switch to slanted font |
| 986 |
\def\sl{\/\rm} % Redefine \sl |
| 987 |
\advance\hsize by -\boxitwidth % Bring margins in |
| 988 |
\boxit{ % Draw a box around the text |
| 989 |
\vbox{\noindent Editor's note: #1}}} % Create a vbox that contains |
| 990 |
\vglue 0pt} % Finish it up |
| 991 |
|
| 992 |
\def\boxit#1{\vbox{\tithrule\hbox{\titvrule\kern\boxitspace% |
| 993 |
\vbox{\kern\boxitspace #1 \kern\boxitspace}% |
| 994 |
\kern\boxitspace\titvrule}\tithrule}} |
| 995 |
|
| 996 |
\def\tithrule{\hrule height\boxitrule} |
| 997 |
\def\titvrule{\vrule width\boxitrule} |
| 998 |
|
| 999 |
% |
| 1000 |
% \centerbox |
| 1001 |
% |
| 1002 |
% Create a \vbox that contains a centered \hbox. The centering is relative |
| 1003 |
% to the current \hsize. |
| 1004 |
% |
| 1005 |
% Inputs: |
| 1006 |
% |
| 1007 |
% #1 - \vbox to center -> \centerbox{\shadowbox{...}} |
| 1008 |
% |
| 1009 |
\def\centerbox#1{\hbox{\hfil#1\hfil}} % Create a \vbox containing a centered |
| 1010 |
|
| 1011 |
|
| 1012 |
\newdimen\oboxht \newdimen\oboxwd \newdimen\boxshadowsize |
| 1013 |
\boxshadowsize=4pt % Shadow box size is 4pt |
| 1014 |
% |
| 1015 |
% Draw a righthand shadow box. This is accomplished by building a vbox |
| 1016 |
% containing an hbox that is the boxed text and an hbox that is the right |
| 1017 |
% hand shadow. This vbox is then joined with a vbox that forms |
| 1018 |
% the bottom shadow. |
| 1019 |
% |
| 1020 |
\def\shadowbox#1{{ |
| 1021 |
\setbox0=\vbox{\boxit{#1}} % Set box after \boxit |
| 1022 |
\oboxht=\ht0 \oboxwd=\wd0 % Store the dimensions |
| 1023 |
\advance\oboxwd by-\boxshadowsize % Subtract shadow size from wd |
| 1024 |
\vbox{ % Put it all in one vbox |
| 1025 |
\offinterlineskip % Butt \vboxes together |
| 1026 |
\vbox{ % Create a vbox of whole thing |
| 1027 |
\hbox{\vbox{\unvbox0} % Create box with text box + |
| 1028 |
\hskip-\fontdimen2\font |
| 1029 |
\lower\boxshadowsize % Draw the right-hand boxshadowsize |
| 1030 |
\hbox{\vrule width\boxshadowsize height\oboxht}} % ... Finish off \hbox |
| 1031 |
} % End of the \vbox |
| 1032 |
\advance\boxshadowsize by\boxitrule |
| 1033 |
\vskip-\boxshadowsize % Back up to bottom of \vbox |
| 1034 |
\vbox{ % Start a new \vbox |
| 1035 |
\hbox{\kern\boxshadowsize\vbox{ % Create \hbox that is shadow |
| 1036 |
\hrule height\boxshadowsize width\oboxwd}} % ... |
| 1037 |
} % End of the \vbox |
| 1038 |
} % End of \vbox |
| 1039 |
}} % End of \shadowbox |
| 1040 |
% |
| 1041 |
% Draw a lefthand shadow box. This is accomplished by building a lowered |
| 1042 |
% vbox containing an hbox that is the left hand shadow and an hbox that |
| 1043 |
% contains the boxed text. This vbox is then joined with a vbox that forms |
| 1044 |
% the bottom shadow. |
| 1045 |
% |
| 1046 |
\def\leftshadowbox#1{{ |
| 1047 |
\setbox0=\vbox{\boxit{#1}} % Set box after \boxit |
| 1048 |
\oboxht=\ht0 \oboxwd=\wd0 % Store the dimensions |
| 1049 |
\advance\oboxwd by-\boxshadowsize % Subtract shadow size from wd |
| 1050 |
\vbox{ |
| 1051 |
\offinterlineskip % Butt \vboxes together |
| 1052 |
\vbox{ % Create a vbox of whole thing |
| 1053 |
\hbox{ % Create an hbox |
| 1054 |
\hskip-\fontdimen2\font % Move left one character width |
| 1055 |
\hskip-\boxshadowsize % Move left = size of shadow box |
| 1056 |
\advance\boxitrule by\boxshadowsize % Make shadow a tad bit wider |
| 1057 |
\lower\boxshadowsize % Move down the same amount |
| 1058 |
\hbox{\vrule width\boxitrule height\oboxht} % Draw the left box |
| 1059 |
} % ... Finish off \hbox |
| 1060 |
\vskip-\oboxht\vskip-\boxshadowsize % Move back up to top of box |
| 1061 |
\hbox{\vbox{\unvbox0} % Create box with text inside it |
| 1062 |
}} % End of vboxes |
| 1063 |
\advance\boxshadowsize by\boxitrule % Make box a little thicker |
| 1064 |
% ... so it overlaps bottom line |
| 1065 |
\vskip-\boxitrule % Move up height of bottom line |
| 1066 |
\vbox{ % Start a new \vbox |
| 1067 |
\hbox{\vbox{ % Create \hbox that is shadow |
| 1068 |
\hrule height\boxshadowsize width\oboxwd}} % ... |
| 1069 |
} % End of the \vbox |
| 1070 |
} % End of \vbox |
| 1071 |
}} % End of \shadowbox |
| 1072 |
|
| 1073 |
\def\bestbreak{\par\penalty-1000} |
| 1074 |
|
| 1075 |
% |
| 1076 |
% Begin a quotation. The quote is separated from the main text by two |
| 1077 |
% hrules and is indented from the normal text. |
| 1078 |
% |
| 1079 |
\def\beginquote{ |
| 1080 |
\begingroup % Define beginning of a group |
| 1081 |
\quotefont\baselineskip=16.8pt |
| 1082 |
\hrule height2pt % Draw a line |
| 1083 |
\parindent 5pt % Indent paragraphs by 5pt |
| 1084 |
\vglue\medskipamount % Use some glue so rule sticks |
| 1085 |
\narrower\narrower % Bring margins in (10pt) |
| 1086 |
\noindent % Don't indent |
| 1087 |
} % End of macro |
| 1088 |
% |
| 1089 |
% End a quotation. |
| 1090 |
% |
| 1091 |
\def\endquote{ |
| 1092 |
\vglue\medskipamount % Use some glue so rule sticks |
| 1093 |
\hrule height2pt % Draw a line |
| 1094 |
\endgroup % End the quote group |
| 1095 |
} |
| 1096 |
|
| 1097 |
\def\quotee#1{{\hfill\break\hbox{}\nobreak\hfill\hbox{\quoteefont #1} |
| 1098 |
\finalhyphendemerits=0}} |
| 1099 |
\def\Quote#1#2{\vbox{\vskip1.2pt\beginquote #1% |
| 1100 |
\quotee{#2}\endquote\vskip1.20003pt}} |
| 1101 |
|
| 1102 |
% |
| 1103 |
% Insert current month and year |
| 1104 |
% |
| 1105 |
\def\DATE{\ifcase\month\or January\or February\or March\or April\or May |
| 1106 |
\or June\or July\or August\or September\or October\or November |
| 1107 |
\or December\fi\space\number\year} |
| 1108 |
% |
| 1109 |
% Include a TeX file. |
| 1110 |
% |
| 1111 |
\def\include#1{\immediate\write10{Including TeX file #1} |
| 1112 |
\input #1 % Read the file in |
| 1113 |
% Things to do after formatting the file |
| 1114 |
} |
| 1115 |
% |
| 1116 |
% Separate articles with some vskip and an \hrule |
| 1117 |
% |
| 1118 |
\def\articlesep{ % Rule to separate articles |
| 1119 |
\vglue 10pt plus2pt minus4pt % Use vglue |
| 1120 |
\hrule %height.4pt % Draw a rule equal to \hsize |
| 1121 |
\vskip 10pt plus2pt minus2pt % Skip some vertical space |
| 1122 |
} |
| 1123 |
|
| 1124 |
% Put release flush right. If it won't fit, put it on the next line. |
| 1125 |
% From TeXbook, Chapter 14. |
| 1126 |
\def\farright#1{{\unskip\nobreak\hfill\penalty50\hskip2em |
| 1127 |
\hbox{}\nobreak\hfill \hbox{#1}\finalhyphendemerits=0}} |
| 1128 |
|
| 1129 |
% |
| 1130 |
% Define end-of-article marker. |
| 1131 |
% |
| 1132 |
\def\eoa{\farright{\vrule height1.5ex width1.5ex depth0pt}} |
| 1133 |
% |
| 1134 |
% Generate a blank page and a blank line. |
| 1135 |
% |
| 1136 |
\def\nullpage{\eject\line{}\vfil\eject} % Define an empty page |
| 1137 |
\def\nullline{\break\hbox{}\hfil\break} % Define an empty line |
| 1138 |
% |
| 1139 |
% Start on a new page. |
| 1140 |
% |
| 1141 |
\def\newpage{\vfill\eject} |
| 1142 |
% |
| 1143 |
% Get rid of underfill errors |
| 1144 |
% |
| 1145 |
\def\ignoreunderfill{\vbadness=10000\hbadness=10000\tolerance=2000} |
| 1146 |
|
| 1147 |
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 1148 |
% Macros for bibliography entries |
| 1149 |
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 1150 |
% |
| 1151 |
% Sample usage: |
| 1152 |
% |
| 1153 |
% \beginbibliography |
| 1154 |
% \bibbook{The Wolf's Hour} |
| 1155 |
% \ENUM New York: Pocket Books, March 1989 (paperback) |
| 1156 |
% \endbibliography |
| 1157 |
% |
| 1158 |
\newcount\enumno % New counter - item # |
| 1159 |
% |
| 1160 |
% \beginbibliography - Begin a bibliography |
| 1161 |
% |
| 1162 |
\def\beginbibliography{\begingroup\global\enumno=1 |
| 1163 |
\tiny % Use 8pt font |
| 1164 |
\parskip=1pt plus 1pt % Skip up to 2 points |
| 1165 |
} % End of \beginbibliography |
| 1166 |
\def\endbibliography{\par\endbiblist\endgroup} % End of bibliography |
| 1167 |
% |
| 1168 |
% \beginbiblist - Begin a list of bibliographic references |
| 1169 |
% |
| 1170 |
\def\beginbiblist{\begingroup |
| 1171 |
\vglue0pt\parindent=30pt\parskip=0pt} |
| 1172 |
% |
| 1173 |
% \beginanotherlist - Begin a list inside a list of bibliographic references |
| 1174 |
% |
| 1175 |
\def\beginanotherlist{\begingroup |
| 1176 |
\divide\parskip by 2 |
| 1177 |
\vglue\parskip\advance\parindent by10pt\parskip=0pt} |
| 1178 |
\def\endbiblist{\par\endgroup\vskip4pt} |
| 1179 |
|
| 1180 |
% ENUM - Number items in a list |
| 1181 |
% ENum - No number, but spaced as if number was present |
| 1182 |
% NoENUM - Only one reference is present. Start reference where number would |
| 1183 |
% normally start (hanging into left column). |
| 1184 |
% |
| 1185 |
% Examples: |
| 1186 |
% |
| 1187 |
% \ENUM First one 1. First one |
| 1188 |
% \ENUM Second one Yields 2. Second one |
| 1189 |
% \ENum Third one Third one |
| 1190 |
% \NoENUM Fourth one Fourth one |
| 1191 |
% |
| 1192 |
\def\ENUM#1\par{\item{\the\enumno.}\advance\enumno by 1 #1 \par } |
| 1193 |
\def\ENum#1\par{\item{}\advance\enumno by 1 #1 \par } |
| 1194 |
\def\NoENUM#1\par{\advance\enumno by 1\par\hang\hskip-10pt #1 \par } |
| 1195 |
% |
| 1196 |
% \bibshort, \bibbook, \bibview |
| 1197 |
% |
| 1198 |
% Macros to begin a new bibliography entry for a short story, a book, and |
| 1199 |
% and interviews. These macros will terminate the previous bibliography |
| 1200 |
% entry (if there is one) and begin a new entry. |
| 1201 |
% |
| 1202 |
\def\bibshort#1{\ifnum\enumno>1 \bestbreak\endbiblist\fi % Short story |
| 1203 |
\noindent{\story{#1}}\beginbiblist |
| 1204 |
} |
| 1205 |
\def\bibbook#1{\ifnum\enumno>1 \endbiblist\fi % Book |
| 1206 |
\noindent{\sl #1}\beginbiblist |
| 1207 |
} |
| 1208 |
\def\bibview#1{\ifnum\enumno>1 \endbiblist\fi % Interview |
| 1209 |
\noindent{#1}\beginbiblist |
| 1210 |
} |
| 1211 |
\def\subbib#1{\hskip-20pt #1\hfill} %Subheading for a bib entry |
| 1212 |
\def\bibsectitle#1{ %Title of bib section (BOOKS...) |
| 1213 |
\vskip 8pt plus1pt minus1pt % Skip some space |
| 1214 |
\hrule % Draw an hrule |
| 1215 |
{\tenss #1} % Add text in 10pt font |
| 1216 |
\vglue 10pt plus1pt minus1pt % Skip some more space |
| 1217 |
} |
| 1218 |
%=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |
| 1219 |
% |
| 1220 |
% File: QUOTE.TEX |
| 1221 |
% |
| 1222 |
% Author: Hunter Goatley |
| 1223 |
% |
| 1224 |
% Date: August 14, 1991 |
| 1225 |
% |
| 1226 |
% Abstract: |
| 1227 |
% |
| 1228 |
% This file defines the macros \begindoublequotes and \enddoublequotes, |
| 1229 |
% which let TeX replace the double-quote character (") with TeX's |
| 1230 |
% left double-quote and right double-quote. For example: |
| 1231 |
% |
| 1232 |
% "This is a test." ---> ``This is a test.'' |
| 1233 |
% |
| 1234 |
% The double-quote character is still available via \dq. (\" is still |
| 1235 |
% treated as the umlaut accent.) |
| 1236 |
% |
| 1237 |
% This macro makes a couple of assumptions about the double-quotes: |
| 1238 |
% |
| 1239 |
% 1. Double-quotes are assumed to come in pairs. When replacing |
| 1240 |
% double-quotes, the macro alternates between `` and ''. The only |
| 1241 |
% exception to this is noted in (2) below. |
| 1242 |
% 2. A double-quote at the beginning of a paragraph is always treated |
| 1243 |
% as ``. This correctly handles the case where a quotation is |
| 1244 |
% continued into a second paragraph: |
| 1245 |
% |
| 1246 |
% "This is the first paragraph.\par |
| 1247 |
% "This is the second paragraph of the same quote." |
| 1248 |
% |
| 1249 |
% Normal TeX spacing after `` and '' is maintained by saving and |
| 1250 |
% restoring the \spacefactor. |
| 1251 |
% |
| 1252 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1253 |
% |
| 1254 |
% HOW IT WORKS: |
| 1255 |
% |
| 1256 |
% The double-quote character (") is made active by \begindoublequotes. |
| 1257 |
% The " macro keeps track of left-quote/right-quote pairs and inserts |
| 1258 |
% the appropriate `` and '' in its place. |
| 1259 |
% |
| 1260 |
% Each character has a \spacefactor associated with it, which specifies |
| 1261 |
% the amount of stretch or shrink that a space following the character |
| 1262 |
% can have. Most characters have a factor of 1000, but some punctuation |
| 1263 |
% marks have higher spacefactors, most notably the period, which has a |
| 1264 |
% \spacefactor of 3000. This means the space following a period can |
| 1265 |
% stretch up to 3 times more than the space after a regular character, |
| 1266 |
% accounting for the increased space at the end of sentences. |
| 1267 |
% |
| 1268 |
% The `` and '' ligatures are assigned \spacefactor's of 0, so that the |
| 1269 |
% \spacefactor that is applied to the next character is the same as that |
| 1270 |
% of the character preceding the quotes. Because " has been redefined as |
| 1271 |
% a macro, any spaces following " are swallowed by TeX. It was necessary |
| 1272 |
% to have this macro re-insert any needed space so that the following |
| 1273 |
% cases worked correctly: |
| 1274 |
% |
| 1275 |
% "This is a test," she said. --> ``This is a test,'' she said. |
| 1276 |
% "This is in a list"; etc. --> ``This is in a list''; etc. |
| 1277 |
% |
| 1278 |
% Without the added space, the first example becomes: |
| 1279 |
% |
| 1280 |
% ``This is a test,''she said. |
| 1281 |
% |
| 1282 |
% The solution was to save the current \spacefactor before inserting a |
| 1283 |
% right double-quote, then resetting the \spacefactor after the |
| 1284 |
% insertion. The net effect was that the " macro has a \spacefactor |
| 1285 |
% of 0, which matches the way TeX treats `` and ''. |
| 1286 |
% |
| 1287 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1288 |
{% % Begin a group for which " is active |
| 1289 |
\catcode`\"=\active % Make " an active character |
| 1290 |
\catcode`\@=11 % Make @ an active character |
| 1291 |
% |
| 1292 |
% \begindoublequotes |
| 1293 |
% |
| 1294 |
% This macro makes " an active character, resets the control sequence |
| 1295 |
% \dblqu@te to L (left), and defines \dq as a replacement for ". |
| 1296 |
% |
| 1297 |
\gdef\begindoublequotes{% % \begindoublequotes enables " |
| 1298 |
\global\catcode`\"=\active % Make " an active character |
| 1299 |
\global\chardef\dq=`\" % Double-quote char. via \dq |
| 1300 |
\global\let\dblqu@te=L % Always start with a left double-quote |
| 1301 |
} % End of macro |
| 1302 |
% |
| 1303 |
% Define the macro that will be executed whenever " is encountered. |
| 1304 |
% |
| 1305 |
\gdef"{% |
| 1306 |
% If the double-quote is the first character in a new paragraph, |
| 1307 |
% make sure it becomes a left double-quote. This case can be |
| 1308 |
% detected by checking to see if TeX is currently in vertical mode. |
| 1309 |
% If so, the double-quote is at the beginning of the paragraph |
| 1310 |
% (since " hasn't actually generated any horizontal mode tokens |
| 1311 |
% yet, TeX is still in vertical mode). If the mode is vertical, |
| 1312 |
% set \dblqu@te equal to L. |
| 1313 |
% |
| 1314 |
\ifinner\else\ifvmode\let\dblqu@te=L\fi\fi |
| 1315 |
% |
| 1316 |
% Now insert the appropriate left or right double-quote. |
| 1317 |
% |
| 1318 |
% If \dblqu@te is L, insert a `` and set \dblqu@te to R. |
| 1319 |
% |
| 1320 |
\if L\dblqu@te``\global\let\dblqu@te=R% |
| 1321 |
% |
| 1322 |
% Otherwise, save the current \spacefactor, insert '', set \dblqu@te |
| 1323 |
% to L, and reset the original \spacefactor. |
| 1324 |
% |
| 1325 |
\else |
| 1326 |
\let\xxx=\spacefactor % Save the \spacefactor |
| 1327 |
''\global\let\dblqu@te=L% % Insert '' and reset \dblqu@te |
| 1328 |
\spacefactor\xxx % Reset the \spacefactor |
| 1329 |
\fi % End of \if L\dblqu@te... |
| 1330 |
} % End of " macro |
| 1331 |
} % End of group |
| 1332 |
|
| 1333 |
\gdef\enddoublequotes{% |
| 1334 |
\catcode`\"=12 %Set " back to other |
| 1335 |
} |
| 1336 |
% |
| 1337 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1338 |
% Header & Footer Macros |
| 1339 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1340 |
% |
| 1341 |
% These macros implement the headers and footers for the newsletter format. |
| 1342 |
% The macros accept three parameters: text that is to appear flush-left on |
| 1343 |
% the line, text that should be centered, and text that should be flush-right |
| 1344 |
% on the line. Parameters can be omitted by specifying empty braces ({}). |
| 1345 |
% |
| 1346 |
% The following macros are defined for headers and footers: |
| 1347 |
% |
| 1348 |
% \evenpageheader{LEFT}{CENTER}{RIGHT} |
| 1349 |
% \oddpageheader{LEFT}{CENTER}{RIGHT} |
| 1350 |
% \evenpagefooter{LEFT}{CENTER}{RIGHT} |
| 1351 |
% \oddpagefooter{LEFT}{CENTER}{RIGHT} |
| 1352 |
% |
| 1353 |
% If the headers/footers are the same for even & odd pages, the following |
| 1354 |
% macros can be used instead of the four above: |
| 1355 |
% |
| 1356 |
% \pageheader{LEFT}{CENTER}{RIGHT} |
| 1357 |
% \pagefooter{LEFT}{CENTER}{RIGHT} |
| 1358 |
% |
| 1359 |
% Additional header/footer definitions: |
| 1360 |
% |
| 1361 |
% \pageheaderlinetrue - A line should extend below header text |
| 1362 |
% \pageheaderlinefalse - Header does NOT have a line |
| 1363 |
% \pagefooterlinetrue - A line should extend above footer text |
| 1364 |
% \pagefooterlinefalse - Footer does NOT have a line |
| 1365 |
% \headfootrule=Xpt - Thickness of header/footer lines |
| 1366 |
% \pageheaderskip=Xpt - \vskip between header and line |
| 1367 |
% \pagefooterskip=Xpt - \vskip between footer and line |
| 1368 |
% \headfont=\fontname - Font to use for header text |
| 1369 |
% \footfont=\fontname - Font to use for footer text |
| 1370 |
% |
| 1371 |
% Example: |
| 1372 |
% |
| 1373 |
% \pageheader{}{My Newsletter}{} |
| 1374 |
% \pagefooter{October 1989}{}{\pageno} |
| 1375 |
% |
| 1376 |
\newif\ifpageheaderline \pageheaderlinefalse % By default, no header line |
| 1377 |
\newif\ifpagefooterline \pagefooterlinefalse % By default, no footer line |
| 1378 |
\newdimen\headfootrule \headfootrule=0.50pt % Height of header & footer rule |
| 1379 |
\newdimen\pageheaderskip \pageheaderskip=4pt % Space between header and rule |
| 1380 |
\newdimen\pagefooterskip \pagefooterskip=4pt % Space between rule and footer |
| 1381 |
|
| 1382 |
\let\headfont=\twelverm \let\footfont=\twelverm % Assign fonts for head/foot |
| 1383 |
|
| 1384 |
\def\@pageheader#1#2#3{% |
| 1385 |
\ifpageheaderline % If headerline |
| 1386 |
\vbox{\hbox to\normalhsize{{\headfont\rlap{#1}\hss{#2}\hss\llap{#3}}}% |
| 1387 |
\vskip\pageheaderskip\hrule height\headfootrule}% Do hbox and hrule |
| 1388 |
\else |
| 1389 |
{\headfont\rlap{#1}\hss{#2}\hss\llap{#3}}% |
| 1390 |
\fi |
| 1391 |
} |
| 1392 |
|
| 1393 |
\def\@pagefooter#1#2#3{% |
| 1394 |
\ifpagefooterline |
| 1395 |
\vbox{\hrule height\headfootrule\vskip\pagefooterskip |
| 1396 |
\hbox to\normalhsize{\footfont\rlap{#1}\hss{#2}\hss\llap{#3}}}% |
| 1397 |
\else |
| 1398 |
{\footfont\rlap{#1}\hss{#2}\hss\llap{#3}}% |
| 1399 |
\fi |
| 1400 |
} |
| 1401 |
% |
| 1402 |
% Define default headers and footers - null lines of text |
| 1403 |
% |
| 1404 |
\def\@oddhead{\nullline} \def\@evenhead{\nullline} |
| 1405 |
\def\@oddfoot{\nullline} \def\@evenfoot{\nullline} |
| 1406 |
|
| 1407 |
\def\@newhead{\headline{\ifodd\pageno\@oddhead\else\@evenhead\fi}} |
| 1408 |
\def\@newfoot{\footline{\ifodd\pageno\@oddfoot\else\@evenfoot\fi}} |
| 1409 |
|
| 1410 |
\def\oddpageheader#1#2#3{\@newhead\def\@oddhead{\@pageheader{#1}{#2}{#3}}} |
| 1411 |
\def\evenpageheader#1#2#3{\@newhead\def\@evenhead{\@pageheader{#1}{#2}{#3}}} |
| 1412 |
\def\oddpagefooter#1#2#3{\@newfoot\def\@oddfoot{\@pagefooter{#1}{#2}{#3}}} |
| 1413 |
\def\evenpagefooter#1#2#3{\@newfoot\def\@evenfoot{\@pagefooter{#1}{#2}{#3}}} |
| 1414 |
% |
| 1415 |
% If no difference between even and odd pages, just define both to be the same. |
| 1416 |
% |
| 1417 |
\def\pageheader#1#2#3{\evenpageheader{#1}{#2}{#3}\oddpageheader{#1}{#2}{#3}} |
| 1418 |
\def\pagefooter#1#2#3{\evenpagefooter{#1}{#2}{#3}\oddpagefooter{#1}{#2}{#3}} |
| 1419 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1420 |
% |
| 1421 |
% Command for "poor man's bold": \pmb (use sparingly) |
| 1422 |
% |
| 1423 |
\def\pmb#1{\setbox0=\hbox{#1}% % Copy box to box0 |
| 1424 |
\leavevmode\hbox{% % Make an hbox that holds |
| 1425 |
\kern-.025em\copy0\kern-\wd0% % Move left 1/4 em and copy box0 |
| 1426 |
\kern.05em\copy0\kern-\wd0% % Move right 1/4 em and copy it |
| 1427 |
\kern-.025em\raise.0433em\box0 }} % Raise a little and copy again |
| 1428 |
|
| 1429 |
% |
| 1430 |
% Define dots for ending sentences (4 dots instead of 3) |
| 1431 |
% |
| 1432 |
\def\eldots{\mathinner{\ldotp\ldotp\ldotp\ldotp}} |
| 1433 |
\def\edots{\relax\ifmmode\eldots\else$\m@th\eldots\,$\fi} |
| 1434 |
\def\ellip{\hskip.2em\ifmmode\ldots\else$\ldots$\fi\hskip.25em} |
| 1435 |
% |
| 1436 |
% Define macros \ital and \slant to switch to italic (\it) and slanted (\sl) |
| 1437 |
% respectively. These macros automatically insert the italic correction |
| 1438 |
% unless the next character is a period or a comma. Based on the |
| 1439 |
% \predict macro presented in _TeX for the Impatient_, p. 233. |
| 1440 |
% |
| 1441 |
% These macros use \toks0 as a temporary. |
| 1442 |
% |
| 1443 |
% The \futurelet\it@next in \ital and \slant defines \it@next to be whatever |
| 1444 |
% the character following the parameter is. \d@slant checks to see if |
| 1445 |
% \it@next is a comma or period; if it is neither, the italic correction |
| 1446 |
% (\/) is included. |
| 1447 |
% |
| 1448 |
\def\ital#1{\toks0={#1}\let\slf@nt=\it\futurelet\it@next\d@slant} |
| 1449 |
\def\slant#1{\toks0={#1}\let\slf@nt=\sl\futurelet\it@next\d@slant} |
| 1450 |
\def\d@slant{{\slf@nt\the\toks0}% |
| 1451 |
\ifx\it@next,% % If \it@next not a comma |
| 1452 |
\else\ifx\it@next.% % ... and is not a period |
| 1453 |
\else\/% % ... insert the correction (\/) |
| 1454 |
\fi\fi% % ... |
| 1455 |
\let\it@next=\relax% % "Undefine" \it@next |
| 1456 |
} |
| 1457 |
|
| 1458 |
\def\book#1{\ital{#1}} %For ease, define \book too |
| 1459 |
\def\story#1{``#1''} %Short story title (add quotes) |
| 1460 |
% |
| 1461 |
% Important - make "@" a valid alphanumeric character again |
| 1462 |
% |
| 1463 |
\catcode`\@=12 % Follow TeX's lead on variable names |
| 1464 |
|
| 1465 |
\tenpoint % Default point size is 10pt |