| 1 |
% \def\filename{index.dtx} |
| 2 |
% \def\fileversion{4.04} |
| 3 |
% \def\filedate{2025/02/06} |
| 4 |
|
| 5 |
% \iffalse meta-comment |
| 6 |
% |
| 7 |
% David M. Jones |
| 8 |
% [email protected] |
| 9 |
% |
| 10 |
% Copyright 2024, 2025 David M. Jones |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either version 1.3 |
| 14 |
% of this license or (at your option) any later version. |
| 15 |
% The latest version of this license is in |
| 16 |
% https://www.latex-project.org/lppl.txt |
| 17 |
% and version 1.3c or later is part of all distributions of LaTeX |
| 18 |
% version 2008 or later. |
| 19 |
% |
| 20 |
% CAUTION: Use only as directed. Do not take internally. May cause |
| 21 |
% rash if applied directly to skin. Federal law prohibits distributing |
| 22 |
% without a proscription. |
| 23 |
% |
| 24 |
% This work has the LPPL maintenance status `maintained'. |
| 25 |
% |
| 26 |
% The Current Maintainer of this work is David M. Jones. |
| 27 |
% |
| 28 |
% \fi |
| 29 |
% |
| 30 |
% \iffalse |
| 31 |
%<*driver> |
| 32 |
\NeedsTeXFormat{LaTeX2e} |
| 33 |
\documentclass{ltxdoc} |
| 34 |
|
| 35 |
\DoNotIndex{\!,\/,\?,\@,\^,\_} |
| 36 |
\DoNotIndex{\@@par,\@M,\@auxout,\@bsphack,\@esphack,\@depth,\@ehc} |
| 37 |
\DoNotIndex{\@for,\@flushglue,\@gobble,\@gobbletwo,\@height,\@idxitem} |
| 38 |
\DoNotIndex{\@ifnextchar,\@ifstar,\@ifundefined,\@input,\@latexerr} |
| 39 |
\DoNotIndex{\@makeschapterhead,\@namedef,\@nameuse,\@nil} |
| 40 |
\DoNotIndex{\@nobreakfalse,\@restonecolfalse,\@restonecoltrue} |
| 41 |
\DoNotIndex{\@tempa,\@tempf,\@temptokena,\@themark,\@width} |
| 42 |
\DoNotIndex{\active,\aindex,\baselineskip,\begin,\begingroup,\box} |
| 43 |
\DoNotIndex{\c@page,\catcode,\chapter,\char,\chardef,\closeout} |
| 44 |
\DoNotIndex{\CodelineIndex,\sp,\sb,\label,\leavevmode,\mark} |
| 45 |
\DoNotIndex{\mark,\newinsert,\newwrite,\newtoks,\xdef} |
| 46 |
\DoNotIndex{\columnsep,\columnseprule,\columnwidth,\csname,\def} |
| 47 |
\DoNotIndex{\dimen,\do,\DocInput,\documentstyle,\edef,\em} |
| 48 |
\DoNotIndex{\EnableCrossrefs,\end,\endcsname,\endgroup,\endinput} |
| 49 |
\DoNotIndex{\everypar,\expandafter,\filedate,\fileversion} |
| 50 |
\DoNotIndex{\footnotesize,\gdef,\global,\glossary,\hangindent} |
| 51 |
\DoNotIndex{\if@filesw,\else,\fi} |
| 52 |
\DoNotIndex{\if@nobreak,\if@twocolumn,\if@twoside,\fi,\fi,\fi} |
| 53 |
\DoNotIndex{\hsize,\hskip} |
| 54 |
\DoNotIndex{\ifhmode,\ifmmode,\ifodd,\ifvmode,\ifx,\fi,\fi,\fi,\fi,\fi} |
| 55 |
\DoNotIndex{\immediate,\insert,\item,\jobname,\long} |
| 56 |
\DoNotIndex{\let,\lineskip,\marginparsep,\marginparwidth,\maxdimen} |
| 57 |
\DoNotIndex{\makeatletter,\noexpand,\openout,\protect,\rlap} |
| 58 |
\DoNotIndex{\min,\newpage,\nobreak,\normalbaselineskip} |
| 59 |
\DoNotIndex{\normallineskip,\p@,\par,\parfillskip,\parindent,\parskip} |
| 60 |
\DoNotIndex{\penalty,\relax,\section,\sin,\sloppy,\space,\string} |
| 61 |
\DoNotIndex{\tableofcontents,\the,\thepage,\thispagestyle,\toks,\tt} |
| 62 |
\DoNotIndex{\twocolumn,\uppercase,\vbox,\vrule,\vskip,\vss} |
| 63 |
\DoNotIndex{\write,\z@,\z@skip} |
| 64 |
|
| 65 |
\setcounter{StandardModuleDepth}{1} |
| 66 |
|
| 67 |
\newcommand*{\email}[1]{$\langle$\texttt{#1}$\rangle$} |
| 68 |
\newcommand*{\vdate}[1]{$\langle$#1$\rangle$} |
| 69 |
\newcommand*{\bundle}[1]{\texttt{#1}} |
| 70 |
\newcommand*{\program}[1]{\textsf{#1}} |
| 71 |
\newcommand*{\Ltag}[1]{\texttt{\bslash#1}} |
| 72 |
\newcommand*{\Lopt}[1]{\textsf {#1}} |
| 73 |
\newcommand*{\Lenv}[1]{\texttt {#1}} |
| 74 |
\newcommand*{\cls}[1]{\texttt {#1}} |
| 75 |
\newcommand*{\pck}[1]{\texttt {#1}} |
| 76 |
\newcommand*{\file}[1]{\texttt {#1}} |
| 77 |
\CodelineIndex |
| 78 |
|
| 79 |
\title{A new implementation of \LaTeX's indexing commands} |
| 80 |
|
| 81 |
\author{David M. Jones} |
| 82 |
|
| 83 |
\date{\filedate} |
| 84 |
|
| 85 |
\begin{document} |
| 86 |
|
| 87 |
\DocInput{index.dtx} |
| 88 |
|
| 89 |
\PrintIndex |
| 90 |
|
| 91 |
% ^^A\PrintChanges |
| 92 |
|
| 93 |
\end{document} |
| 94 |
%</driver> |
| 95 |
% \fi |
| 96 |
% |
| 97 |
% \maketitle |
| 98 |
% |
| 99 |
% \section{Introduction} |
| 100 |
% |
| 101 |
% This style file reimplements \LaTeX's indexing macros to provide |
| 102 |
% better and more robust support for indexes. In particular, it |
| 103 |
% provides the following features:\footnote{Earlier versions of |
| 104 |
% this package provided a ``shortindexing'' feature (see below for |
| 105 |
% description). This feature is now deprecated and will be removed |
| 106 |
% in a future release of this package.} |
| 107 |
% \begin{enumerate} |
| 108 |
% |
| 109 |
% \item |
| 110 |
% Support for multiple indexes. |
| 111 |
% |
| 112 |
% \item |
| 113 |
% Indexing of items by counters other than the page number. |
| 114 |
% |
| 115 |
% \item |
| 116 |
% A $*$-variant of the \cs{index} command that, in addition to |
| 117 |
% putting it's argument in the index, also typesets it in the |
| 118 |
% running text. |
| 119 |
% |
| 120 |
% \item |
| 121 |
% The \bundle{showidx} style option has been merged into this file. |
| 122 |
% The command \cs{proofmodetrue} can be used to enable the printing |
| 123 |
% of index entries in the margin of pages. The size and style of |
| 124 |
% font can be controlled with the \cs{indexproofstyle} command. |
| 125 |
% |
| 126 |
% \item |
| 127 |
% A two-stage process, similar to that used to create tables of |
| 128 |
% contents, for creating the raw index files. This means that when |
| 129 |
% processing a portion of a document using the \cs{includeonly} |
| 130 |
% command, the index entries from the rest of the document are not |
| 131 |
% lost. |
| 132 |
% |
| 133 |
% \item |
| 134 |
% A more robust \cs{index} command. In particular, it no longer |
| 135 |
% depends on \cs{catcode} changes to work properly, so the new |
| 136 |
% \cs{index} command can be used in places that the original |
| 137 |
% couldn't, such as inside the arguments of other macros. |
| 138 |
% |
| 139 |
% \end{enumerate} |
| 140 |
% |
| 141 |
% |
| 142 |
% \section{Creating an index with \LaTeX} |
| 143 |
% |
| 144 |
% Conceptually, there are four stages to creating an index. First, |
| 145 |
% \LaTeX\ must be informed of your intention to include an index in |
| 146 |
% your document. Second, you must add appropriate markup commands |
| 147 |
% to your document to tell \LaTeX\ what to put in the index. |
| 148 |
% Third, after \LaTeX\ has been run on your document, the raw index |
| 149 |
% information must be processed and turned into a form that \LaTeX\ |
| 150 |
% can process to typeset the index. Finally, the finished index |
| 151 |
% must be inserted at the appropriate point in your document. |
| 152 |
% |
| 153 |
% In \LaTeX, these steps are accomplished with the commands |
| 154 |
% \cs{makeindex}, \cs{index}, \cs{printindex}, and (typically) with |
| 155 |
% the auxiliary program \program{MakeIndex}. For example, assuming |
| 156 |
% that your main file is called \file{foo.tex}, \cs{makeindex} |
| 157 |
% opens the file \file{foo.idx} and initializes it for holding the |
| 158 |
% raw index entries, and \cs{index} is used to add raw index |
| 159 |
% entries into \file{foo.idx}. Then the raw index file is |
| 160 |
% processed by \program{MakeIndex}, which puts the finished index |
| 161 |
% in \file{foo.ind}. Finally, the \cs{printindex} command is used |
| 162 |
% in your \LaTeX\ document to indicate where the file |
| 163 |
% \file{foo.idx} should be inserted, i.e., where the index should |
| 164 |
% appear in your document. |
| 165 |
% |
| 166 |
% The \bundle{index} package modifies the \cs{makeindex}, |
| 167 |
% \cs{index}, and \cs{printindex} commands, as described below. |
| 168 |
% |
| 169 |
% |
| 170 |
% \section{The user interface} |
| 171 |
% |
| 172 |
% There are four pieces of information associated with each index: |
| 173 |
% \begin{enumerate} |
| 174 |
% |
| 175 |
% \item |
| 176 |
% A short, unique tag that identifies the index. |
| 177 |
% |
| 178 |
% \item |
| 179 |
% The extension of the output file where the raw index information |
| 180 |
% will be put by \LaTeX. |
| 181 |
% |
| 182 |
% \item |
| 183 |
% The extension of the input file where the processed information |
| 184 |
% created by \program{MakeIndex} will be stored to be read in later |
| 185 |
% by \LaTeX. |
| 186 |
% |
| 187 |
% \item |
| 188 |
% The title of the index. |
| 189 |
% |
| 190 |
% \end{enumerate} |
| 191 |
% |
| 192 |
% \DescribeMacro{\newindex} |
| 193 |
% Correspondingly, the \cs{newindex} command has four required |
| 194 |
% arguments. For example, to declare an author index, you might |
| 195 |
% use the following: |
| 196 |
% \begin{verbatim} |
| 197 |
% \newindex{aut}{adx}{and}{Name Index}\end{verbatim} |
| 198 |
% Here, \texttt{aut} is the tag used to identify the author index, |
| 199 |
% and ``Name Index'' is the title of the index. If the name of |
| 200 |
% your main file is \file{root.tex}, then \LaTeX\ will write the |
| 201 |
% raw index entries to the file \file{root.adx}, and you will |
| 202 |
% execute the following \program{MakeIndex} command to process the |
| 203 |
% author index: |
| 204 |
% \begin{verbatim} |
| 205 |
% makeindex -o root.and root.adx\end{verbatim} |
| 206 |
% |
| 207 |
% By default, the \cs{index} tags its argument with the page number |
| 208 |
% (i.e., the value of \cs{thepage}), but occasionaly you may want |
| 209 |
% to index items according to a different counter. For example, |
| 210 |
% you may want an index that contains figure numbers instead of |
| 211 |
% page numbers. To accomodate, this, the \cs{newindex} command |
| 212 |
% takes an optional argument, which is the name of the command that |
| 213 |
% generates the number that should be included in the index. For |
| 214 |
% instance, to include the number of a figure, you might say |
| 215 |
% \begin{verbatim} |
| 216 |
% \newindex[thefigure]{fig}{fdx}{fnd}{Figures}\end{verbatim} |
| 217 |
% |
| 218 |
% However, this introduces a new technicality: When creating an |
| 219 |
% index with page numbers, the choice of which page number is to be |
| 220 |
% written to the \texttt{aux} file should be deferred until the |
| 221 |
% page containing the entry is shipped out to the \texttt{dvi} |
| 222 |
% file, otherwise the wrong number will sometimes be chosen. |
| 223 |
% However, when using counters other than the page counter, one |
| 224 |
% normally wants the opposite behaviour: the number written to the |
| 225 |
% \texttt{aux} file should be chosen immediately, otherwise every |
| 226 |
% item on a given page will be tagged with the number of the last |
| 227 |
% item on that page. So, when a counter is specified using the |
| 228 |
% optional argument of \cs{newindex}, it is assumed that the |
| 229 |
% counter should be evaluated immediately. If for some reason you |
| 230 |
% need the choice to be deferred until the page is written to the |
| 231 |
% \texttt{dvi} file, you can force this behaviour by putting a $*$ |
| 232 |
% {\em after\/} the optional argument: |
| 233 |
% \begin{verbatim} |
| 234 |
% \newindex[thefigure]*{fig}{fdx}{fnd}{Figures}\end{verbatim} |
| 235 |
% (One consequence of this scheme is that if, for some reason, you |
| 236 |
% need the choice of page number to be made immediately instead of |
| 237 |
% being deferred until a page is shipped out to the \texttt{dvi} |
| 238 |
% file, you can acomplish this by beginning your index declaration |
| 239 |
% with |
| 240 |
% \begin{verbatim} |
| 241 |
% \newindex[thepage]*\end{verbatim} |
| 242 |
% |
| 243 |
% |
| 244 |
% \DescribeMacro{\renewindex} |
| 245 |
% The \cs{renewindex} command takes the same arguments as the |
| 246 |
% \cs{newindex} command and can be used to redefine indexes that |
| 247 |
% have been previously declared. |
| 248 |
% |
| 249 |
% |
| 250 |
% \DescribeMacro{\makeindex} |
| 251 |
% For backwards compatibility, the \cs{makeindex} command is |
| 252 |
% redefined to use \cs{newindex}. It is essentially equivalent to |
| 253 |
% \begin{verbatim} |
| 254 |
% \newindex{default}{idx}{ind}{Index}\end{verbatim} |
| 255 |
% The index labeled \texttt{default} is special: it is the one that |
| 256 |
% will be used by \cs{index} and \cs{printindex} unless another |
| 257 |
% index is specified (see below). |
| 258 |
% |
| 259 |
% |
| 260 |
% \DescribeMacro{\printindex} |
| 261 |
% The \cs{printindex} command is modified by the addition of an |
| 262 |
% optional argument, which is the tag of the index that should be |
| 263 |
% printed. |
| 264 |
% |
| 265 |
% |
| 266 |
% \DescribeMacro{\index} |
| 267 |
% The \cs{index} command is modified in two ways. First, there is |
| 268 |
% a $*$-variant of the command that, in addition to putting its |
| 269 |
% argument into an index, also typesets it on the page. Second, |
| 270 |
% \cs{index} now takes an optional argument to indicate which index |
| 271 |
% the new entry should be added to. If given, the optional |
| 272 |
% argument should be the identifying tag of a previously-defined |
| 273 |
% index. If no such tag is supplied, the \texttt{default} index |
| 274 |
% (such as that opened by \cs{makeindex} above) is used. |
| 275 |
% |
| 276 |
% |
| 277 |
% \DescribeMacro{\shortindexingon} |
| 278 |
% \DescribeMacro{\shortindexingoff} |
| 279 |
% Perhaps the most dubious feature of \bundle{index.sty} is that it |
| 280 |
% allows you to define the characters |^| and |_| to be |
| 281 |
% abbreviations for \cs{index*} and \cs{index} outside of math |
| 282 |
% mode. These abbreviations are enabled by the |
| 283 |
% \cs{shortindexingon} command and disabled by the |
| 284 |
% \cs{shortindexingoff} command. The scope of both of these latter |
| 285 |
% commands is local to the current group. (This might be useful, |
| 286 |
% for example, if you wanted the abbreviations turned on throughout |
| 287 |
% most of the documentation, but turned off in one particular |
| 288 |
% environment.) In addition, |
| 289 |
% \DescribeEnv{shortindexingon}\Lenv{shortindexingon} can be used |
| 290 |
% as an environment if that seems appropriate. \textbf{Warning: |
| 291 |
% This feature is deprecated and will disappear in a future release |
| 292 |
% of this package.} |
| 293 |
% |
| 294 |
% |
| 295 |
% \DescribeMacro{\proofmodetrue} |
| 296 |
% \DescribeMacro{\proofmodefalse} |
| 297 |
% \DescribeMacro{\indexproofstyle} |
| 298 |
% As mentioned above, the \bundle{showidx} document-style option |
| 299 |
% has been merged into \bundle{index.sty}. It can be turned on |
| 300 |
% with \cs{proofmodetrue} and turned off with \cs{proofmodefalse}. |
| 301 |
% When it is turned on, all index entries\footnote{Well, most, at |
| 302 |
% least. There are some circumstances under which the index |
| 303 |
% entries won't show up in the proofs, although they will show up |
| 304 |
% in the index.} will be put in the margin of the page where they |
| 305 |
% appear. By default, they appear in the typewriter font at |
| 306 |
% \cs{footnotesize}, but the user can override this with the |
| 307 |
% \cs{indexproofstyle} command; for example, |
| 308 |
% \begin{verbatim} |
| 309 |
% \indexproofstyle{\footnotesize\it}\end{verbatim} |
| 310 |
% will cause them to be put in italics instead. |
| 311 |
% |
| 312 |
% |
| 313 |
% \DescribeMacro{\disableindex} |
| 314 |
% There are some circumstances where it might be helpful to |
| 315 |
% suppress the writing of a particular index. The |
| 316 |
% \cs{disableindex} command is provided for this purpose. It takes |
| 317 |
% one argument, a comma-separated list of tags of the indexes that |
| 318 |
% should be disabled. This command should come {\em before\/} the |
| 319 |
% declarations for the indexes that are being |
| 320 |
% disabled\footnote{This limits its usefulness somewhat, but since |
| 321 |
% the output file for an index is opened when the index is |
| 322 |
% declared, the damage has already been done. We could close the |
| 323 |
% file, but we can't prevent a new output stream from being |
| 324 |
% allocated and we can't keep the old file from being truncated.}. |
| 325 |
% One situation where the \cs{disableindex} command might be useful |
| 326 |
% is if there are so many indexes that you are exhausting \TeX's |
| 327 |
% supply of output streams\footnote{\TeX\ only has 16 output |
| 328 |
% streams, which are allocated with the {\tt\string\newwrite} |
| 329 |
% command. The standard \LaTeX\ styles use from 3 to 7 of these, |
| 330 |
% which should leave room for up to 9 indexes. Of course, if you |
| 331 |
% have extra output files, then there will be fewer output streams |
| 332 |
% left for indexes.}. For example, suppose you have 10 indexes, |
| 333 |
% but only 5 output streams available for indexes. Then you could |
| 334 |
% add a \cs{disableindex} command to the top of your file to |
| 335 |
% suppress the writing of all but 5 of the indexes. (Note that the |
| 336 |
% index entries would still get written to the \texttt{aux} file; |
| 337 |
% they just wouldn't get copied to the individual raw index files |
| 338 |
% at the end of the run.) At the end of the run, you could then |
| 339 |
% re-run your main file a couple of times with different indexes |
| 340 |
% disabled until you had created all of the raw index files. This |
| 341 |
% is somewhat clumsy, but safer than any alternative I've come up |
| 342 |
% with\footnote{A less clumsy (for the user, at least) solution |
| 343 |
% would be to read the \texttt{aux} file multiple times at the end |
| 344 |
% of the run, each time writing just one of the raw index files. |
| 345 |
% The main disadvantage of this scheme at present is that it would |
| 346 |
% require a modification of {\tt\string\enddocument}.}. |
| 347 |
% |
| 348 |
% |
| 349 |
% \section{Caveats} |
| 350 |
% |
| 351 |
% In order to implement this style file, it's been necessary to |
| 352 |
% modify a number of \LaTeX\ commands seemingly unrelated to |
| 353 |
% indexing, namely, \cs{@starttoc}, \cs{raggedbottom}, |
| 354 |
% \cs{flushbottom}, and \cs{addcontents}. Naturally, this could |
| 355 |
% cause incompatibilities |
| 356 |
% between \bundle{index.sty} and any style files that either |
| 357 |
% redefine these same commands or make specific assumptions about |
| 358 |
% how they operate. See Section~\ref{sec:thecode} for explanations |
| 359 |
% of why these various commands needed modification. |
| 360 |
% |
| 361 |
% The redefinition of \cs{@starttoc} is particularly bad, since it |
| 362 |
% introduces an incompatibility with the AMS document classes. |
| 363 |
% This will be addressed soon. |
| 364 |
% |
| 365 |
% Unfortunately, it's also been necessary to modify the |
| 366 |
% \Lenv{theindex} environment, so if you don't like the default |
| 367 |
% \LaTeX\ definition, you'll need copy the definition of |
| 368 |
% \Lenv{theindex} from this file and modify it appropriately. |
| 369 |
% |
| 370 |
% In the current implementation, \bundle{index.sty} uses one output |
| 371 |
% stream for each index. Since there are a limited number of |
| 372 |
% output indexes, this means that there is a limit on the number of |
| 373 |
% indexes you can have in a document. See the description of |
| 374 |
% \cs{disableindex} for a fuller discussion of this problem and one |
| 375 |
% way around it. |
| 376 |
% |
| 377 |
% |
| 378 |
% \section{To do's} |
| 379 |
% |
| 380 |
% It might be nice if the \cs{index*} command parsed its argument |
| 381 |
% so that, for example, instead of writing |
| 382 |
% `|\index{sin@$\sin$}$\sin$|', one could write |
| 383 |
% `|index*{sin@$\sin$}|'. However, this is fraught with numerous |
| 384 |
% dangers, and I'm both too lazy and too cowardly to undertake it |
| 385 |
% now. |
| 386 |
% |
| 387 |
% It would be reasonable to add support for \cs{makeglossary} and |
| 388 |
% similar things, if they were well-defined enough to decide what |
| 389 |
% the general syntax for defining them should be. |
| 390 |
% |
| 391 |
% The documentation should be carefully read, edited, and finished, |
| 392 |
% especially since it's still based on the 2.09 version, even |
| 393 |
% though a few substantial changes have been made for the \LaTeXe\ |
| 394 |
% version. |
| 395 |
% |
| 396 |
% For some truly outlandish ideas, see the file \file{TODO} in the |
| 397 |
% distribution. |
| 398 |
% |
| 399 |
% \StopEventually{} |
| 400 |
% |
| 401 |
% \section{The code} |
| 402 |
% \label{sec:thecode} |
| 403 |
% |
| 404 |
% As is customary, identify this as a \LaTeXe\ package. |
| 405 |
% \begin{macrocode} |
| 406 |
%<*style> |
| 407 |
\NeedsTeXFormat{LaTeX2e}[2024/11/01] |
| 408 |
|
| 409 |
\ProvidesPackage{index}[2025/02/06 v4.04 Improved index support (dmj)] |
| 410 |
% \end{macrocode} |
| 411 |
% |
| 412 |
% \begin{macro}{\disableindex} |
| 413 |
% The \cs{disableindex} should come before the declarations of the |
| 414 |
% indexes it refers to. (Question: If an index has been disabled, |
| 415 |
% should it show up in index proofs? Maybe there should be a |
| 416 |
% separate command to disable index proofs on and index-by-index |
| 417 |
% basis.) |
| 418 |
% \begin{macrocode} |
| 419 |
\def\disableindex#1{% |
| 420 |
\@for\@tempa:=#1\do{% |
| 421 |
\@namedef{disable@\@tempa}{}% |
| 422 |
\@ifundefined{tf@\@tempa}{}{% |
| 423 |
\PackageWarningNoLine{index}{It's too late to disable |
| 424 |
the `\@tempa' index;\MessageBreak |
| 425 |
\jobname.\@tempa\space has already |
| 426 |
been opened for output. You \MessageBreak |
| 427 |
should put the \string\disableindex\space command |
| 428 |
before\MessageBreak |
| 429 |
the declaration of the `\@tempa' index}% |
| 430 |
}% |
| 431 |
}% |
| 432 |
} |
| 433 |
% \end{macrocode} |
| 434 |
% \end{macro} |
| 435 |
% |
| 436 |
% \begin{macro}{\if@newindex} |
| 437 |
% \begin{macro}{\newindex} |
| 438 |
% \begin{macro}{\renewindex} |
| 439 |
% The \cs{newindex} and \cs{renewindex} commands are defined on |
| 440 |
% analogy with the \cs{[re]newcommand} macros. Each index is |
| 441 |
% identified by a unique tag, which is specified in the first |
| 442 |
% required argument of \cs{newindex}. Much of the information |
| 443 |
% about the index labeled \meta{tag} is kept in the macro |
| 444 |
% \cs{idx@}\meta{tag}, so we can check to see if a particular index |
| 445 |
% has already been defined by checking whether \cs{idx@}\meta{tag} |
| 446 |
% is defined. \cs{newindex} and \cs{renewindex} both check to see |
| 447 |
% if their first argument is already associated with an index and |
| 448 |
% then either issue an appropriate error message or call |
| 449 |
% \cs{def@index}. |
| 450 |
% |
| 451 |
% The \cs{if@newindex} flag will be used to keep \cs{renewindex} |
| 452 |
% from re-allocating \cs{write} and \cs{toks} registers later. The |
| 453 |
% \cs{if@tempswa} switch will be used to determine whether the |
| 454 |
% \cs{write}s for this index should be done \cs{immediate}ly or |
| 455 |
% not. |
| 456 |
% \begin{macrocode} |
| 457 |
\newif\if@newindex |
| 458 |
|
| 459 |
\def\newindex{% |
| 460 |
\@tempswafalse |
| 461 |
\@ifnextchar[{\@tempswatrue\x@newindex}{\x@newindex[thepage]}% |
| 462 |
} |
| 463 |
|
| 464 |
\def\x@newindex[#1]{% |
| 465 |
\@ifstar {\@tempswafalse\y@newindex{#1}} |
| 466 |
{\y@newindex{#1}}% |
| 467 |
} |
| 468 |
|
| 469 |
\def\y@newindex#1#2{% |
| 470 |
\@ifundefined{idx@#2}% |
| 471 |
{\@newindextrue\def@index{#1}{#2}}% |
| 472 |
{% |
| 473 |
\@latexerr{Index type `\string#2' already defined}\@ehc |
| 474 |
\expandafter\@gobble\@gobbletwo |
| 475 |
}% |
| 476 |
} |
| 477 |
|
| 478 |
\def\renewindex{% |
| 479 |
\@tempswafalse |
| 480 |
\@ifnextchar[{\@tempswatrue\x@renewindex}{\x@renewindex[thepage]}% |
| 481 |
} |
| 482 |
|
| 483 |
\def\x@renewindex[#1]{% |
| 484 |
\@ifstar {\@tempswafalse\y@renewindex{#1}} |
| 485 |
{\y@renewindex{#1}}% |
| 486 |
} |
| 487 |
|
| 488 |
\def\y@renewindex#1#2{% |
| 489 |
\@ifundefined{idx@#2}% |
| 490 |
{% |
| 491 |
\@newindextrue |
| 492 |
\@latexerr{Index type `\string#2' not defined}\@ehc |
| 493 |
}% |
| 494 |
{\@newindexfalse}% |
| 495 |
\def@index{#1}{#2}% |
| 496 |
} |
| 497 |
% \end{macrocode} |
| 498 |
% \end{macro} |
| 499 |
% \end{macro} |
| 500 |
% \end{macro} |
| 501 |
% |
| 502 |
% \begin{macro}{\@preamblecmds} |
| 503 |
% Neither \cs{newindex}, \cs{renewindex}, nor \cs{disableindex} |
| 504 |
% should be used anywhere except inside style files or in the |
| 505 |
% preamble of a document, so we add them to the \cs{@preamblecmds} |
| 506 |
% list. |
| 507 |
% \begin{macrocode} |
| 508 |
\@onlypreamble\newindex |
| 509 |
\@onlypreamble\renewindex |
| 510 |
\@onlypreamble\disableindex |
| 511 |
% \end{macrocode} |
| 512 |
% \end{macro} |
| 513 |
% |
| 514 |
% \begin{macro}{\def@index} |
| 515 |
% \cs{def@index} does most of the work. First, it picks up the |
| 516 |
% first three arguments of the \cs{[re]newindex} command and stores |
| 517 |
% the second two in an appropriate \cs{idx@} macro. The title of |
| 518 |
% the index is treated differently, however, since it is |
| 519 |
% potentially fragile in a particularly odd way. To prevent |
| 520 |
% mishaps, it is stored in a token register. In addition to |
| 521 |
% stashing away the information about the index, \cs{def@index} |
| 522 |
% also opens an appropriate output file if we are writing auxiliary |
| 523 |
% files (i.e., unless \cs{nofiles} is in effect). |
| 524 |
% |
| 525 |
% \begin{macrocode} |
| 526 |
\def\def@index#1#2#3#4{% |
| 527 |
\@namedef{idx@#2}{#3:#4:#1}% |
| 528 |
\expandafter\let\csname if@immediate@#2\endcsname\if@tempswa |
| 529 |
\if@filesw |
| 530 |
\if@newindex |
| 531 |
\expandafter\newtoks\csname idxtitle@#2\endcsname |
| 532 |
\fi |
| 533 |
\@ifundefined{disable@#2}{% |
| 534 |
\if@newindex |
| 535 |
\expandafter\newwrite\csname tf@#2\endcsname |
| 536 |
\else |
| 537 |
\immediate\closeout\@nameuse{tf@#2}% |
| 538 |
\fi |
| 539 |
\immediate\openout\@nameuse{tf@#2}\jobname.#3 % |
| 540 |
\PackageInfo{index}{Writing index file \jobname.#3}% |
| 541 |
} |
| 542 |
{\PackageInfo{index}{Index `#2' disabled -- not opening |
| 543 |
\jobname.#3}}% |
| 544 |
\fi |
| 545 |
\expandafter\csname idxtitle@#2\endcsname |
| 546 |
} |
| 547 |
% \end{macrocode} |
| 548 |
% \end{macro} |
| 549 |
% |
| 550 |
% \begin{macro}{\@first} |
| 551 |
% \begin{macro}{\@second} |
| 552 |
% \begin{macro}{\@third} |
| 553 |
% These are useful macros for retrieving individual components |
| 554 |
% of an index specification. |
| 555 |
% \begin{macrocode} |
| 556 |
\def\@first#1:#2:#3\@nil{#1} |
| 557 |
|
| 558 |
\def\@second#1:#2:#3\@nil{#2} |
| 559 |
|
| 560 |
\def\@third#1:#2:#3\@nil{#3} |
| 561 |
% \end{macrocode} |
| 562 |
% \end{macro} |
| 563 |
% \end{macro} |
| 564 |
% \end{macro} |
| 565 |
% |
| 566 |
% \begin{macro}{\@nearverbatim} |
| 567 |
% |\@nearverbatim\foo| is much like |\meaning\foo|, |
| 568 |
% except that it suppresses the ``\texttt{macro ->}'' string |
| 569 |
% produced when \cs{meaning} expands a macro. It is used by |
| 570 |
% \cs{@wrindex} to produce an ``almost verbatim'' copy of their |
| 571 |
% arguments. This method replaces the use of \cs{@sanitize} from |
| 572 |
% latex.tex and allows indexing macros to be used in places (such |
| 573 |
% as inside macro arguments) where the original \cs{index} command |
| 574 |
% could not. Thanks to Donald Arseneau |
| 575 |
% \email{[email protected]} for pointing out this trick to me. |
| 576 |
% (For more information on this trick, see Dirty Trick \#3 of the |
| 577 |
% \TeX book, page 382). |
| 578 |
% |
| 579 |
% As defined, \@nearverbatim only works on macros. It would be |
| 580 |
% nice if it could work with other tokens, but it's more important |
| 581 |
% that it work only by expansion, which means we can't put in tests |
| 582 |
% to see what the next token is. |
| 583 |
% \begin{macrocode} |
| 584 |
\def\@nearverbatim{\expandafter\strip@prefix\meaning} |
| 585 |
% \end{macrocode} |
| 586 |
% \end{macro} |
| 587 |
% |
| 588 |
% Now we define the \cs{index} macro itself. The following |
| 589 |
% definitions are adapted from \bundle{latex.tex} v2.09 \vdate{25 |
| 590 |
% March 1992}. |
| 591 |
% |
| 592 |
% \begin{macro}{\makeindex} |
| 593 |
% First we redefine \cs{makeindex} to define the default index |
| 594 |
% using \cs{newindex}. We use \cs{edef} to make sure that |
| 595 |
% \cs{indexname} gets expanded here. Otherwise we'll get into an |
| 596 |
% infinite loop later on when we try to redefine \cs{indexname} |
| 597 |
% inside the \cs{theindex} environment. |
| 598 |
% |
| 599 |
% Unfortunately, this means that if the user changes \cs{indexname} |
| 600 |
% in the preamble, the index will come out with the wrong heading. |
| 601 |
% \begin{macrocode} |
| 602 |
\edef\makeindex{% |
| 603 |
\noexpand\newindex{default}{idx}{ind}{\indexname}% |
| 604 |
} |
| 605 |
% \end{macrocode} |
| 606 |
% \end{macro} |
| 607 |
% |
| 608 |
% \begin{macro}{\if@silentindex} |
| 609 |
% \begin{macro}{\if@addtoindex} |
| 610 |
% \begin{macro}{\if@proofmode} |
| 611 |
% We need three new flags. The first, \cs{if@silentindex}, |
| 612 |
% indicates whether the entry should be typeset in running text, as |
| 613 |
% well as written out to the index; this is used to implement the |
| 614 |
% \cs{index*} command. The second, \cs{if@addtoindex}, indicates |
| 615 |
% whether entries should be written to the index; this is used to |
| 616 |
% disable the \cs{index} command inside of page headings and tables |
| 617 |
% of contents. The third, \cs{ifproofmode}, indicates whether |
| 618 |
% index entries should be put in the margin of the page for |
| 619 |
% proofing purposes. |
| 620 |
% \begin{macrocode} |
| 621 |
\newif\if@silentindex\@silentindextrue |
| 622 |
|
| 623 |
\newif\if@addtoindex\@addtoindextrue |
| 624 |
|
| 625 |
\newif\ifproofmode\proofmodefalse |
| 626 |
% \end{macrocode} |
| 627 |
% \end{macro} |
| 628 |
% \end{macro} |
| 629 |
% \end{macro} |
| 630 |
% |
| 631 |
% \begin{macro}{\index} |
| 632 |
% \begin{macro}{\p@index} |
| 633 |
% \begin{macro}{\x@index} |
| 634 |
% \cs{index} will be made self-protecting (a la \cs{em}, etc.) so |
| 635 |
% it can be used inside, for example, sectioning commands. |
| 636 |
% Unfortunately, to really make \cs{index} robust, we have to |
| 637 |
% redefine some of \LaTeX's commands for dealing with tables of |
| 638 |
% contents and page headings. (See below.) $*$sigh$*$ |
| 639 |
% \begin{macrocode} |
| 640 |
\protected\def\index{\protect\p@index} |
| 641 |
|
| 642 |
\def\p@index{% |
| 643 |
\if@silentindex\@bsphack\fi |
| 644 |
\@ifstar{\@silentindexfalse\@xindex}{\@silentindextrue\@xindex}% |
| 645 |
} |
| 646 |
|
| 647 |
\def\@xindex{\@ifnextchar[{\@index}{\@index[default]}} |
| 648 |
% \end{macrocode} |
| 649 |
% \end{macro} |
| 650 |
% \end{macro} |
| 651 |
% \end{macro} |
| 652 |
% |
| 653 |
% \begin{macro}{\@index} |
| 654 |
% \begin{macro}{\@@index} |
| 655 |
% \begin{macro}{\@wrindex} |
| 656 |
% The following is much more complicated than it should have to be. |
| 657 |
% First, note the check to see if \cs{index} is equal to |
| 658 |
% \cs{@gobble}. This is so I don't have to redefine |
| 659 |
% \cs{@outputpage}, which temporarily disables \cs{label}, |
| 660 |
% \cs{index}, and \cs{glossary} by \cs{let}'ing them equal to |
| 661 |
% \cs{@gobble}. (For this reason, we have to be very careful to |
| 662 |
% make sure that \cs{index} has expanded to \cs{p@index} before it |
| 663 |
% gets to \cs{@outputpage}.) Second, note that if |
| 664 |
% \cs{if@addtoindex} is false, we don't complain about undefined |
| 665 |
% index types. This is because if your page headings, for example, |
| 666 |
% are being typeset in all uppercase, you might end up with |
| 667 |
% something like \cs{index[AUT]{...}} instead of |
| 668 |
% \cs{index[aut]{...}}. |
| 669 |
% \begin{macrocode} |
| 670 |
\def\@index[#1]{% |
| 671 |
\ifx\index\@gobble |
| 672 |
\@addtoindexfalse |
| 673 |
\fi |
| 674 |
\def\@tempf{% |
| 675 |
\begingroup |
| 676 |
\@sanitize |
| 677 |
\@@index{#1}% |
| 678 |
}% |
| 679 |
\if@addtoindex |
| 680 |
\@ifundefined{idx@#1}% |
| 681 |
{% |
| 682 |
\def\@tempf{% |
| 683 |
\@latexerr{Index type `\string#1' undefined}% |
| 684 |
\@ehc |
| 685 |
\@silentindextrue |
| 686 |
\@gobble |
| 687 |
}% |
| 688 |
}% |
| 689 |
{}% |
| 690 |
\fi |
| 691 |
\@tempf |
| 692 |
} |
| 693 |
|
| 694 |
\def\@@index#1#2{% |
| 695 |
\endgroup |
| 696 |
\if@addtoindex |
| 697 |
\if@filesw\@wrindex{#1}{#2}\fi |
| 698 |
\ifproofmode\@showidx{#2}\fi |
| 699 |
\fi |
| 700 |
\if@silentindex |
| 701 |
\expandafter\@esphack |
| 702 |
\else |
| 703 |
\@silentindextrue#2% |
| 704 |
\fi |
| 705 |
} |
| 706 |
|
| 707 |
\def\@wrindex#1#2{% |
| 708 |
\begingroup |
| 709 |
\def\@tempa{#2}% |
| 710 |
\edef\@tempb{\@nameuse{idx@#1}}% |
| 711 |
\edef\@tempb{\expandafter\@third\@tempb\@nil}% |
| 712 |
\csname if@immediate@#1\endcsname \else |
| 713 |
\expandafter\let\csname\@tempb\endcsname\relax |
| 714 |
\fi |
| 715 |
\edef\@tempa{% |
| 716 |
\write\@auxout{% |
| 717 |
\string\@writefile{#1}{% |
| 718 |
\string\indexentry{\@nearverbatim\@tempa}% |
| 719 |
{\@nameuse{\@tempb}}% |
| 720 |
}% |
| 721 |
}% |
| 722 |
}% |
| 723 |
\expandafter\endgroup\@tempa |
| 724 |
\if@nobreak\ifvmode\nobreak\fi\fi |
| 725 |
} |
| 726 |
% \end{macrocode} |
| 727 |
% \end{macro} |
| 728 |
% \end{macro} |
| 729 |
% \end{macro} |
| 730 |
% |
| 731 |
% \begin{macro}{\seename} |
| 732 |
% \begin{macro}{\see} |
| 733 |
% \begin{macro}{\printindex} |
| 734 |
% \begin{macro}{\@printindex} |
| 735 |
% The following are adapted from \bundle{makeidx.sty}, v2.09 |
| 736 |
% \vdate{21 Oct 91}. \cs{index@prologue} adapted from |
| 737 |
% \bundle{doc.dtx}. \Lenv{theindex} based on version from |
| 738 |
% \bundle{classes.dtx}, v1.3g, 26 June 1995. |
| 739 |
% \begin{macrocode} |
| 740 |
\providecommand{\seename}{see} |
| 741 |
|
| 742 |
\providecommand*{\see}[2]{\emph{\seename} #1} |
| 743 |
|
| 744 |
\@ifclassloaded{article}{% |
| 745 |
|
| 746 |
\renewenvironment{theindex}{% |
| 747 |
\edef\indexname{\the\@nameuse{idxtitle@\@indextype}}% |
| 748 |
\if@twocolumn |
| 749 |
\@restonecolfalse |
| 750 |
\else |
| 751 |
\@restonecoltrue |
| 752 |
\fi |
| 753 |
\columnseprule \z@ |
| 754 |
\columnsep 35\p@ |
| 755 |
\twocolumn[% |
| 756 |
\section*{\indexname}% |
| 757 |
\ifx\index@prologue\@empty\else |
| 758 |
\index@prologue |
| 759 |
\bigskip |
| 760 |
\fi |
| 761 |
]% |
| 762 |
\@mkboth{\MakeUppercase\indexname}% |
| 763 |
{\MakeUppercase\indexname}% |
| 764 |
\thispagestyle{plain}% |
| 765 |
\parindent\z@ |
| 766 |
\parskip\z@ \@plus .3\p@\relax |
| 767 |
\let\item\@idxitem |
| 768 |
}{% |
| 769 |
\if@restonecol |
| 770 |
\onecolumn |
| 771 |
\else |
| 772 |
\clearpage |
| 773 |
\fi |
| 774 |
} |
| 775 |
}{% |
| 776 |
\renewenvironment{theindex}{% |
| 777 |
\edef\indexname{\the\@nameuse{idxtitle@\@indextype}}% |
| 778 |
\if@twocolumn |
| 779 |
\@restonecolfalse |
| 780 |
\else |
| 781 |
\@restonecoltrue |
| 782 |
\fi |
| 783 |
\columnseprule \z@ |
| 784 |
\columnsep 35\p@ |
| 785 |
\twocolumn[% |
| 786 |
\@makeschapterhead{\indexname}% |
| 787 |
\ifx\index@prologue\@empty\else |
| 788 |
\index@prologue |
| 789 |
\bigskip |
| 790 |
\fi |
| 791 |
]% |
| 792 |
\@mkboth{\MakeUppercase\indexname}% |
| 793 |
{\MakeUppercase\indexname}% |
| 794 |
\thispagestyle{plain}% |
| 795 |
\parindent\z@ |
| 796 |
\parskip\z@ \@plus .3\p@\relax |
| 797 |
\let\item\@idxitem |
| 798 |
}{% |
| 799 |
\if@restonecol |
| 800 |
\onecolumn |
| 801 |
\else |
| 802 |
\clearpage |
| 803 |
\fi |
| 804 |
} |
| 805 |
} |
| 806 |
|
| 807 |
\def\printindex{\@ifnextchar[{\@printindex}{\@printindex[default]}} |
| 808 |
|
| 809 |
\def\@printindex[#1]{% |
| 810 |
\@ifnextchar[{\@print@index[#1]}{\@print@index[#1][]}% |
| 811 |
} |
| 812 |
|
| 813 |
\long\def\@print@index[#1][#2]{% |
| 814 |
\def\@indextype{#1}% |
| 815 |
\long\def\index@prologue{#2}% |
| 816 |
\@ifundefined{idx@#1}% |
| 817 |
{\@latexerr{Index type `\string#1' undefined}\@ehc}% |
| 818 |
{% |
| 819 |
\edef\@tempa{\@nameuse{idx@#1}}% |
| 820 |
\edef\@tempb{% |
| 821 |
\jobname.\expandafter\@second\@tempa\@nil |
| 822 |
}% |
| 823 |
\edef\@tempc{% |
| 824 |
\jobname.\expandafter\@first\@tempa\@nil |
| 825 |
}% |
| 826 |
\InputIfFileExists{\@tempb}{}{% |
| 827 |
\typeout{No file \@tempb: Run makeindex -o |
| 828 |
\@tempb \space \@tempc}% |
| 829 |
}% |
| 830 |
}% |
| 831 |
} |
| 832 |
% \end{macrocode} |
| 833 |
% \end{macro} |
| 834 |
% \end{macro} |
| 835 |
% \end{macro} |
| 836 |
% \end{macro} |
| 837 |
% |
| 838 |
% \begin{macro}{\@indexstar@} |
| 839 |
% Now we set things up for |
| 840 |
% \cs{shortindexing}.\footnote{\textbf{Warning:} This feature is |
| 841 |
% deprecated and will be removed entirely in a future release of |
| 842 |
% this package.} First, we define a one-token shorthand for |
| 843 |
% \cs{index*}. This will be needed in the definition of |
| 844 |
% \cs{idx@activehat}. |
| 845 |
% \begin{macrocode} |
| 846 |
\def\@indexstar@{\index*} |
| 847 |
% \end{macrocode} |
| 848 |
% \end{macro} |
| 849 |
% \begin{macro}{\idx@activehat} |
| 850 |
% \begin{macro}{\idx@activebar} |
| 851 |
% Next, we define the values that |^| and |_| will have when |
| 852 |
% shortindexing is turned on. |
| 853 |
% \begin{macrocode} |
| 854 |
\def\idx@activehat{% |
| 855 |
\relax |
| 856 |
\ifmmode\expandafter\sp\else\expandafter\@indexstar@\fi |
| 857 |
} |
| 858 |
|
| 859 |
\def\idx@activebar{% |
| 860 |
\relax |
| 861 |
\ifmmode\expandafter\sb\else\expandafter\index\fi |
| 862 |
} |
| 863 |
% \end{macrocode} |
| 864 |
% \end{macro} |
| 865 |
% \end{macro} |
| 866 |
% |
| 867 |
% \begin{macro}{\shortindexingon} |
| 868 |
% \begin{macro}{\shortindexingoff} |
| 869 |
% Now we define the \cs{shortindexingon} and \cs{shortindexinoff} |
| 870 |
% commands to turn shortindexing on and off (surprise!). |
| 871 |
% \cs{shortindexingon} saves the old definitions and \cs{catcode}'s |
| 872 |
% of |^| and |_| so they can later be restored by |
| 873 |
% \cs{shortindexingoff}. Both of these make their changes local to |
| 874 |
% any enclosing group, so they can be used as declarations to |
| 875 |
% disable or enable shortindexing temporarily. In addition, |
| 876 |
% \Lenv{shortindexingon} can also be used as an environment. |
| 877 |
% |
| 878 |
% This is potentially very confusing. My basic rationale (if it |
| 879 |
% can be described as such) was that under normal circumstances, |
| 880 |
% one would put \cs{shortindexingon} in the preamble of one's |
| 881 |
% document, and never want to turn it off. \cs{shortindexingoff} |
| 882 |
% is an attempt to make allowance for the contingency that someone |
| 883 |
% might want to turn shortindexing off, either permanently or |
| 884 |
% temporarily. |
| 885 |
% \begin{macrocode} |
| 886 |
\newif\if@shortindexing |
| 887 |
|
| 888 |
\begingroup |
| 889 |
|
| 890 |
\catcode`\^\active |
| 891 |
\catcode`\_\active |
| 892 |
|
| 893 |
\gdef\shortindexingon{% |
| 894 |
\@shortindexingtrue |
| 895 |
\chardef\old@idxhatcode\catcode`\^\relax |
| 896 |
\chardef\old@idxbarcode\catcode`\_\relax |
| 897 |
\catcode`\^\active |
| 898 |
\catcode`\_\active |
| 899 |
\let\old@idxhat ^% |
| 900 |
\let\old@idxbar _% |
| 901 |
\let^\idx@activehat |
| 902 |
\let_\idx@activebar |
| 903 |
} |
| 904 |
|
| 905 |
\gdef\shortindexingoff{% |
| 906 |
\if@shortindexing |
| 907 |
\@shortindexingfalse |
| 908 |
\let^\old@idxhat |
| 909 |
\let_\old@idxbar |
| 910 |
\catcode`\^\old@idxhatcode |
| 911 |
\catcode`\_\old@idxbarcode |
| 912 |
\fi |
| 913 |
} |
| 914 |
|
| 915 |
\endgroup |
| 916 |
% \end{macrocode} |
| 917 |
% \end{macro} |
| 918 |
% \end{macro} |
| 919 |
% |
| 920 |
% Now we take some code from \bundle{showidx.sty} and merge it into |
| 921 |
% our new system. There are four reasons for redefining the |
| 922 |
% commands here rather than just inputting \bundle{showidx.sty} (or |
| 923 |
% requiring the user to do so). First, \bundle{showidx.sty} ends |
| 924 |
% with a call to \cs{flushbottom}, which I want to avoid. Second, |
| 925 |
% the instructions for successfully using \bundle{showidx.sty} |
| 926 |
% along with \bundle{index.sty} would be somewhat tricky. This |
| 927 |
% way, I can just tell users not to use \bundle{showidx.sty} at |
| 928 |
% all. Third, I need to make some alterations to \cs{@showidx} |
| 929 |
% anyway. In particular, (a) I need to add the \cs{@sanitizeat} |
| 930 |
% command so this works correctly with AMS-\LaTeX\ and (b) I want |
| 931 |
% to add the \cs{indexproofstyle} command so the user can customize |
| 932 |
% the size and font used for the index proofs. Finally, |
| 933 |
% \bundle{showidx.sty} has at least two annoying bugs in it. See |
| 934 |
% the edit-history for version 2.01 for a description. |
| 935 |
% |
| 936 |
% \begin{macro}{\@indexbox} |
| 937 |
% This code is adapted from \bundle{showidx.sty}, v2.09 \vdate{16 |
| 938 |
% Jun 1991}. |
| 939 |
% \begin{macrocode} |
| 940 |
\newinsert\@indexbox |
| 941 |
|
| 942 |
\dimen\@indexbox\maxdimen |
| 943 |
% \end{macrocode} |
| 944 |
% \end{macro} |
| 945 |
% |
| 946 |
% \begin{macro}{\@sanitizeat} |
| 947 |
% The definition of \cs{@sanitizeat} is slightly tricky, since we |
| 948 |
% need |@| to be active when this macro is defined, but we also |
| 949 |
% need it to be part of the control sequence name. |
| 950 |
% \begin{macrocode} |
| 951 |
\begingroup |
| 952 |
\catcode`\@\active |
| 953 |
\expandafter\gdef\csname\string @sanitizeat\endcsname |
| 954 |
{\def @{\char`\@}} |
| 955 |
\endgroup |
| 956 |
% \end{macrocode} |
| 957 |
% \end{macro} |
| 958 |
% |
| 959 |
% \begin{macro}{\indexproofstyle} |
| 960 |
% \begin{macro}{\@showidx} |
| 961 |
% \begin{macro}{\@leftidx} |
| 962 |
% \begin{macro}{\@rightidx} |
| 963 |
% \begin{macro}{\@mkidx} |
| 964 |
% \begin{macro}{\raggedbottom} |
| 965 |
% \begin{macro}{\flushbottom} |
| 966 |
% \begin{macro}{\@texttop} |
| 967 |
% \begin{macrocode} |
| 968 |
\newtoks\indexproofstyle |
| 969 |
|
| 970 |
\indexproofstyle{\footnotesize\reset@font\ttfamily} |
| 971 |
|
| 972 |
\def\@showidx#1{% |
| 973 |
\insert\@indexbox{% |
| 974 |
\@sanitizeat |
| 975 |
\the\indexproofstyle |
| 976 |
\hsize\marginparwidth |
| 977 |
\hangindent\marginparsep \parindent\z@ |
| 978 |
\everypar{}\let\par\@@par \parfillskip\@flushglue |
| 979 |
\lineskip\normallineskip |
| 980 |
\baselineskip .8\normalbaselineskip\sloppy |
| 981 |
\raggedright \leavevmode |
| 982 |
\vrule \@height .7\normalbaselineskip \@width \z@\relax#1\relax |
| 983 |
\vrule \@height\z@ \@depth.3\normalbaselineskip \@width\z@\relax |
| 984 |
}% |
| 985 |
\ifhmode\penalty\@M \hskip\z@skip\fi |
| 986 |
} |
| 987 |
|
| 988 |
\def\@leftidx{\hskip-\marginparsep \hskip-\marginparwidth} |
| 989 |
|
| 990 |
\def\@rightidx{\hskip\columnwidth \hskip\marginparsep} |
| 991 |
|
| 992 |
\def\@mkidx{% |
| 993 |
\vbox to \z@{% |
| 994 |
\rlap{% |
| 995 |
\if@twocolumn |
| 996 |
\if@firstcolumn \@leftidx \else \@rightidx \fi |
| 997 |
\else |
| 998 |
\if@twoside |
| 999 |
\ifodd\c@page \@rightidx \else \@leftidx \fi |
| 1000 |
\else |
| 1001 |
\@rightidx |
| 1002 |
\fi |
| 1003 |
\fi |
| 1004 |
\box\@indexbox |
| 1005 |
}% |
| 1006 |
\vss |
| 1007 |
}% |
| 1008 |
} |
| 1009 |
|
| 1010 |
\def\raggedbottom{% |
| 1011 |
\def\@textbottom{\vskip\z@ plus.0001fil}% |
| 1012 |
\let\@texttop\@mkidx |
| 1013 |
} |
| 1014 |
|
| 1015 |
\def\flushbottom{\let\@textbottom\relax \let\@texttop\@mkidx} |
| 1016 |
|
| 1017 |
\let\@texttop\@mkidx |
| 1018 |
% \end{macrocode} |
| 1019 |
% \end{macro} |
| 1020 |
% \end{macro} |
| 1021 |
% \end{macro} |
| 1022 |
% \end{macro} |
| 1023 |
% \end{macro} |
| 1024 |
% \end{macro} |
| 1025 |
% \end{macro} |
| 1026 |
% \end{macro} |
| 1027 |
% |
| 1028 |
% Now, this next bit really gets up my nose. The only way to make |
| 1029 |
% sure that the \cs{index} command gets handled correctly when used |
| 1030 |
% inside of sectioning commands is to redefine a bunch of \LaTeX's |
| 1031 |
% table of contents and running-heads macros. $*$blech$*$ Fragility |
| 1032 |
% rears its ugly head again. |
| 1033 |
% |
| 1034 |
% These are based on \bundle{latex.tex} 2.09 \vdate{25 March 1992}. |
| 1035 |
% |
| 1036 |
% \begin{macro}{\addcontentsline} |
| 1037 |
% We need to redefine \cs{addcontentsline} to keep it from |
| 1038 |
% expanding \cs{index} commands too far. In particular, we have |
| 1039 |
% removed \cs{index} from the list of macros that are set equal to |
| 1040 |
% \cs{@gobble} and we substitute \cs{@vwritefile} for |
| 1041 |
% \cs{@writefile}. This latter change also means that we can |
| 1042 |
% simplify the definition of \cs{protect} somewhat. |
| 1043 |
% \begin{macrocode} |
| 1044 |
\CheckCommand\addtocontents[2]{% |
| 1045 |
\protected@write\@auxout |
| 1046 |
{\let\label\@gobble \let\index\@gobble \let\glossary\@gobble}% |
| 1047 |
{\string\@writefile{#1}{#2}}% |
| 1048 |
} |
| 1049 |
|
| 1050 |
\renewcommand{\addtocontents}[2]{% |
| 1051 |
\protected@write\@auxout |
| 1052 |
{\let\label\@gobble \let\glossary\@gobble}% |
| 1053 |
{\string\@writefile{#1}{#2}}% |
| 1054 |
} |
| 1055 |
% \end{macrocode} |
| 1056 |
% \end{macro} |
| 1057 |
% |
| 1058 |
% \begin{macro}{\@starttoc} |
| 1059 |
% We need to redefine \cs{@starttoc} to \cs{@addtoindexfalse} so |
| 1060 |
% that items don't get written to the index from within tables of |
| 1061 |
% contents. The only change here is the addition of |
| 1062 |
% \cs{@addtoindexfalse}. |
| 1063 |
% |
| 1064 |
% Unfortunately, this will break pretty badly with the AMS document |
| 1065 |
% classes, since they redefine \cs{@starttoc} to take two arguments |
| 1066 |
% rather than one. This must be addressed. |
| 1067 |
% |
| 1068 |
% \begin{macrocode} |
| 1069 |
\let\old@starttoc\@starttoc |
| 1070 |
|
| 1071 |
\renewcommand{\@starttoc}[1]{% |
| 1072 |
\begingroup |
| 1073 |
\@addtoindexfalse |
| 1074 |
\old@starttoc{#1}% |
| 1075 |
\endgroup |
| 1076 |
} |
| 1077 |
% \end{macrocode} |
| 1078 |
% \end{macro} |
| 1079 |
% |
| 1080 |
% \section{Finale} |
| 1081 |
% |
| 1082 |
% The usual \cs{endinput} to ensure that random garbage at the end of |
| 1083 |
% the file doesn't get copied by \texttt{docstrip}. |
| 1084 |
% \begin{macrocode} |
| 1085 |
\endinput |
| 1086 |
% \end{macrocode} |
| 1087 |
% |
| 1088 |
% \section{Edit history} |
| 1089 |
% |
| 1090 |
% \begin{description} |
| 1091 |
% |
| 1092 |
% \item[v1.00 (4 Mar 1993)] |
| 1093 |
% initial version, posted to comp.text.tex. |
| 1094 |
% |
| 1095 |
% \item[v1.01 (4 Mar 1993)] |
| 1096 |
% added \cs{renewindex} command and checking to make sure index is |
| 1097 |
% (or is not) defined in \cs{newindex}, \cs{index} and |
| 1098 |
% \cs{printindex}. Also tightened up the code in various places |
| 1099 |
% and added check to make sure file is only loaded once. |
| 1100 |
% |
| 1101 |
% \item[v2.00 (24 Mar 1993)] |
| 1102 |
% added support for \cs{index*}, proofmode, \cs{shortindexingon} |
| 1103 |
% and \cs{shortindexingoff}. |
| 1104 |
% |
| 1105 |
% \item[v2.01 (24 Jun 1993)] |
| 1106 |
% Fixed 3 bugs. (1) If proofmode was turned on, then something |
| 1107 |
% like ``\cs{index{WORD}WORD}'' would suppress the hyphenation of |
| 1108 |
% WORD. This was fixed by adding ``|\penalty\@M\hskip\z@skip|'' to |
| 1109 |
% the end of \cs{@showidx}. (This is just the definition of |
| 1110 |
% \cs{allowhyphens} borrowed from \bundle{german.sty}, v2 \vdate{4 |
| 1111 |
% Nov 1988}). (2) The \cs{hbox} in \cs{@mkidx} was being set at |
| 1112 |
% its natural width, which had a tendency to interfere with the |
| 1113 |
% width of the page. The \cs{hbox} is now replaced by \cs{rlap}. |
| 1114 |
% (3) If the title of an index (i.e., the fourth argument of |
| 1115 |
% \cs{newindex}) contained a particularly fragile command |
| 1116 |
% like~\cs{d}, havoc would ensue when \cs{theindex} tried to |
| 1117 |
% extract the title. Titles are now kept in token registers to |
| 1118 |
% prevent such unpleasantness. Bugs (2) and (3) were reported by |
| 1119 |
% Dominik Wujastyk \email{[email protected]} on 24 June 1993. |
| 1120 |
% Note that bugs (1) and (2) are actually bugs in showidx.sty, |
| 1121 |
% v2.09 \vdate{16 Jun 1991}. |
| 1122 |
% |
| 1123 |
% \item[v2.02 (25 Jun 1993)] |
| 1124 |
% Rewrote the code that implements the short indexing commands (|^| |
| 1125 |
% and |_|) to make index.sty compatible with other style files that |
| 1126 |
% need to make |^| and |^| active in some contexts. See the code |
| 1127 |
% for more details. |
| 1128 |
% |
| 1129 |
% \item[v2.03 (30 Jun 1993)] |
| 1130 |
% Once again rewrote the code that implements the short indexing |
| 1131 |
% commands. Dumped the shortindexing environment and rewrote the |
| 1132 |
% \cs{shortindexingon} and \cs{shortindxingoff} commands to save |
| 1133 |
% and restore the \cs{catcode}'s and meanings of |^| and |^| in the |
| 1134 |
% safest possible (I hope) order. Also added the |
| 1135 |
% \cs{if@shortindexing} flag to keep \cs{shortindexingoff} from |
| 1136 |
% doing anything if it is called outside of the scope of a |
| 1137 |
% \cs{shortindexingon} command. (Question: Should |
| 1138 |
% \cs{shortindexingon} check that flag before doing anything?) |
| 1139 |
% |
| 1140 |
% \item[v2.04 (beta) (14 Jul 1993)] |
| 1141 |
% Added \cs{disableindex} command. Added \cs{newindex} and |
| 1142 |
% \cs{renewindex} to \cs{@preamblecmds}. Added \cs{if@newindex} |
| 1143 |
% flag to \cs{@newindex} to prevent \cs{renewindex} from |
| 1144 |
% re-allocating new \cs{write} and \cs{toks} registers. Rewrote |
| 1145 |
% using \bundle{doc.sty} and \program{DocStrip}. Also cleaned up |
| 1146 |
% the code somewhat. |
| 1147 |
% |
| 1148 |
% \item[v3.00 (15 Jul 1993)] |
| 1149 |
% Made further minor tweaks to code and internal documentation. |
| 1150 |
% Booted version number up to 3.00 and released on the world. |
| 1151 |
% |
| 1152 |
% \item[v3.01 (19 Jul 1993)] |
| 1153 |
% Fixed \program{DocStrip} CheckSum. |
| 1154 |
% |
| 1155 |
% \item[v3.02 (15 Sep 1993)] |
| 1156 |
% Corrected spelling of \cs{@shortindexingfalse} in definition of |
| 1157 |
% \cs{shortindexingoff}. Thanks to Hendrik G. Seliger |
| 1158 |
% \email{[email protected]} for this bug report. |
| 1159 |
% Also added redefinitions of \cs{@leftmark} and \cs{@rightmark} to |
| 1160 |
% fix a bug reported by Dominik Wujastyk |
| 1161 |
% \email{[email protected]}. |
| 1162 |
% |
| 1163 |
% \item[v3.03 (beta) (20 Feb 1994)] |
| 1164 |
% Added \cs{long} to the definition of \cs{@ifundefined} to cover |
| 1165 |
% the unlikely contingency that someone wanted to use, for example, |
| 1166 |
% |\string\par| in the middle of a control sequence name. Added an |
| 1167 |
% optional argument to \cs{newindex} to specify which counter to |
| 1168 |
% use in place of \cs{thepage}. The first change was suggested by |
| 1169 |
% Martin Schr\"oder \email{[email protected]}; the second was |
| 1170 |
% suggested independently by Schr\"oder and Stefan Heinrich |
| 1171 |
% H\"oning \email{[email protected]}. The |
| 1172 |
% \cs{@newindex} command was renamed \cs{def@index}. Also fixed |
| 1173 |
% the \cs{disableindex} command. |
| 1174 |
% |
| 1175 |
% \item[v3.04 (7 Mar 1994)] |
| 1176 |
% Rewrote the user documentation (Sections 1--5) and released on |
| 1177 |
% the world. Also deleted some extraneous spaces that had crept |
| 1178 |
% into some macros. |
| 1179 |
% |
| 1180 |
% \item[v4.00beta, (20 Feb 1995)] |
| 1181 |
% Preliminary conversion to a native \LaTeXe\ package. Fixed |
| 1182 |
% \cs{@printindex} to work under \LaTeXe\ (bug reported by Carsten |
| 1183 |
% Folkertsma \email{[email protected]}). Removed much code |
| 1184 |
% that had been put in to work around various ancient versions of |
| 1185 |
% \LaTeX~2.09. Added \cs{index@prologue} support (modelled on |
| 1186 |
% \bundle{doc.sty}) at suggestion of Nick Higham |
| 1187 |
% \email{[email protected]}. |
| 1188 |
% |
| 1189 |
% \item[v4.01beta (28 Sep 1995)] |
| 1190 |
% Rewrote as a \LaTeXe\ package (finally!). Changes too numerous |
| 1191 |
% to list, but in general deleted some now-superfluous code, |
| 1192 |
% replaced some tricks by tricks from the \LaTeXe\ kernel, and |
| 1193 |
% added some bullet-proofing. Much still remains to be done, but |
| 1194 |
% this should be good enough for testing. |
| 1195 |
% |
| 1196 |
% Changed definition of \cs{protect} in \cs{markright} and |
| 1197 |
% \cs{markboth} to fix bug reported by Dominik Wujastyk. |
| 1198 |
% |
| 1199 |
% \item[??? (5 Jan 2004)] |
| 1200 |
% |
| 1201 |
% \end{description} |
| 1202 |
|
| 1203 |
\endinput |