Debian Codegraph @

texk/makeindexk/ind-src/ind.tex

raw
1 % Document Type: LaTeX
2 % Master File: ind.tex
3
4 \input{indplus.tex}
5
6 \title{Index Preparation and Processing\thanks{Sponsored
7 in part by the National Science Foundation under Grant MCS-8311787,
8 and by the Defense Advanced Research Projects Agency (DoD),
9 ARPA Order No.\ 4871, monitored by Space and Naval Warfare Systems Command,
10 under Contract No.\ N00039-84-C-0089.}
11 }
12
13 \author{{\sl Pehong Chen}\thanks{Additional support has been provided
14 by an IBM Graduate Fellowship.}\\
15 {\sl Michael A. Harrison}\\
16 {et al.}\thanks{Updated 2014 by Dan Luecking and Karl Berry.}\\
17 \\
18 Computer Science Division \\
19 University of California \\
20 Berkeley, CA 94720
21 }
22
23 \def\today{}
24 \maketitle
25
26 \begin{abstract}
27 Index preparation is a tedious and time-consuming task.
28 This paper indicates how the indexing process can be automated
29 in a way that is largely independent of a specific typesetting system
30 and independent of the format being used.
31 Fundamental issues related to this process are identified and analyzed.
32 Specifically, we develop a framework for placing index
33 commands in the document. In addition, the design of
34 a general purpose index processor that
35 transforms a raw index into an alphabetized version is described.
36 The resulting system has proved very useful and effective in producing
37 indexes for several books, technical reports, and manuals.
38 A comparison of our system with indexing facilities
39 available from a variety of other document preparation environments is given.
40
41 {\it Keywords\/}: index placement, index processing, source-language model,
42 direct manipulation.
43 \end{abstract}
44
45 \section*{Document Updates}
46
47 MakeIndex is maintained as part of \TeX\ Live ({\tt
48 http://tug.org/texlive}); please send bug reports about both the program
49 and this document to {\tt [email protected]}.
50
51 This paper by Chen and Harrison, the originators of the MakeIndex
52 program, remains largely unchanged. In 2014, aside from formatting
53 changes, Dan Luecking (with Karl Berry) made some updates to correspond
54 with changes in the program: the \verb|lethead_*| directives are now
55 \verb|heading_*|, along with \verb|numhead_*| and \verb|symhead_*|; and
56 \verb|delim_t| has been added.
57
58 \section{Introduction}
59 Although there has been a great deal of activity in
60 electronic publishing~[1],
61 there are still aspects of document composition that have not been
62 fully automated.
63 One of the most time-consuming concerns is the preparation of an index.
64 In ordinary books, an index allows a reader to
65 access essential information easily.
66 A poor index with many omissions or poorly chosen concepts
67 detracts from other aspects of the book.
68 For highly complex technical material that may include computer programs,
69 different kinds of indices may
70 reference even the identifiers of a programming language. A good example
71 of an elaborate indexing scheme can be found in Knuth's
72 {\it {\TeX}:\ The Program\/}~[2] and his WEB system~[3] in general.
73 For computer programs like these,
74 completeness is essential and the accuracy of
75 traditional hand methods will not suffice for software engineering
76 applications.
77
78 Standard authors' guides, such as Reference~[4],
79 recommend that index terms be marked on page proofs or on a separate set of
80 galley proofs.
81 The traditional method is to use $3 \times 5$ cards, appropriately called
82 index cards.
83 A page number is added to a card when a reference is encountered.
84 Sorting is done by hand and the process is tedious and error-prone.
85 Computers offer an opportunity to significantly reduce the amount of labor
86 invested in this process while noticeably improving the quality of the
87 resulting index.
88
89 This paper indicates how the indexing process can be automated
90 in a way that is largely independent of a specific typesetting system
91 and independent of the format being used.
92 Specifically, we develop a framework for placing index
93 commands in the document. In addition, the design of
94 a general purpose index processor that
95 transforms a raw index into an alphabetized version is described.
96 These concepts have been implemented as part of an extensive authoring
97 environment~[5]. This environment includes a suite of Lisp programs
98 for the index placing facility and a C program for the
99 index processor. The resulting system has been successfully
100 used in producing indexes for some books~[6,7]
101 and a number of technical reports and manuals.
102
103 Indexing issues under both {\it source-language\/} and
104 {\it direct-manipulation\/}~[8,9] paradigms are considered.
105 In a source-language based system, the user specifies
106 the document with interspersed commands, which is then passed to a formatter,
107 and the output is obtained. The source-language usually provides some
108 abstraction and control mechanisms such as procedures, macros,
109 conditionals, variables, etc. in much the same way as a high-level programming
110 language does. In a direct-manipulation environment,
111 the user manipulates the document output appearance directly
112 by invoking built-in operators available through menus and buttons.
113 These systems are highly interactive; the result of invoking an operation
114 is observed instantaneously, thereby creating an illusion that the user
115 is ``directly'' manipulating the underlying object.
116
117 The document attributes in direct-manipulation systems
118 are usually specified by a declarative language encapsulated as
119 form-based property sheets. These property sheets
120 correspond to textual markup tags that can be imported to
121 or exported from the direct-manipulation system for document interchange
122 purposes. While a source representation is maintained explicitly in the
123 source-language model, the notion of a document semantics specification
124 language is somewhat implicit in direct-manipulation systems.
125
126 Some people have called direct-manipulation systems {\W}
127 ({\it what-you-see-is-what-you-get\/}).
128 The two concepts are not equivalent, however.
129 {\W} refers to the correspondence between what is presented on a video display
130 and what can be generated on some other device. In the context of
131 electronic publishing, {\W} means that there is a very close relationship
132 in terms of document appearance
133 between a screen representation and the final hardcopy.
134 Direct manipulation is a more general concept that models user interfaces.
135 A direct-manipulation document preparation system may not have
136 a {\W} relationship between its display representation and the final hardcopy.
137 Conversely, a batch-oriented, source-language based formatter
138 may be coupled with a previewer that is {\W}.
139
140 This paper presents some general indexing problems and our solutions
141 in a top-down fashion.
142 First we discuss the desirable features of an index processor
143 and then some design and implementation considerations for such a processor.
144 Our goal is to arrive at general purpose solutions.
145 Next, a framework is introduced under which an author enters index commands
146 or tags with much reduced overhead.
147 The examples shown are in {\LaTeX}~[10], a high-level
148 document preparation language based on {\TeX}~[11].
149 The model, however, is not restricted to any particular formatting language,
150 nor to the source-language paradigm.
151 We also examine some unique indexing issues in
152 electronic document development environments that do not seem to find
153 appropriate counterparts in traditional printed material.
154 Finally our indexing facilities are evaluated against those available in
155 other formatting systems such as {\SB}~[12],
156 {\TF}~[13], and some direct-manipulation environments.
157
158 \begin{figure}
159 %% \centerline{
160 %% \psfig{figure=fig1.ps,height=4.5in}
161 %% }
162 %% Replace PostScript figure with LaTeX picture mode version
163 %% designed to closely match the original fig1.ps output
164 %% so that this document can be formatted and printed on any
165 %% system. -- Nelson H. F. Beebe <[email protected]> [08-Jul-1991]
166 \input{fig1.tex}
167 \caption[{\it The sequential flow of index processing\/}.]{Circles
168 in the picture represent processors,
169 squares are documents or auxiliary files. In Step~I, the author uses an
170 editor to place index commands in the document. In Step~II, a raw index
171 is generated as a by-product of formatting. In Step~III, this raw index
172 together with some optional style information are taken as input to
173 the index processor and an alphabetized version is created.
174 Finally in Step~IV, the index is formatted to yield the ultimate result.}
175 \end{figure}
176
177 \section{Basic Tasks}
178 Index preparation is a process involving the following steps:
179 \renewcommand{\labelenumi}{\Roman{enumi}.} % set the enumerated list in roman
180 \begin{enumerate}
181 \item Placing index commands in the document source, which presumably
182 comprises multiple files. An index command takes a single
183 argument: the key to be indexed.
184 \item Creating a raw index file whose entries each consists
185 of two arguments: the index key and the page on which the index
186 command appears.
187 \item Processing the raw index file. Here, all index keys are
188 sorted alphabetically. Page numbers under the same key are merged
189 and successive numbers may be collected into
190 intervals (e.g., \verb|1, 2, 3, 4, 5| is replaced by \verb|1-5|).
191 Subitems within an entry, if any, are properly handled.
192 \item Formatting the processed index. The result is the actual index.
193 \end{enumerate}
194 \renewcommand{\labelenumi}{\arabic{enumi}.} % reset the list back to arabic
195 The idea is illustrated in Figure~1, where roman capitals I--IV marking
196 the edges correspond to the four steps here.
197 This procedure is a highly sequential,
198 for the input to one step depends upon the result from the previous one.
199
200 Figure~2 exemplifies a stepwise development of the process.
201 In {\LaTeX} and {\TeX}, all commands begin with a backslash
202 (\verb|\|). Figure~2.a shows some occurrences of index
203 commands (\verb|\index|) in the document source, with corresponding pages
204 listed on the left. The page number is not part of the source file since at
205 file-preparation time, it is unclear on which page a given textual material
206 will eventually appear. Figure~2.a includes these numbers just to
207 indicate that ultimately these entries would appear on those pages.
208 Figure~2.b shows a raw index file generated by {\LaTeX}.
209 After running through the index processor, it becomes an alphabetized index
210 with commands specifying a particular output appearance (Figure~2.c).
211 The result after formatting is shown in Figure~2.d.
212
213 \begin{figure}
214 \begin{iexample}
215 &\\
216 {\sl Page iv\/}: & \verb|\index{alpha}| \\
217 {\sl Page 1\/}: & \verb|\index{alpha}| \\
218 {\sl Page 2\/}: & \verb|\index{alpha}| \\
219 {\sl Page 3\/}: & \verb|\index{alpha}| \\
220 {\sl Page 11\/}: & \verb#\index{alphabeta|see{beta}}# \\
221 {\sl Page 14\/}: & \verb|\index{alpha@{\it alpha\/}}| \\
222 & \verb#\index{beta|bold}# \\
223 {\sl Page 22\/}: & \verb|\index{alpha!beta!gamma}| \\
224 {\sl Page 38\/}: & \verb|\index{alpha!delta}| \\
225 & \\
226 \sindex
227 \\
228 \verb|\indexentry{alpha}{iv}| \\
229 \verb|\indexentry{alpha}{1}| \\
230 \verb|\indexentry{alpha}{2}| \\
231 \verb|\indexentry{alpha}{3}| \\
232 \verb#\indexentry{alphabeta|see{beta}}{11}# \\
233 \verb|\indexentry{alpha@{\it alpha\/}}{14}| \\
234 \verb#\indexentry{beta|bold}{14}# \\
235 \verb|\indexentry{alpha!beta!gamma}{22}| \\
236 \verb|\indexentry{alpha!delta}{38}| \\
237 \end{iexample}
238 \hrule
239 \begin{iexample}
240 &\\
241 \verb|\begin{theindex}| &\\
242 &\\
243 \verb|\item alpha, iv, 1-3| &\\
244 \verb| \subitem beta| &\\
245 \verb| \subsubitem gamma, 22| &\\
246 \verb| \subitem delta, 38| &\\
247 \verb|\item {\it alpha\/}, 14| &\\
248 \verb|\item alphabeta, \see{beta}{11}| &\\
249 &\\
250 \verb|\indexspace| &\\
251 &\\
252 \verb|\item beta, \bold{14}| &\\
253 &\\
254 \verb|\end{theindex}| &\\
255 \tindex
256 \\
257 alpha, iv, 1--3 \\
258 \sitem beta \\
259 \ssitem gamma, 22\\
260 \sitem delta, 38 \\
261 {\it alpha\/}, 14\\
262 alphabeta, {\it see\/} beta\\
263 \\
264 beta, {\bf 14}\\
265 \end{iexample}
266 \caption{{\it The stepwise development of index processing\/}.
267 This example is specified in {\LaTeX}.
268 (a) {\sl Top Left\/}: Occurrences of index commands in the document source.
269 Note that page numbers are unknown at the time of input when a source-based
270 formatter like {\LaTeX} is used. Page numbers are included here simply to
271 illustrate where each instance will occur.
272 (b) {\sl Top Right\/}: raw index file generated by {\LaTeX}.
273 (c) {\sl Bottom Left\/}: alphabetized index file.
274 (d) {\sl Bottom Right\/}: formatted final index.}
275 \end{figure}
276
277 Based on the example given in Figure~2, these four steps are explained
278 below, where Steps~I and III are further expanded in subsequent sections.
279 Issues involved in Steps~II and IV are less complex
280 and are covered only in this section.
281
282 \subsection{Placing Index Commands}
283 Step~I deals with placing index commands in the document.
284 In a source-language based environment, the commands can simply be inserted
285 in the document source with a text editor.
286 They will be utilized by the formatter in generating
287 raw index entries (Step~II), but will contribute nothing to the output
288 appearance as far as the corresponding pages are concerned.
289
290 In a direct-manipulation system, index commands cannot be entered directly in
291 the document under manipulation. A possible solution is to put them
292 in ``shadow pages'' instead of the document output representation.
293 A shadow document is the original document plus
294 special tags that, among other things,
295 mark logical objects like comments, bibliographical citations,
296 cross references, indexes, etc.
297 These tags are essential to document composition but do not correspond to
298 physical appearance in their original forms. Upon request, the corresponding
299 markers of these tags can be displayed along with the original document
300 for editing purposes. For the user's visual cue, each type of tags can be
301 represented by a different marker symbol.
302 Normally for each tag entered in the
303 document, an embedded annotation can be specified.
304 An additional window can be created to show the associated annotation
305 if necessary. This shadow document approach is widely adopted by
306 direct-manipulation document development or desktop publishing systems
307 such as Xerox {\ST}~[14], {\FM}~[15],
308 {\WD}~[16], and {\VP}~[17].
309
310 The primary issue in step I for both paradigms
311 is whether or not a systematic mechanism
312 can be derived for the entering of index commands or tags.
313 Details of a general model that accomplishes this task are given below.
314
315
316 \subsection{Generating the Raw Index}
317 Step~II concerns attaching the current page number to each index
318 command placed in the document. The command used in the generated
319 raw index file may be renamed (in our example, it is changed
320 from \verb|\index| to \verb|\indexentry|).
321 The entries are in the exact order in which they appear in the document source.
322 Thus, as long as the current page number is accessible, be it
323 source-language or direct-manipulation based, generating raw index entries
324 is relatively straightforward.
325
326 There are minor differences between the two paradigms in this step,
327 however. The generation of raw index entries in a source-language based
328 system, like formatting itself, is by and large a ``batch job''.
329 In a direct-manipulation editor, it is easier to maintain the list of raw index entries
330 incrementally because the document being manipulated is always formatted
331 so the page number is always current.
332
333 \subsection{Index Processing}
334 Processing raw index entries raises several issues.
335 Some high-level issues are described below with references to the example given
336 in Figure~2; how these tasks can be realized is detailed in the next section.
337
338 {\it Permutation\/}. Index entries are sorted alphabetically (Figure~2.c).
339 The index processor must differentiate among different types of keys
340 such as strings, numbers, and special symbols.
341 Upper and lower case letters should be distinguished.
342 Furthermore, it may be necessary to handle roman, arabic, and
343 alphabetic page numbers.
344
345 {\it Merging\/}. Different page numbers corresponding to the same
346 index key are merged into one list. Also, three or more
347 successive page numbers are abbreviated as a range (as in the
348 case of \verb|alpha, iv, 1-3|, Figure~2.c). If citations on successive
349 pages are logically distinct, good indexing practice suggests that they
350 should not be represented by a range. Our system allows user control
351 of this practice.
352
353 {\it Subindexing\/}. Multi-level indexing is supported.
354 Here, entries sharing a common prefix are grouped together
355 under the same prefix key.
356 The special symbol `\verb|!|' serves as the level operator
357 in the example (Figure~2.a and 2.b). Primary indexes are
358 converted to first level items (the \verb|\item| entries in Figure~2.c)
359 while subindexes are converted to lower level items
360 (e.g., \verb|\subitem| or \verb|\subsubitem| entries in Figure~2.c).
361
362 {\it Actual Field\/}. The distinction between a {\it sort key\/}
363 and its {\it actual field\/} is made explicit.
364 Sort keys are used in comparison while their actual counterparts are
365 what end up being placed in the printed index.
366 In the example, the `\verb|@|'
367 sign is used as the actual field operator, which means its
368 preceding string is the sort key and its succeeding string
369 is the actual key (e.g., the \verb|\index{alpha@{\it alpha\/}}|
370 in Figure~2.a).
371 The same sort key with and without an actual field
372 are treated as two separate entries (cf. \verb|alpha| and {\it alpha\/}
373 in the example). If a key contains no actual operator,
374 it is used as both the sort field and the actual field.
375
376 The separation of a sort key from its actual field makes entry sorting
377 much easier. If there were only one field,
378 the comparison routine would have to ignore syntactic sugar related to
379 output appearance and compare only the ``real'' keywords.
380 For instance, in \verb|{\it alpha\/}|, the program has to ignore the font
381 setting command \verb|\it|, the italic correction command \verb|\/|,
382 and the scope delimiters \verb|{}|.
383 In general, it is impossible to know
384 all the patterns that the index processor should ignore,
385 but with the separation of the fields, the sort key is used as a verbatim string
386 in comparison; any special effect can be achieved via the actual field.
387
388 {\it Page Encapsulation\/}. Page numbers can be encapsulated
389 using the `\verb#|#' operator. In the example,
390 page 14 on which \verb|\index{beta}| occurs is set in boldface, as
391 represented by the command \verb|\bold|. The ability to set
392 page numbers in different fonts allows the index to convey
393 more information about whatever is being indexed. For instance,
394 the place where a definition occurs can be set in one font, its
395 primary example in a second, and others in a third.
396
397 {\it Cross Referencing\/}. Some index entries make references to
398 others. In our example the \verb|alphabeta| entry is a reference
399 to \verb|beta|, as indicated by the {\it see\/} phrase.
400 The page number, however, disappears after formatting (Step~IV),
401 hence it is immaterial where index commands dealing with cross references
402 like {\it see\/} occur in the document.
403 This is a special case of page encapsulation (\verb|see{beta}| appears
404 after the `\verb#|#' operator).
405 Variations like {\it see also\/}, which gives page numbers as well
406 as references to other entries, work similarly.
407
408 {\it Input/Output Style\/}. In order to be
409 formatter- and format-independent, the index processor must be able
410 to handle a variety of formats. There are two reasons for considering
411 this independence issue in the input side:
412 Raw index files generated by systems
413 other than {\LaTeX} may not comply to the default format, and
414 the basic framework established for processing indexes can also be
415 used to process other objects of similar nature (e.g., glossaries).
416 But these other objects will certainly have a different keyword
417 (e.g., \verb|\glossaryentry| as opposed to \verb|\indexentry|)
418 in the very least.
419 Similarly in the output side the index style
420 may vary for different systems. Even within the same formatting
421 system, the index may have to look differently under different
422 publishing requirements. In other words, there must be a way to inform
423 the processor of the input format and the output style.
424
425
426 \subsection{Index Formatting}
427 Two key issues in this last step are
428 support for multiple styles and formatting independence.
429 First, the formatting style macros used in Step~III output
430 must be defined. In our example,
431 the global environment (\verb|\begin{theindex}...\end{theindex}|) tells
432 {\LaTeX} to use a two-column page layout. Each \verb|\item| is
433 left justified against the column margin and each \verb|\subitem| is indented
434 by 20 points, \verb|\subsubitem| by 30, etc.
435 There is a vertical space bound to
436 \verb|\indexspace| inserted before the beginning of a new letter
437 (e.g., before \verb|beta|).
438
439 The formatting independence problem refers to whether or not the final index
440 can be formatted independently of the entire document.
441 Indexing is typically the last step of document preparation, and
442 is attempted only when the entire document is finalized.
443 It is desirable to be able to generate the index without
444 reformatting the entire document. To be able to format
445 the index separately, the global context must be known, which is made possible
446 by the extensible style facility in our design.
447 One can redefine \verb|preamble| and \verb|postamble| to
448 invoke a style consistent with the original document.
449
450 The other information needed to perform effective separate formatting
451 is the starting page number for the index.
452 Some styles require that the index
453 start on an even or odd page number.
454 In either case, there must be provisions for including the correct
455 starting page number in the pre-formatted version of index.
456
457
458 \section{Index Processing}
459 The index processor performs the tasks indicated above ---
460 permutation, page number merging, subindexing, style handling, and other
461 special effects. In order to achieve format and formatter independence,
462 the index processor must be able to accept raw index
463 terms designated by different keywords and delimiters.
464 Likewise, it must be able to generate output in a specific style
465 so that the result can be processed by the corresponding formatter.
466 The intended tasks can be performed in multiple passes:
467 First the input format file and output style file are scanned and analyzed.
468 Entries in the input file are then processed. Next, all legal entries are
469 sorted. Finally, the output index is generated in the last pass.
470 The remainder of this section discusses the essential attributes
471 for input formats and output styles and points out relevant issues
472 for sorting and generating the entries.
473
474
475 \begin{table}
476 \begin{center}
477 {\small
478 \begin{tabular}{l|c|c|l}
479 \hline
480 \hd{specifier} & \hd{attribute} & \hd{default} & \hdr{meaning} \\
481 \hline\hline
482 \verb|keyword| & {\it string\/} & \verb|"\\indexentry"| &
483 index command\\
484 \hline
485 \verb|arg_open| & {\it char\/} & \verb|'{'| &
486 argument opening delimiter\\
487 \hline
488 \verb|arg_close| & {\it char\/} & \verb|'}'| &
489 argument closing delimiter\\
490 \hline
491 \verb|range_open| & {\it char\/} & \verb|'('| &
492 page range opening delimiter\\
493 \hline
494 \verb|range_close| & {\it char\/} & \verb|')'| &
495 page range closing delimiter\\
496 \hline
497 \verb|level| & {\it char\/} & \verb|'!'| &
498 index level delimiter\\
499 \hline
500 \verb|actual| & {\it char\/} & \verb|'@'| &
501 actual key designator\\
502 \hline
503 \verb|encap| & {\it char\/} & \verb#'|'# &
504 page number encapsulator\\
505 \hline
506 \verb|quote| & {\it char\/} & \verb|'"'| &
507 quote symbol\\
508 \hline
509 \verb|escape| & {\it char\/} & \verb|'\\'| &
510 symbol that escapes \verb|quote|\\
511 \hline
512 \verb|page_compositor| & {\it string\/} & \verb|"-"| &
513 composite page delimiter\\
514 \hline
515 \end{tabular}
516 }
517 \end{center}
518 \caption{Input format parameters.}
519 \end{table}
520
521 \subsection{Input Format}
522 Table~1 is a summary of the input format that consists of a list
523 of \verb|<|{\it specifier\/}, {\it attribute\/}\verb|>| pairs.
524 These attributes
525 are the essential tokens and delimiters needed in scanning the
526 input index file. Default string constants are enclosed in
527 double quotes (\verb|"..."|) and character constants are
528 in single quotes (\verb|'x'|). The user can override
529 the default value by specifying a specifier and a new attribute
530 in the format file or property sheet.
531 The attribute of \verb|keyword| is self-explanatory;
532 \verb|arg_open| and \verb|arg_close| denote the argument opening and
533 closing delimiters, respectively.
534 The meanings of special operators such as \verb|level|,
535 \verb|actual|, and \verb|encap| are described above.
536
537 The two range delimiters \verb|range_open| and \verb|range_close| are
538 used with the \verb|encap| operator.
539 When \verb|range_open| immediately follows \verb|encap|
540 (i.e., \verb#\index{...|(...}#),
541 it tells the index processor that an explicit range is starting.
542 Conversely \verb|range_close| signals the closing of a range.
543 In our design, three or more successive page numbers are abbreviated as
544 a range implicitly. This {\it implicit\/} range formation can be turned
545 off if an indexed term represents logically distinct concepts in different
546 pages. When the implicit range is disabled, {\it explicit\/} page ranges
547 can be enforced by using the two range delimiters
548 \verb|range_open| and \verb|range_close|.
549 Therefore, it is possible to index an entire section or a large piece
550 of text related to a certain concept without having to insert an index
551 command in every single page.
552
553 The \verb|quote| operator is used to escape symbols.
554 Thus \verb|\index{foo"@goo}| means a sort key of \verb|foo@goo|
555 rather than a sort key of \verb|foo"| and an actual key of \verb|goo|.
556 As an exception, \verb|quote|, when preceded by \verb|escape| (i.e.
557 \verb|\index{...\"...}|), does not escape its succeeding letter.
558 This special case is included because \verb|\"| is the umlaut
559 command in {\TeX}. Requiring \verb|quote| itself to be quoted
560 in this case (i.e. \verb|\""|) is feasible but somewhat awkward;
561 \verb|quote| and \verb|escape| must be distinct.
562
563 A page number can be a composite of one or more fields
564 separated by the delimiter bound to \verb|page_compositor|
565 (e.g., II-12 for page 12 of Chapter II).
566 This attribute allows the lexical analyzer to separate
567 these fields, simplifying the sorting of page numbers.
568
569 \subsection{Output Style}
570 Table~2 summarizes the output style parameters. Again, it is a list
571 of \verb|<|{\it specifier\/}, {\it attribute\/}\verb|>| pairs.
572 In the default column, `\verb|\n|' and `\verb|\t|' denote a new line
573 and a tab, respectively. These parameters can be further divided into
574 the following groups:
575
576 \begin{table}
577 \begin{center}
578 {\small
579 \begin{tabular}{l|c|l|l}
580 \hline
581 \hd{specifier} & \hd{attribute} & \hd{default} & \hdr{meaning} \\
582 \hline\hline
583 \verb|preamble| & {\it string\/} & \verb|"\\begin{theindex}\n"| &
584 index preamble\\
585 \hline
586 \verb|postamble| & {\it string\/} & \verb|"\n\n\\end{theindex}\n"| &
587 index postamble\\
588 \hline
589 \verb|setpage_prefix| & {\it string\/} & \verb|"\n \\setcounter{page}{"| &
590 page setting command prefix\\
591 \hline
592 \verb|setpage_suffix| & {\it string\/} & \verb|"}\n"| &
593 page setting command suffix\\
594 \hline
595 \verb|group_skip| & {\it string\/} & \verb|"\n\n \\indexspace\n"| &
596 intergroup vertical space\\
597 \hline
598 \verb|heading_prefix| & {\it string\/} & \verb|""| &
599 new letter heading prefix\\
600 \hline
601 \verb|heading_suffix| & {\it string\/} & \verb|""| &
602 new letter heading suffix\\
603 \hline
604 \verb|headings_flag| & {\it number\/} & \verb|0| &
605 flag designating new letter\\
606 \hline
607 \verb|numhead_positive| & {\it string\/} & \verb|"Numbers"| &
608 heading for numbers (flag${}>0$)\\
609 \hline
610 \verb|numhead_negative| & {\it string\/} & \verb|"numbers"| &
611 heading for numbers (flag${}<0$)\\
612 \hline
613 \verb|symhead_positive| & {\it string\/} & \verb|"Symbols"| &
614 heading for symbols (flag${}>0$)\\
615 \hline
616 \verb|symhead_negative| & {\it string\/} & \verb|"symbols"| &
617 heading for symbols (flag${}<0$)\\
618 \hline
619 \verb|item_0| & {\it string\/} & \verb|"\n \\item "| &
620 level 0 item separator\\
621 \hline
622 \verb|item_1| & {\it string\/} & \verb|"\n \\subitem "| &
623 level 1 item separator\\
624 \hline
625 \verb|item_2| & {\it string\/} & \verb|"\n \\subsubitem "| &
626 level 2 item separator\\
627 \hline
628 \verb|item_01| & {\it string\/} & \verb|"\n \\subitem "| &
629 levels 0/1 separator\\
630 \hline
631 \verb|item_x1| & {\it string\/} & \verb|"\n \\subitem "| &
632 levels x/1 separator\\
633 \hline
634 \verb|item_12| & {\it string\/} & \verb|"\n \\subsubitem "| &
635 levels 1/2 separator\\
636 \hline
637 \verb|item_x2| & {\it string\/} & \verb|"\n \\subsubitem "| &
638 levels x/2 separator\\
639 \hline
640 \verb|delim_0| & {\it string\/} & \verb|", "| &
641 level 0 key/page delimiter\\
642 \hline
643 \verb|delim_1| & {\it string\/} & \verb|", "| &
644 level 1 key/page delimiter\\
645 \hline
646 \verb|delim_2| & {\it string\/} & \verb|", "| &
647 level 2 key/page delimiter\\
648 \hline
649 \verb|delim_n| & {\it string\/} & \verb|", "| &
650 inter page number delimiter\\
651 \hline
652 \verb|delim_r| & {\it string\/} & \verb|"--"| &
653 page range designator\\
654 \hline
655 \verb|delim_t| & {\it string\/} & \verb|""| &
656 page list terminator \\
657 \hline
658 \verb|encap_prefix| & {\it string\/} & \verb|"\\"| &
659 page encapsulator prefix\\
660 \hline
661 \verb|encap_infix| & {\it string\/} & \verb|"{"| &
662 page encapsulator infix\\
663 \hline
664 \verb|encap_suffix| & {\it string\/} & \verb|"}".| &
665 page encapsulator suffix\\
666 \hline
667 \verb|page_precedence| & {\it string\/} & \verb|"rnaRA"| &
668 page type precedence\\
669 \hline
670 \verb|line_max| & {\it number\/} & \verb|72| &
671 maximum line length\\
672 \hline
673 \verb|indent_space| & {\it string\/} & \verb|"\t\t"| &
674 indentation for wrapped lines\\
675 \hline
676 \verb|indent_length| & {\it number\/} & \verb|16| &
677 length of indentation\\
678 \hline
679 \end{tabular}
680 }
681 \end{center}
682 \caption{Output style parameters.}
683 \end{table}
684
685 {\it Context\/}. Together, \verb|preamble| and \verb|postamble|
686 define the context in which the index is to be formatted.
687
688 {\it Starting Page\/}. The starting page number can either be supplied
689 by the user or retrieved automatically from the document transcript.
690 In either case, this number can be enclosed with \verb|setpage_prefix|
691 and \verb|setpage_suffix| to yield a page number initializing command.
692
693 {\it New Group/Letter\/}. The string bound to \verb|group_skip|
694 denotes the extra vertical space needed when a group is started.
695 For a group beginning with a different letter,
696 the parameters \verb|heading_prefix| and \verb|heading_suffix| (both with
697 a default nil string) denote the group heading.
698 The flag \verb|headings_flag| has a default value of 0, which
699 means other than \verb|group_skip| nothing else will be inserted before
700 the group.
701 On the other hand, if this flag is positive, the strings bound
702 to \verb|heading_prefix| and \verb|heading_suffix| will be inserted with
703 an instance of the new letter in uppercase in between. Similarly,
704 a lowercase letter will be inserted if the flag is negative.
705
706 For the symbols group, the heading is determined by
707 \verb|symhead_positive| if \verb|headings_flag| is positive (default
708 \verb|"Symbols"|) and by \verb|symhead_negative| if \verb|headings_flag|
709 is negative (default \verb|"symbols"|). Similarly, the numbers group is
710 headed by \verb|numhead_positive| (default \verb|"Numbers"|) or
711 \verb|numhead_negative| (default \verb|"numbers"|). These strings will
712 be preceded by the string associated to \verb|heading_prefix| and
713 followed by the string associated to \verb|heading_suffix|.
714
715 {\it Entry Separators\/}. This group includes everything with the
716 \verb|item_| prefix. First, \verb|item_|$i$
717 denotes the command and indentation to be inserted when
718 a key is started from a level greater than or equal to $i$.
719 Second, \verb|item_|$ij$ has a similar meaning, but with
720 $i = j-1$. Finally, the two \verb|item_x|$j$'s
721 are included to handle the situation where the parent level has no
722 page numbers. Some styles require cases like these to be
723 different from those with page numbers.
724
725 Table~2 depicts a system that supports three levels of
726 subindexing. In general, suppose $n$ is the number of index
727 levels supported, there will be $n$ \verb|item_|$i$'s
728 ($0 \leq i \leq n-1$), $(n-1)$ \verb|item_|$ij$'s
729 ($1 \leq j \leq n-1, i = j-1$), and
730 $(n-1)$ \verb|item_x|$j$'s ($1 \leq j \leq n-1$).
731
732 {\it Page Delimiters\/}. Each level has a key/page delimiter
733 that defines what is to be inserted between a key and its first
734 page number. The inter-page delimiter is specified by \verb|delim_n|,
735 the range designator is given by \verb|delim_r|, and the last page
736 number is terminated by \verb|delim_t|.
737
738 {\it Page Encapsulator\/}. The attributes of
739 \verb|encap_prefix|, \verb|encap_infix|, and \verb|encap_suffix|
740 form what is to be placed into the output
741 when an encapsulator is specified
742 for a certain entry. Suppose \verb|foo| is the specified encapsulator
743 and \verb|N| is the page number, the output sequence is
744 \begin{verbatim}
745 encap_prefix foo encap_infix N encap_suffix
746 \end{verbatim}
747
748 {\it Page Precedence\/}. Five different types of numerals are
749 supported by most systems for page numbering. These are
750 lowercase roman (\verb|r|), numeric or arabic (\verb|n|),
751 lowercase alphabetic (\verb|a|), uppercase roman (\verb|R|),
752 and uppercase alphabetic (\verb|A|). The string bound to
753 \verb|page_precedence| (default \verb|"rnaRA"|)
754 specifies their order.
755
756 {\it Line Wrapping\/}. In the output index file,
757 the merged list of page numbers can be wrapped in multiple lines,
758 if it is longer than \verb|line_max|. The newly wrapped
759 line is indented by \verb|indent_space| whose length is
760 \verb|indent_length|. This artificial line wrapping does not
761 make any difference in formatting, but does provide increased
762 readability for the pre-formatted final index.
763 This feature may seem somewhat trivial at first glance, but if no
764 formatters are involved whatsoever, the readability of the
765 verbatim output index is important.
766
767 \subsection{Sorting Entries}
768 Entries in the raw index file are sorted primarily on their index keys
769 and secondarily on their page numbers.
770 Index keys are sorted first; within the same index key,
771 page numbers are sorted numerically.
772 Sort keys and numeric page numbers are used in the comparison, while
773 actual keys and literal page fields are entered into the
774 resulting index. In our design,
775 a complete index key is an aggregate of one or more sort keys plus the same
776 or a smaller number of actual keys. The comparison is based on
777 sort keys, but if two aggregates have identical sort fields and
778 page numbers, the actual keys can be used to distinguish their order.
779
780 Index keys can be categorized into the following groups:
781 {\it strings\/}, {\it numbers\/}, and {\it symbols\/}.
782 A string is a pattern whose leading character is a letter in the alphabet.
783 A number is a pattern consisting of all digits. A symbol is a pattern
784 beginning with a character not in the union of the English alphabet and
785 arabic digits or starting with a digit but mixed with non-digits.
786 Members of the same group should appear in sequence.
787 Hence there are two issues concerning ordering:
788 one deals with entries within a group; the other is
789 the global precedence among the three groups in question.
790 Details of sorting index keys can be found in Reference~[18].
791
792 There are three basic types of numerals for page numbers: {\it roman\/},
793 {\it alphabetic\/}, and {\it arabic\/}.
794 The sorting of arbitrary combinations of these three types of numerals
795 (e.g., 112, iv, II-12, A.1.3, etc.)
796 must be based on their numeric values and relative precedence.
797 The attribute of \verb|page_precedence| in Table~2, for instance, specifies
798 the precedence. Again, details of sorting page numbers can be found in
799 Reference~[18].
800
801 \subsection{Creating Output Index Entries}
802 Once all input entries are sorted, the output index file can be
803 created. First the attribute bound to \verb|preamble| is placed into
804 the output file, followed by the string
805 \begin{quote}
806 \verb|setpage_prefix |{\sl N\/}\verb| setpage_suffix|,
807 \end{quote}
808 provided {\sl N\/} is the starting page number and
809 such a setting is requested. Next, each entry in the sorted list
810 is processed in order. Finally, the attribute bound to \verb|postamble|
811 is appended at the end of the output file.
812 The algorithm for generating each entry with appropriate formatter-specific
813 commands or delimiters (i.e. \verb|item_|$i$'s, \verb|delim_|$i$'s, etc.)
814 is described in Reference~[18].
815
816 \section{Placing Index Commands}
817 This section discusses a simple framework for placing index commands
818 in a document. It assumes an interactive editor is available with
819 {\it string search\/}, which positions the cursor to a specified pattern, and
820 {\it query-insert\/}, which displays a menu of
821 options and, upon the user's selection, inserts
822 a specified key, together with other constant strings (e.g.,
823 the index command and its argument delimiters).
824
825 We implemented this framework on top of
826 GNU {\E}~[19] as part of an interactive environment for
827 composing {\TeX}-based documents~[5].
828 The underlying model applies not just to conventional text
829 editors, but to direct-manipulation systems as well.
830
831 \subsection{Basic Framework}
832 The basic framework is very simple. All the author needs is
833 to specify a {\it pattern\/} and a {\it key\/}.
834 The editor then finds the pattern,
835 issues a menu of options and inserts the index command along with the key
836 as its argument upon the user's request.
837 In our example, suppose both {\it pattern\/} and {\it key\/} are
838 \verb|alpha|, then the inserted string after an instance
839 of \verb|alpha| in the document is \verb|\index{alpha}|.
840 This insertion will be visible in a source-language based system and will be
841 invisible for a direct-manipulation system (or visible as hidden text
842 for its shadow pages).
843
844 Before the actual insertion is made, it is desirable to make a confirmation
845 request that presents a menu of options, of which
846 {\it confirm\/} and {\it ignore\/} are the most obvious ones.
847 Thus for each instance of the pattern found, the user can decide if
848 it is to be indexed.
849
850 Representing patterns as regular expressions gives significantly more power
851 to this query-insert operation. The same key can represent a complicated
852 string of a basic pattern, its capitalized form, its acronym, and other
853 abbreviations. For instance, the following patterns may all be indexed
854 by the key \verb|UCB|,
855 \begin{verbatim}
856 University of California, Berkeley
857 Berkeley
858 berkeley
859 UCB
860 \end{verbatim}
861
862 As a special case of this \verb|<|{\it key\/}, {\it pattern\/}\verb|>|
863 setup, one can use words in the neighborhood of current cursor position
864 as the implicit value for both the key and the pattern.
865 Some editors allow the use of special characters to delimit word boundaries.
866 These characters can be used in searching to reduce on the number of
867 ``false drops''. For example, one can position the cursor
868 after the desired pattern and with one editor command (typically
869 in two or three key strokes), an index entry will
870 be inserted with the preceding word (or words) as the implicit key.
871 The advantage of this facility is that there is no need to type
872 the key-pattern pair.
873 The same idea also applies to a region of text, which is a piece of
874 continuous text in the document. In {\E}, a region is
875 everything between a marker and the current cursor position.
876 More generally, the implicit operand can be the {\it current selection\/},
877 in which case the bounding positions of the selected text
878 are not necessarily the insertion point.
879
880 In our system, there is also a special facility to index every author name
881 that appears in the bibliography or references section of a document.
882 This feature involves skipping citation entries without an author field and
883 for each author name found, issuing a query-insert prompt similar to
884 the normal case. Instead of entering a name directly as the index term,
885 it is better to display it in the form of last name followed by first
886 and middle names for confirmation, as in
887 \begin{quote}
888 \verb|Confirm: Knuth, Donald E.|
889 \end{quote}
890 This reordering yields last names as primary sort keys.
891 Our name separation heuristic does not always
892 work for multi-word last names. The confirmation prompt
893 allows the user to correct it before insertion.
894
895 \subsection{Key-Pattern List}
896 A collection of these \verb|<|{\it key\/}, {\it pattern\/}\verb|>| pairs
897 can be compiled in a list. A global function can then be invoked to
898 process each pair for the entire document or parts of it.
899 This list can be created off-line by the user, or automatically
900 in an incremental fashion as the
901 user confirms new index insertions in an interactive session. The pattern
902 matching mechanism must be able to recognize and skip instances already
903 indexed so that unnecessary repetitions are avoided.
904 In our system, this key-pattern list is a per document list.
905 If a document includes multiple files, the global function processes
906 each of them according to the preorder traversal of the file inclusion tree.
907
908
909 \subsection{Indexing Menu}
910 For each instance of the pattern found, a menu of options such as the
911 following may be presented.
912
913 \begin{itemize}
914 \item {\it Confirm\/}.
915 \item {\it Ignore\/}.
916 \item {\it Key-Pattern List\/}. Add the current
917 \verb|<|{\it key\/}, {\it pattern\/}\verb|>| pair to the list
918 associated with the current document.
919 \item {\it Index Level\/}. Prompt the user for an index prefix.
920 The \verb|level| operator (`\verb|!|'), if not given at the end
921 of the specified string, should be inserted automatically between
922 the prefix and the current key.
923 \item {\it Actual Field\/}. Prompt the user for the actual field
924 corresponding to the current (sort) key. The \verb|actual|
925 operator (`\verb|@|') should be automatically inserted in between.
926 \item {\it Page Encapsulator\/}. Prompt the user for the page
927 number encapsulator. The \verb|encap| operator (`\verb#|#'),
928 if not given, should be attached in front of the specified string.
929 Encapsulators corresponding to popular fonts such as bold, italic,
930 and slanted, or to cross references like {\it see\/} and
931 {\it see also\/} can be implemented as a submenu.
932 \end{itemize}
933
934 \subsection{Extended Framework}
935 A typical scenario for placing index commands under the extended framework
936 is as follows. There are two query-insert modes:
937 one based on a single key-pattern pair and the other
938 on multiple key-pattern pairs.
939 In the former mode, the user specifies a pattern and a key, and for
940 every instance of the pattern found, decides whether to insert the
941 index command with the specified key, or a variant of it (i.e., a combination
942 of \verb|level|, \verb|actual|, and \verb|encap|).
943 In the latter mode, there is a collection of entries that may be represented
944 as a long list for an entire document, or as a short list for a section.
945 Each key-pattern pair in the list is processed as in the former case.
946 Provisions are also available to help construct the list.
947
948 With such powerful mechanisms available, there is a tendency to ``over index''
949 because it is so easy to be comprehensive.
950 In some cases, ``less may be more''. Therefore, one should be extremely
951 careful in confirming the insertion of {\it key\/}
952 to avoid false drops picked up by the search mechanism.
953
954
955 \section{Direct Manipulation}
956 Although our implementation of these facilities was for a source-based system,
957 a number of direct-manipulation systems do support a similar indexing facility.
958 Four systems are described briefly to indicate
959 the applicability of the principles depicted in the previous sections.
960 Also examined is a more elaborate on-line
961 indexing facility made possible using the electronic media.
962
963
964 \subsection{Indexing under Direct Manipulation}
965 In Xerox PARC's {\CD} environment~[20],
966 the {\TG} editor supports an
967 application called {\sl IndexTool\/}~[21]
968 that automatically prepares multiple
969 multi-level indexes (general index, author index, etc.) with cross
970 references ({\it see\/} and {\it see also\/})
971 and with substitution phrases (index the
972 phrase ``data structures'' under ``data structure'' to handle these
973 automatically). {\sl IndexTool\/} takes a selection and creates an
974 index entry attached to the document over the selection range. Index
975 entries can be edited in a separate tool to permit creating the cross
976 references and substitution text. {\TG} also has a regular expression search
977 capability via {\sl EditTool\/}, which also
978 permits a wide range of search and replace operations.
979
980 In {\FM} 1.0~[15], index tags can be placed and edited
981 using a combination of the {\sl Markers\/} and the {\sl Search\/} tools.
982 {\sl Markers\/} allows one to specify invisible tags such as
983 subjects, comments, and of course, index entries.
984 For each marker, an associated annotation can be specified.
985 In the indexing case, the annotation is the key to appear in the final index.
986 Attributes of page encapsulation discussed previously can also be specified
987 in the {\sl Markers\/} window.
988 These attributes include explicit page range, fonts, and an option to disable
989 page numbers so that cross references like {\it see\/} can be realized.
990 {\FM}'s {\sl Search\/} can be used to locate the desired pattern in plain
991 or regular expressions. An invisible character \verb|\m|
992 can be specified in {\sl Search\/} to identify each occurrence
993 of index markers in the document.
994 Whenever a marker is found, the corresponding
995 annotation is displayed in the {\sl Markers\/} window.
996 The annotated text can incorporate special symbols to yield
997 multi-level indexing and actual field substitution similar to the ones
998 described in above. A processor called
999 {\sl fmBook\/} can be executed off-line to collect index markers,
1000 sort them, and finally generate a formatted index whose style
1001 is customizable via system supplied property sheets.
1002
1003 In the Macintosh version of {\WD} 3.0~[16], an index command is
1004 designated by the ``index code'' \verb|.i.| The text between \verb|.i.|
1005 and an ``end-of-entry code'', such as a semicolon, is regarded
1006 as the index key. A colon (\verb|:|) in the entry text acts as the index
1007 level operator. The output appearance can be refined by using
1008 variants of the index code. For instance,
1009 \verb|.iB.| and \verb|.iI.| set the page number in boldface and
1010 italic fonts, respectively, \verb|.i(.| and \verb|.i).| create
1011 an explicit page range, etc. Index entries are ``compiled''
1012 into the actual index that appears at the end of the document.
1013 Before that takes place, the system must be notified that these index codes
1014 are {\it hidden text\/}. An option in the preference sheet
1015 can be set to display hidden text embedded in the document.
1016 Hidden text must be ``hidden'' when index entries are being compiled;
1017 otherwise page number computation will be incorrect.
1018 There are no special tools for entering index codes.
1019 The {\sl find\/} and {\sl change\/} commands in the {\sl Search Menu\/}
1020 do not support regular expressions. There are no query-insert
1021 modes in the search mechanism. Although abbreviations can be registered
1022 as glossary entries, a great many keystrokes are still required in placing
1023 a single index entry.
1024
1025 In {\VP} 1.1~[17], a desktop publishing system
1026 for documents prepared on any of several word processing
1027 programs on the IBM PC, index entries can be placed in the document by
1028 invoking a dialogue box at the desired position.
1029 An alternative is to use a word processor to enter a markup tag such as
1030 \begin{quote}
1031 \verb|<$I<I>alpha<L>[alpha];beta>|
1032 \end{quote}
1033 where \verb|<$I|$\cdots$\verb|>| marks $\cdots$ as an index term,
1034 \verb|<I>alpha<L>| is the actual key in italic,
1035 \verb|[|$\cdots$\verb|]| designates $\cdots$ as the corresponding sort key,
1036 and the semicolon is the index level operator.
1037 It supports two levels of subindexing as well as {\it see\/} and
1038 {\it see also\/}. Index terms are hidden text; the word {\tt Index}
1039 will be displayed by its {\it Current Selection Indicator\/} when
1040 the cursor is placed at a location where an index term is anchored.
1041 The output index style can be specified by changing attributes in
1042 a property sheet called {\tt GENERATE INDEX}. The collection of
1043 attributes is a proper subset of Table~2. Index processing is executed
1044 as a batch job similar to {\sl fmBook\/} in {\FM}. Searching is unavailable
1045 in {\VP}, therefore an automated index placing subsystem is not possible.
1046
1047
1048 \subsection{Dynamic Indexing and Hypertext}
1049 Our proposed implementation of an indexing facility under direct manipulation
1050 and the four real systems discussed previously all operate
1051 in a multi-pass fashion, much the same as a source-language based system.
1052 However, based on its interactive nature, a direct-manipulation document
1053 editor can be constructed with an indexing subsystem that follows the same
1054 central ideas, but with an user interface more closely related to the
1055 direct-manipulation paradigm.
1056
1057 The ``directness'' may be observed in the following scenario.
1058 The author specifies input/output styles by selecting options available
1059 in system supplied property sheets. For each key selected
1060 in the document, its corresponding entry in the index is immediately
1061 displayed, along with entries already entered.
1062 Sorting is done as the entry is generated for the output.
1063 Consequently, the internal structure for these entries can no longer be
1064 an array that is suitable for fast sorting algorithms.
1065 Instead, a balanced tree may be the preferred structure.
1066 Insertion and deletion reorganize the tree automatically and
1067 a traversal of the tree yields the correct ordering.
1068 A link between a page number in the index entry and its corresponding
1069 actual page is required so that the index needs not be regenerated
1070 when the document is reformatted. In other words, when a page
1071 number changes due to reformatting, all instances of that page in the index
1072 change automatically.
1073
1074 One possible extension to this model is the ability to point at an entry
1075 in the index and
1076 have the corresponding page located automatically with a keyword highlighted.
1077 Thus indexing becomes a dynamic activity from the reader's point of view.
1078 This feature typifies the power of ``dynamics'' that an electronic document
1079 environment is able to offer, which does not exist in traditional
1080 static printed material. In addition to dynamic indexing,
1081 one can do such hypertext operations as navigation, filtering, summarizing,
1082 etc.~[22] effectively based on markup tags, embedded annotations, and
1083 links among compound objects in the document.
1084
1085
1086 \section{Evaluation}
1087 \subsection{Index Placing Subsystem}
1088 An important aspect of our system is the framework for
1089 placing index commands in the document.
1090 This task has been performed traditionally in an ad hoc fashion.
1091 It is unclear how placement is done in the
1092 UNIX {\TF} environment. Reference~[23] does not describe
1093 any automated assistance for the author.
1094
1095 Entering index codes in {\WD} is awkward because
1096 its search mechanism lacks full regular expression support
1097 and query-insert mode is unavailable.
1098 To mark one piece of text as an index entry, an ordinary session
1099 requires 8 mouse clicks and 4 keystrokes. Even with accelerated keyboard
1100 abbreviations, it still takes 2 mouse clicks and 8 keystrokes to mark a single
1101 index entry. The premise, however, is that the index pattern has been
1102 located and that it is identical to the index key.
1103 Locating the pattern may involve extra mouse clicks and keystrokes.
1104 Moreover, if the index key and the search pattern are distinct, more
1105 keystrokes would be necessary to enter the text for the index key.
1106 This situation happens to the marking of each and every instance
1107 of index entries. No global scheme is available in {\WD}.
1108
1109 {\VP} does not support any searching mechanism; it assumes
1110 searching is performed in a front-end word processor.
1111 Therefore, systematic index placing in the stand-alone {\VP} is difficult.
1112
1113 The situation in {\FM} is somewhat better because of its more powerful
1114 keyboard macro registration capability and the support for regular
1115 expression search. In {\FM}, a specific combination
1116 of tools can be used to enter index tags at desired places.
1117 Operations can be recorded as keyboard macros so that repetitions
1118 can be done by a single keystroke (the invocation of the keyboard macro).
1119 The problem is that a new keyboard macro has to be defined for each
1120 key-pattern pair. Furthermore, it
1121 lacks the systematic global scheme available in our extended
1122 framework to make the whole process efficient.
1123
1124 In our system, it takes only 1 to 3 keystrokes to mark an index entry.
1125 Also available is a global scheme for marking index entries in the entire
1126 document that may span over multiple files. In the single key-pattern
1127 case, the same key can be inserted at a variety of places
1128 described by a single regular expression. Patterns already indexed
1129 are skipped automatically. A number of options are
1130 available upon each occurrence of the pattern. Thus, marking each instance
1131 takes just one keystroke to confirm and it works uniformly and continuously
1132 throughout the entire document. This can be expanded to a scheme of
1133 multiple key-pattern pairs that works iteratively on a list of
1134 different index entries.
1135 In our system,
1136 a significant amount of time is saved not just in typing {\it per se\/}, but
1137 in the user's mental reaction time due to the side effect of
1138 unautomated discrete repetitions as in {\FM}, {\WD}, and {\VP}.
1139
1140 In the production of an index for a book~[6], our {\E} Lisp
1141 implementation of the index placing subsystem has proved very useful
1142 and effective. The provision for multi-pair
1143 \verb|<|{\it key\/}, {\it pattern\/}\verb|>| query-insert has been the most
1144 time-saving operation in our experience.
1145 With minor modifications, the same facility should work on
1146 placing index commands for other formatting languages like
1147 {\TF} and {\SB}. Adapting it to direct-manipulation environments is more
1148 involved, but given proper editor programming power,
1149 the basic principles discussed above should apply.
1150
1151 \subsection{Index Processor}
1152 The other major portion of our work is
1153 a complete index processor implementation.
1154 The resulting processor
1155 is a single C program called {\MI}. Actually, {\MI}
1156 had several predecessors all written as UNIX shell scripts with
1157 embedded \verb|sed|~[24] and \verb|awk|~[25] code.
1158 We quickly became unsatisfied with them for various reasons.
1159 One of the concerns was efficiency.
1160 Interpreted languages such as \verb|sed| and \verb|awk| are satisfactory for
1161 rapid prototyping, but they are slow.
1162 In our experience, {\MI} was able to process
1163 a book index of 3,300 entries in less
1164 than 50 seconds of user time plus an extra 5\% of system time on
1165 a client node of SUN 3/50 (MC68020 at 12.5 MHz).
1166 This is at least an order of magnitude faster than
1167 using its most recent \verb|sed|/\verb|awk| predecessor, which has only
1168 half the features of {\MI}.
1169
1170 %The efficiency issue is not that significant since normally
1171 %an index processor is not needed until the document is at its
1172 %final stage. Most of the time is spent in placing index commands
1173 %in the document. There are relatively few invocations to
1174 %process raw index entries. A speedup of over an order of magnitude, however,
1175 %can be significant.
1176
1177 The decision to do a C implementation was made because of C's dynamic
1178 storage allocation and data structures.
1179 Since we wanted as general a solution as possible, it would be difficult,
1180 if not impossible, to implement all the desired features using \verb|sed/awk|.
1181 For instance, in \verb|awk| a dynamically linked list of index entries is
1182 impossible, and the style handling mechanism with a comprehensive error
1183 processing facility is difficult to realize. Originally developed
1184 in UNIX C with portability in mind, {\MI} also runs on VAX/VMS,
1185 TOPS-20, MS/DOS systems with a few trivial changes.
1186 This portability would have
1187 been very difficult for an implementation in UNIX shell scripts.
1188 Furthermore, {\MI} has more features and is more extensible than tools like
1189 {\sl Idx{\TeX}\/}~[26], a {\LaTeX}-specific index processor
1190 that runs only on VAX/VMS systems.
1191
1192 Our approach is the direct opposite of that taken by \verb|make.index|,
1193 a host of indexing tools~[23] built for {\TF}.
1194 As part of the UNIX {\TF} document
1195 preparation environment, these tools are canonical examples of
1196 the pipelining model. They are a collection of small \verb|awk|
1197 programs working together in a very long pipeline.
1198 The claim is that by breaking the system down into small pieces, it is
1199 easier for the user to adapt the package to various situations
1200 not possible to envision in advance. Their approach, therefore, seems
1201 to follow the ``do it yourself'' metaphor whereby you get a toolkit
1202 and assemble the final product yourself. The basic package covers
1203 only those features used by its authors. A third party user has to
1204 modify their \verb|awk| code if something different is desired.
1205
1206 The design of {\MI} is quite different.
1207 Our intention is to build a complete system by analyzing
1208 the tasks involved in index processing. Parameters are derived
1209 to form a table-driven style handling facility.
1210 Formatter and format independence is achieved by
1211 simple style specification. All the underlying
1212 data structures and processing mechanisms are transparent.
1213 Yet it is robust enough to handle different precedence schemes,
1214 ordering rules, etc.
1215 To use the system, the user needs not deal with the processing
1216 details. If the default is inappropriate,
1217 the only adaptation required is a table specification for the style facility.
1218
1219 For instance, by assigning the output index header \verb|index.head|
1220 defined in \verb|make.index| to our \verb|preamble| and
1221 other related commands to \verb|item_|$i$'s, it is easy to produce
1222 an alphabetized index in {\TF} format from a raw index generated by {\TF}.
1223 The same technique applies to other formatting systems.
1224 {\SB}, for example, has an indexing subsystem
1225 that supports a subset of the functionality described above.
1226 By adapting its raw index file format as input style and
1227 its output appearance commands as output style, its indexing capability
1228 can be readily expanded using {\MI}. In both cases,
1229 there is no need to modify the original code used to generate
1230 the raw index (Step II), nor is it necessary to modify {\MI} itself.
1231 Likewise, {\MI} can be integrated with direct-manipulation
1232 document development or publishing systems by binding their descriptive
1233 markup tags to the attributes of {\MI}'s input format and output style.
1234
1235 To summarize the differences in approach between {\MI} and \verb|make.index|,
1236 let us examine the points of comparison: speed, size of the
1237 programs, ease of use, portability, and extensibility.
1238 {\MI} is an order of magnitude faster. The \verb|awk| programs
1239 of \verb|make.index| are less than 100 lines of code, while {\MI} is large:
1240 6,000 lines of C code and a binary of 70K bytes. {\MI} is a self-contained
1241 C program, adapted from our original UNIX implementation, to run on
1242 a variety of machines from micros to mainframes. The \verb|make.index|
1243 system will run on any UNIX system which has \verb|awk| so it too spans
1244 many systems, although it is UNIX-specific while {\MI} is not.
1245
1246 {\MI} is easy to use. It is monolithic and covers almost every conceivable
1247 case likely to occur. We actually examined many of the books in the
1248 Addison-Wesley Computer Science Series and found that more than 95\% of the
1249 cases could be handled by the program. The \verb|make.index| suite, on the
1250 other hand, handles the standard cases and all customizations must be done
1251 by the user by modifying \verb|awk| code. With {\MI}, user changes will
1252 very rarely occur. If they should occur, and we have never had them happen,
1253 then the user must change the C source code. The question as to whether it is
1254 easier to modify \verb|awk| code or C code is left to the reader.
1255 Our answer is given in {\MI}.
1256
1257
1258 \section{Acknowledgements}
1259 We would like to thank Leslie Lamport for his collaboration in the design
1260 of {\MI}. He provided the initial specification and did some serious testing.
1261 Charles Karney furnished the patches for {\MI} to run under VMS.
1262 Nelson Beebe ported {\MI} to TOPS-20 and MS/DOS.
1263 Some useful feedback came from Art Werschulz who tried out both {\MI}
1264 and the index placing facility with {\AmSTeX}.
1265 We are grateful to Richard Beach for his description of {\TG}'s
1266 index processing facility, to Ravi Sethi for the information on {\TF}'s
1267 index processing tools, and to Ventura Software, Inc. for giving us
1268 documentation on their indexing mechanism.
1269 Thanks also go to Ethan Munson and the anonymous referees for their helpful
1270 comments on earlier drafts of this paper.
1271
1272 % Bibliography
1273 % \bibliography{int,doc,env,hyper}
1274 % \bibliographystyle{unsrt}
1275
1276 {\small
1277 \input ind.bbl
1278 }
1279 \input{indminus.tex}