summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/robustindex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-04-29 23:02:37 +0000
committerKarl Berry <karl@freefriends.org>2018-04-29 23:02:37 +0000
commitf00655c17fbdf03e3f77fdec53d6a64d76082f86 (patch)
tree0a8f8a343300cfb307c91005e6456fc00e55f121 /Master/texmf-dist/tex/latex/robustindex
parentf8834f35084ceda8688cd138ef75fc19828c23f8 (diff)
robustindex (25apr18)
git-svn-id: svn://tug.org/texlive/trunk@47495 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/robustindex')
-rw-r--r--Master/texmf-dist/tex/latex/robustindex/robustindex.sty107
1 files changed, 66 insertions, 41 deletions
diff --git a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
index 8ddcecbc27b..490758af944 100644
--- a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
+++ b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
@@ -1,4 +1,4 @@
-% Package robustindex.sty, Wilberd van der Kallen 2005, 2017.
+% Package robustindex.sty, Wilberd van der Kallen 2005, 2017, 2018.
%
% Third parties often change the page numbers without rerunning makeindex.
% One would like to make the page numbers in the index entries more robust.
@@ -37,26 +37,24 @@
% the active one at any given moment.
% This steers the behaviour of \index and \printindex.
%
+% We introduce tools to embellish an index with letter headings.
+%
% That is the positive part.
%
% While robustindex.sty broke the automatic page range feature of
-% makeindex, the multind option also breaks the insertions
-% 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.
+% makeindex, the multind option also broke the insertions
+% of \indexspace in the index file. And it messed up the sorting.
+% We use various hacks to restore reasonable behaviour. This makes the index file
+% pretty unreadable and style files of makeindex will probably fail.
%
+%
% Remark.
% The package imakeidx also synchronises the index with the manuscript,
% but it has a different method and different requirements.
%
% https://www.staff.science.uu.nl/~kalle101/stind
%
-% Copyright 2017 Wilberd van der Kallen
+% Copyright 2018 Wilberd van der Kallen
%
% This file may be distributed under the conditions of the LaTeX Project Public
% License, either version 1.2 of this license or (at your option) any
@@ -66,9 +64,11 @@
% version 1999/12/01 or later.
\ProvidesPackage{robustindex}
- [2017/09/28
+ [2018/04/25
index entries with pagerefs]
+\RequirePackage{makeidx}
+
\DeclareOption{multind}{
\AtBeginDocument{\setindex{main}}%
\def\robust@mult{\relax}
@@ -112,11 +112,12 @@
\@esphack
\protected@write
\@indexfile {}{\string \indexentry
- {\string\indnr\robustchoice bs\findencap#1|\relax }{\theindexctr}}%
+ {\string\indnr\robustchoice d\gr@bltr#1-\relax b \findencap#1|\relax}{\theindexctr}}%
\endgroup
\@esphack
}
+
\ifx\robust@mult\undefined\else\let\@wrindex\@multwrindex\fi
\newcommand\sindex{\@ifnextchar[{\@sindex}{\@@sindex}}%
@@ -137,6 +138,12 @@
\newcommand{\indexpreamble}{\relax}% compare the preamble of makeindex
+\newcommand{\mult@err}{\PackageWarning{robustindex}{%
+ Index file is obsolete. Run makeindex. Detected}Index file is obsolete. Run makeindex.
+ \end{theindex}\endinput}%
+
+\newcommand{\gobbletillnine}{\mult@err}
+
\newcommand{\indexincontents}{%
\def\indexpreamble{%
\refstepcounter{subsection}%
@@ -209,6 +216,7 @@
}%
+
% 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}, \index{entry|)towrap}, where
@@ -226,6 +234,7 @@
\fi
}%
+
\newcommand{\wr@pencap}{}%
\def\wr@pencap#1|{encpageref{#1}}%
@@ -289,24 +298,29 @@
% 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.
+\newcommand{\gr@bltr}{\relax}%
+
+\def\gr@bltr#1#2\relax{\ifcat A#1\the\uccode`#1\else 60\fi}% to keep "a" and "A" together.
+
% 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.
+% \indexspace that precedes the entries that start with t or T.
+% First we describe the default style, that does not insert 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{\nxtletre}{\def\item{\letr@test}}% about next letter 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}}%
+ \protected@write
+ \@indexfile {}{\string \indexentry
+ {\string\indnr \robustchoice d\gr@bltr#1\relax a #1@\protect\nxtletre
+ \protect\def\protect\nwletre{#1}\string\jmptonine}{9}}%
+}%
\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}%
@@ -317,31 +331,34 @@
\else\find@capitals#2\relax
\fi}%
-\newcommand{\letretst}{\relax}% To test if entry starts with new letter.
+\newcommand{\letr@test}{\relax}% To test if entry starts with new letter.
-\long\def\letretst#1{\ifx#1\nxtletre\else\procletter{#1}\fi}%
+\long\def\letr@test#1{\ifx#1\nxtletre\else\procletter{#1}\fi}%
-\newcommand{\procletter}{\relax}% To process a new letter.
+\newcommand{\procletter}{\relax}%
\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.
+\newcommand{\ja@}{\relax}
+
+\def\ja@#1 {\fi}% Mysterious. 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
+\expandafter\ifx\csname#1@rbstind\endcsname\relax
\newindex{#1}%
\else
- \edef\robustchoice{\csname#1ind\endcsname}%
+ \edef\robustchoice{\csname#1@rbstind\endcsname}%
\fi
\@esphack}%
-\ifx\robust@mult\undefined\def\setindex{\relax}\fi
+\ifx\robust@mult\undefined\def\setindex{\PackageWarning{robustindex}{%
+ \string\setindex{} requires option multind. Detected}}\fi
\newcounter{multindctr}%
\newcommand{\robustcutpoint}{\relax}%
@@ -350,38 +367,46 @@
\newcommand{\robustchoice}{\relax}%
\newcommand{\indnr}{\relax}%
-\setcounter{multindctr}{999}%
+\setcounter{multindctr}{999}% Fewer than 899 indexes expected.
\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{}%
+\def\indnr#1 {}% The \indnr part is used for sorting by makeindex and needs to be ignored
+ % by TeX thereafter.
+
+\newcommand\multindpreamble{\let\olditem\item\let\jmptonine\jmp@tnine}%
+% \multindpreamble may serve as hook for further code.
+
+\newcommand{\jmptonine}{\mult@err}%
-\newcommand{\gobbletillnine}{\relax}
+\newcommand{\jmp@tnine}{\relax}%
-\def\gobbletillnine#1 9{\relax}
+\def\jmp@tnine#1 9{\relax}
\def\newindex#1{\@bsphack
+\ifx\@indexfile\undefined\PackageWarning{robustindex}{%
+Package needs \string\make index in preamble. Detected}\fi
\ifnum\c@multindctr=999%
\protected@write
\@indexfile {}{\string \indexentry
- {\string\indnr 999bs @\string\nxtletre
- \string\robustcutpoint\string\gobbletillnine}{9}}%
+ {\string\indnr 999b @\string\nxtletre
+ \string\robustcutpoint\string\jmptonine}{9}}%
\@esphack
\fi
\addtocounter{multindctr}{-1}%
-\expandafter\edef\csname#1ind\endcsname{\the\c@multindctr}%
-\edef\robustchoice{\csname#1ind\endcsname}%
+\expandafter\edef\csname#1@rbstind\endcsname{\the\c@multindctr}%
+\edef\robustchoice{\csname#1@rbstind\endcsname}%
\@esphack \protected@write
\@indexfile {}{\string \indexentry
- {\string\indnr\the\c@multindctr as @\string\robustcutpoint
-\string\ifnum \string\robustchoice=\the\c@multindctr\string\relax
-\string\else\string\nxtletre\string\untilrobustcutpoint
-\string\fi\string\gobbletillnine
+ {\string\indnr\the\c@multindctr a @\string\robustcutpoint
+\string\ifnum\string\robustchoice=\the\c@multindctr\string\multindpreamble
+\string\else\string\untilrobustcutpoint
+\string\fi\string\jmptonine
}{9}}%
-\capitalsinindex{abcdefghijklmnopqrstuvwxyz}%
+\capitalsinindex{ABCDEFGHIJKLMNOPQRSTUVWXYZ}%
\@esphack
}%
-\endinput \ No newline at end of file
+\endinput