summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/robustindex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-10-02 21:58:27 +0000
committerKarl Berry <karl@freefriends.org>2017-10-02 21:58:27 +0000
commitb05bbbaa1cd9b63551731cdd1577f90225da2079 (patch)
treeb00d557f9bddbf3a303b45572fce477b6484804d /Master/texmf-dist/tex/latex/robustindex
parentf3d0235a07baa8c6f8430bddcaa95ba3ad6de5ee (diff)
robustindex (1oct17)
git-svn-id: svn://tug.org/texlive/trunk@45452 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/robustindex')
-rw-r--r--Master/texmf-dist/tex/latex/robustindex/robustindex.sty94
1 files changed, 72 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
index 4aff4fb1cbc..8ddcecbc27b 100644
--- a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
+++ b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
@@ -30,9 +30,9 @@
% adding the \usepackage{robustindex} to the preamble. Do not exclude any
% relevant files, as in \includeonly.
%
-% The option multind provides support for several indexes with pagerefs,
-% albeit with a simple layout. There is just one index file,
-% and the usual compilation cycle (latex, makeindex, latex) suffices.
+% The option multind provides support for several indexes with pagerefs.
+% There is just one index file, and the usual compilation cycle
+% (latex, makeindex, latex) suffices.
% With the command \setindex in the LaTeX file one arranges which index is
% the active one at any given moment.
% This steers the behaviour of \index and \printindex.
@@ -41,8 +41,12 @@
%
% While robustindex.sty broke the automatic page range feature of
% makeindex, the multind option also breaks the insertions
-% of \indexspace in the index file.
-% This makes that the layout of an index gets more plain.
+% of \indexspace in the index file. And it messes up the sorting a bit.
+% Therefore, when using the option multind, we require that the argument of
+% an \index command always starts with at least two lower case letters.
+% We then hack some more to restore the placement of \indexspace
+% and also introduce tools to embellish an index with letter headings.
+%
% The various hacks make the index file pretty unreadable
% and style files of makeindex will probably fail.
%
@@ -62,7 +66,7 @@
% version 1999/12/01 or later.
\ProvidesPackage{robustindex}
- [2017/09/12
+ [2017/09/28
index entries with pagerefs]
\DeclareOption{multind}{
@@ -181,9 +185,7 @@
\PackageWarning{robustindex}{%
Index not up to date, run makeindex. Detected%
}\else
- \PackageWarning{robustindex}{%
- Print each index or run makeindex. Detected%
- }%
+ \PackageWarning{robustindex}{Print each index or run makeindex. Detected}%
\fi
\fi
\fi
@@ -209,8 +211,9 @@
% Now it gets ugly, because we wish to implement a poor man's encap
% mechanism, distinguishing \index{entry}, \index{entry|(}, \index{entry|)},
-% \index{entry|(towrap}, \index{entry|)towrap}, where towrap is a sequence
-% of letters and \towrap is to be wrapped around \indpageref{countervalue}.
+% \index{entry|towrap}, \index{entry|(towrap}, \index{entry|)towrap}, where
+% towrap is a sequence of letters and \towrap is to be wrapped around
+% \indpageref{countervalue}.
\newcommand{\findencap}{}%
@@ -281,9 +284,54 @@
\ignorespaces
}%
+
+
% Now the part that supports multiple indices. We hack the sorting mechanism of
% Makeindex and put instructions for the mouth of TeX in the index file.
+% But first some code for embellishing an index. Our hacking brakes the insertion of
+% \indexspace at appropriate places. We have to work hard to restore that. While we
+% are at it, we may as well add the possibility to insert a letter T after the
+% \indexspace that precedes the entries that start with t.
+% First we describe the default style, without the T.
+\newcommand{\indexcapstyle}[1]{\indexspace}
+% To get the T one changes the style like this
+% \renewcommand{\indexcapstyle}[1]{\indexspace\textbf{#1}\par}%
+
+\newcommand{\nxtletre}{\relax}% nextletter in alphabet
+
+\newcommand{\indexcapitalhead}[1]{% Preparing for a heading; not printed.
+\index{#1@\protect\nxtletre\protect\def\protect
+\item{\protect\olditem\protect\letretst}%
+\protect\edef\protect\nwletre{\uppercase{#1}}\gobblepageref}}%
+
+\newcommand{\capitalsinindex}[1]{% Will be called by \newindex with full alphabet.
+\index{-@\protect\let\protect\olditem\protect\item\gobblepageref}%
+\find@capitals#1\relax}%
+
+\newcommand{\find@capitals}{\relax}%
+
+\def\find@capitals#1#2\relax{% To deal with 26 letters.
+\indexcapitalhead #1%
+\ifx\relax#2\relax
+\else\find@capitals#2\relax
+\fi}%
+
+\newcommand{\letretst}{\relax}% To test if entry starts with new letter.
+
+\long\def\letretst#1{\ifx#1\nxtletre\else\procletter{#1}\fi}%
+
+\newcommand{\procletter}{\relax}% To process a new letter.
+
+\def\procletter#1{\long\def\item{\olditem}\indexcapstyle{\nwletre}\ifx#1\indnr
+\expandafter\ja@\else #1\fi}%
+
+\newcommand{\olditem}{\relax}%
+
+\def\ja@#1s{\fi}% Seems necessary.
+
+% All this just to embellish an index. Now the support for multiple indexes.
+
\newcommand{\setindex}[1]{%
\@bsphack
\expandafter\ifx\csname#1ind\endcsname\relax
@@ -293,33 +341,33 @@
\fi
\@esphack}%
+\ifx\robust@mult\undefined\def\setindex{\relax}\fi
-
-\newcounter{multindctr}
+\newcounter{multindctr}%
\newcommand{\robustcutpoint}{\relax}%
\newcommand{\untilrobustcutpoint}{\relax}%
\newcommand{\newindex}{\relax}%
\newcommand{\robustchoice}{\relax}%
-\newcommand{\indnr}{\relax}
+\newcommand{\indnr}{\relax}%
-\setcounter{multindctr}{999}
+\setcounter{multindctr}{999}%
\long\def\untilrobustcutpoint#1\robustcutpoint{\fi}%
% This tels the mouth of TeX not to send too much to the stomach.
% It should only forward the part that belongs to the active index.
-\def\indnr#1s{\@bsphack\@esphack}%
-% The \indnr#1s part is not for output, but for Makeindex sorting, separating the
-% different indexes.
+\def\indnr#1s{}%
\newcommand{\gobbletillnine}{\relax}
\def\gobbletillnine#1 9{\relax}
-\def\newindex#1{\@bsphack\ifnum\c@multindctr=999%
+\def\newindex#1{\@bsphack
+\ifnum\c@multindctr=999%
\protected@write
\@indexfile {}{\string \indexentry
- {\string\indnr 999bs @\string\robustcutpoint\string\gobbletillnine}{9}}%
+ {\string\indnr 999bs @\string\nxtletre
+ \string\robustcutpoint\string\gobbletillnine}{9}}%
\@esphack
\fi
\addtocounter{multindctr}{-1}%
@@ -329,8 +377,10 @@
\@indexfile {}{\string \indexentry
{\string\indnr\the\c@multindctr as @\string\robustcutpoint
\string\ifnum \string\robustchoice=\the\c@multindctr\string\relax
-\string\else \string\untilrobustcutpoint\string\fi\string\gobbletillnine
-}{9}}%
+\string\else\string\nxtletre\string\untilrobustcutpoint
+\string\fi\string\gobbletillnine
+}{9}}%
+\capitalsinindex{abcdefghijklmnopqrstuvwxyz}%
\@esphack
}%