summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/robustindex/robustmanual.tex
blob: df3a549df5f074b24c11c693784ceb8010ef11e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
% robustmanual.tex
\documentclass{article}
\usepackage{makeidx}
\usepackage{robustindex}
\usepackage[hyperindex=false]{hyperref}

\title {Manual of robustindex package}

\author{Wilberd van der Kallen\index{Wilberd}}
\date{2017}

\makeindex    % obligatory with robustindex

\begin{document}

\maketitle

\section*{Introduction}

\index{discussion|(}

Amazingly often a third party changes the page numbers without rerunning
makeindex. We therefore want to have an index in which the page numbers automatically synchronise with the document.

The package \texttt{robustindex} achieves this
by invoking the \verb|\pageref| mechanism on automatically generated labels
of the form \verb|ind.2|, \verb|ind.4|, \dots.

Only after adding/deleting/modifying an \verb|\index{|\textit{entry}\verb|}|
command, or after changing the order of \verb|\index{|\textit{entry}\verb|}|
commands, does one have to rerun makeindex. (How would you change the order? By moving a block of text that contains 
an \verb!\index! command.)

Make sure to run makeindex at least once after the last change to the \verb!\index! commands.
Keep an eye on the \TeX\ log file. It often contains a warning that you  need to rerun \LaTeX\ or makeindex. 

\section*{Standard usage}
Put 
$$
\verb!\usepackage{makeidx}! 
$$
$$
\verb!\usepackage{robustindex}! 
$$
$$\verb!\makeindex!$$
in your preamble.
If you use the hyperref package, go against their advice and put 
$$\verb!\usepackage{robustindex}! $$
\emph{after} the hyperref declaration, \emph{or} 
turn off \verb!hyperindex! as in 
$$
\verb!\usepackage[plainpages=false,hyperindex=false]{hyperref}!.
$$

That should be all. (You may have to trash old auxiliary files.)

You can now use \index{alpha}\index{gamma|textbf}
$$\verb!\index{alpha}!$$
$$\verb?\index{alpha!see beta}?$$
$$\verb!\index{gamma|textbf}!$$
$$\verb!\index{ampersand@\&|textbf}!$$
in the usual manner. 
\index{ampersand@\&|textbf}

See \url{https://en.wikibooks.org/wiki/LaTeX/Indexing}.\\



The symbol \verb!|!  has a special meaning inside an \verb!\index! command and cannot be escaped.
To get \verb!|! as output use the \LaTeX\ command \verb!\vert!.


We also have a command \verb!\gobblepageref!
used as in 
$$\verb?\index{alpha!see also gamma\gobblepageref}?$$
\index{alpha!see also gamma\gobblepageref}

\subsection*{Page ranges}
Some features of makeindex had to be repurposed.
In particular, \emph{implicit} page ranges are no longer supported. 


If you want a page range in the index you have to use 
the \emph{explicit} page range mechanism of makeindex as in
$$\verb!\index{discussion|(}!$$% used above

%\index{discussion}% inside range, hence would be suppressed.

%\index{discussion|blah}% inside range, hence would be suppressed.




on the first page of the range, followed by
$$\verb!\index{discussion|)}!$$\index{discussion|)}on the last page of the range.\\

\subsection*{Table of contents}
If there is a table of contents and you want the index listed in it, put the command
$$\verb!\indexincontents!$$
somewhere before the \verb!\printindex!.
\index{alpha!see beta}

We now use $\verb!\printindex!$ to get an index (on a new page).
\printindex
\end{document}