summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/splitindex/splitidx.sty
blob: ece91ede7614e9ecd09edc9d35cf04ec866436eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
%%
%% This is file `splitidx.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% splitidx.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (c) Markus Kohm, 2002-2009
%% 
%% This file was generated from file(s) of the `SplitIndex bundle'.
%% ----------------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, version 1.3c of the license.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3c or later is part of all distributions of LaTeX
%% version 2005/12/01 or later and of this work.
%% 
%% This work has the LPPL maintenance status "author-maintained".
%% 
%% The Current Maintainer and author of this work is Markus Kohm.
%% 
%% This file may only be distributed together with a copy of the
%% SplitIndex bundle. You may however distribute the SplitIndex bundle
%% without such generated files.
%% 
%% The list of all files belongig to the SplitIndex bundle is given in
%% in the file `manifest.txt'. Files generated by means of unpacking the
%% distribution (using, for example, the docstrip program) or by means
%% of compiling them from a source file, for example, from splitindex.c
%% or splitindex.java may be distributed at the distributor's discretion.
%% However if they are distributed then a copy of the SplitIndex bundle
%% must be distributed together with them.
%% 
%% The list of derived (unpacked or compiled) files belongig to the
%% distribution and covered by LPPL is defined by the unpacking scripts
%% (with extension .ins) and the installation script (with name
%% install.sh) which are part of the distribution.
%% 
%% Two often ignorred clauses from LPPL 1.3c you should not ignore:
%% ----------------------------------------------------------------
%% 2. You may distribute a complete, unmodified copy of the Work as you
%%    received it.  Distribution of only part of the Work is considered
%%    modification of the Work, and no right to distribute such a Derived
%%    Work may be assumed under the terms of this clause.
%% 3. You may distribute a Compiled Work that has been generated from a
%%    complete, unmodified copy of the Work as distributed under Clause 2
%%    above, as long as that Compiled Work is distributed in such a way that
%%    the recipients may install the Compiled Work on their system exactly
%%    as it would have been installed if they generated a Compiled Work
%%    directly from the Work.
%% 
\ProvidesPackage{splitidx}[%
 2013/04/09 v1.2a multiple indices for LaTeX]
\DeclareOption{makeindex}{\AtEndOfPackage{\makeindex}}
\DeclareOption{useindex}{%
  \def\@se@nd@xc@d@{\let\index\sindex}%
  \AtEndOfPackage{\@se@nd@xc@d@}%
}
\let\@se@nd@xc@d@\relax
\DeclareOption{allatone}{%
  \PackageWarning{splitidx}{Option `allatone' deprecated!\MessageBreak
    You should replace it by `allintoone'}%
  \ifx\@se@nd@xc@d@\relax\else
    \PackageInfo{splitidx}{option `allatone' overwrites option `useindex'}%
    \let\@se@nd@xc@d@\relax
  \fi
  \AtEndOfPackage{%
    \renewcommand*{\sindex}[1][]{\index}%
    \g@addto@macro\makeindex{\renewcommand*{\sindex}[1][]{\index}}%
  }%
}
\DeclareOption{allintoone}{%
  \ifx\@se@nd@xc@d@\relax\else
    \PackageInfo{splitidx}{option `allintoone' overwrites option `useindex'}%
    \let\@se@nd@xc@d@\relax
  \fi
  \AtEndOfPackage{%
    \renewcommand*{\sindex}[1][]{\index}%
    \g@addto@macro\makeindex{\renewcommand*{\sindex}[1][]{\index}}%
  }%
}
\newif\if@verbindex\@verbindexfalse
\DeclareOption{protected}{\@verbindextrue}
\newif\if@newidxcmd\@newidxcmdfalse
\DeclareOption{idxcommands}{\@newidxcmdtrue}
\newif\if@splitidx\@splitidxfalse
\DeclareOption{split}{\@splitidxtrue}
\ProcessOptions\relax
\newcommand*\see[2]{\emph{\seename} #1}
\providecommand*\seealso[2]{\emph{\alsoname} #1}
\providecommand\seename{see}
\providecommand*\alsoname{see also}
\newcommand*{\sindex}[2][]{%
}
\g@addto@macro\makeindex{%
  \renewcommand*{\sindex}{%
    \@bsphack\begingroup
    \@sanitize
    \@wrsindex
  }%
  \typeout{Using splitted index at \jobname.idx}%
  \@se@nd@xc@d@
}
\newcommand*{\@wrsindex}[2][]{%
  \ifx\relax#1\relax
    \if@splitidx
      \@wrsindex[idx]{#2}%
    \else
      \def\@tempa{#2}%
      \if@verbindex\@onelevel@sanitize\@tempa\fi
      \@wrindex{\@tempa}%
    \fi
  \else
    \def\@tempa{#2}%
    \csname index@#1@hook\endcsname
    \expandafter\ifx\csname @@wrsindex\endcsname\relax
      \@@@wrsindex{#1}{{\@tempa}{\thepage}}%
    \else
      \def\@tempb{\@@wrsindex{#1}}%
      \expandafter\@tempb\@tempa||\\%
    \fi
    \endgroup
    \@esphack
  \fi
}
\newcommand*{\@@@wrsindex}[2]{%
  \begingroup
    \if@splitidx
      \expandafter\ifx\csname @indexfile@#1\endcsname\relax
        \PackageError{splitidx}{%
          Index entry for not existing index%
        }{%
          You've tried to set an index to index `#1', without
          defining\MessageBreak
          that index before using \string\newindex.\MessageBreak
          This is only allowed, if you are not using package option
          `split'.%
        }%
      \else
        \expandafter\protected@write\csname @indexfile@#1\endcsname{%
          \csname index@#1@writehook\endcsname
          \csname index@#1@writehook@once\endcsname
        }{%
          \string\indexentry#2%
        }%
      \fi
    \else
      \protected@write\@indexfile{%
        \csname index@#1@writehook\endcsname
        \csname index@#1@writehook@once\endcsname
      }{%
        \string\indexentry[#1]#2%
      }%
    \fi
  \endgroup
}
\AtBeginDocument{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname ifHy@hyperindex\endcsname\relax
  \else
    \csname ifHy@hyperindex\endcsname
      \expandafter\ifx\csname @@wrsindex\endcsname\relax
        \def\@@wrsindex#1#2|#3|#4\\{%
          \ifx\\#3\\%
            \@@@wrsindex{#1}{{#2|hyperpage}{\thepage}}%
          \else
            \def\Hy@temp@A{#3}%
            \ifx\Hy@temp@A\HyInd@ParenLeft
              \@@@wrsindex{#1}{{#2|#3hyperpage}{\thepage}}%
            \else
              \ifx\Hy@temp@A\HyInd@ParenRight
                \@@@wrsindex{#1}{{#2|#3hyperpage}{\thepage}}%
              \else
                \@@@wrsindex{#1}{{#2|#3}{\thepage}}%
              \fi
            \fi
          \fi
        }%
      \fi
    \csname fi\endcsname
  \fi
}
\newcommand*{\AtWriteToIndex}[1]{%
  \expandafter\ifx\csname index@#1@writehook\endcsname\relax
    \expandafter\let\csname index@#1@writehook\endcsname\@empty
  \fi
  \expandafter\g@addto@macro\csname index@#1@writehook\endcsname
}
\newcommand*{\AtNextWriteToIndex}[1]{%
  \expandafter\ifx\csname index@#1@writehook@once\endcsname\relax
    \expandafter\gdef\csname index@#1@writehook@once\endcsname{%
      \expandafter\global\expandafter\let\expandafter
      \csname index@#1@writehook@once\endcsname\relax
    }%
  \fi
  \expandafter\g@addto@macro\csname index@#1@writehook@once\endcsname
}
\newcommand*{\printindex}{%
  \@ifstar {%
    \begingroup
      \let\printindex@@endhook=\printindex@endhook
      \let\printindex@endhook=\relax
      \printindices%
      \csname printindex@@endhook\endcsname
    \endgroup
  }{%
    \@ifnextchar [\@printindex%] brace check comment
    {%
      \@input@{\jobname.ind}%
      \csname printindex@endhook\endcsname
    }%
  }%
}
\newcommand*{\@printindex}{}
\def\@printindex[#1]{%
  \@ifnextchar [%
  {\@@printindex[{#1}]}%
  {\@@printindex[{#1}][\csname index@#1@name\endcsname]}%
}
\newcommand*{\@@printindex}{}
\def\@@printindex[#1][#2]{%
  \begingroup
    \edef\indexshortcut{#1}%
    \def\indexname{#2}%
    \let\index@preamble\relax
    \expandafter\let\expandafter\index@preamble
    \csname index@\indexshortcut @preamble\endcsname
    \if@splitidx
      \def\@tempa{idx}\def\@tempb{#1}%
      \ifx\@tempa\@tempb\let\@indexsuffix\@gobble\fi
    \fi
    \@input@{\jobname\@indexsuffix{#1}.ind}%
  \endgroup
  \csname printindex@endhook\endcsname
}
\begingroup
\catcode`\-12
\lowercase{\endgroup
  \newcommand*{\@indexsuffix}[1]{-#1}%
}
\newcommand*{\printindices}{%
  \ifx\@indices\@empty
    \printindex
  \else
    \begingroup
      \@for\@tempa:=\@indices\do{%
        \expandafter\printindex\expandafter[\@tempa]%
      }%
    \endgroup
  \fi
}
\newcommand*{\newindex}[2][\relax]{%
  \@ifundefined{index@#2@name}{%
    \if@verbindex
      \expandafter\gdef\csname index@#2@hook\endcsname{%
        \@onelevel@sanitize\@tempa
      }%
    \else
      \expandafter\gdef\csname index@#2@hook\endcsname{}%
    \fi
    \ifx\@indices\@empty
      \xdef\@indices{#2}%
    \else
      \xdef\@indices{\@indices,#2}%
    \fi
    \ifx \relax#1
      \expandafter\xdef\csname index@#2@name\endcsname{#2}%
    \else
      \expandafter\xdef\csname index@#2@name\endcsname{#1}%
    \fi
    \if@newidxcmd
      \expandafter\newcommand\expandafter*\csname #2\endcsname{}%
      \expandafter\gdef\csname #2\endcsname{%
        \sindex[#2]%
      }%
    \fi
    \if@splitidx
      \def\@tempa{#2}\def\@tempb{idx}%
      \ifx\@tempa\@tempb
        \global\let\@indexfile@idx=\@indexfile
      \else
        \expandafter\newwrite\csname @indexfile@#2\endcsname
        \expandafter\immediate\expandafter\openout
        \csname @indexfile@#2\endcsname=\jobname-#2.idx
      \fi
    \fi
  }{%
    \PackageError{splitidx}{%
      index `#2' already defined%
    }{%
      You have already defined an index with shortcut `#2'.\MessageBreak
      You can't define a new index with the same shortcut. If you'll continue
      \MessageBreak
      The new definition will be ignored.%
    }%
  }%
}
\if@splitidx
  \@onlypreamble\newindex
\fi
\newcommand*{\newprotectedindex}[2][\relax]{%
  \begingroup\@verbindextrue\newindex[{#1}]{#2}\endgroup
}
\newcommand*{\@indices}{}
\gdef\@indices{}
\newcommand{\extendtheindex}[4]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname splitindex@theindex\endcsname\relax
    \let\splitindex@theindex=\theindex
    \let\endsplitindex@theindex=\endtheindex
  \fi
  \renewcommand*{\theindex}{%
    #1\splitindex@theindex #2%
  }%
  \renewcommand*{\endtheindex}{%
    #3\endsplitindex@theindex #4%
  }%
}
\newcommand{\splitindex@setip}{}
\let\splitindex@setip\setindexpreamble
\let\setindexpreamble\relax
\newcommand{\setindexpreamble}[2][]{%
  \ifx \relax#1\relax
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname splitindex@setip\endcsname\relax
      \@namedef{index@preamble}{#2}%
    \else
      \splitindex@setip{#2}%
    \fi
  \else
    \@namedef{index@#1@preamble}{#2}%
  \fi
}
\newcommand{\useindexpreamble}[1][]{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname index@preamble\endcsname\relax\else
    \ifx\index@preamble\@empty\else
      \index@preamble #1%
    \fi
  \fi
}
\newcommand*{\printsubindex}{%
  \begingroup
    \begingroup\expandafter\expandafter\expandafter\endgroup
    \expandafter\ifx\csname chapter\endcsname\relax
      \let\section\subsection
      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\ifx\csname addsec\endcsname\relax\else
        \def\addsec{\setcounter{secnumdepth}{0}\subsection}%
      \fi
    \else
      \let\chapter\section
      \def\@makeschapterhead{\section*}
      \let\@makechapterhead\section
      \begingroup\expandafter\expandafter\expandafter\endgroup
      \expandafter\ifx\csname addchap\endcsname\relax\else
        \let\addchap\addsec
      \fi
    \fi
    \let\onecolumn\@firstoptofone
    \let\twocolumn\@firstoptofone
    \let\clearpage\relax
    \let\cleardoublepage\relax
    \def\markboth{\expandafter\markright\@gobble}%
    \ifx\@mkboth\@gobble\else\let\@mkboth\markboth\fi
    \let\thispagestyle\@gobble
    \let\printindex@endhook=\endgroup
    \printindex
}
\providecommand{\@firstoptofone}[1][]{#1}
\endinput
%%
%% End of file `splitidx.sty'.