summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/splitindex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/splitindex
Initial commit
Diffstat (limited to 'macros/latex/contrib/splitindex')
-rw-r--r--macros/latex/contrib/splitindex/README78
-rwxr-xr-xmacros/latex/contrib/splitindex/install.sh141
-rw-r--r--macros/latex/contrib/splitindex/install.txt222
-rw-r--r--macros/latex/contrib/splitindex/manifest.txt62
-rw-r--r--macros/latex/contrib/splitindex/splitidx.dtx1667
-rw-r--r--macros/latex/contrib/splitindex/splitidx.ins135
-rw-r--r--macros/latex/contrib/splitindex/splitidx.pdfbin0 -> 422877 bytes
-rw-r--r--macros/latex/contrib/splitindex/splitindex.164
-rw-r--r--macros/latex/contrib/splitindex/splitindex.c602
-rw-r--r--macros/latex/contrib/splitindex/splitindex.java441
-rwxr-xr-xmacros/latex/contrib/splitindex/splitindex.pl212
-rw-r--r--macros/latex/contrib/splitindex/splitindex.tex189
-rwxr-xr-xmacros/latex/contrib/splitindex/splitindex.tlu50
-rw-r--r--macros/latex/contrib/splitindex/splitindex_main.tlu197
14 files changed, 4060 insertions, 0 deletions
diff --git a/macros/latex/contrib/splitindex/README b/macros/latex/contrib/splitindex/README
new file mode 100644
index 0000000000..182f40b3cb
--- /dev/null
+++ b/macros/latex/contrib/splitindex/README
@@ -0,0 +1,78 @@
+Welcome to SplitIndex, the TeX index splitter. SplitIndex creates
+multiple index files from one (intermediate) raw index.
+See manifest.txt if you want to know the files SplitIndex exists of.
+
+There are a lot of alternatives in using SplitIndex, because I wanted
+solutions for every platform. Not all of the programs are distributed
+in binary form. But splitindex.tex will work at every platform. And you
+need only TeX (even not LaTeX) to run it.
+
+Currently I provide C source prepared for the following platforms:
+
+ - Linux,
+ - OpenBSD,
+ - FreeBSD,
+ - OpenSolaris,
+ - CygWIN Windows
+
+And four platform independent solutions using one of:
+
+ - Perl,
+ - Java 1.4.1,
+ - TeX
+ - TeXLua
+
+If you need support, you can write me a mail. Use
+
+ To: splitindex <komascript(at)gmx.info>
+ Subject: SPLITINDEX: <YourProblem>
+
+And replace <YourProblem> by a short (at least 60 chars) description
+of your problem.
+
+See file install.txt for a description how to install this
+distribution and how to get the manual, which describes how to use
+SplitIndex.
+
+LEGALESE:
+---------
+
+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.
+
+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.
+
+Enjoy, Markus.
diff --git a/macros/latex/contrib/splitindex/install.sh b/macros/latex/contrib/splitindex/install.sh
new file mode 100755
index 0000000000..d5ddad4a9f
--- /dev/null
+++ b/macros/latex/contrib/splitindex/install.sh
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# splitindex installation script
+# Copyright (c) Markus Kohm 2013
+#
+# $Id: install.sh,v 1.10 2013-04-04 13:12:18 mjk Exp $
+#
+# This file is part 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 "maintained".
+#
+# The Current Maintainer and author of this work is Markus Kohm.
+#
+# 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.
+
+if [ -z "$DESTDIR" ]
+then
+ TEXMFINSTALL=`kpsewhich -var-value=TEXMFLOCAL`
+ if ! mkdir -p $TEXMFINSTALL/tex/latex/splitidx
+ then
+ TEXMFINSTALL=`kpsewhich -var-value=TEXMFHOME`
+ fi
+else
+ [ -z "$TEXMFINSTALL" ] && TEXMFINSTALL="/texmf"
+ [ -z "$BINDIR" ] && BINDIR="/bin"
+fi
+
+if [ "$1" == "-h" -o "$1" == "--help" ]
+then
+ cat <<EOF
+install.sh
+Copyright (c) Markus Kohm 2013
+
+This bash script installs splitidx and splitindex.
+The files will be installed into TEXMF tree
+$DESTDIR$TEXMFINSTALL/.
+EOF
+ echo -n 'Binaries will be installed to '
+ if [ -z "$BINDIR" ]
+ then
+ find `kpsewhich -var-value=SELFAUTODIR` -mindepth 1 -type d -print
+ else
+ echo "$DESTDIR$BINDIR/"
+ fi
+ cat <<EOF
+You may change installation paths by setting environment variables DESTDIR,
+TEXMFINSTALL and BINDIR.
+EOF
+ exit 0
+fi
+
+perlavailable=false
+if type perl
+then
+ perlavailable=true
+fi
+
+set -e
+
+sourcedir=`find ./ -name splitidx.dtx`
+sourcedir=${sourcedir%/*}/
+
+pushd $sourcedir
+
+tex splitidx.ins
+
+pdflatex -draftmode -interaction=batchmode splitidx.dtx
+pdflatex -draftmode -interaction=batchmode splitidx.dtx
+mkindex splitidx.dtx
+pdflatex -interaction=batchmode splitidx.dtx
+
+mkdir -p "$DESTDIR$TEXMFINSTALL/tex/latex/splitidx"
+mkdir -p "$DESTDIR$TEXMFINSTALL/tex/generic/splitindex"
+mkdir -p "$DESTDIR$TEXMFINSTALL/scripts/splitindex"
+mkdir -p "$DESTDIR$TEXMFINSTALL/doc/latex/splitidx"
+mkdir -p "$DESTDIR$TEXMFINSTALL/doc/man/man1"
+mkdir -p "$DESTDIR$TEXMFINSTALL/source/latex/splitindex"
+
+install -v -m 644 splitidx.sty "$DESTDIR$TEXMFINSTALL/tex/latex/splitidx/"
+install -v -m 644 splitindex.tex "$DESTDIR$TEXMFINSTALL/tex/generic/splitindex/"
+install -v -m 755 splitindex.pl splitindex.tlu splitindex_main.tlu \
+ "$DESTDIR$TEXMFINSTALL/scripts/splitindex"
+install -v -m 644 README splitidx.pdf \
+ "$DESTDIR$TEXMFINSTALL/source/latex/splitindex/"
+install -v -m 644 splitindex.1 "$DESTDIR$TEXMFINSTALL/doc/man/man1/"
+
+install -v -m 644 README install.txt manifest.txt \
+ splitidx.dtx splitidx.ins \
+ splitindex.1 splitindex.c splitindex.java splitindex.pl splitindex.tex \
+ splitindex.tlu splitindex_main.tlu \
+ "$DESTDIR$TEXMFINSTALL/source/latex/splitindex/"
+
+if $perlavailable
+then
+ cp splitindex.pl splitindex
+else
+ cp splitindex.tlu splitindex
+fi
+
+if [ -z "$BINDIR" ]
+then
+ find `kpsewhich -var-value=SELFAUTODIR` -mindepth 1 -type d -print0 | \
+ xargs -0 install -v -m 755 splitindex
+else
+ install -v -m 755 splitindex "$DESTDIR$BINDIR/"
+fi
+
+rm splitindex
+
+popd
diff --git a/macros/latex/contrib/splitindex/install.txt b/macros/latex/contrib/splitindex/install.txt
new file mode 100644
index 0000000000..109b05f43b
--- /dev/null
+++ b/macros/latex/contrib/splitindex/install.txt
@@ -0,0 +1,222 @@
+ SplitIndex Installation Guide
+
+ 2016-02-18
+
+
+INTRODUCTION
+============
+
+If you know how to install LaTeX packages and how to install binary
+programs, just do it. If you don't know, read the following. If you
+are using a system which provides a bash and gnu tools, you may try
+install.sh for installation. See
+
+ ./install.sh --help
+
+for more information.
+
+But you may also try the following step by step installation:
+
+HOW TO INSTALL SplitIndex FROM A TDS-ARCHIVE
+============================================
+
+Some distributors may use a SplitIndex TDS-archive for distributing
+SplitIndex. SplitIndex TDS-archive may be installed very easily.
+The SplitIndex TDS-archive has following contents:
+
+ +- doc/
+ | +- latex/
+ | | +- splitindex/
+ | | +- README
+ | | +- install.txt
+ | | +- manifest.txt
+ | | +- splitidx.pdf
+ | +- man/
+ | +- man1/
+ | +- splitindex.1
+ +- tex/
+ | +- generic/
+ | +- splitindex/
+ | +- splitindex.tex
+ | +- latex/
+ | +- splitindex/
+ | +- splitidx.sty
+ +- scripts/
+ | +- splitindex/
+ | +- splitindex.pl
+ | +- splitindex.tlu
+ | +- splitindex_main.tlu
+ +- source/
+ +- latex/
+ +- splitindex/
+ +- install.sh
+ +- splitidx.dtx
+ +- splitidx.ins
+ +- splitindex.c
+ +- splitindex.java
+
+If you don't have such an archive, continue reading at 1st step of ``HOW TO
+GENERATE THE splitidx PACKAGE''. If you have such an archive - we will use
+the file name ``splitindex.tds.zip'' in the following - you may continue
+with:
+
+A) Have a look where your LaTeX Distribution searchs for files.
+ With TeX Live you can ask kpathsea for this, e.g. using a unix
+ shell:
+
+ kpsexpand \$TEXMFLOCAL
+
+ to use the local texmf tree or:
+
+ kpsexpand \$TEXMFHOME
+
+ to use your private texmf tree. Following uses ``<TEXMF>'' to
+ be a synonym for the texmf tree you want to use.
+
+B) Extract splitindex.tds.zip at <TEXMF> with all the subdirectories of
+ the splitindex.tds.zip but without generating additional
+ subdirectories, e.g., using:
+
+ cd <TEXMF>
+ unzip splitindex.tds.zip
+
+ or any other zip extraction programm.
+
+C) Continue with 5th or 6th step at ``HOW TO INSTALL THE EXECUTABLES''.
+
+D) Call the program, which is used to update the filename data
+ base, e.g., texhash or mktexlsr if you are using teTeX/TeX Live.
+
+E) Read ``HOW TO TEST YOUR INSTALLATION'' at the end of this
+ documentation.
+
+
+HOW TO GENERATE THE splitidx PACKAGE
+====================================
+
+You need this only, if you don't have a SplitIndex TDS-archive, but want
+to install SplitIndex from a basic SplitIndex distribution. If you have
+already done the SplitIndex TDS-archive installation discribed above, you
+should skip this section.
+
+1st) Process splitidx.ins with TeX or LaTeX, e.g. using the following
+ input at a command shell (e.g. bash or command.com):
+
+ latex splitidx.ins
+
+ Maybe you'll be asked, if you want to overwrite existing files.
+ Answer this question with yes.
+
+2nd) Have a look where your LaTeX Distribution searchs for files.
+ With TeX Live you can ask kpathsea for this, e.g. using a unix
+ shell:
+
+ kpsexpand \$TEXMFLOCAL
+
+ to use the local texmf tree or:
+
+ kpsexpand \$TEXMFHOME
+
+ to use your private texmf tree. Following uses ``<TEXMF>'' to
+ be a synonym for the texmf tree you want to use.
+
+3rd) Create folder <TEXMF>/tex/latex/splitindex (at Windows:
+ <TEXMF>\tex\latex\splitindex), if it doesn't exist. Copy
+ splitidx.sty to this folder.
+
+4th) Create folder <TEXMF>/scripts/splitindex (at Windows:
+ <TEXMF>\scripts\latex\splitindex), if it doesn't exist. Copy
+ splitindex.pl, splitindex.tlu and splitindex_main.tlu to this folder.
+
+5th) Call the program, which is used to update the filename data
+ base, e.g. texhash or mktexlsr if you are using teTeX/TeX Live.
+
+
+HOW TO INSTALL THE EXECUTABLE
+=============================
+
+You need only one of the executables splitindex.pl or splitindex.tlu.
+I recommend to use splitindex.pl, but if your system doesn't provide perl
+but TeXLua, you may use splitindex.tlu instead.
+
+To install splitindex.pl or splitindex.tlu on Windows:
+
+5th) Rename a copy of runscript.exe into splitindex.exe and copy it
+ into the binary folder of your TeX installation. You may simply search
+ for runscript.exe itself to find the binary folder.
+
+To install splitindex.pl or splitindex.tlu on Linux, OpenBSD, OS X,
+OpenSolaris etc.:
+
+6th) Copy splitindex.pl or splitindex.tlu to the binary folder of your TeX
+ installation and rename it into splitindex. You may simply do a
+ `which pdflatex' to find the binary folder. Make splitindex executable
+ for everybody using e.g. `chmod a+x splitindex'.
+
+
+HOW TO GET A REAL BINARY
+========================
+
+If you don't like scripts, you may make a real binary from the C source file
+splitindex.c and install that instead of the script. If your getopt library
+doesn't support long options, you may define NO_LONGOPT. In this case the code
+for long options won't be compiled. I recommend to use either the perl or the
+TeXLua script.
+
+
+HOW TO GENERATE THE MANUAL
+==========================
+
+7th) process splitidx.dtx with LaTeX to generate the user manual of
+ splitidx and SplitIndex, e.g. using the following input at a
+ command shell:
+
+ pdflatex splitidx.dtx
+ pdflatex splitidx.dtx
+ mkindex splitidx
+ pdflatex splitidx.dtx
+
+ or (if you do not have the mkindex script):
+
+ pdflatex splitidx.dtx
+ pdflatex splitidx.dtx
+ makeindex -s gind.ist splitidx
+ makeindex -s gglo.ist -o splitidx.gls splitidx.glo
+ pdflatex splitidx.dtx
+
+ You may print the resulting splitidx.pdf.
+
+8th) read the manual you produced at 7th step.
+
+
+HOW TO TEST YOUR INSTALLATION
+=============================
+
+Use the following LaTeX source to test the installation. See
+splitidx.pdf to learn to know how to do this.
+
+\documentclass{article} % We use \Class{article} class ...
+\usepackage{splitidx} % ... and the \Package{splitidx} package
+\makeindex % And we want index generation
+\usepackage{hyperref}
+% We define 4 indices:
+\newindex[General Index]{idx} % Name and shortcut of the 1st index
+\newindex[Index of Animals]{ani} % ... 2nd index
+\newindex[Index of Fruits]{fru} % ... 3rd index
+\newindex[Index of Vegetables]{veg} % ... \dots\ 4th index
+
+\begin{document}
+Apples\sindex[fru]{apple} % an entry to fru index
+and oranges\sindex[fru]{orange} % an entry to fru index
+are fruits\sindex{fruits}. % an implicite entry to idx index
+Tomatos\sindex[veg]{tomato} % an entry to veg index
+are vegetables\index{vegetables}. % an implicite entry to idx index
+Cats\sindex[ani]{cat} % an entry to ani index
+are animals\sindex[idx]{animals}. % an explicite entry to idx index
+
+\twocolumn[%
+ \section*{Indices}%
+ \markboth{Indices}{Indices}%
+]
+\printsubindex* % print all indices
+\end{document}
diff --git a/macros/latex/contrib/splitindex/manifest.txt b/macros/latex/contrib/splitindex/manifest.txt
new file mode 100644
index 0000000000..651a683912
--- /dev/null
+++ b/macros/latex/contrib/splitindex/manifest.txt
@@ -0,0 +1,62 @@
+%
+% The following files form the SplitIndex Bundle and also every
+% SplitIndex Distribution since 2013.
+%
+%
+% CONTENTS OF THE SplitIndex DISTRIBUTION
+% =======================================
+%
+% Documentation:
+% --------------
+%
+% manifest.txt -- This file.
+% install.txt -- How to install SplitIndex (overview).
+% README -- Should be read first.
+% splitindex.1 -- The unix manual page of all SplitIndex
+% programs.
+% splitidx.pdf -- The user manual of SplitIndex and
+% splitidx.sty.
+%
+%
+% LaTeX files:
+% ------------
+%
+% splitidx.dtx -- The source of the splitidx package and of the
+% manual.
+% splitidx.ins -- The installation script for the splitidx
+% package.
+%
+%
+% Program sources:
+% ----------------
+%
+% splitindex.pl -- The source of the reference implementation of
+% the SplitIndex program.
+% splitindex.java -- The source of the SUN JAVA 1.4.1 implementation
+% of the SplitIndex program.
+% splitindex.c -- The source of the C implementation of the
+% SplitIndex program.
+% splitindex.tex -- The source of the TeX implementation of the
+% SplitIndex program.
+% splitindex.tlu -- TeXlua wrapper for the TeXlua implementation of
+% the SplitIndex program.
+% splitindex_main.tlu
+% -- TeXlua implementation of the SplitIndex program.
+%
+%
+% Programs (binaries):
+% --------------------
+%
+% splitindex.pl -- Perl is an interpreter, so this is the source
+% and the program itself (but not binary)
+% splitindex.tlu -- TeXlua is an interpreter, so this is the source
+% and the program itself (but not binary)
+%
+% Installation programs:
+% ----------------------
+%
+% install.sh -- See `install.txt' for more information about
+% this.
+%
+% ====================================================================
+%
diff --git a/macros/latex/contrib/splitindex/splitidx.dtx b/macros/latex/contrib/splitindex/splitidx.dtx
new file mode 100644
index 0000000000..379abdf63e
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitidx.dtx
@@ -0,0 +1,1667 @@
+% \CheckSum{626}
+% \iffalse
+% ======================================================================
+% splitidx.dtx
+% Copyright (c) Markus Kohm, 2002-2016
+%
+% $Id: splitidx.dtx 4 2016-02-18 10:13:32Z mjk $
+%
+% This file is part 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 "maintained".
+%
+% The Current Maintainer and author of this work is Markus Kohm.
+%
+% 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.
+% ======================================================================
+%
+%<*dtx>
+% \fi
+\ProvidesFile{splitidx.dtx}[%
+% \iffalse
+%</dtx>
+%<driver>\ProvidesFile{splitidx.drv}[%
+%<package>\ProvidesPackage{splitidx}[%
+% \fi
+ 2016/02/18 v1.2c multiple indices for LaTeX]
+% \iffalse
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage{color,alltt}
+\usepackage{hypdoc}
+\DeclareRobustCommand*{\Prompt}{{\color{green}\textbf{\$}}}
+\DeclareRobustCommand*{\Package}[1]{\textsf{#1}}
+\DeclareRobustCommand*{\Class}[1]{\textsf{#1}}
+\DeclareRobustCommand*{\Program}[1]{\textsf{#1}}
+\DeclareRobustCommand*{\File}[1]{\texttt{#1}}
+\DeclareRobustCommand*{\Cmdline}[1]{\texttt{#1}}
+\providecommand*{\url}{\texttt}
+\makeatletter
+\providecommand*{\Autoref}[1]{%
+ \@ifundefined{hyperref}{Section~\ref{#1}}{%
+ \hyperref[#1]{Section~\ref*{#1}}%
+ }%
+}%
+\makeatother
+\CodelineIndex
+\RecordChanges
+\EnableCrossrefs
+\GetFileInfo{splitidx.dtx}
+\title{Creating More Than One Index Using \Package{splitidx} And
+ \Program{SplitIndex}\thanks{This file is version \fileversion{} of file
+ \File{\filename}. Nevertheless it should be stable.}}
+\author{Markus Kohm\thanks{Markus Kohm \textless komascript\textcircled{\tiny
+ at}gmx.info\textgreater}\ \thanks{Many thanks to Michael Palmer who
+ improved the English user manual of the \Program{SplitIndex}.}}
+\date{\filedate}
+\begin{document}
+\maketitle
+\begin{abstract}
+ With \Package{makeidx}, there's a standard package in \LaTeX{} to create one
+ index for each document. But sometimes more than one index is needed. There
+ are different packages with different solutions and different problems to
+ generate multiple indices. \Package{splitidx} implements another solution to
+ this problem. In addition, \Package{splitidx} also lets you customize the
+ typesetting and appearance of these indices, as well as the formatting of
+ individual index entries.
+\end{abstract}
+\tableofcontents
+\DocInput{splitidx.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \DoNotIndex{\DeclareOption,\AtEndOfPackage,\renewcommand,\g@addto@macro}
+% \DoNotIndex{\renewcommand,\ProcessOptions,\relax,\newcommand,\emph}
+% \DoNotIndex{\providecommand,\@bsphack,\@esphack,\@sanitize,\typeout}
+% \DoNotIndex{\begingroup,\endgroup,\jobname,\ifx,\else,\fi,\expandafter}
+% \DoNotIndex{\csname,\endcsname,\protected@write,\AtBeginDocument}
+% \DoNotIndex{\ifHy@hyperindex,\@indexfile,\thepage,\Hy@temp@A}
+% \DoNotIndex{\HyInd@ParenLeft,\HyInd@ParenRight,\string,\@ifstar,\@input@}
+% \DoNotIndex{\@ifnextchar,\edef,\let,\@empty,\@for,\@tempa,\xdef,\def}
+% \DoNotIndex{\catcode,\lowercase,\do,\@ifundefined,\PackageError}
+% \DoNotIndex{\MessageBreak,\gdef,\@namedef,\setcounter,\@gobble.\-,\\}
+% \DoNotIndex{\@onlypreamble,\@tempb,\@wrindex,\immediate,\newif,\newwrite}
+% \DoNotIndex{\openout,\@gobble}
+%
+% \changes{v1.2}{2013/04/04}{several improvements of the user manual by
+% Michael Palmer}
+%
+% \section{Introduction}
+% \label{sec:intro}
+%
+% Standard \LaTeX\ provides for only a single document index. To produce such
+% an index, one usually loads \Package{makeidx} and marks up index entries in
+% the document using the \cs{index} command. When the document is processed
+% with \LaTeX, the \cs{index} commands from the document are written as
+% \cs{indexentry} commands to the raw index file
+% ``\File{\cs{jobname}.idx}''. The raw index file is then processed with
+% \Program{MakeIndex} or another auxiliary program like \Program{xindy}, which
+% will produce a sorted index file named ``\File{\cs{jobname}.ind}''. This
+% file is then included at the end of the document using the \cs{printindex}
+% command.\footnote{For further details, read \protect\cite{makeindex} and
+% e.g.\ \protect\cite{makeindexmanual}.}
+%
+% The \Package{splitidx} package extends this process to permit the creation
+% of multiple indices. Separate indices are declared and given unique shortcut
+% identifiers with the \cs{newindex} command. In the document, individual
+% index entries are marked up and assigned to specific indices with the
+% \cs{sindex} command. For each of the declared indices, a separate
+% \File{.idx} file is generated, each of which is post-processed into a
+% separate \File{.ind} file. These \File{.ind} files are then included in the
+% document using a modified version of the \cs{printindex} command.
+%
+% The process outlined thus far resembles that of other multi-index packages
+% such as \Package{multind}. The most straightforward way to implement this
+% scheme, which is the one used by package \Package{multind} and others, is to
+% directly write a separate \File{.idx} file for each declared index when
+% processing the document with \LaTeX, and then to separately post-process
+% each \File{.idx} file with \Program{MakeIndex}. However, this approach can
+% run into technical limitations. \TeX{} can have no more than 16 files open
+% for writing at any one time. Several of these file handles are required by
+% \LaTeX{} itself for other purposes, such as cross references, the table of
+% contents, and possibly others, depending on the structure of your
+% document. Therefore, if you need a large number of separate indices, the
+% limited number of available file handles may become a problem. The
+% \Package{splitidx} package provides a solution to this problem.
+%
+% If the number of indices can be accommodated within the number of available
+% file handles, you can use \Package{splitidx} with the package option
+% \texttt{split}. Then, \Package{splitidx} will directly write multiple raw
+% index files, that is, it will behave according to the scheme just
+% described. On the other hand, if the number of indices exceeds the number of
+% available file handles, you can request \Package{splitidx} to write all
+% index entries to a single intermediate index file, which must then be
+% post-processed in order to obtain the separate raw index files. The
+% post-processing of the intermediate file is done with the
+% \Program{SplitIndex} program, which exists in several different
+% implementations (see below). This behavior of \Package{splitidx} is
+% activated by omitting option \texttt{split}, that is, it is the package's
+% default behavior.
+%
+% In addition to the construction of separate indices, \Package{splitidx} also
+% offers help with customizing the typesetting and appearance of these
+% indices, as well as the formatting of individual index entries.
+%
+%
+% \section{The \protect\Program{SplitIndex} program}
+% \label{sec:splitindex.program}
+%
+% \subsection{Purpose}
+%
+% While the number of files \TeX{} can open for writing is limited, using
+% multiple indices is normally limited too. As already mentioned in
+% \autoref{sec:intro} this limitation may be neutralized using a single
+% intermediate index file, that will be split into several raw index files by
+% an external post-processor: \Program{SplitIndex}.
+%
+%
+% \subsection{Implementation}
+%
+% The program has been implemented in five different languages, as follows:
+%
+% \begin{description}
+% \item[\Program{splitindex.pl}] This is written in perl. You need a perl
+% interpreter to run it. If you are a Unix user, you have a perl interpreter
+% and you can call \Program{splitindex.pl} like you would call a binary
+% program or a shell script from your shell. This is the reference
+% implementation. I prefer to use this, because it was the first, the
+% easiest and the shortest to be written.
+% \item[\Program{splitindex.java}] This is written using Sun Java~1.4.1. I
+% wrote it because Java is everywhere and may be installed everywhere and a
+% lot of people are able to understand Java source files. Nevertheless
+% There's no longer a precompiled version of this in the main distribution.
+% But you may download it from the repository at
+% \url{http://sarovar.org/plugins/scmcvs/cvsweb.php/binaries/?cvsroot=splitindex}
+% \item[\Program{splitindex.c}:] This is a C source of \Program{splitindex}.
+% I wrote the
+% C version because a lot of people like to have a binary and most software
+% authors understand C, and some people want fast binaries instead of slow
+% Java byte code\,---\,even, if the Java program is fast
+% enough. Nevertheless, there are no longer binaries of generated from this
+% source in the main distribution.
+% \item[\Program{splitindex.tex}:] This is a \TeX{} version of the
+% program. Yes, you are right: it is a program written in \TeX{}. It has not
+% the whole functionality of the other programs (see \autoref{TeX}), but
+% it is system-independent and you don't need to install any other program
+% like perl or Sun Java 1.4. It is not impossible to fix all the
+% disadvantages of this program\,---\,but it isn't easy and much more work
+% than all the other programs.
+% \changes{v1.2}{2013/04/04}{new \TeX Lua implementation of
+% \Program{SplitIndex}}
+% \item[\Program{splitindex.tlu}:] This is a new \TeX Lua version of the
+% program. It is platform independent like the perl script. Note, that the
+% syntax for regular expressions in Lua differs from the perl syntax, if you
+% use it instead of the perl version. Distributors should prefere the perl
+% version, if they also provide perl for the installation platform.
+% \end{description}
+% With the exception of the \TeX{} version, all of these programs are also
+% able to call the index processor on each of the resulting raw index files.
+%
+% And where is the lisp, the smalltalk, the prolog, the \dots{} version of
+% \Program{splitindex}? Hey, five languages are enough for me! If you need one
+% more, write it!
+%
+%
+% \section{Using the \Package{splitidx} package}
+% \label{package}
+%
+% \subsection{Setup}
+%
+% You can use \Package{splitidx} as a drop-in-replacement for
+% \Package{makeidx}. If you do so, you just have to replace
+% \begin{verbatim}
+% \usepackage{makeidx}
+% \end{verbatim}\vspace{-\baselineskip}
+% by
+% \begin{verbatim}
+% \usepackage{splitidx}
+% \end{verbatim}\vspace{-\baselineskip}
+%
+% \DescribeMacro{\makeindex}
+% To activate index generation, you can use \cs{makeindex}, which is declared
+% by the \LaTeX{} kernel.
+% You can also load the package with the option
+% \texttt{makeindex}:
+% \begin{verbatim}
+% \usepackage[makeindex]{splitidx}
+% \end{verbatim}\vspace{-\baselineskip}
+% which is almost the same like:
+% \begin{verbatim}
+% \usepackage{splitidx}\makeindex
+% \end{verbatim}\vspace{-\baselineskip}
+%
+% Other package options are available. The effect of the \texttt{split} option
+% was already described in \autoref{sec:intro}; further options are
+% discussed below.
+%
+% \DescribeMacro{\newindex}
+% If you want to generate more than one index without shortcut, you should
+% declare this using \cs{newindex} with syntax:
+% \begin{quote}
+% \cs{newindex}\oarg{index name}\marg{shortcut}.
+% \end{quote}
+% The mandatory argument \meta{shortcut} is used to distinguish the different
+% indices. See description of \cs{sindex} for more information about this. The
+% optional argument \meta{index name} is the name of the index. This is also
+% the default heading of this index used by the macros \cs{printindex} and
+% \cs{printsubindex} (see below). If you omit \meta{index name}, the shortcut
+% will be used as index name.
+%
+% While it is always good practice to declare all index explicitly in the
+% preamble of the document, this \emph{must} be done if you also use the
+% package option \texttt{split}. In this case, the \cs{newindex} command opens
+% a raw index file to write to for each declared index. As the only exception,
+% the raw index file for the index entries with the default shortcut
+% (\texttt{idx}) will be created automatically. As noted above, the number of
+% index files that you can create in this way is limited, which is due to the
+% limited number of output streams provided by \TeX{}. If you exceed this
+% number, not only the \cs{newindex} macro itself may result in an error, but
+% also \cs{tableofcontents}, \cs{listoffigures}, \cs{listoftables} and any
+% other command that implicitly allocates an output stream.
+%
+% A unique shortcut declared with \cs{newindex} to refer to a specific
+% index becomes part of the filenames of the corresponding \File{.idx} and
+% \File{.ind} files. Therefore, when you choose a shortcut, make sure that you
+% only use characters or symbols in the \meta{shortcut} that are allowed in
+% filenames. On file systems that treat file names as case-insensitive, you
+% should not mix uppercase and lowercase letters. For maximum portability and
+% minimum hassle, it is best to always use only lowercase letters.
+%
+% \subsection{Marking up index entries}
+%
+% \DescribeMacro{\index}%^^A
+% After loading the \Package{splitidx} package, you may use the \cs{index}
+% command to mark up index entries in your manuscript as usual. You can find
+% the description of the argument and features of this command in reference
+% \cite{makeindex}. The \Program{splitindex} program (see
+% \autoref{program}) will put all index entries that were produced with
+% \cs{index} into the same raw index file, which is tagged with the unique
+% shortcut ``\texttt{idx}''; that is, the \cs{index} command does \emph{not}
+% allow you to assign index entries to separate indices. However, the
+% \texttt{useindex} option allows you to change this behavior; this is
+% discussed below.
+%
+% \DescribeMacro{\sindex}%^^A
+% The \Package{splitidx} package also defines the command \cs{sindex} with the
+% syntax:
+% \begin{quote}
+% \cs{sindex}\oarg{shortcut}\marg{index-entry}
+% \end{quote}
+% The \cs{sindex} command is \Package{splitidx}' mechanism for placing
+% individual index entries into specific indices. The target index is
+% identified by passing its unique shortcut, as declared with \cs{newindex},
+% in the optional argument to \cs{sindex}. If not given, the shortcut defaults
+% to ``\texttt{idx}'', which should therefore be used to identify some sort of
+% general index.
+%
+% If you like, you may also request that \cs{index} should be an alias
+% for \cs{sindex}. To do so, you use the package
+% option \texttt{useindex}, e.g.:
+% \begin{verbatim}
+% \usepackage[useindex]{splitidx}
+% \end{verbatim}\vspace{-\baselineskip}
+% This may be useful when using packages like \textsf{jurabib} that expect
+% \cs{index} to be the index command.
+%
+% \subsection{Suppressing multiple index generation}
+%
+% Under some unfortunate circumstances, for example when working with a
+% publisher that enforces a rigid document format, it may be necessary to
+% merge the separate indices back into a single index. In this case, it is
+% \emph{not} necessary to strip out all the individually marked up index
+% identifiers. Instead, you may load the \Package{splitidx} package with the
+% \texttt{allintoone} option:
+%
+% \begin{verbatim}
+% \usepackage[allintoone]{splitidx}
+% \end{verbatim}\vspace{-\baselineskip}
+% or
+% \begin{verbatim}
+% \usepackage[allintoone,makeindex]{splitidx}
+% \end{verbatim}\vspace{-\baselineskip}
+% With this option, \Package{splitidx} will do the stripping for you, that is,
+% \cs{sindex}\oarg{shortcut}\linebreak[1]\marg{indexentry} will be substituted
+% with \cs{index}\marg{indexentry} during \LaTeX\ processing.
+%
+% \emph{Note: Currently only one of the options \texttt{allintoone} and
+% \texttt{useindex} can be used at same time. If you try to use both,
+% \texttt{useindex} will be disabled! This may result in many error
+% messages!}
+%
+% \subsection{Customizing index entries}
+%
+% \DescribeMacro{\AtWriteToIndex}%^^A
+% \Package{splitidx} uses \cs{protected@write} to write the index entries to
+% its output files. The \cs{AtWriteToIndex} macro lets you execute a piece of
+% code each time an index is written to a specific index. Usage:
+% \begin{quote}
+% \cs{AtWriteToIndex}\marg{shortcut}\marg{code}
+% \end{quote}
+% This may be useful if you want your index entries to reference not the page
+% number but some other counter instead. For example, in order to make each
+% index entry in the general index (identified by the \texttt{idx} shortcut)
+% point to the corresponding section number, you would write
+% \begin{verbatim}
+% \AtWriteToIndex{idx}{\let\thepage\thesection}
+% \end{verbatim}
+% Note that this will work only if the shortcut of the index is given
+% explicitly in each marked-up index entry; for example,
+% \begin{verbatim}
+% \sindex[idx]{Roller blades}
+% \end{verbatim}\vspace{-\baselineskip}
+% instead of
+% \begin{verbatim}
+% \sindex{Roller blades}
+% \end{verbatim}\vspace{-\baselineskip}
+% Note, if you want to use command \cs{index} instead of \cs{sindex}, you
+% should also use the package option \texttt{useindex}; without it, command
+% \cs{index} will still write the page number to the index.
+%
+% The \cs{AtWriteToIndex} command may be used only in the document preamble.
+%
+% \DescribeMacro{\AtNextWriteToIndex}%^^A
+% Sometimes it may be useful to execute some commands only for writing a
+% single index entry. To do so, you may use
+% \begin{quote}
+% \cs{AtNextWriteToIndex}\marg{shortcut}\marg{commands}
+% \end{quote}
+% instead of \cs{AtWriteToIndex}.
+%
+%\subsection{Automatic custom index commands}
+%
+% Some people do not like to write \cs{sindex[foo]}\marg{entry}. They want to
+% write \cs{foo}\marg{entry}. For these people, the package option
+% `\texttt{idxcommands}' has been implemented. This option defines a command
+% with the name of the \meta{shortcut} for each declared index. If you use
+% this option, you'll get an error if a command with this name is already
+% defined. Also note that if you are using this option, the characters of the
+% shortcuts must be letters.
+%
+% \subsection{Preventing premature expansion of index entries}
+%
+% \DescribeMacro{\newprotectedindex}%^^A
+% When using the standard index package \textsf{makeidx}, the \LaTeX{} kernel
+% command \cs{index} may expand its argument. The kernel uses \cs{@sanitize}
+% to avoid expansion in some cases. But this fails if the argument was already
+% read by another macro. So if you define a macro that reads its argument,
+% does something with it and then writes it to the index, this may expand the
+% argument. For illustration, try the following:
+% \begin{verbatim}
+% \documentclass{article}
+% \usepackage{ngerman}
+% \usepackage{makeidx}\makeindex
+% \newcommand*{\Test}[1]{#1\index{#1}}
+% \begin{document}
+% \Test{"Anderung}
+% "Anderung\index{"Anderung}
+% \end{document}
+% \end{verbatim}\vspace{-\baselineskip}
+% This will result in two entries in the \texttt{.idx} file:
+% \begin{verbatim}
+% \indexentry{\active@dq \dq@prtct{A}nderung}{1}
+% \indexentry{"Anderung}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% The first one is something expanded that is not wanted. Package
+% \textsf{splitindx} behaves the same way by default. But if you use
+% \cs{newprotectedindex} to define a new index, it uses a trick to avoid
+% expansion. If all indices should behave like this, you may simply use the
+% package option \texttt{protected}.
+% \begin{verbatim}
+% \documentclass{article}
+% \usepackage{ngerman}
+% \usepackage[protected,useindex,makeindex]{splitidx}
+% \newcommand*{\Test}[1]{#1\index{#1}}
+% \begin{document}
+% \Test{"Anderung}
+% "Anderung\index{"Anderung}
+% \end{document}
+% \end{verbatim}\vspace{-\baselineskip}
+% Will result in two entries at the \texttt{.idx} file:
+% \begin{verbatim}
+% \indexentry{"Anderung}{1}
+% \indexentry{"Anderung}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% If you want to know more about the trick, see the command
+% \cs{@onelevel@sanitize} in the \LaTeX{} kernel documentation,
+% \texttt{source2e}.
+%
+% \subsection{Including the generated indices in your document}
+%
+% \DescribeMacro{\printindex}%^^A
+% \changes{v0.2a}{2003/01/05}{fix of documentation bug}%^^A
+% The \cs{printindex} command is used to print one index or all indices that
+% are declared using \cs{newindex}. How it behaves depends on the syntax you
+% are using.
+%
+% Used like this:
+% \begin{quote}
+% \cs{printindex}\oarg{shortcut}\oarg{index name}
+% \end{quote}
+% the index file with the optional shortcut will be included and printed, with
+% the optional \meta{index name} being used as the title. If \meta{index name}
+% is omitted, the default index name declared with \cs{newindex} will be used
+% instead. If this name was omitted as well, the shortcut itself will be used
+% as the title.
+%
+% If both optional arguments, \meta{shortcut} and \meta{index name}, are
+% omitted, and you are using simply
+% \begin{quote}
+% \cs{printindex}
+% \end{quote}
+% this command behaves like \cs{printindex} from package
+% \Package{makeidx}. You should not use this if you are using multiple
+% indices.
+%
+% You may also print all indices that were declared using \cs{newindex} at
+% once. Use the syntax:
+% \begin{quote}
+% \cs{printindex*}
+% \end{quote}
+% to do so. The indices will be printed in the order you declared them using
+% \cs{newindex}.
+%
+% \subsection{Typesetting the generated indices}
+%
+% \cs{printindex} uses the default index output of the class and the index
+% processor you are using. Usually, this will be \texttt{theindex}
+% environment, but it doesn't have to be this way. Note, however, that
+% \cs{printindex} expects the name of the index to be contained in the
+% \cs{indexname} macro; otherwise, it will fail to typeset the index
+% name.\footnote{This would be a failure of the class or used package, not of
+% the \Package{splitidx} package. I don't know of any class with this failure,
+% but package \Package{tcolorbox}'s library \File{documentation} does use
+% \cs{kvtcb@text@index} instead of \cs{indexname}. Since version~1.2c
+% \Package{splitidx} therefore also redefines \cs{kvtcb@text@index} locally.}
+%
+% \DescribeMacro{\printsubindex}%^^A
+% The \cs{printsubindex} command is analogous to \cs{printindex}, but it
+% performs some redefinitions before printing the index, as follows:
+% \begin{itemize}
+% \item demote the index heading level by 1, that is, format the index title
+% using \cs{section*} instead of \cs{chapter*} with classes that define
+% \cs{chapter} (such as \texttt{book} and \texttt{report}), and using
+% \cs{subsection*} instead of \cs{section*} with classes that don't define
+% \cs{chapter} (such as \texttt{article});
+% \item deactivate \cs{onecolumn}, \cs{twocolumn} and \cs{clearpage},
+% \cs{cleardoublepage} that are otherwise used to start a new page in each
+% index,
+% \item change the mark mechanism to use \cs{markright} instead of
+% \cs{markboth} for setting up the running headers.
+% \end{itemize}
+% Using this macro, you can print multiple indices in one chapter, if you are
+% using a class with \cs{chapter}, or in one section, if you are using a class
+% without \cs{chapter}.
+%
+%
+% \DescribeMacro{\setindexpreamble}%^^A
+% If you are using a KOMA-Script class, you'll know this command. Package
+% \Package{splitidx} redefines this command as follows:
+% \begin{quote}
+% \cs{setindexpreamble}\oarg{shortcut}\marg{preamble}
+% \end{quote}
+% This allows you to define a separate preamble for each index. Note: Package
+% \Package{splitidx} doesn't print the preamble itself. Instead, before
+% typesetting an index with a given shortcut using \cs{printindex} or
+% \cs{printsubindex}, it assigns the user-defined preamble for this shortcut
+% to the internal macro \cs{index@preamble}. At the user level, its value can
+% be accessed with the \cs{useindexpreamble} macro (see below).
+%
+% \DescribeMacro{\useindexpreamble}%^^A
+% If you are defining your own index environment or if you extend the existing
+% \texttt{theindex} environment using \cs{extendtheindex} or otherwise, you
+% can use \cs{useindexpreamble} to retrieve the preamble previously defined
+% for the current index using \cs{setindexpreamble}:
+% \begin{quote}
+% \cs{useindexpreamble}\oarg{additional commands}
+% \end{quote}
+% This macro is not limited to the KOMA-Script classes; it can also be used
+% e.g.\ with the standard classes. The commands passed in the optional
+% argument \meta{additional commands} are only used if the preamble for the
+% current index is defined and not empty. Authors of wrapper classes may use
+% this, e.g.\ to add additional vertical spaces after the index preamble if
+% and only if an index preamble will be printed.
+%
+% \DescribeMacro{\indexshortcut}%^^A
+% The macro \cs{indexshortcut} is only defined within the body of
+% \cs{printindex} and \cs{printsubindex}. It expands to the shortcut of the
+% specific index that is being printed. It may be useful when defining your
+% own index environment or extending the \texttt{theindex} environment using
+% e.g.\ \cs{extendtheindex}.
+%
+%
+% \DescribeMacro{\extendtheindex}%^^A
+% Most classes define the environment \texttt{theindex} to be used for
+% printing the index. Using \cs{extendtheindex} with this syntax:
+% \begin{quote}
+% \cs{extendtheindex}\marg{before begin}\marg{after begin}^^A
+% \marg{before end}\mbox{\marg{after end}}
+% \end{quote}
+% you may extend this environment. The commands passed in \meta{before begin}
+% are inserted in \cs{begin\{theindex\}} just after starting the group but
+% before the existing code defined for this code block. The commands passed in
+% \meta{after begin} are inserted after \cs{begin\{theindex\}}. Analogously,
+% the commands passed in \meta{before end} are inserted before
+% \cs{end\{theindex\}}, while those passed in \meta{after end} are used within
+% \cs{end\{theindex\}} just after ending the index but just before ending the
+% group.
+%
+%
+% \subsection{Examples}
+% \label{examples}
+%
+% Let's see how you may get more than one index. The text of the example is
+% silly, so don't think about the text, think about the usage of
+% \Package{splitidx}.
+%
+% \begin{flushleft}\ttfamily
+% \cs{documentclass}\{article\} \percentchar \textit{ We use \Class{article}
+% class \dots}\\
+% \cs{usepackage}\{splitidx\} \percentchar \textit{ \dots\ and the
+% \Package{splitidx} package}\\
+% \cs{makeindex} \percentchar \textit{ And we want index generation}\\
+% ~\\
+% \percentchar \textit{ We define 4 indices:}\\
+% \cs{newindex}[General Index]\{idx\} \percentchar \textit{ Name and shortcut
+% of the 1st index}\\
+% \cs{newindex}[Index of Animals]\{ani\} \percentchar \textit{ \dots\ 2nd
+% index}\\
+% \cs{newindex}[Index of Fruits]\{fru\} \percentchar \textit{ \dots\ 3rd
+% index}\\
+% \cs{newindex}[Index of Vegetables]\{veg\} \percentchar \textit{ \dots\ 4th
+% index}\\
+% ~\\
+% \cs{begin}\{document\}\\
+% Apples\cs{sindex}[fru]\{apple\} \percentchar \textit{ an entry to
+% }fru\texttt{ index}\\
+% and oranges\cs{sindex}[fru]\{orange\} \percentchar \textit{ an entry to
+% }fru\texttt{ index}\\
+% are fruits\cs{sindex}\{fruits\}.\ \percentchar \textit{ an implicit entry
+% to }idx\textit{ index}\\
+% Tomatoes\cs{sindex}[veg]\{tomato\} \percentchar \textit{ an entry to
+% }veg\textit{ index}\\
+% are\\
+% vegetables\cs{index}\{vegetables\}.\ \percentchar \textit{ an implicit
+% entry to }idx\textit{ index}\\
+% Cats\cs{sindex}[ani]\{cat\} \percentchar \textit{ an entry to
+% }ani\textit{ index}\\
+% are animals\cs{sindex}[idx]\{animals\}.\ \percentchar \textit{ an explicite
+% entry to }idx\textit{ index}\\
+% ~\\
+% \cs{printindex*} \percentchar \textit{ print all indices}\\
+% \cs{end}\{document\}
+% \end{flushleft}
+% After processing the file above with \LaTeX{} you'll get a raw index file
+% with following contents:
+% \begin{verbatim}
+% \indexentry[fru]{apple}{1}
+% \indexentry[fru]{orange}{1}
+% \indexentry{fruits}{1}
+% \indexentry[veg]{tomato}{1}
+% \indexentry{vegetables}{1}
+% \indexentry[ani]{cat}{1}
+% \indexentry[idx]{animals}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% \Autoref{program} explains how to convert this intermediate file into
+% separate raw index files and index files. In the above example, all four
+% index files are input with a single \cs{printindex*} command. Each file will
+% produce a single section that start on a new page. The section headings
+% ``General Index'', ``Index of Animals'', ``Index of Fruits'' and ``Index of
+% Vegetables'' will be printed in onecolumn mode, followed by the index
+% entries printed in twocolumn mode.
+%
+% Maybe you would like to format all indices as subsections within one
+% section. You can do this by replacing the \cs{printindex*} command in the
+% example above with the following:
+% \begin{flushleft}\ttfamily
+% \cs{twocolumn}[\percentchar\textit{ set the title onecolumn}\\
+% \ \cs{section*}\{Indices\} \percentchar\textit{ the section with the
+% indices}\percentchar\\
+% \ \cs{markboth}\{Indices\}\{Indices\} \percentchar\textit{ setting up the
+% running headline }\percentchar\\
+% ]\percentchar\textit{ but the indices twocolumn}\\
+% \cs{printsubindex*} \percentchar\textit{ print all indices}
+% \end{flushleft}
+% Note that I've used \cs{printsubindex*} instead of \cs{printindex*} in this
+% modified example.
+%
+% We now turn to the running headers for the index pages. If you are using
+% page style \texttt{plain}, which is default at \Class{article} class, the
+% running headers are empty, so you don't need to set them up. However, if
+% you're using page style \texttt{headings} for your index pages and the
+% \cs{section*} command to format the headings of the several indices, you
+% should set up the running headers to match the current index titles. If you
+% are using a KOMA-Script class, you can use \cs{addsec} or \cs{addsec*}
+% instead of \cs{section*} to format the index titles, in which case you will
+% not need to manually update the running headers.
+%
+% Maybe you want the general index to be the section, while the other indices
+% should be subsections of the general index. You might then try to replace
+% the code above with the following:
+% \begin{flushleft}\ttfamily
+% \percentchar\textit{\#\#\#\#\# This will not do the thing you wanted!
+% \#\#\#\#\#}\\
+% \cs{printindex}[idx] \percentchar\textit{ print index }idx\textit{ as
+% section}\\
+% \cs{printsubindex}[ani] \percentchar\textit{ print index }ani\textit{ as
+% subsection}\\
+% \cs{printsubindex}[fru] \percentchar\textit{ print index }fru\textit{ as
+% subsection}\\
+% \cs{printsubindex}[veg] \percentchar\textit{ print index }veg\textit{ as
+% subsection}\\
+% \end{flushleft}
+% But this will result in a twocolumn section containing the general index
+% (identified by \texttt{idx}) and three onecolumn subsections containing the
+% other indices, and a page break after the general index. Why is this?
+% \LaTeX\ will switch to twocolumn mode as it enters the \texttt{theindex}
+% environment (which is created by the \cs{printindex} command) and will
+% revert to onecolumn mode when it exits \texttt{theindex}. If twocolumn mode
+% was active before \cs{printindex}, a \cs{clearpage} command will be issued
+% at the end of \texttt{theindex}. So what's the solution? Remembering the
+% \cs{extendtheindex} command, you can write:
+% \begin{flushleft}\ttfamily
+% \cs{begingroup} \percentchar\textit{ keep the following extension local to
+% this
+% group}\\
+% \ \cs{extendtheindex}\percentchar \textit{ some changes of
+% }theindex\textit{ environment}\\
+% \ \ \{\}\percentchar\textit{ no change before beginning}\\
+% \ \ \{\}\percentchar\textit{ no change after beginning}\\
+% \ \ \{\cs{let}\cs{onecolumn}\cs{relax} \percentchar\textit{ deactivate
+% \cs{onecolumn} before ending}\\
+% \ \ \ \cs{let}\cs{clearpage}\cs{relax} \percentchar\textit{ deactivate
+% \cs{clearpage} before ending}\\
+% \ \ \}\percentchar \textit{ changes before ending}\\
+% \ \ \{\}\percentchar\textit{ no change after ending}\\
+% \ \cs{printindex}[idx] \percentchar\textit{ print index }idx\textit{ as
+% section}\\
+% \cs{endgroup} \percentchar\textit{ end group with extended
+% }theindex\textit{
+% environment}\\
+% \cs{printsubindex}[ani] \percentchar\textit{ print index }ani\textit{ as
+% subsection}\\
+% \cs{printsubindex}[fru] \percentchar\textit{ print index }fru\textit{ as
+% subsection}\\
+% \cs{printsubindex}[veg] \percentchar\textit{ print index }veg\textit{ as
+% subsection}\\
+% \cs{onecolumn} \percentchar\textit{ finish the indices}
+% \end{flushleft}
+% With this extension, the whole index will be set in twocolumn mode, with no
+% page break before the first subsection. However, you have to switch back to
+% onecolumn mode manually at the end of the indices.
+%
+% The example above may be modified as follows to obtain a onecolumn index:
+% \begin{flushleft}\ttfamily
+% \cs{begingroup} \percentchar\textit{ hold following extension local to this
+% group}\\
+% \ \cs{makeatletter} \percentchar\textit{ allow }@\textit{ at macro names}\\
+% \ \cs{extendtheindex}\percentchar \textit{ some changes of
+% }theindex\textit{ environment}\\
+% \ \ \{\cs{let}\cs{twocolumn}\cs{@firstoptofone} \percentchar\textit{
+% deactivate \cs{twocolumn}}\\
+% \ \ \ \cs{let}\cs{onecolumn}\cs{@firstoptofone} \percentchar\textit{
+% deactivate \cs{twocolumn}}\\
+% \ \ \ \cs{let}\cs{clearpage}\cs{relax} \percentchar\textit{ deactivate
+% \cs{clearpage}}\\
+% \ \ \}\percentchar \textit{ changes before beginning}\\
+% \ \ \{\}\percentchar\textit{ no change after beginning}\\
+% \ \ \{\}\percentchar\textit{ no change before ending}\\
+% \ \ \{\}\percentchar\textit{ no change after ending}\\
+% \ \cs{makeatother} \percentchar\textit{ deactivate \cs{makeatletter}}\\
+% \ \cs{printindex} \percentchar\textit{ print index}\\
+% \cs{endgroup} \percentchar\textit{ end group with extended }theindex\textit{
+% environment}
+% \end{flushleft}
+% This not only works with splitted indices but also with one
+% single index.
+%
+% I hope that these examples were useful to understand how to format indices
+% using \Package{splitidx}. The next section will show you how to generate
+% separate indices from a single intermediate index file.
+%
+%
+% \subsection{Splitting intermediate index files}
+% \label{program}
+%
+% Most commonly, it will be sufficient to call one of the \Program{splitindex}
+% programs with one parameter, the name of the intermediate index file. This
+% will split the intermediate file into several raw index files, and then call
+% \Program{MakeIndex} on each of these. The program \Program{splitindex} can
+% be instructed to use another index processor such as \Program{xindy}, or to
+% pass additional options along to the index processor, e.g.\ ``\Cmdline{-g}''
+% to use German sorting with \Program{MakeIndex}. While it may be a rare need,
+% it is also possible to modify the parsing of the intermediate index file and
+% the generation of the filenames and contents of the resulting raw index
+% files.
+%
+% The names of the options and the syntax of the Arguments is same at all of
+% the programs except \Program{splitindex.tex} (see
+% \autoref{TeX}): \begin{description}\setlength{\labelsep}{1em}
+% \item[\texttt{--help}]
+% \item[{\makebox[1.2em][l]{\texttt{-h}}}]\vspace{-2\itemsep}
+% Show information about usage, options and arguments and terminate without
+% processing an index file.
+% \item[\texttt{--makeindex} \meta{program name}]~
+% \item[\texttt{-m} \meta{program name}]\vspace{-2\itemsep}
+% Call \meta{program name}
+% instead of \Program{makeindex} to process each generated raw index
+% file. You may set this variable to an empty value. How this may be done
+% depends on the shell, which you are using. Using bash you may achieve an
+% empty value using \texttt{""} or \texttt{''}. An empty value means that
+% no index processor will be called on the generated raw index files.
+% \item[\texttt{--identify} \meta{regular expression}]~
+% \item[\texttt{-i} \meta{regular expression}]\vspace{-2\itemsep} Uses
+% \meta{regular expression} to identify the index shortcut and the contents
+% of the raw index file with this shortcut in the intermediate file. The
+% default value is: ``\verb|^(\\indexentry)\[([^]]*)\](.*)$|'' for all but
+% \Program{splitindex.tlu}. This means:
+% \begin{description}
+% \item[{\makebox[1em][l]{\texttt{\textasciicircum}}}]
+% Search from beginning of the line.
+% \item[\texttt{(\string\\indexentry)}]~\par
+% Search for ``\verb|\indexentry|'' and
+% set group 1 to this.
+% \item[{\makebox[1em][l]{\texttt{\string\[}}}]
+% Search for ``\verb|[|'' and ignore it.
+% \item[\texttt{([\textasciicircum]]*)}]~\par
+% Search for any character which is not ``]'' and set group 2 to this.
+% \item[{\makebox[1em][l]{\texttt{\string\]}}}]
+% Search for ``\verb|]|'' and ignore it.
+% \item[\texttt{(.*)\$}]~\par
+% Search for all characters till end of line and set group 3 to these.
+% \end{description}
+% The \meta{regular expression} is POSIX~1003.2 compatible.
+% For \Program{splitindex.tlu} the default is:
+% ``\verb|^(\\indexentry)%[([^]]*)%](.*)$|''.
+% \item[\texttt{--resultis} \meta{pattern}]~
+% \item[\texttt{-r} \meta{pattern}]\vspace{-2\itemsep} Set the lines, which
+% are written to the generated raw index files after identification (see
+% option \texttt{--identify}) to \meta{pattern}. Each
+% \texttt{\$}\meta{digit} at \meta{pattern} will be replaced by the
+% corresponding group, e.g. \verb|$1| will be replaced by the first group
+% (see \texttt{--identify}). The default is: ``\verb|$1$3|'' for all but
+% \Program{splitindex.tlu} resp. ``\verb|%1%3|'' for
+% \Program{splitindex.tlu}, which means: contents of group 1 and group 3.
+%
+% If the \meta{regular expression} of option \texttt{--identify} doesn't
+% match a line at the raw index file the line itself will be written.
+% \item[\texttt{--suffixis} \meta{pattern}]~
+% \item[\texttt{-s} \meta{pattern}]\vspace{-2\itemsep} Set the suffix of the
+% names of the generated raw index files after identification (see option
+% \texttt{--identify}) to \meta{pattern}. Each \texttt{\$}\meta{digit} at
+% \meta{pattern} will be replaced by the corresponding group, e.g. \verb|$1|
+% will be replaced by the first group (see \texttt{--identify}). The default
+% is: ``\verb|-$2|'' resp. ``\verb|-%2|'', which means:
+% character `\texttt{-}' followed by contents of group 2.
+%
+% If the \meta{regular expression} of option \texttt{--identify} doesn't
+% match a line at the raw index file, all groups will be set to
+% ``\texttt{idx}''.
+% \item[\texttt{--verbose}]
+% \item[{\makebox[1.2em][l]{\texttt{-v}}}]\vspace{-2\itemsep}
+% Increase verbosity by one. More verbose means: tell the user more about,
+% what the program is doing.
+% \item[\texttt{--version}]
+% \item[{\makebox[1.2em][l]{\texttt{-V}}}]\vspace{-2\itemsep}
+% Show information about program version and terminate without processing a
+% index file.
+% \end{description}
+%
+% Some of the binaries compiled from the C source won't understand the long
+% option names (\texttt{--makeindex}, \texttt{--identify} \dots). In this case
+% you'd have to use the alternative short option names (\texttt{-m},
+% \texttt{-i} \dots).
+%
+% The first non-option-argument in the command line is used as the name of the
+% intermediate index file to be processed. All arguments that follow the
+% argument ``\texttt{--}'' are interpreted as non-option arguments. All but
+% the first non-option-arguments will be passed to the index processor.
+%
+% You will find some examples in the following subsections.
+%
+%
+% \subsection{Using \Program{splitindex.pl}}
+% \label{perl}
+%
+% This is the reference implementation. Let's use an example to demonstrate
+% its use. If you have the following \LaTeX{} file ``\File{allabout.tex}'':
+% \begin{verbatim}
+% \documentclass{article}
+% \usepackage[makeindex]{splitidx}
+% \begin{document}
+% Apples\sindex[fru]{apple} and oranges\sindex[fru]{orange} are
+% fruits\sindex{fruits}.
+% Tomatos\sindex[veg]{tomato} are vegetables\sindex{vegetables}.
+% Cats\sindex[ani]{cat} are animals\sindex[idx]{animals}.
+% \end{document}
+% \end{verbatim}\vspace{-\baselineskip}
+% this generates the intermediate index file ``File{allabout.idx}'':
+% \begin{verbatim}
+% \indexentry[fru]{apple}{1}
+% \indexentry[fru]{orange}{1}
+% \indexentry{fruits}{1}
+% \indexentry[veg]{tomato}{1}
+% \indexentry{vegetables}{1}
+% \indexentry[ani]{cat}{1}
+% \indexentry[idx]{animals}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+%
+% This file can't be processed by an index processor like
+% \Program{MakeIndex}. In order to split this intermediate file into several
+% raw index files and run the default index processor, you do the following
+% call (the \Prompt{} is a symbol for the shell prompt):
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl allabout.idx|
+% \end{quote}
+% You may omit the extension ``\File{.idx}'':
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl allabout|
+% \end{quote}
+% Both commands will result in a file \File{allabout-fru.idx}:
+% \begin{verbatim}
+% \indexentry[fru]{apple}{1}
+% \indexentry[fru]{orange}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% a file \File{allabout-idx.idx}
+% \begin{verbatim}
+% \indexentry{fruits}{1}
+% \indexentry{vegetables}{1}
+% \indexentry{animals}
+% \end{verbatim}\vspace{-\baselineskip}
+% a file \File{allabout-veg.idx}:
+% \begin{verbatim}
+% \indexentry[veg]{tomato}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% and a file \File{allabout-ani.idx}:
+% \begin{verbatim}
+% \indexentry[ani]{cat}{1}
+% \end{verbatim}\vspace{-\baselineskip}
+% After generation of these files, it calls the default index processor using
+% the command lines:
+% \begin{verbatim}
+% makeindex allabout-fru.idx
+% makeindex allabout-idx.odx
+% makeindex allabout-veg.idx
+% makeindex allabout-ani.idx
+% \end{verbatim}\vspace{-\baselineskip}
+% \begin{sloppypar}\noindent
+% These calls create the index files \File{allabout-fru.ind},
+% \File{allabout-idx.ind}, \File{allabout-veg.ind} and
+% \File{allabout-ani.ind}, which can be loaded into the document using
+% e.g.\ \cs{printindex} from package \Package{splitidx}.
+% \end{sloppypar}
+%
+% If you don't want \Program{splitindex} to call any index processor, use
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl -m "" allabout|
+% \end{quote}
+% instead of the shell command above.
+%
+% You may obtain the same files as above using (it's one input line not two
+% as shown here):
+% \begin{quote}\raggedright
+% \Prompt{}\verb|splitindex.pl -i '^\\indexentry\[([^]]*)\](.*)$'|
+% \verb|-s '-$1'| \verb|-r '\\indexentry$2' allabout|
+% \end{quote}
+%
+% If you want \Program{splitindex} to call \Program{makeindex} with the
+% additional option ``\verb|-s foo.ist|'' to make it use the MakeIndex style
+% file \File{foo.ist}, you can do so as follows:
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl allabout -- -s foo.ist|
+% \end{quote}
+% As you can see ``\verb|--|'' is used to prevent \Program{splitindex} from
+% interpreting ``\verb|-s foo.ist|'' as option ``\verb|--suffixis foo.ist|''.
+% All \Program{splitindex} options must be put before ``\verb|--|'', but you
+% can put the raw file argument ``\verb|allabout|'' after that:
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl -- allabout -s foo.ist|
+% \end{quote}
+%
+% If you want so use the index processor \Program{xindy} instead of default
+% index processor \Program{MakeIndex}, you can use this call:
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl -m xindy allabout|
+% \end{quote}
+% If \Program{xindy} is not in your standard \texttt{PATH}, you may set the
+% whole path:
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl -m /home/me/bin/xindy allabout|
+% \end{quote}
+% With most perl implementations, the perl module \verb|Getopt::Long| allows to
+% put options after no-option-arguments. So you may also write:
+% \begin{quote}
+% \Prompt{}\verb|splitindex.pl allabout -m /home/me/bin/xindy|
+% \end{quote}
+% with the same result.
+%
+%
+% \subsection{Using \Program{splitindex.jar}}
+% \label{Java}
+%
+% This implementation should also be portable. If you are not using Sun
+% Java~1.4.1 or higher, you may try to recompile this using the shell command:
+% \begin{quote}
+% \Prompt{}\verb|javac splitindex.java|
+% \end{quote}
+% This should result in a new \File{splitindex.class}. But it will fail
+% e.g. with Sun Java 1.3, because regular expressions are needed, which are
+% not available in Sun Java 1.3.
+%
+% The call of \Program{splitindex.class} is almost the same as shown for
+% \autoref{perl} for \Program{splitindex.pl}, but you have to replace
+% ``\verb|splitindex.pl|'' by ``\verb|java splitindex|''. So the last example
+% from \autoref{perl} becomes:
+% \begin{quote}
+% \Prompt{}\verb|java splitindex allabout -m /home/me/bin/xindy|
+% \end{quote}
+%
+%
+% \subsection{Using \Program{splitindex.tex}}
+% \label{TeX}
+%
+% The \TeX{} or \LaTeX{} program \Program{splitindex.tex} doesn't know any
+% options or arguments. The number of files that it can generate is limited
+% to to number of \TeX's free write handles. If there are any other lines than
+% ``\verb|\indexentry|''-lines in the raw index file, running
+% \Program{splitindex.tex} will result in an error.
+%
+% You may use \Program{splitindex.tex} interactively:
+% \begin{quote}
+% \Prompt{}\verb|tex splitindex|
+% \end{quote}
+% or
+% \begin{quote}
+% \Prompt{}\verb|latex splitindex|
+% \end{quote}
+% If you do so, you will be asked for the name of the raw index file. You have
+% to omit the extension ``\File{.idx}'' answering that question.
+%
+% You may also use the \Program{splitindex.tex} not interactively, e.g. if you
+% are working with a batch. To do so you have to define macro \cs{IDX} to the
+% name of the raw index file without the extension ``\texttt{.idx}''. So the
+% first example of \autoref{perl} would become:
+% \begin{quote}
+% \Prompt{}\verb|tex \def\IDX{allabout}\input splitindex|
+% \end{quote}
+% You may also use \LaTeX{} instead of \TeX:
+% \begin{quote}
+% \Prompt{}\verb|latex \def\IDX{allabout}\input splitindex|
+% \end{quote}
+%
+% The current version of \Program{splitindex.tex} doesn't call any index
+% processor. But maybe a future version will be able to do so.
+%
+% \StopEventually{^^A
+% \begin{thebibliography}{99}
+% \bibitem{makeindex} \textsc{Leslie Lamport}: \textit{MakeIndex: An Index
+% Processor For \LaTeX}, 17 February 1987
+% \bibitem{makeindexmanual} \textsc{Pehong Chen}, \textsc{Rick P. C. Rodgers}:
+% \textit{MAKEINDEX(1L)}, Manual page, 10 December 1991
+% \end{thebibliography}
+% \PrintIndex\PrintChanges}
+%
+%
+% \subsection{Merging Indices}
+%
+% Now you should know how to use package \Package{splitidx} and the
+% \Program{SplitIndex} programs to split the index. But what about combining
+% two or more indices to one, e.g. you want vegetables and fruits in the
+% same index? Try this:
+% \begin{flushleft}\ttfamily
+% \cs{documentclass}\{article\} \percentchar \textit{ We use \Class{article}
+% class \dots}\\
+% \cs{usepackage}\{splitidx\} \percentchar \textit{ \dots\ and the
+% \Package{splitidx} package}\\
+% \cs{makeindex} \percentchar \textit{ And we want index generation}\\
+% ~\\
+% \percentchar \textit{ We define 4 indices:}\\
+% \cs{newindex}[General Index]\{idx\} \percentchar \textit{ Name and shortcut
+% of the 1st index}\\
+% \cs{newindex}[Index of Animals]\{ani\} \percentchar \textit{ \dots\ 2nd
+% index}\\
+% \cs{newindex}[Index of Fruits And Vegetables]\{fru\} \percentchar
+% \textit{ \dots\ 3rd
+% index}\\
+% ~\\
+% \cs{begin}\{document\}\\
+% Apples\cs{sindex}[fru]\{apple\} \percentchar \textit{ an entry to
+% }fru\texttt{ index}\\
+% and oranges\cs{sindex}[fru]\{orange\} \percentchar \textit{ an entry to
+% }fru\texttt{ index}\\
+% are fruits\cs{sindex}\{fruits\}.\ \percentchar \textit{ an implicit entry
+% to }idx\textit{ index}\\
+% Tomatoes\cs{sindex}[veg]\{tomato\} \percentchar \textit{ an entry to
+% }veg\textit{ index}\\
+% are\\
+% vegetables\cs{index}\{vegetables\}.\ \percentchar \textit{ an implicit
+% entry to }idx\textit{ index}\\
+% Cats\cs{sindex}[ani]\{cat\} \percentchar \textit{ an entry to
+% }ani\textit{ index}\\
+% are animals\cs{sindex}[idx]\{animals\}.\ \percentchar \textit{ an explicite
+% entry to }idx\textit{ index}\\
+% ~\\
+% \cs{printindex*} \percentchar \textit{ print all indices}\\
+% \cs{end}\{document\}
+% \end{flushleft}
+% And do the following call after splitting the index using
+% \Program{SplitIndex}:
+% \begin{quote}\raggedright
+% \Prompt{}\verb|makeindex allabout-veg.idx allabout-fru.idx|\\
+% \end{quote}
+% Alternatively you can concatenate \File{allabout-fru.idx} to
+% \File{allabout-veg.idx} before running the index processor on
+% \File{allabout-veg.idx}.
+%
+%
+%
+% \section{Implementation of \Package{splitidx}}
+%
+% \begin{macrocode}
+%<*package>
+% \end{macrocode}
+%
+% \subsection{Options}
+%
+% The first option is used to activate index generation.
+% \begin{macrocode}
+\DeclareOption{makeindex}{\AtEndOfPackage{\makeindex}}
+% \end{macrocode}
+%
+% \changes{v0.9}{2006/05/07}{new option \texttt{useindex}}
+% With option \texttt{useindex} the original command \cs{index} behaves like
+% \cs{sindex}.
+% \begin{macrocode}
+\DeclareOption{useindex}{%
+ \def\@se@nd@xc@d@{\let\index\sindex}%
+ \AtEndOfPackage{\@se@nd@xc@d@}%
+}
+\let\@se@nd@xc@d@\relax
+% \end{macrocode}
+%
+% There is also an option to make \cs{sindex} ignores the optional argument
+% and behaves like \cs{index}.%^^A
+% \changes{v1.2}{2013/04/04}{new option `allintoone'}%^^A
+% \changes{v1.2}{2013/04/04}{option `allatone' deprecated}%^^A
+% \begin{macrocode}
+\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}}%
+ }%
+}
+% \end{macrocode}
+%
+% \changes{v0.9}{2006/05/07}{new option \texttt{protected}}
+% Do not expand index arguments.
+% \begin{macrocode}
+\newif\if@verbindex\@verbindexfalse
+\DeclareOption{protected}{\@verbindextrue}
+% \end{macrocode}
+%
+% \changes{v0.2}{2002/11/15}{new option \texttt{idxcommands}}
+% With option \texttt{idxcommands} every \cs{newindex} also defines a new index
+% command.
+% \begin{macrocode}
+\newif\if@newidxcmd\@newidxcmdfalse
+\DeclareOption{idxcommands}{\@newidxcmdtrue}
+% \end{macrocode}
+%
+% \changes{v0.2}{2002/11/15}{new option \texttt{split}}
+% With option \texttt{split} each index uses its own index file.
+% \begin{macrocode}
+\newif\if@splitidx\@splitidxfalse
+\DeclareOption{split}{\@splitidxtrue}
+% \end{macrocode}
+%
+% Processing the options
+% \begin{macrocode}
+\ProcessOptions\relax
+% \end{macrocode}
+%
+%
+% \subsection{Setting an Index Entry}
+%
+% \begin{macro}{\see}
+% \begin{macro}{\seealso}
+% \begin{macro}{\seename}
+% \begin{macro}{\alsoname}
+% These are four standard macros, which are also defined at
+% \Package{makeidx}. Hey, these definitions are stolen from \Package{makeidx}!
+% No, no, I'm not a bad guy, read ``\File{legal.txt}'', which comes with
+% \Package{makeidx}.
+% \begin{macrocode}
+\newcommand*\see[2]{\emph{\seename} #1}
+\providecommand*\seealso[2]{\emph{\alsoname} #1}
+\providecommand\seename{see}
+\providecommand*\alsoname{see also}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\sindex}
+% \begin{macro}{\@wrsindex}
+% \changes{v0.9}{2006/03/07}{optionally do not expand the index argument}
+% \begin{macro}{\@@wrsindex}
+% This works similar to original \cs{index} but uses a splitted index. So it
+% allows an optional argument.
+% \begin{macrocode}
+\newcommand*{\sindex}[2][]{%
+}
+\g@addto@macro\makeindex{%
+ \renewcommand*{\sindex}{%
+ \@bsphack\begingroup
+ \@sanitize
+ \@wrsindex
+ }%
+ \typeout{Using splitted index at \jobname.idx}%
+ \@se@nd@xc@d@
+}
+% \end{macrocode}
+% At the following \cs{@@wrsindex} is used as a hook. If it is defines, it is
+% used to write out the index entry. This hook may be used from
+% e.g. \Package{hyperref} to add \verb|hyperpage| to the font selection of the
+% page number. This only works with \verb+encap |+.
+% \changes{v1.0}{2006/07/30}{one level expansion of \cs{\@tempa} for
+% hyperref hook}
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% If \Package{hyperref} was loaded at \cs{begin\{document\}} and
+% \Package{hyperref}-option \texttt{hyperindex} isn't disabled, and the hook
+% is not used, define it:
+% \changes{v1.2b}{2014/04/08}{\cs{ifHy@hyperindex} test changed}
+% \begin{macrocode}
+\AtBeginDocument{%
+ \begingroup\expandafter\expandafter\expandafter\endgroup
+ \expandafter\ifx\csname ifHy@hyperindex\endcsname\relax
+ \else
+ \expandafter\ifx\csname ifHy@hyperindex\expandafter\endcsname
+ \csname iftrue\endcsname
+ \@ifundefined{@@wrsindex}{%
+ \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
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\AtWriteToIndex}
+% \changes{v1.1}{2009/02/26}{New}
+% Add commands to the write hook.
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+% \begin{macro}{\AtNextWriteToIndex}
+% \changes{v1.1}{2009/02/26}{New}
+% Like \cs{AtWriteToIndex} only once.
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \subsection{Printing One Or More Indices}
+%
+% \begin{macro}{\printindex}
+% \begin{macro}{\printindex*}
+% This is used to print an index in the normal way. In most cases this uses
+% |theindex| environment, but it need not.
+% \begin{macrocode}
+\newcommand*{\printindex}{%
+% \end{macrocode}
+% The command may be called in the star version, which prints all defined
+% indices. This is same as \cs{printindices}.
+% \begin{macrocode}
+ \@ifstar {%
+ \begingroup
+ \let\printindex@@endhook=\printindex@endhook
+ \let\printindex@endhook=\relax
+ \printindices%
+ \csname printindex@@endhook\endcsname
+ \endgroup
+ }{%
+% \end{macrocode}
+% It may also be called with optional arguments to print one of the indices:
+% \begin{macrocode}
+ \@ifnextchar [\@printindex%] brace check comment
+% \end{macrocode}
+% Or it is called without any parameter and so it is same as at
+% \Package{makeidx} package:
+% \begin{macrocode}
+ {%
+ \@input@{\jobname.ind}%
+ \csname printindex@endhook\endcsname
+ }%
+ }%
+}
+% \end{macrocode}
+% \begin{macro}{\@printindex}
+% This is used to print one of the indices. The optional (here obligatory)
+% argument is the shortcut of the index.
+% \begin{macrocode}
+\newcommand*{\@printindex}{}
+\def\@printindex[#1]{%
+% \end{macrocode}
+% There can be one more optional argument, which is the title of the index. If
+% not, the default title \cs{index@\meta{shortcut}@name} is used.
+% \begin{macrocode}
+ \@ifnextchar [%
+ {\@@printindex[{#1}]}%
+ {\@@printindex[{#1}][\csname index@#1@name\endcsname]}%
+}
+% \end{macrocode}
+% \begin{macro}{\@@pintindex}
+% \changes{v0.2}{2002/11/15}{with option \texttt{split} general index has no
+% suffix}
+% We use the default environment to print one of the indices, but we redefine
+% \cs{indexname} to the title of the wanted index, \cs{indexshortcut} to the
+% shortcut of the wanted index and \cs{index@preamble} to the preamble of the
+% wanted index. We do this in a group so it is local.
+% \begin{macrocode}
+\newcommand*{\@@printindex}{}
+\def\@@printindex[#1][#2]{%
+ \begingroup
+ \edef\indexshortcut{#1}%
+ \def\indexname{#2}%
+% \end{macrocode}
+% \changes{v1.2c}{2016/02/18}{workaround for \Package{tcolorbox} library
+% \File{documentation}}^^A
+% The \Package{tcolorbox} library \File{documentation} uses
+% \cs{kvtcb@text@index} instead of \cs{indexname}. So we also redefine this
+% command.
+% \begin{macrocode}
+ \def\kvtcb@text@index{#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
+}
+% \end{macrocode}
+% \begin{macro}{\@indexsuffix}
+% This generated the suffix from the shortcut. You may redefine this
+% function, if you need. I`m using a trick here, to define the macro with
+% proper catcodes but not to define it global. You may also use
+% \cs{@firstofone} instead of \cs{lowercase}.
+% \begin{macrocode}
+\begingroup
+\catcode`\-12
+\lowercase{\endgroup
+ \newcommand*{\@indexsuffix}[1]{-#1}%
+}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\printindices}
+% This is used to print all defined indices in the order of their definition
+% and with their default titles. If the list is empty, is behaves like
+% \cs{printindex} without star and optional arguments.
+% \begin{macrocode}
+\newcommand*{\printindices}{%
+ \ifx\@indices\@empty
+ \printindex
+ \else
+ \begingroup
+ \@for\@tempa:=\@indices\do{%
+ \expandafter\printindex\expandafter[\@tempa]%
+ }%
+ \endgroup
+ \fi
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newindex}
+% \changes{v0.2}{2002/11/15}{optional definition of index-shortcut-command}
+% \changes{v0.2}{2002/11/15}{optional opening a new index file}
+% The definition of a new index has an obligatory argument, the shortcut for
+% this index, and an optional argument, the name of this index. If you omit
+% the optional argument the shortcut is used for the default name if the
+% index. The definition will be done global!
+% \begin{macrocode}
+\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
+ }{%
+% \end{macrocode}
+% If the index is already defined, an error occurs:
+% \begin{macrocode}
+ \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
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\newprotectedindex}
+% \changes{v0.9}{2006/07/03}{new command}
+% Same like \cs{newindex} but always define an index with protected arguments.
+% \begin{macrocode}
+\newcommand*{\newprotectedindex}[2][\relax]{%
+ \begingroup\@verbindextrue\newindex[{#1}]{#2}\endgroup
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@indices}
+% This macro stores a list of the index shortcuts. This is needed by
+% e.g. \cs{printindices} and build by \cs{newindex}.
+% \begin{macrocode}
+\newcommand*{\@indices}{}
+\gdef\@indices{}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\extendtheindex}
+% Extend \verb|theindex| by some macros called before starting the index,
+% after starting the index, before stopping the index and after stopping the
+% index. This may be used to change index behaviour. One additional change is
+% done, which may be useful: before the index \cs{index@preamble} is set to
+% \cs{index@\meta{shortcut}@preamble}.
+% \begin{macrocode}
+\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%
+ }%
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\setindexpreamble}
+% Set one of the splitted index preambles or the original one.
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\useindexpreamble}
+% Use the index preamble and optional add additional information after it, if
+% it exists and if it is not empty:
+% \begin{macrocode}
+\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
+}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\printsubindex}
+% \begin{macro}{\printsubindex*}
+% Works like \cs{printindex} but changes some macros before to level down the
+% headings at the index generation.
+% \begin{macrocode}
+\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
+% \end{macrocode}
+% Also, \cs{onecolumn} and \cs{twocolumn} and even \cs{clearpage} must be
+% disabled. The macros \cs{onecolumn} and \cs{twocolumn} cannot be let
+% \cs{relax} because the have an optional argument which must be used.
+% \begin{macrocode}
+ \let\onecolumn\@firstoptofone
+ \let\twocolumn\@firstoptofone
+ \let\clearpage\relax
+ \let\cleardoublepage\relax
+% \end{macrocode}
+% And the mark mechanism must also use one down:
+% \begin{macrocode}
+ \def\markboth{\expandafter\markright\@gobble}%
+ \ifx\@mkboth\@gobble\else\let\@mkboth\markboth\fi
+% \end{macrocode}
+% And the page style shouldn't change too:
+% \begin{macrocode}
+ \let\thispagestyle\@gobble
+% \end{macrocode}
+% Now, using \cs{printindex} enables all of it's features:
+% \begin{macrocode}
+ \let\printindex@endhook=\endgroup
+ \printindex
+}
+% \end{macrocode}
+% \begin{macro}{\@firstoptofone}
+% Read the optional argument and do it.
+% \begin{macrocode}
+\providecommand{\@firstoptofone}[1][]{#1}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macrocode}
+%</package>
+% \end{macrocode}
+%
+% \Finale
+%
+\endinput
+%
+% end of file `splitindex.dtx'
+%%% Local Variables:
+%%% mode: doctex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/splitindex/splitidx.ins b/macros/latex/contrib/splitindex/splitidx.ins
new file mode 100644
index 0000000000..c6554a89d7
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitidx.ins
@@ -0,0 +1,135 @@
+%%
+%% splitidx.ins
+%% Copyright (c) Markus Kohm, 2002-2016
+%%
+%% $Id: splitidx.ins 4 2016-02-18 10:13:32Z mjk $
+%%
+%% This file is part 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.
+%%
+%% In particular, NO PERMISSION is granted to modify the contents of this
+%% file since it contains the legal notices that are placed in the files
+%% it generates.
+%%
+%% 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.
+%%
+%% This file will generate fast loadable files and documentation
+%% driver files from the doc files in this package when run through
+%% LaTeX or TeX.
+%%
+%% --------------- start of docstrip commands ------------------
+%%
+
+\input docstrip
+
+\preamble
+
+This is a generated file.
+
+Copyright (c) Markus Kohm, 2002-2016
+
+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.
+
+\endpreamble
+
+\keepsilent
+\usedir{tex/latex/splitindex}
+
+\generate{\file{splitidx.sty}{\from{splitidx.dtx}{package}}}
+
+\Msg{*************************************************************}
+\Msg{*}
+\Msg{* To finish the installation you have to move `splitidx.sty'}
+\Msg{* files into a directory searched by TeX.}
+\Msg{* Using a TDS compatible TeX distribution, this would be e.g.}
+\Msg{* tex/latex/splitindex of your main or your local or your}
+\Msg{* private texmf path. If you don't know these paths, have}
+\Msg{* a look at your `texmf.cnf' or try:}
+\Msg{* \space\space kpsexpand \string\$TEXMFMAIN}
+\Msg{* \space\space kpsexpand \string\$TEXMFLOCAL}
+\Msg{* \space\space kpsexpand \string\$TEXMFHOME}
+\Msg{* You may also use another folder at your TEXINPUTS path.}
+\Msg{*}
+\Msg{* To produce the documentation run splitidx.dtx files}
+\Msg{* through LaTeX.}
+\Msg{*}
+\Msg{* Happy TeXing}
+\Msg{************************************************************}
+
+\endbatchfile
diff --git a/macros/latex/contrib/splitindex/splitidx.pdf b/macros/latex/contrib/splitindex/splitidx.pdf
new file mode 100644
index 0000000000..2b0ebfaeca
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitidx.pdf
Binary files differ
diff --git a/macros/latex/contrib/splitindex/splitindex.1 b/macros/latex/contrib/splitindex/splitindex.1
new file mode 100644
index 0000000000..ac8988b0cd
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.1
@@ -0,0 +1,64 @@
+.TH SPLITINDEX "1" "April 2013" "splitindex 0.2a" "User Commands"
+.SH NAME
+splitindex \- manual page for splitindex 0.2a
+.SH SYNOPSIS
+.B splitindex.pl
+[\fIOPTION\fR] ... \fIINTERMEDIATE-INDEX-FILE \fR[\fIMAKEINDEX-OPTION\fR] ...
+.PP
+.B splitindex
+[\fIOPTION\fR] ... \fIINTERMEDIATE-INDEX-FILE \fR[\fIMAKEINDEX-OPTION\fR] ...
+.PP
+.B java splitindex
+[\fIOPTION\fR] ... \fIINTERMEDIATE-INDEX-FILE \fR[\fIMAKEINDEX-OPTION\fR] ...
+.PP
+.B tex splitindex
+.SH DESCRIPTION
+splitindex 0.2a
+Copyright (c) 2002 Markus Kohm <kohm@gmx.de>
+.PP
+Split a single intermediate index file into multiple raw index files.
+.PP
+Example: splitindex.pl foo.idx.
+.SH OPTIONS
+.TP
+\fB\-h\fR, \fB\-\-help\fR
+show this help and terminate
+.TP
+\fB\-m\fR, \fB\-\-makeindex\fR PROGNAME
+call PROGNAME instead of default `makeindex'.
+.TP
+\fB\-i\fR, \fB\-\-identify\fR EXPRESSION
+use regular EXPRESSION to match entries
+(see also option \fB\-\-resultis\fR and \fB\-\-suffixis\fR).
+Default is `^(\e\eindexentry)\e[([^]]*)\e](.*)$'.
+.TP
+\fB\-r\fR, \fB\-\-resultis\fR PATTERN
+create line to be written from PATTERN after matching
+lines (see also option \fB\-\-identify\fR).
+Default is `$1$3'.
+.TP
+\fB\-s\fR, \fB\-\-suffixis\fR PATTERN
+create suffix to be used from PATTERN after matching
+lines (see also option \fB\-\-identify\fR).
+Default is `-$2'.
+.TP
+\fB\-v\fR, \fB\-\-verbose\fR
+be more verbose
+(can be used multiple to increase verbosity)
+.TP
+\fB\-\-version\fR
+show version and terminate
+.SH COPYRIGHT
+Copyright \(co 2002 Markus Kohm <kohm@gmx.de>
+.SH "SEE ALSO"
+The full documentation for
+.B splitindex
+is maintained as a LaTeX manual. If the
+.B texdoc
+and
+.B splitindex
+programs are properly installed at your site, the command
+.IP
+.B texdoc splitidx
+.PP
+should give you access to the complete manual.
diff --git a/macros/latex/contrib/splitindex/splitindex.c b/macros/latex/contrib/splitindex/splitindex.c
new file mode 100644
index 0000000000..515799cba9
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.c
@@ -0,0 +1,602 @@
+/*
+ * splitindex.c
+ * Copyright (c) Markus Kohm, 2002
+ *
+ * $Id: splitindex.c 4 2016-02-18 10:13:32Z mjk $
+ *
+ * This file is part 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.
+ *
+ * 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.
+ */
+
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#include <ctype.h>
+#include <errno.h>
+#include <regex.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+enum {
+ OPT_HELP = 'h', OPT_MAKEINDEX = 'm', OPT_IDENTIFY = 'i',
+ OPT_RESULTIS = 'r', OPT_VERBOSE = 'v', OPT_SUFFIXIS = 's',
+ OPT_VERSION = 'V'
+};
+
+#if defined(__OpenBSD__) || defined(__FreeBSD__) || defined (NO_LONGOPT)
+
+#define HAS_LONGOPT 0
+#define HAPAR ""
+
+#else /* defined(__OpenBSD__) || defined(__FreeBSD__) || defined(NO_LONGOPT) */
+
+#define HAS_LONGOPT 1
+#define HAPAR "\n\t\t"
+
+#include <getopt.h>
+
+static const struct option long_options[] = {
+ { "help", 0, NULL, OPT_HELP },
+ { "makeindex", 1, NULL, OPT_MAKEINDEX },
+ { "identify", 1, NULL, OPT_IDENTIFY },
+ { "resultis", 1, NULL, OPT_RESULTIS },
+ { "suffixis", 1, NULL, OPT_SUFFIXIS },
+ { "verbose", 0, NULL, OPT_VERBOSE },
+ { "version", 0, NULL, OPT_VERSION },
+ { NULL, 0, NULL, 0 },
+};
+
+#endif
+
+static const char short_options[] = {
+ OPT_HELP,
+ OPT_MAKEINDEX, ':',
+ OPT_IDENTIFY, ':',
+ OPT_RESULTIS, ':',
+ OPT_SUFFIXIS, ':',
+ OPT_VERBOSE,
+ OPT_VERSION,
+};
+
+int Verbose = 0;
+
+char *MakeIndex = "makeindex";
+char *Identify = "^(\\\\indexentry)\\[([^]]*)\\](.*)$";
+char *ResultIs = "$1$3";
+char *SuffixIs = "-$2";
+char *IDX = NULL;
+char *Jobname = NULL;
+char * const * MakeIndexArgs = NULL;
+char *prgname = "splitindex";
+int MakeIndexArgc = 0;
+
+static void show_version( void ) {
+ printf( "splitindex 0.2a\n"
+ "Copyright (c) 2002 Markus Kohm <kohm@gmx.de>\n" );
+}
+
+static void show_usage( FILE *out ) {
+ fputs( "Usage: splitindex [OPTION]... RAWINDEXFILE [MAKEINDEXOPTION]...\n",
+ out );
+}
+
+static void usage_error( const char *format, ... ) {
+ if ( format != NULL ) {
+ va_list ap;
+ va_start( ap, format );
+ vfprintf( stderr, format, ap );
+ va_end( ap );
+ }
+ fputs( "Try `splitindex "
+#if HAS_LONGOPT
+ "--help"
+#else
+ "-h"
+#endif
+ "' for more information.\n", stderr );
+ exit( 1 );
+}
+
+static void show_help( void ) {
+ show_version();
+ printf( "\n" );
+ show_usage( stdout );
+ printf(
+ "Split a single raw index file into multiple raw index files.\n"
+ "Example: splitindex.pl foo.idx.\n"
+ "\n"
+ "Options:\n"
+ " -h"
+#if HAS_LONGOPT
+ ", --help "
+#else
+ " "
+#endif
+ "\tshow this help and terminate\n"
+ " -m"
+#if HAS_LONGOPT
+ ", --makeindex"
+#endif
+ " PROGNAME " HAPAR
+ "\tcall PROGNAME instead of default `%s'.\n",
+ MakeIndex
+ );
+ printf(
+ " -i"
+#if HAS_LONGOPT
+ ", --identify"
+#endif
+ " EXPRESSION " HAPAR
+ "\tuse regular EXPRESSION to match entries\n"
+ "\t\t\t(see also option --resultis and --suffixis).\n"
+ "\t\t\tDefault is `%s'.\n",
+ Identify
+ );
+ printf(
+ " -r"
+#if HAS_LONGOPT
+ ", --resultis"
+#endif
+ " PATTERN " HAPAR
+ "\tcreate line to be written from PATTERN after matching\n"
+ "\t\t\tlines (see also option --identify).\n"
+ "\t\t\tDefault is `%s'.\n",
+ ResultIs
+ );
+ printf(
+ " -s"
+#if HAS_LONGOPT
+ ", --suffixis"
+#endif
+ " PATTERN " HAPAR
+ "\tcreate suffix to be used from PATTERN after matching\n"
+ "\t\t\tlines (see also option --identify).\n"
+ "\t\t\tDefault is `%s'.\n",
+ SuffixIs
+ );
+ printf(
+ " -v"
+#if HAS_LONGOPT
+ ", --verbose "
+#else
+ " "
+#endif
+ "\tbe more verbose\n"
+ "\t\t\t(can be used multiple to increase verbosity)\n"
+ " -V"
+#if HAS_LONGOPT
+ ", --version "
+#else
+ " "
+#endif
+ "\tshow version and terminate\n"
+ );
+ exit(0);
+}
+
+static void ScanArguments( int argc, char * const argv[] ) {
+ int retVal;
+ char *hs;
+ if ( argc > 0 )
+ prgname = argv[0];
+#if HAS_LONGOPT
+ while ( ( retVal = getopt_long( argc, argv, short_options,
+ long_options, NULL ) ) != - 1 ) {
+#else
+ while ( ( retVal = getopt( argc, argv, short_options ) ) != - 1 ) {
+#endif
+ switch( retVal ) {
+ case OPT_HELP:
+ show_help();
+ break; /* should never be reached */
+ case OPT_VERSION:
+ show_version();
+ exit( 0 );
+ break; /* should never be reached */
+ case OPT_MAKEINDEX:
+ MakeIndex = optarg;
+ break;
+ case OPT_IDENTIFY:
+ Identify = optarg;
+ break;
+ case OPT_RESULTIS:
+ ResultIs = optarg;
+ break;
+ case OPT_SUFFIXIS:
+ SuffixIs = optarg;
+ break;
+ case OPT_VERBOSE:
+ Verbose++;
+ break;
+ case ':':
+ case '?':
+ usage_error( NULL );
+ break; /* should never be reached */
+ }
+ }
+ if ( optind < argc ) {
+ IDX = argv[optind++];
+ MakeIndexArgc = argc - optind;
+ MakeIndexArgs = argv + optind;
+ } else {
+ usage_error( "missing raw index file\n" );
+ return; /* should never be reached */
+ }
+
+ if ( ( Jobname = strdup( IDX ) ) == NULL ) {
+ perror( prgname );
+ exit( errno );
+ }
+
+ if ( ( ( hs = strrchr( Jobname, '.' ) ) != NULL )
+ && !strcmp( hs, ".idx" ) )
+ *hs = 0;
+}
+
+static char *regsub( const char *string, const char *replace,
+ int nmatch, regmatch_t pmatch[] ) {
+ int pass;
+ int size, n;
+ const char *hs;
+ char c;
+ char *retVal = NULL;
+ char *ts;
+
+ /* Two times parsing to get size and replace */
+ for ( pass = size = 0; pass < 2; pass++ ) {
+ ts = retVal;
+ for ( hs = replace; *hs; hs++ ) {
+ switch( *hs ) {
+ case '$':
+ if ( isdigit( hs[1] ) ) {
+ n = *++hs - '0';
+ if ( ( pmatch[n].rm_so >= 0 )
+ && ( pmatch[n].rm_so < pmatch[n].rm_eo ) ) {
+ /* maybe group n is not empty */
+ if ( pass ) {
+ strncpy( ts,
+ string + pmatch[n].rm_so,
+ pmatch[n].rm_eo - pmatch[n].rm_so );
+ ts += pmatch[n].rm_eo - pmatch[n].rm_so;
+ } else {
+ size += pmatch[n].rm_eo - pmatch[n].rm_so;
+ }
+ }
+ } else {
+ if ( pass ) {
+ *ts++ = '$';
+ } else {
+ size++;
+ }
+ }
+ break;
+ case '\\':
+ switch( c = *++hs ) {
+ case 0: c = '\\'; hs--; break;
+ case 'b': c = '\b'; break;
+ case 'f': c = '\f'; break;
+ case 'n': c = '\n'; break;
+ case 'r': c = '\r'; break;
+ case 't': c = '\t'; break;
+ }
+ if ( pass ) {
+ *ts++ = c;
+ } else {
+ size++;
+ }
+ break;
+ default:
+ if ( pass ) {
+ *ts++ = *hs;
+ } else {
+ size++;
+ }
+ break;
+ }
+ }
+ if ( pass ) {
+ *ts = '\0';
+ } else {
+ if ( ( retVal = malloc( size + 1 ) ) == NULL ) {
+ perror( prgname );
+ exit( 1 );
+ }
+ }
+ }
+
+ return retVal;
+}
+
+static struct list {
+ struct list *next;
+ char *name;
+ FILE *file;
+} *IDXfiles = NULL;
+
+static FILE *findsuffix( const char *name ) {
+ struct list *run;
+ for ( run = IDXfiles;
+ run != NULL;
+ run = run->next ) {
+ const char *suffix = strchr( run->name, '\0' );
+ suffix -= 4; /* .idx */
+ suffix -= strlen( name );
+ if ( ( suffix >= run->name )
+ && !strncmp( suffix, name, strlen( name ) ) ) {
+ return run->file;
+ }
+ }
+ return NULL;
+}
+
+static struct list *addentry( char *name, FILE *file ) {
+ struct list *newentry = malloc( sizeof( struct list ) );
+ if ( !newentry ) {
+ perror( prgname );
+ exit( 1 );
+ }
+ newentry->name = name;
+ newentry->file = file;
+ if ( IDXfiles == NULL ) {
+ newentry->next = NULL;
+ } else {
+ newentry->next = IDXfiles;
+ }
+ IDXfiles = newentry;
+ return IDXfiles;
+}
+
+static FILE *newentry( const char *suffix ) {
+ char *name;
+ FILE *file;
+
+ if ( ( name = malloc( strlen( Jobname ) + strlen( suffix ) + 5 ) ) == NULL ) {
+ perror( prgname );
+ exit( 1 );
+ }
+
+ strcpy( name, Jobname );
+ strcat( name, suffix );
+ strcat( name, ".idx" );
+
+ if ( ( file = fopen( name, "w" ) ) == NULL ) {
+ perror( name );
+ exit( errno );
+ }
+
+ if ( Verbose > 1 )
+ printf( "New index file %s\n", name );
+ addentry( name, file );
+ return file;
+}
+
+static void CloseAllIDX( void ) {
+ struct list *run;
+ for ( run = IDXfiles; run != NULL; run = run->next )
+ if ( fclose( run->file ) ) {
+ perror( run->name );
+ exit( 1 );
+ }
+}
+
+static void CallMakeIndex( void ) {
+ char **argv;
+ int idx;
+ struct list *run, *next;
+
+ if ( ( argv = calloc( MakeIndexArgc + 3, sizeof( char * ) ) ) == NULL ) {
+ perror( prgname );
+ exit( 0 );
+ }
+
+ for ( idx = 0; idx < MakeIndexArgc; idx++ )
+ argv[idx+1] = MakeIndexArgs[idx];
+
+ idx++;
+ argv[0] = MakeIndex;
+
+ for ( run = IDXfiles; run != NULL; run = next ) {
+ pid_t fret;
+ int status;
+ argv[idx] = run->name;
+
+ if ( ( fret = fork() ) == 0 ) {
+ /* This is the child */
+ if ( Verbose > 1 ) {
+ int i;
+ for ( i = 0; argv[i] != NULL; i++ )
+ printf( "\"%s\" ", argv[i] );
+ printf( "\n" );
+ }
+ if ( execvp( MakeIndex, argv ) ) {
+ perror( MakeIndex );
+ exit( 1 );
+ }
+ } else if ( fret == -1 ) {
+ perror( prgname );
+ exit( 1 );
+ } else {
+ /* Parent */
+ waitpid( fret, &status, 0 );
+ if ( ! WIFEXITED( status ) ) {
+ fprintf( stderr, "%s terminated abnormally!\n", MakeIndex );
+ exit( 1 );
+ }
+ }
+
+ free( (void *)run->name );
+ next = run->next;
+ free( run );
+ }
+
+
+}
+
+static void ProcessIDXFile( void ) {
+ FILE *fIDX;
+ char *line;
+ regex_t preg;
+ int retVal;
+ int buffersize = 2050;
+ regmatch_t pmatch[10];
+
+ if ( ( line = malloc( buffersize ) ) == NULL ) {
+ perror( prgname );
+ exit( errno );
+ }
+
+ if ( ( retVal = regcomp( &preg, Identify, REG_EXTENDED ) ) != 0 ) {
+ regerror( retVal, &preg, line, buffersize );
+ fprintf( stderr, "Error at identify: %s\n", line );
+ free( line );
+ exit( 1 );
+ }
+
+ if ( ( fIDX = fopen( IDX, "r" ) ) == NULL ) {
+ if ( !strcmp ( IDX, Jobname ) ) {
+ if ( ( IDX = malloc( strlen( Jobname + 5 ) ) ) == NULL ) {
+ perror( prgname );
+ regfree( &preg );
+ free( line );
+ exit( errno );
+ }
+ strcpy( IDX, Jobname );
+ strcat( IDX, ".idx" );
+ if ( ( fIDX = fopen( IDX, "r" ) ) == NULL ) {
+ fprintf( stderr,
+ "Can read neither file %s nor file %s\n",
+ Jobname, IDX );
+ regfree( &preg );
+ free( line );
+ exit( 1 );
+ }
+ } else {
+ fprintf( stderr,
+ "Can't red file %s\n", IDX );
+ regfree( &preg );
+ free( line );
+ exit( 1 );
+ }
+ }
+
+ while ( fgets( line, buffersize, fIDX ) != NULL ) {
+ char *hs;
+ char *result, *suffix;
+ FILE *f;
+ while ( ( ( hs = strchr( line, '\n' ) ) == NULL )
+ && ! feof( fIDX ) ) {
+ if ( ( line = realloc( line, 2 * buffersize ) ) == NULL ) {
+ perror( prgname );
+ exit( errno );
+ }
+ if ( fgets( line + buffersize - 1, buffersize + 1, fIDX ) == NULL )
+ break;
+ buffersize *= 2;
+ }
+ if ( ferror( fIDX ) )
+ break;
+ if ( ( hs = strchr( line, '\n' ) ) != NULL ) // remove newline
+ *hs = 0;
+ if ( ( retVal = regexec( &preg, line, 10, pmatch, 0 ) ) == 0 ) {
+ result = regsub( line, ResultIs, 10, pmatch );
+ suffix = regsub( line, SuffixIs, 10, pmatch );
+ } else {
+ int i;
+ result = strdup( line );
+ for ( i = 0; i < 10; i++ ) {
+ pmatch[i].rm_so = 0;
+ pmatch[i].rm_eo = 3;
+ }
+ suffix = regsub( "idx", SuffixIs, 10, pmatch );
+ }
+ if ( !result || !suffix ) {
+ perror( prgname );
+ exit ( 1 );
+ }
+
+ if ( ( f = findsuffix( suffix ) ) == NULL )
+ f = newentry( suffix );
+ fprintf( f, "%s\n", result );
+
+ free( suffix );
+ free( result );
+ }
+
+ regfree( &preg );
+ free( line );
+ if ( ferror( fIDX ) ) {
+ perror( IDX );
+ fclose( fIDX );
+ exit( errno );
+ }
+ fclose( fIDX );
+
+ CloseAllIDX();
+
+ CallMakeIndex();
+}
+
+int main( int argc, char * const argv[] ) {
+ int retVal = 0;
+
+ ScanArguments( argc, argv );
+
+ if ( Verbose > 0 ) {
+ show_version();
+ if ( Verbose > 9 ) {
+ int i;
+ printf( "Identify: \"%s\"\n", Identify );
+ printf( "ResultIs: \"%s\"\n", ResultIs );
+ printf( "SuffixIs: \"%s\"\n", SuffixIs );
+ printf( "IDX: \"%s\"\n", IDX );
+ printf( "Jobname: \"%s\"\n", Jobname );
+ printf( "MakeIndex: \"%s\"", MakeIndex );
+ for ( i = 0; i < MakeIndexArgc; i++ )
+ printf( " \"%s\"", MakeIndexArgs[i] );
+ printf( "\n" );
+ }
+ }
+
+ ProcessIDXFile();
+
+ return retVal;
+}
diff --git a/macros/latex/contrib/splitindex/splitindex.java b/macros/latex/contrib/splitindex/splitindex.java
new file mode 100644
index 0000000000..c6c6d4bbf1
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.java
@@ -0,0 +1,441 @@
+/*
+ * splitindex.java
+ * Copyright (c) Markus Kohm, 2002-2009
+ *
+ * $Id: splitindex.java 4 2016-02-18 10:13:32Z mjk $
+ *
+ * This file is part 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.
+ *
+ * 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.
+ */
+
+/*
+ I know, I should never write an application in a single static class
+ like I do here. But I wanted the program at each language to be one
+ file.
+*/
+
+import java.util.*;
+import java.util.regex.*;
+import java.io.*;
+
+public final class splitindex {
+ private static ArrayList MakeIndexArgs = new ArrayList();
+// private static String Identify = "^(.*)\\\\UseIndex *\\{([^\\}]*)\\}(.*)$";
+ private static String Identify = "^(\\\\indexentry)\\[([^\\]]*)\\](.*)$";
+ private static String ResultIs = "$1$3";
+ private static String SuffixIs = "-$2";
+ private static int Verbose = 0;
+ private static String IDX = null;
+ private static String Jobname = null;
+ private static HashMap IDXwriters = new HashMap();
+
+ private static void ShowHelp() {
+ String nl = System.getProperty( "line.separator" );
+ ShowVersion();
+ System.out.println();
+ ShowUsage();
+ System.out.println(
+ "Split a single raw index file into multiple raw index files." +nl+
+ "Example: java splitindex foo.idx." +nl+
+ nl+
+ "Options:" +nl+
+ " -h, --help " +
+ "\tshow this help and terminate" +nl+
+ " -m, --makeindex PROGNAME" +nl+
+ "\t\t\tcall PROGNAME instead of default `makeindex'." +nl+
+ " -i, --identify EXPRESSION" +nl+
+ "\t\t\tuse regular EXPRESSION to match entries" +nl+
+ "\t\t\t(see also option --resultis and --suffixis)." +nl+
+ "\t\t\tDefault is \'" + Identify + "\'." +nl+
+ " -r, --resultis PATTERN" +nl+
+ "\t\t\tcreate line to be written from PATTERN after matching" +nl+
+ "\t\t\tlines (see also option --identify)." +nl+
+ "\t\t\tDefault is \'" + ResultIs + "\'." +nl+
+ " -s, --suffixis PATTERN" +nl+
+ "\t\t\tcreate suffix to be used from PATTERN after matching" +nl+
+ "\t\t\tlines (see also option --identify)." +nl+
+ "\t\t\tDefault is \'" + SuffixIs +"\'." +nl+
+ " -v, --verbose " +
+ "\tbe more verbose" +nl+
+ "\t\t\t(can be used multiple to increase verbosity)" +nl+
+ " --version " +
+ "\tshow version and terminate"
+ );
+ System.exit( 0 );
+ }
+
+ private static void ShowVersion() {
+ System.out.println( "splitindex.pl 0.1" );
+ System.out.println( "Copyright (c) 2002 Markus Kohm <kohm@gmx.de>" );
+ }
+
+ private static void ShowUsage( PrintStream out ) {
+ out.println( "Usage: java splitindex [OPTION]... RAWINDEXFILE [MAKEINDEXOPTION]..." );
+ }
+
+ private static void ShowUsage() {
+ ShowUsage( System.out );
+ }
+
+ private static void UsageError( String msg ) {
+ System.err.println( msg );
+ System.err.println( "Try `java splitindex --help' for more information." );
+ System.exit( 1 );
+ }
+
+ private static void ScanArguments(String[] args) {
+ String MakeIndex = "makeindex";
+ for (int i = 0; i < args.length; i++) {
+ if ( args[i].charAt(0) == '-' ) {
+ // Option
+ if ( args[i].charAt(1) == '-' ) {
+ // Long Option
+ if ( args[i].substring(2).equals( "help" ) ) {
+ ShowHelp();
+ System.exit(0);
+ } else if ( args[i].substring(2).equals( "version" ) ) {
+ ShowVersion();
+ System.exit(0);
+ } else if ( args[i].substring(2).equals( "verbose" ) ) {
+ Verbose++;
+ } else if ( args[i].substring(2).equals( "makeindex" ) ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option makeindex requires an argument" );
+ }
+ MakeIndex = args[i];
+ } else if ( ( args[i].length() >= 11 ) &&
+ ( args[i].substring(2,11).equals( "makeindex=" ) ) ) {
+ MakeIndex = args[i].substring(12);
+ } else if ( args[i].substring(2).equals( "identify" ) ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option identify requires an argument" );
+ }
+ Identify = args[i];
+ } else if ( ( args[i].length() >= 10 ) &&
+ ( args[i].substring(2,10).equals( "identify=" ) ) ) {
+ Identify = args[i].substring(11);
+ } else if ( args[i].substring(2).equals( "resultis" ) ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option resultis requires an argument" );
+ }
+ ResultIs = args[i];
+ } else if ( ( args[i].length() >= 10 ) &&
+ ( args[i].substring(2,10).equals( "resultis=" ) ) ) {
+ ResultIs = args[i].substring(11);
+ } else if ( args[i].substring(2).equals( "suffixis" ) ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option suffixis requires an argument" );
+ }
+ SuffixIs = args[i];
+ } else if ( ( args[i].length() >= 10 ) &&
+ ( args[i].substring(2,10).equals( "suffixis=" ) ) ) {
+ SuffixIs = args[i].substring(11);
+ } else if ( args[i].equals( "--" ) ) {
+ while ( ++i < args.length ) {
+ MakeIndexArgs.add( args[i] );
+ }
+ } else {
+ UsageError( "Unknown option " + args[i].substring(2) );
+ }
+ } else {
+ // Short Option
+ for ( int n = 1; n < args[i].length(); ) {
+ switch( args[i].charAt(n++) ) {
+ case 'h':
+ ShowHelp();
+ System.exit(0);
+ case 'm':
+ if ( n >= args[i].length() ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option makeindex requires an argument" );
+ } else {
+ MakeIndex = args[i];
+ n = args[i].length();
+ }
+ } else {
+ MakeIndex = args[i].substring( n );
+ n = args[i].length();
+ }
+ break;
+ case 'i':
+ if ( n >= args[i].length() ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option identify requires an argument" );
+ } else {
+ Identify = args[i];
+ n = args[i].length();
+ }
+ } else {
+ Identify = args[i].substring( n );
+ n = args[i].length();
+ }
+ break;
+ case 'r':
+ if ( n >= args[i].length() ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option resultis requires an argument" );
+ } else {
+ ResultIs = args[i];
+ n = args[i].length();
+ }
+ } else {
+ ResultIs = args[i].substring( n );
+ n = args[i].length();
+ }
+ break;
+ case 's':
+ if ( n >= args[i].length() ) {
+ if ( ++i >= args.length ) {
+ UsageError( "Option suffixis requires an argument" );
+ } else {
+ SuffixIs = args[i];
+ n = args[i].length();
+ }
+ } else {
+ SuffixIs = args[i].substring( n );
+ n = args[i].length();
+ }
+ break;
+ case 'v':
+ Verbose++;
+ break;
+ }
+ }
+ }
+ } else {
+ MakeIndexArgs.add( args[i] );
+ }
+ }
+
+ // Args --> IDX + Stringarray
+ if ( MakeIndexArgs.isEmpty() ) {
+ UsageError( "missing raw index file" );
+ } else {
+ IDX = (String)MakeIndexArgs.get(0);
+ MakeIndexArgs.remove(0);
+ MakeIndexArgs.add( 0, MakeIndex );
+ }
+
+ if ( IDX.endsWith( ".idx" ) ) {
+ Jobname = IDX.substring( 0, IDX.length() - 4 );
+ } else {
+ Jobname = IDX;
+ }
+ }
+
+ public static void main(String[] args) {
+ ScanArguments(args);
+
+ if ( Verbose > 0 ) {
+ ShowVersion();
+ System.out.println();
+ if ( Verbose > 9 ) {
+ System.out.println( "Identify: \"" + Identify + "\"" );
+ System.out.println( "ResultIs: \"" + ResultIs + "\"" );
+ System.out.println( "SuffixIs: \"" + SuffixIs + "\"" );
+ System.out.println( "IDX: \"" + IDX + "\"" );
+ System.out.println( "Jobname: \"" + Jobname + "\"" );
+ System.out.print( "MakeIndex:" );
+ for ( int i = 0; i < MakeIndexArgs.size(); i++ )
+ System.out.print( " \"" + (String)MakeIndexArgs.get(i) + "\"" );
+ System.out.println();
+ }
+ }
+
+ ProcessIDXFile();
+ }
+
+ private static void ProcessIDXFile() {
+ File fIDX = new File( IDX );
+ LineNumberReader rIDX = null;
+ boolean error = false;
+ if ( !fIDX.canRead() ) {
+ if ( IDX.equals( Jobname ) ) {
+ IDX = IDX.concat( ".idx" );
+ fIDX = new File( IDX );
+ if ( !fIDX.canRead() ) {
+ System.err.println( "Can read neither file " + Jobname +
+ " nor file " + IDX );
+ System.exit( 1 );
+ }
+ } else {
+ System.err.println( "Can't read file " + Jobname );
+ System.exit( 1 );
+ }
+ }
+
+ try {
+ FileReader reader = new FileReader( fIDX );
+ rIDX = new LineNumberReader( reader );
+ } catch ( FileNotFoundException ex ) {
+ System.err.println( ex.getMessage() );
+ System.exit( 1 );
+ }
+
+ try {
+ Pattern search = Pattern.compile( Identify );
+ while ( rIDX.ready() ) {
+ String line = rIDX.readLine();
+ Matcher match = search.matcher( line );
+ String suffix, result;
+
+ try {
+ if ( match.find() ) {
+ suffix = match.replaceFirst( SuffixIs );
+ result = match.replaceFirst( ResultIs );
+ } else {
+ result = line;
+ suffix = SuffixIs.replaceFirst( "\\$\\d", "idx" );
+ }
+ WriteToIndex( Jobname + suffix + ".idx", result );
+ } catch ( Exception ex ) {
+ System.err.println( ex.getMessage() );
+ error = true;
+ break;
+ }
+ }
+
+ if ( ! CloseAllIndex() )
+ error = true;
+ else if ( ! CallAllMakeIndex() )
+ error = true;
+ } catch ( IOException ex ) {
+ System.err.println( ex.getMessage() );
+ }
+
+ try {
+ rIDX.close();
+ } catch ( IOException ex ) {
+ System.err.println( ex.getMessage() );
+ System.exit( 1 );
+ }
+
+ if ( error )
+ System.exit( 1 );
+
+ }
+
+ static void WriteToIndex( String Name, String line )
+ throws FileNotFoundException, SecurityException {
+ PrintWriter fOut;
+ if ( ( fOut = (PrintWriter)IDXwriters.get( Name ) ) == null ) {
+ if ( Verbose > 1 ) {
+ System.out.println( "New index file " + Name );
+ }
+ fOut = new PrintWriter( new FileOutputStream( Name ) );
+ IDXwriters.put( Name, fOut );
+ }
+ fOut.println( line );
+ }
+
+ static boolean CloseAllIndex() {
+ Iterator all = IDXwriters.entrySet().iterator();
+ boolean retVal = true;
+ while ( all.hasNext() ) {
+ Map.Entry entry = (Map.Entry)all.next();
+ PrintWriter writer = (PrintWriter)entry.getValue();
+ if ( Verbose > 1 ) {
+ System.out.println( "Close " + entry.getKey() );
+ }
+ writer.close();
+ if ( writer.checkError() ) {
+ System.err.println( "Error writing " + entry.getKey() );
+ retVal = false;
+ }
+ }
+ return retVal;
+ }
+
+ static boolean CallAllMakeIndex() {
+ Iterator all = IDXwriters.entrySet().iterator();
+ boolean retVal = true;
+ ArrayList processes = new ArrayList();
+ while ( all.hasNext() ) {
+ Map.Entry entry = (Map.Entry)all.next();
+ String name = (String)entry.getKey();
+ try {
+ MakeIndexArgs.add(name);
+ String Args[] = new String[MakeIndexArgs.size()];
+ Args = (String[])MakeIndexArgs.toArray( Args );
+ MakeIndexArgs.remove(MakeIndexArgs.size()-1);
+ if ( Verbose > 1 ) {
+ System.out.print( "MakeIndex:" );
+ for ( int i = 0; i < Args.length; i++ )
+ System.out.print( " \"" + Args[i] + "\"" );
+ System.out.println();
+ }
+ processes.add(Runtime.getRuntime().exec( Args ));
+ } catch ( Exception ex ) {
+ System.err.println( ex.getMessage() );
+ retVal = false;
+ }
+ }
+
+ for ( int i = 0; i < processes.size(); i++ ) {
+ Process p = (Process)processes.get( i );
+ InputStream out = p.getInputStream();
+ byte[] buffer = new byte[1024];
+ for ( boolean oncemore = true; oncemore; ) {
+ oncemore = false;
+ try {
+ while ( out.available() > 0 ) {
+ out.read( buffer );
+ System.out.print( new String(buffer) );
+ }
+ for ( out = p.getErrorStream();
+ out.available() > 0; ) {
+ out.read( buffer );
+ System.err.print( new String( buffer ) );
+ }
+ } catch ( Exception ex ) {
+ System.err.println( ex.getMessage() );
+ retVal = false;
+ }
+ try {
+ if ( p.exitValue() != 0 )
+ retVal = false;
+ } catch ( IllegalThreadStateException ex ) {
+ oncemore = true;
+ }
+ }
+ }
+
+ return retVal;
+ }
+}
diff --git a/macros/latex/contrib/splitindex/splitindex.pl b/macros/latex/contrib/splitindex/splitindex.pl
new file mode 100755
index 0000000000..70c61720c9
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.pl
@@ -0,0 +1,212 @@
+#! /usr/bin/perl -w
+eval 'exec perl -S $0 ${1+"$@"}'
+ if 0; #$running_under_some_shell
+
+# ======================================================================
+# splitindex.pl
+# Copyright (c) Markus Kohm, 2002-2009
+#
+# $Id: splitindex.pl,v 1.3 2009-03-20 14:55:11 mjk Exp $
+#
+# This file is part 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.
+#
+# 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.
+# ======================================================================
+
+use strict;
+use Getopt::Long;
+
+my $makeindex = "makeindex";
+# my $identify = "^(.*)\\\\UseIndex *\\{([^\\}]*)\\}(.*)\$";
+my $identify = "^(\\\\indexentry)\\[([^]]*)\\](.*)\$";
+my $suffixis = "-\$2";
+my $lineis = "\$1\$3";
+my $verbose = 0; # option verbose with default value
+my $result = GetOptions(
+ 'help' => sub { help() },
+ 'makeindex=s' => \$makeindex,
+ 'identify=s' => \$identify,
+ 'resultis=s' => \$lineis,
+ 'suffixis=s' => \$suffixis,
+ 'verbose|v+' => \$verbose,
+ 'version' => sub { version(); exit 0; }
+ );
+
+usage("missing raw index file") if ( $#ARGV < 0 );
+
+my $indexinput = shift;
+my $jobname = ( $indexinput =~ /^(.*)\.idx$/ ) ? $1 : $indexinput;
+
+my %idxfile;
+my %linesatidxfile;
+
+version() if ($verbose > 0);
+
+if ( !( open (IDX,"<$indexinput") ) ) {
+ if ( $indexinput ne "$jobname.idx" ) {
+ open (IDX,"<$jobname.idx") ||
+ die "Cannot read raw index file $indexinput nor $jobname.idx";
+ $indexinput = "$jobname.idx";
+ } else {
+ die "Cannot read raw index file $indexinput";
+ }
+}
+
+while (<IDX>) {
+ my $line;
+ my $suffix;
+ if ( /$identify/ ) {
+ my $eval = "\$line = \"$lineis\n\"";
+ eval $eval;
+ $eval = "\$suffix = \"$suffixis\"";
+ eval $eval;
+ } else {
+ $line = $_;
+ $suffix = "";
+ $suffix .= "$1" if ( $suffixis =~ /^(.*)\$/ );
+ $suffix .= "idx";
+ $suffix .= "$1" if ( $suffixis =~ /\$[123456789](.*)$/ );
+ }
+ while ( $suffix =~ /(^[^,]+)(.*)$/ ) {
+ $suffix = $2;
+ writetoidx ($1,$line);
+ }
+}
+
+closeallind();
+
+close(IDX);
+
+generateallind(@ARGV);
+
+exit 0;
+
+sub generateallind {
+ my $name;
+ my $file;
+
+ if ( $makeindex ne "" ) {
+ while (($name,$file) = each %idxfile) {
+ system( "$makeindex @ARGV $jobname$name.idx" );
+ }
+ }
+}
+
+sub closeallind {
+ my $name;
+ my $file;
+ my $lines;
+ while (($name,$file) = each %idxfile) {
+ print "Close $jobname$name.idx\n"
+ if ( $verbose > 1 );
+ close( $file );
+ $idxfile{$name}=0;
+ }
+ if ( $verbose > 0 ) {
+ print "\n";
+ while (($name,$lines) = each %linesatidxfile) {
+ print "$jobname$name.idx with $lines lines\n";
+ }
+ }
+}
+
+sub writetoidx {
+ my $suffix = $_[0];
+ my $line = $_[1];
+ my $file = $idxfile{$suffix};
+ if ( ! $file ) {
+ open ( $file, ">$jobname$suffix.idx" ) ||
+ die "Cannot write to file $jobname$suffix.idx";
+ $idxfile{$suffix} = $file;
+ $linesatidxfile{$suffix} = 0;
+ print( "New index file $jobname$suffix.idx\n" )
+ if ( $verbose > 1 );
+ }
+ print ($file $line);
+ $linesatidxfile{$suffix}++;
+}
+
+sub help {
+ version();
+ print "\n";
+ usage();
+ print
+ "Split a single raw index file into multiple raw index files.\n".
+ "Example: splitindex.pl foo.idx.\n".
+ "\n".
+ "Options:\n" .
+ " -h, --help " .
+ "\tshow this help and terminate\n" .
+ " -m, --makeindex PROGNAME\n" .
+ "\t\t\tcall PROGNAME instead of default \`makeindex\'.\n" .
+ " -i, --identify EXPRESSION\n" .
+ "\t\t\tuse regular EXPRESSION to match entries\n".
+ "\t\t\t(see also option --resultis and --suffixis).\n".
+ "\t\t\tDefault is \'$identify\'.\n".
+ " -r, --resultis PATTERN\n" .
+ "\t\t\tcreate line to be written from PATTERN after matching\n".
+ "\t\t\tlines (see also option --identify).\n".
+ "\t\t\tDefault is \'$lineis\'.\n".
+ " -s, --suffixis PATTERN\n" .
+ "\t\t\tcreate suffix to be used from PATTERN after matching\n".
+ "\t\t\tlines (see also option --identify).\n".
+ "\t\t\tDefault is \'$suffixis\'.\n".
+ " -v, --verbose " .
+ "\tbe more verbose\n".
+ "\t\t\t(can be used multiple to increase verbosity)\n" .
+ " --version " .
+ "\tshow version and terminate\n";
+ exit 0;
+}
+
+sub version {
+ print "splitindex.pl 0.1\n" .
+ "Copyright (c) 2002 Markus Kohm \<kohm\@gmx.de\>\n";
+}
+
+sub usage {
+ my $text = "Usage: splitindex.pl [OPTION]... RAWINDEXFILE [MAKEINDEXOPTION]...\n";
+ if ( $#_ >= 0 ) {
+ print STDERR @_;
+ print STDERR "\n$text";
+ print STDERR "Try \`splitindex.pl --help\' for more information.\n";
+ exit 1;
+ } else {
+ print $text;
+ }
+}
diff --git a/macros/latex/contrib/splitindex/splitindex.tex b/macros/latex/contrib/splitindex/splitindex.tex
new file mode 100644
index 0000000000..3d22e33cfc
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.tex
@@ -0,0 +1,189 @@
+% ======================================================================
+% splitindex.tex
+% Copyright (c) Markus Kohm, 2002-2009
+%
+% $Id: splitindex.tex 4 2016-02-18 10:13:32Z mjk $
+%
+% This file is part 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.
+%
+% 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.
+% ======================================================================
+
+% Set newlinechar
+\newlinechar`\^^J
+
+% Tell program information
+\message{splitindex.tex 0.1^^J%
+ Copyright (c) 2002 Markus Kohm <kohm@gmx.de>^^J^^J}
+
+% Change \catcode of At to be a letter
+\catcode`\@11\relax
+
+% New end processing command (one of these should do the job)
+\def\endprocessing{%
+ \csname @@end\endcsname
+ \csname end\endcsname
+ \csname endinput\endcsname
+}
+
+% Check out, if we are using LaTeX or plainTeX:
+\let\@earlyend\relax
+\def\@tempa{LaTeX2e}
+\expandafter\ifx\csname fmtname\endcsname\@tempa
+\else
+ \def\@tempa{plain}
+ \expandafter\ifx\csname fmtname\endcsname\@tempa
+ \def\newwrite{\alloc@7\write\chardef\sixt@@n}% not longer \outer
+ \chardef\@inputcheck=0\relax
+ \else
+ \message{Unkown format \csname fmtname\endcsname^^J
+ You have to use plainTeX or LaTeX2e to run
+ splitindex.tex!^^J}
+ \let\@earlyend\endprocessing
+ \fi
+\fi
+\@earlyend
+
+% Is \idx defined to the name of the raw index file?
+\expandafter\ifx\csname idx\endcsname\relax
+% no it isn't
+ \message{Enter the name of the idx file to be processed: }%
+ \advance\endlinechar\@M
+ \read\m@ne to\idx
+ \advance\endlinechar-\@M
+\fi
+
+% Sorry to late for log file
+\def\setjobname#1.idx#2\\{\def\jobname{#1}}
+\expandafter\setjobname\idx.idx\\
+
+\let\@earlyend\relax
+\openin\@inputcheck\idx %
+\ifeof\@inputcheck
+ \ifx\jobname\idx
+ \openin\@inputcheck\jobname.idx %
+ \ifeof\@inputcheck
+ \message{Error: Neither file `\idx' nor file `\jobname.idx' found!^^J}%
+ \let\@earlyend\endprocessing
+ \else
+ \xdef\idx{\jobname.idx}%
+ \fi
+ \else
+ \message{Error: File `\idx' not found!^^J}%
+ \let\@earlyend\endprocessing
+ \fi
+\fi
+\@earlyend
+
+\message{Read from file: \idx^^J%
+ Write to files: \jobname-*.idx^^J}
+
+% We are ready to do the processing
+
+% First we have to do the tricky splitting of the input line.
+% We do not allow lines which don't start with \indexentry.
+% We do not support other index file definitions but with an
+% optional argument of \indexentry.
+% We need some catcode changes to read and split the line. So
+% we do this part of the processing at a group.
+\newtoks\verbatim@line
+\begingroup
+\catcode`\^^M\active
+
+\begingroup
+\catcode`\|=0
+\catcode`\\=12
+|gdef|splitidxline\indexentry#1{%
+ |if #1[%
+ |expandafter|@splitidxline%
+ |else%
+ |expandafter |@splitidxline |expandafter i|expandafter d%
+ |expandafter x|expandafter ]|expandafter#1%
+ |fi%
+}
+|endgroup
+
+\gdef\@splitidxline#1]#2^^M{%
+ \idxwrite{#1}{\string\indexentry#2}%
+}
+
+\gdef\processidxline{%\message{\the\verbatim@line}%
+ \expandafter\splitidxline\verbatim@line^^M
+}
+\endgroup
+
+% Now, we can do the main job: writing to the index files
+\def\idxwrite#1#2{%
+ \expandafter\ifx\csname write@#1\endcsname\relax
+ % We need a new file
+ \message{New index file: \jobname-#1.idx^^J}%
+ \expandafter\newwrite\csname write@#1\endcsname
+ \immediate\openout\csname write@#1\endcsname \jobname-#1.idx %
+ % FixMe: Don't close by end TeX run but use \closeout
+ \fi
+ \immediate\write\csname write@#1\endcsname{#2}%
+}
+
+% Read the file verbatim and process the lines
+\newif\ifnoteof
+\newtoks\par@tok\par@tok{\par}
+\def\@makeother#1{\catcode`#112\relax}
+\def\processidxfile{
+ \immediate\openin\@inputcheck \idx %
+ \noteoftrue
+ \loop
+ \ifeof\@inputcheck \noteoffalse\fi
+ \ifnoteof
+ \begingroup
+ \let\do\@makeother\dospecials
+ \immediate\read\@inputcheck to \verbatim@line
+ \if\par@tok\verbatim@line\else
+ \processidxline
+ \fi
+ \endgroup
+ \repeat
+}
+
+\processidxfile
+
+% Trick to end processing in TeX and LaTeX
+\endprocessing
+%%% Local Variables:
+%%% mode: tex
+%%% TeX-master: t
+%%% End:
diff --git a/macros/latex/contrib/splitindex/splitindex.tlu b/macros/latex/contrib/splitindex/splitindex.tlu
new file mode 100755
index 0000000000..1cd6de7e1f
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex.tlu
@@ -0,0 +1,50 @@
+#!/usr/bin/env texlua
+-- splitindex.tlu
+-- Copyright (c) Markus Kohm, 2013
+--
+-- $Id: splitindex.tlu 4 2016-02-18 10:13:32Z mjk $
+--
+-- This file is part 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.
+--
+-- 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.
+
+kpse.set_program_name(arg[-1],'splitindex')
+require('splitindex.splitindex_main')
+
+--
+-- End of file `splitindex.tlu'
diff --git a/macros/latex/contrib/splitindex/splitindex_main.tlu b/macros/latex/contrib/splitindex/splitindex_main.tlu
new file mode 100644
index 0000000000..de12c50efe
--- /dev/null
+++ b/macros/latex/contrib/splitindex/splitindex_main.tlu
@@ -0,0 +1,197 @@
+#!/usr/bin/env texlua
+-- splitindex.tlu
+-- Copyright (c) Markus Kohm, 2013-2014
+--
+-- $Id: splitindex_main.tlu 4 2016-02-18 10:13:32Z mjk $
+--
+-- This file is part 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.
+--
+-- 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.
+
+local version_number = string.sub( '$Revision: 4 $', 12, -2 )
+local action_version = ' r'..version_number..'\n'..[[
+Copyright (c) 2013 Markus Kohm.
+License: lppl 1.3c or later. See <http://www.latex-project.org/lppl.txt>.
+]]
+local action_help = [[
+options:
+ -h, --help Print this help message.
+ -i, --identify <regular expression>
+ Setup the regular expression to match the entries.
+ -m, --makeindex <program name>
+ Use <program name> instead of `makeindex'.
+ -r, --resultis <pattern>
+ Create line to be written from <pattern> after matching.
+ -s, --suffixis <pattern>
+ Create suffix to be used from <pattern> after matching.
+ -v, --verbose Be more verbose.
+ -V,--version Print the version information.
+]]
+
+local action_opts = {
+ ['-h'] = 'help',
+ ['--help'] = 'help',
+ ['-i'] = 'identify',
+ ['--identify'] = 'identify',
+ ['-m'] = 'makeindex',
+ ['--makeindex'] = 'makeindex',
+ ['-r'] = 'resultis',
+ ['--resultis'] = 'resultis',
+ ['-s'] = 'suffixis',
+ ['--suffixis'] = 'suffixis',
+ ['-v'] = 'verbose',
+ ['--verbose'] = 'verbose',
+ ['-V'] = 'version',
+ ['--version'] = 'version',
+ ['--'] = '--',
+}
+
+local identify = '^(\\indexentry)%[([^]]*)%](.*)$'
+local makeindex = 'makeindex'
+local resultis = '%1%3'
+local suffixis = '-%2'
+local verbose = 0
+
+while arg[1] do
+ local action = action_opts[arg[1]]
+ if action == '--' then
+ table.remove(arg,1)
+ break
+ elseif action == 'help' then
+ print( arg[0]..action_version )
+ print( 'Usage: ' .. arg[0] .. ' -h/--help' )
+ print( ' ' .. arg[0] .. ' -V/--version' )
+ print( ' ' .. arg[0] .. ' [<option> ...] \\ \
+ <intermediate index file> \\ \
+ [<makeindex option> ...]' )
+ print( action_help );
+ os.exit( 0 );
+ elseif action == 'identify' then
+ table.remove(arg,1)
+ if arg[1] == nil then
+ error( 'value expected after option -i or --identify' )
+ end
+ identify = arg[1]
+ table.remove(arg,1)
+ elseif action == 'makeindex' then
+ table.remove(arg,1)
+ if arg[1] == nil then
+ error( 'value expected after option -m or --makeindex' )
+ end
+ makeindex = arg[1]
+ table.remove(arg,1)
+ elseif action == 'resultis' then
+ table.remove(arg,1)
+ if arg[1] == nil then
+ error( 'value expected after option -r or --resultis' )
+ end
+ resultis = string.gsub(arg[1],'%$','%%')
+ table.remove(arg,1)
+ elseif action == 'suffixis' then
+ table.remove(arg,1)
+ if arg[1] == nil then
+ error( 'value expected after option -s or --suffixis' )
+ end
+ suffixis = string.gsub(arg[1],'%$','%%')
+ table.remove(arg,1)
+ elseif action == 'verbose' then
+ table.remove(arg,1)
+ verbose = verbose + 1
+ elseif action == 'version' then
+ print( arg[0] .. action_version );
+ os.exit( 0 );
+ else
+ break;
+ end
+end
+
+if arg[1] == nil then
+ error( 'intermediate file missing' )
+end
+
+local ifilename = arg[1]
+table.remove(arg,1)
+local bfilename = string.gsub(ifilename,'^(.*)%.idx$','%1')
+
+local f=io.open(ifilename,"rb")
+if f~=nil then io.close(f);
+elseif ifilename ~= bfilename..'.idx' then
+ f=io.open(bfilename..'.idx',"rb")
+ if f~=nil then
+ io.close(f)
+ ifilename=bfilename..'.idx'
+ end
+end
+
+local makeindexargs=''
+while arg[1] do
+ makeindexargs = makeindexargs..' "'..arg[1]..'"'
+ table.remove(arg,1)
+end
+
+local ofiles={}
+
+local line
+for line in io.lines(ifilename) do
+ local newline=string.gsub(line,identify,resultis)
+ local ext,matches=string.gsub(line,identify,suffixis)
+ if matches == 0 then
+ ext = string.gsub(suffixis,'%%[1234567890]','idx')
+ end
+ if ofiles[ext] == nil then
+ local msg
+ ofiles[ext],msg = io.open(bfilename..ext..'.idx','w')
+ if ofiles[ext] == nil then error(msg) end
+ end
+ assert( ofiles[ext]:write(newline,"\n") )
+end
+
+local k,v
+for k,v in pairs(ofiles) do
+ assert( v:close() )
+ local cmd=makeindex..makeindexargs..' "'..bfilename..k..'.idx"'
+ if makeindex ~= '' then
+ local s,t,n=os.execute(cmd)
+ if not s then
+ error('failed to execute ' .. cmd )
+ end
+ end
+end
+
+--
+-- End of file `splitindex.tlu'