1 \def\filedate{1997/03/20}
2 \def\docdate{1997/03/20}
3 \def\fileversion{v1.1beta}
5 % \iffalse meta-comment
7 % Package 'xindy' to use with LaTeX2e
8 % Copyright 1997 by Andreas 'Vignard' Schlechte, all right reserved.
10 % This package is distributed in the hope that it will be useful,
11 % but WITHOUT ANY WARRANTY; without even the implied warranty of
12 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 % For error reports in case of UNCHANGED versions please email to
17 % Andreas.Schlechte@tu-clausthal.de
19 % Please do not request updates from me directly. Distribution is
20 % done through ftp-Server at TU Clausthal and ftp.dante.de.
22 % You are not allowed to change this file.
24 % You are allowed to distribute this file under the condition that
25 % it is distributed UNCHANGED. You are NOT ALLOWED to take money for
26 % the distribution or use of either this file or a changed version,
27 % except for a nominal charge for copying etc.
32 %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
33 %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
34 %% Digits \0\1\2\3\4\5\6\7\8\9
35 %% Exclamation \! Double quote \" Hash (number) \#
36 %% Dollar \$ Percent \% Ampersand \&
37 %% Acute accent \' Left paren \( Right paren \)
38 %% Asterisk \* Plus \+ Comma \,
39 %% Minus \- Point \. Solidus \/
40 %% Colon \: Semicolon \; Less than \<
41 %% Equals \= Greater than \> Question mark \?
42 %% Commercial at \@ Left bracket \[ Backslash \\
43 %% Right bracket \] Circumflex \^ Underscore \_
44 %% Grave accent \` Left brace \{ Vertical bar \|
45 %% Right brace \} Tilde \~}
48 % \changes{v1.1beta}{97/03/20}{First documented version}
52 % \title{Interface to the \textsf{xindy} indexing program\thanks{This file
53 % has version number \fileversion{}, last revised \filedate}}
54 % \author{Andreas `Vignard' Schlechte\\Am Klepperberg 2\\
55 % D-38678 Clausthal-Zellerfeld\\Federal Republic of Germany}
60 % Are you still using \emph{MakeIndex}? Go with the future and switch now!
62 % The \textsf{xindy}-distribution contains a small programm called |tex2xindy|, which converts
63 % a standard LaTeX into a rawindex, readable by \textsf{xindy}. Using this program, old
64 % documents can be indexed using \textsf{xindy}, but you can't really use all features
65 % in documents. Thus, I began writing a small package which provides an interface between
66 % \LaTeX\ and xindy. This interface covers all xindy-tags and doesn't need
67 % |tex2xindy| anymore.
72 % \section{The user interface}
73 % \subsection{How to include \texttt{xindy.sty}}
75 % The package is included by the command
77 % |\usepackage{xindy}|
79 % in the preambel of your \LaTeX-document.
81 % \subsection{Locationstyles}
83 % \DescribeMacro\locationstyle
84 % |xindy.sty| supports the use of different location-references, as you may define
85 % them within \textsf{xindy}. A reference type is called \emph{locationstyle} in |xindy.sty|.
86 % A locationstyle is selected by the following command:
88 % |\locationstyle{|\meta{locationstyle}|}|
90 % The package provides the following \meta{locationstyles}:
93 % \item[\texttt{page}] The location-reference is given by the pagenumber, as usual in
94 % \LaTeX (e.g. 47, 11).
95 % \item[\texttt{chapter}] This one is only defined, if you use a documentclass, which
96 % provides chapters. The location-reference is composed of the chapternumber and
97 % the pagenumber: \meta{chapter}-\meta{page} (e.g 47-11, A-5).
98 % \item[\texttt{section}] This one is only defined, if a documentclass providing
99 % sections is used. The location-reference is composed of the sectionnumber and
100 % pagenumber: \meta{section}-\meta{page} (e.g. 1-5, 2-6). In fact, the
101 % reference uses the commands |\thesection| and |\thepage|. Thus, if you are
102 % using e.g. |book.cls|, the reference will look like
103 % \meta{chapter}.\meta{section}-\meta{page} (e.g. 1.1-47, A.5-6).
107 % \DescribeMacro\newlocationstyle
108 % \DescribeMacro\renewlocationstyle
109 % You may define new locationsstyles using the commands
111 % |\newlocationstyle{|\meta{locationstyle}|}{|\meta{what}|}|\\
112 % |\renewlocationstyle{|\meta{locationstyle}|}{|\meta{what}|}|
114 % If the \meta{locationstyle} is already defined, |\newlocationstyle|
115 % leads to an error. Thus, you must use |\renewlocationstyle| for
116 % redefining existing styles. \meta{what} is the tokenlist to be used
117 % as location-reference. For examples take a look at the definition of
118 % the styles in the code-section.
120 % \subsection{Indexing}
122 % \DescribeMacro\indexindy
123 % To index a key, you must use the command
125 % |\indexindy[|\meta{xindy-keys}|][|\meta{xref}|]{|\meta{key}|}|
127 % The Syntax isn't quite that simple, as you will see in the following.
129 % The main argument \meta{key} is a list of strings in a special
130 % syntax. As you surely know, a index-entry consists of different
131 % Layers. Additionally, per Layer a printkey---different from the sortkey---may be
132 % specified. First of all, the \meta{key} is a semicoleon-separated list
133 % of strings. This defines the sort keys:
135 % |\indexindy{First;Second;Third}|
137 % Now suppose, you want |Second| to appear in small caps. This can be done
138 % either by defining a merge-rule in the xindy-style and the typing |\textsc{Second}|
139 % instead of |Second| or by specifiying the printkey inside the indexing command:
141 % |\indexindy{First;Second,\textsc{Second};Third}|
143 % Now you've learned anything about the complete syntax for the \meta{key}:
145 % |{Layer 0,printkey;Layer 1,printkey;Layer 2,printkey;....}|
147 % Note, that it's not the main philosophy of xindy, to specify the printkey.
148 % In many cases, it is much handier to define a merge-rule inside the xindy-style.
149 % If, in any case, you wish a semikolen or a comma to be part of a print key,
150 % you have to surround it by brackets: |{,}| and |{;}|.
152 % The optional Argument \meta{xindy-keys} is a comma-separated list
153 % of xindy-keys and their assignment. Currently the following keys
156 % \begin{description}
157 % \item[open-range] The indexentry will be the beginning of a range.
158 % \item[close-range] The indexentry will be the end of a range.
159 % \item[attr=\meta{attribute}] The given \meta{attribute} will be
160 % attached to the indexentry.
163 % If, in any case, you wish to use a comma as an argument, you must
164 % enclose it by brackets |{,}|.
166 % At least, we've to discuss the optional argument \meta{xref}.
167 % This one can be used to define a crossreference inside the index.
168 % Which \emph{MakeIndex} you write \verb+\index{foo|see{bar}}+. Using
169 % \textsf{xindy}, crossreferences become more flexible. \meta{xref}
170 % is a comma-separated list of sortkey, the entry should point to.
173 % |\indexindy[attr=see][bar]{foo}|
175 % leads (using standard xindy-styles) to the same result, generated
176 % by \emph{MakeIndex}. But, different to \emph{MakeIndex}, you are
177 % now able to point to other Layers:
179 % |\indexindy{First;Second,\textsc{Second};Third}|\\
180 % |\indexindy[][First,Second,Third]{foo}|
182 % Note, that I didn't use either the attribute |see| nor any other
183 % \meta{xindy-key} in the latter example. Thus, there has to be an
184 % extra pair of brackets |[]|.
186 % \subsection*{Example}
190 % \documentclass{book}
195 % \indexindy[attr=idef]{Euler}
196 % \indexindy[open-range,attr=idef]{Euler,\textsc{Euler}}
197 % \indexindy[attr=see][Layer 0,Layer 1,Layer 2]{Persons;Math-related}
200 % \indexindy[close-range,attr=idef]{Euler,\textsc{Euler}}
201 % \locationstyle{chapter}
202 % \indexindy{Layer 0;Layer 1,\textsc{Layer 1};Layer 2}
203 % \indexindy{Index a comma{,} too}
204 % \end{document}\end{verbatim}
207 % \item Entry, \textbf{1}
208 % \item \textsc{Euler}, \textbf{1}ff.
210 % \item Index a comma{,} too, 2-3
212 % \item Layer~0,\hfill~
213 % \subitem \textsc{Layer~1},\hfill~
214 % \subsubitem Layer~2, 2-3
218 % \subitem Math-related, \see{Layer 0, Layer 1, Layer 2}
221 % \section{Known bugs, problems and exceptions}
223 % Currently, there are no known bugs, but there are some
224 % exceptions using |xindy.sty|:
226 % \item Because \textsf{xindy} uses indexes in a raw-format and |xindy.sty|
227 % redefines |\index| for internal use, you should not use |\index| inside
229 % \item Because |\indexindy| uses the comma and semikoleon in special manner,
230 % you have to write |{,}| and |{;}| if you wish them to appear in a key. Thus,
231 % you should specify a merge-rule in your xindy-style, which discards the brackets:
233 % |(merge-rule "{,}" "," :again)|\\
234 % |(merge-rule "{;}" ";" :again)|
236 % \item Because |xindy| needs the backslash and the doulequote escaped, |\indexindy|
237 % does this for the user. But if you define a shortcut, calling |\indexindy|, this
238 % function doesn't work any more. Thus you must escape these chars by yourself:
240 % |\newcommand{\foo}[1]{\indexindy[attr=definition]{#1}}|\\
241 % |\foo{Backslash (\\) and Doublequote (\")}|
245 % \section{Code documentation}\label{sec:code}
247 % \subsection{The documentation driver file}
249 % The next bit of code contains the documentation driver file for
250 % \TeX{}, i.e., the file that will produce the documentation you are
251 % currently reading. It will be extracted from this file by the
252 % \texttt{docstrip} program. Since it is the first code in the file
253 % one can alternatively process this file directly with \LaTeXe{} to
254 % obtain the documentation.
258 \documentclass[draft]{ltxdoc}
260 \def\see#1{\emph{see} #1}
261 \parindent0pt\hfuzz2pt
262 \setlength{\textwidth}{360pt}
270 % \subsection{Documentation of the Macros}
275 \RequirePackage{keyval}
278 %% Allow definition of locationstyles
281 \def\newlocationstyle#1#2{%
282 \@ifundefined{xindy@style@#1}%
283 {\expandafter\gdef\csname xindy@style@#1\endcsname{#2}}
284 {\typeout{xindy: locationstyle #1 already defined}}}
287 %% existing styles may be redefined
290 \def\renewlocationstyle#1#2{%
291 \expandafter\let\csname xindy@style@#1\endcsname=\undefined%
292 \newlocationstyle{#1}{#2}}
295 %% set up the locationstyles page, chapter and section
298 \newlocationstyle{page}{\thepage}
299 \ifx\@undefined\chapter\else
300 \newlocationstyle{chapter}{\thechapter-\thepage}
302 \ifx\@undefined\section\else
303 \newlocationstyle{section}{\thesection-\thepage}
310 \def\locationstyle#1{%
311 \@ifundefined{xindy@style@#1}
312 {\typeout{xindy: locationstyle #1 not defined}}
313 {\def\xindy@style{\csname xindy@style@#1\endcsname}}}
316 %% default is normal pagenumbering, as in LaTeX
322 %% The optional keys for the index (as mentioned by Bernd Raichle)
326 % make all punctuation chars inactive (if they can be active)
327 \catcode`\:=12 \catcode`\"=12
330 \define@key{xindy}{attr}{%
332 \ifx\@empty\xindy@attr%
334 \def\xindy@attr{:attr "#1"}%
336 \define@key{xindy}{open-range}[:open-range]{\def\xindy@range{:open-range}}
337 \define@key{xindy}{close-range}[:close-range]{\def\xindy@range{:close-range}}
345 %% The Backslash should be doubled, the
346 %% doublequote should be quoted (as mentioned by Bernd Raichle)
351 \catcode`\~=13 \lccode`\~=`\\
354 \def\xindy@activatebsp{%
355 \catcode`\\=\active \def~{#1}
356 \catcode`\"=\active \def"{\"}}}}
357 \catcode`\|=0 \catcode`|\=12
364 \def\delspace#1 \xindy@relax{#1}
365 \def\xindy@space{\space\space\space\space\space\space}
366 \edef\xindy@space{\xindy@space\xindy@space}
369 %% The indexing command (as mentioned by Bernd Raichle)
373 \@bsphack %% to handle `space factor' etc.
381 % make all punctuation chars inactive (if they can be active)
382 \catcode`\:=12 \catcode`\"=12
385 %% this one parses the optional arguments, no quoting is active right now
387 \newcommand{\indexindy@}[1][]{% setup keys
391 %% parse the key, quoting is enabled
393 \newcommand{\indexindy@@}[2][]{%
395 \xindy@checksyntax{#2}%
396 \toks@=\expandafter{\expandafter\delspace\the\toks@\xindy@relax}% delete tailing space
397 \expandafter\def\expandafter\xindy@tmp\expandafter{\the\toks@}%
401 \ifx\@empty\xindy@@tmp\def\xindy@ref{}
404 \toks@=\expandafter{\expandafter\delspace\the\toks@\xindy@relax}% delete tailing space
405 \expandafter\def\expandafter\xindy@xref\expandafter{\the\toks@}%
407 \index{(indexentry :tkey (\xindy@tmp)}%
408 \ifx\@empty\xindy@attr\else
409 \index{\xindy@space\xindy@attr}
411 \ifx\@empty\xindy@range\else
412 \index{\xindy@space\xindy@range}%
414 \ifx\@empty\xindy@xref%
415 \index{\xindy@space:locref "\xindy@style")}%
417 \index{\xindy@space:xref \xindy@xref)}%
424 %% convert input into :tkey form
427 \def\xindy@checksyntax#1{%
429 \xindy@for\xindy@@tmp:=\xindy@tmp\do{\xindy@@checksyntax}}
430 \def\xindy@@checksyntax{%
431 \addto@hook\toks@{(}%
432 \@for\xindy@@@tmp:=\xindy@@tmp\do{%
433 \expandafter\addto@hook\expandafter\toks@\expandafter{\expandafter"\xindy@@@tmp" }}%
434 \toks@=\expandafter{\expandafter\delspace\the\toks@\xindy@relax}% delete tailing space
435 \addto@hook\toks@{) }}
439 %% We need a special for-command to enable nested loops.
442 \def\xindy@fornoop#1\@@#2#3{}
443 \long\def\xindy@for#1:=#2\do#3{%
444 \expandafter\def\expandafter\xindy@fortmp\expandafter{#2}%
445 \ifx\xindy@fortmp\@empty \else
446 \expandafter\xindy@forloop#2;\@nil;\@nil\@@#1{#3}\fi}
447 \long\def\xindy@forloop#1;#2;#3\@@#4#5{\def#4{#1}\ifx #4\@nnil \else
448 #5\def#4{#2}\ifx #4\@nnil \else#5\xindy@iforloop #3\@@#4{#5}\fi\fi}
449 \long\def\xindy@iforloop#1;#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
450 \expandafter\xindy@fornoop \else
451 #4\relax\expandafter\xindy@iforloop\fi#2\@@#3{#4}}
452 \def\xindy@tfor#1:={\xindy@tf@r#1 }
453 \long\def\xindy@tf@r#1#2\do#3{\def\xindy@fortmp{#2}\ifx\xindy@fortmp\space\else
454 \xindy@tforloop#2\@nil\@nil\@@#1{#3}\fi}
455 \long\def\xindy@tforloop#1#2\@@#3#4{\def#3{#1}\ifx #3\@nnil
456 \expandafter\xindy@fornoop \else
457 #4\relax\expandafter\xindy@tforloop\fi#2\@@#3{#4}}
458 \long\def\@breakxindy@tfor#1\@@#2#3{\fi\fi}
461 %% Now redifene \@wrindex from the kernel
465 \protected@write\@indexfile{}%
472 % \section{Acknowledgements}
474 % |xindy.sty| is based on a personal idea, but there were two persons, who
475 % helped me in many special tasks. First, I want to thank \textsc{Roger Kehr},
476 % who gave me hints on xindy-dependent part. Additionally, I thank \textsc{Bernd Raichle}.
477 % He gave many hints on changing categories correctly, to achieve compability to
478 % other styles like |german.sty|.
482 % \GlossaryPrologue{}