%% %% %% 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}