| 1 |
% $StyleId: cweb.doc,v 3.6 1995/11/30 15:44:53 schrod Exp $ |
| 2 |
%---------------------------------------------------------------------- |
| 3 |
% Written by Joachim Schrod <[email protected]>. |
| 4 |
% Copyright conditions see below (GPL). |
| 5 |
|
| 6 |
% |
| 7 |
% LaTeX class cweb |
| 8 |
% support for LaTeX markup in CWEB sources |
| 9 |
% |
| 10 |
% [LaTeX in MAKEPROG] |
| 11 |
% (history at end) |
| 12 |
|
| 13 |
% If you have received this style file without the user manual (in the |
| 14 |
% file cweb-user.dvi or the respective LaTeX file), it's incomplete and |
| 15 |
% near to useless. If it was given to you as something that you shall |
| 16 |
% use as an author -- complain bitterly to your provider. You need the |
| 17 |
% documentation and you have a right on it! (Below you can find info |
| 18 |
% where to get the reference version.) |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
\documentclass{progltx} |
| 24 |
|
| 25 |
\usepackage{cweb-doc} % document-specific markup |
| 26 |
\usepackage{fullpage} |
| 27 |
|
| 28 |
|
| 29 |
\RCS $StyleRevision: 3.6 $ |
| 30 |
\RCS $StyleDate: 1995/11/30 15:44:53 $ |
| 31 |
|
| 32 |
|
| 33 |
\begin{document} |
| 34 |
|
| 35 |
|
| 36 |
\title{The \texttt{cweb} Class\\ |
| 37 |
{\large (Implementation)}% |
| 38 |
} |
| 39 |
\author{% % LaTeX does not discard unnecessary glue... |
| 40 |
Joachim Schrod% |
| 41 |
\thanks{% |
| 42 |
\protect\raggedright |
| 43 |
TU~Darmstadt, Computer Science Department, WG Systems Programming, |
| 44 |
Alexanderstr.~10, D-64283~Darmstadt, Germany. |
| 45 |
Email: \texttt{[email protected]}% |
| 46 |
}% |
| 47 |
} |
| 48 |
\date{% |
| 49 |
Revision \RCSStyleRevision\\ |
| 50 |
(as of \RCSStyleDate)% |
| 51 |
} |
| 52 |
|
| 53 |
\maketitle |
| 54 |
|
| 55 |
|
| 56 |
% doesn't work with progltx yet |
| 57 |
%\tableofcontents |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
% ------------------------------------------------------------ |
| 62 |
% |
| 63 |
% subdocument: The user interface of cweb.cls |
| 64 |
% |
| 65 |
|
| 66 |
\input{cweb-user} |
| 67 |
|
| 68 |
% |
| 69 |
% ------------------------------------------------------------ |
| 70 |
% |
| 71 |
% subdocument: The internal interface |
| 72 |
% |
| 73 |
|
| 74 |
\input{cweb-conf} |
| 75 |
|
| 76 |
% |
| 77 |
% ------------------------------------------------------------ |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
\chap Implementation. |
| 83 |
|
| 84 |
This implementation must typeset complete files output by \cweave{}. |
| 85 |
Large parts of this task are available from the module \pkg{cwebbase}. |
| 86 |
It remains mainly to implement document-level markup and front and |
| 87 |
back matter (table of contents, index, etc.) In particular, the back |
| 88 |
matter material is not trivial; its tags are behind |\end{document}|, |
| 89 |
we have to read carefully behind the end of our \cweb{} document to |
| 90 |
detect if we have to typeset them at all. |
| 91 |
|
| 92 |
|
| 93 |
\sect This module reserves the namespace |cweb|. |
| 94 |
|
| 95 |
\beginprog |
| 96 |
\ifx \cweb@loaded\undefined |
| 97 |
\def\cweb@loaded{$StyleRevision: 3.6 $} |
| 98 |
\else |
| 99 |
\PackageWarningNoLine{cweb}% |
| 100 |
{Some other package already uses namespace `cweb'} |
| 101 |
\fi |
| 102 |
\endprog |
| 103 |
|
| 104 |
|
| 105 |
\sect Let's identify this class. |
| 106 |
|
| 107 |
\noindent The code below is explained in the implementation |
| 108 |
documentation of the \pkg{rcs} package. |
| 109 |
|
| 110 |
\beginprog |
| 111 |
\begingroup |
| 112 |
\def\RCSClass#1#2 $#3: #4 #5\endRCS $#6: #7 #8\endRCS{% |
| 113 |
\def\date{#4}\def\id{v#7}% |
| 114 |
\ProvidesClass{#1}[\date\space\id\space #2]% |
| 115 |
} |
| 116 |
|
| 117 |
\RCSClass{cweb}{LaTeX markup for CWEB sources} |
| 118 |
$StyleDate: 1995/11/30 15:44:53 $: 9999/00/00 \endRCS |
| 119 |
$StyleRevision: 3.6 $: 0.0 \endRCS |
| 120 |
\endgroup |
| 121 |
\endprog |
| 122 |
|
| 123 |
|
| 124 |
\sect This module is from a supported bundle. Send bug reports, |
| 125 |
comments and repairs. |
| 126 |
|
| 127 |
The reference version may be retrieved via anonymous ftp from |
| 128 |
|ftp.th-darmstadt.de| [130.83.47.112], directory |
| 129 |
|pub/programming/literate-programming/c.c++/|. It's |
| 130 |
placed there as a gzipped tar file. (The information on the IP~number |
| 131 |
is dated August~29,~1995. |
| 132 |
It might have changed, although this is very unlikely. Use |
| 133 |
your friendly nameserver.) |
| 134 |
|
| 135 |
|
| 136 |
\sect This is freely distributable software; you can redistribute it |
| 137 |
and/or modify it under the terms of the GNU General Public License as |
| 138 |
published by the Free Software Foundation; either version~2 of the |
| 139 |
License, or (at your option) any later version. |
| 140 |
|
| 141 |
This software is distributed in the hope that it will be useful, but |
| 142 |
\textbf{without any warranty}; without even the implied warranty of |
| 143 |
\textbf{merchantability} or \textbf{fitness for a particular purpose}. |
| 144 |
See the GNU General Public License for more details. |
| 145 |
|
| 146 |
You should have received a copy of the GNU General Public License in |
| 147 |
the file |License| along with this package; if not, write to the Free |
| 148 |
Software Foundation, Inc., 675~Mass Ave, Cambridge, MA~02139,~USA. |
| 149 |
|
| 150 |
|
| 151 |
\sect Before we start we declare some shorthands for category codes. |
| 152 |
By declaring the underscore~`(|_|)' as letter we can use it in our |
| 153 |
macros. (I agree with \textsc{D.~Knuth} that |
| 154 |
|\identifier_several_words_long| is more readable than |
| 155 |
|\IdentifierSeveralWordsLong| and in every case better than |\p@@@s|.) |
| 156 |
|
| 157 |
As this is a \LaTeX{} style file the at sign is a letter anyhow; so |
| 158 |
we can use the ``private'' \LaTeX{} macros; and with the underscore we |
| 159 |
can make our own macros more readable. But as we have to restore this |
| 160 |
category code at the end of this macro file we store its former value |
| 161 |
in the control sequence |\CatUsCode|. This method is better than to |
| 162 |
use a group because not all macros have to be defined global this way. |
| 163 |
|
| 164 |
Since somebody might use more styles from me, this cseqs might be |
| 165 |
defined already. |
| 166 |
|
| 167 |
\beginprog |
| 168 |
\ifx \CatEscape\undefined |
| 169 |
\chardef\CatEscape=0 |
| 170 |
\chardef\CatOpen=1 |
| 171 |
\chardef\CatClose=2 |
| 172 |
\chardef\CatIgnore=9 |
| 173 |
\chardef\CatLetter=11 |
| 174 |
\chardef\CatOther=12 |
| 175 |
\chardef\CatActive=13 % is defined in Plain already |
| 176 |
|
| 177 |
\chardef\CatUsCode=\catcode`\_ |
| 178 |
\fi |
| 179 |
|
| 180 |
\catcode`\_=\CatLetter % top level macro file |
| 181 |
\endprog |
| 182 |
|
| 183 |
|
| 184 |
\sect Problems over problems with different \LaTeX{} versions. I have |
| 185 |
decided that I will take the same stand as the \LaTeX{} team: I will |
| 186 |
only support the last two official \LaTeX{} versions, folks who run |
| 187 |
older software might need to upgrade. |
| 188 |
|
| 189 |
The implementation will use `star'-forms of \LaTeX{}'s command |
| 190 |
definition macros. They were introduced with \LaTeX{} |
| 191 |
\mbox{$\langle$1994/12/01$\rangle$}. |
| 192 |
|
| 193 |
Currently (as of 07 Nov 95), 1995/06/01 is the most recent version. |
| 194 |
I want to use a features introduced with that version: |\newif| is not |
| 195 |
outer any more. So I check here for the version and supply the new |
| 196 |
definition if necessary. |
| 197 |
|
| 198 |
\beginprog |
| 199 |
\NeedsTeXFormat{LaTeX2e}[1994/12/01] |
| 200 |
\@ifl@t@r \fmtversion{1995/06/01}{}% else |
| 201 |
{ |
| 202 |
\@namedef{newif}#1{% |
| 203 |
\count@\escapechar \escapechar\m@ne |
| 204 |
\let#1\iffalse |
| 205 |
\@if#1\iftrue |
| 206 |
\@if#1\iffalse |
| 207 |
\escapechar\count@ |
| 208 |
} |
| 209 |
\def\@if#1#2{% |
| 210 |
\expandafter\def |
| 211 |
\csname \expandafter\@gobbletwo\string#1% |
| 212 |
\expandafter\@gobbletwo\string#2\endcsname {% |
| 213 |
\let#1#2% |
| 214 |
}% |
| 215 |
} |
| 216 |
} |
| 217 |
\endprog |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
\chap Options. |
| 223 |
|
| 224 |
Our options are of the ``keyword-value'' category. We realize them by |
| 225 |
the \pkg{keyvald} package, an enhancement of the \pkg{keyval} package |
| 226 |
from the Graphics bundle that supports defaulting for unknown keys. |
| 227 |
|
| 228 |
\begin{fixme} |
| 229 |
Most of the code below should be extracted and moved to a |
| 230 |
\pkg{keyvalx} package (or a new version of \pkg{keyval}). In |
| 231 |
particular, support for package/class option processing, enumeration |
| 232 |
values, and set values for keyword options. |
| 233 |
\end{fixme} |
| 234 |
|
| 235 |
|\ProcessKeyValOptions| may be used instead of |\ProcessOptions|, it |
| 236 |
takes the keyval set identifier as argument. At the end it evaluates |
| 237 |
and resets a hook. That hook may be used at option definition to |
| 238 |
define further dependencies. (E.g., enabling that option implies |
| 239 |
enabling an other option, too.) |
| 240 |
% |
| 241 |
\begin{fixme} |
| 242 |
Like |\ProcessOptions|, I define |\@curroptions|, since I don't know |
| 243 |
if that's needed later. The only place where it could been needed is |
| 244 |
in the check for unprocessed options. |
| 245 |
\end{fixme} |
| 246 |
|
| 247 |
\beginprog |
| 248 |
\RequirePackage{keyvald} |
| 249 |
|
| 250 |
\let\ProcessKeyValOptionsHook\empty |
| 251 |
\providecommand*\ProcessKeyValOptions[1]{% |
| 252 |
\edef\@curroptions{\@ptionlist{\@currname.\@currext}}% |
| 253 |
\edef\next{\noexpand\setkeys{#1}{\@curroptions}}% |
| 254 |
\next |
| 255 |
\ProcessKeyValOptionsHook |
| 256 |
\let\ProcessKeyValOptionsHook\empty |
| 257 |
} |
| 258 |
\endprog |
| 259 |
|
| 260 |
|
| 261 |
\sect The enumeration option |structure| selects hierarchic~(0) or |
| 262 |
flat~(1) structure. The predefined value is `hierarchic', there is no |
| 263 |
default. The option value is bound to |\cweb@structure|. |
| 264 |
|
| 265 |
\beginprog |
| 266 |
%% \define@key@enum{cweb}{structure}{hierarchic,flat}[hierarchic] |
| 267 |
\@namedef{KV@cweb@structure@enum:hierarchic}{0 } % <-- space! |
| 268 |
\@namedef{KV@cweb@structure@enum:flat}{1 } % <-- space! |
| 269 |
\define@key{cweb}{structure}{% |
| 270 |
\expandafter\let \expandafter\@tempa |
| 271 |
\csname KV@cweb@structure@enum:#1\endcsname % \relax if undefined |
| 272 |
\ifx \@tempa\relax |
| 273 |
\PackageError{cweb}% |
| 274 |
{% |
| 275 |
Invalid value `#1' for option structure% |
| 276 |
}{% |
| 277 |
Possible valid values are `hierarchic' and `flat'.\MessageBreak |
| 278 |
The predefined value is `hierarchic'.\MessageBreak |
| 279 |
There's no default value, you have to specify one.% |
| 280 |
}% |
| 281 |
\else |
| 282 |
\let\cweb@structure\@tempa |
| 283 |
\fi |
| 284 |
} |
| 285 |
\setkeys{cweb}{structure=hierarchic} |
| 286 |
\endprog |
| 287 |
|
| 288 |
|
| 289 |
\sect With the set option |suppress| one can select suppression of |
| 290 |
different document parts: |changehints| suppresses output of hints |
| 291 |
that a changefile was involved, |unchanged| output of unchanged |
| 292 |
chunks, |index| and |reflist| output of index and reference list, and |
| 293 |
|format| output of `|@f|' directives. |
| 294 |
|
| 295 |
The predefined value is no suppression. There is no default value. |
| 296 |
% |
| 297 |
\begin{fixme} |
| 298 |
Shouldn't I supply a default value? `|{index,reflist}|'? |
| 299 |
\end{fixme} |
| 300 |
|
| 301 |
Set options are represented by flags named |
| 302 |
|@cweb@|\<option>|@|\<value>|@|. |
| 303 |
|
| 304 |
\beginprog |
| 305 |
%% \define@key@set{cweb}{suppress}{changehints,unchanged,index,reflist,format} |
| 306 |
\@for \@tempa :=changehints,unchanged,index,reflist,format\do {% |
| 307 |
\expandafter\newif \csname if@cweb@suppress@\@tempa @\endcsname |
| 308 |
\csname @cweb@suppress@\@tempa @false\endcsname |
| 309 |
}% |
| 310 |
\define@key{cweb}{suppress}{% |
| 311 |
\@for \@tempa :=#1\do {% |
| 312 |
\expandafter\let \expandafter\@tempb |
| 313 |
\csname @cweb@suppress@\@tempa @true\endcsname |
| 314 |
%% \relax if undefined |
| 315 |
\ifx \@tempb\relax |
| 316 |
\PackageError{cweb}% |
| 317 |
{% |
| 318 |
Invalid value `#1' for set option suppress% |
| 319 |
}{% |
| 320 |
Possible valid values are `changehints', `unchanged',\MessageBreak |
| 321 |
or a comma-separated list of these words enclosed in braces.\MessageBreak |
| 322 |
Specified values are turned on, you can't turn them off.\MessageBreak |
| 323 |
No value is on initially.\MessageBreak |
| 324 |
There's no default value, you have to specify one.% |
| 325 |
}% |
| 326 |
\else |
| 327 |
\@tempb |
| 328 |
\fi |
| 329 |
}% |
| 330 |
} |
| 331 |
|
| 332 |
\g@addto@macro\ProcessKeyValOptionsHook{% |
| 333 |
\if@cweb@suppress@unchanged@ |
| 334 |
\@cweb@suppress@changehints@true |
| 335 |
\fi |
| 336 |
} |
| 337 |
\endprog |
| 338 |
|
| 339 |
|
| 340 |
\sect The base document class may be specified by the option |
| 341 |
|baseclass|. |
| 342 |
|
| 343 |
\beginprog |
| 344 |
\def\CwebBaseClass{article} |
| 345 |
\define@key{cweb}{baseclass}[report]{\def\CwebBaseClass{#1}} |
| 346 |
\endprog |
| 347 |
|
| 348 |
|
| 349 |
\sect Language-specific adaptions are stored in files |
| 350 |
\texttt{cwbl-{\it language}.sty}. They may be accessed as packages or |
| 351 |
by the |language| option that takes the \textit{language} as value. We |
| 352 |
have to require the respective package at the end of the class, then |
| 353 |
all cseqs with default names are defined and may be overwritten. |
| 354 |
|
| 355 |
For some languages, we provide Babel-compatible option names, to ease |
| 356 |
the usage of global class options taken up by other packages (like |
| 357 |
\pkg{varioref}), too. |
| 358 |
|
| 359 |
\beginprog |
| 360 |
\def\cweb_set_language#1{% |
| 361 |
\IfFileExists{cwbl-#1.sty}{% |
| 362 |
%% true |
| 363 |
\RequirePackage{cwbl-#1}% |
| 364 |
}{% |
| 365 |
%% false |
| 366 |
\ClassError{cweb}{Language `#1' is unknown.}{% |
| 367 |
Language definitions are stored in files `cwbl-<language>.sty'.\MessageBreak |
| 368 |
I could not locate the file `cwbl-#1.sty'. If you didn't make a% |
| 369 |
\MessageBreak |
| 370 |
typo, please check if there is such a file in a directory searched\MessageBreak |
| 371 |
by LaTeX.% |
| 372 |
}% |
| 373 |
}% |
| 374 |
} |
| 375 |
|
| 376 |
\define@key{cweb}{language}{\AtEndOfClass{\cweb_set_language{#1}}} |
| 377 |
|
| 378 |
\define@key{cweb}{german}[]{\setkeys{cweb}{language=german}} |
| 379 |
\define@key{cweb}{french}[]{\setkeys{cweb}{language=french}} |
| 380 |
\define@key{cweb}{italian}[]{\setkeys{cweb}{language=italian}} |
| 381 |
\endprog |
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
\chap Configuration, inheritance, and aggregation. |
| 387 |
|
| 388 |
This chapter sets up access to other modules, therefore we restore the |
| 389 |
original catcodes for the time being. |
| 390 |
|
| 391 |
\beginprog |
| 392 |
\catcode`\_=\CatUsCode |
| 393 |
\endprog |
| 394 |
|
| 395 |
|
| 396 |
\sect As usual, we provide the possibility to configure this class. |
| 397 |
|
| 398 |
\beginprog |
| 399 |
\InputIfFileExists{cweb.cfg}{% |
| 400 |
\typeout{******************************************^^J% |
| 401 |
*^^J% |
| 402 |
* Using local configuration file cweb.cfg^^J% |
| 403 |
*^^J% |
| 404 |
******************************************% |
| 405 |
}% |
| 406 |
}{} |
| 407 |
\endprog |
| 408 |
|
| 409 |
|
| 410 |
\sect Inherit article class. |
| 411 |
|
| 412 |
\beginprog |
| 413 |
\ifx \CwebBaseClass\undefined |
| 414 |
\def\CwebBaseClass{article} |
| 415 |
\fi |
| 416 |
\define@key{cweb}*[]{\PassOptionsToClass{\KV@key}{\CwebBaseClass}} |
| 417 |
\ProcessKeyValOptions{cweb} |
| 418 |
\LoadClass{\CwebBaseClass} |
| 419 |
\endprog |
| 420 |
|
| 421 |
|
| 422 |
\sect OK, now comes our own code; switch on again our lexical |
| 423 |
conventions. |
| 424 |
|
| 425 |
\beginprog |
| 426 |
\catcode`\_=\CatLetter |
| 427 |
\endprog |
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
\chap Typesetting \cweave{} output. |
| 433 |
|
| 434 |
This task has been out-sourced to an other module, \pkg{cwebbase}. As |
| 435 |
mentioned at the start of the implementation, there remain mainly some |
| 436 |
bigger tasks, they will be implemented in further sections below. For |
| 437 |
the most part, the necessary preconditions are actually our class |
| 438 |
option definitions, we don't have to do anything. (Gosh, what a |
| 439 |
coincidence. :--) We need to tell \pkg{cwebbase}, that it should use |
| 440 |
class warnings on problems. |
| 441 |
|
| 442 |
\beginprog |
| 443 |
\let\cweb_warning=\ClassWarningNoLine |
| 444 |
\input{cwebbase} |
| 445 |
\endprog |
| 446 |
|
| 447 |
|
| 448 |
\sect But there remain also some small things to be done right now: |
| 449 |
For flat structure, the counter |secnumdepth| must be set to~11, then |
| 450 |
we want to number chunks in the whole document. |
| 451 |
|
| 452 |
\beginprog |
| 453 |
\ifcase \cweb@structure |
| 454 |
%% hierarchic |
| 455 |
\or |
| 456 |
%% flat |
| 457 |
\setcounter{secnumdepth}{11} |
| 458 |
\fi |
| 459 |
\endprog |
| 460 |
|
| 461 |
|
| 462 |
\sect \pkg{cwebbase} uses |\part|, |\chapter| (if bound), and |
| 463 |
|\section|. We have no use for any other section division that came |
| 464 |
from the base class, let's discard the standard ones. |
| 465 |
|
| 466 |
\beginprog |
| 467 |
\let\subsection\undefined |
| 468 |
\let\subsubsection\undefined |
| 469 |
\let\paragraph\undefined |
| 470 |
\let\subparagraph\undefined |
| 471 |
\endprog |
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
\chap Table of contents. |
| 477 |
|
| 478 |
The table of contents features only sections, chunks don't have |
| 479 |
titles, after all. Titles are indented proportionally to the rank, |
| 480 |
with an basic indentation of |\CwebTocIndent|. An entry on major |
| 481 |
ranks may be differentiated by layout instead of indentation, as it's |
| 482 |
done in standard \LaTeX{} classes, too. |
| 483 |
|
| 484 |
The counter |\CwebTocIndentMaxLevel| constitutes an upper limit for a |
| 485 |
recognized indent (concerning indentation, that is). |
| 486 |
|
| 487 |
\beginprog |
| 488 |
\newdimen\CwebTocIndent |
| 489 |
\CwebTocIndent=1.5em |
| 490 |
\newcount\CwebTocIndentMaxLevel |
| 491 |
\CwebTocIndentMaxLevel=6 % increase indentation if <= max level |
| 492 |
\endprog |
| 493 |
|
| 494 |
|
| 495 |
\sect For hierarchic structure, we can ignore chunk entries |
| 496 |
completely, but have to supply a bunch of definitions for entries of |
| 497 |
type `|section|$l$'. But for flat structure, sections are passed as |
| 498 |
chunks, too. Then the current rank is stored in the title, as |
| 499 |
|\cwbbRank{|$r$|}|. These differences are so large that we'll have |
| 500 |
to make a very large |\ifcase|, over many chunks in this macro source |
| 501 |
file. Let's start with the hierarchic stuff. |
| 502 |
|
| 503 |
\beginprog |
| 504 |
\ifcase \cweb@structure |
| 505 |
%% hierarchic |
| 506 |
\def\l@chunk#1#2{} |
| 507 |
\endprog |
| 508 |
|
| 509 |
|
| 510 |
\sect Let's assume that we're subclassed from one of \LaTeX{}'s |
| 511 |
standard classes; otherwise this stuff must be redefined, too. They |
| 512 |
indent |\section| entries always by the same amount (1.5\,em), our |
| 513 |
layout must fit to that. |
| 514 |
|
| 515 |
If we have chapters, they are also indented by 1.5\,em and |
| 516 |
distinguished by layout. The first minor section starts on rank~3 and |
| 517 |
is placed on level~2, it should be indented larger. Let's simply add |
| 518 |
1.5\,em for each rank, that makes 3\,em for sections of type |
| 519 |
|section2|. I.e., we use $f=l$ as a factor for our basic indentation. |
| 520 |
|
| 521 |
If we don't have chapters, the first minor section starts on rank~2 |
| 522 |
and is placed also on level~2, it should be indented like sections |
| 523 |
(1.5\,em), as it will be in another layout. I.e., we use $f=l-1$ as |
| 524 |
the indentation factor. |
| 525 |
|
| 526 |
The actual definitions are generated in a loop. `|\l@section|$l$' |
| 527 |
expands to `|\cweb@toc_entry{|$l$|}|'. The indentation will be |
| 528 |
computed within that macro. |
| 529 |
|
| 530 |
\beginprog |
| 531 |
\count@=2 |
| 532 |
\@whilenum \count@<11 \do { |
| 533 |
\expandafter\edef \csname l@section\number\count@\endcsname{% |
| 534 |
\noexpand\cweb@toc_entry{\number\count@}% |
| 535 |
} |
| 536 |
\advance \count@ by 1 |
| 537 |
} |
| 538 |
\endprog |
| 539 |
|
| 540 |
|
| 541 |
\sect A toc entry may be produced by |\@dottedtocline|. That cseq |
| 542 |
needs the level (to decide if that entry is produced after all), the |
| 543 |
entry indentation, the inner-entry indentation used for the number, |
| 544 |
entry text, and page number. |
| 545 |
|
| 546 |
As explained above, we use an indentation of $f \cdot |
| 547 |
|\CwebTocIndent|$, if the level is not larger than |
| 548 |
|\CwebTocIndentMaxLevel|. Otherwise we use the indentation of that |
| 549 |
level. |
| 550 |
|
| 551 |
Each entry is kind of an item with the number as the label. We need an |
| 552 |
inner-entry indentation to be used for subsequent lines within this |
| 553 |
entry. If a number is specified, it's tagged by |\numberline| in the |
| 554 |
entry text. With a proper local definition and a pro-forma evaluation |
| 555 |
of the text, we get at the width of the number (with a fitting space |
| 556 |
for separation to text) and can use that as the inner-entry |
| 557 |
indentation. |
| 558 |
|
| 559 |
\beginprog |
| 560 |
\def\cweb@toc_entry#1#2{% % #3 (page) will follow |
| 561 |
%% \count@ == factor for basic indentation |
| 562 |
%% min(#1,TocIndentMaxRank) - correct_level |
| 563 |
\ifnum #1>\CwebTocIndentMaxLevel |
| 564 |
\count@\CwebTocIndentMaxLevel |
| 565 |
\else |
| 566 |
\count@ #1 % <-- space! |
| 567 |
\fi |
| 568 |
\ifx \chapter\undefined |
| 569 |
\advance \count@\m@ne |
| 570 |
\fi |
| 571 |
%% \dimen@ == inner-entry indentation |
| 572 |
%% width of number & space, if existing |
| 573 |
\begingroup |
| 574 |
\global\dimen@ \z@ % assert value |
| 575 |
\def\numberline##1{\settowidth{\global\dimen@}{##1\enskip}}% |
| 576 |
\setbox\z@ \hbox{#2}% % evaluates \numberline if specified |
| 577 |
\endgroup |
| 578 |
\@dottedtocline |
| 579 |
{#1}% % level |
| 580 |
{\count@ \CwebTocIndent}% % basic indent |
| 581 |
\dimen@ % num width |
| 582 |
{#2}% % entry; page will follow |
| 583 |
} |
| 584 |
\endprog |
| 585 |
|
| 586 |
|
| 587 |
\sect We're done with toc configuration for hierarchic structure, |
| 588 |
since entry definitions for |chapter| and |section| types exist |
| 589 |
already. Let's turn over to the flat structure. |
| 590 |
|
| 591 |
\beginprog |
| 592 |
\or |
| 593 |
%% flat |
| 594 |
\endprog |
| 595 |
|
| 596 |
|
| 597 |
\sect The section rank determines how they are featured in the table. |
| 598 |
Titles on rank~0 are typeset boldface, other titles are dotted |
| 599 |
contents lines in roman. |
| 600 |
|
| 601 |
The rank is specified within the title, i.e., in the |
| 602 |
first argument to |\l@chunk|, as an argument for the |\cwbbRank| tag. |
| 603 |
With an appropriate definition we might set |\count@| to the |
| 604 |
respective value. If it is not set, an explicite invocation of |
| 605 |
|\section| or |\addcontentsline| is responsible for this entry. Then |
| 606 |
we assume that the rank is~0. |
| 607 |
|
| 608 |
\beginprog |
| 609 |
\def\l@chunk#1{% % page will be processed later |
| 610 |
\count@\@ne % default value of group level |
| 611 |
\begingroup |
| 612 |
\let\numberline\@gobble % width not known yet |
| 613 |
\def\cwbbRank##1{\global\count@ ##1\relax}% |
| 614 |
\setbox\z@ \hbox{#1}% |
| 615 |
\endgroup |
| 616 |
\ifnum \count@=\z@ |
| 617 |
\let\next\cweb@bold_toc_line |
| 618 |
\else |
| 619 |
\let\next\cweb@normal_toc_line |
| 620 |
\fi |
| 621 |
\next{#1}% |
| 622 |
} |
| 623 |
\endprog |
| 624 |
|
| 625 |
|
| 626 |
\sect A boldface line is typeset similar to the definition of |
| 627 |
|\@dottedtocline|, only with fewer parameters. It takes two |
| 628 |
parameters, the entry and the page number. |
| 629 |
|
| 630 |
\beginprog |
| 631 |
\def\cweb@bold_toc_line#1#2{% |
| 632 |
\addpenalty{\@secpenalty}% |
| 633 |
\addvspace{1em plus\p@}% |
| 634 |
\begingroup |
| 635 |
\noindent \bf |
| 636 |
\hangindent\CwebTocIndent |
| 637 |
\rightskip\@tocrmarg \parfillskip -\rightskip |
| 638 |
\interlinepenalty\@M |
| 639 |
\@tempdima\CwebTocIndent % for \numberline |
| 640 |
#1\nobreak\hfill \hbox to\@pnumwidth{\hss #2}% |
| 641 |
\par |
| 642 |
\endgroup |
| 643 |
} |
| 644 |
\endprog |
| 645 |
|
| 646 |
|
| 647 |
\sect A normal line uses |\@dottedtocline| like the hierarchic stuff. |
| 648 |
Rank~1 shall still be on the same level as the bold toc line, so we |
| 649 |
have to use $r-1$ as the proportional factor for |\CwebTocIndent|. |
| 650 |
|
| 651 |
\beginprog |
| 652 |
\def\cweb@normal_toc_line#1{% % page will be processed later |
| 653 |
\edef\next{\noexpand\@dottedtocline{\the\count@}}% % toc entry level |
| 654 |
\ifnum \count@>\CwebTocIndentMaxLevel |
| 655 |
\count@ \CwebTocIndentMaxLevel |
| 656 |
\fi |
| 657 |
\advance\count@\m@ne % group level -= 1 |
| 658 |
\next{\count@\CwebTocIndent}% % basic indent |
| 659 |
\CwebTocIndent % numwidth |
| 660 |
{#1}% % entry |
| 661 |
} |
| 662 |
\endprog |
| 663 |
|
| 664 |
|
| 665 |
\sect The first argument of |\@dottedtocline| is used to specify a |
| 666 |
depth of the issued entry. All entries with a depth larger than |
| 667 |
|tocdepth| are discarded. We typeset all entries, our |tocdepth| |
| 668 |
value is the largest possible section level. |
| 669 |
|
| 670 |
\beginprog |
| 671 |
\setcounter{tocdepth}{10} |
| 672 |
\endprog |
| 673 |
|
| 674 |
|
| 675 |
\sect That's it. Close our distinction between hierarchic and flat |
| 676 |
structure. |
| 677 |
|
| 678 |
\beginprog |
| 679 |
\fi |
| 680 |
\endprog |
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
\chap The end of the document. |
| 686 |
|
| 687 |
The end of a \cweave{} document is a rather complicated thing. It is |
| 688 |
described in detail in the \cweave{} interface specification, we repeat the |
| 689 |
most important points shortly. |
| 690 |
% |
| 691 |
\begin{itemize} |
| 692 |
|
| 693 |
\item The user has issued an |\end{document}| tag in the documentation |
| 694 |
part of the last chunk. |
| 695 |
|
| 696 |
This tag is therefore part of a chunk, the chunk end (i.e., the |
| 697 |
|\fi| cseq) does appear later in the document. Particularly, this |
| 698 |
means that at the accurence of this tag there is still an open |\if|. |
| 699 |
|
| 700 |
\item Between the |\end{document}| and the |\fi| a lot of text may |
| 701 |
come which must be ignored. Within this text no |\fi| is allowed. |
| 702 |
|
| 703 |
\item After the |\fi| the document may be finished by |\end|. |
| 704 |
(Then the |-x| option of \cweave{} was used.) |
| 705 |
|
| 706 |
Or additional information about the whole document is added: An |
| 707 |
optional tag |\ch|, two mandatory tags |\inx\fin|, and another |
| 708 |
optional tag |\con|. |
| 709 |
|
| 710 |
\end{itemize} |
| 711 |
|
| 712 |
Btw, the last chunk is marked as changed if any changefile entry has |
| 713 |
been applied in the document. (In Plain \cweb{} that chunk is |
| 714 |
colloquially used as the introduction to the index, and that shall be |
| 715 |
printed always.) If we suppress unchanged chunks, the last |
| 716 |
chunk will therefore always be processed, independent if it was really |
| 717 |
changed or not. Yet another reason to use a whole chunk just for |
| 718 |
|\end{document}|. |
| 719 |
|
| 720 |
We'll use a the following approach for the implementation of the |
| 721 |
iidentifier index and the refinement list (remember that we do not |
| 722 |
produce a table of contents): We will check if there is any of these |
| 723 |
two lists available. The available ones are typeset. Then we'll |
| 724 |
finish the document. This functionality will be bound to |\fin|. |
| 725 |
|\inx| will be simply a no-op. |\con| will never be reached, so we |
| 726 |
don't have to cope with it. |
| 727 |
|
| 728 |
|
| 729 |
\sect With the introduction of an end-document hook in \LaTeXe{}, one |
| 730 |
might have hoped that we can utilize that hook for our task. But this |
| 731 |
is not possible: We don't want to add some additional actions |
| 732 |
\emph{into} the end-document handling, we want to look ahead and issue |
| 733 |
lots of commands \emph{before} the end-document handling has happened. |
| 734 |
(If you know \TeX{} by heart, you may skip the rest of the explanation |
| 735 |
and go to the next chunk.) |
| 736 |
|
| 737 |
As a macro language, \TeX{}'s cseqs take those tokens as arguments |
| 738 |
that are behind them in the token stream. The token stream is |
| 739 |
initially the document source, evaluation of a macro pushes its |
| 740 |
expansion (a token list) on front of the stream. I.e., the evaluation |
| 741 |
of |\end| will push the expansion on the token stream before |
| 742 |
|\enddocument| is even looked at. And |\enddocument| will also push |
| 743 |
its expansion before the hook is evaluated. |
| 744 |
|
| 745 |
If we would allow |\enddocument| to push its expansion, all these |
| 746 |
tokens have to be evaluated after we have typeset the backmatter -- |
| 747 |
after all, we need a proper document end, don't we? One would need to |
| 748 |
skip over them, look at and eventually evaluate tokens that come |
| 749 |
behind (from the initial document stream, the document source), and |
| 750 |
then evaluate the skipped tokens. That's too hairy, we don't know |
| 751 |
exactly how many tokens to skip, this is probable to change in future |
| 752 |
\LaTeX{} revisions, etc. |
| 753 |
|
| 754 |
The pushed tokens from |\end| don't pose so much problems. As |
| 755 |
|\enddocument| will terminate the document processing, they are not |
| 756 |
evaluated anyhow, we can just throw them away. And |\end| has changed |
| 757 |
only once in the last few years, so it seems to be a stable macro -- |
| 758 |
necessary as we need to know its expansion for propper skipping. |
| 759 |
|
| 760 |
A very first consequence of the demand to process tokens after |
| 761 |
|\end{document}| is that we have to save the ``standard'' \LaTeX{} |
| 762 |
document termination, since we will execute that later. |
| 763 |
|
| 764 |
\beginprog |
| 765 |
\let\cweb@save@enddocument=\enddocument |
| 766 |
\endprog |
| 767 |
|
| 768 |
|
| 769 |
\sect When we encounter |\end{document}| we have to skip tokens |
| 770 |
until we reach a |\fi|. Then we establish the correct |
| 771 |
environment for the material behind. |
| 772 |
|
| 773 |
The skip itself is actually a bit difficil, so we'll look at it more |
| 774 |
closely. |\enddocument| is executed within |\end|. As mentioned above, |
| 775 |
the original |
| 776 |
definition of |\enddocument| cheats, it terminates \LaTeX{} before |
| 777 |
the rest of |\end| is executed. |\end| first checks if we're in |
| 778 |
the correct current environment, then it establishs the end |
| 779 |
processing for paragraph building environments, closes the |
| 780 |
group---each environment is in its own group, executes the end |
| 781 |
processing established before, and it may ignore following white |
| 782 |
space. |
| 783 |
|
| 784 |
The |document| pseudo-environment is different in that it isn't in a |
| 785 |
group. I.e., we have to open a group which can be closed by |\end| |
| 786 |
afterwards. The environment check will be done in this group. With |
| 787 |
|\aftergroup| we establish a macro which will skip the rest of the |
| 788 |
|\end| processing. This processing is not needed anyhow: |document| |
| 789 |
is no paragraph building environment and the following white space is |
| 790 |
ignored by ourselves. Since |document| is no paragraph building |
| 791 |
environment, the end processing described above is empty, i.e., not |
| 792 |
existant. Then come a few tokens which ignore the white space. One of |
| 793 |
these tokens is a |\fi|, so we have to skip them first separately. |
| 794 |
They are discarded by |\cweb@skip_end|, we can start to look |
| 795 |
for our |\fi| afterwards. |
| 796 |
|
| 797 |
If |\end{document}| is the first (i.e., the only) text in this chunk |
| 798 |
we discard the chunk start marker. This is possible since it isn't set |
| 799 |
until now, it's in the |\everypar| token register. Of course, then we |
| 800 |
have to do the house keeping work stored in |\everypar| ourselves. |
| 801 |
|
| 802 |
\beginprog |
| 803 |
\def\enddocument{% |
| 804 |
\if@noskipsec |
| 805 |
\global\everypar{}% |
| 806 |
\global\@noskipsecfalse |
| 807 |
\global\@nobreakfalse |
| 808 |
\global\clubpenalty\@clubpenalty |
| 809 |
\fi |
| 810 |
\begingroup |
| 811 |
\aftergroup\cweb@skip_end |
| 812 |
} |
| 813 |
\endprog |
| 814 |
|
| 815 |
|
| 816 |
\sect Let's make sure that the expansion of |\end| is the one that we |
| 817 |
expect. Then we can define |\cweb@skip_end| appropriately, we have to |
| 818 |
skip 5~tokens. |
| 819 |
|
| 820 |
\beginprog |
| 821 |
\CheckCommand*\end[1]{% |
| 822 |
\csname end#1\endcsname\@checkend{#1}% |
| 823 |
\expandafter\endgroup\if@endpe\@doendpe\fi |
| 824 |
% 1 2 3 4 5 |
| 825 |
\if@ignore\global\@ignorefalse\ignorespaces\fi} |
| 826 |
|
| 827 |
\def\cweb@skip_end#1#2#3#4#5{\cweb@check_fi} |
| 828 |
\endprog |
| 829 |
|
| 830 |
|
| 831 |
\sect |\cweb@check_fi| gets the next token, and invokes |
| 832 |
|\cweb@do_check_fi| who really checks it. If this token is |\fi| we |
| 833 |
can prepare to finish our document. Otherwise we have to check the |
| 834 |
next token. |
| 835 |
|
| 836 |
Of course, first the token we have checked already must be discarded. |
| 837 |
Therefore we insert the followup action by |\afterassignment|. It's |
| 838 |
important that the assignment gets \emph{only} the next token, we |
| 839 |
have to supply both the equals sign and the optional blank which are |
| 840 |
allowed between the both arguments to |\let|. |
| 841 |
|
| 842 |
\beginprog |
| 843 |
\def\cweb@check_fi{% |
| 844 |
\futurelet\next \cweb@do_check_fi |
| 845 |
} |
| 846 |
\def\cweb@do_check_fi{% |
| 847 |
\ifx \next\fi |
| 848 |
\afterassignment\cweb@finish |
| 849 |
\else |
| 850 |
\afterassignment\cweb@check_fi |
| 851 |
\fi |
| 852 |
\let\next= % <-- blank!! |
| 853 |
} |
| 854 |
\endprog |
| 855 |
|
| 856 |
|
| 857 |
\sect When we found the |\fi|, we also discard it. But we're still |
| 858 |
within a chunk, i.e., there is an open |\if|. So we must supply the |
| 859 |
|\fi|. |
| 860 |
|
| 861 |
\TeX{}nical note: |\next| is now equivalent to |\fi|. It must not be |
| 862 |
used within a loop where it denotes the tail recursion's action. I.e., |
| 863 |
code like |
| 864 |
% |
| 865 |
\begin{verbatim} |
| 866 |
\ifx \foo\bar |
| 867 |
\let\next\relax |
| 868 |
\else |
| 869 |
\let\next\continue |
| 870 |
\fi |
| 871 |
\next |
| 872 |
\end{verbatim} |
| 873 |
% |
| 874 |
will fail. This trap is closed by a redefinition of |\next|. |
| 875 |
|
| 876 |
The output of all following lists may be suppressed by some option. |
| 877 |
That is tested at the place where the respective list shall be |
| 878 |
produced. |
| 879 |
|
| 880 |
All following lists are typeset in CR state. |
| 881 |
|
| 882 |
\beginprog |
| 883 |
\def\cweb@finish{% |
| 884 |
\fi |
| 885 |
\let\next\relax |
| 886 |
\let\ch\cweb@changed_list |
| 887 |
\let\inx\relax |
| 888 |
\let\fin\cweb@end_document |
| 889 |
\let\end\cweb@save@enddocument |
| 890 |
\cwbb@CR |
| 891 |
} |
| 892 |
\endprog |
| 893 |
|
| 894 |
|
| 895 |
\sect The following lists are started with unnumbered section |
| 896 |
divisions. They are either chapters or sections. |
| 897 |
|
| 898 |
\beginprog |
| 899 |
\ifx \chapter\undefined |
| 900 |
\let\CwebListSectionDiv=\section |
| 901 |
\else |
| 902 |
\let\CwebListSectionDiv=\chapter |
| 903 |
\fi |
| 904 |
\def\CwebListSection{\CwebListSectionDiv*} |
| 905 |
\endprog |
| 906 |
|
| 907 |
|
| 908 |
\sect The list of changed chunks is a cross reference list, (nearly) |
| 909 |
like all others at the end of a chunk. The only difference is that |
| 910 |
we do not show changeflags any more---each chunk number in this list |
| 911 |
carries a change flag by definition. |
| 912 |
|
| 913 |
\TeX{}nical note: The redefinition of |\*| is part of the second |
| 914 |
argument of |\CwebCrossRef|. It is \emph{not} a global redefinition. |
| 915 |
|
| 916 |
\beginprog |
| 917 |
\def\CwebCRChanged{% |
| 918 |
\CwebCrossRef{The following chunks were changed by the change file:}% |
| 919 |
} |
| 920 |
\def\CwebChangedListName{Changed Chunks} |
| 921 |
|
| 922 |
\if@cweb@suppress@changehints@ |
| 923 |
\def\cweb@changed_list#1.{} |
| 924 |
\else |
| 925 |
\def\cweb@changed_list{% |
| 926 |
\CwebListSection{\CwebChangedListName}% |
| 927 |
\@mkboth{\uppercase{\CwebChangedListName}}% |
| 928 |
{\uppercase{\CwebChangedListName}}% |
| 929 |
\message{\CwebChangedListName}% |
| 930 |
\let\CwebCRSize\relax |
| 931 |
\CwebCRChanged \let\*\relax |
| 932 |
} |
| 933 |
\fi |
| 934 |
\endprog |
| 935 |
|
| 936 |
|
| 937 |
\sect As outlined above, we want to check if there are any entries in |
| 938 |
the identifier index or the refinement list. The former is stored in |
| 939 |
the file |\jobname.idx|, the latter in the file |\jobname.scn|. |
| 940 |
|
| 941 |
We write a macro |\cweb@if_file_not_empty| that's like |\IfFileExists|. |
| 942 |
|
| 943 |
\beginprog |
| 944 |
\def\cweb@end_document{% |
| 945 |
\cweb@if_file_not_empty{\jobname.idx}{% |
| 946 |
\if@cweb@suppress@index@ \else |
| 947 |
\CwebIdIndex |
| 948 |
\fi |
| 949 |
}{}% |
| 950 |
\cweb@if_file_not_empty{\jobname.scn}{% |
| 951 |
\if@cweb@suppress@reflist@ \else |
| 952 |
\CwebRefList |
| 953 |
\fi |
| 954 |
}{}% |
| 955 |
\cweb@save@enddocument |
| 956 |
} |
| 957 |
\endprog |
| 958 |
|
| 959 |
|
| 960 |
\sect The paragraph layout for both the index and the refinement list |
| 961 |
is much the same, it is taken from Plain \cweb{}: Each entry is a |
| 962 |
paragraph, nearly no skip between the paragraphs (just a bit to |
| 963 |
prevent underfull vboxes), no paragraph indentation, ragged right. |
| 964 |
Overfull hboxes in the lists don't make sense, so we prevent them. And |
| 965 |
we don't allow hyphenation. |
| 966 |
|
| 967 |
\beginprog |
| 968 |
\def\cweb@list_par_layout{% |
| 969 |
\parskip \z@ plus .5\p@ |
| 970 |
\parindent\z@ |
| 971 |
\rightskip \z@ plus 2.5em |
| 972 |
\tolerance\@M \hyphenpenalty\@M |
| 973 |
} |
| 974 |
\endprog |
| 975 |
|
| 976 |
|
| 977 |
\sect We consider a file as ``not empty'' if (1)~the file exists, |
| 978 |
(2)~is not empty, and (3)~has a non-empty line at the very front. (In |
| 979 |
fact, an empty line at the front means that there should not be |
| 980 |
anything behind it---but we can't test this portably.) |
| 981 |
|
| 982 |
|\cweb@if_file_not_empty| tests the property, it's parametrized by the |
| 983 |
file name and gets passed actions for the true and the false case. |
| 984 |
|
| 985 |
We open the file first. Then we check if it doesn't exist or if it's |
| 986 |
empty, both conditions deliver true on |\ifeof|; in this case we |
| 987 |
pretend that there was an empty line. (The \LaTeX{} kernel already |
| 988 |
once provided a macro for an empty line, |\@defpar|, we repeat that |
| 989 |
definition here since it was discarded there.) Otherwise we read the |
| 990 |
first line. At this state, the emptiness of the first line is |
| 991 |
equivalent to the non-availability of entries, we can easily construct |
| 992 |
an appropriate macro call to set the flag. |
| 993 |
|
| 994 |
\beginprog |
| 995 |
\def\@defpar{\par} |
| 996 |
\def\cweb@if_file_not_empty#1#2#3{% |
| 997 |
\openin\@inputcheck #1\relax |
| 998 |
\ifeof \@inputcheck |
| 999 |
\let\next\@defpar |
| 1000 |
\else |
| 1001 |
\read\@inputcheck to \next |
| 1002 |
\fi |
| 1003 |
\closein\@inputcheck |
| 1004 |
\ifx \next\@defpar |
| 1005 |
\def\reserved@a{#3}% |
| 1006 |
\else |
| 1007 |
\def\reserved@a{#2}% |
| 1008 |
\fi |
| 1009 |
\reserved@a |
| 1010 |
} |
| 1011 |
\endprog |
| 1012 |
|
| 1013 |
|
| 1014 |
\sect The identifier index is available in the file |\jobname.idx|. |
| 1015 |
The setup for the index is a mixture of the |theindex| environment of |
| 1016 |
the \cls{article} class and DEK's index macros. It's typeset in two |
| 1017 |
columns; the user may specify an introductionary text for the index |
| 1018 |
by |\cwebIndexIntro|. If there is any introductionary text we add a |
| 1019 |
medium skip below. |
| 1020 |
|
| 1021 |
For the index, |\parfillskip| set in such a way that almost empty |
| 1022 |
lines are avoided. |
| 1023 |
|
| 1024 |
Before we read in this file, we have to bind the special cseqs used |
| 1025 |
therein. |
| 1026 |
|
| 1027 |
\begin{fixme} |
| 1028 |
\LaTeX{} feature or bug? The optional argument of |\twocolumn| is |
| 1029 |
typeset as a vbox, therefore the space at top of the section heading |
| 1030 |
is not discarded at the top of a page. But we know that |\twocolumn| |
| 1031 |
will start a page in any case, we must prevent the addition of this |
| 1032 |
space. Looking in the source, we see that setting the flag |
| 1033 |
|@nobreak| will prevent this addition, let's do that as a |
| 1034 |
workaround. File a \LaTeX{} bug report? |
| 1035 |
\end{fixme} |
| 1036 |
|
| 1037 |
\begin{fixme} |
| 1038 |
Surprise: If |@nobreak| is set \emph{and} if there are no index |
| 1039 |
entries, |\twocolumn| will drop its optional argument. (That |
| 1040 |
happened to be noticed when there was an error in |
| 1041 |
|\cweb@if_file_not_empty|.) File a \LaTeX{} bug report? |
| 1042 |
\end{fixme} |
| 1043 |
|
| 1044 |
\begin{fixme} |
| 1045 |
If |\CwebListSection| is a chapter tag of the standard classes, that |
| 1046 |
macro will check if it's in twocolumn mode and will try to set |
| 1047 |
itself at the top of the current page in full width, as it would |
| 1048 |
have been given in an optional argument of |\twocolumn|. As the |
| 1049 |
method that optional argument uses (a float) must not be nested, we |
| 1050 |
must prevent this to happen. We set the |@twocolumn| flag to false, |
| 1051 |
chapter macros will then think they're evaluated in a one-column |
| 1052 |
document. It's debatable if that is a kludge or even \emph{the} |
| 1053 |
solution -- after all, within the optional argument we aren't in |
| 1054 |
twocolumn mode any more. File a \LaTeX{} bug report? |
| 1055 |
\end{fixme} |
| 1056 |
|
| 1057 |
\beginprog |
| 1058 |
\newtoks\cwebIndexIntro |
| 1059 |
\cwebIndexIntro={} |
| 1060 |
\def\CwebIdIndex{% |
| 1061 |
%% two column format |
| 1062 |
\columnseprule\z@ |
| 1063 |
\columnsep 35\p@ % value is from article.sty |
| 1064 |
%% introduction of index |
| 1065 |
\twocolumn[% |
| 1066 |
\cwbb@tex |
| 1067 |
\@nobreaktrue % don't add space in front of section |
| 1068 |
\@twocolumnfalse % \CwebListSection might be \chapter |
| 1069 |
\CwebListSection{\indexname}% |
| 1070 |
\edef\intro{\the\cwebIndexIntro}% % is a local def |
| 1071 |
\ifx \intro\empty |
| 1072 |
\else |
| 1073 |
\the\cwebIndexIntro\unskip |
| 1074 |
\par\medskip |
| 1075 |
\fi |
| 1076 |
]% |
| 1077 |
\@mkboth{\uppercase{\indexname}}{\uppercase{\indexname}}% |
| 1078 |
\message{\indexname:}% % tell the user what we're doing |
| 1079 |
%% paragraph layout |
| 1080 |
\cweb@list_par_layout |
| 1081 |
\parfillskip \z@ plus .6\hsize |
| 1082 |
%% bindings |
| 1083 |
\let\I\CwebIndexEntry |
| 1084 |
\let\[\CwebIndexDeclared |
| 1085 |
\let\*\cwbb@change_flag |
| 1086 |
%% read the index |
| 1087 |
\CwebReadIndex |
| 1088 |
} |
| 1089 |
\def\CwebReadIndex{\@input{\jobname.idx}} |
| 1090 |
\endprog |
| 1091 |
|
| 1092 |
|
| 1093 |
\sect An index entry is typeset with the same hanging indentation like |
| 1094 |
a cross reference list. |
| 1095 |
|
| 1096 |
The entry is tagged with |\.|, if it was entered by the \cweb{} |
| 1097 |
operator~`|@.|'. Then it shall be typeset as a string. But an indexed |
| 1098 |
name may also want to use |\.| as an accent. This is the same |
| 1099 |
situation as we had at the refinement names (in module |
| 1100 |
\pkg{cwebbase}), where we introduced |\cwbb@check_dot| to handle this |
| 1101 |
case. The same minor restriction as there holds here, a refinement |
| 1102 |
name may not consist of a single dot-accented expression. (|@:|~helps |
| 1103 |
in this singular case.) |
| 1104 |
|
| 1105 |
\beginprog |
| 1106 |
\def\CwebIndexEntry#1, {% |
| 1107 |
\par |
| 1108 |
\hangindent\CwebNumberListHangindent |
| 1109 |
\leavevmode |
| 1110 |
\cwbb@check_dot{#1}:\quad |
| 1111 |
} |
| 1112 |
\endprog |
| 1113 |
|
| 1114 |
|
| 1115 |
\sect The chunks where identifiers are declared are noted with |
| 1116 |
underlined numbers. We also must not forget the default declaration of |
| 1117 |
|\9|, the tag for the user definable index layout. |
| 1118 |
|
| 1119 |
\beginprog |
| 1120 |
\def\CwebIndexDeclared#1]{$\underline{#1}$} |
| 1121 |
\def\9#1{} |
| 1122 |
\endprog |
| 1123 |
|
| 1124 |
|
| 1125 |
\sect The list of the refinement names is available in the file |
| 1126 |
|\jobname.scn|. The layout is taken from the plain version: ragged |
| 1127 |
right, each entry is a paragraph, the different cross reference |
| 1128 |
categories are separated by a quad. |
| 1129 |
|
| 1130 |
We must initialize our whole paragraph layout, as the index might have |
| 1131 |
been suppressed and no initialization has happened there then. If |
| 1132 |
there was an index, it changed |\parfillskip| and |\*|, let's restore it. |
| 1133 |
|
| 1134 |
\beginprog |
| 1135 |
\def\CwebRefListName{List of Refinements} |
| 1136 |
|
| 1137 |
\def\CwebRefList{% |
| 1138 |
%% paragraph layout: like in index, but |
| 1139 |
\onecolumn |
| 1140 |
\cweb@list_par_layout |
| 1141 |
\parfillskip\@flushglue % must be reset before section heading |
| 1142 |
\CwebListSection{\CwebRefListName}% |
| 1143 |
\@mkboth{\uppercase{\CwebRefListName}}% |
| 1144 |
{\uppercase{\CwebRefListName}}% |
| 1145 |
\message{\CwebRefListName:}% |
| 1146 |
%% different bindings |
| 1147 |
\def\I{\par \hangindent\CwebNumberListHangindent}% |
| 1148 |
\def\CwebCrossRef##1##2.{\quad {\reset@font\footnotesize ##1~##2.}}% |
| 1149 |
\let\Q\CwebXRCite |
| 1150 |
\let\Qs\CwebXRCites |
| 1151 |
\let\U\CwebXRUse |
| 1152 |
\let\Us\CwebXRUses |
| 1153 |
\let\*\cwbb@change_flag |
| 1154 |
%% Read the list, allow configuration first. |
| 1155 |
\csname CwebRefListHook\endcsname |
| 1156 |
\CwebReadPPList |
| 1157 |
} |
| 1158 |
\def\CwebReadPPList{\@input{\jobname.scn}} |
| 1159 |
\endprog |
| 1160 |
|
| 1161 |
|
| 1162 |
\sect Extra definitions for the sake of internationalization. |
| 1163 |
|
| 1164 |
\beginprog |
| 1165 |
\def\CwebXRCite{\CwebCrossRef{Cited in chunk}} |
| 1166 |
\def\CwebXRCites{\CwebCrossRef{Cited in chunks}} |
| 1167 |
\def\CwebXRUse{\CwebCrossRef{Used in chunk}} |
| 1168 |
\def\CwebXRUses{\CwebCrossRef{Used in chunks}} |
| 1169 |
\endprog |
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
\chap The end. |
| 1174 |
|
| 1175 |
Well, after all we're finished with this class. We must not forget to |
| 1176 |
restore the underscore catcode. |
| 1177 |
|
| 1178 |
\beginprog |
| 1179 |
\catcode`\_=\CatUsCode |
| 1180 |
|
| 1181 |
\endinput |
| 1182 |
\endprog |
| 1183 |
|
| 1184 |
|
| 1185 |
\sect I would like to thank those who helped me to improve this module. |
| 1186 |
% In particular, XXX provided XXXsubstantial parts of the code. |
| 1187 |
|
| 1188 |
\textsc{Michael M\"uller} and \textsc{Zden\v{e}k Wagner} did thorough |
| 1189 |
checks that helped me to improve the alpha test version. |
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1194 |
|
| 1195 |
\vskip \PltxPreSectSkip |
| 1196 |
|
| 1197 |
\begin{rcslog} |
| 1198 |
$StyleLog: cweb.doc,v $ |
| 1199 |
\Revision 3.6 1995/11/30 15:44:53 schrod |
| 1200 |
Still didn't work with version \mbox{$\langle$1994/12/01$\rangle$}, |
| 1201 |
the copy of |\newif| was not complete.\\ |
| 1202 |
Problem reported by Michael Seel \path|<[email protected]>|. |
| 1203 |
|
| 1204 |
\Revision 3.5 1995/11/20 22:34:18 schrod |
| 1205 |
Add language support.\\ |
| 1206 |
Triggered by Christian Kumpf \path|<[email protected]>| and Andreas |
| 1207 |
Scherer \path|<[email protected]>|. |
| 1208 |
|
| 1209 |
Use my `official' (ACM) email address. |
| 1210 |
|
| 1211 |
\Revision 3.4 1995/11/07 17:55:18 schrod |
| 1212 |
\LaTeX{} \cweb{} should work at least with the last two \LaTeX{} |
| 1213 |
versions; make it work with the previous-to-last one, version |
| 1214 |
\mbox{$\langle$1994/12/01$\rangle$}. For that, one has to install the |
| 1215 |
\mbox{$\langle$1995/06/01$\rangle$} (non-outer) definition of |
| 1216 |
|\newif|, and |\hb@xt@| must not be used.\\ |
| 1217 |
Problem reported by Laurent Desnogues |
| 1218 |
\path|<[email protected]>| and somebody else (XXX |
| 1219 |
-- add name). |
| 1220 |
|
| 1221 |
\Revision 3.3 1995/09/17 14:15:36 schrod |
| 1222 |
Initialize list paragraph layout in refinement list, too. With the |
| 1223 |
introduction of index suppression, the initialization -- located in |
| 1224 |
the index code -- might have been skipped. |
| 1225 |
|
| 1226 |
\Revision 3.2 1995/09/15 10:22:59 schrod |
| 1227 |
The \cls{cweb} class needs at least \LaTeX{} version |
| 1228 |
\mbox{$\langle$1994/12/01$\rangle$}.\\ |
| 1229 |
Problem reported by John S. Robinson \path|[email protected]|. |
| 1230 |
|
| 1231 |
\Revision 3.1 1995/09/12 23:00:48 schrod |
| 1232 |
Moved all code that does the actual typesetting of \cweave{} tags and |
| 1233 |
is therefore also needed for a |cweb| environment. It's now an own |
| 1234 |
module named \pkg{cwebbase}. |
| 1235 |
|
| 1236 |
\Revision 2.8 1995/09/12 11:44:33 schrod |
| 1237 |
Standard base classes with chapters (i.e., report \& book) produced an |
| 1238 |
error at the start of the index: |\chapter| may not be called in the |
| 1239 |
optional argument of |\twocolumn|. Add a workaround to |\twocolumn|.\\ |
| 1240 |
Problem reported by Christopher Higgins \path|<[email protected]>|. |
| 1241 |
|
| 1242 |
\Revision 2.7 1995/08/29 17:32:36 schrod |
| 1243 |
Add hook for refinement list. |
| 1244 |
|
| 1245 |
Allow internationalization of refinement list.\\ |
| 1246 |
(Problem reported by Christian Kumpf \path|<[email protected]>|.) |
| 1247 |
|
| 1248 |
Cweb bundle, version 1.0. |
| 1249 |
|
| 1250 |
\Revision 2.6 1995/08/29 15:19:50 schrod |
| 1251 |
Added (hint to non-existence of) description of the internal interface. |
| 1252 |
|
| 1253 |
\Revision 2.5 1995/08/29 02:07:26 schrod |
| 1254 |
Discard dependencies on 10\,pt fonts. |
| 1255 |
|
| 1256 |
Support suppression of format directives. |
| 1257 |
|
| 1258 |
\Revision 2.4 1995/08/27 19:31:43 schrod |
| 1259 |
Discard superfluous space at the top of index. Spacing in refinement |
| 1260 |
heading was wrong. Repair test on empty auxilliary files. Make |
| 1261 |
section heading for index and refinement list divisions (more) |
| 1262 |
configurable. Suppression of index and reference list is supported. |
| 1263 |
|
| 1264 |
Make configuration of change flag easier. |
| 1265 |
|
| 1266 |
Put section title of changed chunks list in marks, and tell the user |
| 1267 |
that it got typeset. |
| 1268 |
|
| 1269 |
\Revision 2.3 1995/08/27 17:24:46 schrod |
| 1270 |
Make usage of baseclass with chapters work. |
| 1271 |
|
| 1272 |
\Revision 2.2 1995/08/27 13:26:22 schrod |
| 1273 |
Add possibility to suppress change hints. Suppression of unchanged |
| 1274 |
chunks suppress change hints as well, they are meaningless as all |
| 1275 |
printed chunks are changed by definition. |
| 1276 |
|
| 1277 |
Realize dependencies in options by |\ProcessKeyValOptionsHook|. |
| 1278 |
Illegal values for enumeration options don't alter the current value |
| 1279 |
any more. |
| 1280 |
|
| 1281 |
List of changed chunks is an unnumbered section now. |
| 1282 |
|
| 1283 |
\Revision 2.1 1995/08/25 19:11:18 schrod |
| 1284 |
Add keyword-value option style, with new \pkg{keyvald} package. |
| 1285 |
|
| 1286 |
Hierarchic strucutures are supported now, in addition to the flat |
| 1287 |
structure of the beta-test version. One can choose with an option. For |
| 1288 |
that step, the terminology was cleaned up, too: Chunks are not named |
| 1289 |
sections any more. (That change involved reimplementation of almost |
| 1290 |
all the structure and toc stuff.) |
| 1291 |
|
| 1292 |
The chunk number supplied by \cweave{} is used now, not some computed |
| 1293 |
number. Change flags are printed, too. |
| 1294 |
|
| 1295 |
One can suppress output of unchanged sections. |
| 1296 |
|
| 1297 |
One can select the baseclass with an option. That may be used to use |
| 1298 |
\cls{report} or \cls{book} to get chapter-style layout. Of course, |
| 1299 |
using an arbitrary baseclass is dangerous, it must conform to the |
| 1300 |
conventions of \LaTeX{} standard classes. |
| 1301 |
|
| 1302 |
\Revision 1.13 1995/08/08 00:14:29 schrod |
| 1303 |
Updated to \LaTeXe{}, the |cweb| style is now a document class. Used |
| 1304 |
my standard templates for that, no changes in functionality. |
| 1305 |
|
| 1306 |
\Revision 1.12 1993/08/10 14:15:43 schrod |
| 1307 |
New page on main section only if group level $<$ |\cwebSecNoEject|. |
| 1308 |
Default for the latter is 3. |
| 1309 |
|
| 1310 |
Document that logos will not be defined in this style file. |
| 1311 |
|
| 1312 |
Copy of plain macros for |\CwebNumber| does not work. Repaired the |
| 1313 |
most important one (subscript must be accessed via |\sb|). |
| 1314 |
Incompatibility to NFSS will be addressed later.\\ |
| 1315 |
(Problems reported by Zden\v{e}k Wagner \path|<[email protected]>|.) |
| 1316 |
|
| 1317 |
\Revision 1.11 1993/08/10 11:21:07 schrod |
| 1318 |
Reference to section number does not render a period after the |
| 1319 |
number any more. |
| 1320 |
|
| 1321 |
\Revision 1.10 1993/08/09 20:08:20 schrod |
| 1322 |
|\cweb@cweave_bindings| is now a no-op if \cweave{} bindings are in |
| 1323 |
effect already.\\ |
| 1324 |
(Problem reported by Michael M\"uller \path|<[email protected]>|.) |
| 1325 |
|
| 1326 |
\Revision 1.9 1993/08/09 18:05:28 schrod |
| 1327 |
Left shift operator wasn't defined correctly.\\ |
| 1328 |
(Problem reported by Michael M\"uller \path|<[email protected]>|.) |
| 1329 |
|
| 1330 |
\Revision 1.8 1993/06/15 15:22:30 schrod |
| 1331 |
\textbf{Version 0.2:} Moved from |pub/incoming| to official place, in |
| 1332 |
Literate Programming Archive. |
| 1333 |
|
| 1334 |
\Revision 1.7 1993/06/15 13:25:48 schrod |
| 1335 |
First attempt to make it a style: |article| is imported. Warns the |
| 1336 |
user if he tries to use |cweb| as a style option. |
| 1337 |
|
| 1338 |
\Revision 1.6 1993/06/15 08:49:23 schrod |
| 1339 |
|\cweb@check_dot| must not evaluate its argument in an |\edef|, this |
| 1340 |
causes problems if a |\PB| is within. Now I try hard not to evaluate any |
| 1341 |
tokens outside of my control. |
| 1342 |
|
| 1343 |
Can use |\@defpar| for an empty line in |\cweb@has_entries|, don't |
| 1344 |
need an own macro. |
| 1345 |
|
| 1346 |
\Revision 1.5 1993/06/14 17:50:30 schrod |
| 1347 |
Handle a missing |\con|: |\inx| and |\con| are now never looked at. |
| 1348 |
Instead |\fin| checks for the existence of the lists and typeset them |
| 1349 |
if there are entries available. |
| 1350 |
|
| 1351 |
\Revision 1.4 1993/06/14 15:54:18 schrod |
| 1352 |
Made it work with older versions of \LaTeX{}, too. The |\enddocument| |
| 1353 |
implementation of cweb.sty depends on the |\end| implementation; check |
| 1354 |
if the current implementation is one we know of (currently: 91-01-14 |
| 1355 |
and 92-03-25).\\ |
| 1356 |
(Problem reported by Michael M\"uller \path|<[email protected]>|.) |
| 1357 |
|
| 1358 |
Add FSA diagram about processing states. CR state is also switched |
| 1359 |
to from \TeX{} state (that happens with |\ch| at the document end). |
| 1360 |
|
| 1361 |
\Revision 1.3 1993/05/13 17:51:21 schrod |
| 1362 |
Refinements may also be filenames (`|@(|'). Then the complete name |
| 1363 |
consists of a |\.| macro call, which is handled now.\\ |
| 1364 |
(Problem reported by Michael M\"uller \path|<[email protected]>|.) |
| 1365 |
|
| 1366 |
Made the detection of `|@.|' index entries more robust. |
| 1367 |
|
| 1368 |
\Revision 1.2 1993/05/12 18:28:59 schrod |
| 1369 |
Adapted to recent changes of \cweave{} (of April 93): |
| 1370 |
|
| 1371 |
Main sections have a group level, represented in the table of |
| 1372 |
contents. This changed the complete implementation of section tags. |
| 1373 |
|
| 1374 |
New C token cseqs: |\Z| and |\MRL|, implemented as |\CwebLe| and |
| 1375 |
|\CwebCombinedOp|. |
| 1376 |
|
| 1377 |
\Revision 1.1 1993/04/09 15:00:37 schrod |
| 1378 |
Initial revision |
| 1379 |
|
| 1380 |
\end{rcslog} |
| 1381 |
|
| 1382 |
|
| 1383 |
|
| 1384 |
\end{document} |
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 1389 |
Local Variables: |
| 1390 |
mode: LaTeX |
| 1391 |
TeX-brace-indent-level: 4 |
| 1392 |
indent-tabs-mode: t |
| 1393 |
TeX-auto-untabify: nil |
| 1394 |
TeX-auto-regexp-list: LaTeX-auto-regexp-list |
| 1395 |
compile-command: "make cweb.cls" |
| 1396 |
End: |