1 % \iffalse meta-comment
4 % The LaTeX3 Project and any individual authors listed elsewhere
7 % This file is part of the LaTeX base system.
8 % -------------------------------------------
10 % It may be distributed and/or modified under the
11 % conditions of the LaTeX Project Public License, either version 1.3c
12 % of this license or (at your option) any later version.
13 % The latest version of this license is in
14 % http://www.latex-project.org/lppl.txt
15 % and version 1.3c or later is part of all distributions of LaTeX
16 % version 2005/12/01 or later.
18 % This file has the LPPL maintenance status "maintained".
20 % The list of all files belonging to the LaTeX base distribution is
21 % given in the file `manifest.txt'. See also `legal.txt' for additional
24 % The list of derived (unpacked) files belonging to the distribution
25 % and covered by LPPL is defined by the unpacking scripts (with
26 % extension .ins) which are part of the distribution.
31 % Copyright (C) 1985 by Leslie Lamport
32 % Copyright (C) 1994-98 by \LaTeX3 Project and Johannes Braams
35 % \changes{1.0b}{1994/01/21}{added a missing \cs{end\{macro\}}, a
36 % missing docstrip end of module and corrected a few typos}
37 % \changes{1.0d}{1994/02/11}{Corrected a few documentation errors;
38 % added \cs{Checksum}}
39 % \changes{1.0e}{1994/02/22}{Another documentation flaw fixed}
40 % \changes{1.0f}{1994/03/01}{Moved driver further up; corrected a few
42 % \changes{1.0f}{1994/03/01}{Added overview of {\sc docstrip} modules}
43 % \changes{1.0i}{1994/11/11}{(DPC) Removed spurious \cs{wlog}}
44 % \changes{1.0k}{1998/08/17}{(RmS) Minor documentation corrections.}
45 % \changes{1.0m}{2000/03/29}{(RmS) Added macros \cs{seealso} and \cs{alsoname}.}
47 %\title{Standard \LaTeXe\ packages \texttt{makeidx} and
55 % Frank Mittelbach\and
60 % \MaintainedByLaTeXTeam{latex}
63 % \section{Description}
65 % \subsection{Makeidx}
67 % The package \texttt{makeidx} provides two new commands, |\see|
71 % The command |\see| can used in the index to cross reference to
74 % \DescribeMacro\printindex
75 % This command can be used to include the sorted and formatted
76 % index in the document.
78 % \subsection{Showidx}
80 % The package \texttt{showidx} changes a number of internal
81 % \LaTeXe\ commands in such a way that each index entry is shown in
82 % the margin on the page where the entry appears. This package was
83 % originally meant to be used with the \texttt{report} and
84 % \texttt{book} document classes, but works with other classes as
85 % well. It makes |\flushbottom| the default.
89 % \section{The {\sc docstrip} modules}
91 % The following modules are used in the implementation to direct
92 % {\sc docstrip} in generating the external files:
95 % makeidx & produce makeidx.sty\\
96 % showidx & produce showidx.sty\\
97 % driver & produce a documentation driver file \\
101 % \section{The documentation driver file}
103 % The next bit of code contains the documentation driver file for
104 % \TeX{}, i.e., the file that will produce the documentation you are
105 % currently reading. It can be extracted from this file by the
106 % {\sc docstrip} program.
109 \documentclass{ltxdoc}
111 \DocInput{makeindx.dtx}
116 % \section{Implementation}
118 % \subsection{Identification}
120 % Announce the package and its version:
121 % \changes{v1.0h}{1994/05/01}{Removed use of variables}
123 %<makeidx>\ProvidesPackage{makeidx}
124 %<showidx>\ProvidesPackage{showidx}
125 [2014/09/29 v1.0m Standard LaTeX package]
128 % \subsection{Makeidx}
130 % \begin{macro}{\see}
131 % This macro discards its second argument (typically a page number)
132 % and just prints |\seename| together with the entry the reader is
134 % \changes{v1.0j}{1995/04/19}{Use \cs{emph} instead of \cs{em}}
135 % \changes{v1.0j}{1995/04/19}{Disallow \cs{par} in argument}
138 \newcommand*\see[2]{\emph{\seename} #1}
142 % \begin{macro}{\seealso}
143 % \changes{v1.0m}{2000/03/29}{Macro added (see PR 3133).}
144 % This macro discards its second argument (typically a page number)
145 % and just prints |\alsoname| together with the entry the reader is
146 % pointed to. We use |\providecommand| to retain compatibility with
147 % existing files that define this macro.
149 \providecommand*\seealso[2]{\emph{\alsoname} #1}
153 % \begin{macro}{\printindex}
154 % This command simply inputs the (formatted) index if it exists,
155 % otherwise a warning is issued.
156 % \changes{1.0c}{1994/02/08}{Use \cs{@input@} instead of \cs{@input} to
157 % get the index listed by \cs{listfiles}}
159 \newcommand\printindex{\@input@{\jobname.ind}}
163 % \begin{macro}{\seename}
164 % This package is for documents prepared in the English language.
165 % To prepare a version for another language, various English words
166 % must be replaced. All the English words that require replacement
167 % are% defined below in command names.
168 % \changes{1.0g}{1994/03/07}{Replaced \cs{newcommand} by \cs{providecommand}.}
170 \providecommand\seename{see}
172 % We used |\providecommand| in case the command is already defined
173 % by a package loaded earlier.
176 % \begin{macro}{\alsoname}
177 % \changes{v1.0m}{2000/03/29}{Macro added (see PR 3133).}
178 % This macro discards its second argument (typically a page number)
179 % and just prints |\alsoname| together with the entry the reader is
180 % pointed to. We use |\providecommand| to retain compatibility with
181 % existing files that define this macro.
183 \providecommand*\alsoname{see also}
188 % \subsection{showidx}
190 % \begin{macro}{\indexbox}
191 % This package uses \TeX's insert mechanism, therefore it needs to
192 % allocate an insert register.
196 \dimen\indexbox=\maxdimen
200 % \begin{macro}{\index}
201 % This is a modified default definition for the user level |\index|
202 % command. The difference is the change of the category code of the
205 \renewcommand\index{\@bsphack\begingroup
206 \@sanitize\catcode32=10\relax\@index}
210 % \begin{macro}{\makeindex}
211 % The same change has to be included in the user level |\makeindex|
212 % command, which changes the definition of |\index| to actually
213 % write index entries to an external file.
215 \renewcommand\makeindex{\if@filesw \newwrite\@indexfile
216 \immediate\openout\@indexfile=\jobname.idx
217 \def\index{\@bsphack\begingroup
218 \def\protect####1{\string####1\space}\@sanitize
219 \catcode32=10 \@wrindex\@indexfile}\typeout
220 {Writing index file \jobname.idx }\fi}
224 % \begin{macro}{\@wrindex}
225 % This macro takes care of writing the index entries to a file. The
226 % definition is modified to call |\@showidx|.
228 \def\@wrindex#1#2{\let\thepage\relax
229 \xdef\@gtempa{\write#1{\string
230 \indexentry{#2}{\thepage}}}\endgroup\@gtempa
231 \@showidx{#2}\if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
235 % \begin{macro}{\@index}
236 % When the user didn't use the |\makeindex| command, the |\index|
237 % macro calls |\@index|, which normally does basically nothing.
238 % This package changes the definition to call |\@showidx|, which
239 % includes the entry in the list of indexentries on the current page.
241 \def\@index#1{\@showidx{#1}\endgroup\@esphack}
245 % \begin{macro}{\@showidx}
246 % This macro adds the current index entry to the insert
247 % |\indexbox|. The |\indexbox| is typeset as a flushleft paragraph.
250 \insert\indexbox{\small
251 \hsize\marginparwidth
252 \hangindent\marginparsep \parindent\z@
253 \everypar{}\let\par\@@par \parfillskip\@flushglue
254 \lineskip\normallineskip
255 \baselineskip .8\normalbaselineskip\sloppy
256 \raggedright \leavevmode
257 \vrule \@height .7\normalbaselineskip \@width \z@\relax
259 \vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@}}
263 % \begin{macro}{\raggedbottom}
264 % \begin{macro}{\flushbottom}
265 % The definition of these macros from \texttt{latex.dtx} is changed
266 % here to add the execution of |\@mkidx| to |\@texttop|, which is
267 % executed at the top of each page.
269 \renewcommand\raggedbottom{\def\@textbottom{\vskip
270 \z@ plus.0001fil}\let\@texttop\@mkidx}
271 \renewcommand\flushbottom{\let\@textbottom\relax
272 \let\@texttop\@mkidx}
277 % \begin{macro}{\@mkidx}
278 % This macro actually typesets the box containing all the index
279 % entries on the current page. They will occur on the left or the
280 % right side of the text, or both, depending on the setting of the
281 % switches |\if@twocolumn| and |\if@twoside|.
283 \def\@mkidx{\vbox to \z@{\hbox{\if@twocolumn
284 \if@firstcolumn \@leftidx \else \@rightidx \fi
285 \else \if@twoside \ifodd\c@page \@rightidx
293 % \begin{macro}{\@leftidx}
294 % \begin{macro}{\@rightidx}
295 % These macros give the amount of displacement for the |\indexbox|.
297 \def\@leftidx{\hskip-\marginparsep \hskip-\marginparwidth}
298 \def\@rightidx{\hskip\columnwidth \hskip\marginparsep}
303 % To make this work we have to execute either |\raggedbottom| or
304 % |\flushbottom|. Assuming this package is used most often with the
305 % document classes \texttt{report} and \texttt{book}, we execute