index.sty 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. %%% ====================================================================
  2. %%% @LaTeX-style-file{
  3. %%% author = "David M. Jones",
  4. %%% version = "2.00",
  5. %%% date = "24 March 1993",
  6. %%% time = "18:45:00 EST",
  7. %%% filename = "index.sty",
  8. %%% address = "MIT Laboratory for Computer Science
  9. %%% Room NE43-316
  10. %%% 545 Technology Square
  11. %%% Cambridge, MA 02139
  12. %%% USA",
  13. %%% telephone = "(617) 253-5936",
  14. %%% FAX = "(617) 253-3480",
  15. %%% checksum = "28116 661 2603 23730",
  16. %%% email = "dmjones@theory.lcs.mit.edu",
  17. %%% codetable = "ISO/ASCII",
  18. %%% keywords = "LaTeX, index",
  19. %%% supported = "yes",
  20. %%% docstring = "This is a reimplementation of LaTeX's
  21. %%% indexing macros to provide better support
  22. %%% for indexing in LaTeX. In particular, it
  23. %%% provides:
  24. %%%
  25. %%% (a) Support for multiple indexes, which
  26. %%% are declared using the \newindex and
  27. %%% \renewindex commands.
  28. %%%
  29. %%% (b) A two-stage process for creating the
  30. %%% raw index files (such as the default .idx
  31. %%% file), similar to that used to create the
  32. %%% .toc file. That is, the index entries are
  33. %%% first written to the .aux file, and then
  34. %%% copied to the .idx file at the end of the
  35. %%% run. This means that if you have a large
  36. %%% document consisting of several \include'd
  37. %%% files, you no longer lose the index if you
  38. %%% format only part of the document with
  39. %%% \includeonly.
  40. %%%
  41. %%% (c) A *-variant of the \index command
  42. %%% that, in addition to putting it's argument
  43. %%% in the Index, also typesets it in the
  44. %%% running text.
  45. %%%
  46. %%% (d) A \shortindexingon command that causes
  47. %%% ^{foo} to be shorthand for \index{foo} and
  48. %%% _{foo} to be shorthand for \index*{foo}
  49. %%% (only outside of math mode, of course).
  50. %%% These shorthands can be turned off with
  51. %%% \shortindexingoff command.
  52. %%%
  53. %%% (e) The functionality of the showidx style
  54. %%% option has been merged into this file.
  55. %%% The command \proofmodetrue can be used to
  56. %%% enable the printing of index entries in
  57. %%% the margin of pages. The size and style
  58. %%% of font can be controlled with the the
  59. %%% \indexproofstyle command.
  60. %%%
  61. %%% (f) The \index command has been rewritten
  62. %%% to be more robust. In particular, it no
  63. %%% longer depends on \catcode changes to work
  64. %%% properly, so the new \index command can be
  65. %%% used in places that the original couldn't,
  66. %%% such as inside the arguments of other
  67. %%% macros.
  68. %%%
  69. %%% There is a sample file after the \endinput
  70. %%% command.
  71. %%%
  72. %%% The definitive version of this file is
  73. %%% theory.lcs.mit.edu:pub/tex/index.sty.
  74. %%%
  75. %%% CAVEATS: In order to implement these
  76. %%% improvements, it's been necessary to
  77. %%% modify a number of LaTeX commands
  78. %%% seemingly unrelated to indexing, including
  79. %%% the following: \@starttoc, \raggedbottom,
  80. %%% \flushbottom, \addcontentsline, \markboth,
  81. %%% \markright. Naturally, this could cause
  82. %%% incompatibilities between index.sty and
  83. %%% any style files that either redefine these
  84. %%% same commands or make specific assumptions
  85. %%% about how they operate. See below for
  86. %%% explanations of why these various commands
  87. %%% needed modification.
  88. %%%
  89. %%% It's also been necessary to modify the
  90. %%% \theindex environment, but I've tried to
  91. %%% do so very conservatively. If your style
  92. %%% file uses \indexname, you should be ok.
  93. %%% Otherwise, you'll have to redefine the
  94. %%% \theindex environment yourself if you
  95. %%% don't want the LaTeX book.sty default.
  96. %%%
  97. %%% TO DO: I really should rewrite this using
  98. %%% doc.sty. Also, it might be nice if the
  99. %%% \index* command parsed it's argument so
  100. %%% that, for example, you could say
  101. %%% `\index*{sin@$\sin$}' as a synonym for
  102. %%% `\index{sin@$\sin$}$\sin$'. However, this
  103. %%% fraught with numerous dangers and I'm both
  104. %%% too lazy and too cowardly to undertake it
  105. %%% now.
  106. %%%
  107. %%% Maybe it would be nice if this package were
  108. %%% plain TeX compatible.",
  109. %%%
  110. %%% edit-history = "v2.00 (24 Mar 1993): added support for
  111. %%% \index*, proofmode, \shortindexingon and
  112. %%% \shortindexingoff.
  113. %%%
  114. %%% v1.01 (4 Mar 1993): added \renewindex
  115. %%% command and checking to make sure index is
  116. %%% (or is not) defined in \newindex, \index
  117. %%% and \printindex. Also tightened up the
  118. %%% code in various places and added check to
  119. %%% make sure file is only loaded once.
  120. %%%
  121. %%% v1.00 (4 Mar 1993): initial version,
  122. %%% posted to comp.text.tex
  123. %%%
  124. %%% The checksum field above contains a CRC-16
  125. %%% checksum as the first value, followed by
  126. %%% the equivalent of the standard UNIX wc
  127. %%% (word count) utility output of lines,
  128. %%% words, and characters. This is produced
  129. %%% by Robert Solovay's checksum utility.",
  130. %%% }
  131. %%% ====================================================================
  132. \@ifundefined{newindex}{}{\endinput}
  133. \typeout{Style-Option: `index' v2.00 <24 Mar 1993> (dmj)}
  134. %% The following redefinitions of internal LaTeX commands are
  135. %% borrowed from amsart.sty, v1.1b <31 Jul 1991>. I don't
  136. %% particularly need \@leftmark and \@rightmark to be \long in this
  137. %% style file, but it seems like a reasonable idea. I do rely
  138. %% heavily upon this more robust definition of \@ifundefined.
  139. \long\def\@leftmark#1#2{#1}
  140. \long\def\@rightmark#1#2{#2}
  141. \def\@ifundefined#1{%
  142. \expandafter\ifx\csname#1\endcsname\relax
  143. \expandafter\@leftmark
  144. \else
  145. \expandafter\@rightmark
  146. \fi
  147. }
  148. %% The \newindex command is used to declare new indexes; the
  149. %% \renewindex command is used to redefine existing indexes. The
  150. %% first argument is a short tag to be used to refer to the index.
  151. %% The commands \index and \printindex are redefined to take an
  152. %% optional argument, the tag of the index referred to. Thus, if you
  153. %% have defined an author index with the tag ``aut'', the command
  154. %% \index[aut]{foo} will add an entry to the author index, and the
  155. %% command \printindex[aut] will print the author index. If the
  156. %% optional argument is absent, the index with the tag ``default'' is
  157. %% used. (This normally corresponds to the usual index declared by
  158. %% \makeindex.) The second argument is the extension of the raw
  159. %% index file where LaTeX should dump the unprocessed entries for
  160. %% this index. The third argument is the extension of the index file
  161. %% where LaTeX will expect to find the processed index. The fourth
  162. %% argument is the name of the index.
  163. %% Examples:
  164. %% \newindex{default}{idx}{ind}{\indexname} %equivalent to \makeindex
  165. %% \newindex{aut}{adx}{and}{Name Index}
  166. %% \newindex{not}{ndx}{nnd}{Index of Notation}
  167. %% #1 = tag (default, author, notation, etc.)
  168. %% #2 = extension (idx, adx, ndx, etc.) of the raw index file
  169. %% #3 = extension of processed file (ind, and, nnd, etc.)
  170. %% #4 = title (Subject Index, Name Index, Index of Notation, etc.)
  171. \def\newindex#1{%
  172. \@ifundefined{idx@#1}%
  173. {\@newindex{#1}}%
  174. {%
  175. \@latexerr{Index type `\string#1' already defined}\@ehc
  176. \expandafter\@gobble\@gobbletwo
  177. }%
  178. }
  179. \def\renewindex#1{%
  180. \@ifundefined{idx@#1}%
  181. {\@latexerr{Index type `\string#1' not defined}\@ehc}%
  182. {}%
  183. \@newindex{#1}%
  184. }
  185. \def\@newindex#1#2#3#4{%
  186. \@namedef{idx@#1}{#2:#3:#4}%
  187. \if@filesw
  188. \expandafter\newwrite\csname tf@#1\endcsname
  189. \immediate\openout\@nameuse{tf@#1}=\jobname.#2
  190. \typeout{Writing index file \jobname.#2 }%
  191. \fi
  192. }
  193. %% These are useful macros for getting to specific fields of an Index
  194. %% specification.
  195. %% \def\@first#1:#2\@nil{#1}
  196. \def\@second#1:#2:#3\@nil{#2}
  197. \def\@third#1:#2:#3\@nil{#3}
  198. %% \@nearverbatim\foo is much like \meaning\foo, except that it
  199. %% suppresses the ``macro ->'' string produced when \meaning expands
  200. %% a macro. It is used by \@wrindex and \@vwritefile to produce an
  201. %% ``almost verbatim'' copy of their arguments. This method replaces
  202. %% the use of \@sanitize from latex.tex and allows indexing macros to
  203. %% be used in places (such as inside \mbox's) where the original
  204. %% \index command could not. Thanks to Donald Arseneau
  205. %% <asnd@erich.triumf.ca> for pointing out this trick to me. (For
  206. %% more information on this trick, see Dirty Trick #3 of the TeXbook,
  207. %% page 382).
  208. \def\@nearverbatim#1{\expandafter\@meaning\meaning#1}
  209. \def\@meaning#1>{}
  210. %% The following are adapted from latex.tex v2.09 <25 March 1992>.
  211. \def\makeindex{\newindex{default}{idx}{ind}{\indexname}}
  212. %% We need three new flags. The first indicates whether the entry
  213. %% should be typeset in running text, as well as written out to the
  214. %% index; this is used to implement the \index* command. The second
  215. %% indicates whether entries should be written to the index; this is
  216. %% used to disable the \index command inside of page headings and
  217. %% tables of contents. The third indicates whether index entries
  218. %% should be put in the margin of the page for proofing purposes.
  219. \newif\if@silentindex\@silentindextrue
  220. \newif\if@addtoindex\@addtoindextrue
  221. \newif\ifproofmode\proofmodefalse
  222. %% \index will be made self-protecting (a la \em, etc.) so it can be
  223. %% used inside, for example, sectioning commands. Unfortunately, to
  224. %% really make \index robust, we have to redefine some of LaTeX's
  225. %% commands for dealing with tables of contents and page headings.
  226. %% (See below.) *sigh*
  227. \def\index{\protect\p@index}
  228. \def\p@index{\if@silentindex\@bsphack\fi
  229. \@ifstar{\@silentindexfalse\@xindex}{\@silentindextrue\@xindex}%
  230. }
  231. \def\@xindex{\@ifnextchar[{\@index}{\@index[default]}}
  232. %% This is much more complicated than it should have to be. First,
  233. %% note the check to see if \index is equal to \@gobble. This is so
  234. %% I don't have to redefine \@outputpage, which temporarily disables
  235. %% \label, \index, and \glossary by \let'ing them equal to \@gobble.
  236. %% (For this reason, we have to be very careful to make sure that
  237. %% \index has expanded to \p@index before it gets to \@outputpage.)
  238. %% Second, note that if \if@addtoindex is false, we don't complain
  239. %% about undefined index types. This is because if your page
  240. %% headings, for example, are being typeset in all uppercase, you
  241. %% might end up with something like \index[AUT]{...} instead of
  242. %% \index[aut]{...}.
  243. \def\@index[#1]{%
  244. \ifx\index\@gobble
  245. \@addtoindexfalse
  246. \fi
  247. \def\@tempf{\@@index{#1}}%
  248. \if@addtoindex
  249. \@ifundefined{idx@#1}%
  250. {%
  251. \def\@tempf{\@latexerr{Index type `\string#1' undefined}%
  252. \@ehc\@silentindextrue}%
  253. }%
  254. {}%
  255. \fi
  256. \@tempf
  257. }
  258. \def\@@index#1#2{%
  259. \if@addtoindex
  260. \if@filesw\@wrindex{#1}{#2}\fi
  261. \ifproofmode\@showidx{#2}\fi
  262. \fi
  263. \if@silentindex\expandafter\@esphack\else\@silentindextrue#2\fi
  264. }
  265. \def\@wrindex#1#2{%
  266. \begingroup
  267. \let\thepage\relax
  268. \def\@tempa{#2}%
  269. \edef\@tempa{%
  270. \write\@auxout{%
  271. \string\@vwritefile{#1}%
  272. {\string\indexentry{\@nearverbatim\@tempa}{\thepage}}%
  273. }%
  274. }%
  275. \expandafter\endgroup\@tempa
  276. \if@nobreak\ifvmode\nobreak\fi\fi
  277. }
  278. %% The following are adapted from makeidx.sty, v2.09 <21 Oct 91>.
  279. \@ifundefined{seename}{\def\seename{see}}{}
  280. \def\see#1#2{{\em \seename\/} #1}
  281. \def\printindex{\@ifnextchar [{\@printindex}{\@printindex[default]}}
  282. \def\@printindex[#1]{%
  283. \def\@indextype{#1}%
  284. \@ifundefined{idx@#1}%
  285. {\@latexerr{Index type `\string#1' undefined}\@ehc}%
  286. {%
  287. \edef\@tempa{\@nameuse{idx@#1}}%
  288. \@input{\jobname.\expandafter\@second\@tempa\@nil}%
  289. }%
  290. }
  291. %% Now we set things up for \shortindexing. First we carefully
  292. %% define the values that ^ and _ should have when active:
  293. \def\@indexstar@{\index*}
  294. \begingroup
  295. \catcode`\^=\active \catcode`\_=\active
  296. \gdef^{\relax\ifmmode\expandafter\sp\else\expandafter\@indexstar@\fi}
  297. \gdef_{\relax\ifmmode\expandafter\sb\else\expandafter\index\fi}
  298. \endgroup
  299. %% Then we define \shortindexingon to first save the current
  300. %% \catcodes of ^ and _ so that \shortindexingoff can restore the
  301. %% meanings in place before \shortindexingon was called. Havoc will
  302. %% be wrought if the \catcode's are changed to some other value
  303. %% between the time that \shortindexingon is called and the time that
  304. %% \shortindexingoff is called.
  305. \def\shortindexingon{%
  306. \edef\shortindexingoff{%
  307. \catcode`\noexpand\^=\the\catcode`\^\relax
  308. \catcode`\noexpand\_=\the\catcode`\_\relax
  309. }%
  310. \catcode`\^=\active \catcode`\_=\active\relax
  311. }
  312. %% Now we make sure \shortindexingoff has the right default value.
  313. \shortindexingon\shortindexingoff
  314. %% Thanks to Alan Jeffrey <alanje@cogs.sussex.ac.uk> for pointing out
  315. %% how the package should behave when \indexname is already defined
  316. %% and for the code to implement that case.
  317. \expandafter\ifx\csname indexname\endcsname\relax
  318. \message{index.sty> Uh oh! It looks like your document style
  319. doesn't use \string\indexname.}
  320. \message{index.sty> I'll have to redefine the
  321. \string\theindex\space environment, using}
  322. \message{index.sty> the `book' style default.}
  323. \def\indexname{Index}
  324. %% The following is adapted from book.sty v2.09 <14 Jan 92>.
  325. \def\theindex{%
  326. \@restonecoltrue
  327. \if@twocolumn\@restonecolfalse\fi
  328. \columnseprule\z@ \columnsep 35\p@
  329. \edef\@indexname{\@nameuse{idx@\@indextype}}%
  330. \edef\@indexname{\expandafter\@third\@indexname\@nil}%
  331. \twocolumn[\@makeschapterhead{\@indexname}]%
  332. \@mkboth{\uppercase{\@indexname}}{\uppercase{\@indexname}}%
  333. \thispagestyle{plain}%
  334. \parindent\z@
  335. \parskip\z@ plus .3\p@\relax\let\item\@idxitem
  336. }
  337. \else
  338. \@temptokena={%
  339. \edef\indexname{\@nameuse{idx@\@indextype}}%
  340. \edef\indexname{\expandafter\@third\indexname\@nil}%
  341. }
  342. \toks0=\expandafter{\theindex}
  343. \edef\theindex{\the\@temptokena\the\toks0}
  344. \fi
  345. %% \@vwritefile performs essentially the same function as
  346. %% \@writefile, except that it does not expand it second argument
  347. %% (i.e., it writes it out verbatim (well, almost verbatim)).
  348. %% NOTE: There doesn't seem to be any reason why \@writefile *should*
  349. %% expand it's second argument and in fact, we later redefine
  350. %% \addcontentsline to use \@vwritefile instead of \@writefile. A
  351. %% slight extension of this idea could be used to solve the problem
  352. %% of fragility in sectioning commands.
  353. %% \@vwritefile, like \@writefile, should be disabled when the .aux
  354. %% file is being read in by \begin{document}. To avoid modifying
  355. %% \document, we make the behaviour of \@vwritefile conditional on
  356. %% the current meaning of \@writefile.
  357. \def\@vwritefile{%
  358. \ifx\@writefile\@gobbletwo
  359. \expandafter\@gobbletwo
  360. \else
  361. \expandafter\x@vwritefile
  362. \fi
  363. }
  364. \def\x@vwritefile#1{%
  365. \@ifundefined{tf@#1}{\@gobbletwo}{\y@vwritefile}{#1}%
  366. }
  367. \long\def\y@vwritefile#1#2{%
  368. \def\@tempa{#2}%
  369. \immediate\write\csname tf@#1\endcsname{\@nearverbatim\@tempa}%
  370. }
  371. %% Now let's take some code from showidx.sty and merge it into our
  372. %% new system. There are three reasons for redefining the commands
  373. %% here rather than just inputting showidx.sty (or requiring the user
  374. %% to do so). First, showidx.sty ends with a call to \flushbottom,
  375. %% which I want to avoid. Second, the instructions for successfully
  376. %% using showidx.sty along with index.sty would be somewhat tricky.
  377. %% This way, I can just tell users not to use showidx.sty at all.
  378. %% (If I were feeling really paranoid, I could implement something
  379. %% that would disable the showidx style option, but I won't.) Third,
  380. %% I need to make some alterations to \@showidx anyway. In
  381. %% particular, (a) I need to add the \@sanitizeat command so this
  382. %% works correctly with AMS-LaTeX and (b) I want to add the
  383. %% \indexproofstyle command so the user can customize the size and
  384. %% font used for the index proofs.
  385. %% These are adapted from showidx.sty, v2.09 <16 Jun 1991>.
  386. \newinsert\indexbox
  387. \dimen\indexbox=\maxdimen
  388. %% Partly I'm just being silly here, but partly there's a good reason
  389. %% for doing things this way. I can't define \@sanitizeat directly,
  390. %% since its definition requires @ to be active, and thus ineligible
  391. %% to be part of a command name. On the other hand, I don't want to
  392. %% define something like \sanitizeat, since that's in the user's
  393. %% namespace. So, I use a temporary control sequence that is
  394. %% unlikely to conflict with anything.
  395. \begingroup
  396. \catcode`\?=11
  397. \catcode`\!=11
  398. \begingroup
  399. \catcode`\@=\active
  400. \gdef\?!?{\def @{\char`\@}}
  401. \endgroup
  402. \global\let\@sanitizeat\?!?
  403. \endgroup
  404. \newtoks\indexproofstyle
  405. %% Note the cautious way of calling \reset@font, which is necessary
  406. %% for this to work correctly under the NFSS.
  407. \indexproofstyle{\footnotesize\csname reset@font\endcsname\tt}
  408. \def\@showidx#1{%
  409. \insert\indexbox{%
  410. \@sanitizeat
  411. \the\indexproofstyle
  412. \hsize\marginparwidth
  413. \hangindent\marginparsep \parindent\z@
  414. \everypar{}\let\par\@@par \parfillskip\@flushglue
  415. \lineskip\normallineskip
  416. \baselineskip .8\normalbaselineskip\sloppy
  417. \raggedright \leavevmode
  418. \vrule \@height .7\normalbaselineskip \@width \z@\relax#1\relax
  419. \vrule \@height\z@ \@depth.3\normalbaselineskip \@width\z@\relax
  420. }%
  421. }
  422. \def\@leftidx{\hskip-\marginparsep \hskip-\marginparwidth}
  423. \def\@rightidx{\hskip\columnwidth \hskip\marginparsep}
  424. \def\@mkidx{%
  425. \vbox to \z@{%
  426. \hbox{%
  427. \if@twocolumn
  428. \if@firstcolumn \@leftidx \else \@rightidx \fi
  429. \else
  430. \if@twoside
  431. \ifodd\c@page \@rightidx \else \@leftidx \fi
  432. \else
  433. \@rightidx
  434. \fi
  435. \fi
  436. \box\indexbox
  437. }%
  438. \vss
  439. }%
  440. }
  441. \def\raggedbottom{%
  442. \def\@textbottom{\vskip\z@ plus.0001fil}%
  443. \let\@texttop\@mkidx
  444. }
  445. \def\flushbottom{\let\@textbottom\relax \let\@texttop\@mkidx}
  446. \let\@texttop\@mkidx
  447. %% Now, this really gets up my nose. The only way to make sure that
  448. %% the \index command gets handled correctly when used inside of
  449. %% sectioning commands is to redefine a bunch of LaTeX's table of
  450. %% contents and running-heads macros. *blech* Fragility rears its ugly
  451. %% head again. (Incidentally, it should be possible to use the
  452. %% \@nearverbatim trick to make arguments of sectioning commands
  453. %% robust. I'll have to explore this.)
  454. %% These are based on latex.tex 2.09 <25 March 1992>.
  455. %% We need to redefine \addcontentsline to keep it from expanding
  456. %% \index commands too far.
  457. \def\addcontentsline#1#2#3{%
  458. \if@filesw
  459. \begingroup
  460. \let\label\@gobble
  461. \let\glossary\@gobble
  462. \def\protect##1{\string##1\space}%
  463. \@temptokena{\thepage}%
  464. \edef\@tempa{%
  465. \write\@auxout
  466. {\string\@vwritefile{#1}{\string\contentsline{#2}{#3}%
  467. {\the\@temptokena}}%
  468. }%
  469. }%
  470. \@tempa
  471. \endgroup
  472. \if@nobreak\ifvmode\nobreak\fi\fi
  473. \fi
  474. }
  475. %% We need to redefine \@starttoc to \@addtoindexfalse so that items
  476. %% don't get written to the index from within tables of contents.
  477. \def\@starttoc#1{%
  478. \begingroup
  479. \@addtoindexfalse
  480. \makeatletter
  481. \@input{\jobname.#1}%
  482. \if@filesw
  483. \expandafter\newwrite\csname tf@#1\endcsname
  484. \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
  485. \fi
  486. \global\@nobreakfalse
  487. \endgroup
  488. }
  489. %% We have to redefine \markboth and \markright to keep them from
  490. %% disabling the expansion of \index while putting section heads into
  491. %% the \mark. Otherwise, we'd end up with ``\index'' in the mark,
  492. %% which would cause problems when \@outputpage redefines \index to be
  493. %% equal to \@gobble. Instead, we want \index to expand to \p@index
  494. %% in the \mark, so we retain control over what happens in
  495. %% \@outputpage.
  496. \def\markboth#1#2{%
  497. \gdef\@themark{{#1}{#2}}%
  498. \begingroup
  499. \let\protect\noexpand
  500. \let\label\relax
  501. \let\glossary\relax
  502. \mark{\@themark}%
  503. \endgroup
  504. \if@nobreak\ifvmode\nobreak\fi\fi
  505. }
  506. \def\markright#1{%
  507. \begingroup
  508. \let\protect\noexpand
  509. \let\label\relax
  510. \let\glossary\relax
  511. \expandafter\@markright\@themark{#1}%
  512. \mark{\@themark}%
  513. \endgroup
  514. \if@nobreak\ifvmode\nobreak\fi\fi
  515. }
  516. \endinput
  517. %% This is a sample file for index.sty. To run the sample, save the
  518. %% following in a file testidx.tex. Then execute the following
  519. %% commands:
  520. %%
  521. %% latex testidx.tex
  522. %% makeindex testidx
  523. %% makeindex -o testidx.and testidx.adx
  524. %% makeindex -o testidx.nnd testidx.ndx
  525. %% latex testidx.tex
  526. \documentstyle[index]{book}
  527. \makeindex
  528. \newindex{aut}{adx}{and}{Name Index}
  529. \newindex{not}{ndx}{nnd}{List of Notation}
  530. \shortindexingon
  531. \proofmodetrue
  532. \def\aindex{\index*[aut]}
  533. \begin{document}
  534. \tableofcontents
  535. \newpage
  536. \chapter{Here is a ^[aut]{chapter} title}
  537. \section{Section header\index[aut]{section}}
  538. Here is some text.\index{subject}
  539. Here is \index[not]{notation}some more \index[not]{sin@$\sin$} text.
  540. Here is some ^{more} _[not]{notation} text.
  541. Here is yet more \aindex{text}.
  542. \section{Another Section header _[aut]{section2}}
  543. And here is some math: $x^1_b$.
  544. Here is an ^[aut]{index} entry \fbox{inside an
  545. \index[not]{min@$\min$}fbox}
  546. \fbox{Here is an ^[aut]{entry} in a box.}
  547. \printindex[not]
  548. \printindex[aut]
  549. \printindex
  550. \end{document}