Debian Codegraph @

texmf-dist/source/latex/amscls/amsmidx.dtx

raw
1 % \def\filename{amsmidx.dtx}
2 % \def\fileversion{2.02}
3 % \def\filedate{2007/09/25}
4 %
5 % \iffalse meta-comment
6 %
7 % American Mathematical Society
8 % Technical Support
9 % Publications Technical Group
10 % 201 Charles Street
11 % Providence, RI 02904
12 % USA
13 % tel: (401) 455-4080
14 % (800) 321-4267 (USA and Canada only)
15 % fax: (401) 331-3842
16 % email: [email protected]
17 %
18 % Copyright 1995, 2004, 2009, 2010 American Mathematical Society.
19 %
20 % This work may be distributed and/or modified under the
21 % conditions of the LaTeX Project Public License, either version 1.3c
22 % of this license or (at your option) any later version.
23 % The latest version of this license is in
24 % http://www.latex-project.org/lppl.txt
25 % and version 1.3c or later is part of all distributions of LaTeX
26 % version 2005/12/01 or later.
27 %
28 % This work has the LPPL maintenance status `maintained'.
29 %
30 % The Current Maintainer of this work is the American Mathematical
31 % Society.
32 %
33 % \fi
34 %
35 % \iffalse
36 %<*driver>
37 \documentclass{amsdtx}
38 \begin{document}
39 \title{The \pkg{amsmidx} package}
40 \author{American Mathematical Society\\Barbara Beeton}
41 \date{Version \fileversion, \filedate}
42 \DocInput{amsmidx.dtx}
43 \end{document}
44 %</driver>
45 % \fi
46 %
47 % \maketitle
48 %
49 % \MakeShortVerb\|
50 %
51 % \section{Introduction}
52 %
53 % This package provides the facility to produce multiple indexes
54 % with \amslatex/ document classes (particularly \fn{amsbook} and
55 % the AMS author packages for books), superseding the built-in
56 % index facility which can accommodate only one index. This may
57 % in the future be incorporated as an option into the \amslatex/
58 % document classes.
59 %
60 % This package is based on \pkg{multind.sty} by F.W. Long.
61 %
62 % \StopEventually{}
63 %
64 % Standard file identification.
65 % \begin{macrocode}
66 \NeedsTeXFormat{LaTeX2e}[1995/06/01]
67 \ProvidesPackage{amsmidx}[2007/09/25 v2.02 multiple indexes for AMS classes]
68 % \end{macrocode}
69 %
70 % \section{User instructions}
71 %
72 % In the preamble, invoke \cn{makeindex} with a file name to provide
73 % as many indexes as desired:
74 %\begin{verbatim}
75 % \makeindex{filename-a}
76 % \makeindex{filename-b}
77 %\end{verbatim}
78 % This will initiate the creation of \fn{filename-a.idx} etc.
79 %
80 % In the body of the text, use the \cn{index} command with two
81 % arguments
82 %\begin{verbatim}
83 % \index{filename-a}{index term}
84 %\end{verbatim}
85 % as appropriate to populate the \fn{.idx} files.
86 %
87 % In the \cn{backmatter} segment of the driver file, insert the
88 % \cn{Printendex} command to print the indexes; the second argument
89 % gives the title to be printed at the top of the index:
90 %\begin{verbatim}
91 % \Printindex{filename-a}{First Index}
92 % \Printindex{filename-b}{Second Index}
93 %\end{verbatim}
94 %
95 % On the first pass, the \fn{.idx} files will be created. Process
96 % each \fn{.idx} file with \textit{MakeIndex} to generate an \fn{.ind}
97 % file, which will then be read in by \cn{Printindex}. Whenever any
98 % page references change, be sure to run \textit{MakeIndex} again,
99 % and process the entire job with \latex/ once more to get the correct
100 % page references in the indexes.
101 %
102 % To include a paragraph of comments below the index title, insert
103 % the text as an \cn{indexcomment} before the relevant \cn{Printindex}:
104 %\begin{verbatim}
105 % \indexcomment{Text of comments}
106 % \Printindex{...}{...}
107 %\end{verbatim}
108 % The \cn{indexcomment} text will be cleared after use.
109 %
110 %
111 % \section{Implementation}
112 %
113 % \begin{macro}{\makeindex}
114 % Redefine \cn{makeindex} to create a new \fn{.idx} file with the
115 % name provided by argument |#1|.
116 % \begin{macrocode}
117 \renewcommand{\makeindex}[1]{%
118 \begingroup
119 \makeatletter
120 \if@filesw \expandafter\newwrite\csname #1@idxfile\endcsname
121 \expandafter\immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
122 \typeout{Writing index file #1.idx }\fi
123 \endgroup}
124 % \end{macrocode}
125 % \end{macro}
126 %
127 % \begin{macro}{\index}
128 % Redefine \cn{index} to specify into which file/index the term is
129 % to be placed. Argument |#1| identifies the file, |#2| provides
130 % the text of the term to be indexed.
131 % \begin{macrocode}
132 \renewcommand{\index}[1]{%
133 \@bsphack
134 \begingroup
135 \def\protect##1{\string##1\space}\@sanitize\@wrindex{#1}}
136 % \end{macrocode}
137 % \end{macro}
138 %
139 % \begin{macro}{\@wrindex}
140 % \cs{@wrindex} checks to make sure that the requested file is available,
141 % and writes an entry into the file or emits an error message.
142 % \begin{macrocode}
143 \renewcommand{\@wrindex}[2]{%
144 \let\thepage\relax
145 \xdef\@gtempa{%
146 \@ifundefined{#1@idxfile}{%
147 \PackageError{\@packagename}{%
148 The requested file, #[email protected], does not exist;\MessageBreak
149 index term #2 will not be be written out.%
150 }%
151 }{%
152 \expandafter\write\csname #1@idxfile\endcsname
153 {\string\indexentry{#2}{\thepage}}%
154 }%
155 }%
156 \endgroup\@gtempa
157 \if@nobreak \ifvmode\nobreak\fi\fi
158 \@esphack
159 }
160 % \end{macrocode}
161 % \end{macro}
162 %
163 % \begin{macro}{\printindex}
164 % \begin{macro}{\Printindex}
165 % Redefine \cs{printindex} to specify the file to be included; provide
166 % an alternate command \cs{Printindex} that specifies both the file and
167 % the index title to be printed. Argument |#1| identifies the file,
168 % |#2| provides the title. Also modify some formatting commands to
169 % improve the appearance of index entries, especially long ones in
170 % the presence of three index levels.
171 % \begin{macrocode}
172 \renewcommand{\printindex}[1]{\@input{#1.ind}}
173 \newcommand{\Printindex}[2]{%
174 \begingroup
175 \cleardoublepage
176 \def\indexname{#2}%
177 \raggedright
178 \hyphenpenalty=10000
179 \renewcommand{\seename}{see~also}
180 \renewcommand{\subitem}{\par\hangindent 3em\hspace*{1em}}
181 \@input{#1.ind}%
182 \endgroup
183 }
184 % \end{macrocode}
185 % \end{macro}
186 % \end{macro}
187 %
188 % \begin{macro}{\indexcomment}
189 % \begin{macro}{\indexchap}
190 % Format comments in a block somewhat narrower than the full page
191 % width, and redefine \cn{indexchap} to insert the block below the
192 % title, before starting the two-column index. Clear out
193 % \cs{indexcomment} after use.
194 % \begin{macrocode}
195 \newdimen\@indexcommentwidth
196 \@indexcommentwidth=\textwidth
197 \ifdim\@indexcommentwidth > 26pc
198 \advance\@indexcommentwidth-6pc
199 \else
200 \advance\@indexcommentwidth-4pc
201 \fi
202 \newcommand{\indexcomment}[1]{%
203 \def\theindexcomment{%
204 \vskip\baselineskip
205 \parbox[t]{\@indexcommentwidth}{\normalsize\mdseries#1}%
206 }%
207 }
208 \let\theindexcomment\@empty
209 \renewcommand{\indexchap}[1]{%
210 \global\topskip 7.5pc\relax
211 \twocolumn[\fontsize{\@xivpt}{18}%
212 \vskip\topskip\vskip-\baselineskip\hbox{}% adjust top space
213 \bfseries\centering #1\par
214 \ifx\theindexcomment\@empty
215 \else \theindexcomment
216 \global\let\theindexcomment\@empty
217 \fi
218 ]%
219 \global\topskip 34\p@
220 }
221 % \end{macrocode}
222 % \end{macro}
223 % \end{macro}
224 %
225 % The usual \cs{endinput} to ensure that random garbage at the end of
226 % the file doesn't get copied by \fn{docstrip}.
227 % \begin{macrocode}
228 \endinput
229 % \end{macrocode}
230 %
231 % \CheckSum{131}
232 % \Finale