diff options
Diffstat (limited to 'Master/texmf-dist/tex/latex/robustindex/robustindex.sty')
-rw-r--r-- | Master/texmf-dist/tex/latex/robustindex/robustindex.sty | 122 |
1 files changed, 115 insertions, 7 deletions
diff --git a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty index a57ba7e87f1..4aff4fb1cbc 100644 --- a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty +++ b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty @@ -16,7 +16,7 @@ % Alternatively, you may go against the advice of hyperref and put our % package later. % -% We tested a little with +% We tested with % % \usepackage[plainpages=false,hyperindex=false]{hyperref} % @@ -30,6 +30,22 @@ % 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. +% 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. +% +% 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. +% This makes that the layout of an index gets more plain. +% The various hacks make 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. @@ -46,19 +62,28 @@ % version 1999/12/01 or later. \ProvidesPackage{robustindex} - [2017/08/31 + [2017/09/12 index entries with pagerefs] +\DeclareOption{multind}{ + \AtBeginDocument{\setindex{main}}% + \def\robust@mult{\relax} +}% + +\ProcessOptions\relax + \newcounter{indexctr}% \newcounter{maxindctr}% Used to check if number of \index commands has changed. \newcommand{\indstring}{ind.}% + \def\@wrindex#1{% +\@bsphack \stepcounter{indexctr}% \stepcounter{indexctr}% second time, to emulate makeindex -r. - \@bsphack \protected@write \@auxout {}{% + \protected@write \@auxout {}{% \string \newlabel {\indstring\theindexctr}{{\relax }{\thepage }% \ifx\ifHy@bookmarks\undefined\else{\relax }{page.\thepage }{}\fi% }% @@ -68,9 +93,34 @@ \@indexfile {}{\string \indexentry {\findencap#1|\relax }{\theindexctr}}% \findencap will check for the \endgroup % encap symbol | in the argument. - \@esphack +\@esphack }% +\def\@multwrindex#1{% +\@bsphack +\stepcounter{indexctr}% +\stepcounter{indexctr}% second time, to emulate makeindex -r. +\protected@write \@auxout {}{% + \string \newlabel {\indstring\theindexctr}{{\relax }{\thepage }% + \ifx\ifHy@bookmarks\undefined\else{\relax }{page.\thepage }{}\fi% + }% + }% + \@esphack + \protected@write + \@indexfile {}{\string \indexentry + {\string\indnr\robustchoice bs\findencap#1|\relax }{\theindexctr}}% + \endgroup +\@esphack +} + +\ifx\robust@mult\undefined\else\let\@wrindex\@multwrindex\fi + +\newcommand\sindex{\@ifnextchar[{\@sindex}{\@@sindex}}% + +\def\@sindex[#1]{\setindex{#1}\index} + +\def\@@sindex{\setindex{main}\index} + \newif\ifinside@range% output must be supressed inside page range. \inside@rangefalse @@ -127,9 +177,14 @@ use option hyperindex=false. Detected% }% \else - \PackageWarning{robustindex}{% + \ifx\robust@mult\undefined + \PackageWarning{robustindex}{% Index not up to date, run makeindex. Detected% - }% + }\else + \PackageWarning{robustindex}{% + Print each index or run makeindex. Detected% + }% + \fi \fi \fi }% @@ -226,4 +281,57 @@ \ignorespaces }% -\relax +% 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{\setindex}[1]{% +\@bsphack +\expandafter\ifx\csname#1ind\endcsname\relax + \newindex{#1}% +\else + \edef\robustchoice{\csname#1ind\endcsname}% +\fi +\@esphack}% + + + +\newcounter{multindctr} +\newcommand{\robustcutpoint}{\relax}% +\newcommand{\untilrobustcutpoint}{\relax}% +\newcommand{\newindex}{\relax}% +\newcommand{\robustchoice}{\relax}% +\newcommand{\indnr}{\relax} + +\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. + +\newcommand{\gobbletillnine}{\relax} + +\def\gobbletillnine#1 9{\relax} + +\def\newindex#1{\@bsphack\ifnum\c@multindctr=999% + \protected@write + \@indexfile {}{\string \indexentry + {\string\indnr 999bs @\string\robustcutpoint\string\gobbletillnine}{9}}% + \@esphack +\fi +\addtocounter{multindctr}{-1}% +\expandafter\edef\csname#1ind\endcsname{\the\c@multindctr}% +\edef\robustchoice{\csname#1ind\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\untilrobustcutpoint\string\fi\string\gobbletillnine +}{9}}% +\@esphack +}% + +\endinput
\ No newline at end of file |