summaryrefslogtreecommitdiff
path: root/dviware/beebe/doc/myindex.sty
blob: 6bcd0da79042e1f51e3e6c18cf99f8fe4adbd645 (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
% -*-LaTeX-*-
% myindex.sty
%
% Indexing macro usage (producing a file for TeXidx to sort):
%	\INDEX{sortkey}{primary}
%	\SUBINDEX{sortkey}{primary}{secondary}
%
% For \SUBINDEX, the {secondary} field is automatically appended
% to the sort key, but separated from it by CTL-A (so that
% \SUBINDEX{foo}{foo}{bar} sorts before
% \SUBINDEX{foo}{foo}{baz} and
% \INDEX{foo bar}{foo bar}{bar} [the keys will be "foo<CTL-A>{bar}",
% "foo<CTL-A>{baz}", and "foo bar", respectively]
% TeX does not allow a control character in the input, so we
% actually output a "!" instead; it can be filtered back to
% a CTL-A using "sed -e 's/!/\001/' <infile >outfile", or we
% can make a special version of TeXidx that makes the change
% internally.
%
\makeatletter	% in case it wasn't
\def\initial#1{\section*{#1}}%
\def\entry#1#2{\item {#1}, #2}%
\def\primary#1{\item {#1}}%
\def\secondary#1#2{\subitem {#1}, #2}%
%
 \def\INDEX{\@bsphack\begingroup\@sanitize\@WRINDEX\@indexfile}%
%
 \def\@WRINDEX#1#2#3{\let\thepage\relax
     \xdef\@gtempa{\write#1{\string
      \entry{#2}{\thepage}{#3}}}\endgroup\@gtempa
     \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}%
%
  \def\SUBINDEX{\@bsphack\begingroup\@sanitize\@WRSUBINDEX\@indexfile}%
%
  \def\@WRSUBINDEX#1#2#3#4{\let\thepage\relax
     \xdef\@gtempa{\write#1{\string
      \entry{#3!{#4}}{\thepage}{#3}{#4}}}\endgroup\@gtempa
     \if@nobreak \ifvmode\nobreak\fi\fi\@esphack}%
%
\newcommand{\X}[1]{{#1}\INDEX{#1}{#1}}%
%
\makeatletter
\def\@xobeysp{\leavevmode\penalty10000\ } % prevent verbatim mode line breaks
\makeatother