| 1 |
% multisample.tex 2018/04/11 |
| 2 |
\documentclass{book} |
| 3 |
|
| 4 |
\usepackage{makeidx} |
| 5 |
\usepackage[multind]{robustindex} |
| 6 |
\usepackage[plainpages=false,hyperindex=false,colorlinks=true]{hyperref} |
| 7 |
|
| 8 |
|
| 9 |
\title {A file with several indexes} |
| 10 |
|
| 11 |
\author{Wilberd van der Kallen\index{wilberd@Wilberd}} |
| 12 |
\date{April 2018} |
| 13 |
|
| 14 |
\makeindex % obligatory with robustindex |
| 15 |
%\altsort % to get other sorting under option maltind in Version 2019/01/24 of robustindex . |
| 16 |
% It places \index{\"U} after the alphabet, not before. |
| 17 |
\begin{document} |
| 18 |
%\renewcommand{\indexcapstyle}[1]{\par\vskip1em plus.5em minus.3em\textbf{\uppercase{#1}}} |
| 19 |
\renewcommand\thepage{\roman{page}} |
| 20 |
\index{z} |
| 21 |
|
| 22 |
\setindex{b1} |
| 23 |
|
| 24 |
|
| 25 |
\maketitle |
| 26 |
|
| 27 |
\tableofcontents |
| 28 |
\addcontentsline{toc}{chapter}{Contents} |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
\chapter*{Preface} |
| 34 |
|
| 35 |
\addcontentsline{toc}{chapter}{Preface} |
| 36 |
\markboth{Preface}{Preface} |
| 37 |
This file illustrates some features of the \verb!robustindex! package with option \verb!multind!. This option |
| 38 |
supports multiple indexes. |
| 39 |
|
| 40 |
Although this is not a book, we have chosen the book style for illustration. |
| 41 |
Let us say we want to use four indexes. First we choose tags to identify them. |
| 42 |
In this file we use the tags \verb|main|, \verb|bis|, \verb|a1|, \verb|b1|. |
| 43 |
With the \verb!\setindex! command we activate an index. |
| 44 |
Thus \verb!\setindex{main}! tells \LaTeX\ that the active index is now the index identified by the tag |
| 45 |
\verb|main|, until the next \verb!\setindex! command. If a tag has not been encountered |
| 46 |
before, then a new index with that tag is created. The tag \verb|main| is always known and |
| 47 |
the index with tag \verb|main| becomes active at the \verb|\begin{document}|. |
| 48 |
The \verb!\index! command and |
| 49 |
the \verb|\printindex| commands write to/from the active index.\\ |
| 50 |
|
| 51 |
If you wish you may use \verb!\sindex[bis]{!\emph{entry}\verb!}! as shorthand for\\ |
| 52 |
|
| 53 |
\hspace{5em} \verb!\setindex{bis}\index{!\emph{entry}\verb!}!\\ |
| 54 |
|
| 55 |
and \verb!\sindex{!\emph{entry}\verb!}! as shorthand for\\ |
| 56 |
|
| 57 |
\hspace{5em} \verb!\setindex{main}\index{!\emph{entry}\verb!}!.\\ |
| 58 |
|
| 59 |
|
| 60 |
To see how option \verb|multind| may be used, you may also compare the file |
| 61 |
\verb|multisample.tex| with the output. |
| 62 |
|
| 63 |
This preface has an \emph{indexed term}.\setindex{b1}\index{indexed term} (You see this in the source file only.) |
| 64 |
|
| 65 |
\chapter{Introduction}\sloppy |
| 66 |
\renewcommand\thepage{\arabic{page}} |
| 67 |
\addtocounter{page}{-2}% Just to get overlap in roman and arabic page numbers. |
| 68 |
This introduction has another indexed term |
| 69 |
\setindex{a1} |
| 70 |
\index{other term!cited twice on same page}% |
| 71 |
as well as the old indexed term.\setindex{b1}\index{indexed term} |
| 72 |
The page number is again 5, but now in arabic. |
| 73 |
If you index the same term twice on the same page, then one simply gets |
| 74 |
a repeat in the index.\setindex{a1}\index{other term!cited twice on same page} |
| 75 |
That is inherent in our method. |
| 76 |
Indeed we had to disable the implicit page range formation of makeindex. |
| 77 |
|
| 78 |
The index file {\it filename}.\texttt{ind} has become quite unreadable. Do not edit it. |
| 79 |
Use the option \verb!multind! only if you are willing to keep the indexes standard. |
| 80 |
Note that if you open a page range you must close |
| 81 |
it again with the same index active as when you opened the range. |
| 82 |
|
| 83 |
We have hacked various mechanisms of makeindex. |
| 84 |
Subentries are still supported. We illustrate this in |
| 85 |
\verb|multisample.tex| and appendix \ref{appendix} with alpha, beta and gamma. |
| 86 |
This also illustrates the use of \verb|\gobblepageref|, a variant of \verb!\see!. |
| 87 |
\setindex{a1}\index{alpha!see beta} |
| 88 |
\index{alpha!see also gamma\gobblepageref} |
| 89 |
|
| 90 |
After running \LaTeX\ on {\it filename}.\verb!tex! one must run makeindex on {\it |
| 91 |
filename} to get the index entries in {\it filename}.\texttt{ind}. |
| 92 |
Before this there may be error messages about labels or names. |
| 93 |
Do not exclude any relevant files. For instance, do not use |
| 94 |
\verb|\includeonly|. |
| 95 |
|
| 96 |
The package \verb|hyperref| may break our code. Therefore |
| 97 |
one must use the option |
| 98 |
\verb|hyperindex=false|, as in |
| 99 |
\verb|\usepackage[hyperindex=false]{hyperref}|. |
| 100 |
Note that \verb|robustindex| already puts |
| 101 |
hyperlinks in the index. Alternatively one may go against the advice of |
| 102 |
\verb|hyperref| and put \verb|robustindex| later in the preamble. |
| 103 |
In the file \verb|multisample.tex| we actually used |
| 104 |
\verb|\usepackage[plainpages=false,hyperindex=false]{hyperref}| |
| 105 |
because of the roman page numbers in the beginning. |
| 106 |
|
| 107 |
\setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|(textbf}% |
| 108 |
\index{page range|(textbf}% |
| 109 |
\index{page range!risky@this $\vert$is$\vert$ complicated|textbf}% |
| 110 |
\index{page range!risky@this $\vert$is$\vert$ complicated}% |
| 111 |
\index{page range!risky@this $\vert$is$\vert$ complicated|textbf}% |
| 112 |
% |
| 113 |
\index{simpler!page range|(}% |
| 114 |
\index{simplest page range|(}% |
| 115 |
|
| 116 |
\appendix |
| 117 |
\chapter{Structure of the \LaTeX\ file}\label{appendix} |
| 118 |
\begin{verbatim} |
| 119 |
\documentclass{book} |
| 120 |
|
| 121 |
\usepackage{makeidx} |
| 122 |
\usepackage[multind]{robustindex} |
| 123 |
\usepackage[plainpages=false,hyperindex=false]{hyperref} |
| 124 |
... |
| 125 |
...\author{Wilberd van der Kallen\index{wilberd@Wilberd}} |
| 126 |
... |
| 127 |
\makeindex % obligatory with robustindex |
| 128 |
|
| 129 |
\begin{document} |
| 130 |
... |
| 131 |
\tableofcontents |
| 132 |
...\index{indexed term} % on page v |
| 133 |
... |
| 134 |
...\index{other term!cited twice on same page} % on page 5 |
| 135 |
...\index{indexed term} % on page 5 |
| 136 |
...\index{other term!cited twice on same page} % on page 5 |
| 137 |
... |
| 138 |
\setindex{a1}\index{alpha!see beta} % on page 5 |
| 139 |
\index{alpha!see also gamma\gobblepageref} % on page 5 |
| 140 |
... |
| 141 |
\indexincontents % before the index. |
| 142 |
\setindex{main} |
| 143 |
\printindex |
| 144 |
... |
| 145 |
\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par} |
| 146 |
\renewcommand{\indexname}{Index with headings} |
| 147 |
\setindex{main} |
| 148 |
\printindex |
| 149 |
\end{document} |
| 150 |
\end{verbatim} |
| 151 |
|
| 152 |
\index{as! t@is} |
| 153 |
|
| 154 |
\index{tris} |
| 155 |
|
| 156 |
\setindex{main}\index{alpha} |
| 157 |
|
| 158 |
\setindex{a1}\index{gamma} |
| 159 |
|
| 160 |
\setindex{bis}\index{bis} |
| 161 |
|
| 162 |
\setindex{main}\index{delta!vardelta} |
| 163 |
|
| 164 |
|
| 165 |
\setindex{main}\index{animal!than@fish} |
| 166 |
|
| 167 |
\setindex{main}\index{animal!ruminant!cow} |
| 168 |
|
| 169 |
\setindex{main}\index{time!here@now} |
| 170 |
|
| 171 |
|
| 172 |
\setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|)textit} |
| 173 |
|
| 174 |
\chapter{Purpose of \texttt{robustindex.sty}}\label{purpose} |
| 175 |
Amazingly often a third party changes the page numbers without rerunning |
| 176 |
makeindex. It is much nicer to have indexes that adapt themselves to all |
| 177 |
changes that do not involve |
| 178 |
\verb|\index{|\textit{entry}\verb|}| commands. |
| 179 |
|
| 180 |
The package achieves this |
| 181 |
by invoking the \verb|\pageref| mechanism on automatically generated labels |
| 182 |
of the form \verb|ind.2|, \verb|ind.4|, \dots. |
| 183 |
|
| 184 |
Only after adding/deleting/modifying an \verb|\index{|\textit{entry}\verb|}| |
| 185 |
command, or after changing the order of \verb|\index{|\textit{entry}\verb|}| |
| 186 |
commands, does one have to run makeindex. But then it is important that you |
| 187 |
do run makeindex, even when no warning is issued. The robustness has its |
| 188 |
limits. |
| 189 |
|
| 190 |
With option \verb!multind! the package supports multiple indexes. But one still works with the standard compilation sequence\\ |
| 191 |
latex \emph{filename}.tex, makeindex \emph{filename}, latex \emph{filename}.tex. |
| 192 |
|
| 193 |
\index{page range|)textit}% |
| 194 |
|
| 195 |
\sindex[b1]{page range!risky@this $\vert$is$\vert$ complicated|texttt} |
| 196 |
|
| 197 |
% |
| 198 |
\setindex{b1}\index{page range!with risky label\label{range}} |
| 199 |
% This label actually works and was used above in a \pageref{range} command. |
| 200 |
% |
| 201 |
\index{simpler!page range|)}% |
| 202 |
\index{simplest page range|)}% |
| 203 |
|
| 204 |
|
| 205 |
% If you want the index in the table of contents, you may do |
| 206 |
% |
| 207 |
% \clearpage |
| 208 |
% \phantomsection |
| 209 |
% \addcontentsline{toc}{chapter}{\indexname} |
| 210 |
% |
| 211 |
% We have a command for this: |
| 212 |
|
| 213 |
\indexincontents % before \printindex |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
\renewcommand{\indexname}{Index} |
| 219 |
\setindex{main} |
| 220 |
\printindex |
| 221 |
|
| 222 |
\renewcommand{\indexname}{Index bis} |
| 223 |
\setindex{bis} |
| 224 |
\printindex |
| 225 |
|
| 226 |
\renewcommand{\indexname}{Index with tag a1} |
| 227 |
\setindex{a1} |
| 228 |
\printindex |
| 229 |
|
| 230 |
|
| 231 |
\renewcommand{\indexname}{Index with tag b1} |
| 232 |
\setindex{b1} |
| 233 |
\printindex |
| 234 |
|
| 235 |
|
| 236 |
\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par} |
| 237 |
\renewcommand{\indexname}{Index with headings} |
| 238 |
\setindex{main} |
| 239 |
\printindex |
| 240 |
\end{document} |