summaryrefslogtreecommitdiff
path: root/indexing/makeindexk/makeindex.1
blob: eb2efeb226d95904395909c4bb1fc7ca30b0804f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
.if t .ds LX L\\h'-0.36m'\\v'-0.15v'\\s-2A\\s+2\\h'-0.15m'\\v'0.15v'T\\h'-0.1667m'\\v'0.20v'E\\v'-0.20v'\\h'-0.125m'X
.if n .ds LX LaTeX
.if t .ds TX T\\h'-0.1667m'\\v'0.20v'E\\v'-0.20v'\\h'-0.125m'X
.if n .ds TX TeX
.ds Ts T\s-2RAN\s+2S\s-2CRIPT\s+2
.if t .ds Uc \fIU\\h'-0.12m'C\\v'0.27m'\\h'-.23m'S\\h'-0.11m'F\\v'-0.27m'\fP
.if n .ds Uc UCSF
.ds Et \\f(boE\\h'-0.1667m'\\v'-0.20v'T\\v'0.20v'\\h'-0.125m'T\\fP
.TH MAKEINDEX 1 "12 November 2014" "TeX Live" "TeX Live"
.\"=====================================================================
.SH NAME
makeindex \- a general purpose, formatter-independent index processor
.SH SYNOPSIS
.B makeindex
.RB [ \-c ]
.RB [ \-g ]
.RB [ \-i ]
.RB [ \-l ]
.RB [ \-o
.IR ind ]
.RB [ \-p
.IR num ]
.RB [ \-q ]
.RB [ \-r ]
.RB [ \-s
.IR sfile ]
.RB [ \-t
.IR log ]
.RB [ \-L ]
.RB [ \-T ]
.RI [ idx0
.I idx1
.IR idx2 .\|.\|.]
.\"=====================================================================
.SH DESCRIPTION
The program
.I makeindex
is a general purpose hierarchical index generator; it accepts one or
more input files (often produced by a text formatter such as \*(TX
.RI ( tex (1L))
or
.IR troff (1),
sorts the entries, and produces an output file which can be formatted.
The index can have up to three levels (0, 1, and 2) of subitem nesting.
The way in which words are flagged for indexing within the main document
is specific to the formatter used;
.I makeindex
does
.I not
automate the process of selecting these words.  As the output index
is hierarchical,
.I makeindex
can be considered complementary to the
.IR awk (1)-based
.IR make.index (1L)
system of Bentley and Kernighan, which is specific to
.IR troff (1),
generates non-hierarchical indices, and employs a much simpler syntax
for indicating index entries.  For illustration of use with
.I troff
and
.IR \*(TX ,
see the section \s-2EXAMPLES\s+2 below.
.LP
The formats of the input and output files are
specified in a style file; by default, input is assumed to be a
.I \&.idx
file, as generated by \*(LX.
.LP
Unless specified explicitly, the base name of the first input file
.RI ( idx0 )
is used to determine the names of other files.  For each input file
name specified, a file of that name is sought.  If this file is not
found and the file name has no extension, the extension
.I \&.idx
is appended.  If no file with this name is found,
.I makeindex
aborts.
.LP
If exactly one input file was given and no explicit style file was
specified using
.BR \-s ,
.I makeindex
uses a file with the extension
.I \&.mst
as default style file (when present).
.LP
For important notes on how to select index keywords, see the document
by Lamport cited below.  As an issue separate from selecting index
keywords, a systematic mechanism for placing index terms in a document
is suggested in
.IR "Index Preparation and Processing" ,
a paper cited below.
.\"=====================================================================
.SH OPTIONS
.TP 10
.B \-c
Compress intermediate blanks (ignoring leading and trailing blanks and
tabs).  By default, blanks in the index key are retained.
.TP 10
.B \-g
Employ German word ordering in the index, in accord with rules set forth
in DIN 5007.  By default,
.I makeindex
employs a word ordering in which precedence is: symbols, numbers,
uppercase letters, lowercase letters.  The sequence in German word
ordering is: symbols, lowercase letters, uppercase letters, numbers.
Additionally, this option enables
.I makeindex
to recognize the German \*(TX-commands {"a, "o, "u and "s} as {ae, oe,
ue and ss} during the sorting of the entries.  The quote character
must be redefined in a style file (for example, redefine quote
as '+').  If the quote character is not redefined,
.I makeindex
will produce an error message and abort.
.TP 10
.B \-i
Take input from
.IR stdin .
When this option is specified and
.B \-o
is not, output is written to
.IR stdout .
.TP 10
.B \-l
Letter ordering; by default, word ordering is used (see
the \s-2ORDERING\s+2 section).
.TP 10
.BI \-o " ind"
Employ
.I ind
as the output index file.  By default, the file name
is created by appending the extension
.I .ind
to the base name of
the first input file
.RI ( idx0 ).
.TP 10
.BI \-p " num"
Set the starting page number of the output index file to be
.I num
(useful when the index file is to be formatted separately).  The
argument
.I num
may be numerical or one of the following:
.RS
.TP 10
.I any
The starting page is the last source page number plus 1.
.TP
.I odd
The starting page is the first odd page following the last source page
number.
.TP
.I even
The starting page is the first even page following the last source
page number.
.RE
.IP
The last source page is obtained by searching backward in the log file
for the first instance of a number included within paired square
brackets
.RB ( [ .\|.\|. ] ).
If a page number is missing or the log file is not found, no attempt
will be made to set the starting page number.  The source log file
name is determined by appending the extension
.I \&.log
to the base name of the first input file
.RI ( idx0 ).
.TP 10
.B \-q
Quiet mode; send no messages to
.IR stderr .
By default, progress
and error messages are sent to
.I stderr
as well as to the
transcript file.
.TP 10
.B \-r
Disable implicit page range formation; page ranges must be created by
using explicit range operators; see \s-2SPECIAL EFFECTS\s+2 below.  By
default, three or more successive pages are automatically abbreviated
as a range (e.g. 1\(em5).
.TP 10
.BI \-s " sty"
Employ
.I sty
as the style file (no default).  The environment
variable \s-2INDEXSTYLE\s+2 defines the path where the style file
should be found.
.TP 10
.BI \-t " log"
Employ
.I log
as the transcript file.  By default, the file name is
created by appending the extension
.I .ilg
to the base name of the
first input file
.RI ( idx0 ).
.TP 10
.BR \-L
sort based on locale settings. Not available on all systems.
.TP 10
.BR \-T
special support for Thai documents. Not available on all systems.
.\"=====================================================================
.SH "STYLE FILE"
The style file informs
.I makeindex
about the format of the
.I \&.idx
input files and the intended format of the final output file; examples
appear below.  This file can reside anywhere in the path defined by
the environment variable \s-2INDEXSTYLE\s+2.  The style file contains
a list of
.RI < specifier , " attribute" >
pairs.  There are two types of specifiers: input and output.
Pairs do not have to appear in any particular order.
A line begun by `%' is a comment.  In the following list of
specifiers and arguments, <string> is an arbitrary string delimited by
double quotes (".\|.\|."), <char> is a single letter embraced by
single quotes ('.\|.\|.'), and <number> is a nonnegative integer.
The maximum length of a <string> is 2048.  A literal backslash or
quote must be escaped (by a backslash).  Anything not specified in the
style file will be assigned a default value, which is shown at the
head of the rightmost column.
.\"----------------------------------------------------------------------
.SS "INPUT STYLE SPECIFIERS"
.TP 25
.BR actual " <char>"
\'@\'
.RS
Symbol indicating that the next entry is to appear in the output file.
.RE
.TP
.BR arg_close " <char>"
\'}\'
.RS
Closing delimiter for the index entry argument.
.RE
.TP
.BR arg_open " <char>"
\'{\'
.RS
Opening delimiter for the index entry argument.
.RE
.TP
.BR encap " <char>"
\'|\'
.RS
Symbol indicating that the rest of the argument list
is to be used as the encapsulating command for the page number.
.RE
.TP
.BR escape " <char>"
\'\\\\\'
.RS
Symbol which escapes the following letter, unless its preceding letter
is
.BR escape .
Note:
.B quote
is used to escape the letter which immediately follows it, but if it is
preceded by
.BR escape ,
it is treated as a ordinary character.  These two symbols
.I must
be distinct.
.RE
.TP
.BR keyword " <string>"
"\\\\indexentry"
.RS
Command which tells
.I makeindex
that its argument is an index entry.
.RE
.TP
.BR level " <char>"
\'!\'
.RS
Delimiter denoting a new level of subitem.
.RE
.TP
.BR page_compositor " <string>"
"-"
.RS
Delimiter separating parts of a composite page number (see
\s-2SPECIAL EFFECTS\s+2 below).
.RE
.TP
.BR quote " <char>"
\'"\'
.RS
Note:
.B quote
is used to escape the letter which immediately follows it, but if it is
preceded by
.BR escape ,
it is treated as a ordinary character.  These two symbols
.I must
be distinct.
.RE
.TP
.BR range_close " <char>"
\')\'
.RS
Closing delimiter indicating the end of an explicit page range.
.RE
.TP
.BR range_open " <char>"
\'(\'
.RS
Opening delimiter indicating the beginning of an explicit page range.
.RE
.\"---------------------------------------------------------------------
.SS "OUTPUT STYLE SPECIFIERS"
.TP 25
.BR preamble " <string>"
"\\\\begin{theindex}\\n"
.RS
Preamble of output file.
.RE
.TP
.BR postamble " <string>"
"\\n\\n\\\\end{theindex}\\n"
.RS
Postamble of output file.
.RE
.TP
.BR setpage_prefix " <string>"
"\\n  \\\\setcounter{page}{"
.RS
Prefix of command which sets the starting page number.
.RE
.TP
.BR setpage_suffix " <string>"
"}\\n"
.RS
Suffix of command which sets the starting page number.
.RE
.TP
.BR group_skip " <string>"
"\\n\\n  \\\\indexspace\\n"
.RS
Vertical space to be inserted before a new group begins.
.RE
.TP
.BR headings_flag " <string>"
0
.RS
Flag indicating treatment of new group headers, which are inserted
when before a new group (symbols, numbers, and the 26 letters):
positive values cause an uppercase letter to be inserted between
prefix and suffix, and negative values cause a lowercase letter to be
inserted (default is 0, which produces no header).
.RE
.TP
.BR heading_prefix " <string>"
""
.RS
Letter heading prefix to be inserted before a new letter begins.
.RE
.TP
.BR heading_suffix " <string>"
""
.RS
Letter heading suffix to be inserted when a new letter begins.
.RE
.TP
.BR symhead_positive " <string>"
"Symbols"
.RS
Heading for symbols to be inserted if
.B headings_flag
is positive.
.RE
.TP
.BR symhead_negative " <string>"
"symbols"
.RS
Heading for symbols to be inserted if
.B headings_flag
is negative.
.RE
.TP
.BR numhead_positive " <string>"
"Numbers"
.RS
Heading for numbers to be inserted if
.B headings_flag
is positive.
.RE
.TP
.BR numhead_negative " <string>"
"numbers"
.RS
Heading for numbers to be inserted if
.B headings_flag
is negative.
.RE
.TP
.BR item_0 " <string>"
"\\n  \\\\item "
.RS
Command to be inserted between two primary (level 0) items.
.RE
.TP
.BR item_1 " <string>"
"\\n     \\\\subitem "
.RS
Command to be inserted between two secondary (level 1) items.
.RE
.TP
.BR item_2 " <string>"
"\\n       \\\\subsubitem "
.RS
Command to be inserted between two level 2 items.
.RE
.TP
.B item_01 " <string>"
"\\n    \\\\subitem "
.RS
Command to be inserted between a level 0 item and a level 1 item.
.RE
.TP
.BR item_x1 " <string>"
"\\n    \\\\subitem "
.RS
Command to be inserted between a level 0 item and a level 1 item,
where the level 0 item does not have associated page numbers.
.RE
.TP
.BR item_12 " <string>"
"\\n    \\\\subsubitem "
.RS
Command to be inserted between a level 1 item and a level 2 item.
.RE
.TP
.BR item_x2 " <string>"
"\\n    \\\\subsubitem "
.RS
Command to be inserted between a level 1 item and a level 2 item,
where the level 1 item does not have associated page numbers.
.RE
.TP
.BR delim_0 " <string>"
", "
.RS
Delimiter to be inserted between a level 0 key and its first page number
(default: comma followed by a blank).
.RE
.TP
.BR delim_1 " <string>"
", "
.RS
Delimiter to be inserted between a level 1 key and its first page number
(default: comma followed by a blank).
.RE
.TP
.BR delim_2 " <string>"
", "
.RS
Delimiter to be inserted between a level 2 key and its first page number
(default: comma followed by a blank).
.RE
.TP
.BR delim_n " <string>"
", "
.RS
Delimiter to be inserted between two page numbers for the same key
in any level (default: comma followed by a blank).
.RE
.TP
.BR delim_r " <string>"
"--"
.RS
Delimiter to be inserted between the starting and ending page numbers
of a range.
.RE
.TP
.BR delim_t " <string>"
""
.RS
Delimiter to be inserted at the end of a page list.  This delimiter
has no effect on entries which have no associated page list.
.RE
.TP
.BR encap_prefix " <string>"
"\\\\"
.RS
First part of prefix for the command which encapsulates the page number.
.RE
.TP
.BR encap_infix " <string>"
"{"
.RS
Second part of prefix for the command which encapsulates the page
number.
.RE
.TP
.BR encap_suffix " <string>"
"}".
.RS
Suffix for the command which encapsulates the page number.
.RE
.TP
.BR page_precedence " <string>"
"rnaRA".
.RS
Page type precedence order.  The default specifies: lowercase roman,
numeric/arabic, lowercase alphabetic, uppercase roman, uppercase alphabetic.
.RE
.TP
.BR line_max " <number>"
72
.RS
Maximum length of a line in the output, beyond which a line wraps.
.RE
.TP
.BR indent_space " <string>"
"\\t\\t"
.RS
Space to be inserted in front of a wrapped line (default: two tabs).
.RE
.TP
.BR indent_length " <number>"
16
.RS
Length of
.B indent_space
(default: 16, equivalent to 2 tabs).
.RE
.TP
.BR suffix_2p " <string>"
""
.RS
Delimiter to replace the range delimiter and the second page number of
a two page list. When present, it overrides
.BR delim_r .
Example: "f.".
.RE
.TP
.BR suffix_3p " <string>"
""
.RS
Delimiter to replace the range delimiter and the second page number of
a three page list. When present, it overrides
.B delim_r
and
.BR suffix_mp .
Example: "ff.".
.RE
.TP
.BR suffix_mp " <string>"
""
.RS
Delimiter to replace the range delimiter and the second page number of
a multiple page list (three or more pages). When present, it overrides
.BR delim_r .
Example: "f.".
.RE
.\"=====================================================================
.SH EXAMPLES
.\"---------------------------------------------------------------------
.SS "\*(TX EXAMPLE"
The following example shows a style file called
.IR book.ist ,
which defines an index for a book which can be formatted independently
of the main source:
.LP
.RS
.nf
\fCpreamble
"\\\\documentstyle[12pt]{book}
\\\\begin{document}
\\\\begin{theindex}
{\\\\small\\n"
postamble
"\\n\\n}
\\\\end{theindex}
\\\\end{document}\\n\fP"
.fi
.RE
.LP
Assuming that a particular book style requires the index (as well as any
chapters) to start from an odd page number, and that the input file is
named
.IR foo.idx ,
the following command line produces output in file
.IR footmp.ind :
.LP
.RS
\fCmakeindex  \-s book.ist  \-o footmp.ind  \-p odd  foo\fP
.RE
.LP
Here a non-default output file name is used to avoid clobbering the
output for the book itself (presumably
.IR foo.dvi ,
which would have been the default name for the index output file!).
.\"---------------------------------------------------------------------
.SS "TROFF EXAMPLE"
A sample control file for creating an index, which we will assume
resides in the file
.IR sample.ist :
.LP
.RS
.nf
\&\fCkeyword "IX:"
\&preamble
\&".\\\\\\" start of index output
\&\\".\\\\\\" enter two column mode
\&.2C
\&.SH
\&.ce
\&INDEX
\&.XS
\&INDEX
\&.XE
\&.R
\&.ps 9p
\&.vs 11p
\&.sp
\&.de I1
\&.ti 0.25i
\&..
\&.de I2
\&.ti 0.5i
\&.."
\&postamble "\\n.\\\\\\" end of index output"
\&setpage_prefix "\\n.nr % "
\&setpage_suffix ""
\&group_skip "\\n.sp 1.0"
\&headings_flag 1
\&heading_prefix "\\n.IS\\n"
\&heading_suffix "\\n.IE"
\&item_0 "\\n.br\\n"
\&item_1 "\\n.I1\\n"
\&item_2 "\\n.I2\\n"
\&item_01 "\\n.I1\\n"
\&item_x1 "\\n.I1\\n"
\&item_12 "\\n.I2\\n"
\&item_x2 "\\n.I2\\n"
\&delim_0 ", "
\&delim_1 ", "
\&delim_2 ", "
\&delim_r "-"
\&delim_t "."
\&encap_prefix "\\\\fB"
\&encap_infix ""
\&encap_suffix "\\\\fP"
\&indent_space ""
\&indent_length 0\fP
.fi
.RE
.LP
The local macro package may require modification, as in this example
of an extension to the
.B \-ms
macros (note that at some sites, this macro should
.I replace
a pre-existing macro of the same name):
.LP
.RS
.nf
\fC\&.\" IX - index words to stderr
\&.de IX
\&.ie '\\\\n(.z'' .tm IX: \\\\$1 \\\\$2 \\\\$3 \\\\$4 \\\\$5 \\\\$6 \\\\$7 \\\\$8 \\\\$9 {\\\\n(PN}
\&.el \\\\!.IX \\\\$1 \\\\$2 \\\\$3 \\\\$4 \\\\$5 \\\\$6 \\\\$7 \\\\$8 \\\\$9 {\\\\n(PN}
\&..\fP
.fi
.RE
.LP
(note that the string {\fC\\\\n(PN\fP} is separated from the rest of the
line by a tab.
If your local macro package does not contain this extension,
just include those lines at the beginning of your file.
Here is a simple
.IR troff (1)
input file, which we will assume is named
.IR sample.txt :
.LP
.RS
.nf
\fC\&This is a sample file to test the \\fImakeindex\\fP(1L)
\&program, and see
\&.IX {indexing!programs!C language}
\&.IX {makeindex@\\fImakeindex\\fP(1L)}
\&.bp
\&.rs
\&.IX {Knuth}
\&.IX {typesetting!computer-aided}
\&how well it functions in the \\fItroff\\fP(1) environment.\fP
.fi
.RE
.LP
Note that index entries are indicated by the
.B .IX
macro, which
causes the following text to be written to
.I stdout
along with the
current page number.
.\"---------------------------------------------------------------------
.SS "CREATING THE INDEX FILE IN THE BOURNE SHELL"
To create an input file for
.IR makeindex ,
.B "in the Bourne shell"
environment, do the equivalent at your site of the command:
.LP
.nf
\fCpsroff -ms -Tpsc -t sample.txt > /dev/null 2> sample.tmp\fP
.fi
.LP
Some sites will require
.I ditroff
instead of
.IR psroff .
To filter out any genuine error messages, invoke
.IR grep (1):
.LP
.RS
\fCgrep '^IX: ' sample.tmp > sample.idx\fP
.RE
.\"---------------------------------------------------------------------
.SS "CREATING THE INDEX FILE USING \*(Uc ENHANCED TROFF/\*(Ts"
With \*(Uc Enhanced troff/\*(Ts, the
.B \-I
option of
.IR psroff (1L)
can produce both formatter output and an index file:
.LP
.RS
\fCpsroff -ms -I sample.inp -Tpsc sample.txt\fP
.RE
.LP
If it is wished to suppress the formatter output:
.RS
.LP
.nf
\fCpsroff -ms -I sample.inp -Tpsc -t sample.txt > /dev/null\fP
.fi
.RE
.\"---------------------------------------------------------------------
.SS "COMPLETING THE INDEX"
Any of the above procedures leaves the input for
.I makeindex
in
.IR sample.inp .
The next step is to invoke
.IR makeindex :
.LP
.RS
\fCmakeindex -s sample.ist sample.idx\fP
.RE
.LP
This leaves
.IR troff (1)-ready
output in the file
.IR sample.ind .
.\"=====================================================================
.SH "ORDERING"
By default,
.I makeindex
assumes
.IR "word ordering" ;
if the
.B \-l
option is in effect,
.I "letter ordering"
is used.  In word ordering, a blank precedes any letter in the
alphabet, whereas in letter ordering, it does not count at all.  This
is illustrated by the following example:
.LP
.RS
\fIword order                      letter order\fP
.br
sea lion                        seal
.br
seal                            sea lion
.RE
.LP
Numbers are always sorted in numeric order.  For instance,
.LP
.RS
9 (nine),  123
.br
10 (ten), see Derek, Bo
.RE
.LP
Letters are first sorted without regard to case; when words are
identical, the uppercase version precedes its lowercase counterpart.
.LP
A special symbol is defined here to be any character not appearing in
the union of digits and the English alphabetic characters.  Patterns
starting with special symbols precede numbers, which precede patterns
starting with letters.  As a special case, a string starting with a
digit but mixed with non-digits is considered to be a pattern starting
with a special character.
.\"=====================================================================
.SH "SPECIAL EFFECTS"
Entries such as
.LP
.RS
.nf
\fC\\indexentry{alpha}{1}
\\indexentry{alpha!beta}{3}
\\indexentry{alpha!beta!gamma}{10}\fP
.fi
.RE
.LP
in the input file will be converted to
.LP
.RS
.nf
\fC\\item alpha, 1
\0\0\0\\subitem beta, 3
\0\0\0\0\0\0\\subsubitem gamma, 10\fP
.fi
.RE
.LP
in the output index file.
Notice that the
.B level
symbol (`!') is used above to delimit
hierarchical levels.
.LP
It is possible to make an item appear in a designated form by
using the
.B actual
(`@') operator.  For instance,
.LP
.RS
\fC\\indexentry{alpha@{\\it alpha\\/}}{1}\fP
.RE
.LP
will become
.LP
.RS
\fC\\item {\\it alpha\\/},  1\fP
.RE
.LP
after processing.  The pattern preceding `@' is
used as sort key, whereas the one following it is written to the
output file.  Note that two appearances of the same key, one with and
one without the
.B actual
operator, are regarded as
.I distinct
entries.
.LP
The item, subitem, and subsubitem fields may have individual sort keys:
.LP
.RS
.nf
\fC\\indexentry{aa@{\\it aa\\/}!bb@{\\it bb\\/}!cc@{\\it cc\\/}}{1}\fP
.fi
.RE
.LP
This will be converted to
.LP
.RS
.nf
\fC\\item {\\it aa}, 1
\0\0\0\\subitem {\\it bb}, 3
\0\0\0\0\0\0\\subsubitem {\\it cc}, 10\fP
.fi
.RE
.LP
It is possible to encapsulate a page number with a designated
command using the
.B encap
(`|') operator:
.LP
.RS
\fC\\indexentry{alpha|bold}{1}\fP
.RE
.LP
will be converted to
.LP
.RS
\fC\\item alpha, \\bold{1}\fP
.RE
.LP
where, with a suitable definition for \*(TX, \fC\\bold{n}\fP
will expand to \fC{\\bf n}\fP.
In this example, the three output attributes associated with page
encapsulation
.BR encap_prefix ,
.BR encap_infix ,
and
.BR encap_suffix ,
correspond to backslash, left brace, and right brace, respectively.
This mechanism allows page numbers to be set in different fonts.  For
example, the page where the definition of a keyword appears can be in
one font, the location of a primary example can be in another font,
and other appearances in yet a third font.
.LP
The
.B encap
operator can also be used to create cross references in
the index:
.LP
.RS
\fC\\indexentry{alpha|see{beta}}{1}\fP
.RE
.LP
will become
.LP
.RS
\fC\\item alpha, \\see{beta}{1}\fP
.RE
.LP
in the output file, where
.LP
.RS
\fC\\see{beta}{1}\fP
.RE
.LP
will expand to
.LP
.RS
\fC{\\it see\\/} beta\fP
.RE
.LP
Note that in a cross reference like this the page number disappears.
.LP
A pair of
.B encap
concatenated with
.B range_open
(`|(') and
.B range_close
(`|)') creates an explicit page range:
.LP
.RS
.nf
\fC\\indexentry{alpha|(}{1}
\\indexentry{alpha|)}{5}\fP
.fi
.RE
.LP
will become
.LP
.RS
\fC\\item alpha, 1\(em5\fP
.RE
.LP
Intermediate pages indexed by the same key will be merged into the
range implicitly.  This is especially useful when an entire section
about a particular subject is to be indexed, in which case only the
range opening and closing operators need to be inserted at the
beginning and end of the section.  Explicit page range formation can
also include an extra command to set the page range in a designated
font:
.LP
.RS
.nf
\fC\\indexentry{alpha|(bold}{1}
\\indexentry{alpha|)}{5}\fP
.fi
.RE
.LP
will become
.LP
.RS
\fC\\item alpha, \\bold{1--5}\fP
.RE
.LP
Several potential problems are worth mentioning.  First, entries like
.LP
.RS
.nf
\fC\\indexentry{alpha|(}{1}
\\indexentry{alpha|bold}{3}
\\indexentry{alpha|)}{5}\fP
.fi
.RE
.LP
will be interpreted as
.LP
.RS
\fC\\item alpha, \\bold{3}, 1--5\fP
.RE
.LP
but with a warning message in the transcript about encountering an
inconsistent page encapsulator.
An explicit range beginning in a Roman page number and ending
in Arabic is also considered an error.  In this instance, (if
possible) the range is broken into two subranges, one in Roman and the
other in Arabic.  For instance,
.LP
.RS
.nf
\fC\\indexentry{alpha|(}{i}
\\indexentry{alpha}{iv}
\\indexentry{alpha}{3}
\\indexentry{alpha|)}{7}\fP
.fi
.RE
.LP
will be turned into
.LP
.RS
\fC\\item alpha, i--iv, 3--7\fP
.RE
.LP
with a warning message in the transcript file complaining about an
illegal range formation.
.LP
Every special symbol mentioned in this section may be
escaped by the
.B quote
operator (`"').  Thus
.LP
.RS
\fC\\indexentry{alpha"@beta}{1}\fP
.RE
.LP
will actually become
.LP
.RS
\fC\\item alpha@beta,  1\fP
.RE
.LP
as a result of executing
.IR makeindex .
The quoting power of
.B quote
is eliminated if it is immediately preceded
by
.B escape
(`\\').  For example,
.LP
.RS
\fC\\indexentry{f\\"ur}{1}\fP
.RE
.LP
becomes
.LP
.RS
\fC\\item f\\"ur, 1\fP
.RE
.LP
which represents an umlaut-accented `u' to the \*(TX family of
processors.
.LP
A page number can be a composite of one or more fields
separated by the delimiter bound to
.B page_compositor
(`-'), e.g., II-12 for page 12 of Chapter II.  Page numbers may
contain up to ten fields.
.PP
Since version 2.11 of
.IR makeindex ,
the
.B quote
operator may quote
.I any
character in the range 1 .\|.\|. 255.   Character 0 is excluded because
it is used internally in the
.I makeindex
source code as a string terminator.  With this change, sort keys can
be created for all eight-bit characters except 0.  The sorting order
is
.RS
.nf

punctuation characters (in ASCII order),
digits,
control characters (1 .\|.\|. 31),
space (32),
letters (ignoring case),
characters 127 .\|.\|. 255.

.fi
.RE
Here is an example showing the indexing of all printable ASCII
characters other than letters and digits, assuming the default
\*(TX format.  For convenience, the page number references are
the corresponding ASCII ordinal values.
.RS
.nf

\fC\\indexentry{" @"  (space)}{32}
\\indexentry{"!@"! (exclamation point)}{33}
\\indexentry{""@"" (quotation mark)}{34}
\\indexentry{"#@"\\# (sharp sign)}{35}
\\indexentry{"$@"\\$ (dollar sign)}{36}
\\indexentry{"%@"\\% (percent sign)}{37}
\\indexentry{"&@"\\& (ampersand)}{38}
\\indexentry{"<@"$<$ (left angle bracket)}{60}
\\indexentry{"=@"= (equals)}{61}
\\indexentry{">@"$>$ (right angle bracket)}{62}
\\indexentry{"?@"? (query)}{63}
\\indexentry{"@@"@ (at sign)}{64}
\\indexentry{"[@"[ (left square bracket)}{91}
\\indexentry{"\\@"\\verb=\\= (backslash)}{92}
\\indexentry{"]@"] (right square bracket)}{93}
\\indexentry{"^@"\\verb=^= (caret)}{94}
\\indexentry{"_@"\\verb=_= (underscore)}{95}
\\indexentry{"`@"\\verb=~= (grave accent)}{96}
\\indexentry{"{@"\\"{ (left brace)}{123}
\\indexentry{"|@"\\verb="|= (vertical bar)}{124}
\\indexentry{"}@"\\"} (right brace)}{125}
\\indexentry{"~@"\\verb=~= (tilde)}{126}\fP

.fi
.RE
Characters in the actual fields following the `@' character which
have special significance to \*(TX must be represented as control
sequences, or as math mode characters.  Note particularly how the
entries for the at sign, left and right braces, and the vertical
bar, are coded.  The index file output by
.I makeindex
for this example looks like this:
.RS
.nf

\fC\\begin{theindex}

  \\item ! (exclamation point), 33
  \\item " (quotation mark), 34
  \\item \\# (sharp sign), 35
  \\item \\$ (dollar sign), 36
  \\item \\% (percent sign), 37
  \\item \\& (ampersand), 38
  \\item $<$ (left angle bracket), 60
  \\item = (equals), 61
  \\item $>$ (right angle bracket), 62
  \\item ? (query), 63
  \\item @ (at sign), 64
  \\item [ (left square bracket), 91
  \\item \\verb=\\= (backslash), 92
  \\item ] (right square bracket), 93
  \\item \\verb=^= (caret), 94
  \\item \\verb=_= (underscore), 95
  \\item \\verb=~= (grave accent), 96
  \\item \\{ (left brace), 123
  \\item \\verb=|= (vertical bar), 124
  \\item \\} (right brace), 125
  \\item \\verb=~= (tilde), 126

  \\indexspace

  \\item   (space), 32

\\end{theindex}\fP
.fi
.RE
.\"=====================================================================
.SH "FILES"
.TP 2.2i
.I makeindex
executable file
.TP
.I $TEXMFMAIN/tex/plain/makeindex/idxmac.tex
\*(TX macro file used by
.I makeindex
.TP
.I $TEXMFMAIN/tex/latex/base/makeidx.sty
\*(TX macro file used by
.I makeindex
.\"=====================================================================
.SH "SEE ALSO"
ditroff(1L),
latex(1L),
make.index (1L),
qsort(3),
tex(1L),
troff(1L)
.LP
.IR "\*(Uc Enhanced troff/\*(Ts \(em An Overview" ,
R. P. C. Rodgers and Conrad Huang, LSMB Technical Report 90-2,
UCSF School of Pharmacy, San Francisco, 1990.
.LP
.IR "Index Preparation and Processing" ,
Pehong Chen and Michael A. Harrison,
.IR "Software: Practice and Experience" ,
.BR 19 (9),
897\(en915,
September 1988.
.LP
.IR "Automating Index Preparation" ,
Pehong Chen and Michael A. Harrison.  Technical Report 87/347,
Computer Science Division, University of California, Berkeley, 1987
(a \*(LX document supplied with
.IR makeindex ).
.LP
.IR "MakeIndex: An Index Processor for \*(LX" ,
Leslie Lamport, February 1987 (a \*(LX document supplied
with
.IR makeindex ).
.LP
.IR "Tools for Printing Indices" ,
Jon L. Bentley and Brian W. Kernighan,
.IR "Electronic Publishing \(em Origination, Dissemination, and Design" ,
1(1), 3\(en18, June 1988 (also available as: Computing Science
Technical Report No. 128,
AT&T Bell Laboratories, Murray Hill, NJ 07974, 1986).
.\"=====================================================================
.SH "AUTHOR"
Pehong Chen, Chen & Harrison International Systems, Inc.
Palo Alto, California, USA.
.br
Manual page extensively revised and corrected, and
.IR troff (1)
examples created by Rick P. C. Rodgers, UCSF School
of Pharmacy.
.\"=====================================================================
.SH ACKNOWLEDGMENTS
Leslie Lamport contributed significantly to the design of MakeIndex.
Michael Harrison provided valuable comments and suggestions.
Nelson Beebe improved on the portable version, and maintained the
source distribution for the \*(TX Users Group for many years.
Andreas Brosig contributed to the German word ordering.
The modification to the
.B \-ms
macros was derived from a method proposed by Ravi Sethi of AT&T
Bell Laboratories.
The
.I LOG
and
.I CONTRIB
files in the
.I makeindex
source distribution record other contributions.
.PP
.I makeindex
is currently maintained as part of the \*(TX Live
distribution (http://tug.org/texlive); please send bug reports to
tex-k@tug.org.