home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / tex / webtp55.arc / WEBMAC.TEX < prev   
Text File  |  1988-08-27  |  10KB  |  202 lines

  1. % This is WEBMAC.TEX in text format, as of May 5, 1986.
  2. % standard macros for WEB listings (in addition to PLAIN.TEX)
  3. \xdef\fmtversion{\fmtversion+WEBMAC1.4}
  4. \parskip 0pt % no stretch between paragraphs
  5. \parindent 1em % for paragraphs and for the first line of Pascal text
  6.  
  7. \font\eightrm=cmr8
  8. \let\sc=\eightrm \let\mainfont=\tenrm
  9. \font\titlefont=cmr7 scaled\magstep4 % title on the contents page
  10. \font\ttitlefont=cmtt10 scaled\magstep2 % typewriter type in title
  11. \font\tentex=cmtex10 % TeX extended character set (used in strings)
  12.  
  13. \def\\#1{\hbox{\it#1\/\kern.05em}} % italic type for identifiers
  14. \def\|#1{\hbox{$#1$}} % one-letter identifiers look a bit better this way
  15. \def\{\hbox{\bf#1\/}} % boldface type for reserved words
  16. \def\.#1{\hbox{\tentex % typewriter type for strings
  17.   \let\\=\BS % backslash in a string
  18.   \let\'=\RQ % right quote in a string
  19.   \let\`=\LQ % left quote in a string
  20.   \let\{=\LB % left brace in a string
  21.   \let\}=\RB % right brace in a string
  22.   \let\~=\TL % tilde in a string
  23.   \let\ =\SP % space in a string
  24.   \let\_=\UL % underline in a string
  25.   \let\&=\AM % ampersand in a string
  26.   #1}}
  27. \def\#{\hbox{\tt\char`\#}} % parameter sign
  28. \def\${\hbox{\tt\char`\$}} % dollar sign
  29. \def\%{\hbox{\tt\char`\%}} % percent sign
  30. \def\^{\ifmmode\mathchar"222 \else\char`^ \fi} % pointer or hat
  31. % circumflex accents can be obtained from \^^D instead of \^
  32. \def\AT!{@} % at sign for control text
  33.  
  34. \chardef\AM=`\& % ampersand character in a string
  35. \chardef\BS=`\\ % backslash in a string
  36. \chardef\LB=`\{ % left brace in a string
  37. \def\LQ{{\tt\char'22}} % left quote in a string
  38. \chardef\RB=`\} % right brace in a string
  39. \def\RQ{{\tt\char'23}} % right quote in a string
  40. \def\SP{{\tt\char`\ }} % (visible) space in a string
  41. \chardef\TL=`\~ % tilde in a string
  42. \chardef\UL=`\_ % underline character in a string
  43.  
  44. \newbox\bak \setbox\bak=\hbox to -1em{} % backspace one em
  45. \newbox\bakk\setbox\bakk=\hbox to -2em{} % backspace two ems
  46.  
  47. \newcount\ind % current indentation in ems
  48. \def\1{\global\advance\ind by1\hangindent\ind em} % indent one more notch
  49. \def\2{\global\advance\ind by-1} % indent one less notch
  50. \def\3#1{\hfil\penalty#10\hfilneg} % optional break within a statement
  51. \def\4{\copy\bak} % backspace one notch
  52. \def\5{\hfil\penalty-1\hfilneg\kern2.5em\copy\bakk\ignorespaces}% optional break
  53. \def\6{\ifmmode\else\par % forced break
  54.   \hangindent\ind em\noindent\kern\ind em\copy\bakk\ignorespaces\fi}
  55. \def\7{\Y\6} % forced break and a little extra space
  56.  
  57. \let\yskip=\smallskip
  58. \def\to{\mathrel{.\,.}} % double dot, used only in math mode
  59. \def\note#1#2.{\Y\noindent{\hangindent2em\baselineskip10pt\eightrm#1 #2.\par}}
  60. \def\lapstar{\rlap{*}}
  61. \def\startsection{\Q\noindent{\let\*=\lapstar\bf\modstar.\quad}}
  62. \def\defin#1{\global\advance\ind by 2 \1\&{#1 }} % begin `define' or `format'
  63. \def\A{\note{See also}} % cross-reference for multiply defined section names
  64. \def\B{\mathopen{\.{@\{}}} % begin controlled comment
  65. \def\C#1{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % Pascal comments
  66.   \XX\hfil\penalty-1\hfilneg\quad$\{\,$#1$\,\}$\XX}
  67. \def\D{\defin{define}} % macro definition
  68. \def\E{\cdot10^} % exponent in floating point constant
  69. \def\F{\defin{format}} % format definition
  70. \let\G=\ge % greater than or equal sign
  71. \def\H#1{\hbox{\rm\char"7D\tt#1}} % hexadecimal constant
  72. \let\I=\ne % unequal sign
  73. \def\J{\.{@\&}} % TANGLE's join operation
  74. \let\K=\gets % left arrow
  75. \let\L=\le % less than or equal sign
  76. \outer\def\M#1.{\MN#1.\ifon\vfil\penalty-100\vfilneg % beginning of section
  77.   \vskip12ptminus3pt\startsection\ignorespaces}
  78. \outer\def\N#1.#2.{\MN#1.\vfil\eject % beginning of starred section
  79.   \def\rhead{\uppercase{\ignorespaces#2}} % define running headline
  80.   \message{*\modno} % progress report
  81.   \edef\next{\write\cont{\Z{#2}{\modno}{\the\pageno}}}\next % to contents file
  82.   \ifon\startsection{\bf\ignorespaces#2.\quad}\ignorespaces}
  83. \def\MN#1.{\par % common code for \M, \N
  84.   {\xdef\modstar{#1}\let\*=\empty\xdef\modno{#1}}
  85.   \ifx\modno\modstar \onmaybe \else\ontrue \fi \mark{\modno}}
  86. \def\O#1{\hbox{\rm\char'23\kern-.2em\it#1\/\kern.05em}} % octal constant
  87. \def\P{\rightskip=0pt plus 100pt minus 10pt % go into Pascal mode
  88.   \sfcode`;=3000
  89.   \pretolerance 10000
  90.   \hyphenpenalty 10000 \exhyphenpenalty 10000
  91.   \global\ind=2 \1\ \unskip}
  92. \def\Q{\rightskip=0pt % get out of Pascal mode
  93.   \sfcode`;=1500 \pretolerance 200 \hyphenpenalty 50 \exhyphenpenalty 50 }
  94. \let\R=\lnot % logical not
  95. \let\S=\equiv % equivalence sign
  96. \def\T{\mathclose{\.{@\}}}} % terminate controlled comment
  97. \def\U{\note{This code is used in}} % cross-reference for uses of sections
  98. \let\V=\lor % logical or
  99. \let\W=\land % logical and
  100. \def\X#1:#2\X{\ifmmode\gdef\XX{\null$\null}\else\gdef\XX{}\fi % section name
  101.   \XX$\langle\,$#2{\eightrm\kern.5em#1}$\,\rangle$\XX}
  102. \def\Y{\par\yskip}
  103. \let\Z=\let % now you can \send the control sequence \Z
  104. \def\){\hbox{\.{@\$}}} % sign for string pool check sum
  105. \def\]{\hbox{\.{@\\}}} % sign for forced line break
  106. \def\=#1{\kern2pt\hbox{\vrule\vtop{\vbox{\hrule
  107.         \hbox{\strut\kern2pt\.{#1}\kern2pt}}
  108.       \hrule}\vrule}\kern2pt} % verbatim string
  109. \let\~=\ignorespaces
  110. \let\*=*
  111.  
  112. \def\onmaybe{\let\ifon=\maybe} \let\maybe=\iftrue
  113. \newif\ifon \newif\iftitle \newif\ifpagesaved
  114. \def\lheader{\mainfont\the\pageno\eightrm\qquad\rhead\hfill\title\qquad
  115.   \tensy x\mainfont\topmark} % top line on left-hand pages
  116. \def\rheader{\tensy x\mainfont\topmark\eightrm\qquad\title\hfill\rhead
  117.   \qquad\mainfont\the\pageno} % top line on right-hand pages
  118. \def\page{\box255 }
  119. \def\normaloutput#1#2#3{\ifodd\pageno\hoffset=\pageshift\fi
  120.   \shipout\vbox{
  121.     \vbox to\fullpageheight{
  122.       \iftitle\global\titlefalse
  123.       \else\hbox to\pagewidth{\vbox to10pt{}\ifodd\pageno #3\else#2\fi}\fi
  124.       \vfill#1}} % parameter #1 is the page itself
  125.   \global\advance\pageno by1}
  126.  
  127. \def\rhead{\.{WEB} OUTPUT} % this running head is reset by starred sections
  128. \def\title{} % an optional title can be set by the user
  129. \def\topofcontents{\centerline{\titlefont\title}
  130.   \vfill} % this material will start the table of contents page
  131. \def\botofcontents{\vfill} % this material will end the table of contents page
  132. \def\contentspagenumber{0} % default page number for table of contents
  133. \newdimen\pagewidth \pagewidth=6.5in % the width of each page
  134. \newdimen\pageheight \pageheight=8.7in % the height of each page
  135. \newdimen\fullpageheight \fullpageheight=9in % page height including headlines
  136. \newdimen\pageshift \pageshift=0in % shift righthand pages wrt lefthand ones
  137. \def\magnify#1{\mag=#1\pagewidth=6.5truein\pageheight=8.7truein
  138.   \fullpageheight=9truein\setpage}
  139. \def\setpage{\hsize\pagewidth\vsize\pageheight} % use after changing page size
  140. \def\contentsfile{CONTENTS} % file that gets table of contents info
  141. \def\readcontents{\input CONTENTS}
  142.  
  143. \newwrite\cont
  144. \output{\setbox0=\page % the first page is garbage
  145.   \openout\cont=\contentsfile
  146.   \global\output{\normaloutput\page\lheader\rheader}}
  147. \setpage
  148. \vbox to \vsize{} % the first \topmark won't be null
  149.  
  150. \def\ch{\note{The following sections were changed by the change file:}
  151.   \let\*=\relax}
  152. \newbox\sbox % saved box preceding the index
  153. \newbox\lbox % lefthand column in the index
  154. \def\inx{\par\vskip6pt plus 1fil % we are beginning the index
  155.   \write\cont{} % ensure that the contents file isn't empty
  156.   \closeout\cont % the contents information has been fully gathered
  157.   \output{\ifpagesaved\normaloutput{\box\sbox}\lheader\rheader\fi
  158.     \global\setbox\sbox=\page \global\pagesavedtrue}
  159.   \pagesavedfalse \eject % eject the page-so-far and predecessors
  160.   \setbox\sbox\vbox{\unvbox\sbox} % take it out of its box
  161.   \vsize=\pageheight \advance\vsize by -\ht\sbox % the remaining height
  162.   \hsize=.5\pagewidth \advance\hsize by -10pt
  163.     % column width for the index (20pt between cols)
  164.   \parfillskip 0pt plus .6\hsize % try to avoid almost empty lines
  165.   \def\lr{L} % this tells whether the left or right column is next
  166.   \output{\if L\lr\global\setbox\lbox=\page \gdef\lr{R}
  167.     \else\normaloutput{\vbox to\pageheight{\box\sbox\vss
  168.         \hbox to\pagewidth{\box\lbox\hfil\page}}}\lheader\rheader
  169.     \global\vsize\pageheight\gdef\lr{L}\global\pagesavedfalse\fi}
  170.   \message{Index:}
  171.   \parskip 0pt plus .5pt
  172.   \outer\def\:##1, {\par\hangindent2em\noindent##1:\kern1em} % index entry
  173.   \let\ttentry=\. \def\.##1{\ttentry{##1\kern.2em}} % give \tt a little room
  174.   \def\[##1]{$\underline{##1}$} % underlined index item
  175.   \rm \rightskip0pt plus 2.5em \tolerance 10000 \let\*=\lapstar
  176.   \hyphenpenalty 10000 \parindent0pt}
  177. \def\fin{\par\vfill\eject % this is done when we are ending the index
  178.   \ifpagesaved\null\vfill\eject\fi % output a null index column
  179.   \if L\lr\else\null\vfill\eject\fi % finish the current page
  180.   \parfillskip 0pt plus 1fil
  181.   \def\rhead{NAMES OF THE SECTIONS}
  182.   \message{Section names:}
  183.   \output{\normaloutput\page\lheader\rheader}
  184.   \setpage
  185.   \def\note##1##2.{\hfil\penalty-1\hfilneg\quad{\eightrm##1 ##2.}}
  186.   \linepenalty=10 % try to conserve lines
  187.   \def\U{\note{Used in}} % cross-reference for uses of sections
  188.   \def\:{\par\hangindent 2em}\let\*=*\let\.=\ttentry}
  189. \def\con{\par\vfill\eject % finish the section names
  190.   \rightskip 0pt \hyphenpenalty 50 \tolerance 200
  191.   \setpage
  192.   \output{\normaloutput\page\lheader\rheader}
  193.   \titletrue % prepare to output the table of contents
  194.   \pageno=\contentspagenumber \def\rhead{TABLE OF CONTENTS}
  195.   \message{Table of contents:}
  196.   \topofcontents
  197.   \line{\hfil Section\hbox to3em{\hss Page}}
  198.   \def\Z##1##2##3{\line{\ignorespaces##1
  199.     \leaders\hbox to .5em{.\hfil}\hfil\ ##2\hbox to3em{\hss##3}}}
  200.   \readcontents\relax % read the contents info
  201.   \botofcontents \end} % print the contents page(s) and terminate
  202.