summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/manyind/mindsample.tex
blob: b1ec5963d5064f65579a85c7a3abed4d19eb5658 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
% mindsample.tex 2019.01.27. 
\documentclass{book}

\usepackage{manyind} % 
\usepackage[plainpages=false,colorlinks=true]{hyperref}

\altsort % to get other sorting. 

\title {Package manyind provides support for many indexes}
\author{Wilberd van der Kallen\index{Wilberd}}
\date{January 2019}

\makeindex    % obligatory with manyindex

\begin{document}

\renewcommand\thepage{\roman{page}}
\index{z}% ends up in index main.

\index{/@/ divide symbol comes before A}
\index{:@\indexspace : colon comes here}% goes after Z when using \altsort, before A otherwise.
 
\setindex{b1}

\maketitle % So Wilberd will end up in index b1.

\tableofcontents
\addcontentsline{toc}{chapter}{Contents}


\chapter*{Preface}

\addcontentsline{toc}{chapter}{Preface}
\markboth{Preface}{Preface}
This file illustrates some features of the \verb!manyind! package. 
One runs latex and makeindex as if there is just one index. No extra programs are required.
We let makeindex and \TeX\ do the work. As we are using makeindex in a way that was never intended, 
some features of makeindex may not work anymore.
 
 Although this is not a book, we have chosen the book style for illustration.
Let us say we want to use four indexes. First we choose tags to identify them.
In this file we use the tags \verb|main|, \verb|bis|, \verb|a1|, \verb|b1|.
With the \verb!\setindex! command we activate an index.
Thus \verb!\setindex{main}! (no spaces!) tells \LaTeX\ that the active index is now the index identified by the tag
\verb|main|, until the next \verb!\setindex! command. If a tag has not been encountered 
before, then a new index with that tag is created. 
The tag \verb|main| is always known and
the index with tag \verb|main|  becomes active at the \verb|\begin{document}|.
The \verb!\index! command and
the \verb|\printindex| commands write to/from the active index.\\

After running latex on {\it filename}.\verb!tex! one must run makeindex on {\it
filename} to get the index entries in {\it filename}.\texttt{ind}.
Before this there may be warnings about labels or names.
Do not exclude any relevant files. For instance, do not use
\verb|\includeonly|. 

(A tool like  pdflatexmk in TeXShop on the MAC will call makeindex for you.)\\

If you wish you may use \verb!\sindex[bis]{!\emph{entry}\verb!}! as shorthand for\\

\hspace{5em} \verb!\setindex{bis}\index{!\emph{entry}\verb!}!\\
 
and \verb!\sindex{!\emph{entry}\verb!}! as shorthand for\\

 \hspace{5em} \verb!\setindex{main}\index{!\emph{entry}\verb!}!.\\
 
 One may give (at most) two optional arguments to \verb|\printindex|.
\noindent  While  
 
 \verb|\printindex| 
 
\noindent  prints the active index, 
 
 \verb|\printindex[b1]|  
 
\noindent  first makes  \verb|b1| the active index.
 And 
 
 \verb|\printindex[b1][Index with tag b1]| 
 
 \noindent also first does a
 \verb|\renewcommand{\indexname}{Index with tag b1}|.


To see how package \verb|manyind| may be used, you may also compare the file
\verb|mindsample.tex| with the output.

This preface has an \emph{indexed term}.\setindex{b1}\index{indexed term}
 (You see this in the source file only.)




\chapter{Introduction}\sloppy
\renewcommand\thepage{\arabic{page}}
\addtocounter{page}{-6}% Just to get overlap in roman and arabic page numbers.
This introduction has another indexed term 
\setindex{a1}
\index{other term!cited twice on same page}%
as well as the old indexed term.\setindex{b1}\index{indexed term}% will appear in an automatic page range
The page number is  \thepage, but now in arabic.
If you index the same term twice on the same page, then it gets listed only once.

We have hacked various mechanisms of makeindex. 
Subentries are still supported. We illustrate this in
\verb|mindsample.tex| and appendix \ref{appendix} with alpha, beta and gamma (output on page \pageref{range}).
This also illustrates the use of \verb|\gobblepageref|, a variant of \verb!\see!.

The package \verb|manyind|
  is similar to option \verb!multind! of package \verb|robustindex|, but it does not
 put any \verb|\pageref| in an index. Therefore it does not have to disable the automatic page range mechanism of makeindex.

The index file {\it filename}.\texttt{ind} has become quite unreadable. Do not edit it.
Use the package \verb!manyind! only if you are willing to keep the indexes standard. 

If one puts \verb|\altsort|
in the preamble, then entries are sorted differently. For instance, \verb|\index{\"U}|
will put \"U after the alphabet, not before. 

\setindex{a1}\index{alpha!see beta}
\index{alpha!see also gamma\gobblepageref}

\newpage
\setindex{b1}\index{indexed term}% will appear in an automatic page range

\setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|(textbf}%
\index{page range|(textit}%
\index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
\index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
\index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
%
\index{simpler!page range|(}%
\index{simplest page range|(}%
\setindex{b1}\index{indexed term}% will appear in an automatic page range
\appendix
\setindex{b1}\index{indexed term}% will appear in an automatic page range
\chapter{Structure of the \LaTeX\ file}\label{appendix}
\setindex{b1}\index{indexed term}% will appear in an automatic page range
\begin{verbatim}
\documentclass{book}

\usepackage{manyind}
\usepackage[plainpages=false,colorlinks=true]{hyperref}

...
...\author{Wilberd van der Kallen\index{Wilberd}} 
...
\makeindex    % obligatory with manyind

\begin{document}
...
\tableofcontents
...\index{indexed term}                          % on page vi
...
...\index{other term!cited twice on same page}   % on page 1
...\index{indexed term}                          % on page 1
...\index{other term!cited twice on same page}   % on page 1
...
\setindex{a1}\index{alpha!see beta}              % on page 1         
\index{alpha!see also gamma\gobblepageref}       % on page 1
...
\indexincontents %  before the indexes.
\setindex{main}
\printindex
...
\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}
\printindex[main][Index with headings]
\end{document}
\end{verbatim}

\setindex{b1}\index{indexed term}% will appear in an automatic page range

\sindex{as! t@is}

\index{tris}

\setindex{main}\index{alpha}

\setindex{a1}\index{gamma}

\setindex{bis}\index{bis}


\setindex{main}\index{delta!vardelta}


\setindex{main}\index{animal!than@fish}


\setindex{main}\index{time!here@now}

% When you are sure there is an entry \index{\"U...}.
\index{\"U@\indexcapstyle{\"U}\gobblepageref}% 

\index{\"Uber}% 
\index{\"Uberhaupt}% 

% There is a nerdy way:
\index{\"N@\protect\nxtletre \protect\def \nwletre {\"O}\gobblepageref}
\index{\"P@\relax\gobblepageref}

% Now look what happens if you leave out the next  line
\index{\"Osterreich}

% Similarly
\index{\A>@\protect\nxtletre \protect\def \nwletre {\AA}\gobblepageref}
\index{\AB@\relax\gobblepageref}

\index{\AA ngstrom}



\setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|)textbf}


\index{page range|)textit}%

%\sindex[b1]{page range!risky@this $\vert$is$\vert$ complicated|textbf}

%
\index{page range!with risky label\label{range}}
% This label actually works and was used above in a \pageref{range} command.
%
\sindex[b1]{simpler!page range|)}%
\index{simplest page range|)}%


% If you want the index in the table of contents, you may do
%
%         \clearpage
%         \phantomsection
%         \addcontentsline{toc}{chapter}{\indexname}
%
% We have a command for this:

\indexincontents % before \printindex



\renewcommand{\indexname}{Index}
\setindex{main}
\printindex

\sindex[b1]{page range!risky@this $\vert$is$\vert$ complicated|textbf}

\renewcommand{\indexname}{Index bis}
\setindex{bis}
\printindex


\renewcommand{\indexname}{Index with tag a1}
\setindex{a1}
\printindex


\renewcommand{\indexname}{Index with tag b1}
\setindex{b1}
\printindex
\subsection*{Embellishment}
The command \verb!\indexcapstyle!
takes one argument. Its original definition is \verb!\newcommand{\indexcapstyle}[1]{\indexspace}!.

One may embellish an index with letter headings, like this.\\

\setindex{main}\index{animal!ruminant!cow}


\verb!\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}!%


\verb!\printindex[main][Index with headings]! \\

\noindent This gives 



\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}
\printindex[main][Index with headings]



\end{document}