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