summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xindex/xindex.sty
blob: a2b229b74f3c60fffe8e16a8007d1b38373aeb7b (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
%% This is file `xindex.sty',
%%
%% Copyright (C) 2018-2022
%% Herbert Voss
%%
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% of this license or (at your option) any later version.
%% 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.
%
% $Id: xindex.sty 836 2018-11-11 20:22:56Z herbert $
%
% -------------------------------------
\ProvidesPackage{xindex}[2018/11/11 v. 0.02 write into an idx file (hv)]
%
\RequirePackage{xkeyval}

\newif\if@@imakeidx \@@imakeidxfalse

\DeclareOptionX{imakeidx}{\@@imakeidxtrue}
\DeclareOptionX*{\PassOptionsToPackage\CurrentOption{imakeidx}}
\ProcessOptionsX\relax

\@ifpackageloaded{imakeidx}{}{%   imakeidx already loaded?? if not then define ...
  \newif\ifimki@startedidx
  \newif\ifimki@splitindex
}

\if@@imakeidx
  \typeout{xindex: Using package imakeidx}%
  \RequirePackage{imakeidx}
  \def\imki@progdefault{xindex}
  \def\imki@program{xindex}
%
  \def\imki@@startidxsplit#1{%
    \if@filesw
      \def\index{\@bsphack
        \@ifnextchar [{\@index}{\@index[\imki@jobname]}}
      \expandafter\newwrite\csname #1@idxfile\endcsname
      \immediate\openout \csname #1@idxfile\endcsname #1.idx\relax
      \def\writeidx##1{\write\expandafter\csname #1@idxfile\endcsname{\noexpand##1}}%
      \typeout{Writing index file #1.idx}%
    \fi
  }
  \global\imki@startedidxfalse
  \def\imki@@startidxunique#1{%
    \if@filesw
      \ifimki@startedidx\else
        \newwrite\@indexfile
        \immediate\openout\@indexfile\imki@jobname.idx%
        \def\writeidx##1{\write\@indexfile{\noexpand##1}}%
        \global\imki@startedidxtrue
      \fi
      \def\index{\@bsphack
        \@ifnextchar [{\@index}{\@index[\imki@jobname]}}
      \expandafter\let\csname #1@idxfile\endcsname\@empty
      \typeout{Started index file #1}%
   \fi
  }
%
  \ifimki@splitindex
    \let\imki@startidx\imki@@startidxunique
  \else
    \let\imki@startidx\imki@@startidxsplit
  \fi
\else
  \typeout{xindex: Using package makeidx}%
  \RequirePackage{makeidx}
  \def\writeidx#1{\write\@indexfile{\noexpand#1}}
\fi

\endinput