home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / texmf / inputs / distribs / doc / doc.doc < prev    next >
Encoding:
Text File  |  1992-09-08  |  187.0 KB  |  4,555 lines

  1. % \iffalse meta-comment
  2. %
  3. % Copyright (C) 1989-1992 by Frank Mittelbach.  All rights reserved.
  4. % This file is part of the doc package.
  5. % IMPORTANT NOTICE:
  6. % You are not allowed to change this file.  You may however copy
  7. % this file to a file with a different name and then change the
  8. % copy if you obey the restrictions on file changes described in
  9. % readme.mz.
  10. % You are NOT ALLOWED to distribute this file alone.  You are NOT
  11. % ALLOWED to take money for the distribution or use of this file
  12. % (or a changed version) except for a nominal charge for copying
  13. % etc.
  14. % You are allowed to distribute this file under the condition that
  15. % it is distributed together with all files mentioned in
  16. % readme.mz0.
  17. % If you receive only some of these files from someone, complain!
  18. % However, if these files are distributed by established suppliers
  19. % as part of a complete TeX distribution, and the structure of the
  20. % distribution would make it difficult to distribute the whole set
  21. % of files, *those parties* are allowed to distribute only some of
  22. % the files provided that it is made clear that the user will get
  23. % a complete distribution-set upon request to that supplier (not
  24. % me).  Notice that this permission is not granted to the end
  25. % user.
  26. % For error reports in case of UNCHANGED versions see readme.mz
  27. % \fi
  28. % ^^A -*-LaTeX-*-
  29.  
  30. % ^^A These shouldn't come out in .ist files, hence the module
  31. % ^^A comments, or in the printed version, hence temporary comment
  32. % ^^A category for `<'
  33. %\catcode`\<=14
  34. %<*style>
  35. \def\fileversion{v1.7k} 
  36. \def\filedate{92/08/24}
  37. \def\docdate {92/08/28}
  38. %</style>
  39. %\catcode`\<=12
  40.  
  41. % \CheckSum{1985}
  42. %% \CharacterTable
  43. %%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  44. %%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  45. %%   Digits        \0\1\2\3\4\5\6\7\8\9
  46. %%   Exclamation   \!     Double quote  \"     Hash (number) \#
  47. %%   Dollar        \$     Percent       \%     Ampersand     \&
  48. %%   Acute accent  \'     Left paren    \(     Right paren   \)
  49. %%   Asterisk      \*     Plus          \+     Comma         \,
  50. %%   Minus         \-     Point         \.     Solidus       \/
  51. %%   Colon         \:     Semicolon     \;     Less than     \<
  52. %%   Equals        \=     Greater than  \>     Question mark \?
  53. %%   Commercial at \@     Left bracket  \[     Backslash     \\
  54. %%   Right bracket \]     Circumflex    \^     Underscore    \_
  55. %%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  56. %%   Right brace   \}     Tilde         \~}
  57. %%
  58. %\iffalse    This is a METACOMMENT
  59. %           Everything up to the next `\ fi' (without a blank) will
  60. %           be ignored.  This is necessary because `%' may no longer
  61. %           be a comment mark when this file is read in.
  62. %           
  63.  
  64. % Style-option `doc' to use with LaTeX v2.09
  65. %% Copyright (C) 1989-1992 Frank Mittelbach, all rights reserved.
  66. %
  67. %
  68. % Version:     Date:     Changes:
  69. %
  70. %  1.0a        5.5.88    This is nothing but a collection of tests and
  71. %                        hacks. It is certainly going to be greatly
  72. %                        changed.
  73. %                        Better not to use it!
  74. %  1.1a        13.5.88   \theindex and \endtheindex redefined.
  75. %  1.1b        15.5.88   \bslash redefined.
  76. %                        \verbatim changed so that `%'s will be ignored.
  77. %  1.1c        19.5.88   Partly documented and \@temp... in
  78. %                        \theindex replaced by private commands.
  79. %                        Moreover, \pageshrink incorporated in the
  80. %                        computation of the amount of free space on the
  81. %                        page.
  82. %  1.1d        3.6.88    Something goes wrong during the computation of
  83. %                        \pageshrink, therefore a bit of empty space is
  84. %                        inserted by
  85. %                        hand, and some tracing information introduced.
  86. %                        It can't stay like that!!
  87. %  1.2a        23.9.88   Documentation of the macros in DOC-format,
  88. %                        i.e. so that this file can document itself.
  89. %  1.2b        7.10.88   Change of the index environment.
  90. %  1.2c        10.10.88  Further Documentation.
  91. %  1.2d        19.10.88  \the before \catcode eliminated. (thanks P.
  92. %                        Breitenlohner)
  93. %  1.3a        24.10.88  Scanning of macro names via \scanmacro
  94. %                        introduced to produce index entries.
  95. %  1.3b         16.1.89  Scanning of macro names via \scanmacro
  96. %                        improved.
  97. %                        At present only suitable for the makeindex
  98. %                        program
  99. %                        in conjunction with a special style file.
  100. %                        Macro environment in `macro' environment
  101. %                        renamed.
  102. %  1.3c         30.1.89  Index environment removed. Will be developed in
  103. %                        other style file.
  104. %  1.4a         7.2.89   \SpecialEscapechar added (may change its name).
  105. %  1.4b         7.3.89   \SpecialEscapechar reimplemented.
  106. %  1.4c         9.3.89   \parts of \short@macro reimplemented because
  107. %                        of some bugs in the macros and the makeindex
  108. %                        program.
  109. %                        Old definition of \b@slash used for \bslash.
  110. %                        \b@slash removed.
  111. %  1.4d         10.3.89  English documentation added.
  112. %  1.4e         10.3.89  private names for private macros.
  113. %                        \makespecialletters renamed to
  114. %                        \MakePrivateLetters
  115. %  1.4f         12.3.89  \short@macro changed (again)
  116. %                        documentation update.
  117. %  1.4g         13.3.89  \DoNotIndex macros changed.
  118. %  1.4h         13.3.89  \DoNotIndex macros changed to version with
  119. %                        \@elt
  120. %  1.4i         15.3.89  documentation update
  121. %  1.4j         15.3.89  \printindex inserted
  122. %  1.4k         21.3.89  documentation update
  123. %                        \PrintDescribe... and \Describe... added
  124. %                        macro env. + \SpecialIndex changed to accept \
  125. %  1.4l         29.3.89  macro env. changed once more (\macro@ added) to
  126. %                        correct bug introduced in v1.4k
  127. %                        \SpecialUsageIndex and \SpecialEnvIndex added.
  128. %  1.4m          3.4.89  \OnlyDescription added, \MakePrivateLetters
  129. %                        changed
  130. %  1.4n         10.4.89  \MakePrivateLetters changed back to
  131. %                        \makeatletter.
  132. %                        \ifnot@excluded changed to allow other things
  133. %                        than
  134. %                        macro names in the exclude list (e.g. \abc*)
  135. %  1.4o         14.4.89  Documentation update (Brian's correction)
  136. %                        \EnableCrossrefs changed to disable
  137. %                        \DisableCrossrefs
  138. %  1.4p         15.4.89  Documentation update \Finale added,
  139. %                        some changes to index.tex 
  140. %  1.4q         19.4.89  Documentation update \verbatim changed (RmS)
  141. %                        twocolumns env. added index.tex changed.
  142. %  1.4r         22.4.89  Changed \macro@ to support \par and
  143. %                        conditionals (might be wrong.)
  144. %  1.4s         23.4.89  Getting nearer to the `final' version.
  145. %                        \@sphack ...
  146. %                        placed in several macros. Documentation update.
  147. %                        Tried a \changes macro (somewhere in the middle
  148. %                        of this file by using \glossary (might work!)
  149. %  1.4t         24.4.89  Should change to 1.5? Index now uses multicols
  150. %                        added \c@IndexColumns. Other changes forgotten.
  151. %                        Some macro names renamed.
  152. %  1.5a         26.4.89  Finally 1.5:  changes to \makelabel in macro
  153. %                        env.
  154. %  1.5b and higher...    are documented with the (undocumented) \changes
  155. %                        feature.
  156. %  \changes{v1.5f}{89/4/29}{Thanks to Brian who documented the
  157. %                          {\tt\bslash changes} macro feature.}
  158. %  \changes{v1.5g}{89/5/07}{MacroTopsep now called MacrocodeTopsep and
  159. %                          new MacroTopsep added}
  160. %  \changes{v1.5h}{89/05/17}{All lines shortened to <72 characters}
  161. %  \changes{v1.5j}{89/06/09}{Corrections by Ron Whitney added}
  162. %  \changes{v1.5q}{89/11/03}{`\ldots{}Listing macros renamed to
  163. %                         `\ldots{}Input. Suggested by R. Wonneberger}
  164. %  \changes{v1.5W}{90/02/05}{Counter codelineno renamed to CodelineNo}
  165. %                        
  166. %
  167. %\fi
  168. %
  169. % \hyphenation{make-index}
  170. % \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty}
  171. % \DoNotIndex{\@flushglue,\@gobble,\@input}
  172. % \DoNotIndex{\@makefnmark,\@makeother,\@maketitle}
  173. % \DoNotIndex{\@namedef,\@ne,\@spaces,\@tempa}
  174. % \DoNotIndex{\@tempb,\@tempswafalse,\@tempswatrue}
  175. % \DoNotIndex{\@thanks,\@thefnmark,\@topnum}
  176. % \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa,\@totalleftmargin}
  177. % \DoNotIndex{\",\/,\@ifundefined,\@nil,\@verbatim,\@vobeyspaces}
  178. % \DoNotIndex{\|,\~,\ ,\active,\advance,\aftergroup,\begingroup,\bgroup}
  179. % \DoNotIndex{\cal,\csname,\def,\documentstyle,\dospecials,\edef}
  180. % \DoNotIndex{\egroup}
  181. % \DoNotIndex{\else,\endcsname,\endgroup,\endinput,\endtrivlist}
  182. % \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef,\global}
  183. % \DoNotIndex{\hbox,\hss,\if,\if@inlabel,\if@tempswa,\if@twocolumn}
  184. % \DoNotIndex{\ifcase}
  185. % \DoNotIndex{\ifcat,\iffalse,\ifx,\ignorespaces,\index,\input,\item}
  186. % \DoNotIndex{\jobname,\kern,\leavevmode,\leftskip,\let,\llap,\lower}
  187. % \DoNotIndex{\m@ne,\next,\newpage,\nobreak,\noexpand,\nonfrenchspacing}
  188. % \DoNotIndex{\obeylines,\or,\protect,\raggedleft,\rightskip,\rm,\sc}
  189. % \DoNotIndex{\setbox,\setcounter,\small,\space,\string,\strut}
  190. % \DoNotIndex{\strutbox}
  191. % \DoNotIndex{\thefootnote,\thispagestyle,\topmargin,\trivlist,\tt}
  192. % \DoNotIndex{\twocolumn,\typeout,\vss,\vtop,\xdef,\z@}
  193. % \DoNotIndex{\,,\@bsphack,\@esphack,\@noligs,\@vobeyspaces,\@xverbatim}
  194. % \DoNotIndex{\`,\catcode,\end,\escapechar,\frenchspacing,\glossary}
  195. % \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht,\it,\langle}
  196. % \DoNotIndex{\leaders,\long,\makelabel,\marginpar,\markboth,\mathcode}
  197. % \DoNotIndex{\mathsurround,\mbox,\newcount,\newdimen,\newskip}
  198. % \DoNotIndex{\nopagebreak}
  199. % \DoNotIndex{\parfillskip,\parindent,\parskip,\penalty,\raise,\rangle}
  200. % \DoNotIndex{\section,\setlength,\TeX,\topsep,\underline,\unskip,\verb}
  201. % \DoNotIndex{\vskip,\vspace,\widetilde,\\,\%,\@date,\@defpar}
  202. % \DoNotIndex{\[,\{,\},\]}
  203. % \DoNotIndex{\count@,\ifnum,\loop,\today,\uppercase,\uccode}
  204. % \DoNotIndex{\baselineskip,\begin,\tw@}
  205. % \DoNotIndex{\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k,\l,\m,\n,\o,\p,\q}
  206. % \DoNotIndex{\r,\s,\t,\u,\v,\w,\x,\y,\z,\A,\B,\C,\D,\E,\F,\G,\H}
  207. % \DoNotIndex{\I,\J,\K,\L,\M,\N,\O,\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z}
  208. % \DoNotIndex{\1,\2,\3,\4,\5,\6,\7,\8,\9,\0}
  209. % \DoNotIndex{\!,\#,\$,\&,\',\(,\),\+,\.,\:,\;,\<,\=,\>,\?,\_}
  210. % \DoNotIndex{\discretionary,\immediate,\makeatletter,\makeatother}
  211. % \DoNotIndex{\meaning,\newenvironment,\par,\relax,\renewenvironment}
  212. % \DoNotIndex{\repeat,\scriptsize,\selectfont,\the,\undefined}
  213. % \DoNotIndex{\arabic,\do,\makeindex,\null,\number,\show,\write,\@ehc}
  214. % \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title,\everypar}
  215. % \DoNotIndex{\if@minipage,\if@restonecol,\ifeof,\ifmmode}
  216. % \DoNotIndex{\lccode,\newtoks,\onecolumn,\openin,\p@,\SelfDocumenting}
  217. % \DoNotIndex{\settowidth,\@resetonecoltrue,\@resetonecolfalse,\bf}
  218. % \DoNotIndex{\clearpage,\closein,\lowercase,\@inlabelfalse}
  219. % \DoNotIndex{\selectfont,\mathcode,\newmathalphabet,\rmdefault}
  220. % \DoNotIndex{\bfdefault}
  221. %
  222. % \MakeShortVerb{\"}
  223. % \setcounter{StandardModuleDepth}{1}
  224. %
  225. % {\catcode`\p=12 \catcode`\t=12 ^^A hack used later on to print
  226. % \gdef\dimenvalue#1pt{$#1$pt}}  ^^A a register value with a - sign
  227. %
  228. % \makeatletter  ^^A hack so that this can be printed without multicols
  229. % \newif \ifmulticols
  230. % \ifhave@multicol \multicolstrue \fi
  231. % \makeatother
  232. % \title{The {\tt doc}--Option\thanks{%
  233. %    This file has version number \fileversion{} dated \filedate{}.
  234. %    The documentation was last revised on \docdate.
  235. %       }}
  236. % \author{Frank Mittelbach\thanks{Further commentary added at Royal
  237. %        Military College of Science by B. Hamilton Kelly; English
  238. %        translation of parts of the original German commentary
  239. %        provided by Andrew Mills; fairly substantial additions,
  240. %        particularly from {\tt newdoc},  and
  241. %        documentation of post-v1.5q features added at v1.7a by Dave
  242. %        Love (SERC Daresbury Lab).}\\
  243. %         Gutenberg Universit\"at Mainz}
  244. %
  245. % \maketitle
  246. %
  247. % \begin{abstract}
  248. %    This style option contains the definitions that are necessary to
  249. %    format the documentation of style files.  The style file was
  250. %    developed in Mainz in cooperation with the Royal Military College
  251. %    of Science.  This is an update which documents various changes
  252. %    and new features in {\sf doc} and integrates the features of {\sf
  253. %    newdoc}. 
  254. % \end{abstract}
  255. %
  256. % \ifmulticols
  257. % \addtocontents{toc}{\protect\begin{multicols}{2}}
  258. % \fi
  259. %
  260. % {\parskip 0pt                ^^A We have to reset \parskip
  261. %                              ^^A (bug in \LaTeX)
  262. % \tableofcontents
  263. % }
  264. %
  265. % \changes{v1.7a}{92/02/25}{Miscellaneous small changes to the text}
  266. %
  267. % \ifmulticols
  268. % \begin{multicols}{2}[\section*{Preface to version 1.7}]
  269. % \else \section*{Preface to version 1.7} \fi
  270. %
  271. % This version of {\tt doc.doc} documents changes which have occurred
  272. % since the last published version \cite{art:doc} but which have been
  273. % present in distributed versions of {\tt doc.sty} for some time.  It
  274. % also integrates the (undocumented) features of the distributed {\tt
  275. % newdoc.sty}. 
  276. %
  277. % The following changes and additions have been made to the user
  278. % interface since the published version~\cite{art:doc}.  See
  279. % \S\ref{sec:interface} for more details. 
  280. % \begin{description}
  281. % \item[Driver mechanism] "\DocInput" is now used in the driver file
  282. % to input possibly multiple independent {\tt doc} files and {\tt doc}
  283. % no longer has to be the last style option.  "\IndexListing" is
  284. % replaced by "\IndexInput";
  285. % \item[Indexing] is controlled by "\PageIndex" and
  286. % "\CodelineIndex", one of which must be specified to produce an
  287. % index---there is no longer a "\makeindex" in the default
  288. % "\DocstyleParms";
  289. % \item[The {\tt macro} environment] now takes as argument the macro
  290. % name {\em with\/} the backslash;
  291. % \item[Verbatim text] Newlines are now forbidden inside "\verb" and
  292. % commands "\MakeShortVerb" and "\DeleteShortVerb" are provided for
  293. % verbatim shorthand;
  294. % \item[{\tt \bslash par}] can now be used in "\DoNotIndex";
  295. % \item[Checksum/character table support] for ensuring the
  296. % integrity of distributions is added;
  297. % \item[{\tt \bslash printindex}] becomes "\PrintIndex";
  298. % \item[{\tt multicol.sty}] is no longer necessary to use {\tt doc} or
  299. % print the documentation (although it is recommended);
  300. % \item[`Docstrip' modules] are recognised and formatted specially.
  301. % \end{description}
  302. %
  303. % As well as adding some completely new stuff,
  304. % the opportunity has been taken to add some commentary to the code
  305. % formerly in {\tt newdoc.sty} and that added after version 1.5k of
  306. % {\tt doc.sty}.  Since (as noted in the sections concerned) this
  307. % commentary wasn't written by Frank Mittelbach but the code was, it is
  308. % probably {\em not\/} true in this case that ``if the code and
  309. % comments disagree both are probably wrong''!
  310. %
  311. % \subsection*{Bugs}
  312. %
  313. % There are some known bugs in this version:
  314. % \begin{itemize}
  315. % \item The `General changes' glossary entry would come out after
  316. %    macro names with a leading "!" and possibly a leading \verb+"+;
  317. % \item If you have an old version of {\sf makeindex} long "\changes"
  318. %    entries will come out strangely and you may find the section
  319. %    header amalgamated with the first changes entry.  Try to get an
  320. %    up-to-date one (see p.~\pageref{makeindex:version});
  321. % \item Because the accompanying {\sf makeindex} style files support
  322. %    the inconsistent attribute specifications of older and newer
  323. %    versions {\sf makeindex} always complains about three `unknown
  324. %    specifier's when sorting the index and changes entries.
  325. % \item If "\MakeShortVerb" and "\DeleteShortVerb" are used with
  326. %    single character arguments, e.g., "{|}" instead of "{\|}" chaos
  327. %    may happen.
  328. % \end{itemize}
  329. % (Some `features' are documented below.)
  330. %
  331. % \subsection*{Wish list}
  332. %
  333. % \begin{itemize}
  334. % \item Hooks to allow "\DescribeMacro" and "\DescribeEnv" to write
  335. % out to a special file information about the style's `exported'
  336. % definitions which they describe.  This could subsequently be
  337. % included in the {\tt docstrip}ped {\tt .sty} file in a suitable form
  338. % for use by smart editors in command completion, spelling checking
  339. % etc., based on the style options of a document.  This would need
  340. % agreement on a `suitable form'.
  341. % \item Indexing of the modules used in {\tt docstrip}'s "%<"
  342. % directives.  I'm not sure how to index directives containing
  343. % module combinations;
  344. % \item Writing out bibliographic information about the style;
  345. % \item Allow turning off use of the special font for, say, the next
  346. % guarded block.
  347. % \end{itemize}
  348. %
  349. % \ifmulticols
  350. % \end{multicols}
  351. % \begin{multicols}{2}[\medskip \rule{\textwidth}{.3pt}
  352. %                      \section{Introduction}]
  353. % \else
  354. % \section{Introduction}
  355. % \fi
  356. %
  357. % The \TeX{} macros which are described here allow definitions and
  358. % documentation to be held in one and the same file.  This has the
  359. % advantage that normally very complicated instructions are made
  360. % simpler to understand by comments inside the definition. In addition
  361. % to this, updates are easier and only one source file needs to be
  362. % changed.  On the other hand, because of this, the style files are
  363. % considerably longer: thus \TeX{} takes longer to load them.  If this
  364. % is a problem, there is an easy remedy: one needs only to run the
  365. % {\tt docstrip.tex} program that removes nearly all lines that begin
  366. % with a
  367. % percent sign.
  368. %
  369. % The idea of integrated documentation was born with the development
  370. % of the \TeX{} program; it was crystallized in Pascal with the \Web{}
  371. % system.  The advantages of this method are plain to see (it's easy
  372. % to make comparisons \cite{art:Knuthliterat}).  Since this
  373. % development, systems similar to \Web{} have been developed for other
  374. % programming languages. But for one of the most complicated
  375. % programming languages (\TeX) the documentation has however been
  376. % neglected.  The \TeX{} world seems to be divided between:---
  377. % \begin{itemize} \item a couple of ``wizards'', who produce many
  378. % lines of completely unreadable code ``off the cuff'', and \item many
  379. % users who are amazed that it works just how they want it to do.  Or
  380. % rather, who despair that certain macros refuse to do what is
  381. % expected of them.\end{itemize}
  382. %
  383. % I do not think that the \Web{} system is {\em the\/} reference work;
  384. % on the contrary, it is a prototype which suffices for the
  385. % development of programs within the \TeX{} world.  It is sufficient,
  386. % but not totally sufficient.\footnote{I know that this will be seen
  387. % differently by a few people, but this product should not be seen as
  388. % the finished product, at least as far as applications concerning
  389. % \TeX{} are concerned.  The long-standing debate over `multiple
  390. % change files' shows this well.} As a result of \Web, new programming
  391. % perspectives have been demonstrated; unfortunately, though, they
  392. % haven't been developed further for other programming languages.
  393. %
  394. % The method of documentation of \TeX{} macros which I have introduced
  395. % here should also only be taken as a first sketch.  It is designed
  396. % explicitly to run under \LaTeX{} alone.  Not because I was of the
  397. % opinion that this was the best starting point, but because from this
  398. % starting point it was the quickest to develop.\footnote{This
  399. % argument is a bad one, however, it is all too often trotted out.} As
  400. % a result of this design decision, I had to move away from the
  401. % concept of modularization; this was certainly a step backward.
  402. %
  403. % I would be happy if this article could spark off discussion over
  404. % \TeX\ documentation.  I can only advise anyone who thinks that they
  405. % can cope without documentation to ``Stop Time'' until he or she
  406. % completely understands the \AmSTeX{} source code.
  407. %
  408. %
  409. %
  410. %
  411. %
  412. % \subsection{Using the {\sf doc} style option}
  413. %
  414. % Just like any other option, invoke it by including it amongst the
  415. % style options in the optional parameter list for the
  416. % \verb+\documentstyle+ command.  {\sf Doc}'s use of
  417. % \verb+\reversemarginpars+ may make it incompatible with some style
  418. % options.
  419. % \changes{v1.7a}{92/02/25}{Altered usage info}
  420. %
  421. % \ifmulticols\end{multicols}\fi
  422. %
  423. %
  424. % \section{The User Interface}\label{sec:interface}
  425. % \subsection{The driver file}
  426. %
  427. % If one is going to document a set of macros with the {\tt doc}
  428. % option one has to prepare a special driver file which produces the
  429. % formatted document. This driver file has the following
  430. % characteristics:
  431. % \noindent \verb+\documentstyle[+\meta{options}]^^A
  432. %           \verb+{+\meta{document-style}\verb+}+\\[3pt]
  433. % \hspace*{10pt}\meta{preamble}\\[3pt]
  434. % \verb+\begin{document}+\\[3pt]
  435. % \hspace*{10pt}\meta{special input commands}\\[3pt]
  436. % \verb+\end{document}+
  437. %
  438. % The list of \meta{options} must contain the {\tt doc} option but it
  439. % is not necessary any longer to put this option on the end of the
  440. % list.
  441. %
  442. % The \meta{document-style} might be any document style, I normally
  443. % use {\tt article}.
  444. % In the \meta{preamble} one should place declarations which
  445. % manipulate the behavior of the {\tt doc} option like
  446. % \verb+\DisableCrossrefs+ or \verb+\OnlyDescription+.
  447. %
  448. % \DescribeMacro\DocInput \DescribeMacro\IndexInput
  449. % Finally the \meta{special input commands} part should contain one or
  450. % more \verb+\DocInput+\meta{file name} and/or
  451. % \verb+\IndexInput+\meta{file name} commands.  The
  452. % \verb+\DocInput+ command is used for files prepared for the {\tt
  453. % doc} option whereas \verb+\IndexInput+ can be used for all kinds of
  454. % macro files.  See page \pageref{..Input} for more details of
  455. % "\IndexInput".  Multiple "\DocInput"s can be used with a
  456. % number of included files which are each self-contained
  457. % self-documenting styles---for instance, each containing
  458. % "\maketitle". 
  459. %
  460. % As an example, the driver file for the {\tt doc} option itself is
  461. % derived from the following text.  This is meant to be extracted by
  462. % the {\tt docstrip} program which will remove the leading "<+driver>"
  463. % indicating the `module'; the line numbers are added by {\tt
  464. % doc}'s formatting.
  465. % \changes{v1.7a}{92/03/06}{Added docstrip-derivable driver file as
  466. %                           example.}
  467. % \changes{v1.7c}{92/04/01}{Expurgated ltugboat.sty from driver.}
  468. %    \begin{macrocode}
  469. %<+driver>\documentstyle[doc]{article}
  470. %<+driver>% dimensions from ltugboat.sty:
  471. %<+driver>\setlength\textwidth{31pc} \setlength\textheight{54pc}
  472. %<+driver>\setlength{\parindent}{0pt} 
  473. %<+driver>\setlength{\parskip}{2pt plus 1pt minus 1pt}
  474. %<+driver>\setlength{\oddsidemargin}{8pc} 
  475. %<+driver>\setlength{\marginparwidth}{8pc}
  476. %<+driver>\setlength{\topmargin}{-2.5pc} 
  477. %<+driver>\setlength{\headsep}{20pt}
  478. %<+driver>\setlength{\columnsep}{1.5pc} 
  479. %<+driver>\setlength{\columnwidth}{18.75pc}
  480. %<+driver>\EnableCrossrefs         
  481. %<+driver>%\DisableCrossrefs % Say \DisableCrossrefs if index is ready
  482. %<+driver>\RecordChanges                  % Gather update information
  483. %<+driver>\CodelineIndex                  % Index code by line number
  484. %<+driver>%\OnlyDescription  % comment out for implementation details
  485. %<+driver>%\OldMakeindex     % use if your MakeIndex is pre-v2.9
  486. %<+driver>\begin{document}
  487. %<+driver>   \DocInput{doc.doc}
  488. %<+driver>\end{document}
  489. %    \end{macrocode}
  490. %^^A As an example this is the driver file for the {\tt doc} option
  491. %^^A itself: 
  492. %^^A\begin{verbatim}
  493. %^^A\documentstyle[ltugboat,doc]{article}
  494. %^^A
  495. %^^A %  \DisableCrossrefs     % Say \DisableCrossrefs if the index
  496. %^^A                          % is ready.
  497. %^^A
  498. %^^A    \RecordChanges        % Gather update-information
  499. %^^A
  500. %^^A %  \OnlyDescription      % Remove the comment char if you only want
  501. %^^A                          % the description
  502. %^^A
  503. %^^A\SelfDocumenting          % Tugbot style macro (for doc)
  504. %^^A
  505. %^^A\begin{document}
  506. %^^A
  507. %^^A   \DocInput{doc.doc}
  508. %^^A
  509. %^^A\end{document}
  510. %^^A\end{verbatim}
  511. %
  512. % \changes{v1.7a}{92/02/25}{Note on avoiding driver file}
  513. % \subsection{Avoiding using a driver file}
  514. %
  515. % It is possible to dispense with a driver file at the expense of some
  516. % flexibility using the following trick.\footnote{Due to David
  517. % Carlisle, Manchester University.}  Before the documentation part of
  518. % the file starts, include (without leading "%"s!)\ something like
  519. % \begin{verbatim}
  520. %\ifcat a\noexpand @\let\next\relax\else\def\next{%
  521. %    \documentstyle[doc]{article}\MakePercentIgnore}\fi\next
  522. %\end{verbatim}
  523. % with any necessary extra style options included, of course.  Then
  524. % the file can either be used directly as a style file as normal or
  525. % have the documentation printed simply by using
  526. % "latex"~\meta{filename}.  You can also arrange to have this process
  527. % ask questions about whether to format only the usage section, for
  528. % instance. 
  529. %
  530. % \subsection{General conventions}
  531. %
  532. % A \TeX{} file prepared to be used with the `doc' style option
  533. % consists of `documentation parts' intermixed with `definition
  534. % parts'.
  535. %
  536. % Every line of a `documentation part' starts with a percent sign
  537. % (\verb+%+) in column one.  It may contain arbitrary \TeX{} or
  538. % \LaTeX{} commands except that the character `\verb+%+' cannot be
  539. % used as a comment character.
  540. % \SortIndex{\string^\string^A}{\string\verb\verbatimchar
  541. % \string^\string^A\verbatimchar \encapchar usage} To allow user
  542. % comments, the \verb+^^A+ character is defined as a comment character
  543. % later on.  Such `metacomments' may be also be included simply by
  544. % surrounding them with "\iffalse" \ldots~"\fi".
  545. %
  546. % All other parts of the file are called `definition parts'.  They
  547. % contain fractions of the macros described in the `documentation
  548. % parts'.
  549. %
  550. % If the file is used to define new macros (e.g.\ as a style file in
  551. % the \verb+\documentstyle+ macro), the `documentation parts' are
  552. % bypassed at high speed and the macro definitions are pasted
  553. % together, even if they are split into several `definition parts'.
  554. %
  555. % \DescribeEnv{macrocode}
  556. % On the other hand, if the documentation of these macros is to be
  557. % produced, the `definition parts' should be typeset verbatim. To
  558. % achieve this, these parts are surrounded by the {\sf macrocode}
  559. % environment.
  560. % More exactly: before a `definition part' there should be a line
  561. % containing\\
  562. % \hspace*{\MacroIndent}\verb*+%    \begin{macrocode}+\\
  563. % and after this part a line\\
  564. % \hspace*{\MacroIndent}\verb*+%    \end{macrocode}+\\
  565. % There must be {\em exactly\/} four spaces between the \verb+%+
  566. % and \verb+\end{macrocode}+ --- \TeX{} is looking for this string
  567. % and not for the macro while processing a `definition part'.
  568. %
  569. % Inside a `definition part' all \TeX{} commands are allowed; even the
  570. % percent sign could be used to suppress unwanted spaces etc.
  571. %
  572. % \DescribeEnv{macrocode*}
  573. % Instead of the {\sf macrocode} environment one can also use the {\sf
  574. % macrocode$*$} environment which produces the same results except
  575. % that spaces are printed as \nopagebreak\verb*+ + characters.
  576. %
  577. %
  578. %
  579. % \subsection{Describing the usage of new macros}
  580. %
  581. % \DescribeMacro\DescribeMacro
  582. % When you describe a new macro you may use \verb+\DescribeMacro+ to
  583. % indicate that at this point the usage of a specific macro is
  584. % explained. It takes one argument which will be printed in the margin
  585. % and also produces a special index entry.  For example, I used
  586. % \verb+\DescribeMacro{\DescribeMacro}+ to make clear that this is the
  587. % point where the usage of \verb+\DescribeMacro+ is explained.
  588. %
  589. % \DescribeMacro\DescribeEnv
  590. % An analogous macro \verb+\DescribeEnv+ should be used to indicate
  591. % that a \LaTeX{} environment is explained. It will produce a somewhat
  592. % different index entry. Below I used \verb+\DescribeEnv{verbatim}+.
  593. %
  594. % \DescribeEnv{verbatim}
  595. % It is often a good idea to include examples of the usage of new macros
  596. % in the text. Because of the \verb+%+ sign in the first column of every
  597. % row, the {\sf verbatim} environment is slightly altered to suppress
  598. % those
  599. % characters.\footnote{These macros were written by Rainer
  600. %                      Sch\"opf~\cite{art:verbatim}. He also
  601. %                      provided a new {\sf verbatim} environment which
  602. %                      can be used inside of other macros.}
  603. % \DescribeEnv{verbatim*}
  604. % The {\sf verbatim$*$} environment is changed in the same way.
  605. % \changes{v1.7a}{92/02/26}{Documented `verb change.}
  606. % \DescribeMacro\verb
  607. % The "\verb" command is re-implemented to give an error report if a
  608. % newline appears in its argument. 
  609. % The {\sf verbatim} and {\sf verbatim$*$} environments set text in
  610. % the style defined by "\MacroFont"~(\S\ref{sec:macrofont}).
  611. %
  612. %
  613. %
  614. % \subsection{Describing the definition of new macros}
  615. %
  616. % \DescribeEnv{macro}
  617. % To describe the definition of a new macro we use the {\sf macro}
  618. % environment. It has one argument: the name of the new
  619. % macro.\footnote{This is a change to the style design I described in
  620. %                ^^A \TUB ^^A removed in case ltugboat.sty not used
  621. %                {\sl TUGboat\/}\ 10\#1 (Jan.~89). We finally decided
  622. %                that it would 
  623. %                be better to use the macro name {\em with\/} the
  624. %                backslash as an argument.}
  625. % This argument is also used to print the name in the margin and to
  626. % produce an index entry.
  627. % Actually the index entries for usage and definition are different to
  628. % allow an easy reference.
  629. % This environment might be nested. In this case the
  630. % labels in the margin are placed under each other.
  631. % \changes{v1.7a}{92/02/26}{Note on need for some text in macro env.}
  632. % There should be some text---even  if it's just an empty
  633. % "\mbox{}"---in this environment before "\begin{macrocode}" or the
  634. % marginal label won't print in the right place. 
  635. %
  636. % \DescribeMacro\MacrocodeTopsep
  637. % \DescribeMacro\MacroTopsep
  638. % There also exist four style parameters: \verb+\MacrocodeTopsep+ and
  639. % \verb+\MacroTopsep+ are used to control the vertical spacing above
  640. % and below the {\sf macrocode} and the {\sf macro}
  641. % \DescribeMacro\MacroIndent
  642. % environment, \verb+\MacroIndent+ is used to indent the lines of code
  643. % and
  644. % \DescribeMacro\MacroFont \label{sec:macrofont}
  645. % \verb+\MacroFont+ holds the font and a possible size change command
  646. % for the code lines, the "verbatim"["*"] environment and the macro
  647. % names printed in the margin.  If you want
  648. % to change their default values in a 
  649. % style file (like {\tt ltugboat.sty}) use the \verb+\DocstyleParms+
  650. % command described below.
  651. %
  652. %
  653. %
  654. %
  655. % \subsection{Formatting the margins}
  656. %
  657. % \DescribeMacro\PrintDescribeMacro
  658. % \DescribeMacro\PrintDescribeEnv
  659. % \DescribeMacro\PrintMacroName
  660. % As mentioned earlier, some macros and the {\sf macro} environment
  661. % print their arguments in the margin. This is actually done by three
  662. % macros which are user
  663. % definable.\footnote{You may place the changed definitions in a
  664. %                     separate style
  665. %                     file or at the beginning of the documentation
  666. %                     file.
  667. %                     For example, if you don't like any names in the
  668. %                     margin
  669. %                     but want a fine index you can simply
  670. %                     {\tt \bslash let}
  671. %                     these macros equal {\tt \bslash @gobble}.
  672. %                     The doc style option won't redefine any existing
  673. %                     definitions of these macros.}
  674. % They are named \verb+\PrintDescribeMacro+, \verb+\PrintDescribeEnv+
  675. % and \verb+\PrintMacroName+ (called by the {\sf macro} environment).
  676. %
  677. %
  678. % \subsection{Using a special escape character}
  679. %
  680. % \DescribeMacro\SpecialEscapechar
  681. % If one defines complicated macros it is sometimes necessary to
  682. % introduce a new escape character because the `\verb+\+' has got a
  683. % special \verb+\catcode+. In this case one can use
  684. % \verb+\SpecialEscapechar+ to indicate which character is actually
  685. % used to play the r\^ole of the `\verb+\+'. A scheme like this is
  686. % needed because the {\sf macrocode} environment and its counterpart
  687. % {\sf macrocode$*$} produce an index entry for every occurrence of a
  688. % macro name. They would be very confused if you didn't tell them that
  689. % you'd changed \verb+\catcode+$\,$s.  The argument to
  690. % \verb+\SpecialEscapechar+ is a single-letter control sequence, that
  691. % is, one has to use \verb+\|+ for example to denote that `\verb+|+'
  692. % is used as an escape character. \verb+\SpecialEscapechar+ only
  693. % changes the behavior of the next {\sf macrocode} or {\sf
  694. % macrocode$*$} environment.
  695. %
  696. %  The actual index entries created will all be printed with \verb+\+
  697. % rather than \verb+|+, but this probably reflects their usage, if not
  698. % their definition, and anyway must be preferable to not having any
  699. % entry at all.  The entries {\em could\/} be formatted appropriately,
  700. % but the effort is hardly worth it, and the resulting index might be
  701. % more confusing (it would certainly be longer!).
  702. %
  703. %
  704. % \subsection{Cross-referencing all macros used}
  705. %
  706. % \DescribeMacro\DisableCrossrefs
  707. % \DescribeMacro\EnableCrossrefs
  708. % As already mentioned, every new macro name used within a {\sf
  709. % macrocode} or {\sf macrocode$*$} environment will produce an index
  710. % entry. In this way one can easily find out where a specific macro is
  711. % used.  Since \TeX{} is considerably slower when it has to produce
  712. % such a bulk of index entries one can turn off this feature by using
  713. % \verb+\DisableCrossrefs+ in the driver file. To turn it on again
  714. % just use
  715. % \verb+\EnableCrossrefs+.\footnote{Actually,
  716. %          {\tt\bslash EnableCrossrefs}
  717. %          changes things more drastically; any following
  718. %          {\tt\bslash DisableCrossrefs}
  719. %          which might be present in the source will be ignored.}
  720. %
  721. %
  722. % \DescribeMacro\DoNotIndex
  723. % But also finer control is provided. The \verb+\DoNotIndex+ macro
  724. % takes a list of macro names separated by commas. Those names won't
  725. % show up in the index. You might use several \verb+\DoNotIndex+
  726. % commands: their lists will be concatenated.  In this article I used
  727. % \verb+\DoNotIndex+ for
  728. % all macros which are already defined in \LaTeX.
  729. %
  730. % All three above declarations are local to the current group.
  731. %
  732. % Production (or not) of the index (via the "\makeindex" commend) is
  733. % controlled by using or omitting the following declarations in the
  734. % driver file preamble; if neither is used, no index is produced.
  735. % \DescribeMacro\PageIndex Using "\PageIndex" makes all index
  736. % entries refer to their page number; with
  737. % \DescribeMacro\CodelineIndex "\CodelineIndex", index entries
  738. % produced by "\DescribeMacro" and "\DescribeEnv" refer to page number
  739. % but those produced by the {\sf macro} environment refer to the
  740. % code lines, which will be numbered automatically.\footnote{The line
  741. % number is actually that of the first line of the first {\sf
  742. % macrocode} environment in the {\sf macro} environment.}
  743. % \DescribeMacro\theCodelineNo
  744. % The style of this numbering can be controlled by defining the macro
  745. % "\theCodelineNo".  Its default definition is to use scriptsize
  746. % arabic numerals; a user-supplied definition won't be overwritten.
  747. %
  748. %
  749. % \subsection{Producing the actual index entries}
  750. %
  751. % Several of the aforementioned macros will produce some sort of index
  752. % entries. These entries have to be sorted by an external
  753. % program---the current implementation assumes that the {\sf
  754. % makeindex} program by Chen~\cite{art:Chen} is used.
  755. %
  756. % But this isn't built in: one has only to redefine some of the
  757. % following macros to be able to use any other index program.  All
  758. % macros which are installation 
  759. % dependent are defined in such a way that they won't overwrite a
  760. % previous definition. Therefore it is safe to put the changed
  761. % versions in a style file which might be read in before the doc style
  762. % option.
  763. %
  764. %  To allow the user to change the specific characters recognized by
  765. %  his or her index program all characters which have special meaning
  766. %  in the {\sf makeindex} program are given symbolic
  767. %  names.\footnote{I don't know if there exists a program which needs
  768. %                  more command characters, but I hope not.}
  769. % However, all characters used should be of \verb+\catcode+ other than
  770. % `letter' (11).
  771. %
  772. % \DescribeMacro{\actualchar}
  773. % The \verb+\actualchar+ is used to separate the `key' and the actual
  774. % index entry.
  775. % \DescribeMacro{\quotechar}
  776. % The \verb+\quotechar+ is used before a special index program
  777. % character to suppress its special meaning.
  778. % \DescribeMacro{\encapchar}
  779. %  The \verb+\encapchar+ separates the indexing information from a
  780. % letter string which {\sf makeindex} uses as a \TeX{} command to
  781. % format the page number associated with a special entry.  It is used
  782. % in this style to apply the \verb+\main+ and the \verb+\usage+
  783. % commands.
  784. % \DescribeMacro{\levelchar}
  785. %  Additionally \verb+\levelchar+ is used to separate `item',
  786. % `subitem' and `subsubitem' entries.
  787. %
  788. % It is a good idea to stick to these symbolic names even if you know
  789. % which index program is used. In this way your files will be
  790. % portable.
  791. %
  792. % \DescribeMacro\SpecialMainIndex
  793. % To produce a main index entry for a macro the
  794. % \verb+\SpecialMainIndex+ macro\footnote{This macro is called by the
  795. % {\sf macro} environment.} may be used.  It is called `special'
  796. % because it has to print its argument verbatim.
  797. % \DescribeMacro\SpecialIndex
  798. % If you want a normal index entry for a macro name
  799. % \verb+\SpecialIndex+ might be used.\footnote{This macro is called
  800. % within the {\sf macrocode} environment when encountering a macro
  801. % name.}
  802. % \DescribeMacro\SpecialUsageIndex
  803. % \DescribeMacro\SpecialEnvIndex
  804. % To index the usage of a macro or an environment
  805. % \verb+\SpecialUsageIndex+ and \verb+\SpecialEnvIndex+ may be used.
  806. % \DescribeMacro\SortIndex
  807. % Additionally a \verb+\SortIndex+ command is provided.  It takes two
  808. % arguments---the sort key and the actual index entry.
  809. %
  810. % All these macros are normally used by other macros; you will need
  811. % them only in an emergency.
  812. %
  813. % \DescribeMacro\verbatimchar
  814. % But there is one characteristic worth mentioning: all macro names in
  815. % the index are typeset with the \verb+\verb*+ command. Therefore one
  816. % special character is needed to act as a delimiter for this command.
  817. % To allow a change in this respect, again this character is
  818. % referenced indirectly, by the macro \verb+\verbatimchar+. It expands
  819. % by default to \verb?+?  but if your code lines contain macros with
  820. % `{\tt +}' characters in their names (e.g.\ when you use \verb?\+?)
  821. % you will end up with an index entry containing \verb?\verb+\++?
  822. % which will be typeset as `\verb+\++' and not as `\verb?\+?'. In this
  823. % case you should redefine \verb+\verbatimchar+ globally or locally to
  824. % overcome this problem.
  825. %
  826. % \DescribeMacro\*
  827. % We also provide a \verb+\*+ macro.  This is intended to be used for
  828. % index entries like
  829. % \begin{quote}
  830. %    index entries \\
  831. %    \hspace*{30pt} Special macros for \*
  832. % \end{quote}
  833. % Such an entry might be produced with the line:
  834. %\begin{verbatim}
  835. %   \index{index entries\levelchar Special macros for \*}
  836. %\end{verbatim}
  837. %
  838. % \DescribeMacro\OldMakeindex
  839. % Versions of {\sf makeindex} prior to 2.9 had some bugs affecting
  840. % {\sf doc}.  One of these, 
  841. % pertaining to the "%" character doesn't have a work-around
  842. % appropriate for versions with and without the
  843. % bug.\label{makeindex:version}  If
  844. % you have an old version, invoke "\OldMakeindex" in a
  845. % style file or the driver file to prevent problems with index entries
  846. % such as "\%", although you'll probably normally want to turn off
  847. % indexing of "\%" anyway.  Try to get an up-to-date {\sf makeindex}
  848. % from one of the \TeX{} repositories.
  849. %
  850. %
  851. % \subsection{Setting the index entries}
  852. %
  853. % \changes{v1.7a}{92/03/11}{Usage note on gind.ist.}
  854. % After the first formatting pass through the {\tt .doc} file you need
  855. % to sort the index entries written to the {\tt .idx} file using {\sf
  856. % makeindex} or your favourite alternative.  You need a suitable style
  857. % file for {\sf makeindex} (specified by the {\tt -s} switch).  A
  858. % suitable one is supplied with {\sf doc}, called {\tt gind.ist}.
  859. %
  860. % \DescribeMacro\PrintIndex
  861. % To read in and print the sorted index, just put the
  862. % \verb+\PrintIndex+ command as the last (commented-out, and thus
  863. % executed during the documentation pass through the file) command
  864. % in your style file.  Precede it by any bibliography commands
  865. % necessary for your citations.
  866. % Alternatively, it may be more convenient to put all such calls
  867. % amongst the arguments of the \verb+\StopEventually+ macro, in
  868. % which case a \verb+\Finale+ command should appear at the end of
  869. % your file.
  870. %
  871. % \DescribeEnv{theindex}
  872. % Contrary to standard \LaTeX, the index is typeset in three columns
  873. % by default. This is controlled by the \LaTeX{} counter `{\sf
  874. % IndexColumns}' and can therefore be changed with a
  875. % \verb+\setcounter+ declaration.  Additionally one doesn't want to
  876. % start a new page unnecessarily.  Therefore the {\sf theindex}
  877. % environment is redefined.
  878. % \DescribeMacro\IndexMin
  879. % When the {\sf theindex} environment starts it will measure how much
  880. % space is left on the current page. If this is more than
  881. % \verb+\IndexMin+ then the index will start on this page. Otherwise
  882. % \verb+\newpage+ is called.
  883. %
  884. % Then a short introduction about the meaning of several index entries
  885. % is typeset (still in onecolumn mode). Afterwards the actual index
  886. % entries follow in multi-column mode.
  887. % \DescribeMacro\IndexPrologue
  888. % You can change this prologue with the help of the
  889. % \verb+\IndexPrologue+ macro. Actually the section heading is also
  890. % produced in this way, so you'd better write something like:
  891. % \begin{verbatim}
  892. %   \IndexPrologue{\section*{Index} The index entries underlined ...} 
  893. %\end{verbatim}
  894. % When the {\sf theindex} environment is finished the last page will
  895. % be reformatted to produce balanced columns. This improves the layout
  896. % and allows the next article to start on the same page.
  897. % \DescribeMacro\IndexParms
  898. % Formatting of the index columns (values for \verb+\columnssep+
  899. % etc.)\ is controlled by the \verb+\IndexParms+ macro. It assigns the
  900. % following values:
  901. % \SpecialUsageIndex{\parindent}\SpecialUsageIndex{\columnsep}^^A
  902. % \SpecialUsageIndex{\parskip}\SpecialUsageIndex{\rightskip}^^A
  903. % \SpecialUsageIndex{\mathsurround}\SpecialUsageIndex{\parfillskip}
  904. % \begin{center}
  905. %  \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
  906. %  \verb+\parindent+    & \IndexParms \the\parindent    &
  907. %  \verb+\columnsep+    & \IndexParms \the\columnsep    \\
  908. %  \verb+\parskip+      & \IndexParms \the\parskip           &
  909. %  \verb+\rightskip+    & \IndexParms 
  910. %                         \expandafter\dimenvalue\the\rightskip  \\
  911. %  \verb+\mathsurround+ & \IndexParms \the\mathsurround  &
  912. %  \verb+\parfillskip+  & \IndexParms 
  913. %                         \expandafter\dimenvalue\the\parfillskip      
  914. %  \end{tabular}
  915. % \end{center}
  916. % \DescribeMacro{\@idxitem}
  917. % Additionally it defines \verb+\@idxitem+ (which will be used when an
  918. % \verb+\item+ command is encountered) and selects \verb+\small+ size.
  919. % If you want to change any of these values you have to define them
  920. % all.
  921. %
  922. % \DescribeMacro\main
  923. % \DescribeMacro\usage
  924. % The page numbers for main index entries are encapsulated by the
  925. % \verb+\main+ macro (underlining its argument) and the numbers
  926. % denoting the description are encapsulated by the \verb+\usage+ macro
  927. % (which produces {\em italics}). As usual these commands are user
  928. % definable.
  929. %
  930. %
  931. % \subsection{Changing the default values of style parameters}
  932. %
  933. % \DescribeMacro\DocstyleParms
  934. % If you want to overwrite some default settings made by the {\tt doc}
  935. % style, you can either put your declarations in the driver file (that
  936. % is after {\tt doc.sty} is read in) or use a separate style file for
  937. % doing this work. In the latter case you can define the macro
  938. % \verb+\DocstyleParms+ to contain all assignments.  This
  939. % indirect approach is necessary if your style file might be read
  940. % before the {\tt doc.sty}, when some of the registers are not
  941. % allocated.  Its default definition is null.
  942. %
  943. % The doc style option currently assigns values to the following
  944. % registers:
  945. % \SpecialUsageIndex{\IndexMin}\SpecialUsageIndex{\MacrocodeTopsep}^^A
  946. % \SpecialUsageIndex{\MacroTopsep}^^A
  947. % \SpecialUsageIndex{\MacroIndent}\SpecialUsageIndex{\marginparpush}^^A
  948. % \SpecialUsageIndex{\marginparwidth}\SpecialUsageIndex{\tolerance}
  949. % \begin{center}
  950. %  \begin{tabular}{l@{\,=\,}ll@{\,=\,}l}
  951. %  \verb+\IndexMin+      & \the\IndexMin    &
  952. %  \verb+\MacroTopsep+   & \the\MacroTopsep    \\
  953. %  \verb+\marginparwidth+& \the\marginparwidth  &
  954. %  \verb+\MacroIndent+   & \the\MacroIndent \\
  955. %  \verb+\marginparpush+ & \the\marginparpush    &
  956. %  \verb+\MacrocodeTopsep+   & \the\MacrocodeTopsep \\
  957. %  \verb+\tolerance+     & \the\tolerance  
  958. %  \end{tabular}
  959. % \end{center}
  960. %
  961. %
  962. % \subsection{Additional bells and whistles}
  963. %
  964. % We provide macros for logos such as \Web, \AmSTeX, \BibTeX,
  965. % \SliTeX{} and \PlainTeX. Just type \verb+\Web+, \verb+\AmSTeX+,
  966. % \verb+\BibTeX+, \verb+\SliTeX+ or \verb+\PlainTeX+, respectively.
  967. % \LaTeX{} and \TeX{} are already defined in {\tt latex.tex}.
  968. %
  969. % \DescribeMacro\meta
  970. % Another useful macro is \verb+\meta+ which has one argument and
  971. % produces something like \meta{dimen parameter}.
  972. %
  973. % \DescribeMacro\OnlyDescription
  974. % \DescribeMacro\StopEventually
  975. % You can use the \verb+\OnlyDescription+ declaration in the driver
  976. % file to suppress the last part of your document (which presumably
  977. % exhibits the code). To make this work
  978. % you have to place the command \verb+\StopEventually+ at a suitable
  979. % point in your file.  This macro has one argument in which you put
  980. % all information you want to see printed if your document ends at
  981. % this point (for example a bibliography which is normally printed at
  982. % the very end). When the \verb+\OnlyDescription+ declaration is
  983. % missing the \verb+\StopEventually+
  984. % \DescribeMacro\Finale
  985. % macro saves its argument in a macro called \verb+\Finale+ which can
  986. % afterwards be used to get things back (usually at the very end).
  987. % Such a scheme makes changes in two places unnecessary.
  988. %
  989. % Thus you can use this feature to produce a local guide for the
  990. % \TeX{} users which describes only the usage of macros (most of them
  991. % won't be interested in your definitions anyway).  For the same
  992. % reason the \verb+\maketitle+
  993. % \DescribeMacro\maketitle 
  994. % command is slightly changed to allow multiple titles in one
  995. % document.  So you can make one driver file reading in several
  996. % articles at once.
  997. % \DescribeMacro{\ps@titlepage}
  998. % To avoid an unwanted {\sf pagestyle} on the title page the
  999. % \verb+\maketitle+ command issues a \verb+\thispagestyle{titlepage}+
  1000. % declaration which produces a {\sf plain} page if the {\sf titlepage}
  1001. % page style is undefined.  This allows style files like {\sf
  1002. % ltugboat.sty} to define their own page styles for title pages.
  1003. %
  1004. % \DescribeMacro\IndexInput \label{..Input}
  1005. % Last but not least I defined an \verb+\IndexInput+ macro which
  1006. % takes a file name as an argument and produces a verbatim listing of
  1007. % the file, indexing every command as it goes along.  This might be
  1008. % handy, if you want to learn something about macros without enough
  1009. % documentation.  I used this feature to cross-reference {\tt
  1010. % latex.tex} getting a verbatim copy with about 15 pages
  1011. % index.\footnote{It took quit a long time and the resulting {\tt .idx}
  1012. %                file was longer than the {\tt .dvi} file.
  1013. %                Actually too long to be handled by the {\sf makeindex}
  1014. %                program directly (on our MicroVAX) but the final result
  1015. %                was worth the trouble.}
  1016. %
  1017. % \DescribeMacro\changes
  1018. % To maintain a change history within the file, the \verb+\changes+
  1019. % command may be placed amongst the description part of the changed
  1020. % code.  It takes three arguments, thus:
  1021. % \begin{quote}
  1022. % \verb+\changes{+\meta{version}\verb+}{+\meta{date}\verb+}{+^^A
  1023. % \meta{text}\verb+}+
  1024. % \end{quote}
  1025. % The changes may be used to produce an auxiliary file (\LaTeX's
  1026. % \verb+\glossary+ mechanism is used for this) which may be printed
  1027. % after suitable formatting. The \verb+\changes+ macro encloses the
  1028. % \meta{date} in parentheses and appends the \meta{text} to form the
  1029. % printed entry in such a change history; because old
  1030. % versions\footnote{Before 2.6.} of the {\sf makeindex} 
  1031. % program limit such fields to 64 characters, care should be taken
  1032. % not to exceed this limit when describing the change.  When
  1033. % referring to macros in change descriptions it is conventional to use
  1034. % "`"\meta{macroname} rather than attempting to format it properly and
  1035. % using up valuable characters in the entry with old {\sf makeindex}
  1036. % versions.
  1037. %
  1038. % \changes{v1.7a}{92/02/26}{Description of `RecordChanges etc. added
  1039. %                           to interface section.}
  1040. % \DescribeMacro\RecordChanges
  1041. % To cause the change information to be written out, include
  1042. % "\RecordChanges" in the driver file.
  1043. % \DescribeMacro\PrintChanges
  1044. % To read in and print the sorted change history (in two columns),
  1045. % just put the \verb+\PrintChanges+ command as the last
  1046. % (commented-out, and thus executed during the documentation pass
  1047. % through the file) command in your style file.  Alternatively, this
  1048. % command may form one of the arguments of the \verb+\StopEventually+
  1049. % command, although a change history is probably {\em not\/} required
  1050. % if only the description is being printed.
  1051. % The command assumes that {\sf makeindex} or some other program
  1052. % has processed the {\tt.glo} file to generate a sorted {\tt.gls} file.
  1053. % You need a special {\sf makeindex} style file; a suitable one is
  1054. % supplied with {\sf doc}, called {\tt gglo.ist}.
  1055. % \DescribeMacro\GlossaryMin \DescribeMacro\GlossaryPrologue
  1056. % \DescribeMacro\GlossaryParms
  1057. % The "\GlossaryMin", "\GlossaryPrologue" and  "\GlossaryParms" macros
  1058. % are analagous to the "\Index"\ldots\ versions.  (The \LaTeX{}
  1059. % `glossary' mechanism is used for the change entries.)
  1060. %
  1061. % \label{sec:checksum}
  1062. % \DescribeMacro\CharacterTable
  1063. % \DescribeMacro\CheckSum 
  1064. % To overcome some of the problems of sending files over the networks
  1065. % we developed two macros which should detect corrupted files. If one
  1066. % places the lines
  1067. % \begin{verbatim}
  1068. %%% \CharacterTable
  1069. %%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  1070. %%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  1071. %%%   Digits        \0\1\2\3\4\5\6\7\8\9
  1072. %%%   Exclamation   \!     Double quote  \"     Hash (number) \#
  1073. %%%   Dollar        \$     Percent       \%     Ampersand     \&
  1074. %%%   Acute accent  \'     Left paren    \(     Right paren   \)
  1075. %%%   Asterisk      \*     Plus          \+     Comma         \,
  1076. %%%   Minus         \-     Point         \.     Solidus       \/
  1077. %%%   Colon         \:     Semicolon     \;     Less than     \<
  1078. %%%   Equals        \=     Greater than  \>     Question mark \?
  1079. %%%   Commercial at \@     Left bracket  \[     Backslash     \\
  1080. %%%   Right bracket \]     Circumflex    \^     Underscore    \_
  1081. %%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
  1082. %%%   Right brace   \}     Tilde         \~}
  1083. %%%
  1084. %\end{verbatim}
  1085. % at the beginning of the file then character translation failures
  1086. % will be detected, provided of course, that the used {\tt doc} option
  1087. % has a correct default table.  The percent signs\footnote{There are
  1088. % two percent signs in each line. This has the effect that these lines
  1089. % are not removed by the {\tt docstrip.tex} program.} at the beginning
  1090. % of the lines should be typed in, since only the {\tt doc} option
  1091. % should look at this command.
  1092. %
  1093. % Another problem of mailing files is possible truncation.  To
  1094. % detect these sort of errors we provide a \verb+\CheckSum+ macro.
  1095. % The check-sum of a file is simply the number of backslashes in the
  1096. % code, i.e.\ all lines between the {\sf macrocode} environments.  But
  1097. % don't be afraid: you don't have count the code-lines yourself; this
  1098. % is done by the {\tt doc} style option for you.  You simply have to
  1099. % use the \verb+\StopEventually+ (which starts looking for backslashes)
  1100. % and the \verb+\Finale+ command.  The latter will inform you either
  1101. % that your file has no check-sum (telling you the right number) or
  1102. % that your number is incorrect (this time telling you both the
  1103. % correct and the incorrect one).  Then you go to the top of your file
  1104. % inserting the line
  1105. % \begin{quote}
  1106. %    \verb+%%   \CheckSum{+\meta{number}\verb+}+
  1107. % \end{quote}
  1108. % and that's all. If you precede it only with one percent then the
  1109. % line will not show up in {\tt docstrip} versions of the file.
  1110. % You should do so whenever you are using conditional code (see
  1111. % {\tt docstrip} documentation) since then the check-sum will not
  1112. % reflect the number of backslashes in the stripped of versions.
  1113. %
  1114. % \DescribeMacro\bslash
  1115. % From time to time, it is necessary to print a \verb+\+ without
  1116. % being able to use the \verb+\verb+ command because the
  1117. % \verb+\catcode+$\,$s of the symbols are already firmly
  1118. % established.  In this instance we can use the command
  1119. % \verb+\bslash+ presupposing, of course, that the actual font in
  1120. % use at this point contains a `backslash' as a symbol.  Note that
  1121. % this definition of \verb+\bslash+ is expandable; it inserts a
  1122. % $"\"_{12}$.  This means that you have to \verb+\protect+
  1123. % it if it is used in `moving arguments'.
  1124. %
  1125. % \DescribeMacro\MakePrivateLetters
  1126. % \changes{v1.7a}{92/02/26}{Documented `MakePrivateLetters in
  1127. %                           interface section}^^A
  1128. % If your macros "\catcode" anything other than "@" to `letter', you
  1129. % should redefine "\MakePrivateLetters" so that it also makes the
  1130. % relevant characters `letters' for the benefit of the indexing.  The
  1131. % default definition is just "\makeatletter".
  1132. %
  1133. % \DescribeMacro\MakeShortVerb \DescribeMacro\DeleteShortVerb
  1134. % It is awkward to have to type, say, "\verb+"\ldots"+" continually
  1135. % when quoting verbatim bits (like macro names) in the text, so an
  1136. % abbreviation mechanism is provided.  Pick a character
  1137. % \meta{c}---one which normally has catcode `other' unless you have
  1138. % very good reason not to---which
  1139. % you don't envisage using in the text, or not using often.  (I like
  1140. % \verb+"+, but you may prefer "|" if you have \verb+"+ active to do
  1141. % umlauts, for instance.)  Then if you say
  1142. % "\MakeShortVerb{\"\meta{c}"}" you can subsequently use
  1143. % \meta{c}\meta{text}\meta{c} as the equivalent of
  1144. % "\verb"\meta{c}\meta{text}\meta{c}.  Use
  1145. % "\DeleteShortVerb{\"\meta{c}"}" if you subsequently
  1146. % want \meta{c} to revert to its previous meaning---you can
  1147. % always turn it on again after the unusual section.  The `short verb'
  1148. % commands make global changes.  The abbreviated "\verb" may not
  1149. % appear in the argument of another command just like "\verb".
  1150. % However the `short verb' character may be used freely in the {\sf
  1151. % verbatim} and {\sf macrocode} environments without ill effect.
  1152. % "\DeleteShortVerb" is silently ignored if its argument does not
  1153. % currently represent a short verb character.  Both commands type a
  1154. % message to tell you the meaning of the character is being changed.
  1155. %
  1156. % \DescribeMacro\DontCheckModules \DescribeMacro\CheckModules
  1157. % \DescribeMacro\Module \DescribeMacro\AltMacroFont
  1158. % The `module' directives of the {\sf docstrip} system
  1159. % \cite{art:docstrip} are normally 
  1160. % recognised and invoke special formatting.  This can be turned on and
  1161. % off in the {\tt .doc} file or the driver file using "\CheckModules"
  1162. % and "\DontCheckModules".  If checking for module directives is on
  1163. % (the default) then code in the scope of the directives is set as
  1164. % determined by the hook "\AltMacroFont", which gives {\small\tt\it
  1165. % small italic type\-writer\/} by default in the New Font
  1166. % Selection Scheme but just ordinary {\small\tt small type\-writer} in
  1167. % the old one, where a font such as italic typewriter can't be used
  1168. % portably (plug for NFSS); you will need to override
  1169. % this if you don't have the italic typewriter font available.
  1170. % Code is in such a scope if it's on a line beginning with "%<" or is
  1171. % between lines starting with "%<*"\meta{name list}">" and
  1172. % "%</"\meta{name list}">".  The directive is formatted by the macro
  1173. % "\Module" whose single argument is the text of the
  1174. % directive between, but not including, the angle brackets; this macro
  1175. % may be re-defined in the driver or style file and by default
  1176. % produces results like \Module{+foo|bar} with no following space.
  1177. %
  1178. % \DescribeMacro{StandardModuleDepth} Sometimes (as in this file) the
  1179. % whole code is surrounded by modules to produce several files from a
  1180. % single source. In this case it is clearly not appropriate to format
  1181. % all code lines in a special "\AltMacroFont". For this reason a
  1182. % counter "StandardModuleDepth" is provided which defines the level of
  1183. % module nesting which is still supposed to be formatted in
  1184. % "\MacroFont" rather then "\AltMacroFont". The default setting is
  1185. % "0", for this documentation it was set to
  1186. %\begin{verbatim}
  1187. %   \setcounter{StandardModuleDepth}{1}
  1188. %\end{verbatim}
  1189. % at the beginning of the file.
  1190. %
  1191. %
  1192. % \subsection{Basic usage summary}
  1193. % \changes{v1.7a}{92/03/11}{Added basic usage summary to spell it out.}
  1194. %
  1195. % To sum up, the basic structure of a {\tt .doc} file without any
  1196. % refinements is like this: 
  1197. % \begin{verse}\small
  1198. % "% "\meta{waffle}\ldots\\
  1199. % \quad\ldots \\
  1200. % "% \DescribeMacro{\fred}"\\
  1201. % "% "\meta{description of fred's use}\\
  1202. % \quad\ldots\\
  1203. % "% \StopEventually{"\meta{finale code}"}"\\
  1204. % \quad\ldots\\
  1205. % "% \begin{macro}{\fred}"\\
  1206. % "% "\meta{commentary on macro fred}\\
  1207. % \verb*+%    \begin{macrocode}+\\
  1208. % \meta{code for macro fred}\\
  1209. % \verb*+%    \end{macrocode}+\\
  1210. % "% \end{macro}"\\
  1211. % \quad\ldots\\
  1212. % "% \Finale \PrintIndex \PrintChanges"
  1213. % \end{verse}
  1214. % For examples of the use of most---if not all---of the features
  1215. % described above consult the {\tt doc.doc} source itself. 
  1216. %
  1217. % \subsection{Acknowledgements}
  1218. %
  1219. % I would like to thank all folks at Mainz and at the Royal Military
  1220. % College of Science for their help in this project. Especially Brian
  1221. % and Rainer who pushed everything with their suggestions, bug fixes,
  1222. % etc.
  1223. %
  1224. % A big thank you to David Love who brought the documentation
  1225. % up-to-date again, after I neglected this file for more than two
  1226. % years. This was most certainly a tough job as many features added to
  1227. % {\sf doc.doc} after its publication in {\sl TUGboat\/} have been never
  1228. % properly described. Beside this splendid work he kindly provided
  1229. % additional code (like ``docstrip'' module formatting) which I think
  1230. % every {\sf doc.doc} user will be grateful for.
  1231. %
  1232. %
  1233. % \StopEventually{
  1234. %  \begin{thebibliography}{1}
  1235. %    \bibitem{book:Buerger}  {\sc G. A. B\"urger}.
  1236. %      \newblock Wunderbare Reisen zu Wasser und zu Lande, Feldz\"uge
  1237. %                und lustige Abenteuer des Freyherrn v.\ M\"unchhausen.
  1238. %      \newblock London, 1786 \& 1788.
  1239. %    \bibitem{art:Knuthliterat} {\sc D. E. Knuth}.
  1240. %      \newblock Literate Programming.
  1241. %      \newblock Computer Journal, Vol.~27, {\it pp}.~97--111, May 1984.
  1242. %    \bibitem{book:KnuthA} {\sc D. E. Knuth}.
  1243. %      \newblock Computers \& Typesetting (The \TeX book).
  1244. %      \newblock Addison-Wesley, Vol. A, 1986.
  1245. %    \bibitem{art:Chen} {\sc L. Lamport}.
  1246. %      \newblock MakeIndex: An Index Processor for \LaTeX.
  1247. %      \newblock 17 February 1987.
  1248. %      \newblock (Taken from the file {\tt makeindex.tex} provided with
  1249. %      the program source code.)
  1250. %    \bibitem{art:doc} {\sc Frank Mittelbach}.
  1251. %      \newblock The {\tt doc}-option.
  1252. %      \newblock {\sl TUGboat}, Vol.~10(2), {\it pp}.~245--273, July
  1253. %        1989.
  1254. %    \bibitem{art:docstrip} {\sc Frank Mittelbach, Denys Duchier and
  1255. %         Johannes Braams}. 
  1256. %      \newblock {\tt docstrip.doc} (to appear).
  1257. %      \newblock The file is part of the DOC package.
  1258. %    \bibitem{book:Raspe} {\sc R. E. Raspe} (*1737, \dag 1797).
  1259. %      \newblock Baron M\"unchhausens narrative of his marvellous
  1260. %                travels and campaigns in Russia.
  1261. %      \newblock Oxford, 1785.
  1262. %    \bibitem{art:verbatim} {\sc Rainer Sch\"opf}.
  1263. %      \newblock A New Implementation of \LaTeX's {\tt verbatim} and
  1264. %      {\tt verbatim*} Environments.
  1265. %      \newblock File {\tt verbatim.doc}, version 1.4i.
  1266. %  \end{thebibliography}
  1267. %  ^^A\PrintIndex
  1268. %  ^^A\PrintChanges
  1269. %
  1270. %  \ifmulticols
  1271. %  \addtocontents{toc}{\protect\end{multicols}}
  1272. %  \fi
  1273. % } ^^A end \StopEventually
  1274. %
  1275. %
  1276. % \section{The Description of Macros}
  1277. %
  1278. % Most of the following code is destined for {\tt doc.sty} after
  1279. % processing with {\tt docstrip} to include the module {\bf style}
  1280. % indicated here.  (All code in this file not appropriate to {\tt
  1281. % doc.sty} has to be included explicitly by docstrip so that this {\tt
  1282. % .doc} file can be used as directly as a style file rather than the
  1283. % stripped version.)  The usual font change for the
  1284. % conditionally-included lines between the \Module{*style} and
  1285. % \Module{/style} directives is suppressed since only the lines with
  1286. % an explicit directive are special in this file.
  1287. %    \begin{macrocode}
  1288. %<*style>
  1289. %    \end{macrocode}
  1290. % As always, we begin by identifying the latest version of this file
  1291. % on the VDU and in the {\sf log} file. But only if the macros are
  1292. % unknown to the system.  
  1293. % \changes{v1.5i}{89/06/07}{Avoid reading the file twice.}
  1294. %    \begin{macrocode}
  1295. \@ifundefined{macro@cnt}{}{\endinput} \typeout{Style-Option: `doc'
  1296. \fileversion \@spaces\space\space <\filedate> (FMi)} \typeout{English
  1297.    Documentation \@spaces\@spaces\space <\docdate> (DLo, FMi, RMCS)}
  1298. %    \end{macrocode}
  1299. % \DescribeMacro\fileversion
  1300. % \DescribeMacro\filedate
  1301. % \DescribeMacro\docdate
  1302. % As you can see I used macros like \verb+\fileversion+ to denote the
  1303. % version number and the date. They are defined at the very beginning
  1304. % of the style file (without a surrounding {\sf macrocode}
  1305. % environment), so I don't have to search for this place here when I
  1306. % change the version number.  You can see their actual outcome in a
  1307. % footnote to the title.
  1308. %
  1309. %
  1310. % The first thing that we do next is to get ourselves a new comment
  1311. % sign.  Because all sensible signs are already occupied, we will
  1312. % choose one that can only be entered indirectly:
  1313. % {\DoNotIndex{\^}^^A avoid misinterpretion !!!!! VERIFY  
  1314. %    \begin{macrocode}
  1315. \catcode`\^^A=14
  1316. %    \end{macrocode}
  1317. %    \SortIndex{\string^\string^A}{\string\verb\verbatimchar
  1318. %                                  \string^\string^A\verbatimchar
  1319. %                                  \encapchar main}
  1320. % }
  1321. %
  1322. %
  1323. % \subsection{Macros surrounding the `definition parts'}
  1324. %
  1325. % \begin{macro}{\macrocode}
  1326. %    Parts of the macro definition will be surrounded by the
  1327. %    environment {\sf macrocode}.  Put more precisely, they will be
  1328. %    enclosed by a macro whose argument (the text to be set
  1329. %    `verbatim') is terminated by the string 
  1330. % \verb*+%    \end{macrocode}+.  Carefully note the number of spaces.
  1331. %    \verb+\macrocode+ is defined completely analogously to
  1332. %    \verb+\verbatim+, but because a few small changes were carried
  1333. %    out, almost all internal macros have got new names.  We start by
  1334. %    calling the macro \verb+\macro@code+, the macro which bears the
  1335. %    brunt of most of the work, such as \verb+\catcode+ reassignments,
  1336. %    etc.
  1337. % \changes{v1.5r}{89/11/04}{Support for code line no. (Undoc)}
  1338. %    \begin{macrocode}
  1339. \def\macrocode{\macro@code
  1340. %    \end{macrocode}
  1341. %    Then we take care that all spaces have the same width, and that
  1342. %    they are not discarded.
  1343. %    \begin{macrocode}
  1344.    \frenchspacing \@vobeyspaces
  1345. %    \end{macrocode}
  1346. %    Before closing, we need to call \verb+\xmacro@code+.  It is this
  1347. %    macro that expects an argument which is terminated by the above
  1348. %    string.  This way it is possible to keep the \verb+\catcode+
  1349. %    changes local.
  1350. % \changes{v1.5r}{89/11/04}{Support for code line no. (Undoc)}
  1351. % \changes{v1.5t}{89/11/07}{Common code moved to `macro@code.}
  1352. %    \begin{macrocode}
  1353.    \xmacro@code}
  1354. %    \end{macrocode}
  1355. % \end{macro}
  1356. %
  1357. %
  1358. % \begin{macro}{\macro@code}
  1359. %    We will now begin with the macro that does the actual work:
  1360. %    \begin{macrocode}
  1361. \def\macro@code{%
  1362. %    \end{macrocode}
  1363. %    In theory it should consist of a {\sf trivlist} environment, but
  1364. %    the empty space before and after the environment should not be
  1365. %    too large.
  1366. %    \begin{macrocode}
  1367.    \topsep \MacrocodeTopsep
  1368. %    \end{macrocode}
  1369. %    The next parameter we set is \verb+\@beginparpenalty+, in order
  1370. %    to prevent a page break before such an environment.
  1371. %    \begin{macrocode}
  1372.    \@beginparpenalty \predisplaypenalty
  1373. %    \end{macrocode}
  1374. %    We then start a \verb+\trivlist+, set \verb+\parskip+ back to
  1375. %    zero and start an empty \verb+\item+.
  1376. %    \begin{macrocode}
  1377.    \trivlist \parskip \z@ \item[]%
  1378. %    \end{macrocode}
  1379. %    Additionally, everything should be set in {\tt typewriter} font.
  1380. %    Some people might prefer it somewhat differently; because of this
  1381. %    the font choice is
  1382. %    macro-driven.\footnote{The font change has to be placed
  1383. %                       {\em after\/}
  1384. %                       the {\tt\bslash item}. Otherwise a change to
  1385. %                       {\tt\bslash baselineskip} will affect the
  1386. %                       paragraph above.}
  1387. %    \begin{macrocode}
  1388.    \macro@font
  1389. %    \end{macrocode}
  1390. %    Because \verb+\item+ sets various parameters, we have found it
  1391. %    necessary to alter some of these retrospectively.
  1392. %    \begin{macrocode}
  1393.    \leftskip\@totalleftmargin \advance\leftskip\MacroIndent
  1394.    \rightskip\z@ \parindent\z@ \parfillskip\@flushglue
  1395. %    \end{macrocode}
  1396. %    The next line consists of the \LaTeX{} definition of \verb+\par+
  1397. %    used in \verb+\verbatim+ and should result in blank lines being
  1398. %    shown as blank lines.
  1399. % \changes{v1.5l}{89/09/10}{Code line numbers supported.}
  1400. % \changes{v1.5t}{89/11/07}{Call `leavevmode to get `everypar on
  1401. %                           blank lines.}
  1402. % \changes{v1.7c}{92/3/24}{Added `interlinepenalty to `par from
  1403. %                          verbatim.sty} 
  1404. %    \begin{macrocode}
  1405.    \blank@linefalse \def\par{\ifblank@line
  1406.                              \leavevmode\fi
  1407.                              \blank@linetrue\@@par
  1408.                              \penalty\interlinepenalty}
  1409. %    \end{macrocode}
  1410. %    What use is this definition of \verb+\par+\,?  We use the macro
  1411. %   \verb+\obeylines+ of \cite{book:KnuthA} which changes all \verb+^^M+
  1412. %    to \verb+\par+ so that each can control its own indentation.
  1413. %    Next we must also ensure that all special signs are normalized;
  1414. %    that is, they must be given \verb+\catcode+ $12$.
  1415. %    \begin{macrocode}
  1416.    \obeylines \let\do\@makeother \catcode`\`\active \@noligs \dospecials
  1417. %    \end{macrocode}
  1418. % \changes{v1.5t}{89/11/07}{Common code added.}
  1419. % \changes{v1.5w}{90/02/05}{Skip of `@totalleftmargin added.}
  1420. % If indexing by code lines is switched on the line number is
  1421. % incremented and set appropriately.  We also check whether the start of
  1422. % the next line indicates a {\tt docstrip} module directive and process
  1423. % it appropriately if so using "\check@module".
  1424. %    \begin{macrocode}
  1425.    \global\@newlistfalse
  1426.    \global\@minipagefalse
  1427.    \ifcodeline@index
  1428.      \everypar{\global\advance\c@CodelineNo\@ne
  1429.                \llap{\theCodelineNo\ \hskip\@totalleftmargin}%
  1430.                \check@module}%
  1431.    \else \everypar{\check@module}%
  1432.    \fi
  1433. %    \end{macrocode}
  1434. %    We also initialize the cross-referencing feature by calling
  1435. %    \verb+\init@crossref+. This will start the scanning mechanism
  1436. %    when encountering an escape character.
  1437. %    \begin{macrocode}
  1438.    \init@crossref}
  1439. %    \end{macrocode}
  1440. % \end{macro}
  1441. %
  1442. %
  1443. % \begin{macro}{\ifblank@line}
  1444. % \begin{macro}{\blank@linetrue}
  1445. % \begin{macro}{\blank@linefalse}
  1446. %    \verb+\ifblank@line+ is the switch used in the definition above.
  1447. %    In the original {\sf verbatim} environment the \verb+\if@tempswa+
  1448. %    switch is used. This is dangerous because its value may change
  1449. %    while processing lines in the {\sf macrocode} environment.
  1450. %    \begin{macrocode}
  1451. \newif\ifblank@line
  1452. %    \end{macrocode}
  1453. % \end{macro}
  1454. % \end{macro}
  1455. % \end{macro}
  1456. %
  1457. % \begin{macro}{\endmacrocode}
  1458. %    Because we have begun a {\sf trivlist} environment in the {\sf
  1459. %    macrocode} environment, we must also end it.  We must also act on
  1460. %    the value of the "pm@module" flag (see below) and empty
  1461. %    "\everypar".
  1462. % \changes{v1.5r}{89/11/04}{Support for code line no. (Undoc)}
  1463. %    \begin{macrocode}
  1464. \def\endmacrocode{%
  1465.                  \ifpm@module \endgroup \pm@modulefalse \fi
  1466.                  \everypar{}%
  1467.                  \global\@inlabelfalse
  1468.                  \endtrivlist
  1469. %    \end{macrocode}
  1470. %    Additionally \verb+\close@crossref+ is used to do anything needed
  1471. %    to end the cross-referencing mechanism.
  1472. %    \begin{macrocode}
  1473.                  \close@crossref}
  1474. %    \end{macrocode}
  1475. % \end{macro}
  1476. %
  1477. %
  1478. % \begin{macro}{\MacroFont}
  1479. %    Here is the default definition for the \verb+\MacroFont+ macro.
  1480. %    If the new font selection scheme is in use we suppress changes
  1481. %    of math fonts thereby making doc much faster.
  1482. % \changes{v1.5x}{90/02/17}{`math@fontsfalse added for new font sel.}
  1483. % \changes{v1.7a}{92/03/13}{Added `reset@font for NFSS.}
  1484. %    \begin{macrocode}
  1485. \@ifundefined{MacroFont}{%
  1486.   \ifx\undefined\selectfont
  1487.     \def\MacroFont{\small\tt}\else
  1488.     \def\MacroFont{\math@fontsfalse\reset@font\small\tt}\fi
  1489.   }{}
  1490. %    \end{macrocode}
  1491. % \end{macro}
  1492. %
  1493. % \begin{macro}{\AltMacroFont}
  1494. % \begin{macro}{\macro@font}
  1495. % \changes{v1.7a}{92/03/12}{Added to support distinction of modules.}
  1496. % \changes{v1.7c}{92/03/26}{Altered font change for OFSS.}
  1497. % Although most of the macro code is set in "\MacroFont" we want to be
  1498. % able to switch to indicate module code set in "\AltMacroFont".
  1499. % "\macro@font" keeps track of which one we're using.  We can't do the
  1500. % same thing sensibly in OFSS as in NFSS.
  1501. %    \begin{macrocode}
  1502. \@ifundefined{AltMacroFont}{%
  1503.   \ifx\undefined\selectfont
  1504.     \def\AltMacroFont{\small\tt}\else
  1505.     \def\AltMacroFont{\math@fontsfalse\small\reset@font\it\tt}\fi
  1506.   }{}
  1507. \let\macro@font=\MacroFont
  1508. %    \end{macrocode}
  1509. % \end{macro}
  1510. % \end{macro}
  1511. %
  1512. % \begin{macro}{\check@module}
  1513. % \begin{macro}{\ifpm@module}
  1514. % \changes{v1.7a}{92/03/12}{Added.}
  1515. % This is inserted by "\everypar" at the start of each macrocode line to
  1516. % check whether it starts with module information.  (Such information is
  1517. % of the form "%<"\meta{switch}">", where the "%" must be at the
  1518. % start of the line and \meta{switch} comprises names with various
  1519. % possible separators and a possible leading "+", "-", "*" or "/"
  1520. % \cite{art:docstrip}.  All that concerns us here is what the first
  1521. % character of \meta{switch} is.)  First it checks the "pm@module" 
  1522. % flag in case the previous line had a non-block module
  1523. % directive i.e., not "%<*" or "%</"; if it did we need to close the
  1524. % group it started and unset the flag.  "\check@module" looks ahead at
  1525. % the next token and then calls "\ch@percent" to take action depending
  1526. % on whether or not it's a "%"; we don't want to expand the token at
  1527. % this stage.  This is all done conditionally so it can be turned off
  1528. % if it causes problems with code that wasn't designed to be {\tt
  1529. % docstrip}ped.
  1530. %    \begin{macrocode}
  1531. \def\check@module{%
  1532.   \ifcheck@modules
  1533.     \ifpm@module \endgroup \pm@modulefalse \fi
  1534.     \expandafter\futurelet\expandafter\next\expandafter\ch@percent
  1535.   \fi}
  1536. \newif\ifpm@module
  1537. %    \end{macrocode}
  1538. % \end{macro}
  1539. % \end{macro}
  1540. % \begin{macro}{\DontCheckModules}
  1541. % \begin{macro}{\CheckModules}
  1542. % \changes{v1.7a}{92/03/12}{Added.}
  1543. % \begin{macro}{\ifcheck@modules}
  1544. % Here are two driver-file interface macros for turning the module
  1545. % checking on and off using the "check@modules" switch.
  1546. %    \begin{macrocode}
  1547. \def\DontCheckModules{\check@modulesfalse}
  1548. \def\CheckModules{\check@modulestrue}
  1549. \newif\ifcheck@modules  \check@modulestrue
  1550. %    \end{macrocode}
  1551. % \end{macro}
  1552. % \end{macro}
  1553. % \end{macro}
  1554. % \begin{macro}{\ch@percent}
  1555. % \changes{v1.7a}{92/03/12}{Added.}
  1556. % If the lookahead token in "\next" is $"%"_{12}$ we go on to check
  1557. % whether the following one is "<" and otherwise do nothing.  Note the
  1558. % "\expandafter" to get past the "\fi".
  1559. %    \begin{macrocode}
  1560. \def\ch@percent{%
  1561.   \if \percentchar\next
  1562.     \expandafter\check@angle
  1563.   \fi}
  1564. %    \end{macrocode}
  1565. % \end{macro}
  1566. % \begin{macro}{\check@angle}
  1567. % \changes{v1.7a}{92/03/12}{Added.}
  1568. % Before looking ahead for the "<" the "%" is gobbled by the
  1569. % argument here.
  1570. %    \begin{macrocode}
  1571. \def\check@angle#1{\futurelet\next\ch@angle}
  1572. %    \end{macrocode}
  1573. % \end{macro}
  1574. % \begin{macro}{\ch@angle}
  1575. % \changes{v1.7a}{92/03/12}{Added.}
  1576. % If the current lookahead token is "<" we are defined to be
  1577. % processing a module directive can go on to look for "+"
  1578. % etc.; otherwise we must put back the gobbled "%".
  1579. %    \begin{macrocode}
  1580. \def\ch@angle{\if<\next
  1581.     \expandafter\ch@plus@etc 
  1582.   \else \percentchar \fi}
  1583. %    \end{macrocode}
  1584. % \end{macro}
  1585. % \begin{macro}{\ch@plus@etc}
  1586. % \begin{macro}{\check@plus@etc}
  1587. % \changes{v1.7a}{92/03/12}{Added.}
  1588. % We now have to decide what sort of a directive we're dealing with
  1589. % and do the right thing with it.
  1590. %    \begin{macrocode}
  1591. \def\ch@plus@etc<{\futurelet\next\check@plus@etc}
  1592. \def\check@plus@etc{%
  1593.     \if +\next
  1594.       \let\next\pm@module
  1595.     \else\if -\next
  1596.       \let\next\pm@module
  1597.     \else\if *\next
  1598.       \let\next\star@module
  1599.     \else\if /\next
  1600.       \let\next\slash@module
  1601.     \else
  1602.       \let\next\pm@module
  1603.     \fi\fi\fi\fi
  1604.     \next}
  1605. %    \end{macrocode}
  1606. % \end{macro}
  1607. % \end{macro}
  1608. % \begin{macro}{\pm@module}
  1609. % If we're not dealing with a block
  1610. % directive ("*" or "/") i.e., it's a single special line, we set
  1611. % everything up to the next ">" appropriately and then change to the
  1612. % special macro font inside a group which will be ended at the start
  1613. % of the next line.  If the apparent module directive is missing the
  1614. % terminating ">" this will lose, but then so will the {\tt docstrip}
  1615. % implementation.  An alternative strategy would be to have
  1616. % "\pm@module" make ">" active and clear a flag set here to indicate
  1617. % processing the directive.  Appropriate action could then be taken if
  1618. % the flag was found still to be set when processing the next line.
  1619. % \changes{v1.7a}{92/03/12}{Added.} 
  1620. % \changes{v1.7i}{92/07/11}{Support for fonts depending on nesting.}
  1621. %    \begin{macrocode}
  1622. \def\pm@module#1>{\pm@moduletrue
  1623.    \Module{#1}\begingroup 
  1624. %    \end{macrocode}
  1625. %    We switch to a special font as soon the nesting is higher than
  1626. %    the current value of "\c@StandardModuleDepth". We do a local
  1627. %    update to the "\guard@level" here which will be restored after
  1628. %    the current input line.
  1629. %    \begin{macrocode}
  1630.      \advance\guard@level\@ne
  1631.      \ifnum\guard@level>\c@StandardModuleDepth\AltMacroFont\fi
  1632. }
  1633. %    \end{macrocode}
  1634. % \end{macro}
  1635. % \begin{macro}{\star@module}
  1636. % \begin{macro}{\slash@module}
  1637. % \changes{v1.7a}{92/03/12}{Added.}
  1638. % \changes{v1.7f}{92/05/16}{Take account of nested guards.}
  1639. % \changes{v1.7i}{92/07/11}{Add counter to determine when to switch to
  1640. %                           special font.}
  1641. % If the start or end of a module {\em block\/} is indicated, after
  1642. % setting the guard we have to check whether a change in the macrocode
  1643. % font should be done.  This will be the case if we are already inside
  1644. % a block or are ending the outermost block.  If so, we globally
  1645. % toggle the font for subsequent macrocode sections between the normal
  1646. % and special form, switching to the new one immediately.
  1647. % \changes{v1.7i}{92/07/17}{Support for fonts depending on module
  1648. %                           nesting}
  1649. %    \begin{macrocode}
  1650. \def\star@module#1>{%
  1651.   \Module{#1}%
  1652.   \global \advance \guard@level\@ne
  1653.   \ifnum \guard@level>\c@StandardModuleDepth
  1654.     \global\let\macro@font=\AltMacroFont \macro@font
  1655.   \fi}
  1656. \def\slash@module#1>{%
  1657.   \Module{#1}%
  1658.   \global \advance \guard@level\m@ne
  1659.   \ifnum \guard@level=\c@StandardModuleDepth
  1660.     \global\let\macro@font\MacroFont  \macro@font
  1661.   \fi
  1662. }
  1663. %    \end{macrocode}
  1664. % \end{macro}
  1665. % \end{macro}
  1666. %
  1667. %
  1668. %  \begin{macro}{\c@StandardModuleDepth}
  1669. % \changes{v1.7i}{92/07/11}{Counter added.}
  1670. %    Counter defining up to which level modules are considered part of
  1671. %    the main code. If, for  example, the whole code is surrounded by
  1672. %    a |%<*style>| module we better set this counter to |1| to avoid
  1673. %    getting the whole code be displayed in typewriter italic.
  1674. %    \begin{macrocode}
  1675. \newcounter{StandardModuleDepth}
  1676. %    \end{macrocode}
  1677. %  \end{macro}
  1678. %
  1679. %
  1680. % \begin{macro}{\guard@level}
  1681. % \changes{v1.7f}{92/05/16}{Added.}
  1682. % We need a counter to keep track of the guard nesting.
  1683. %    \begin{macrocode}
  1684. \newcount \guard@level
  1685. %    \end{macrocode}
  1686. % \end{macro}
  1687. % \begin{macro}{\Module}
  1688. % \changes{v1.7a}{92/03/12}{Added.}
  1689. % \changes{v1.7d}{92/04/25}{Use sans font for modules.}
  1690. % This provides a hook to determine the way the module directive is
  1691. % set.  It gets as argument everything between the angle brackets.
  1692. % The default is to set the contents in sans serif text between
  1693. % $\langle\,\rangle$ with the special characters suitably "\mathcode"d
  1694. % by "\mod@math@codes".  (You can't just set it in a sans text font
  1695. % because normally "|" will print as an em-dash.)  This is done
  1696. % differently depending on whether we have the NFSS or the old one.  In
  1697. % the latter case we can easily change "\fam" appropriately.
  1698. %    \begin{macrocode}
  1699. \@ifundefined{Module}{%
  1700.   \ifx\undefined\selectfont
  1701.     \def\Module#1{{\mod@math@codes$\fam\sffam\langle #1\rangle$}}
  1702. %    \end{macrocode}
  1703. % With NFSS what we probably {\em should\/} do is change to a new
  1704. % "\mathversion" but I (Dave Love) haven't spotted an easy way to do so
  1705. % correctly if the document uses a version other than "normal".  (We
  1706. % need to know in what font to set the other groups.)  This uses a new
  1707. % math alphabet rather than version and consequently has to worry about
  1708. % whether we're using {\sf oldlfont} or not.  I expect there's a better
  1709. % way\ldots
  1710. %    \begin{macrocode}
  1711.   \else
  1712.     \expandafter\ifx\csname ds@oldlfont\endcsname\relax
  1713.       \def\Module#1{{\mod@math@codes$\langle\sfmath{#1}\rangle$}}
  1714.     \else
  1715.       \def\Module#1{{\mod@math@codes$\langle{\sfmath #1}\rangle$}}
  1716.     \fi
  1717.   \fi}{}
  1718. %    \end{macrocode}
  1719. % \end{macro}
  1720. %
  1721. % \begin{macro}{\mod@math@codes}
  1722. % \changes{v1.7c}{92/03/26}{Added.}
  1723. % As well as `words', the module directive text might contain any of the
  1724. % characters "*/+-,&|!()" for the current version of {\sf docstrip}.  We
  1725. % only need special action for two of them in the math code changing
  1726. % required above: "|" is changed to a "\mathop" (it's normally
  1727. % \verb+"026A+) and "&" is also made a "\mathop", but in family 0.
  1728. % Remember that "&" will not have a special catcode when it's
  1729. % encountered. 
  1730. %    \begin{macrocode}
  1731. \def\mod@math@codes{\mathcode`\|="226A \mathcode`\&="2026}
  1732. %    \end{macrocode}
  1733. % \end{macro}
  1734. %
  1735. % \begin{macro}{\sfmath}
  1736. % \changes{v1.7c}{92/03/26}{Added.}
  1737. % \changes{v1.7d}{92/04/25}{Use sans font for modules.}
  1738. % If NFSS is in use we need a new math alphabet which uses a sans serif
  1739. % font.
  1740. %    \begin{macrocode}
  1741. \ifx\selectfont\undefined
  1742. \else
  1743.   \ifx\sfmath\undefined
  1744.     \newmathalphabet*{\sfmath}{\sfdefault}{m}{n}\fi
  1745. \fi
  1746. %    \end{macrocode}
  1747. % \end{macro}
  1748. %
  1749. %
  1750. %
  1751. % \begin{macro}{\MacrocodeTopsep}
  1752. % \begin{macro}{\MacroIndent}
  1753. %    In the code above, we have used two registers. Therefore we have
  1754. %    to allocate them. The default values might be overwritten with
  1755. %    the help of the \verb+\DocstyleParms+ macro.
  1756. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  1757. % \changes{v1.5y}{90/02/24}{Default changed.}
  1758. % \changes{v1.6b}{90/06/15}{`rm moved before `scriptsize to
  1759. %                           avoid unnecessary fontwarning.}
  1760. %    \begin{macrocode}
  1761. \newskip\MacrocodeTopsep \MacrocodeTopsep = 3pt plus 1.2pt minus 1pt
  1762. \newdimen\MacroIndent    
  1763. \settowidth\MacroIndent{\rm\scriptsize 00\ }
  1764. %    \end{macrocode}
  1765. % \end{macro}
  1766. % \end{macro}
  1767. %
  1768. %
  1769. %
  1770. %
  1771. % \begin{macro}{\macrocode*}
  1772. % \begin{macro}{\endmacrocode*}
  1773. %    Just as in the {\sf verbatim} environment, there is also a `star'
  1774. %    variant of the {\sf macrocode} environment in which a space is
  1775. %    shown by the symbol \verb*+ +.  Until this moment, I have not yet
  1776. %    used it (it will be used in the description of the definition of
  1777. %    \verb+\xmacro@code+ below) but it's exactly on this one occasion
  1778. %    {\em here\/} that you can't use it
  1779. %    (cf.\ M\"unchhausens Marsh problem)\footnote{Karl Friedrich
  1780. %         Hieronymus Frhr.\ v.\ M\"unchhausen (*1720, \dag1797).
  1781. %         Several books were written about fantastic adventures
  1782. %         supposedly told by him (see \cite{book:Raspe} or
  1783. %         \cite{book:Buerger}). In one story he escaped from the
  1784. %         marsh by pulling himself out by his hair.}
  1785. %    directly. Because of this, on this one occasion we'll cheat
  1786. %    around the problem with an additional comment character.  But now
  1787. %    back to \verb+\macrocode*+. We start with the macro
  1788. %    \verb+\macro@code+ which prepares everything and then call the
  1789. %    macro \verb+\sxmacro@code+ whose argument is terminated by the
  1790. %    string \verb*+%    \end{macrocode*}+.
  1791. %    \begin{macrocode}
  1792. \@namedef{macrocode*}{\macro@code\sxmacro@code}
  1793. %    \end{macrocode}
  1794. %    As we know, \verb+\sxmacro@code+ and then \verb+\end{macrocode*}+
  1795. %    (the macro, not the string), will be executed, so that for a
  1796. %    happy ending we still need to define the macro
  1797. %    \verb+\endmacrocode*+.
  1798. %    \begin{macrocode}
  1799. \expandafter\let\csname endmacrocode*\endcsname = \endmacrocode
  1800. %    \end{macrocode}
  1801. % \end{macro}
  1802. % \end{macro}
  1803. %
  1804. %
  1805. %
  1806. %
  1807. %
  1808. %
  1809. %
  1810. % \begin{macro}{\xmacro@code}
  1811. \catcode`\!=\catcode`\%   ^^A In this section there must not be
  1812.                               ^^A any exclamation marks.
  1813.                               ^^A
  1814. %    As already mentioned, the macro \verb+\xmacro@code+ expects an
  1815. %    argument delimited by the string \verb*+%    \end{macrocode}+.  At
  1816. %    the moment that this macro is called, the \verb+\catcode+ of
  1817. %    \TeX's special characters are 12 (`other') or 13 (`active').
  1818. %    Because of this we need to utilize a different escape character
  1819. %    during the definition.  This happens locally.
  1820. %    \begin{macrocode*}
  1821. \begingroup
  1822. \catcode`\|=\z@ \catcode`\[=\@ne \catcode`\]=\tw@
  1823. %    \end{macrocode*}
  1824. %    Additionally, we need to ensure that the symbols in the above
  1825. %    string contain the \verb+\catcode+$\,$s which are available
  1826. %    within the {\sf macrocode} environment.
  1827. %    \begin{macrocode*}
  1828. \catcode`\{=12 \catcode`\}=12
  1829. \catcode`\%=12 \catcode`\ =\active \catcode`\\=\active
  1830. !%    \end{macrocode*}
  1831. !    Next follows the actual definition of  \verb+\macro@code+;
  1832. !    notice the
  1833. !    use of the new escape character.  We manage to get the argument
  1834. !    surrounded by the string \verb+\end{macrocode}+, but at the end
  1835. !    however, in spite of the actual characters used during the
  1836. !    definition of
  1837. !    this macro, \verb+\end+ with the argument \verb+{macrocode}+
  1838. !    will be executed, to ensure a balanced environment.
  1839. !    \begin{macrocode*}
  1840. |gdef|xmacro@code#1%    \end{macrocode}[#1|end[macrocode]]
  1841. !%    \end{macrocode*}
  1842. ! \begin{macro}{\sxmacro@code}
  1843. !    The definition of \verb+\sxmacro@code+ is completely analogous,
  1844. !    only
  1845. !    here a slightly different terminating string will be used.
  1846. !    Note that the space is not active in this environment.
  1847. !    \begin{macrocode}
  1848. |catcode`| =12
  1849. |gdef|sxmacro@code#1%    \end{macrocode*}[#1|end[macrocode*]]
  1850. !%    \end{macrocode}
  1851. !    because the \verb+\catcode+ changes have been made local by
  1852. !    commencing a
  1853. !    new group, there now follows the matching \verb+\endgroup+
  1854. !    in a rather
  1855. !    unusual style of writing.
  1856. !    \begin{macrocode}
  1857. |endgroup
  1858. !%    \end{macrocode}
  1859. \catcode`\!=12
  1860. % \end{macro}
  1861. % \end{macro}
  1862. %
  1863. %
  1864. %
  1865. %
  1866. % \subsection{Macros for the `documentation parts'}
  1867. %
  1868. %
  1869. % \begin{macro}{\DescribeMacro}
  1870. % \begin{macro}{\Describe@Macro}
  1871. % \changes{v1.5v}{90/01/28}{Macro added.}
  1872. % \changes{v1.5j}{89/06/09}{ignorespaces added as a temporary fix.}
  1873. % \begin{macro}{\DescribeEnv}
  1874. % \begin{macro}{\Describe@Env}
  1875. % \changes{v1.5v}{90/01/28}{Macro added.}
  1876. % \changes{v1.5j}{89/06/09}{ignorespaces added as a temporary fix.}
  1877. %    The \verb+\DescribeMacro+ and \verb+\DescribeEnv+ macros should
  1878. %    print their arguments in the margin and produce an index entry.
  1879. %    We simply use \verb+\marginpar+ to get the desired result. This
  1880. %    is however not the best solution because the labels might be
  1881. %    slightly misplaced. One also might get a lot of `marginpar moved'
  1882. %    messages which are hard-wired into the \LaTeX{} output
  1883. %    routine.\footnote{It might be better to change these macros into
  1884. %    environments like the {\sf macro} environment.} First we change
  1885. %    to horizontal mode if necessary. The \LaTeX{} macros
  1886. %    \verb+\@bsphack+ and \verb+\@esphack+ are used to make those
  1887. %    commands invisible (i.e.\ to normalize the surrounding space and
  1888. %    to make the \verb+\spacefactor+ transparent).
  1889. % \changes{v1.5v}{90/01/28}{`MakePrivateLetters added.}
  1890. %    \begin{macrocode}
  1891. \def\DescribeMacro{\leavevmode\@bsphack
  1892. %    \end{macrocode}
  1893. %    When documenting the code for the {\tt amstex.sty} option we
  1894. %    encountered a bug: the \verb+\catcode+ of \verb+@+ was active and
  1895. %    therefore couldn't be used in command names. So we first have to
  1896. %    make sure that we get all \verb+\catcode+s right by calling
  1897. %    \verb+\MakePrivateLetters+ inside a group. Then we call
  1898. %    \verb+\Describe@Macro+ to do the work.
  1899. %    \begin{macrocode}
  1900.    \begingroup\MakePrivateLetters\Describe@Macro}
  1901. \def\Describe@Macro#1{\endgroup
  1902.               \marginpar{\raggedleft\PrintDescribeMacro{#1}}%
  1903. %    \end{macrocode}
  1904. %    Note the use of \verb+\raggedleft+ to place the output flushed
  1905. %    right. Finally we call a macro which produces the actual index
  1906. %    entry and finish with \verb+\@esphack+ to leave no
  1907. %    trace.\footnote{The whole mechanism won't work because
  1908. %                    of the {\tt\bslash leavevmode} in front.
  1909. %                    As a temporary change {\tt\bslash ignorespaces}
  1910. %                    is added.}
  1911. %    \begin{macrocode}
  1912.               \SpecialUsageIndex{#1}\@esphack\ignorespaces}
  1913. %    \end{macrocode}
  1914. %    The \verb+\DescribeEnv+ macro is completely analogous.
  1915. % \changes{v1.5v}{90/01/28}{`MakePrivateLetters added.}
  1916. %    \begin{macrocode}
  1917. \def\DescribeEnv{\leavevmode\@bsphack\begingroup\MakePrivateLetters
  1918.   \Describe@Env}
  1919. \def\Describe@Env#1{\endgroup
  1920.               \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
  1921.               \SpecialEnvIndex{#1}\@esphack\ignorespaces}
  1922. %    \end{macrocode}
  1923. %    To put the labels in the left margin we have to use the
  1924. %    \verb+\reversemarginpar+ declaration. (This means that the {\tt
  1925. %    doc.sty} can't be used with all style options.) We also make the
  1926. %    \verb+\marginparpush+ zero and \verb+\marginparwidth+ suitably
  1927. %    wide.
  1928. % \changes{v1.5d}{89/4/28}{marginparwith setting added.}
  1929. %    \begin{macrocode}
  1930. \reversemarginpar
  1931. \setlength\marginparpush{0pt}  \setlength\marginparwidth{8pc}
  1932. %    \end{macrocode}
  1933. % \end{macro}
  1934. % \end{macro}
  1935. % \end{macro}
  1936. % \end{macro}
  1937. %
  1938. % \begin{macro}{\bslash}
  1939. % \changes{v1.7a}{92/02/26}{Moved `bslash documentation to `user
  1940. %                           interface' part}
  1941. %    We start a new group in which to hide the alteration of
  1942. %    \verb+\catcode+$\,$s, and make \verb+|+ introduce commands,
  1943. %    whilst \verb+\+ becomes an `other' character.
  1944. %
  1945. %    \begin{macrocode}
  1946. {\catcode`\|=\z@ \catcode`\\=12
  1947. %    \end{macrocode}
  1948. %    Now we are able to define \verb+\bslash+ (globally) to generate a
  1949. %    backslash of \verb+\catcode+ `other'.  We then close this group,
  1950. %    restoring original \verb+\catcode+$\,$s.
  1951. %    \SpecialEscapechar{\|}
  1952. %    \begin{macrocode}
  1953. |gdef|bslash{\}}
  1954. %    \end{macrocode}
  1955. % \end{macro}
  1956. %
  1957. %
  1958. %
  1959. % \begin{macro}{\verbatim}
  1960. % \begin{macro}{\verbatim*}
  1961. % \changes{v1.7i}{92/07/12}{Added changed definition for verbatim!*.}
  1962. %    The {\sf verbatim} environment holds no secrets; it consists of
  1963. %    the normal \LaTeX{} environment.  We also set the
  1964. %    \verb+\@beginparpenalty+ and change to the font given by
  1965. %    \verb+\MacroFont+.
  1966. %    \begin{macrocode}
  1967. \def\verbatim{\@beginparpenalty \predisplaypenalty \@verbatim
  1968.               \MacroFont \frenchspacing \@vobeyspaces \@xverbatim}
  1969. %    \end{macrocode}
  1970. %    We deal in a similar way with the star form of this environment.
  1971. %    \begin{macrocode}
  1972. \@namedef{verbatim*}{\@beginparpenalty \predisplaypenalty \@verbatim
  1973.               \MacroFont \@sxverbatim}
  1974. %    \end{macrocode}
  1975. % \end{macro}
  1976. % \end{macro}
  1977. %
  1978. % \begin{macro}{\@verbatim}
  1979. %    Additionally we redefine the \verb+\@verbatim+ macro so that it
  1980. %    suppresses \verb+%+ characters at the beginning of the line.  The
  1981. %    first lines are copied literally from {\tt latex.tex}.
  1982. % \changes{v1.7i}{92/07/12}{Added `@@par to clear possible `parshape.}
  1983. %    \begin{macrocode}
  1984. \def\@verbatim{\trivlist \item[]\if@minipage\else\vskip\parskip\fi
  1985.       \leftskip\@totalleftmargin\rightskip\z@
  1986.       \parindent\z@\parfillskip\@flushglue\parskip\z@
  1987.       \@@par
  1988.       \@tempswafalse
  1989. %    \end{macrocode}
  1990. %    \verb+\@verbatim+ sets \verb+^^M+, the end of line character, to
  1991. %    be equal to \verb+\par+.  This control sequence is redefined
  1992. %    here; \verb+\@@par+ is the paragraph primitive of \TeX.
  1993. %    \changes{v1.7c}{92/3/24}{Added `interlinepenalty to `par from
  1994. %                             verbatim.sty} 
  1995. %    \begin{macrocode}
  1996.  \def\par{\if@tempswa\hbox{}\fi\@tempswatrue\@@par
  1997.           \penalty\interlinepenalty
  1998. %    \end{macrocode}
  1999. %    We add a control sequence \verb+\check@percent+ to the definition
  2000. %    of \verb+\par+ whose task it is to check for a percent character.
  2001. %    \begin{macrocode}
  2002.    \check@percent}%
  2003. %    \end{macrocode}
  2004. %    The rest is again copied literally from {\tt latex.tex} (less
  2005. %    "\tt").
  2006. % \changes{v1.7a}{92/02/26}{Removed redundant `tt.}
  2007. %    \begin{macrocode}
  2008.  \obeylines \catcode`\`\active \@noligs \let\do\@makeother
  2009.  \dospecials}
  2010. %    \end{macrocode}
  2011. % \end{macro}
  2012. %
  2013. % \begin{macro}{\check@percent}
  2014. %    Finally we define \verb+\check@percent+.  Since this must compare
  2015. %    a character with a percent sign we must first (locally) change
  2016. %    percent's \verb+\catcode+ so that it is seen by \TeX.  The
  2017. %    definition itself is nearly trivial: grab the following
  2018. %    character, check if it is a \verb+%+, and insert it again if not.
  2019. %    At the end of the {\sf verbatim} environment this macro will peek
  2020. %    at the next input line. In that case the argument to
  2021. %    \verb+\check@percent+ might be a \verb+\par+ or a macro with
  2022. %    arguments. Therefore we make the definition \verb+\long+
  2023. %    (\verb+\par+ allowed) and use the normal \verb+\next+ mechanism
  2024. %    to reinsert the argument after the \verb+\fi+ if necessary.
  2025. %  \changes{v1.5i}{89/06/07}{Definition changed to `long'}
  2026. %  \changes{v1.5i}{89/06/07}{Macro `next' used to guard against
  2027. %                            macro with arguments}
  2028. %    There is a subtle problem here, the equal sign between
  2029. %    \verb+\next+ and \verb+#1+ is actually necessary. Do you see why?
  2030. %    The omission of this token once caused a funny error.
  2031. %  \changes{v1.5u}{89/11/14}{equal sign added.}
  2032. %    \begin{macrocode}
  2033. {\catcode`\%=12 
  2034.  \long\gdef\check@percent#1{\ifx #1%\let\next\@empty \else
  2035.                                     \let\next=#1\fi \next}}
  2036. %    \end{macrocode}
  2037. % \end{macro}
  2038. %
  2039. % \begin{macro}{\verb}
  2040. % \changes{v1.7a}{92/02/27}{Now warns about newlines (from
  2041. %                           newdoc with `@noligs added).}
  2042. % We re-define "\verb" to check for newlines in its argument since a
  2043. % missing delimiter is difficult to detect in {\sf doc} source.
  2044. % Although the code is somewhat different, the
  2045. % method follows \cite{art:verbatim}, which should be
  2046. % consulted for commentary.  Perhaps there should be a font-changing
  2047. % hook rather than just using "\tt", but if so it probably should be
  2048. % different from "\MacroFont" since that normally includes "\small"
  2049. % and would look wrong inline.  (There's no particular reason for
  2050. % using lower-casing here to
  2051. % splice in the relevant character, rather than the upper-casing used in
  2052. % the definition of "\SpecialEscapechar"
  2053. % (\S\ref{sect:specialescapechar}); remember that the case
  2054. % shift doesn't touch the control sequence tokens.)
  2055. % \changes{v1.7a}{92/02/28}{Added math math check (from verbatim.sty).}
  2056. %    \begin{macrocode}
  2057. \begingroup
  2058.   \lccode`\~=`\^^M
  2059.   \lowercase{%
  2060.     \gdef\verb{\relax
  2061.       \ifmmode \hbox \else \leavevmode\null \fi
  2062.       \bgroup
  2063.       \tt   \catcode`\`\active \@noligs
  2064.       \let~\verb@err
  2065.       \catcode`\^^M\active
  2066.       \let\do\@makeother \dospecials
  2067.       \@ifstar\@sverb{\@vobeyspaces \frenchspacing \@sverb}}}
  2068. \endgroup
  2069. \def\verb@err{\egroup\@latexerr{\string\verb\space
  2070.                command ended by end of line.}\@ehc}
  2071. %    \end{macrocode}
  2072. % \end{macro}
  2073. % \begin{macro}{\@sverb}
  2074. % \changes{v1.7a}{92/02/27}{Added for `verb change.}
  2075. % \changes{v1.7a}{92/02/28}{Now same as in verbatim.sty.}
  2076. % See \cite{art:verbatim} for commentary.
  2077. %    \begin{macrocode}
  2078. \def\@sverb#1{%
  2079.   \catcode`#1\active  \lccode`\~`#1%
  2080.   \lowercase{\let~\egroup}}
  2081. %    \end{macrocode}
  2082. % \end{macro}
  2083. %
  2084. %
  2085. % \begin{macro}{\macro}
  2086. % \begin{macro}{\m@cro@}
  2087. % \changes{v1.5v}{90/01/28}{`macro@ renamed to `m@cro@ since AmSTeX
  2088. %      defines another macro of the same name.}
  2089. % \begin{macro}{\macro@cnt}
  2090. % \begin{macro}{\macro@level}
  2091. %    \label{page:macro} The {\sf macro} environment is implemented as
  2092. %    a {\sf trivlist} environment, whereby in order that the macro
  2093. %    names can be placed under one another in the margin
  2094. %    (corresponding to the macro's nesting depth), the macro
  2095. %    \verb+\makelabel+ must be altered.  In order to store the nesting
  2096. %    depth, we use a counter. We also need a counter to count the
  2097. %    number of nested {\sf macro} environments.
  2098. % \changes{v1.5k}{89/08/17}{Fix for save stack problem.}
  2099. %    \begin{macrocode}
  2100. \newcount\macro@cnt \macro@cnt=0
  2101. \newcount\macro@level \macro@level=0
  2102. %    \end{macrocode}
  2103. %    The environment takes an argument---the macro name to be
  2104. %    described.  Since this name may contain special `letters' we have
  2105. %    to re-\verb+\catcode+ them before scanning the argument. This is
  2106. %    done by the \verb+\MakePrivateLetters+ macro.  On toplevel we
  2107. %    start with \verb+\begingroup+ otherwise we simply re-catcode the
  2108. %    special letters and call \verb+\m@cro@+. Therefore the
  2109. %    \verb+\endgroup+ at the start of this macro will cancel the group
  2110. %    opened by the \verb+\begin+ macro if we are already inside a {\sf
  2111. %    macro} environment. This avoids problems with the save-stack on
  2112. %    small systems since then the \verb+\trivlist+ used later on will
  2113. %    not put anything onto this stack.
  2114. % \changes{v1.5k}{89/08/17}{Fix for save stack problem.}
  2115. % \changes{v1.7a}{92/02/26}{Catcode backslash to other (from newdoc).}
  2116. %    \begin{macrocode}
  2117. \def\macro{%
  2118.    \ifnum\macro@level=\z@ \begingroup \fi
  2119.    \catcode`\\12
  2120.    \MakePrivateLetters \m@cro@}
  2121. %    \end{macrocode}
  2122. %    After scanning the argument we close the group to get the normal
  2123. %    \verb+\catcode+$\,$s back. Then we assign a special value to
  2124. %    \verb+\topsep+ and start a {\sf trivlist} environment.
  2125. %    Additionally we advance the \verb+\macro@level+ counter to keep
  2126. %    track of the number of nested {\sf macro} environments.
  2127. % \changes{v1.5f}{89/5/07}{MacroTopsep parameter added.}
  2128. % \changes{v1.5k}{89/08/17}{Fix for save stack problem.}
  2129. %    \begin{macrocode}
  2130. \long\def\m@cro@#1{\endgroup \topsep\MacroTopsep \trivlist
  2131.    \advance\macro@level\@ne
  2132. %    \end{macrocode}
  2133. % We also save the name being described in \verb+\saved@macroname+ for
  2134. % use in conjunction with the \verb+\changes+ macro.
  2135. %    \begin{macrocode}
  2136.    \edef\saved@macroname{\string#1}%
  2137. %    \end{macrocode}
  2138. %    Now there follows a variation of \verb+\makelabel+ which is used
  2139. %    should the environment not be nested, or should it lie between
  2140. %    two successive \verb+\begin{macro}+ instructions or explanatory
  2141. %    text.  One can recognize this with the switch \verb+\if@inlabel+
  2142. %    which will be \verb+true+ in the case of successive \verb+\item+
  2143. %    commands.
  2144. %    \begin{macrocode}
  2145.   \def\makelabel##1{\llap{##1}}%
  2146. %    \end{macrocode}
  2147. %    If \verb+@inlabel+ is \verb+true+ and if $\verb=\macro@cnt= > 0$
  2148. %    then the above definition needs to be changed, because in this
  2149. %    case \LaTeX{} would otherwise put the labels all on the same line
  2150. %    and this would lead to them being overprinted on top of each
  2151. %    other.  Because of this \verb+\makelabel+ needs to be redefined
  2152. %    in this case.
  2153. %    \begin{macrocode}
  2154.   \if@inlabel
  2155. %    \end{macrocode}
  2156. %    If \verb+\macro@cnt+ has the value $1$, then we redefine
  2157. %    \verb+\makelabel+ so that the label will be positioned in the
  2158. %    second line of the margin.  As a result of this, two macro names
  2159. %    appear correctly, one under the other.  It's important whilst
  2160. %    doing this that the generated label box is not allowed to have
  2161. %    more depth than a normal line since otherwise the distance
  2162. %    between the first two text lines of \TeX{} will be incorrectly
  2163. %    calculated. The definition should then look like:
  2164. %\begin{verbatim}
  2165. %     \def\makelabel##1{\llap{\vtop to \baselineskip
  2166. %          {\hbox{\strut}\hbox{##1}\vss}}}
  2167. %\end{verbatim}
  2168. %    Completely analogous to this is the case where labels need to be
  2169. %    placed one under the other.  The lines above are only an example
  2170. %    typeset with the {\sf verbatim} environment. To produce the real
  2171. %    definition we save the value of \verb+\macro@cnt+ in
  2172. %    \verb+\count@+ and empty the temp macro \verb+\@tempa+ for later
  2173. %    use.
  2174. %    \begin{macrocode}
  2175.     \let\@tempa\@empty \count@\macro@cnt
  2176. %    \end{macrocode}
  2177. %    In the following loop we append for every already typeset label
  2178. %    an \verb+\hbox{\strut}+ to the definition of \verb+\@tempa+.
  2179. %    \begin{macrocode}
  2180.     \loop \ifnum\count@>\z@
  2181.       \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
  2182. %    \end{macrocode}
  2183. %    Now be put the definition of \verb+\makelabel+ together.
  2184. % \changes{v1.5b}{89/04/27}{vbox to vtop changed in makelabel (test)}
  2185. % \changes{v1.5e}{89/04/28}{ht strutbox changed to baselineskip (test)}
  2186. %    \begin{macrocode}
  2187.     \edef\makelabel##1{\llap{\vtop to\baselineskip
  2188.                                {\@tempa\hbox{##1}\vss}}}%
  2189. %    \end{macrocode}
  2190. %    Next we increment the value of the nesting depth counter.  This
  2191. %    value inside the {\sf macro} environment is always at least one
  2192. %    after this point, but its toplevel definition is zero. Provided
  2193. %    this environment has been used correctly, $\verb+\macro@cnt+=0$
  2194. %    should not occur when $\verb+@inlabel+=\sf true$.  It is however
  2195. %    possible if this environment is used within other list
  2196. %    environments (but this would have little point).
  2197. %    \begin{macrocode}
  2198.     \advance \macro@cnt \@ne
  2199. %    \end{macrocode}
  2200. %    If \verb+@inlabel+ is false we reset \verb+\macro@cnt+ assuming
  2201. %    that there is enough room to print the macro name without
  2202. %    shifting.
  2203. %    \begin{macrocode}
  2204.   \else  \macro@cnt\@ne  \fi
  2205. %    \end{macrocode}
  2206. %    Now the label will be produced using \verb+\item+. The following
  2207. %    line is only a hack saving the day until a better solution is
  2208. %    implemented.  We have to face two problems: the argument might be
  2209. %    a \verb+\par+ which is forbidden in the argument of other macros
  2210. %    if they are not defined as \verb+\long+, or it is something like
  2211. %    \verb+\iffalse+ or \verb+\else+, i.e.\ something which will be
  2212. %    misinterpreted when \TeX{} is skipping conditional text. In both
  2213. %    cases \verb+\item+ will bomb, so we protect the argument by using
  2214. %    \verb+\string+.
  2215. %    \begin{macrocode}
  2216.   \edef\@tempa{\noexpand\item[\noexpand\PrintMacroName{\string#1}]}%
  2217.   \@tempa
  2218. %    \end{macrocode}
  2219. %    At this point we also produce an index entry.  Because it is not
  2220. %    known which index sorting program will be used, we do not use the
  2221. %    command \verb+\index+, but rather a command
  2222. %    \verb+\SpecialMainIndex+ after advancing the counter for indexing
  2223. %    by line number.  This may be redefined by the user in
  2224. %    order to generate an index entry which will be understood by the
  2225. %    index program in use (note the definition of
  2226. %    \verb+\SpecialMainIndex+ for our installation).
  2227. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  2228. %    \begin{macrocode}
  2229.   {\advance\c@CodelineNo\@ne\SpecialMainIndex{#1}\nobreak}%
  2230. %    \end{macrocode}
  2231. %    The \verb+\nobreak+ is needed to prevent a page break after the
  2232. %    \verb+\write+ produced by the \verb+\SpecialMainIndex+ macro.  We
  2233. %    exclude the new macro in the cross-referencing feature, to
  2234. %    prevent spurious non-main entry references.  Regarding possibly
  2235. %    problematic arguments, the implementation takes
  2236. %    care of \verb+\par+ and the conditionals are uncritical.
  2237. %    \changes{v1.7a}{92/03/02}{Removed redundant code checking for
  2238. %                             `par.}^^A
  2239. %    \begin{macrocode}
  2240.   \DoNotIndex{#1}%
  2241. %    \end{macrocode}
  2242. %    Because the space symbol should be ignored between the
  2243. %    \verb+\begin{macro}{...}+ and the following text we must take
  2244. %    care of this with \verb+\ignorespaces+.
  2245. %    \begin{macrocode}
  2246.   \ignorespaces}
  2247. %    \end{macrocode}
  2248. % \end{macro}
  2249. % \end{macro}
  2250. % \end{macro}
  2251. % \end{macro}
  2252. %
  2253. %
  2254. %
  2255. % \begin{macro}{\endmacro}
  2256. %    When ending a {\sf macro} environment we have to cancel the
  2257. %    \verb+\endgroup+ generated by the \verb+\end+ macro as long as we
  2258. %    are still inside another {\sf macro} environment. Therefore
  2259. %    we check the value of the \verb+\macro@level+ counter. Of course
  2260. %    this counter also has to be decremented.
  2261. %    \SpecialIndex{\macro@cnt}
  2262. % \changes{v1.5k}{89/08/17}{Fix for save stack problem.}
  2263. %    \begin{macrocode}
  2264. \def\endmacro{%
  2265.    \endtrivlist
  2266.    \ifnum\macro@level>\@ne \advance\macro@level\m@ne \begingroup \fi}
  2267. %    \end{macrocode}
  2268. %  \end{macro}
  2269. %
  2270. % \begin{macro}{\MacroTopsep}
  2271. %    Here is the default value for the \verb+\MacroTopsep+ parameter
  2272. %    used above.
  2273. %    \begin{macrocode}
  2274. \newskip\MacroTopsep     \MacroTopsep = 7pt plus 2pt minus 2pt
  2275. %    \end{macrocode}
  2276. % \end{macro}
  2277. %
  2278. %
  2279. %
  2280. %
  2281. %
  2282. % \subsection{Formatting the margin}
  2283. %
  2284. % The following three macros should be user definable.
  2285. % Therefore we define those macros only if they have not already
  2286. % been defined.
  2287. %
  2288. % \begin{macro}{\PrintMacroName}
  2289. % \begin{macro}{\PrintDescribeMacro}
  2290. % \begin{macro}{\PrintDescribeEnv}
  2291. %    The formatting of the macro name in the left margin is done by
  2292. %    these macros. We first set a \verb+\strut+ to get the height and
  2293. %    depth of the normal lines. Then we change to the
  2294. %    \verb+\MacroFont+ using \verb+\string+ to \verb+\catcode+ the
  2295. %    argument to other (assuming that it is a macro name). Finally we
  2296. %    print a space.  The font change remains local since this macro
  2297. %    will be called inside an \verb+\hbox+.
  2298. %    \begin{macrocode}
  2299. \@ifundefined{PrintMacroName}
  2300.    {\def\PrintMacroName#1{\strut \MacroFont \string #1\ }}{}
  2301. %    \end{macrocode}
  2302. %    We use the same formatting conventions when describing a macro.
  2303. %    \begin{macrocode}
  2304. \@ifundefined{PrintDescribeMacro}
  2305.    {\def\PrintDescribeMacro#1{\strut \MacroFont \string #1\ }}{}
  2306. %    \end{macrocode}
  2307. %    To format the name of a new environment there is no need to use
  2308. %    \verb+\string+.
  2309. %    \begin{macrocode}
  2310. \@ifundefined{PrintDescribeEnv}
  2311.    {\def\PrintDescribeEnv#1{\strut \MacroFont #1\ }}{}
  2312. %    \end{macrocode}
  2313. % \end{macro}
  2314. % \end{macro}
  2315. % \end{macro}
  2316. %
  2317. %
  2318. %
  2319. % \subsection{Creating index entries by scanning `macrocode'}
  2320. %
  2321. %  The following macros ensure that index entries are created for each
  2322. %  occurrence of a \TeX-like command (something starting with
  2323. %  `\verb+\+') providing indexing has been turned on with "\PageIndex"
  2324. %  or "\CodelineIndex".  With the default definitions of
  2325. %  \verb+\SpecialMainIndex+, etc., the index file generated is
  2326. %  intended to be processed by Chen's {\sf makeindex} program
  2327. %  \cite{art:Chen}.
  2328. %
  2329. %
  2330. %  Of course, in {\em this\/} style file itself we've sometimes had to
  2331. %  make \verb+|+ take the r\^ole of \TeX's escape character to
  2332. %  introduce command names at places where \verb+\+ has to belong to
  2333. %  some other category.  Therefore, we may also need to recognize
  2334. %  \verb+|+ as the introducer for a command when setting the text
  2335. %  inside the {\sf macrocode} environment.  Other users may have the
  2336. %  need to make similar reassignments for their macros.
  2337. %
  2338. %
  2339. % \begin{macro}{\SpecialEscapechar}\label{sect:specialescapechar}
  2340. % \begin{macro}{\active@escape@char}
  2341. % \begin{macro}{\special@escape@char}
  2342. %    The macro \verb+\SpecialEscapechar+ is used to denote a special
  2343. %    escape character for the next {\sf macrocode} environment. It has
  2344. %    one argument---the new escape character given as a
  2345. %    `single-letter' control sequence.  Its main purpose is defining
  2346. %    \verb+\special@escape@char+ to produce the chosen escape
  2347. %    character \verb+\catcode+$\,$d to 12 and
  2348. %    \verb+\active@escape@char+ to produce the same character but with
  2349. %    \verb+\catcode+ 13.
  2350. %
  2351. %    The macro \verb+\special@escape@char+ is used to {\em print\/}
  2352. %    the escape character while \verb+\active@escape@char+ is needed
  2353. %    in the definition of \verb+\init@crossref+ to start the scanning
  2354. %    mechanism.
  2355. %
  2356. %    In the definition of \verb+\SpecialEscapechar+ we need an
  2357. %    arbitrary character with \verb+\catcode+ 13. We use `\~{}' and
  2358. %    ensure that it is active. The \verb+\begingroup+ is used to make
  2359. %    a possible change local to the expansion of
  2360. %    \verb+\SpecialEscapechar+.
  2361. % \changes{v1.7g}{92/6/19}{Making tilde active moved outside
  2362. %    definition}
  2363. %    \begin{macrocode}
  2364. \begingroup
  2365. \catcode`\~\active
  2366. \gdef\SpecialEscapechar#1{%
  2367.     \begingroup
  2368. %    \end{macrocode}
  2369. %    Now we are ready for the definition of
  2370. %    \verb+\active@escape@char+.  It's a little tricky: we first
  2371. %    define locally the uppercase code of `\~{}' to be the new escape
  2372. %    character.
  2373. %    \begin{macrocode}
  2374.      \uccode`\~`#1%
  2375. %    \end{macrocode}
  2376. %    Around the definition of \verb+\active@escape@char+ we place an
  2377. %    \verb+\uppercase+ command. Recall that the expansion of
  2378. %    \verb+\uppercase+ changes characters according to their
  2379. %    \verb+\uccode+, but leaves their \verb+\catcode+$\,$s untouched
  2380. %    (cf.\ \TeX{}book page 41).
  2381. %    \begin{macrocode}
  2382.      \uppercase{\gdef\active@escape@char{~}}%
  2383. %    \end{macrocode}
  2384. %    The definition of \verb+\special@escape@char+ is easier, we use
  2385. %    \verb+\string+ to \verb+\catcode+ the argument of
  2386. %    \verb+\SpecialEscapechar+ to 12 and suppress the preceding
  2387. %    \verb+\escapechar+.
  2388. %    \begin{macrocode}
  2389.      \escapechar\m@ne  \xdef\special@escape@char{\string#1}%
  2390. %    \end{macrocode}
  2391. %    Now we close the group and end the definition: the value of
  2392. %    \verb+\escapechar+ as well as the \verb+\uccode+ and
  2393. %    \verb+\catcode+ of `\~{}' will be restored.
  2394. %    \begin{macrocode}
  2395.    \endgroup}
  2396. \endgroup
  2397. %    \end{macrocode}
  2398. % \end{macro}
  2399. % \end{macro}
  2400. % \end{macro}
  2401. %
  2402. %
  2403. %
  2404. %
  2405. % \begin{macro}{\init@crossref}
  2406. %    The replacement text of \verb+\init@crossref+ should fulfill the
  2407. %    following tasks:
  2408. %    \begin{itemize}
  2409. %       \parindent4em
  2410. %       \item[1)]
  2411. %          \verb+\catcode+ all characters used in macro names to
  2412. %          11 (i.e.\ `letter').
  2413. %       \item[2)]
  2414. %          \verb+\catcode+ the `\verb+\+' character to 13
  2415. %          (i.e.\ `active').
  2416. %       \item[3a)]
  2417. %          \verb+\let+ the `\verb+\+' equal \verb+\scan@macro+
  2418. %          (i.e.\ start the macro scanning mechanism) if there is
  2419. %          no  special escape character (i.e.\ the
  2420. %          \verb+\special@escape@char+ is `\verb+\+').
  2421. %       \item[3b)]
  2422. %          Otherwise \verb+\let+ it equal \verb+\bslash+, i.e.\
  2423. %          produce a printable \verb+\+.
  2424. %       \item[4)]
  2425. %          Make the \meta{special escape character} active.
  2426. %       \item[5)]
  2427. %          \verb+\let+ the active version of the special escape
  2428. %          character
  2429. %          (i.e.\ the expansion of \verb+\active@escape@char+) equal
  2430. %          \verb+\scan@macro+.
  2431. %    \end{itemize}
  2432. %    The reader might ask why we bother to \verb+\catcode+ the
  2433. %    `\verb+\+' first to 12 (at the end of \verb+\macro@code+) then
  2434. %    re-\verb+\catcode+ it to 13 in order to produce a $\verb+\+_{12}$
  2435. %    in case 3b) above.  This is done because we have to ensure that
  2436. %    `\verb+\+' has \verb+\catcode+ 13 within the {\sf macrocode}
  2437. %    environment.  Otherwise the delimiter for the argument of
  2438. %    \verb+\xmacro@code+ would not be found (parameter matching
  2439. %    depends on \verb+\catcode+$\,$s).
  2440. %
  2441. %    Therefore we first re-\verb+\catcode+ some characters.
  2442. %    \begin{macrocode}
  2443. \begingroup   \catcode`\|=\z@  \catcode`\\=\active
  2444. %    \end{macrocode}
  2445. %    We carry out tasks 2) and 3b) first.
  2446. %    \SpecialEscapechar{\|}
  2447. %    \begin{macrocode}
  2448. |gdef|init@crossref{|catcode`|\|active   |let\|bslash
  2449. %    \end{macrocode}
  2450. %    Because of the popularity of the `\verb+@+' character as a
  2451. %    `letter' in macros, we normally have to change its
  2452. %    \verb+\catcode+ here, and thus fulfill task 1).  But the macro
  2453. %    designer might use other characters as private letters as well,
  2454. %    so we use a macro to do the \verb+\catcode+ switching.
  2455. %    \SpecialEscapechar\|
  2456. %    \begin{macrocode}
  2457.     |MakePrivateLetters
  2458. %    \end{macrocode}
  2459. %    Now we \verb+\catcode+ the special escape character to 13 and
  2460. %    \verb+\let+ it equal \verb+\scan@macro+, i.e.\ fulfill tasks 4)
  2461. %    and 5). Note the use of \verb+\expandafter+ to insert the chosen
  2462. %    escape character saved in \verb+\special@escape@char+ and
  2463. %    \verb+\active@escape@char+.
  2464. %    \SpecialEscapechar\|
  2465. %    \begin{macrocode}
  2466.     |catcode|expandafter`|special@escape@char|active
  2467.     |expandafter|let|active@escape@char|scan@macro}
  2468. |endgroup
  2469. %    \end{macrocode}
  2470. %    If there is no special escape character, i.e.\ if
  2471. %    \verb+\SpecialEscapechar+ is \verb+\\+, the second last line will
  2472. %    overwrite the previous definition of $\verb+\+_{13}$.  In this
  2473. %    way all tasks are fulfilled.
  2474. %
  2475. %    For happy documenting we give default values to
  2476. %    \verb+\special@escape@char+ and \verb+\active@escape@char+ with
  2477. %    the following line:
  2478. %    \begin{macrocode}
  2479. \SpecialEscapechar{\\}
  2480. %    \end{macrocode}
  2481. % \end{macro}
  2482. %
  2483. %
  2484. %
  2485. % \begin{macro}{\MakePrivateLetters}
  2486. %    Here is the default definition of this command, which makes just
  2487. %    the \verb+@+ into a letter. The user may change it if he/she
  2488. %    needs more or other characters masquerading as letters.
  2489. %    \begin{macrocode}
  2490. \@ifundefined{MakePrivateLetters}
  2491.     {\let\MakePrivateLetters\makeatletter}{}
  2492. %    \end{macrocode}
  2493. % \end{macro}
  2494. %
  2495. % \begin{macro}{\close@crossref}
  2496. %    At the end of a cross-referencing part we prepare ourselves for
  2497. %    the next one by setting the escape character to `\verb+\+'.
  2498. %    \begin{macrocode}
  2499. \def\close@crossref{\SpecialEscapechar\\}
  2500. %    \end{macrocode}
  2501. % \end{macro}
  2502. %
  2503. %
  2504. %
  2505. %
  2506. % \subsection{Macros for scanning macro names}
  2507. %
  2508. % \begin{macro}{\scan@macro}
  2509. % \changes{v1.5k}{89/09/04}{Support for checksum added.}
  2510. % \begin{macro}{\macro@namepart}
  2511. %    The \verb+\init@crossref+ will have made \verb+\active+ our
  2512. %    \verb+\special@escape@char+, so that each
  2513. %    \verb+\active@escape@char+ will invoke \verb+\scan@macro+ when
  2514. %    within the {\sf macrocode} environment.  By this means, we can
  2515. %    automatically add index entries for every \TeX-like command which
  2516. %    is met whilst setting (in verbatim) the contents of {\sf
  2517. %    macrocode} environments.
  2518. %    \begin{macrocode}
  2519. \def\scan@macro{%
  2520. %    \end{macrocode}
  2521. %    First we output the character which triggered this macro.  Its
  2522. %    version \verb+\catcode+$\,$d to 12 is saved in
  2523. %    \verb+\special@escape@char+. We also call \verb+\step@checksum+
  2524. %    to generate later on a proper check-sum (see section
  2525. %    \ref{sec:checksum} for details).
  2526. %    \begin{macrocode}
  2527.    \special@escape@char
  2528.    \step@checksum
  2529. %    \end{macrocode}
  2530. %    If the {\sf macrocode} environment contains, for example, the
  2531. %    command \verb+\\+, the second \verb+\+ should not start the
  2532. %    scanning mechanism. Therefore we use a switch to decide if
  2533. %    scanning of macro names is allowed.
  2534. %    \begin{macrocode}
  2535.    \ifscan@allowed
  2536. %    \end{macrocode}
  2537. %    The macro assembles the letters forming a \TeX\ command in
  2538. %    \verb+\macro@namepart+ so this is initially cleared; we then set
  2539. %    \verb+\next+ to the {\it first\/} character following the
  2540. %    \verb+\+ and call \verb+\macro@switch+ to determine whether that
  2541. %    character is a letter or not.
  2542. %    \begin{macrocode}
  2543.       \let\macro@namepart\@empty
  2544.       \def\next{\futurelet\next\macro@switch}%
  2545. %    \end{macrocode}
  2546. %    As you recognize, we actually did something else, because we have
  2547. %    to defer the \verb+\futurelet+ call until after the final
  2548. %    \verb+\fi+.  If, on the other hand, the scanning is disabled we
  2549. %    simply \verb+\let+ \verb+\next+ equal `empty'.
  2550. %    \begin{macrocode}
  2551.    \else \let\next\@empty \fi
  2552. %    \end{macrocode}
  2553. %    Now we invoke \verb+\next+ to carry out what's needed.
  2554. %    \begin{macrocode}
  2555.    \next}
  2556. %    \end{macrocode}
  2557. % \end{macro}
  2558. % \end{macro}
  2559. %
  2560. %
  2561. % \begin{macro}{\ifscan@allowed}
  2562. % \begin{macro}{\scan@allowedtrue}
  2563. % \begin{macro}{\scan@allowedfalse}
  2564. %    \verb+\ifscan@allowed+ is the switch used above to determine if
  2565. %    the \verb+\active@escape@char+\SpecialIndex{\active@escape@char}
  2566. %    should start the macro scanning mechanism.
  2567. %    \begin{macrocode}
  2568. \newif\ifscan@allowed    \scan@allowedtrue
  2569. %    \end{macrocode}
  2570. % \end{macro}
  2571. % \end{macro}
  2572. % \end{macro}
  2573. %
  2574. %
  2575. % \begin{macro}{\EnableCrossrefs}
  2576. % \begin{macro}{\DisableCrossrefs}
  2577. %    At this point we might define two macros which allow the user to
  2578. %    disable or enable the cross-referencing mechanism. Processing of
  2579. %    files will be faster if only main index entries are generated
  2580. %    (i.e., if \verb+\DisableCrossrefs+ is in force).
  2581. %    \begin{macrocode}
  2582. \def\DisableCrossrefs{\@bsphack\scan@allowedfalse\@esphack}
  2583. %    \end{macrocode}
  2584. %    The macro \verb+\EnableCrossrefs+ will also disable any
  2585. %    \verb+\DisableCrossrefs+ command encountered afterwards.
  2586. %    \begin{macrocode}
  2587. \def\EnableCrossrefs{\@bsphack\scan@allowedtrue
  2588.                      \def\DisableCrossrefs{\@bsphack\@esphack}\@esphack}
  2589. %    \end{macrocode}
  2590. % \end{macro}
  2591. % \end{macro}
  2592. %
  2593. %
  2594. %
  2595. %
  2596. % \begin{macro}{\macro@switch}
  2597. %    Now that we have the character which follows the escape character
  2598. %    (in \verb+\next+), we can determine whether it's a `letter'
  2599. %    (which probably includes \verb+@+).
  2600. %
  2601. %    If it is, we let \verb+\next+ invoke a macro which assembles the
  2602. %    full command name.
  2603. %    \begin{macrocode}
  2604. \def\macro@switch{\ifcat\noexpand\next a%
  2605.      \let\next\macro@name
  2606. %    \end{macrocode}
  2607. %    Otherwise, we have a `single-character' command name.  For all
  2608. %    those single-character names, we use \verb+\short@macro+ to
  2609. %    process them into suitable index entries.
  2610. %    \begin{macrocode}
  2611.      \else \let\next\short@macro  \fi
  2612. %    \end{macrocode}
  2613. %    Now that we know what macro to use to process the macro name, we
  2614. %    invoke it~\ldots
  2615. %    \begin{macrocode}
  2616.    \next}
  2617. %    \end{macrocode}
  2618. % \end{macro}
  2619. %
  2620. %
  2621. % \begin{macro}{\short@macro}
  2622. % \changes{v1.5c}{89/4/27}{Corrected bad bug by putting the
  2623. %                         scan@allowedfalse macro before printing
  2624. %                         the argument.}
  2625. % \changes{v1.7a}{92/03/10}{Ensure character stored in `macro@namepart
  2626. %                           as `letter' so index exclusion works.}
  2627. %    This macro will be invoked (with a single character as parameter)
  2628. %    when a single-character macro name has been spotted whilst
  2629. %    scanning within the {\sf macrocode} environment.
  2630. %
  2631. %    First we take a look at the \verb+\index@excludelist+ to see
  2632. %    whether this macro name should produce an index entry.  This is
  2633. %    done by the \verb+\ifnot@excluded+ macro which assumes that the
  2634. %    macro name is saved in \verb+\macro@namepart+.  The character
  2635. %    mustn't be stored with a special category code or exclusion from
  2636. %    the index won't work, so we employ the case-changing trick used
  2637. %    elsewhere.  Since the argument might be an active character,
  2638. %    \verb+\string+ is used to normalize it. 
  2639. %    \begin{macrocode}
  2640. \def\short@macro#1{\begingroup
  2641.    \catcode`\&=11  \uccode`\&=\expandafter`\string#1%
  2642.    \uppercase{\def\macro@namepart{&}}%
  2643.    \endgroup
  2644.    \ifnot@excluded
  2645. %    \end{macrocode}
  2646. %    If necessary the index entry is produced by the macro
  2647. %    \verb+\produce@index+. Depending on the actual character seen,
  2648. %    this macro has to do different things, so we pass the character
  2649. %    as an argument.
  2650. %    \begin{macrocode}
  2651.      \produce@index{#1}\fi
  2652. %    \end{macrocode}
  2653. %    Then we disable the cross-referencing mechanism with
  2654. %    \verb+\scan@allowedfalse+ and print the actual character. The
  2655. %    index entry was generated first to ensure that no page break
  2656. %    intervenes (recall that a \verb+^^M+ will start a new line).
  2657. %    \begin{macrocode}
  2658.     \scan@allowedfalse#1%
  2659. %    \end{macrocode}
  2660. %    After typesetting the character we can safely enable the
  2661. %    cross-referencing feature again. Note that this macro won't be
  2662. %    called (since \verb+\macro@switch+ won't be called) if
  2663. %    cross-referencing is globally disabled.
  2664. %    \begin{macrocode}
  2665.     \scan@allowedtrue }
  2666. %    \end{macrocode}
  2667. % \end{macro}
  2668. %
  2669. %
  2670. %
  2671. % \begin{macro}{\produce@index}
  2672. % \changes{v1.4s}{89/04/23}{Added noexpand to all {\tt\protect\bslash
  2673. %                if} tests
  2674. %               to avoid garbage produced by new active chars}
  2675. % \changes{v1.4s}{89/04/23}{Used {\tt\protect\bslash string} for the
  2676. %                          same reason.}
  2677. % \changes{v1.5c}{89/4/27}{Corrected bad bug by placing the
  2678. %                         scan@allowedfalse macro into short@macro}
  2679. %    This macro is supposed to generate a suitable \verb+\SortIndex+
  2680. %    command for a given single-letter control sequence.  We test
  2681. %    first for the cases which involve active characters (i.e.\ the
  2682. %    backslash, the special escape character (if any), the space and
  2683. %    the \verb+^^M+).  Using the \verb+\if+ test (testing for
  2684. %    character codes), we have to ensure that the argument isn't
  2685. %    expanded.
  2686. %    \begin{macrocode}
  2687. \def\produce@index#1{%
  2688.   \if\noexpand#1\special@escape@char
  2689. %    \end{macrocode}
  2690. %    If the character is the special escape character (or the
  2691. %    `\verb+\+' in case there was none) the \verb+\it@is@a+ macro is
  2692. %    used to produce the actual \verb+\SortIndex+ call.
  2693. %    \begin{macrocode}
  2694.      \scan@allowedfalse \it@is@a\special@escape@char \else
  2695. %    \end{macrocode}
  2696. %    Next comes the test for a `\verb+\+' which must be the
  2697. %    $\verb+\+_{13}$ expanding to \verb+\bslash+.
  2698. %    \begin{macrocode}
  2699.      \if\noexpand#1\bslash \it@is@a\bslash \else
  2700. %    \end{macrocode}
  2701. %    Another possibility is \verb*+ +$_{13}$. Recall that \verb+\space+
  2702. %    produces a \verb*+ +$_{10}$.
  2703. %    \begin{macrocode}
  2704.        \if\noexpand#1\space \it@is@a\space \else
  2705. %    \end{macrocode}
  2706. %    The last\footnote{Well, it isn't the last active character after
  2707. %                      all. I added {\tt \bslash @noligs} some days ago
  2708. %                      and now {\tt `} too is active. So we have to make
  2709. %                      sure that such characters don't get expanded in 
  2710. %                      the index.} 
  2711. %    possibility of an active character is \verb+^^M+\@.  In this case
  2712. %    we don't test for character codes, since it is easier to look if
  2713. %    the character is equal to \verb+\par+. (We are inside the {\sf
  2714. %    macrocode} environment.)
  2715. %    \begin{macrocode}
  2716.          \ifx#1\par
  2717. %    \end{macrocode}
  2718. %    If we end up here we have just scanned a \verb+\^^M+ or something
  2719. %    similar. Since this will be treated like \verb*+\ + by \TeX{} we
  2720. %    produce a corresponding index entry.
  2721. %    \begin{macrocode}
  2722.          \it@is@a\space \else
  2723. %    \end{macrocode}
  2724. %    If it is the token \verb+\relax+ we do nothing. This can't happen
  2725. %    when the `doc' option is used in the way described here, but was
  2726. %    added to allow extensions like the {\tt idxverb} option.
  2727. %  \changes{v1.5t}{89/11/14}{Added `relax as a possible token to allow
  2728. %                            extensions.}
  2729. %    \begin{macrocode}
  2730.          \ifx#1\relax \else
  2731. %    \end{macrocode}
  2732. %    The next three branches are needed because of bugs in
  2733. %    our {\sf makeindex} program. You can't produce unbalanced index
  2734. %    entries\footnote{This is possible for \TeX{} if you use
  2735. %                     {\tt\string{$_{12}$ \rm or \tt\string}$_{12}$},
  2736. %                     but {\sf makeindex} will complain.}
  2737. %    and you have to double a percent character. To get around these
  2738. %    restrictions we use special macros to produce the \verb+\index+
  2739. %    calls.\footnote{Brian {\sc Hamilton Kelly} has written fixes for
  2740. %                  all three
  2741. %                  bugs. When they've found their way through all
  2742. %                    installations,
  2743. %                    the lines above will be removed. See 
  2744. %                    page~\pageref{bug:fixes} if you already have them.
  2745. %                    (I'm not sure which versions incorporate these, but
  2746. %                    2.11 is OK.  See also
  2747. %                    \pageref{makeindex:version}.)}
  2748. %    \begin{macrocode}
  2749.            \if\noexpand#1\bgroup \LeftBraceIndex \else
  2750.              \if\noexpand#1\egroup \RightBraceIndex \else
  2751.                \if\noexpand#1\percentchar \PercentIndex \else
  2752. %    \end{macrocode}
  2753. %    All remaining characters are used directly to produce their index
  2754. %    entries. This is possible even for the characters which have
  2755. %    special meanings in the index program, provided we quote the
  2756. %    characters.  (This is correctly done in \verb+\it@is@a+.)
  2757. %    \begin{macrocode}
  2758.                  \it@is@a{\string#1}%
  2759. %    \end{macrocode}
  2760. %    We now need a whole pile of \verb+\fi+$\,$s to match up with
  2761. %    the \verb+\if+$\,$s.
  2762. %    \begin{macrocode}
  2763.        \fi \fi \fi \fi \fi \fi \fi \fi}
  2764. %    \end{macrocode}
  2765. % \end{macro}
  2766. %
  2767. %
  2768. %
  2769. % \begin{macro}{\macro@name}
  2770. %    We now come to the macro which assembles command names which
  2771. %    consist of one or more `letters' (which might well include
  2772. %    \verb+@+ symbols, or anything else which has a \verb+\catcode+ of
  2773. %    11).
  2774. %
  2775. %    To do this we add the `letter' to the existing definition of
  2776. %    \verb+\macro@namepart+ (which you will recall was originally set
  2777. %    to \verb+\@empty+).
  2778. %    \begin{macrocode}
  2779. \def\macro@name#1{\edef\macro@namepart{\macro@namepart#1}%
  2780. %    \end{macrocode}
  2781. %    Then we grab hold of the {\em next\/} single character and let
  2782. %    \verb+\more@macroname+ determine whether it belongs to the letter
  2783. %    string forming the command name or is a `non-letter'.
  2784. %    \begin{macrocode}
  2785.      \futurelet\next\more@macroname}
  2786. %    \end{macrocode}
  2787. % \end{macro}
  2788. %
  2789. %
  2790. %
  2791. %
  2792. %
  2793. % \begin{macro}{\more@macroname}
  2794. %
  2795. %    This causes another call of \verb+\macro@name+ to add in the next
  2796. %    character, if it is indeed a `letter'.
  2797. %    \begin{macrocode}
  2798. \def\more@macroname{\ifcat\noexpand\next a%
  2799.      \let\next\macro@name
  2800. %    \end{macrocode}
  2801. %    Otherwise, it finishes off the index entry by invoking
  2802. %    \verb+\macro@finish+.
  2803. %    \begin{macrocode}
  2804.      \else \let\next\macro@finish \fi
  2805. %    \end{macrocode}
  2806. %    Here's where we invoke whatever macro was \verb+\let+ equal to
  2807. %    \verb+\next+.
  2808. %    \begin{macrocode}
  2809.      \next}
  2810. %    \end{macrocode}
  2811. % \end{macro}
  2812. %
  2813. %
  2814. %
  2815. %
  2816. %
  2817. % \begin{macro}{\macro@finish}
  2818. %    When we've assembled the full `letter'-string which forms the
  2819. %    command name, we set the characters forming the entire command
  2820. %    name, and generate an appropriate \verb+\index+ command (provided
  2821. %    the command name is not on the list of exclusions).  The
  2822. %    `\verb+\+' is already typeset; therefore we only have to output
  2823. %    all `letters' saved in \verb+\macro@namepart+.
  2824. %    \begin{macrocode}
  2825. \def\macro@finish{%
  2826.   \macro@namepart
  2827. %    \end{macrocode}
  2828. %    Then we call \verb+\ifnot@excluded+ to decide whether we have to
  2829. %    produce an index entry. The construction with \verb+\@tempa+ is
  2830. %    needed because we want the expansion of \verb+\macro@namepart+ in
  2831. %    the \verb+\index+ command.\footnote{The {\tt \bslash index}
  2832. %    command will expand its argument in the {\tt\bslash output}
  2833. %    routine.  At this time {\tt\bslash macro@namepart} might have a
  2834. %    new value.}
  2835. %    \begin{macrocode}
  2836.   \ifnot@excluded
  2837.      \edef\@tempa{\noexpand\SpecialIndex{\bslash\macro@namepart}}%
  2838.      \@tempa  \fi}
  2839. %    \end{macrocode}
  2840. % \end{macro}
  2841. %
  2842. %
  2843. %
  2844. %
  2845. %
  2846. % \subsection[The index exclude list]{The index exclude
  2847. %             list\footnotemark} 
  2848. %            \footnotetext{Warning: the incomplete commentary on {\tt
  2849. %                          \bslash DoNotIndex} and the macros it calls
  2850. %                          was written by Dave Love.} 
  2851. %
  2852. %    The internal form of the index exclude list is
  2853. % \begin{quote}
  2854. % \meta{macro name}\verb+,+\meta{macro name}\verb+,+
  2855. % \ldots\verb+,+
  2856. % \end{quote}
  2857. % where \meta{macro name} is a macro name like
  2858. % $"\"_{12}"p"{_{11}}"@"_{11}$ or $"\"_{12}"$"_{11}$.  Note that the "\"
  2859. % has category `other' and the other characters in the name are all
  2860. % `letter', regardless of their normal category. 
  2861. %
  2862. % \begin{macro}{\DoNotIndex}
  2863. %    This macro is used to suppress macro names in the index.  It
  2864. %    starts off with a new group because we have to change the
  2865. %    \verb+\catcode+$\,$s of all characters which belong to `letters'
  2866. %    while macros are defined.
  2867. %    \begin{macrocode}
  2868. \def\DoNotIndex{\begingroup \MakePrivateLetters
  2869.     \catcode`\\12
  2870. %    \end{macrocode}
  2871. %    Then we call the macro which actually reads the argument given by
  2872. %    the user.
  2873. %    \begin{macrocode}
  2874.     \do@not@index}
  2875. %    \end{macrocode}
  2876. % \end{macro}
  2877. %
  2878. %
  2879. %
  2880. % \begin{macro}{\do@not@index}
  2881. %    We make the \verb+\do@not@index+ macro \verb+\long+
  2882. %    since the user might want to exclude the \verb+\par+ 
  2883. %    macro.
  2884. %    \begin{macrocode}
  2885. \long\def\do@not@index#1{%
  2886. %    \end{macrocode}
  2887. %    It just adds to a token list after finishing the group in which
  2888. %    the catcodes were changed.
  2889. %    \changes{v1.7a}{92/02/26}{Replaced with newdoc version.}
  2890. %    \begin{macrocode}
  2891.     \endgroup
  2892.     \addto@hook\index@excludelist{#1,}}    
  2893. %    \end{macrocode}
  2894. % \end{macro}
  2895. %
  2896. % \begin{macro}{\addto@hook}
  2897. % The code for adding tokens (the second argument) to a token list
  2898. % (the first argument) is taken from~\cite{art:verbatim}, but it needs
  2899. % to be "\long" in case "\par" is amongst the tokens.
  2900. %    \begin{macrocode}
  2901. \long\def\addto@hook#1#2{#1\expandafter{\the#1#2}}
  2902. %    \end{macrocode}
  2903. % \end{macro}
  2904. %
  2905. % \begin{macro}{\index@excludelist}
  2906. % We need an initially-empty register for the excluded list.
  2907. %    \begin{macrocode}
  2908. \newtoks\index@excludelist
  2909. \index@excludelist{}
  2910. %    \end{macrocode}
  2911. % \end{macro}
  2912. %
  2913. % \begin{macro}{\ifnot@excluded}
  2914. %    \changes{v1.7a}{92/02/26}{Replaced with newdoc version.}
  2915. % \begin{macro}{\expanded@notin}
  2916. %    Now we take a look at the \verb+\index@excludelist+ to see
  2917. %    whether a macro name saved in \verb+\macro@namepart+ should
  2918. %    produce an index entry. This macro is a pseudo \verb+\if+; it
  2919. %    should expand to \verb+\iftrue+ or \verb+\iffalse+ depending on
  2920. %    the contents of \verb+\index@excludelist+.
  2921. %    \begin{macrocode}
  2922. \begingroup
  2923. %    \end{macrocode}
  2924. %    First we change "\catcode"s so that "\" is `other' and "|" a
  2925. %    temporary for the escape character. This is necessary since our
  2926. %    macro names are stored that way in the "\index@excludelist".
  2927. %    \begin{macrocode}
  2928. \catcode`\|=0%
  2929. \catcode`\\=12
  2930. %    \end{macrocode}
  2931. %    Then we define "\ifnot@excluded" to call "\expanded@notin" with
  2932. %    two arguments: the first is the string "\" followed by the
  2933. %    contents of "\macro@namepart" followed by a "," and the second is
  2934. %    "\the" followed by "\index@excludelist". To achieve the expansion
  2935. %    of "\macro@namepart", i.e.\ to pass its contents, we need a
  2936. %    suitable number of "\expandafter"s.
  2937. %    \SpecialEscapechar{\|}
  2938. %    \begin{macrocode}
  2939. |gdef|ifnot@excluded{|expandafter
  2940.      |expanded@notin|expandafter{|expandafter
  2941.      \|macro@namepart,}{|the|index@excludelist}}
  2942. |endgroup
  2943. %    \end{macrocode}
  2944. %    The macro "\expanded@notin" now does the dirty work. It first
  2945. %    defines a macro "\in@@" with a very special parameter text. If
  2946. %    you look closely "\in@@" has three arguments, the first one is
  2947. %    delimited by the first argument of "\expanded@notin" (i.e.\ by
  2948. %    the string starting with a "\" and ending with a "," above), the
  2949. %    second is undelimited (which means that it will get the next
  2950. %    token after our string, and the third is delimited again and will
  2951. %    get the rest up to the token "\in@@". In other words the token
  2952. %    "\in@@" is also used as a delimiter.
  2953. %    \begin{macrocode}
  2954. \def\expanded@notin#1#2{%
  2955.  \def\in@@##1#1##2##3\in@@{%
  2956. %    \end{macrocode}
  2957. %    Now the replacement text simply compares the second argument
  2958. %    (i.e.\ the undelimited one after our string) to the token
  2959. %    "\expanded@notin". This is an unclosed "\ifx" statement which
  2960. %    means that this macro behaves similar to a normal \TeX{}
  2961. %    conditional.
  2962. %    \begin{macrocode}
  2963.   \ifx\expanded@notin##2}%
  2964. %    \end{macrocode}
  2965. %    After all these preparations we call "\in@@". First we expand the
  2966. %    token after "\in@@" (which is "\the" from the second argument to
  2967. %    "\expanded@notin"). As a result we get the contents of the
  2968. %    "\index@excludelist" inserted after "\in@@". After this contents
  2969. %    we add once more the string we are looking for, then the token
  2970. %    "\expanded@notin" and finally the token "\in@@".
  2971. %    \begin{macrocode}
  2972.  \expandafter\in@@#2#1\expanded@notin\in@@}
  2973. %    \end{macrocode}
  2974. %    Now what happens when the macro "\in@@" above gets called? The
  2975. %    first argument to "\in@@" is delimited by our string. In other
  2976. %    words it will get everything from the contents of
  2977. %    "\index@excludelist" before this string. If the string is not in
  2978. %    "\index@excludelist" then it gets the whole contents, since after
  2979. %    it we had inserted the string one more. In this case the next
  2980. %    token is "\expanded@notin" which gets assigned to the second
  2981. %    argument and the third argument will be empty. If, on the other
  2982. %    hand, the string was inside "\index@excludelist" then the second
  2983. %    argument will not be the token "\expanded@notin" and the third
  2984. %    argument will be all the garbage up to "\in@@". Therefore testing
  2985. %    the seconded argument, as done in the definition of "\in@@" will
  2986. %    tell us  whether or not the string is in "\index@includelist" and
  2987. %    this was exactly what we wanted. (Deep breath.) You got
  2988. %    that?\footnote{\TeX{}book page 125. The code described above is
  2989. %    originally due to Michael Spivak who used a similar method within
  2990. %    the \AmSTeX{} macros.}
  2991. % \end{macro}
  2992. % \end{macro}
  2993. %
  2994. %
  2995. %
  2996. %
  2997. %
  2998. %
  2999. %
  3000. % \subsection{Macros for generating index entries}
  3001. %
  3002. % Here we provide default definitions for the macros invoked to create
  3003. % index entries; these are either invoked explicitly, or automatically
  3004. % by \verb+\scan@macro+.  As already mentioned, the definitions given
  3005. % here presuppose that the \verb+.idx+ file will be processed by
  3006. % Chen's {\sf makeindex} program --- they may be redefined for use
  3007. % with the user's favourite such program.
  3008. %
  3009. % To assist the reader in locating items in the index, all such
  3010. % entries are sorted alphabetically {\em ignoring\/} the initial
  3011. % `\verb+\+'; this is achieved by issuing an \verb+\index+ command
  3012. % which contains the `actual' operator for {\sf makeindex}.  The
  3013. % default value for the latter operator is `\verb+@+', but the latter
  3014. % character is so popular in \LaTeX\ style files that it is necessary
  3015. % to substitute another character.  This is indicated to {\sf
  3016. % makeindex} by means of an `index style file'; the character selected
  3017. % for this function is \verb+=+, and therefore this character too must
  3018. % be specially treated when it is met in a \TeX\ command.  A suitable
  3019. % index style file is provided amongst the supporting files for this
  3020. % style file in {\tt gind.ist} and is generated from this source by
  3021. % processing with {\tt docstrip} to extract the module {\bf gind}.  A
  3022. % similar style file {\tt gglo.ist} is supplied for sorting the change
  3023. % information in the glossary file and is extracted as module {\bf
  3024. % gglo}.  First of all we add some information to the front of the
  3025. % {\tt .ist} files.  \changes{v1.7a}{92/03/11}{Gglo.ist and gind.ist
  3026. % now derivable from doc.doc with docstrip.}
  3027. %    \begin{macrocode}
  3028. %</style>
  3029. %<+gind|gglo>%% This is a MAKEINDEX style file which should be used to
  3030. %<+gind>%% generate the formatted index for use with the doc
  3031. %<+gglo>%% generate the formatted change history for use with the doc
  3032. %<+gind|gglo>%% style option. The TeX commands used below are defined in
  3033. %<+gind|gglo>%% doc.sty.  The commands for MAKEINDEX like `level'
  3034. %<+gind|gglo>%% `item_x1' are described in `` Makeindex, A General
  3035. %<+gind|gglo>%% Purpose, Formatter-Independent Index Processor'' by
  3036. %<+gind|gglo>%% Pehong Chen. 
  3037. %<+gind|gglo>
  3038. %    \end{macrocode}
  3039. %
  3040. % \begin{macro}{\actualchar}
  3041. % \begin{macro}{\quotechar}
  3042. % \begin{macro}{\levelchar}
  3043. %    First come the definitions of \verb+\actualchar+,
  3044. %    \verb+\quotechar+ and \verb+\levelchar+. Note, that our defaults
  3045. %    are not the ones used by the {\sf makeindex} program without a
  3046. %    style file.
  3047. %    \begin{macrocode}
  3048. %<*style>
  3049. \@ifundefined{actualchar}{\def\actualchar{=}}{}
  3050. \@ifundefined{quotechar}{\def\quotechar{!}}{}
  3051. \@ifundefined{levelchar}{\def\levelchar{>}}{}
  3052. %</style>
  3053. %<+gind|gglo>actual '='
  3054. %<+gind|gglo>quote '!'
  3055. %<+gind|gglo>level '>'
  3056. %<*style>
  3057. %    \end{macrocode}
  3058. % \end{macro}
  3059. % \end{macro}
  3060. % \end{macro}
  3061. %
  3062. %
  3063. % \begin{macro}{\encapchar}
  3064. %    The {\sf makeindex} default for the \verb+\encapchar+ isn't
  3065. %    changed.
  3066. %    \begin{macrocode}
  3067. \@ifundefined{encapchar}{\def\encapchar{|}}{}
  3068. %    \end{macrocode}
  3069. % \end{macro}
  3070. %
  3071. %
  3072. % \begin{macro}{\verbatimchar}
  3073. %    We also need a special character to be used as a delimiter for
  3074. %    the \verb+\verb*+ command used in the definitions below.
  3075. %    \begin{macrocode}
  3076. \@ifundefined{verbatimchar}{\def\verbatimchar{+}}{}
  3077. %    \end{macrocode}
  3078. % \end{macro}
  3079. %
  3080. %
  3081. % \begin{macro}{\SpecialIndex}
  3082. %    The \verb+\SpecialIndex+ command creates index entries for
  3083. %    macros.  If the argument is \verb+\+$xyz$, the command produces
  3084. %    \verb|\indexentry{|$xyz$\verb|=\verb!*+\|$xyz$\verb|+}{|$n$\verb|}|
  3085. %    given the above defined defaults for \verb+\actualchar+,
  3086. %    \verb+\quotechar+ and \verb+\verbatimchar+.  We first remove the
  3087. %    initial `\verb+\+' to get a better index.
  3088. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3089. %    \begin{macrocode}
  3090. \def\SpecialIndex#1{\@bsphack\special@index{\expandafter\@gobble
  3091.                                       \string#1\actualchar
  3092. %    \end{macrocode}
  3093. %    Then follows the actual entry. A \verb+\quotechar+ is placed
  3094. %    before the \verb+*+ to allow its use as a special {\sf makeindex}
  3095. %    character.  Again \verb+\@bsphack+ and \verb+\@esphack+ are used
  3096. %    to make the macros invisible.
  3097. %    \begin{macrocode}
  3098.       \string\verb\quotechar*\verbatimchar\string#1\verbatimchar}%
  3099.     \@esphack}
  3100. %    \end{macrocode}
  3101. % \end{macro}
  3102.  
  3103. % \begin{macro}{\SpecialMainIndex}
  3104. % \begin{macro}{\SpecialUsageIndex}
  3105. %    The \verb+\SpecialMainIndex+ macro is used to cross-reference the
  3106. %    names introduced by the {\sf macro} environment.  The action is
  3107. %    as for \verb+\SpecialIndex+, except that {\sf makeindex} is
  3108. %    instructed to `encap'sulate the entry with the string
  3109. %    \verb+|main+ to cause it to generate a call of the \verb+\main+
  3110. %    macro.
  3111. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3112. %    \begin{macrocode}
  3113. \def\SpecialMainIndex#1{\@bsphack\special@index{\expandafter\@gobble
  3114.                                         \string#1\actualchar
  3115.                                         \string\verb
  3116.                                         \quotechar*\verbatimchar
  3117.                                         \string#1\verbatimchar
  3118.                                         \encapchar main}%
  3119.                         \@esphack}
  3120. %    \end{macrocode}
  3121. %    The \verb+\SpecialUsageIndex+ is literally the same---only we use
  3122. %    {\tt usage} instead of {\tt main}.
  3123. %    \begin{macrocode}
  3124. \def\SpecialUsageIndex#1{\@bsphack\index{\expandafter\@gobble\string#1%
  3125.     \actualchar\string\verb\quotechar*\verbatimchar
  3126.     \string#1\verbatimchar
  3127.     \encapchar usage}\@esphack}
  3128. %    \end{macrocode}
  3129. % \end{macro}
  3130. % \end{macro}
  3131. %
  3132. %
  3133. %
  3134. %
  3135. % \begin{macro}{\SpecialEnvIndex}
  3136. %    Indexing environments is done a little bit differently; we produce
  3137. %    two index entries with the \verb+\SpecialEnvIndex+ macro:
  3138. %    \begin{macrocode}
  3139. \def\SpecialEnvIndex#1{\@bsphack
  3140. %    \end{macrocode}
  3141. %    First we sort the environment under its own name stating in the
  3142. %    actual entry that this is an environment.
  3143. %    \begin{macrocode}
  3144.     \index{#1\actualchar{\tt #1} (environment)\encapchar usage}%
  3145. %    \end{macrocode}
  3146. %    The second entry is sorted as a subitem under the key
  3147. %    `environments:'. 
  3148. %    \begin{macrocode}
  3149.     \index{environments:\levelchar{\tt #1}\encapchar usage}\@esphack}
  3150. %    \end{macrocode}
  3151. %    Because both entries correspond to `descriptions' of the
  3152. %    environment, we encapsulate the page numbers with the
  3153. %    \verb+\usage+ macro.
  3154. % \end{macro}
  3155. %
  3156. %
  3157. %
  3158. % \begin{macro}{\SortIndex}
  3159. %    This macro is used to generate the index entries for any
  3160. %    single-character command that \verb+\scan@macro+ encounters.  The
  3161. %    first parameter specifies the lexical order for the character,
  3162. %    whilst the second gives the actual characters to be printed in
  3163. %    the entry. It can also be used directly to generate index entries
  3164. %    which differ in sort key and actual entry.
  3165. %    \begin{macrocode}
  3166. \def\SortIndex#1#2{\index{#1\actualchar#2}}
  3167. %    \end{macrocode}
  3168. % \end{macro}
  3169. %
  3170. %
  3171. %
  3172. % \begin{macro}{\it@is@a}
  3173. %    This macro is supposed to produce a correct \verb+\SortIndex+
  3174. %    entry for a given character. Since this character might be
  3175. %    recognised as a `command' character by the index program used,
  3176. %    all characters are quoted with the \verb+\quotechar+.
  3177. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3178. %    \begin{macrocode}
  3179. \def\it@is@a#1{\special@index{\quotechar #1\actualchar
  3180.                           \string\verb\quotechar*\verbatimchar
  3181.                           \quotechar\bslash\quotechar#1\verbatimchar}}
  3182. %    \end{macrocode}
  3183. % \end{macro}
  3184. %
  3185. %
  3186. %
  3187. % \begin{macro}{\LeftBraceIndex}
  3188. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3189. % \begin{macro}{\RightBraceIndex}
  3190. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3191. %    These two macros fix the problems with {\sf makeindex}.  Note the
  3192. %    `hack' with \verb+\iffalse}\fi+ to satisfy both \TeX{} and the
  3193. %    {\sf makeindex} program. When this is written to the {\tt .idx}
  3194. %    file \TeX{} will see both braces (so we get a balanced text).
  3195. %    {\sf makeindex} will also see balanced braces but when the actual
  3196. %    index entry is again processed by \TeX{} the brace in between
  3197. %    \verb+\iffalse+ \verb+\fi+ will vanish.
  3198. %    \begin{macrocode}
  3199. \@ifundefined{LeftBraceIndex}{\def\LeftBraceIndex{%
  3200.    \special@index{\bgroup\actualchar\string\verb\quotechar*\verbatimchar
  3201.           \quotechar\bslash{\verbatimchar\string\iffalse}\string\fi}}}{}
  3202.  
  3203. \@ifundefined{RightBraceIndex}{\def\RightBraceIndex{%
  3204.  \special@index{\egroup\actualchar\string\iffalse{\string\fi\string\verb
  3205.            \quotechar*\verbatimchar\quotechar\bslash}\verbatimchar}}}{}
  3206. %    \end{macrocode}
  3207. % \end{macro}
  3208. % \end{macro}
  3209. %
  3210. %
  3211. % \begin{macro}{\PercentIndex}
  3212. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  3213. % \changes{v1.7c}{92/03/25}{Default now for bug-fixed makeindex}
  3214. % By default we assume a version of {\sf makeindex} without the
  3215. % percent bug is being used.
  3216. %    \begin{macrocode}
  3217. \@ifundefined{PercentIndex}
  3218.   {\def\PercentIndex{\it@is@a\percentchar}}{}
  3219. %    \end{macrocode}
  3220. % \end{macro}
  3221. % \begin{macro}{\OldMakeindex}
  3222. % \changes{v1.7c}{92/03/26}{Replaced `NewMakeIndex.}
  3223. % \begin{macro}{\percentchar}
  3224. %    Here is one solution for the percent bug in {\sf makeindex}.  The
  3225. %    macro \verb+\percentchar+ denotes a \verb+%+$_{12}$.
  3226. %    Calling this from a style option or the driver file sets things
  3227. %    up appropriately.\label{bug:fixes} 
  3228. %    \begin{macrocode}
  3229. \def\OldMakeindex{\def\PercentIndex{%
  3230.     \special@index{\quotechar\percentchar\actualchar\string\verb
  3231.            \quotechar*\verbatimchar\quotechar\bslash
  3232.            \percentchar\percentchar\verbatimchar}}}
  3233. {\catcode`\%=12 \gdef\percentchar{%}}
  3234. %    \end{macrocode}
  3235. % \end{macro}
  3236. % \end{macro}
  3237. %
  3238. %
  3239. %
  3240. %
  3241. %
  3242. %
  3243. % \subsection{Redefining the {\sf index} environment}
  3244. %
  3245. %\changes{v1.4r}{89/04/22}{twocols env. placed into separate file}
  3246. %\changes{v1.4?}{89/04/19}{use DEK's algorithm and implement
  3247. %                         a twocols env.}
  3248. %\changes{v1.4?}{89/04/16}{changes to the index env.}
  3249. %\changes{v1.5a}{89/04/26}{Now input multicol.sty instead of
  3250. %                         multcols.sty}
  3251. % \begin{macro}{\ifhave@multicol}
  3252. % \changes{v1.7a}{92/03/04}{Added to support avoiding multicol.sty}
  3253. %    By default
  3254. %    the index is set in three columns, and will start on the same
  3255. %    page as, and underneath, the last part of the text of the
  3256. %    documented style file, if possible.  The last page will be
  3257. %    reformatted with balanced columns.  This requires the {\sf
  3258. %    multicols} environment which is described elsewhere.
  3259. % ^^A  described elsewhere (see page~\xrefto{mittelbachmulti}).
  3260. %    So that {\sf doc} can be run independently of {\tt multicol.sty}
  3261. %    we first check for its existence and set the "have@multicol" flag
  3262. %    appropriately for use below.
  3263. %    \begin{macrocode}
  3264. \newif\ifhave@multicol
  3265. \openin\@ne multicol.sty
  3266. \ifeof\@ne \else \have@multicoltrue \fi
  3267. \closein\@ne \relax
  3268. %    \end{macrocode}
  3269. %    On systems where it is impossible to determine the existence of a
  3270. %    file using the above method the docstrip program can be directed
  3271. %    to force using multicol by including the next line.
  3272. % \changes{v1.7i}{92/07/14}{Force use of multicol.sty if necessary.}
  3273. %    \begin{macrocode}
  3274. %<+multicol>\have@multicoltrue
  3275. %    \end{macrocode}
  3276. % \end{macro}
  3277. %    If we found {\tt multicol.sty} we use it.  It would be nice to
  3278. %    delay this (and the re-definition of "theindex") until we knew
  3279. %    whether an index was actually required \ldots
  3280. %    \begin{macrocode}
  3281. \ifhave@multicol \input{multicol.sty} \fi
  3282. %    \end{macrocode}
  3283. %
  3284. % \begin{macro}{\IndexMin}
  3285. % \begin{macro}{\c@IndexColumns}
  3286. %    \changes{v1.4t}{89/04/24}{Counter added.}
  3287. %    If {\tt multicol} is in use,
  3288. %    when the index is started we compute the remaining space on the
  3289. %    current page; if it is greater than \verb+\IndexMin+, the first
  3290. %    part of the index will then be placed in the available space.
  3291. %    The number of columns set is controlled by the counter
  3292. %    \verb+\c@IndexColumns+ which can be changed with a
  3293. %    \verb+\setcounter+ declaration.
  3294. %    \begin{macrocode}
  3295. \newdimen\IndexMin         \IndexMin       = 80pt
  3296. \newcount\c@IndexColumns   \c@IndexColumns = 3
  3297. %    \end{macrocode}
  3298. % \end{macro}
  3299. % \end{macro}
  3300. %
  3301. %
  3302. % \begin{macro}{\theindex}
  3303. %    Now we start the multi-column mechanism, if appropriate. We use the
  3304. %    \verb+\c@IndexColumns+ \LaTeX{} counter declared above to denote
  3305. %    the number of columns and insert the `index prologue' text (which
  3306. %    might contain a \verb+\section+ call, etc.). See the default
  3307. %    definition for an example.
  3308. %    \changes{v1.4t}{89/04/24}{Incorporated new multicols env.}
  3309. %    \changes{v1.5a}{89/04/26}{Call multicols first}
  3310. %    \changes{v1.6e}{91/04/03}{Turned into env definition.}
  3311. %    \changes{v1.7a}{92/03/04}{Include test for multicols.}
  3312. %    \begin{macrocode}
  3313. \ifhave@multicol
  3314.   \renewenvironment{theindex}
  3315.     {\begin{multicols}\c@IndexColumns[\index@prologue][\IndexMin]%
  3316. %    \end{macrocode}
  3317. %    Then we make a few last minute assignments to read the individual
  3318. %    index \verb+\item+$\,$s and finish off by ignoring any initial
  3319. %    space.
  3320. %    \begin{macrocode}
  3321.       \IndexParms \let\item\@idxitem \ignorespaces}%
  3322. %    \end{macrocode}
  3323. % \end{macro}
  3324. % \begin{macro}{\endtheindex}
  3325. %    \changes{v1.4t}{89/04/24}{Incorporated new multicols env.}
  3326. %    At the end of the index, we have only to end the {\sf multicols}
  3327. %    environment.
  3328. %    \begin{macrocode}
  3329.     {\end{multicols}}
  3330. %    \end{macrocode}
  3331. %    If we can't use {\sf multicols} we warn the user and use an
  3332. %    environment that's basically the one from {\tt article.sty}.
  3333. %    \begin{macrocode}
  3334. \else
  3335.   \typeout{Can't find multicols.sty -- will use normal index layout if
  3336.      necessary.} 
  3337.   \def\theindex{\@restonecoltrue\if@twocolumn\@restonecolfalse\fi
  3338.     \columnseprule \z@  \columnsep 35\p@
  3339.     \twocolumn[\index@prologue]%
  3340.     \IndexParms \let\item\@idxitem \ignorespaces}
  3341.   \def\endtheindex{\if@restonecol\onecolumn\else\clearpage\fi}
  3342. \fi
  3343. %    \end{macrocode}
  3344. % \end{macro}
  3345. % Here are the necessary {\sf makeindex} declarations. We disable
  3346. % scanning of macro names inside the index with "\scan@allowedfalse\n"
  3347. % to avoid recursion.
  3348. %    \begin{macrocode}
  3349. %</style>
  3350. %<+gind>preamble
  3351. %<+gind>"\n \\begin{theindex} \n \\makeatletter\\scan@allowedfalse\n"
  3352. %<+gind>postamble
  3353. %<+gind>"\n\n \\end{theindex}\n"
  3354. %<*style>
  3355. %    \end{macrocode}
  3356. %
  3357. %
  3358. % \begin{macro}{\IndexPrologue}
  3359. % \begin{macro}{\index@prologue}
  3360. %    The \verb+\IndexPrologue+ macro is used to place a short message
  3361. %    into the document above the index.  It is implemented by
  3362. %    redefining \verb+\index@prologue+, a macro which holds the
  3363. %    default text.  We'd better make it a \verb+\long+ macro to allow
  3364. %    \verb+\par+ commands in its argument.
  3365. %    \begin{macrocode}
  3366. \long\def\IndexPrologue#1{\@bsphack\def\index@prologue{#1}\@esphack}
  3367. %    \end{macrocode}
  3368. %    Now we test whether the default is already defined by another
  3369. %    style file. If not we define it.
  3370. %    \begin{macrocode}
  3371. \@ifundefined{index@prologue}
  3372.      {\def\index@prologue{\section*{Index}%
  3373.                  \markboth{Index}{Index}%
  3374.                  The italic numbers denote the pages where the
  3375.                  corresponding entry is described,
  3376.                  numbers underlined point to the definition,
  3377.                  all others indicate the places where it is used.
  3378.                  }}{}
  3379. %    \end{macrocode}
  3380. % \end{macro}
  3381. % \end{macro}
  3382. %
  3383. %
  3384. %
  3385. % \begin{macro}{\IndexParms}
  3386. %    These are some last-minute assignments for formatting the index
  3387. %    entries. They are defined in a separate macro so that a user can
  3388. %    substitute different definitions.  We start by defining the
  3389. %    various parameters controlling leading and the separation between
  3390. %    the two columns.  The entire index is set in \verb+\small+ size.
  3391. %    \begin{macrocode}
  3392. \@ifundefined{IndexParms}
  3393.     {\def\IndexParms{%
  3394.        \parindent \z@
  3395.        \columnsep 15pt
  3396.        \parskip 0pt plus 1pt
  3397.        \rightskip 15pt
  3398.        \mathsurround \z@
  3399.        \parfillskip=-15pt
  3400.         \small
  3401. %    \end{macrocode}
  3402. % \begin{macro}{\@idxitem}
  3403. % \begin{macro}{\subitem}
  3404. % \begin{macro}{\subsubitem}
  3405. %    Index items are formatted with hanging indentation for any items
  3406. %    which may require more than one line.
  3407. %    \begin{macrocode}
  3408.        \def\@idxitem{\par\hangindent 30pt}%
  3409. %    \end{macrocode}
  3410. %    Any sub-item in the index is formatted with a 15pt indentation
  3411. %    under its main heading.
  3412. %    \begin{macrocode}
  3413.        \def\subitem{\@idxitem\hspace*{15pt}}%
  3414. %    \end{macrocode}
  3415. %    Whilst sub-sub-items go in a further 10pt.
  3416. %    \begin{macrocode}
  3417.        \def\subsubitem{\@idxitem\hspace*{25pt}}%
  3418. %    \end{macrocode}
  3419. % \begin{macro}{\indexspace}
  3420. %    The {\sf makeindex} program generates an \verb+\indexspace+
  3421. %    before each new alphabetic section commences. After this final
  3422. %    definition we end the \verb+\@ifundefined+ and the definition of
  3423. %    \verb+\IndexParms+.
  3424. %    \begin{macrocode}
  3425.        \def\indexspace{\par\vspace{10pt plus 2pt minus 3pt}}%
  3426.       }}{}
  3427. %    \end{macrocode}
  3428. % \end{macro}
  3429. % \end{macro}
  3430. % \end{macro}
  3431. % \end{macro}
  3432. % \end{macro}
  3433. %
  3434. %
  3435. % \begin{macro}{\efill}
  3436. %    This definition of \verb+\efill+ is intended to be used after
  3437. %    index items which have no following text (for example, ``{\it
  3438. %    see\/}'' entries).  It just ensures that the current line is
  3439. %    filled, preventing ``\verb+Underfull \hbox+'' messages.
  3440. %    \begin{macrocode}
  3441. \def\efill{\hfill\nopagebreak}%
  3442. %</style>
  3443. %<+gind|gglo>item_x1   "\\efill \n \\subitem "
  3444. %<+gglo>item_x2   "\\ "
  3445. %<+gind>item_x2   "\\efill \n \\subsubitem "
  3446. %<*style>
  3447. %    \end{macrocode}
  3448. % \end{macro}
  3449. %
  3450. %
  3451. %
  3452. % \begin{macro}{\pfill}
  3453. % \begin{macro}{\dotfil}
  3454. % \begin{macro}{\dotfill}
  3455. %     The following definitions provide the \verb+\pfill+ command; if
  3456. %    this is specified in the index style file to {\sf makeindex} as
  3457. %    the delimiter to appear after index items, then the intervening
  3458. %    space before the referenced page numbers will be filled with
  3459. %    dots, with a little white space interpolated at each end of the
  3460. %    dots.  If the line is broken the dots will show up on both lines.
  3461. %    \begin{macrocode}
  3462. \def\dotfill{\leaders\hbox to.6em{\hss .\hss}\hskip\z@ plus  1fill}%
  3463. \def\dotfil{\leaders\hbox to.6em{\hss .\hss}\hfil}%
  3464. \def\pfill{\unskip~\dotfill\penalty500\strut\nobreak
  3465.                \dotfil~\ignorespaces}%
  3466. %</style>
  3467. %<+gind|gglo>delim_0   "\\pfill "
  3468. %<+gind|gglo>delim_1   "\\pfill "
  3469. %<+gind|gglo>delim_2   "\\pfill "
  3470. %<*style>
  3471. %    \end{macrocode}
  3472. % \end{macro}
  3473. % \end{macro}
  3474. % \end{macro}
  3475. %
  3476. %
  3477. %
  3478. % \begin{macro}{\*}
  3479. %    Here is the definition for the \verb+\*+ macro. It isn't used in
  3480. %    this set of macros.
  3481. %    \begin{macrocode}
  3482. \def\*{\leavevmode\lower.8ex\hbox{$\,\widetilde{\ }\,$}}
  3483. %    \end{macrocode}
  3484. % \end{macro}
  3485. %
  3486. %
  3487. % \begin{macro}{\main}
  3488. %    The {\it defining\/} entry for a macro name is flagged with the
  3489. %    string {\tt\encapchar main}\footnote{With the current definition
  3490. %    of {\tt\bslash encapchar} substituted for {\tt\encapchar}} in the
  3491. %    \verb+\index+ command; {\sf makeindex} processes this so that the
  3492. %    \verb+\main+ macro will be invoked to underline the page
  3493. %    number(s) on which the {\em definition\/} of the macro will be
  3494. %    found.
  3495. %    \begin{macrocode}
  3496. \@ifundefined{main}{\def\main#1{\underline{#1}}}{}
  3497. %    \end{macrocode}
  3498. % \end{macro}
  3499. %
  3500. % \begin{macro}{\usage}
  3501. %    The \verb+\usage+ macro is used to indicate entries describing
  3502. %    the usage of a macro. The corresponding page number(s) will be
  3503. %    set in {\it italics}.
  3504. %    \begin{macrocode}
  3505. \@ifundefined{usage}{\def\usage#1{{\it #1}}}{}
  3506. %    \end{macrocode}
  3507. % \end{macro}
  3508. %
  3509. %
  3510. % \begin{macro}{\PrintIndex}
  3511. % \changes{v1.5k}{89/09/04}{`printindex changed to `PrintIndex.}
  3512. % \changes{v1.7a}{92/02/26}{Documentation moved to interface section.}
  3513. % \begin{macro}{\printindex}
  3514. %    This is the same as "\printindex" in the {\sf makeidx} style.
  3515. %    \begin{macrocode}
  3516. \def\PrintIndex{\@input{\jobname.ind}}
  3517. %    \end{macrocode}
  3518. %    Since this macro was called \verb+\printindex+ in older versions
  3519. %    of {\tt doc.sty} we also provide the following definition.
  3520. %    \begin{macrocode}
  3521. \def\printindex{\typeout{\string\printindex\space is obsolete!}%
  3522.                 \typeout{Please use \string\PrintIndex\space
  3523.                          if you are a macro implementor^^J
  3524.                          or get a newer version of the documented 
  3525.                          software if you are a user}%
  3526.                 \PrintIndex}
  3527. %    \end{macrocode}
  3528. % \end{macro}
  3529. % \end{macro}
  3530. %
  3531. % We want headings in the index (and changes list) according to the
  3532. % initial character of the next block of entries and have to instruct
  3533. % {\sf makeindex} appropriately.  Unfortunately the specification for
  3534. % this changed sometime between versions 2.4 and 2.11 of {\sf
  3535. % makeindex}.  We provide both ways of doing it but unfortunately this
  3536. % will always produce a warning message from {\sf makeindex}.  This is
  3537. % for older versions:
  3538. %  \changes{v1.7h}{92/07/01}{Turn off headings in gls file}
  3539. %    \begin{macrocode}
  3540. %</style>
  3541. %<+gind,gglo>% The next lines will produce some warnings when
  3542. %<+gind,gglo>% running Makeindex as they try to cover two different
  3543. %<+gind,gglo>% versions of the program:
  3544. %<+gind,gglo>lethead_prefix   "{\\bf\\hfil "
  3545. %<+gind,gglo>lethead_suffix   "\\hfil}\\nopagebreak\n"
  3546. %<+gind>lethead_flag       1
  3547. %<+gglo>lethead_flag       0
  3548. %    \end{macrocode}
  3549. % This works for newer ones:
  3550. %    \begin{macrocode}
  3551. %<+gind,gglo>heading_prefix   "{\\bf\\hfil "
  3552. %<+gind,gglo>heading_suffix   "\\hfil}\\nopagebreak\n"
  3553. %<+gind>headings_flag       1
  3554. %<+gglo>headings_flag       0
  3555. %<*style>
  3556. %    \end{macrocode}
  3557. %
  3558. %
  3559. %
  3560. % \subsection[Dealing with the change history]
  3561. %            {Dealing with the change history\footnotemark}
  3562. % \footnotetext{The whole section was proposed by Brian {\sc Hamilton
  3563. %               Kelly}. He also documented and debugged the macros as
  3564. %               well as many other parts of this style option.}
  3565. %
  3566. % To provide a change history log, the \verb+\changes+ command has
  3567. % been introduced.  This takes three arguments, respectively, the
  3568. % version number of the file, the date of the change, and some detail
  3569. % regarding what change has been made.  The first of these arguments
  3570. % is otherwise ignored, but the others are written out and may be used
  3571. % to generate a history of changes, to be printed at the end of the
  3572. % document.  However, note that older versions of Chen's standard {\sf
  3573. % makeindex} 
  3574. % program limit any textual field to just 64 characters; therefore,
  3575. % is important that the number of characters in the second and third
  3576. % parameters should not exceed 61 altogether (to allow for the
  3577. % parentheses placed around the date).
  3578. %
  3579. % \begin{macro}{\changes}
  3580. % \changes{BHK}{89/04/26}{Documented {\tt\protect\bslash changes}
  3581. %                         command.}
  3582. % \changes{BHK}{89/04/26}{Changed definition of
  3583. %                         {\tt\protect\bslash protect}.}
  3584. %    The output of
  3585. %    the \verb+\changes+ command goes into the \meta{Glossary\_File}
  3586. %    and therefore uses the normal \verb+\glossaryentry+
  3587. %    commands.\footnote{Note that a recent change in \LaTeX{} 2.09
  3588. %    changed the command name in the {\tt.glo} file from {\tt\bslash
  3589. %    indexentry} to {\tt\bslash glossaryentry}.  It is therefore
  3590. %    necessary to have a special {\sf makeindex} style file called {\tt
  3591. %    gglo.ist} to process this file correctly.} Thus {\sf makeindex}
  3592. %    or a similar program can be used to process the output into a
  3593. %    sorted ``glossary''.  The \verb+\changes+ command commences by
  3594. %    taking the usual measures to hide its spacing, and then redefines
  3595. %    \verb+\protect+ for use within the argument of the generated
  3596. %    \verb+\indexentry+ command. 
  3597. %
  3598. %    We re-code nearly all chars found in \verb+\sanitize+ to letter
  3599. %    since the use of special style options which make some characters
  3600. %    active might upset the \verb+\changes+ command when writing its
  3601. %    entries to the file. However we have to leave \verb+%+ as comment
  3602. %    and \verb*+ + as \meta{space} otherwise chaos will happen.
  3603. %    And, of course the \verb+\+ should be available as escape
  3604. %    character.
  3605. % \changes{v1.5v}{90/01/28}{`Re-code a lot of chars.}
  3606. % \changes{v1.5m}{89/09/20}{`actualchar in second level removed.}
  3607. % \changes{v1.5o}{89/09/24}{New sorting.}
  3608. % \changes{v1.6c}{90/06/29}{Again new sorting.}
  3609. %    \begin{macrocode}
  3610. \def\changes{\@bsphack\begingroup\@sanitize
  3611.    \catcode`\\\z@ \catcode`\ 10 \MakePercentIgnore
  3612.    \changes@}
  3613. \def\changes@#1#2#3{%
  3614.   \def\protect##1{\string##1\space}%
  3615.   \edef\@tempa{\noexpand\glossary{#1\levelchar
  3616.                                  \expandafter\@gobble
  3617.                                  \saved@macroname\actualchar
  3618.                                  \string\verb\quotechar*%
  3619.                                  \verbatimchar\saved@macroname
  3620.                                  \verbatimchar:\levelchar #3}}%
  3621.   \@tempa\endgroup\@esphack}
  3622. %    \end{macrocode}
  3623. % \begin{macro}{\saved@macroname}
  3624. % \changes{BHK}{89/04/26}{Provided for sorting outside
  3625. %                         {\sf macro} environment}
  3626. %    The entries are sorted for convenience by the name of the most
  3627. %    recently introduced macroname (i.e., that in the most recent
  3628. %    \verb+\begin{macro}+ command).  We therefore provide
  3629. %    \verb+\saved@macroname+ to record that argument, and provide a
  3630. %    default definition in case \verb+\changes+ is used outside a {\sf
  3631. %    macro} environment.  (This is a {\em wicked\/} hack to get such
  3632. %    entries at the beginning of the sorted list!  It works providing no
  3633. %    macro names start with "!" or \verb+"+.)
  3634. %    \changes{v1.7a}{92/03/02}{Changed string used for better sorting.}
  3635. %    \begin{macrocode}
  3636. \def\saved@macroname{"General"}
  3637. %    \end{macrocode}
  3638. % \end{macro}
  3639. %
  3640. % \begin{macro}{\RecordChanges}
  3641. % \changes{BHK}{89/04/26}{Renames former {\tt\protect\bslash
  3642. %                         PrintChanges} command.}
  3643. %    To cause the changes to be written (to a {\tt.glo}) file, we
  3644. %    define \verb+\RecordChanges+ to invoke \LaTeX's usual
  3645. %    \verb+\makeglossary+ command.
  3646. %    \begin{macrocode}
  3647. \let\RecordChanges\makeglossary
  3648. %    \end{macrocode}
  3649. % \end{macro}
  3650. % \end{macro}
  3651. %
  3652. % \begin{macro}{\GlossaryMin}
  3653. %    \changes{BHK}{89/04/26}{Added to support
  3654. %                            {\tt\protect\bslash changes}.}
  3655. % \begin{macro}{\c@GlossaryColumns}
  3656. %    \changes{BHK}{89/04/26}{Added to support
  3657. %                            {\tt\protect\bslash changes}.}
  3658. %    The remaining macros are all analogues of those used for the {\sf
  3659. %    theindex} environment.  When the glossary is started we compute
  3660. %    the space which remains at the bottom of the current page; if
  3661. %    this is greater than \verb+\GlossaryMin+ then the first part of
  3662. %    the glossary will be placed in the available space.  The number
  3663. %    of columns set are controlled by the counter
  3664. %    \verb+\c@GlossaryColumns+ which can be changed with a
  3665. %    \verb+\setcounter+ declaration.
  3666. %    \begin{macrocode}
  3667. \newdimen\GlossaryMin         \GlossaryMin       = 80pt
  3668. \newcount\c@GlossaryColumns   \c@GlossaryColumns = 2
  3669. %    \end{macrocode}
  3670. % \end{macro}
  3671. % \end{macro}
  3672. %
  3673. %
  3674. % \begin{macro}{\theglossary}
  3675. %  \changes{BHK}{89/04/26}{Added to support
  3676. %                            {\tt\protect\bslash changes}.}
  3677. % \changes{v1.5p}{89/09/28}{Now call `multicols first.}
  3678. %    \changes{v1.6e}{91/04/03}{Turned into env definition.}
  3679. %    \changes{v1.7a}{92/03/10}{Changed to work without multicols if
  3680. %                              necessary.}
  3681. % \begin{macro}{\endglossary}
  3682. %    \changes{BHK}{89/04/26}{Added to support
  3683. %                            {\tt\protect\bslash changes}.}
  3684. %    The environment {\sf theglossary} is defined in the same manner
  3685. %    as the {\sf theindex} environment.
  3686. %    \begin{macrocode}
  3687. \ifhave@multicol
  3688.   \newenvironment{theglossary}{%
  3689.     \begin{multicols}\c@GlossaryColumns
  3690.                      [\glossary@prologue][\GlossaryMin]%
  3691.     \GlossaryParms \let\item\@idxitem \ignorespaces}%
  3692.    {\end{multicols}}
  3693. \else
  3694.   \newenvironment{theglossary}{%
  3695.       \@restonecoltrue\if@twocolumn\@restonecolfalse\fi
  3696.       \columnseprule \z@  \columnsep 35\p@
  3697.       \twocolumn[\glossary@prologue]%
  3698.       \GlossaryParms \let\item\@idxitem \ignorespaces}
  3699.     {\if@restonecol\onecolumn\else\clearpage\fi}
  3700. \fi
  3701. %    \end{macrocode}
  3702. % \end{macro}
  3703. % \end{macro}
  3704. % Here are the necessary {\sf makeindex} declarations with scanning
  3705. % disabled as for the index.
  3706. %    \begin{macrocode}
  3707. %</style>
  3708. %<+gglo>preamble
  3709. %<+gglo>"\n \\begin{theglossary} \n
  3710. %<+gglo>    \\makeatletter\\scan@allowedfalse\n"
  3711. %<+gglo>postamble
  3712. %<+gglo>"\n\n \\end{theglossary}\n"
  3713. %    \end{macrocode}
  3714. % This difference from {\tt gind.ist} is necessary if you have an
  3715. % up-to-date \LaTeX. 
  3716. %    \begin{macrocode}
  3717. %<+gglo>keyword "\\glossaryentry"
  3718. %<*style>
  3719. %    \end{macrocode}
  3720. %
  3721. %
  3722. % \begin{macro}{\GlossaryPrologue}
  3723. %    \changes{BHK}{89/04/26}{Added to support
  3724. %                            {\tt\protect\bslash changes}.}
  3725. % \begin{macro}{\glossary@prologue}
  3726. %    \changes{BHK}{89/04/26}{Added to support
  3727. %                            {\tt\protect\bslash changes}.}
  3728. %    The \verb+\GlossaryPrologue+ macro is used to place a short
  3729. %    message above the glossary into the document.  It is implemented
  3730. %    by redefining \verb+\glossary@prologue+, a macro which holds the
  3731. %    default text.  We better make it a long macro to allow
  3732. %    \verb+\par+ commands in its argument.
  3733. %    \begin{macrocode}
  3734. \long\def\GlossaryPrologue#1{\@bsphack
  3735.                              \def\glossary@prologue{#1}%
  3736.                              \@esphack}
  3737. %    \end{macrocode}
  3738. %    Now we test whether the default is already defined by another
  3739. %    style file. If not we define it.
  3740. %    \begin{macrocode}
  3741. \@ifundefined{glossary@prologue}
  3742.      {\def\glossary@prologue{\section*{{Change History}}%
  3743.                  \markboth{{Change History}}{{Change History}}%
  3744.                  }}{}
  3745. %    \end{macrocode}
  3746. % \end{macro}
  3747. % \end{macro}
  3748. %
  3749. % \begin{macro}{\GlossaryParms}
  3750. %    \changes{BHK}{89/04/26}{Added to support
  3751. %                            {\tt\protect\bslash changes}.}
  3752. % Unless the user specifies otherwise, we set the change history
  3753. % using the same parameters as for the index.
  3754. %    \begin{macrocode}
  3755. \@ifundefined{GlossaryParms}{\let\GlossaryParms\IndexParms}{}
  3756. %    \end{macrocode}
  3757. % \end{macro}
  3758. % \begin{macro}{\PrintChanges}
  3759. %    \changes{BHK}{89/04/26}{Added to support
  3760. %                            {\tt\protect\bslash changes}.}
  3761. %    To read in and print the sorted change history, just put the
  3762. %    \verb+\PrintChanges+ command as the last (commented-out, and thus
  3763. %    executed during the documentation pass through the file) command
  3764. %    in your style file.  Alternatively, this command may form one of
  3765. %    the arguments of the \verb+\StopEventually+ command, although a
  3766. %    change history is probably {\em not\/} required if only the
  3767. %    description is being printed.
  3768. %
  3769. %    The command assumes that {\sf makeindex} or some other program
  3770. %    has processed the {\tt.glo} file to generate a sorted {\tt.gls}
  3771. %    file.
  3772. %    \begin{macrocode}
  3773. \def\PrintChanges{\@input{\jobname.gls}}
  3774. %    \end{macrocode}
  3775. % \end{macro}
  3776. %
  3777. %    
  3778. %
  3779. %
  3780. %
  3781. % \subsection{Bells and whistles}
  3782. %
  3783. % \begin{macro}{\StopEventually}
  3784. % \changes{v1.5k}{89/09/04}{Support for checksum.}
  3785. % \begin{macro}{\Finale}
  3786. % \changes{v1.5k}{89/09/04}{Support for checksum.}
  3787. % \changes{v1.5z}{90/04/22}{Define `Finale globally.}
  3788. % \begin{macro}{\OnlyDescription}
  3789. %    Here is the default definition for \verb+\StopEventually+, we
  3790. %    simply save its argument in the macro \verb+\Finale+.
  3791. %    \begin{macrocode}
  3792. \long\def\StopEventually#1{\@bsphack\gdef\Finale{#1%
  3793. %    \end{macrocode}
  3794. %    But \verb+\Finale+ will be called at the very end of a file. This
  3795. %    is exactly the point were we want to know if the file is
  3796. %    uncorrupted. Therefore we call \verb+\check@checksum+ at this
  3797. %    point. 
  3798. %    \begin{macrocode}
  3799.               \check@checksum}%
  3800. %    \end{macrocode}
  3801. %    On the other hand: \verb+\StopEventually+ is more or less a
  3802. %    dividing point between description and code. So we start to look
  3803. %    for the check-sum of the documented file by calling
  3804. %    \verb+\init@checksum+. 
  3805. %    \begin{macrocode}
  3806.            \init@checksum
  3807.            \@esphack}
  3808. %    \end{macrocode}
  3809. %    When the user places an \verb+\OnlyDescription+ declaration in
  3810. %    the driver file the document should only be typeset up to
  3811. %    \verb+\StopEventually+. We therefore have to redefine this macro.
  3812. %    \begin{macrocode}
  3813. \def\OnlyDescription{\@bsphack\long\def\StopEventually##1{%
  3814. %    \end{macrocode}
  3815. %    In this case the argument of \verb+\StopEventually+ should be set
  3816. %    and afterwards \TeX{} should stop reading from this file.
  3817. %    Therefore we finish this macro with
  3818. %    \begin{macrocode}
  3819.            ##1\endinput}\@esphack}
  3820. %    \end{macrocode}
  3821. % \end{macro}
  3822. % \end{macro}
  3823. % \end{macro}
  3824. %
  3825. % \begin{macro}{\meta}
  3826. % \changes{v1.4t}{89/04/24}{Macro added.}
  3827. % \begin{macro}{\m@ta}
  3828. % \changes{v1.5w}{90/02/03}{Breaks at space allowed.}
  3829. % \changes{v1.6a}{90/05/24}{Extra space bug corrected.}
  3830. %    The \verb+\meta+ macro is a bit tricky. We want to allow line
  3831. %    breaks at blanks in the argument but we don't want a break
  3832. %    in between. We therefore define \verb+\meta+ in a way that a
  3833. %    \verb*+ + is active when the argument is scanned. Words are then
  3834. %    scanned into \verb+\hbox+es. The active \verb*+ + will end the
  3835. %    preceding \verb+\hbox+ add an ordinary space and open a new
  3836. %    \verb+\hbox+. In this way breaks are only possible at spaces.  It
  3837. %    would be even better to forbid page breaks but this is not
  3838. %    possible in an all cases.
  3839. %    \begin{macrocode}
  3840. \begingroup
  3841. \obeyspaces%
  3842. \catcode`\^^M\active%
  3843. %    \end{macrocode}
  3844. %    We have to be careful to end all lines with a \verb+%+ sign in
  3845. %    this definition.
  3846. %    \begin{macrocode}
  3847. \gdef\meta{\begingroup\obeyspaces\catcode`\^^M\active%
  3848. \let^^M\do@space\let \do@space%
  3849. %    \end{macrocode}
  3850. %    To allow to break up words inside the \verb+\meta+ command we
  3851. %    redefine the \verb+\-+ command. It now has to end the last
  3852. %    open box, add a discretionary and start the next one for the
  3853. %    rest of the current word. See below for more details.
  3854. %
  3855. %    Finally we call \verb+\m@ta+ which
  3856. %    will scan the argument of \verb+\meta+.
  3857. %    \begin{macrocode}
  3858. \def\-{\egroup\discretionary{-}{}{}\hbox\bgroup\it}%
  3859. \m@ta}%
  3860. \endgroup
  3861. %    \end{macrocode}
  3862. %    We start \verb+\m@ta+ by opening an \verb+\hbox+.
  3863. %    Inside this box there will be angle brackets and the argument
  3864. %    typeset in italic typeface. If there are no spaces or \verb+\-+ 
  3865. %    commands in this argument the result will be a single box. But
  3866. %    when a space is encountered (which has \verb+\catcode+ 13) then
  3867. %    it will expand into \verb+\do@space+ which will close the current
  3868. %    box, output a space (so that we have a legitimate break point, and
  3869. %    then opens an new box to catch the rest of the argument.
  3870. % \changes{v1.6d}{90/11/16}{`leavevmode added.}
  3871. %    \begin{macrocode}
  3872. \def\m@ta#1{\leavevmode\hbox\bgroup$\langle$\it#1\/$\rangle$\egroup
  3873. %    \end{macrocode}
  3874. %    Finally, we have to close the group which was started in
  3875. %    \verb+\meta+ 
  3876. %    to restore all our changes.
  3877. %    \begin{macrocode}
  3878.     \endgroup}
  3879. %    \end{macrocode}
  3880. %    The \verb+\do@space+ macro will produce the possible breakpoint
  3881. %    by ending the current box (\verb+\egroup+) and adding the
  3882. %    \verb+\space+ 
  3883. %    into the surrounding paragraph.
  3884. %    \begin{macrocode}
  3885. \def\do@space{\egroup\space
  3886. %    \end{macrocode}
  3887. %    Then we start a new box, switching again to italic to catch the
  3888. %    rest of the argument of \verb+\meta+. But we also have to make sure
  3889. %    that any space following  directly will be ignored. Therefore we
  3890. %    check the following token and discard it as long as it is a token
  3891. %    with the meaning \verb+\do@space+, i.e.\ a $\verb*+ +_{13}$ or a
  3892. %    $\verb+^^M+_{13}$.
  3893. %    \begin{macrocode}
  3894.     \hbox\bgroup\it\futurelet\next\sp@ce}
  3895. \def\sp@ce{\ifx\next\do@space\expandafter\sp@@ce\fi}
  3896. \def\sp@@ce#1{\futurelet\next\sp@ce}
  3897. %    \end{macrocode}
  3898. % \end{macro}
  3899. % \end{macro}
  3900. %
  3901. %
  3902. % \begin{macro}{\IndexInput}
  3903. %    This next macro may be used to read in a separate file (possibly
  3904. %    a style file that is {\em not\/} documented by this means) and
  3905. %    set it verbatim, whilst scanning for macro names and indexing the
  3906. %    latter.  This could be a useful first pass in preparing to
  3907. %    generate documentation for the file read.
  3908. %    \begin{macrocode}
  3909. \def\IndexInput#1{%
  3910. %    \end{macrocode}
  3911. %     We commence by setting up a group, and initializing a
  3912. %    \verb+\trivlist+ as is normally done by a
  3913. %    \verb+\begin{macrocode}+ command.
  3914. %    \begin{macrocode}
  3915.      \begingroup \macro@code
  3916. %    \end{macrocode}
  3917. %    We also make spacing behave as in the {\sf macrocode}
  3918. %    environment, because otherwise all the spaces will be shown
  3919. %    explicitly.
  3920. %    \begin{macrocode}
  3921.    \frenchspacing \@vobeyspaces
  3922. %    \end{macrocode}
  3923. %    Then it only remains to read in the specified file, and finish
  3924. %    off the \verb+\trivlist+.
  3925. % \changes{v1.5t}{89/11/07}{Call `endmacrocode instead of `endtrivlist.}
  3926. %    \begin{macrocode}
  3927.      \input{#1}\endmacrocode
  3928. %    \end{macrocode}
  3929. %    Of course, we need to finish off the group as well.
  3930. %    \begin{macrocode}
  3931.      \endgroup}
  3932. %    \end{macrocode}
  3933. % \end{macro}
  3934. %
  3935. %
  3936. % \begin{macro}{\maketitle}
  3937. %    The macro to generate titles is easily altered in order that it
  3938. %    can be used more than once (an article with many titles).  In the
  3939. %    original, diverse macros were concealed after use with
  3940. %    \verb+\relax+. We must cancel anything that may have been put
  3941. %    into \verb+\@thanks+, etc., otherwise {\em all\/} titles will
  3942. %    carry forward any earlier such setting!
  3943. %  \changes{v1.5j}{89/06/09}{thispagestyle plain removed}
  3944. %    \begin{macrocode}
  3945. \def\maketitle{\par
  3946.       \begingroup \def \thefootnote {\fnsymbol {footnote}}%
  3947.       \setcounter {footnote}\z@
  3948.       \def \@makefnmark {\hbox to \z@{$^{\@thefnmark }$\hss }}%
  3949.       \if@twocolumn \twocolumn [\@maketitle ]%
  3950.       \else \newpage \global \@topnum \z@ \@maketitle \fi
  3951. %    \end{macrocode}
  3952. % \changes{v1.5k}{89/09/04}{Added {\tt\protect\bslash ps@titlepage}}
  3953. %    For special formatting requirements (such as in TUGboat), we use
  3954. %    pagestyle \verb+titlepage+ for this; this is later defined to be
  3955. %    \verb+plain+, unless already defined, as, for example, by
  3956. %    \verb+ltugboat.sty+.
  3957. %    \begin{macrocode}
  3958.        \thispagestyle{titlepage}\@thanks \endgroup
  3959. %    \end{macrocode}
  3960. %    If the driver file documents many files, we don't want parts of a
  3961. %    title of one to propagate to the next, so we have to cancel
  3962. %    these:
  3963. %    \begin{macrocode}
  3964.       \setcounter {footnote}\z@
  3965.       \gdef\@date{\today}\gdef\@thanks{}%
  3966.       \gdef\@author{}\gdef\@title{}}
  3967. %    \end{macrocode}
  3968. % \end{macro}
  3969. %
  3970. %
  3971. % \begin{macro}{\ps@titlepage}
  3972. % \changes{v1.5k}{89/09/04}{Added {\tt\protect\bslash ps@titlepage}}
  3973. %    When a number of articles are concatenated into a journal, for
  3974. %    example, it is not usual for the title pages of such documents to
  3975. %    be formatted differently.  Therefore, a style option such as {\sf
  3976. %    ltugboat} can define this macro in advance.  However, if no such
  3977. %    definition exists, we use pagestyle {\tt plain} for title pages.
  3978. %    \begin{macrocode}
  3979. \@ifundefined{ps@titlepage}
  3980.     {\let\ps@titlepage=\ps@plain}{}
  3981. %    \end{macrocode}
  3982. % \end{macro}
  3983. %
  3984. % \begin{macro}{\MakeShortVerb}
  3985. % \changes{v1.7a}{92/02/27}{Added (from newdoc but now alters
  3986. %                           `dospecials, `@sanitize).} 
  3987. % This arranges an abbreviation for "\verb" such that if you say
  3988. % "\MakeShortVerb{\"\meta{c}"}" subsequently using
  3989. % \meta{c}\meta{text}\meta{c} is equivalent to
  3990. % "\verb"\meta{c}\meta{text}\meta{c}.\footnote{Warning:
  3991. % the commentary in the rest of this section was written by Dave
  3992. % Love.}  In addition, the fact 
  3993. % that \meta{c} is made active is recorded for the benefit of the
  3994. % {\sf verbatim} and {\sf macrocode} environments.
  3995. % Note particularly that the definitions below are global.
  3996. % The first thing we do (it needn't be first) is to record
  3997. % the---presumably new---special character in "\dospecials" and
  3998. % "\@sanitize" using "\add@special".
  3999. %    \begin{macrocode}
  4000. \def\MakeShortVerb#1{%
  4001.   \typeout{*** Made \expandafter\@gobble\string#1\space a short
  4002.            reference for \string\verb \on@line\space ***}%
  4003.   \add@special{#1}%
  4004. %    \end{macrocode}
  4005. % Then the character's current catcode is stored in "\cc\"\meta{c}.
  4006. %    \begin{macrocode}
  4007.   \expandafter
  4008.   \xdef\csname cc\string#1\endcsname{\the\catcode`#1}%
  4009. %    \end{macrocode}
  4010. % The character is spliced into the definition using the same trick as
  4011. % used in "\verb" (for instance), having activated "~" in a group.
  4012. %    \begin{macrocode}
  4013.   \begingroup
  4014.     \catcode`\~\active  \lccode`\~`#1%
  4015.     \lowercase{%
  4016. %    \end{macrocode}
  4017. % The character's old meaning is recorded in "\ac\"\meta{c} prior to
  4018. % assigning it a new one.
  4019. %    \begin{macrocode}
  4020.     \global\expandafter\let
  4021.        \csname ac\string#1\endcsname~%
  4022.     \gdef~{\verb~}}%
  4023.   \endgroup
  4024. %    \end{macrocode}
  4025. % Finally the character is made active.
  4026. %    \begin{macrocode}
  4027.   \global\catcode`#1\active}
  4028. %    \end{macrocode}
  4029. % \end{macro}
  4030. % \begin{macro}{\DeleteShortVerb}
  4031. % \changes{v1.7a}{92/02/27}{Added (from newdoc but now alters
  4032. %                           `dospecials, `@sanitize).}
  4033. % Here's the means of undoing a "\MakeShortVerb", for instance in a
  4034. % region where you need to use the character outside a verbatim
  4035. % environment.  It arranges for "\dospecials" and "\@sanitize" to be
  4036. % altered appropriately, restores the saved catcode and, if necessary,
  4037. % the character's meaning (as stored by 
  4038. % "\MakeShortVerb").  If the catcode wasn't stored in
  4039. % "\cc\"\meta{c} (by "\MakeShortVerb") the command is silently
  4040. % ignored. 
  4041. % \changes{v1.7a}{92/02/28}{Check for previous matched `MakeShortVerb
  4042. %                           to avoid error.}
  4043. %    \begin{macrocode}
  4044. \def\DeleteShortVerb#1{%
  4045.   \expandafter\ifx\csname cc\string#1\endcsname\relax
  4046.   \else
  4047.     \typeout{*** Deleted \expandafter\@gobble\string#1\space as short
  4048.              reference for \string\verb \on@line\space ***}%
  4049.     \rem@special{#1}%
  4050.     \global\catcode`#1\csname cc\string#1\endcsname
  4051.     \ifnum\catcode`#1=\active
  4052.       \begingroup
  4053.         \catcode`\~\active   \lccode`\~`#1%
  4054.         \lowercase{%
  4055.           \global\expandafter\let\expandafter~%
  4056.           \csname ac\string#1\endcsname}%
  4057.       \endgroup \fi \fi}
  4058. %    \end{macrocode}
  4059. % \end{macro}
  4060. % \begin{macro}{\add@special}
  4061. % \changes{v1.7a}{92/02/27}{Added for short verb facility.}
  4062. % This helper macro adds its argument to the
  4063. % "\dospecials" macro which is conventionally used by verbatim macros
  4064. % to alter the catcodes of the currently active characters.  We need
  4065. % to add "\do\"\meta{c} to the expansion of "\dospecials" after
  4066. % removing the character if it was already there to avoid multiple
  4067. % copies building up should "\MakeShortVerb" not be balanced by
  4068. % "\DeleteShortVerb" (in case anything that uses "\dospecials" cares
  4069. % about repetitions).
  4070. %    \begin{macrocode}
  4071. \def\add@special#1{%
  4072.   \rem@special{#1}%
  4073.   \expandafter\gdef\expandafter\dospecials\expandafter
  4074.     {\dospecials \do #1}%
  4075. %    \end{macrocode}
  4076. % Similarly we have to add "\@makeother\"\meta{c} to "\@sanitize"
  4077. % (which is used in things like "\index" to re-catcode all special
  4078. % characters except braces).
  4079. %    \begin{macrocode}
  4080.   \expandafter\gdef\expandafter\@sanitize\expandafter
  4081.     {\@sanitize \@makeother #1}}
  4082. %    \end{macrocode}
  4083. % \end{macro}
  4084. % \begin{macro}{\rem@special}
  4085. % \changes{v1.7a}{92/02/27}{Added for short verb facility.}
  4086. % The inverse of "\add@special" is slightly trickier.  "\do" is
  4087. % re-defined to expand to nothing if its argument is the character of
  4088. % interest, otherwise to expand simply to the argument.  We can then
  4089. % re-define "\dospecials" to be the expansion of itself.  The space
  4090. % after "=`##1" prevents an expansion to "\relax"!
  4091. %    \begin{macrocode}
  4092. \def\rem@special#1{%
  4093.   \def\do##1{%
  4094.     \ifnum`#1=`##1 \else \noexpand\do\noexpand##1\fi}%
  4095.   \xdef\dospecials{\dospecials}%
  4096. %    \end{macrocode}
  4097. % Fixing "\@sanitize" is the same except that we need to re-define
  4098. % "\@makeother" which obviously needs to be done in a group. 
  4099. %    \begin{macrocode}
  4100.   \begingroup
  4101.     \def\@makeother##1{%
  4102.       \ifnum`#1=`##1 \else \noexpand\@makeother\noexpand##1\fi}%
  4103.     \xdef\@sanitize{\@sanitize}%
  4104.   \endgroup}
  4105. %    \end{macrocode}
  4106. % \end{macro}
  4107. % \begin{macro}{\MakeShortverb}
  4108. % \begin{macro}{\DeleteShortverb}
  4109. % \changes{v1.7a}{92/02/27}{Added (from newdoc).}
  4110. % These commands from {\sf newdoc} are now obsolete.
  4111. %    \begin{macrocode}
  4112. \def\MakeShortverb{\typeout{*** Switch to \noexpand\MakeShortVerb
  4113.                          syntax, this is obsolete ***}\MakeShortVerb}
  4114. \def\DeleteShortverb{\typeout{*** Switch to \noexpand\DeleteShortVerb
  4115.                          syntax, this is obsolete ***}\DeleteShortVerb}
  4116. %    \end{macrocode}
  4117. % \end{macro}
  4118. % \end{macro}
  4119. %
  4120. %
  4121. %
  4122. % \subsection[Providing a checksum and character table]
  4123. %        {Providing a checksum and character table\footnotemark}
  4124. %        \footnotetext{Warning: the commentary in this section was
  4125. %                      written by Dave Love. }
  4126. %
  4127. % \begin{macro}{\init@checksum}
  4128. % The checksum mechanism works by counting backslashes in the
  4129. % macrocode.  This initialises the count (when called from
  4130. % "\StopEventually"). 
  4131. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4132. %    \begin{macrocode}
  4133. \def\init@checksum{\relax
  4134.     \global\bslash@cnt\z@}
  4135. %    \end{macrocode}
  4136. % \end{macro}
  4137. %
  4138. %
  4139. % \begin{macro}{\check@checksum}
  4140. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4141. % This reports the sum compared with the value ("\bslash@cnt") the
  4142. % file advertises.  It's called from "\Finale" (if that hasn't been
  4143. % re-defined). 
  4144. %    \begin{macrocode}
  4145. \def\check@checksum{\relax
  4146.      \ifnum\check@sum=\z@
  4147.        \typeout{**********************************}%
  4148.        \typeout{* This macro file has no checksum!}%
  4149.        \typeout{* The checksum should be \the\bslash@cnt!}%
  4150.        \typeout{**********************************}%
  4151.      \else
  4152.        \ifnum\check@sum=\bslash@cnt
  4153.          \typeout{*******************}%
  4154.          \typeout{* Checksum passed *}%
  4155.          \typeout{*******************}%
  4156.        \else
  4157.          \errhelp\wrong@checksum
  4158.          \errmessage{Checksum not passed 
  4159.                     (\the\check@sum<>\the\bslash@cnt)}%
  4160.         \fi
  4161.      \fi
  4162.      \global\check@sum\z@}
  4163. %    \end{macrocode}
  4164. % \end{macro}
  4165. %
  4166. %
  4167. % \begin{macro}{\check@sum}
  4168. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4169. % \begin{macro}{\bslash@cnt}
  4170. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4171. % \begin{macro}{\wrong@checksum}
  4172. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4173. % We need to define the counter for the number of backslashes counted
  4174. % ("\bslash@cnt") and the value advertised by the file ("\check@sum")
  4175. % as well as a help message for when things go wrong.
  4176. %    \begin{macrocode}
  4177. \newcount\check@sum           \check@sum  = \z@
  4178. \newcount\bslash@cnt          \bslash@cnt = \z@
  4179. \newhelp\wrong@checksum
  4180.    {The currently documented file seems to be wrong.^^J%
  4181.     Try to get a correct version.}%
  4182. %    \end{macrocode}
  4183. % \end{macro}
  4184. % \end{macro}
  4185. % \end{macro}
  4186. %
  4187. %
  4188. % \begin{macro}{\CheckSum}
  4189. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4190. % This is the interface to setting "\check@sum".
  4191. %    \begin{macrocode}
  4192. \def\CheckSum#1{\@bsphack\global\check@sum#1\relax\@esphack}
  4193. %    \end{macrocode}
  4194. % \end{macro}
  4195. %
  4196. %
  4197. %
  4198. % \begin{macro}{\step@checksum}
  4199. % \changes{v1.5k}{89/09/04}{Macro added to support checksum.}
  4200. % This advances the count when a backslash is encountered in the
  4201. % macrocode. 
  4202. %    \begin{macrocode}
  4203. \def\step@checksum{\global\advance\bslash@cnt\@ne}
  4204. %    \end{macrocode}
  4205. % \end{macro}
  4206. %
  4207. % \begin{macro}{\CharacterTable}
  4208. %    The user interface to the character table-checking does some
  4209. %    "\catcode"ing and then compares the following table with the
  4210. %    stored version. We need to have "@" of type ``other'' within the
  4211. %    table since this is the way it is usually returned when reading
  4212. %    in a normal document. To nevertheless have a private letter we
  4213. %    use "~" for this purpose. "~" does no harm as a ``letter'' as it
  4214. %    comes last in the table and therefore will not gobble following
  4215. %    space.
  4216. % \changes{v1.5m}{89/09/20}{Macro added to check character translation
  4217. %                           problems.}
  4218. % \changes{v1.5q}{89/11/01}{Made character table more readable.}
  4219. % \changes{v1.5t}{89/11/07}{Make \string\~{} letter in chartable
  4220. %                           macros.} 
  4221. % \changes{v1.5u}{89/11/14}{Made @ other in default table.}
  4222. %    \begin{macrocode}
  4223. \def\CharacterTable{\begingroup \CharTableChanges \character@table}
  4224. %    \end{macrocode}
  4225. % \end{macro}
  4226. % \def\MakePrivateLetters{\catcode`\~=11\makeatletter}
  4227. % \begin{macro}{\character@table}
  4228. % This does the work of comparing the tables and reporting the result.
  4229. % Note that the following code is enclosed in a group
  4230. % with "~" catcoded to letter.
  4231. %    \begin{macrocode}
  4232. \begingroup
  4233.   \catcode`\~=11
  4234.   \gdef\character@table#1{\def\used~table{#1}%
  4235.       \ifx\used~table\default~table
  4236.            \typeout{***************************}%
  4237.            \typeout{* Character table correct *}%
  4238.            \typeout{***************************}%
  4239.       \else
  4240.          \errhelp\wrong@table
  4241.          \errmessage{Character table corrupted}%
  4242.          \show\default~table
  4243.          \show\used~table
  4244.       \fi
  4245.       \endgroup}
  4246. %    \end{macrocode}
  4247. % \end{macro}
  4248. %
  4249. % \begin{macro}{\CharTableChanges}
  4250. %    When the character table is read in we need to scan it with a
  4251. %    fixed set of "\catcode"s. The reference table below  was defined by
  4252. %    assuming the normal "\catcode"s of \TeX{}, i.e.\ "@" is of type
  4253. %    other and the only token of type ``letter'' are the usual letters
  4254. %    of the alphabet. If, for some reason, other characters are made
  4255. %    ``letters'' then their "\catcode"s need to be restored before
  4256. %    checking the table. Otherwise spaces in the table are gobbled and
  4257. %    we get the information that the tables are different, even if
  4258. %    they are actually equal. For this reason "\CharTableChanges" can
  4259. %    be set up to locally restore the "\catcode"s of such ``letters''
  4260. %    to ``other''.
  4261. %    \begin{macrocode}
  4262.   \global\let\CharTableChanges\@empty
  4263. %    \end{macrocode}
  4264. % \end{macro}
  4265. %
  4266. % \begin{macro}{\default~table}
  4267. % Here's what the table {\em should\/} look like (modulo spaces).
  4268. %    \begin{macrocode}
  4269.   \makeatother
  4270.   \gdef\default~table
  4271.      {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  4272.       Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  4273.       Digits        \0\1\2\3\4\5\6\7\8\9
  4274.       Exclamation   \!     Double quote  \"     Hash (number) \#
  4275.       Dollar        \$     Percent       \%     Ampersand     \&
  4276.       Acute accent  \'     Left paren    \(     Right paren   \)
  4277.       Asterisk      \*     Plus          \+     Comma         \,
  4278.       Minus         \-     Point         \.     Solidus       \/
  4279.       Colon         \:     Semicolon     \;     Less than     \<
  4280.       Equals        \=     Greater than  \>     Question mark \?
  4281.       Commercial at \@     Left bracket  \[     Backslash     \\
  4282.       Right bracket \]     Circumflex    \^     Underscore    \_
  4283.       Grave accent  \`     Left brace    \{     Vertical bar  \|
  4284.       Right brace   \}     Tilde         \~}
  4285. \endgroup
  4286. %    \end{macrocode}
  4287. % \end{macro}
  4288. % \let\MakePrivateLetters=\makeatletter
  4289. % \begin{macro}{\wrong@table}
  4290. % \changes{v1.7a}{92/02/28}{Moved to where the catcodes are right so it
  4291. %                           works.} 
  4292. % We need a help message in case of problems.
  4293. %    \begin{macrocode}
  4294.   \newhelp\wrong@table{Some of the ASCII characters are corrupted.^^J
  4295.             I now \string\show\space you both tables for comparison.}
  4296. %    \end{macrocode}
  4297. % \end{macro}
  4298. %
  4299. %
  4300. % \subsection[Attaching line numbers to code lines]
  4301. %            {Attaching line numbers to code lines\footnotemark}
  4302. %            \footnotetext{Warning: the commentary was written by Dave
  4303. %            Love.}
  4304. %
  4305. %
  4306. % The code in this section allows index entries to refer to code line
  4307. % numbers---the number of the first line of macrocode in the {\sf macro}
  4308. % environment. 
  4309. % \begin{macro}{\codeline@index}
  4310. % Indexing by code line is controlled by the "codeline@index" switch.
  4311. % \changes{v1.5s}{89/11/05}{Support for code line no. (Undoc)}
  4312. % \changes{v1.7a}{92/02/24}{Documented code line no. support.}
  4313. %    \begin{macrocode}
  4314. \newif\ifcodeline@index \codeline@indexfalse
  4315. %    \end{macrocode}
  4316. % \end{macro}
  4317. % \begin{macro}{\codeline@wrindex}
  4318. %    The code index entries are written out by "\special@index".  If
  4319. %    indexing is by code line this is "\let" to "\codeline@wrindex";
  4320. %    if indexing is by page it is just "\index".  However, if
  4321. %    "\nofiles" is given, we omit writing such an index entry at all.
  4322. % \changes{v1.7j}{92/08/14}{Added `if@filesw.}
  4323. %    \begin{macrocode}
  4324. \def\codeline@wrindex#1{\if@filesw
  4325.         \immediate\write\@indexfile
  4326.             {\string\indexentry{#1}%
  4327.             {\number\c@CodelineNo}}\fi}
  4328. %    \end{macrocode}
  4329. % \end{macro}
  4330. % \begin{macro}{\special@index}
  4331. % By default no index entries are written out.
  4332. %    \begin{macrocode}
  4333. \let\special@index = \@gobble
  4334. %    \end{macrocode}
  4335. % \end{macro}
  4336. % \begin{macro}{\CodelineIndex}
  4337. % \changes{v1.5u}{89/11/14}{Added `PageIndex and `CodelineIndex (Undoc)}
  4338. % This switches on use of the index file with "\makeindex", sets the
  4339. % switch to indicate code line numbering and defines "\special@index"
  4340. % appropriately. 
  4341. %    \begin{macrocode}
  4342. \def\CodelineIndex{\makeindex 
  4343.                    \codeline@indextrue
  4344.                    \let\special@index\codeline@wrindex}
  4345. %    \end{macrocode}
  4346. % \end{macro}
  4347. % \begin{macro}{\PageIndex}
  4348. % "\PageIndex" is similar.
  4349. %    \begin{macrocode}
  4350. \def\PageIndex{\makeindex 
  4351.                \codeline@indexfalse
  4352.                \let\special@index\index}
  4353. %    \end{macrocode}
  4354. % \end{macro}
  4355. %
  4356. %
  4357. % \begin{macro}{\c@CodelineNo}
  4358. % \changes{v1.5l}{89/09/10}{Counter added to support code line numbers.}
  4359. % \changes{v1.5y}{90/02/24}{Default changed.}
  4360. % \changes{v1.6b}{90/06/15}{`rm moved before `scriptsize to
  4361. %                           avoid unnecessary fontwarning.}
  4362. % We need a counter to keep track of the line number.
  4363. %    \begin{macrocode}
  4364. \newcount\c@CodelineNo  \c@CodelineNo\z@
  4365. %    \end{macrocode}
  4366. % \end{macro}
  4367. % \begin{macro}{\theCodelineNo}
  4368. % \changes{v1.7a}{92/02/25}{Existing definition not overwritten.}
  4369. % \changes{v1.7a}{92/03/12}{Use `reset@font for NFSS.}
  4370. % This provides a hook to control the format of line numbers which may
  4371. % be defined in a style file.
  4372. %    \begin{macrocode}
  4373. \@ifundefined{theCodelineNo}
  4374.   {\ifx\selectfont\undefined
  4375.      \def\theCodelineNo{\rm\scriptsize\arabic{CodelineNo}}%
  4376.    \else
  4377.      \def\theCodelineNo{\reset@font\scriptsize\arabic{CodelineNo}}%
  4378.    \fi}
  4379.   {} 
  4380. %    \end{macrocode}
  4381. % \end{macro}
  4382. %
  4383. %
  4384. %
  4385. %
  4386. % \subsection{Layout Parameters for documenting style files}
  4387. %
  4388. % \begin{macro}{\tolerance}
  4389. %    People documenting style files would probably rather have things
  4390. %    ``sticking out'' in overfull \verb+\hbox+es and poorish spacing,
  4391. %    because they probably don't want to spend a lot of time on making
  4392. %    all the line breaks perfect!
  4393. %    \begin{macrocode}
  4394.        \tolerance=1000\relax
  4395. %    \end{macrocode}
  4396. % \end{macro}
  4397. %
  4398. % \DeleteShortVerb{\"}
  4399. %
  4400. % The following \verb+\mathcode+ definitions allow the characters
  4401. % `\verb+\+'
  4402. % and `{\tt @}' to appear in \verb+\tt+ font when invoked in math 
  4403. % mode;\footnote{You may wonder why the definitions state that both
  4404. %                characters belong to the {\em variable family\/}
  4405. %                (i.e.\ the number 7 in front). The reason is this:
  4406. %                Originally the {\tt\bslash mathcode} of
  4407. %                {\tt\bslash} was defined to be {\tt "075C},
  4408. %                i.e.\ ordinary character number 92 (hex 5C) in
  4409. %                math family number 7 which is the typewriter family in
  4410. %                standard \LaTeX.
  4411. %                But this file should not depend on this specific
  4412. %                setting, so I changed these {\tt\bslash mathcode}$\,$s
  4413. %                to work with any family assignments. For an example
  4414. %                see the article about the new font selection scheme.}
  4415. % particularly for something like $\verb+\@abc+=1$.
  4416. %
  4417. % If an {\em old\/} version of the {\sf german} style option is in
  4418. % force, then the `\verb+"+' character is active and would upset the
  4419. % definition of the \meta{16-bit number} quantities below, therefore
  4420. % we change the \verb+\catcode+ of \verb+"+ inside a group, and use
  4421. % \verb+\global+.
  4422. %    \begin{macrocode}
  4423. { \catcode`\"=12
  4424.   \global\mathcode`\\="705C \global\mathcode`\@="7040 }
  4425. %    \end{macrocode}
  4426. % \MakeShortVerb{\"}
  4427. %
  4428. % \begin{macro}{\DocstyleParms}
  4429. %    This macro can be used, for example, to assign new values to
  4430. %    \verb+\MacrocodeTopsep+ and \verb+\MacroIndent+ and some other
  4431. %    internal registers.  If it is already defined, the default
  4432. %    definition won't be carried out. Note that it is necessary to
  4433. %    assign new values via this macro if it should be done in a style
  4434. %    file (like {\tt ltugboat.sty} for example) since the registers are
  4435. %    undefined before {\tt doc.sty} is read in.  The default values
  4436. %    for the internal registers are scattered over this file.
  4437. % \changes{v1.5u}{89/11/14}{`DocStyleParms now empty}
  4438. %    \begin{macrocode}
  4439. \@ifundefined{DocstyleParms}{}{}
  4440. %    \end{macrocode}
  4441. %    Now we allow overwriting the values by calling
  4442. %    \verb+\DocstyleParms+.
  4443. %    \begin{macrocode}
  4444. \DocstyleParms     \let\DocstyleParms\relax
  4445. %    \end{macrocode}
  4446. % \end{macro}
  4447. %
  4448. %
  4449. %
  4450. % \begin{macro}{\AmSTeX}
  4451. %   \changes{v1.5j}{89/06/09}{Macro AmsTeX renamed to AmSTeX}
  4452. % \begin{macro}{\BibTeX}
  4453. % \begin{macro}{\SliTeX}
  4454. %    Here are a few definitions which can usefully be employed when
  4455. %    documenting style files: now we can readily refer to \AmSTeX,
  4456. %    \BibTeX\ and \SliTeX, as well as the usual \TeX\ and \LaTeX.
  4457. %    \begin{macrocode}
  4458. \@ifundefined{AmSTeX}
  4459.    {\def\AmSTeX{\leavevmode\hbox{$\cal A\kern-.2em\lower.376ex%
  4460.         \hbox{$\cal M$}\kern-.2em\cal S$-\TeX}}}{}
  4461. \@ifundefined{BibTeX}
  4462.    {\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em%
  4463.     T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}}{}
  4464. \@ifundefined{SliTeX}
  4465.    {\def\SliTeX{{\rm S\kern-.06emL\kern-.18em\raise.32ex\hbox
  4466.                 {\sc i}\kern -.03em\TeX}}}{}
  4467. %    \end{macrocode}
  4468. % \end{macro}
  4469. % \end{macro}
  4470. % \end{macro}
  4471. % \begin{macro}{\PlainTeX}
  4472. % \changes{v1.5g}{89/05/07}{space between plain and TeX changed.}
  4473. % \begin{macro}{\Web}
  4474. %     There's even a \PlainTeX{} and a \Web.
  4475. %    \begin{macrocode}
  4476. \@ifundefined{PlainTeX}{\def\PlainTeX{{\sc Plain}\kern2pt\TeX}}{}
  4477. \@ifundefined{Web}{\def\Web{{\sc Web}}}{}
  4478. %    \end{macrocode}
  4479. % \end{macro}
  4480. % \end{macro}
  4481. %
  4482. %
  4483. % \subsection{Changing the {\tt\protect\bslash catcode} of \%}
  4484. %
  4485. % \begin{macro}{\MakePercentIgnore}
  4486. % \begin{macro}{\MakePercentComment}
  4487. %    And finally the most important bit: we change the \verb+\catcode+
  4488. %    of `\verb+%+' so that it is ignored (which is how we are able to
  4489. %    produce this document!). We provide two commands to do the actual
  4490. %    switching.
  4491. %^^A The \verb+\MakePercentIgnore+ is then called as the
  4492. %^^A last command in this file.
  4493. %    \begin{macrocode}
  4494. \def\MakePercentIgnore{\catcode`\%9\relax}
  4495. \def\MakePercentComment{\catcode`\%14\relax}
  4496. %    \end{macrocode}
  4497. % \end{macro}
  4498. % \end{macro}
  4499. %
  4500. % \begin{macro}{\DocInput}
  4501. %    The two macros above are now used to define the
  4502. %    \verb+\DocInput+ macro which was introduced in version v1.5l
  4503. %    (or so) of
  4504. %    the {\tt doc} style option. In older versions
  4505. %    \verb+\MakePercentIgnore+ was placed at the very end of {\tt
  4506. %    doc.sty}.
  4507. %    \begin{macrocode}
  4508. \def\DocInput#1{\MakePercentIgnore\input{#1}\MakePercentComment}
  4509. %    \end{macrocode}
  4510. % \end{macro}
  4511. % We can now finish the {\tt docstrip} main module.
  4512. %    \begin{macrocode}
  4513. %</style>
  4514. %    \end{macrocode}
  4515. %
  4516. %
  4517. %  \begin{macro}{\on@line}
  4518. %    Finally something for people with an old \LaTeX:
  4519. % \changes{v1.7k}{92/08/24}{Macro and test added.}
  4520. %    \begin{macrocode}
  4521. \ifx\on@line\undefined
  4522.   \def\on@line{ on input line \the\inputlineno}
  4523.   \errhelp{Support for input line numbers has been added
  4524.            to latex.tex <dec91>.^^J^^J%
  4525.            Please update to a newer LaTeX release.}
  4526.   \errmessage{Obsolete LaTeX release (older than Dec.91)}
  4527. \fi
  4528. %    \end{macrocode}
  4529. %  \end{macro}
  4530. %
  4531. % \Finale
  4532. % \PrintIndex \PrintChanges
  4533. \endinput
  4534.