Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit da941ef

Browse files
committed
Added support for storing information to build a module index.
Enhance the "theindex" environment to add an entry to the table of contents.
1 parent 875c807 commit da941ef

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

Doc/myformat.sty

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,13 @@
101101
\newcommand{\refbimodindex}[1]{\refmodule{#1}{built-in }}
102102
\newcommand{\refstmodindex}[1]{\refmodule{#1}{standard }}
103103

104+
% support for the module index
105+
\newwrite\modindexfile
106+
\openout\modindexfile=modules.idx
107+
104108
% Add the defining entry for a module
105-
\newcommand{\defmodindex}[2]{\index{#1@{\tt#1} (#2module)|textbf}}
109+
\newcommand{\defmodindex}[2]{\index{#1@{\tt#1} (#2module)|textbf}%
110+
\write\modindexfile{#1 \thepage}}
106111
\newcommand{\bimodindex}[1]{\defmodindex{#1}{built-in }}
107112
\newcommand{\stmodindex}[1]{\defmodindex{#1}{standard }}
108113

@@ -238,3 +243,13 @@
238243
\newenvironment{seealso}[0]{{\bf See Also: }}{\par}
239244
\newcommand{\seemodule}[2]{\ref{module-#1}: {\tt #1} (#2)}
240245
\newcommand{\seetext}[1]{\par{#1}}
246+
247+
% Fix the theindex environment to add an entry to the Table of Contents;
248+
% this is much nicer than just having to jump to the end of the book and
249+
% flip around, especially with multiple indexes.
250+
%
251+
\let\OldTheindex=\theindex
252+
\def\theindex{%
253+
\OldTheindex%
254+
\addcontentsline{toc}{chapter}{\indexname}%
255+
}

0 commit comments

Comments
 (0)