summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/robustindex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-09-01 01:32:22 +0000
committerKarl Berry <karl@freefriends.org>2017-09-01 01:32:22 +0000
commit24b60599fe0fe2a672e102d295ab16b874bca2fd (patch)
tree0345ab1080b9c1d9c525f39a039e0412bc527fbc /Master/texmf-dist/tex/latex/robustindex
parentd23537f56720850db3dedce1b78bd65bbd6d0b0a (diff)
robustindex (31aug17)
git-svn-id: svn://tug.org/texlive/trunk@45185 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/robustindex')
-rw-r--r--Master/texmf-dist/tex/latex/robustindex/robustindex.sty128
1 files changed, 56 insertions, 72 deletions
diff --git a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
index 7d837a28644..a57ba7e87f1 100644
--- a/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
+++ b/Master/texmf-dist/tex/latex/robustindex/robustindex.sty
@@ -1,29 +1,18 @@
-% Package robustindex.sty, Wilberd van der Kallen Feb 2005.
+% Package robustindex.sty, Wilberd van der Kallen 2005, 2017.
%
-% This package addresses two issues.
-%
-% 1. The main issue.
% Third parties often change the page numbers without rerunning makeindex.
% One would like to make the page numbers in the index entries more robust.
% We use the \pageref mechanism for that. Only after adding, deleting or
% otherwise modifying an \index{entry}, or after changing the order of the
% index entries, does one have to rerun makeindex.
-% Other changes do not matter, as long as one runs LaTeX or pdflatex twice.
+% Other changes do not matter, as long as one runs LaTeX or pdflatex until
+% labels are stable.
% As usual a makeindex run has to be preceded and also followed by its
% LaTeX or pdflatex run.
%
-% 2. A patch.
-% The theindex environment does not create a hyperref destination.
-% Therefore we introduce \indexincontents.
-% It does what \addcontentsline{toc}{chapter}{Index} or
-% \addcontentsline{toc}{section}{Index} should have done in the first place:
-% When one clicks on the link that displays the word Index, one actually ends
-% up in the index.
-% Our patch is much more simpleminded than the tocbibind package.
%
-% If you use hyperref, choose the option hyperindex=false. Otherwise hyperref
-% may block our code. And our package already gives hyperlinks in the
-% index.
+% If you use hyperref, you must choose the option hyperindex=false.
+% Our package already gives hyperlinks in the index.
% Alternatively, you may go against the advice of hyperref and put our
% package later.
%
@@ -31,29 +20,23 @@
%
% \usepackage[plainpages=false,hyperindex=false]{hyperref}
%
-% The implicit page range formation of makeindex is disabled.
+% Automatic page ranges are not supported.
% Commands of the type \index{entry|editing command} are supported,
% but much more naively than in the encapsulating mechanism of makeindex.
-% For instance, \index{term|(textbf} may be followed by \index{term|)textit},
-% but not by \index{term|textbf}, even if there is a later
-% \index{term|)textbf}.
-%
-% See robustsample.tex at
-% http://www.math.uu.nl/people/vdkallen/stind.html
-% for further details.
-%
-% There you find examples like
-%
-% \index{alpha!see beta}
-% \index{alpha!see also gamma\gobblepageref}
+% For instance, \index{term|(textbf} may be followed by \index{term|)textit}.
%
-% \indexincontents % always put this before the index.
%
% Our package performs no miracles. But in simple situations all you need is
% adding the \usepackage{robustindex} to the preamble. Do not exclude any
% relevant files, as in \includeonly.
%
-% Copyright 2005 Wilberd van der Kallen
+% 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
%
% 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
@@ -63,7 +46,7 @@
% version 1999/12/01 or later.
\ProvidesPackage{robustindex}
- [2005/02/24
+ [2017/08/31
index entries with pagerefs]
\newcounter{indexctr}%
@@ -88,15 +71,24 @@
\@esphack
}%
+\newif\ifinside@range% output must be supressed inside page range.
+\inside@rangefalse
+
\newcommand{\indpageref}[1]{%
+\ifinside@range \findEndPageRange\else
\ifnum\c@maxindctr<#1\relax\setcounter{maxindctr}{#1}\fi
\pageref{\indstring#1}%
+ \fi
}%
\newcommand{\indexpreamble}{\relax}% compare the preamble of makeindex
\newcommand{\indexincontents}{%
\def\indexpreamble{%
+ \refstepcounter{subsection}%
+ % This creates a hyperlink destination.
+ % Compare phantomsection in hyperref.
+ % An index is not to be followed immediately by a subsection.
\addcontentsline{toc}%
{\ifx\c@chapter\undefined section\else chapter\fi}{\indexname}%
}%
@@ -108,7 +100,7 @@
\newcommand{\cndhyprndxwrng}{%
\ifHy@hyperindex
- \PackageWarning{robustind}{%
+ \PackageWarning{robustindex}{%
Use option hyperindex=false in hyperref. Hyperlinks in the index
will be made through \string\pageref. Detected%
}%
@@ -117,10 +109,7 @@
\def\theindex{%
\old@theindex
- \refstepcounter{subsection}\indexpreamble
- % We use that \refstepcounter{subsection} creates a destination.
- % An index is not to be followed immediately by a subsection.
- % We do not use \phantomsection, as we do not assume hyperref is used.
+ \indexpreamble
\ifx\ifHy@hyperindex\undefined\else\cndhyprndxwrng\fi
}%
@@ -132,13 +121,13 @@
\ifnum\c@indexctr=\c@maxindctr
\else
\ifnum\c@indexctr=0%
- \PackageWarning{robustind}{%
+ \PackageWarning{robustindex}{%
Package needs \string\make index in preamble,
and if you use hyperref, you must
use option hyperindex=false. Detected%
}%
\else
- \PackageWarning{robustind}{%
+ \PackageWarning{robustindex}{%
Index not up to date, run makeindex. Detected%
}%
\fi
@@ -156,18 +145,19 @@
#1{\pageref{\indstring#2}}%
}%
-\newcommand{\gobbleindpageref}{\wrappageref\@gobble}
+\newcommand{\gobbleindpageref}{\wrappageref\@gobble}%
-\newcommand{\gobblepageref}{% to supress one page number.
+\newcommand{\gobblepageref}{% to suppress one page number.
\protect\gobbleindpageref
}%
-% Now it gets technical, because we wish to implement a poor man's encap
+% 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}.
+
\newcommand{\findencap}{}%
\def\findencap#1|#2\relax{%
@@ -183,58 +173,52 @@
\def\wr@pencap#1|{encpageref{#1}}%
\newcommand{\encpageref}[2]{%
- \findleftbrack#1(\relax{#2}%
+ \findleft@brack#1(\relax{#2}%
}%
-\newcommand{\findleftbrack}{}%
+\newcommand{\findleft@brack}{}%
-\def\findleftbrack#1(#2\relax#3{%
- \ifx|#1| \dropleftbrack#2{#3}%
- \else \findrightbrack#1)\relax{#3}%
+\def\findleft@brack#1(#2\relax#3{%
+ \ifx|#1| \dropleft@brack#2{#3}% bracket ( found.
+ \else \findright@brack#1)\relax{#3}%
\fi
}%
-\newcommand{\dropleftbrack}{}%
+\newcommand{\dropleft@brack}{}%
-\def\dropleftbrack#1(#2{%
- \unskip
- \ifx|#1|\indpageref{#2}%
+\def\dropleft@brack#1(#2{%
+ \ifx|#1|\indpageref{#2}\inside@rangetrue%
\else
- \csname #1\endcsname{\indpageref{#2}}%
+ \csname #1\endcsname{\indpageref{#2}}\inside@rangetrue%
\fi
- \gobblecomma
+ % output for this key must be suppressed until end of range.
+ \findEndPageRange%
}%
-\newcommand{\gobblecomma}{}%
-
-\newcommand{\oldndpgrf}{}%
-\let\oldndpgrf\indpageref
+\newcommand{\findEndPageRange}{}% Name is helpful in error message if end not found.
-\def\gobblecomma#1,{%
- \def\indpageref{\rangewarning}%
+\def\findEndPageRange#1,{% It actually removes a comma.
\ignorespaces #1%
}%
-\newcommand{\rangewarning}{%
- \PackageWarning{robustind}{%
- You must first close the page range. Detected%
- }%
-}%
-
-\newcommand{\findrightbrack}{}%
+\newcommand{\findright@brack}{}%
-\def\findrightbrack#1)#2\relax#3{%
- \ifx|#1| \droprightbrack#2{#3}
+\def\findright@brack#1)#2\relax#3{%
+ \ifx|#1|\unskip \dropright@brack#2{#3}% bracket ) found.
\else
- \csname#1\endcsname{\indpageref{#3}}%
+ \ifinside@range
+ \findEndPageRange
+ \else
+ \csname#1\endcsname{\indpageref{#3}}%
+ \fi
\fi
}%
-\newcommand{\droprightbrack}{}%
+\newcommand{\dropright@brack}{}%
-\def\droprightbrack#1)#2{%
- \let\indpageref\oldndpgrf
+\def\dropright@brack#1)#2{%
+ \inside@rangefalse% output no longer suppressed.
\ifx|#1|\unskip \mbox{--}\nobreak\indpageref{#2}%
\else
\unskip \mbox{--}\nobreak\csname #1\endcsname{\indpageref{#2}}%