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.
30 % Copyright (C) 1985 by Leslie Lamport
31 % Copyright (C) 1994-98 by \LaTeX3 Project and Johannes Braams
34 % \changes{1.0b}{1994/01/21}{added a missing \cs{end\{macro\}}, a
35 % missing docstrip end of module and corrected a few typos}
36 % \changes{1.0d}{1994/02/11}{Corrected a few documentation errors;
37 % added \cs{Checksum}}
38 % \changes{1.0e}{1994/02/22}{Another documentation flaw fixed}
39 % \changes{1.0f}{1994/03/01}{Moved driver further up; corrected a few
41 % \changes{1.0f}{1994/03/01}{Added overview of {\sc docstrip} modules}
42 % \changes{1.0i}{1994/11/11}{(DPC) Removed spurious \cs{wlog}}
43 % \changes{1.0k}{1998/08/17}{(RmS) Minor documentation corrections.}
44 % \changes{1.0m}{2000/03/29}{(RmS) Added macros \cs{seealso} and \cs{alsoname}.}
46 %\title{Standard \LaTeXe\ packages \texttt{makeidx} and
54 % Frank Mittelbach\and
59 % \MaintainedByLaTeXTeam{latex}
62 % \section{Description}
64 % \subsection{Makeidx}
66 % The package \texttt{makeidx} provides two new commands, |\see|
70 % The command |\see| can used in the index to cross reference to
73 % \DescribeMacro\printindex
74 % This command can be used to include the sorted and formatted
75 % index in the document.
77 % \subsection{Showidx}
79 % The package \texttt{showidx} changes a number of internal
80 % \LaTeXe\ commands in such a way that each index entry is shown in
81 % the margin on the page where the entry appears. This package was
82 % originally meant to be used with the \texttt{report} and
83 % \texttt{book} document classes, but works with other classes as
84 % well. It makes |\flushbottom| the default.
88 % \section{The {\sc docstrip} modules}
90 % The following modules are used in the implementation to direct
91 % {\sc docstrip} in generating the external files:
94 % makeidx & produce makeidx.sty\\
95 % showidx & produce showidx.sty\\
96 % driver & produce a documentation driver file \\
100 % \section{The documentation driver file}
102 % The next bit of code contains the documentation driver file for
103 % \TeX{}, i.e., the file that will produce the documentation you are
104 % currently reading. It can be extracted from this file by the
105 % {\sc docstrip} program.
108 \documentclass{ltxdoc}
110 \DocInput{makeindx.dtx}
115 % \section{Implementation}
117 % \subsection{Identification}
119 % Announce the package and its version:
120 % \changes{v1.0h}{1994/05/01}{Removed use of variables}
122 %<makeidx>\ProvidesPackage{makeidx}
123 %<showidx>\ProvidesPackage{showidx}
124 [2014/09/29 v1.0m Standard LaTeX package]
127 % \subsection{Makeidx}
129 % \begin{macro}{\see}
130 % This macro discards its second argument (typically a page number)
131 % and just prints |\seename| together with the entry the reader is
133 % \changes{v1.0j}{1995/04/19}{Use \cs{emph} instead of \cs{em}}
134 % \changes{v1.0j}{1995/04/19}{Disallow \cs{par} in argument}
137 \newcommand*\see[2]{\emph{\seename} #1}
141 % \begin{macro}{\seealso}
142 % \changes{v1.0m}{2000/03/29}{Macro added (see PR 3133).}
143 % This macro discards its second argument (typically a page number)
144 % and just prints |\alsoname| together with the entry the reader is
145 % pointed to. We use |\providecommand| to retain compatibility with
146 % existing files that define this macro.
148 \providecommand*\seealso[2]{\emph{\alsoname} #1}
152 % \begin{macro}{\printindex}
153 % This command simply inputs the (formatted) index if it exists,
154 % otherwise a warning is issued.
155 % \changes{1.0c}{1994/02/08}{Use \cs{@input@} instead of \cs{@input} to
156 % get the index listed by \cs{listfiles}}
158 \newcommand\printindex{\@input@{\jobname.ind}}
162 % \begin{macro}{\seename}
163 % This package is for documents prepared in the English language.
164 % To prepare a version for another language, various English words
165 % must be replaced. All the English words that require replacement
166 % are% defined below in command names.
167 % \changes{1.0g}{1994/03/07}{Replaced \cs{newcommand} by \cs{providecommand}.}
169 \providecommand\seename{see}
171 % We used |\providecommand| in case the command is already defined
172 % by a package loaded earlier.
175 % \begin{macro}{\alsoname}
176 % \changes{v1.0m}{2000/03/29}{Macro added (see PR 3133).}
177 % This macro discards its second argument (typically a page number)
178 % and just prints |\alsoname| together with the entry the reader is
179 % pointed to. We use |\providecommand| to retain compatibility with
180 % existing files that define this macro.
182 \providecommand*\alsoname{see also}
187 % \subsection{showidx}
189 % \begin{macro}{\indexbox}
190 % This package uses \TeX's insert mechanism, therefore it needs to
191 % allocate an insert register.
195 \dimen\indexbox=\maxdimen
199 % \begin{macro}{\index}
200 % This is a modified default definition for the user level |\index|
201 % command. The difference is the change of the category code of the
204 \renewcommand\index{\@bsphack\begingroup
205 \@sanitize\catcode32=10\relax\@index}
209 % \begin{macro}{\makeindex}
210 % The same change has to be included in the user level |\makeindex|
211 % command, which changes the definition of |\index| to actually
212 % write index entries to an external file.
214 \renewcommand\makeindex{\if@filesw \newwrite\@indexfile
215 \immediate\openout\@indexfile=\jobname.idx
216 \def\index{\@bsphack\begingroup
217 \def\protect####1{\string####1\space}\@sanitize
218 \catcode32=10 \@wrindex\@indexfile}\typeout
219 {Writing index file \jobname.idx }\fi}
223 % \begin{macro}{\@wrindex}
224 % This macro takes care of writing the index entries to a file. The
225 % definition is modified to call |\@showidx|.
227 \def\@wrindex#1#2{\let\thepage\relax
228 \xdef\@gtempa{\write#1{\string
229 \indexentry{#2}{\thepage}}}\endgroup\@gtempa
230 \@showidx{#2}\if@nobreak \ifvmode\nobreak\fi\fi\@esphack}
234 % \begin{macro}{\@index}
235 % When the user didn't use the |\makeindex| command, the |\index|
236 % macro calls |\@index|, which normally does basically nothing.
237 % This package changes the definition to call |\@showidx|, which
238 % includes the entry in the list of indexentries on the current page.
240 \def\@index#1{\@showidx{#1}\endgroup\@esphack}
244 % \begin{macro}{\@showidx}
245 % This macro adds the current index entry to the insert
246 % |\indexbox|. The |\indexbox| is typeset as a flushleft paragraph.
249 \insert\indexbox{\small
250 \hsize\marginparwidth
251 \hangindent\marginparsep \parindent\z@
252 \everypar{}\let\par\@@par \parfillskip\@flushglue
253 \lineskip\normallineskip
254 \baselineskip .8\normalbaselineskip\sloppy
255 \raggedright \leavevmode
256 \vrule \@height .7\normalbaselineskip \@width \z@\relax
258 \vrule \@height \z@ \@depth .3\normalbaselineskip \@width \z@}}
262 % \begin{macro}{\raggedbottom}
263 % \begin{macro}{\flushbottom}
264 % The definition of these macros from \texttt{latex.dtx} is changed
265 % here to add the execution of |\@mkidx| to |\@texttop|, which is
266 % executed at the top of each page.
268 \renewcommand\raggedbottom{\def\@textbottom{\vskip
269 \z@ plus.0001fil}\let\@texttop\@mkidx}
270 \renewcommand\flushbottom{\let\@textbottom\relax
271 \let\@texttop\@mkidx}
276 % \begin{macro}{\@mkidx}
277 % This macro actually typesets the box containing all the index
278 % entries on the current page. They will occur on the left or the
279 % right side of the text, or both, depending on the setting of the
280 % switches |\if@twocolumn| and |\if@twoside|.
282 \def\@mkidx{\vbox to \z@{\hbox{\if@twocolumn
283 \if@firstcolumn \@leftidx \else \@rightidx \fi
284 \else \if@twoside \ifodd\c@page \@rightidx
292 % \begin{macro}{\@leftidx}
293 % \begin{macro}{\@rightidx}
294 % These macros give the amount of displacement for the |\indexbox|.
296 \def\@leftidx{\hskip-\marginparsep \hskip-\marginparwidth}
297 \def\@rightidx{\hskip\columnwidth \hskip\marginparsep}
302 % To make this work we have to execute either |\raggedbottom| or
303 % |\flushbottom|. Assuming this package is used most often with the
304 % document classes \texttt{report} and \texttt{book}, we execute