home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / f / funnel-x.zip / examples / ex12.tex < prev    next >
Text File  |  1992-05-27  |  16KB  |  386 lines

  1.  
  2. %*******************************************************************************
  3. %*                    START OF AUTOMATICALLY GENERATED TEX FILE                *
  4. %*******************************************************************************
  5. %*                                                                             *
  6. %* This TeX file was automatically generated by the FunnelWeb preprocessor.    *
  7. %* You can typeset this file to produce printed documentation by running it    *
  8. %* through the TeX typesetter using a command such as:                         *
  9. %*    tex thisfilename                                                         *
  10. %* The resultant file thisfilename.dvi can be printed using a command such as: *
  11. %*    lpr -Pcslw -d thisfilename.dvi                                           *
  12. %*                                                                             *
  13. %* FunnelWeb is a preprocessor that allows programmers to weave programs and   *
  14. %* their documentation together in a single document. The FunnelWeb program    *
  15. %* analyses such documents producing both program files and typeset            *
  16. %* documentation such as this TeX file.                                        *
  17. %* FunnelWeb was created by Ross Williams.                                     *
  18. %*                                                                             *
  19. %* For more information on FunnelWeb look in the following FTP archive:        *
  20. %*    Machine  : sirius.itd.adelaide.edu.au [IP=129.127.40.3].                 *
  21. %*    Directory: ~pub/funnelweb/                                               *
  22. %*               (or some other appropriately named directory).                *
  23. %* or email Ross Williams at ross@spam.adelaide.edu.au                         *
  24. %*                                                                             *
  25. %*******************************************************************************
  26.  
  27.  
  28. %===================== Start of FunnelWeb TeX Definitions ======================
  29.  
  30.  
  31. % Version
  32. % -------
  33. % This is FunnelWeb TeX Macro Library Version 1.0.
  34.  
  35.  
  36. % Copyright
  37. % ---------
  38. % This set of FunnelWeb TeX definitions was written by Ross Williams and was
  39. % originally Copyright (C) 1992 Ross N. Williams.  However, I, Ross Williams,
  40. % hereby forego any claim to Copyright in this set of FunnelWeb TeX definitions
  41. % and hereby authorize that the set of TeX definitions pass into the public
  42. % domain. -- Ross N. Williams, 3:41pm 07-May-1992, Adelaide, Australia.
  43.  
  44.  
  45. % Modification
  46. % ------------
  47. % Please record all modifications to these TeX definitions here. Unless
  48. % otherwise specified, all modified definitions fall in the public domain too.
  49. %
  50. % Programmers:
  51. %    RNW  Ross N. Williams  ross@spam.adelaide.edu.au
  52. %
  53. % Changes:
  54. %    07-May-1992  RNW  Prepared this work for public domain release.
  55. %
  56.  
  57.  
  58. % General Comments
  59. % ----------------
  60. % This set of TeX definitions exists for two reasons:
  61. %
  62. %    1. To shorten and neaten the FunnelWeb TeX output.
  63. %    2. To allow users to fiddle with the output format in their input files
  64. %       (by inserting redefining "\def"s) without having to resort to
  65. %       modifying the FunnelWeb code.
  66. %
  67. % The user is warned that these definitions may be changed from time to time
  68. % (but probably not much). The user should not be too sneaky. In particular,
  69. % users wishing to redefine some of these macros should do so in an explicitly
  70. % defined section at the top of their input file. This will mean that in the
  71. % event of problems, that section can simply be deleted or commented out to
  72. % allow the document to at least be typeset in the default format. Users should
  73. % limit themselves to redefining these macros in such a section and should
  74. % refrain from using the macros throughout their documents.
  75.  
  76.  
  77. % Environment Parameters
  78. % ----------------------
  79. % \tolerance tells TeX how tolerant it should be about making bad line and
  80. % page breaks. Here we set it to it's maximum, as
  81. %   1) Computer programs are likely to cause lots of bad breaks.
  82. %   2) In most cases the user would probably rather get the TeX file through
  83. %      TeX without any errors than fiddle with spacings for perfection.
  84. \tolerance=10000
  85.  
  86. % I don't like indentation as it makes the page look more busy. Instead,
  87. % paragraphs are separated by a little space (see next).
  88. \parindent=0pt
  89.  
  90. % In many cases, users will produce documents with long runs of paragraphs.
  91. % In order to space out these paragraphs, it is convenient to maintain a
  92. % prevailing non-zero \parskip (end-of-paragaph skip). The only trouble is
  93. % that the skip becomes a problem in macro definitions which require no skip
  94. % and so we have to turn the skip on and off. The following two macros
  95. % simplify this process.
  96. \def\fwparskipon{\parskip=\medskipamount}
  97. \def\fwparskipoff{\parskip=0pt}
  98. \fwparskipon
  99.  
  100. % Setting raggedbottom allows TeX to leave a bit of space at the bottom of the
  101. % page in order to better vertically align the rest of the page (e.g. skips
  102. % won't stretch as much). It also means that headings are less likely to be
  103. % isolated at the bottom of the page without any following text.
  104. \raggedbottom
  105.  
  106.  
  107. % Fonts
  108. % -----
  109. % Most of the typeset output is set in 10pt roman and 10pt tt font.
  110. % The major extra font needs spring from titles and headings.
  111. % For portability's sake we use only the following fonts:
  112. %    cmr10
  113. %    cmbx10
  114. %    cmtt10
  115. % and some enlargements of them. These fonts are all "standard" fonts
  116. % in Plain TeX. See The TeXbook p.350.
  117. \font\fwfontnote=cmr7
  118.  
  119. \font\fwfontnorm=cmr10
  120. \font\fwfontnorma=cmr10 scaled \magstep1
  121. \font\fwfontnormb=cmr10 scaled \magstep2
  122.  
  123. \font\fwfontbold=cmbx10
  124. \font\fwfontbolda=cmbx10 scaled \magstep1
  125. \font\fwfontboldb=cmbx10 scaled \magstep2
  126. \font\fwfontboldc=cmbx10 scaled \magstep3
  127. \font\fwfontboldd=cmbx10 scaled \magstep4
  128.  
  129.  
  130. % Macros for Stylistic Details
  131. % ----------------------------
  132. % This section contains all the fiddly little macros for setting the details
  133. % of each macro definition.
  134.  
  135. % Macro definitions are sandwiched by calls to these macros which can be used
  136. % to sort out the spacing before and after the macro definition.
  137. \def\fwbeginmacro{\fwparskipoff\bigskip}
  138. \def\fwendmacro{\fwparskipon\par}
  139.  
  140. % These macros deal with the macro name and definition line.
  141. \def\fwmacroname#1#2{{\sl #1\/}$\lbrack$#2$\rbrack$}
  142. \def\fwfilename#1#2{{\bf #1}$\lbrack$#2$\rbrack$}
  143. \def\fwzero#1{{\bf Z}}
  144. \def\fwmany#1{{\bf M}}
  145. \def\fwequals{ $\equiv$}
  146. \def\fwplusequals{ $+\equiv$}
  147.  
  148. % Now for the actual body of the definition. It looks nice to have the tt
  149. % code indented a little. Again, we use macros instead of writing direct TeX,
  150. % so as to allow the user to fiddle this stuff to taste without having to
  151. % modify the FunnelWeb C code.
  152. \def\fwodef{\parindent=15pt\vskip0pt$\lbrace$\parindent=20pt}
  153. \def\fwcdef{$\rbrace$\vskip0pt\parindent=0pt}
  154. \def\fwoquote{`}
  155. \def\fwcquote{'}
  156. \def\fwoparen{$($}
  157. \def\fwcomma{$,$}
  158. \def\fwcparen{$)$}
  159. \def\fwparam#1{$\diamond #1$}
  160. \def\fwparams#1{$(\diamond #1)$}
  161.  
  162. % These macros deal with the notes that are appended at the end of each
  163. % macro definition. Note that even though \fwisafile,\fwusedin, and \fwseealso
  164. % have the same definition, they are given different names so as to allow the
  165. % user to redefine these macros to typeset each kind of information differently
  166. % if desired.
  167. \def\fwbeginmacronotes{\begingroup\baselineskip=9pt\smallskip}
  168. \def\fwnote#1{{\fwfontnote #1}\par}
  169. \def\fwisafile#1{\fwnote{#1}}
  170. \def\fwusedin#1{\fwnote{#1}}
  171. \def\fwseealso#1{\fwnote{#1}}
  172. \def\fwendmacronotes{\endgroup}
  173.  
  174.  
  175. % Macros to Typeset Program Code Verbatim
  176. % ---------------------------------------
  177. % This is by far the hairiest and most difficult part of the typesetting task
  178. % because we have to turn off most of TeX's natural instincts in order to
  179. % typeset the program text exactly as it appears in the input file.
  180. % Two macros are defined to pull this off: \fwbtx and \fwverbatimgobble.
  181. % Their code was inspired by the following sections of "The TeXbook":
  182. %    Appendix D: Dirty Tricks, 3.Verbatim listing, p.380-382.
  183. %    Appendix E: Example Formats, p.421.
  184. % The \fwbtx[ (for "FunnelWeb Begin TeXt") macro does most of the hard work.
  185. % The liberal use of "%" is because I don't understand TeX well enough to
  186. % understand when an end of line will cause trouble, and I am playing it safe.
  187.  
  188. % Before defining the main \fwbtx macro, we have to stash away some definitions
  189. % in the hidden part of TeX's environment. Let's hope that these "hidden"
  190. % definitions don't affect anything except what is desired to be affected.
  191.  
  192. % The tt font in which we wish to set the text has two Latin lurking ligatures!
  193. % These are ?` and !`. To disable them, we define the left quote when ACTIVE
  194. % to be defined in such a way as to prevent ligatures. The main TeX text will
  195. % normally not be exposed to this definition because normally the leftquote
  196. % character is not active. The \fwbtx macro temporarily makes the left quote
  197. % character active thus activating the deactivation of left quote ligatures.
  198. % See The TeXbook p.381.
  199. {\catcode`\`=\active \gdef`{\relax\lq}}
  200.  
  201. % TeX is fairly carefree about spaces and so we have to make it more serious.
  202. % To do so we pull the same trick as above, setting up a definition for active
  203. % space, but only making space active during the span of the verbatim text.
  204. % In Plain TeX the active space is defined to be simply a space, but here we
  205. % define it to be a control space. This ensures that the space cannot
  206. % be gobbled up by one of TeX's mysterious mechanisms when activated.
  207. % See The TeXbook, p.381 and p.352.
  208. {\obeyspaces\global\let =\ }
  209.  
  210. % Here is the main \fwbtx verbatim text macro.
  211. % Note: The order in which all these pieces of business have to be done is
  212. % still a partial mystery to me. Don't fiddle with this stuff unless you
  213. % think you know what you are doing.
  214. \def\fwbtx[{%
  215. %
  216. % The funnies involved in getting verbatim output are safely housed inside
  217. % this \begingroup, and the \endgroup in \fwverbatimgobble. Groups are used
  218. % instead of curly braces because we have to be able to signal the end of
  219. % this macro with a curly brace.
  220. \begingroup%
  221. %
  222. % \pars at the end of empty lines in the verbatim text won't come out normally
  223. % because TeX is in vertical mode and they get gobbled up. To prevent this,
  224. % we force \par to exit vertical mode first. See The TeXbook p.381.
  225. \def\par{\leavevmode\endgraf}%
  226. %
  227. % Activate the leftquote character so as to avoid ligatures (see above).
  228. \catcode`\`=\active%
  229. %
  230. % The \obeylines macro simply defines end of line (^M) to be \par. This ensures
  231. % that TeX will treat each verbatim line as a new paragraph.
  232. \obeylines%
  233. %
  234. % To get verbatim output, we have to desex all the special characters. This
  235. % is explained in detail in The TeXbook p.380.
  236. \def\do##1{\catcode`##1=12 }\dospecials%
  237. %
  238. % Activate the space character so as to make TeX treat blanks seriously.
  239. % This activation invokes an eralier definition (see above).
  240. \obeyspaces
  241. %
  242. % Interparagraph skips do not help the cause.
  243. % Note: We have to preserve the indentation though, as the code is actually
  244. % indented in the final output. See \fwodef in an earlier section.
  245. \parskip=0pt%
  246. %
  247. % We typeset the verbatim text in tt font (courier on the Macintosh) for a
  248. % number of reasons:
  249. %    - tt font has the same horizontal spacing for each character.
  250. %    - tt font covers the ASCII character set.
  251. %    - tt font doesn't have many surprises (e.g. ligatures).
  252. %    - tt font looks much what you might see on a computer terminal screen.
  253. \tt%
  254. %
  255. % Having set up an environment for verbatim, we are ready to use it.
  256. % By invoking \fwverbatimgobble, this \fwbtx macro gobbles up text verbatim (as
  257. % part of the parameter of \fwverbatimgobble) until it sees the termination
  258. % string "]fwetx=" (the "=" was thrown in to add obscurity as this sequence
  259. % must never occur in the verbatim text).
  260. \fwverbatimgobble}
  261.  
  262. % The \fwverbatimgobble macro exists to allow \fwbtx to bracket verbatim text.
  263. \def\fwverbatimgobble#1]fwetx={#1\endgroup}
  264.  
  265.  
  266. % Table of Contents
  267. % -----------------
  268. % The five levels of table of contents that FunnelWeb supports are identified
  269. % by the five letters [A..E]. These are used throughout the following macros.
  270.  
  271. % The following macros are utilities to the TOC macros to follow.
  272. \def\fwrule{\medskip\hrule\medskip}
  273. \def\fwqh{\hskip1.5em\relax}
  274. \def\fwbeforesec{\penalty-200\bigskip\medskip\par}
  275.  
  276. % The following macros are used to typeset the table of contents.
  277. \def\fwtocstart#1{\fwrule\leftline{\fwfontbolda Table of Contents}\fwrule}
  278. \def\fwtoca#1#2{\leftline{{\bf #1 #2}}}
  279. \def\fwtocb#1#2{\leftline{\fwqh #1 #2}}
  280. \def\fwtocc#1#2{\leftline{\fwqh\fwqh #1 #2}}
  281. \def\fwtocd#1#2{\leftline{\fwqh\fwqh\fwqh #1 #2}}
  282. \def\fwtoce#1#2{\leftline{\fwqh\fwqh\fwqh\fwqh #1 #2}}
  283. \def\fwtocfinish#1{\fwrule}
  284.  
  285. % The following "library" macros define five different strengths of headings
  286. % which can be used later in the section macros.
  287. \def\fwliba#1#2{\vfill\eject{\fwfontboldc #1 #2}\penalty200\smallskip}
  288. \def\fwlibb#1#2{\fwbeforesec{\fwfontboldb #1 #2}\penalty200\smallskip}
  289. \def\fwlibc#1#2{\fwbeforesec{\fwfontnormb #1 #2}\penalty200\smallskip}
  290. \def\fwlibd#1#2{\fwbeforesec{\bf          #1 #2}\penalty200}
  291. \def\fwlibe#1#2{\fwbeforesec{\bf          #1 #2}}
  292.  
  293. % Here are the macros that actually typeset the section headings throughout
  294. % the document. The fwlib system has been employed so as to easily allow the
  295. % user to redefine the strengths of headings to taste. For example, the
  296. % user could insert in the input document a similar set of definitions to these
  297. % but with the b..e headings set to \fwlibc. This would tone down the output.
  298. \def\fwseca#1#2{\fwliba{#1}{#2}}
  299. \def\fwsecb#1#2{\fwlibb{#1}{#2}}
  300. \def\fwsecc#1#2{\fwlibc{#1}{#2}}
  301. \def\fwsecd#1#2{\fwlibd{#1}{#2}}
  302. \def\fwsece#1#2{\fwlibe{#1}{#2}}
  303.  
  304.  
  305. % Support for Explicit Typesetting
  306. % --------------------------------
  307. % FunnelWeb supports pragmas and other constructs that allow
  308. % typesetter-independent typesetting commands to be given. The
  309. % following macros support these features.
  310.  
  311. % The in-text literal @{sloth@} and emphasise @[walrus@] features.
  312. \def\fwlit#1{{\tt #1}}
  313. \def\fwemp#1{{\it #1}}
  314.  
  315. % The "@p new_page" pragma.
  316. \def\fwnewpage{\vfill\eject}
  317.  
  318. % The "@p vskip Nmm" pragma.
  319. \def\fwvskip#1{\null\vskip #1mm}
  320.  
  321. % The "@p title <font> <align> <text>" pragma.
  322. \def\fwfontnormal#1{{\fwfontnorm {#1}}}
  323. \def\fwfonttitle#1{{\fwfontboldd {#1}}}
  324. \def\fwfontsmalltitle#1{{\fwfontboldb {#1}}}
  325. \def\fwleftline#1{\leftline{#1}}
  326. \def\fwcenterline#1{\centerline{#1}}
  327. \def\fwrightline#1{\rightline{#1}}
  328.  
  329.  
  330. % Support for Old FunnelWeb
  331. % -------------------------
  332. % The following macros were used extensively in the first version of
  333. % FunnelWeb and are retained so that these older input files will still
  334. % typeset cleanly.
  335. \def\p#1{{\tt #1}}  % P for Program text.
  336. \def\flagpage#1#2{
  337.    \null
  338.    \vfill
  339.    \centerline{\fwfontboldd #1}
  340.    \vskip 1cm
  341.    \centerline{\fwfontboldd #2}
  342.    \vfill
  343.    \null
  344.    \vfill
  345. }
  346.  
  347. %====================== End of FunnelWeb TeX Definitions =======================
  348. EX12: This example gives some simple headings and demonstrates heading name
  349.       inheritance.
  350.  
  351. \fwbeginmacro
  352. \fwfilename{ex12.out}{1}\fwequals \fwodef \fwbtx[dummy text]fwetx=%
  353. \fwcdef 
  354. \fwbeginmacronotes
  355. \fwisafile{This macro is attached to an output file.}
  356. \fwendmacronotes
  357. \fwendmacro
  358.  
  359.  
  360. \fwseca{1}{Feed the Penguins and Save the World}
  361. \fwsecb{1.1}{Feed the Penguins}
  362. \fwsecc{1.1.1}{Feed the little penguins}
  363. \fwsecc{1.1.2}{Feed the big penguins}
  364. \fwsecb{1.2}{Save the World}
  365. \fwsecc{1.2.1}{Save Europe}
  366. \fwsecc{1.2.2}{Save Africa}
  367.  
  368. \fwsecc{1.2.3}{Save the rest of the world} This heading hasn't been given an explicit name, but will inherit the
  369. name $\backslash$p$\{$Save the rest of the world$\}$ from the macro definition below.
  370.  
  371. \fwbeginmacro
  372. \fwmacroname{Save the rest of the world}{2}\fwzero{}\fwequals \fwodef \fwbtx[...]fwetx=%
  373. \fwcdef 
  374. \fwbeginmacronotes
  375. \fwusedin{This macro is NEVER invoked.}
  376. \fwendmacronotes
  377. \fwendmacro
  378.  
  379. \bye
  380.  
  381.  
  382. %*******************************************************************************
  383. %*                    END OF AUTOMATICALLY GENERATED TEX FILE                  *
  384. %*******************************************************************************
  385.  
  386.