Debian Codegraph @

texmf-dist/doc/latex/manyind/mindsample.tex

raw
1 % mindsample.tex 2019.01.27.
2 \documentclass{book}
3
4 \usepackage{manyind} %
5 \usepackage[plainpages=false,colorlinks=true]{hyperref}
6
7 \altsort % to get other sorting.
8
9 \title {Package manyind provides support for many indexes}
10 \author{Wilberd van der Kallen\index{Wilberd}}
11 \date{January 2019}
12
13 \makeindex % obligatory with manyindex
14
15 \begin{document}
16
17 \renewcommand\thepage{\roman{page}}
18 \index{z}% ends up in index main.
19
20 \index{/@/ divide symbol comes before A}
21 \index{:@\indexspace : colon comes here}% goes after Z when using \altsort, before A otherwise.
22
23 \setindex{b1}
24
25 \maketitle % So Wilberd will end up in index b1.
26
27 \tableofcontents
28 \addcontentsline{toc}{chapter}{Contents}
29
30
31 \chapter*{Preface}
32
33 \addcontentsline{toc}{chapter}{Preface}
34 \markboth{Preface}{Preface}
35 This file illustrates some features of the \verb!manyind! package.
36 One runs latex and makeindex as if there is just one index. No extra programs are required.
37 We let makeindex and \TeX\ do the work. As we are using makeindex in a way that was never intended,
38 some features of makeindex may not work anymore.
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}! (no spaces!) 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.
47 The tag \verb|main| is always known and
48 the index with tag \verb|main| becomes active at the \verb|\begin{document}|.
49 The \verb!\index! command and
50 the \verb|\printindex| commands write to/from the active index.\\
51
52 After running latex on {\it filename}.\verb!tex! one must run makeindex on {\it
53 filename} to get the index entries in {\it filename}.\texttt{ind}.
54 Before this there may be warnings about labels or names.
55 Do not exclude any relevant files. For instance, do not use
56 \verb|\includeonly|.
57
58 (A tool like pdflatexmk in TeXShop on the MAC will call makeindex for you.)\\
59
60 If you wish you may use \verb!\sindex[bis]{!\emph{entry}\verb!}! as shorthand for\\
61
62 \hspace{5em} \verb!\setindex{bis}\index{!\emph{entry}\verb!}!\\
63
64 and \verb!\sindex{!\emph{entry}\verb!}! as shorthand for\\
65
66 \hspace{5em} \verb!\setindex{main}\index{!\emph{entry}\verb!}!.\\
67
68 One may give (at most) two optional arguments to \verb|\printindex|.
69 \noindent While
70
71 \verb|\printindex|
72
73 \noindent prints the active index,
74
75 \verb|\printindex[b1]|
76
77 \noindent first makes \verb|b1| the active index.
78 And
79
80 \verb|\printindex[b1][Index with tag b1]|
81
82 \noindent also first does a
83 \verb|\renewcommand{\indexname}{Index with tag b1}|.
84
85
86 To see how package \verb|manyind| may be used, you may also compare the file
87 \verb|mindsample.tex| with the output.
88
89 This preface has an \emph{indexed term}.\setindex{b1}\index{indexed term}
90 (You see this in the source file only.)
91
92
93
94
95 \chapter{Introduction}\sloppy
96 \renewcommand\thepage{\arabic{page}}
97 \addtocounter{page}{-6}% Just to get overlap in roman and arabic page numbers.
98 This introduction has another indexed term
99 \setindex{a1}
100 \index{other term!cited twice on same page}%
101 as well as the old indexed term.\setindex{b1}\index{indexed term}% will appear in an automatic page range
102 The page number is \thepage, but now in arabic.
103 If you index the same term twice on the same page, then it gets listed only once.
104
105 We have hacked various mechanisms of makeindex.
106 Subentries are still supported. We illustrate this in
107 \verb|mindsample.tex| and appendix \ref{appendix} with alpha, beta and gamma (output on page \pageref{range}).
108 This also illustrates the use of \verb|\gobblepageref|, a variant of \verb!\see!.
109
110 The package \verb|manyind|
111 is similar to option \verb!multind! of package \verb|robustindex|, but it does not
112 put any \verb|\pageref| in an index. Therefore it does not have to disable the automatic page range mechanism of makeindex.
113
114 The index file {\it filename}.\texttt{ind} has become quite unreadable. Do not edit it.
115 Use the package \verb!manyind! only if you are willing to keep the indexes standard.
116
117 If one puts \verb|\altsort|
118 in the preamble, then entries are sorted differently. For instance, \verb|\index{\"U}|
119 will put \"U after the alphabet, not before.
120
121 \setindex{a1}\index{alpha!see beta}
122 \index{alpha!see also gamma\gobblepageref}
123
124 \newpage
125 \setindex{b1}\index{indexed term}% will appear in an automatic page range
126
127 \setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|(textbf}%
128 \index{page range|(textit}%
129 \index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
130 \index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
131 \index{page range!risky@this $\vert$is$\vert$ complicated|textbf}%
132 %
133 \index{simpler!page range|(}%
134 \index{simplest page range|(}%
135 \setindex{b1}\index{indexed term}% will appear in an automatic page range
136 \appendix
137 \setindex{b1}\index{indexed term}% will appear in an automatic page range
138 \chapter{Structure of the \LaTeX\ file}\label{appendix}
139 \setindex{b1}\index{indexed term}% will appear in an automatic page range
140 \begin{verbatim}
141 \documentclass{book}
142
143 \usepackage{manyind}
144 \usepackage[plainpages=false,colorlinks=true]{hyperref}
145
146 ...
147 ...\author{Wilberd van der Kallen\index{Wilberd}}
148 ...
149 \makeindex % obligatory with manyind
150
151 \begin{document}
152 ...
153 \tableofcontents
154 ...\index{indexed term} % on page vi
155 ...
156 ...\index{other term!cited twice on same page} % on page 1
157 ...\index{indexed term} % on page 1
158 ...\index{other term!cited twice on same page} % on page 1
159 ...
160 \setindex{a1}\index{alpha!see beta} % on page 1
161 \index{alpha!see also gamma\gobblepageref} % on page 1
162 ...
163 \indexincontents % before the indexes.
164 \setindex{main}
165 \printindex
166 ...
167 \renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}
168 \printindex[main][Index with headings]
169 \end{document}
170 \end{verbatim}
171
172 \setindex{b1}\index{indexed term}% will appear in an automatic page range
173
174 \sindex{as! t@is}
175
176 \index{tris}
177
178 \setindex{main}\index{alpha}
179
180 \setindex{a1}\index{gamma}
181
182 \setindex{bis}\index{bis}
183
184
185 \setindex{main}\index{delta!vardelta}
186
187
188 \setindex{main}\index{animal!than@fish}
189
190
191 \setindex{main}\index{time!here@now}
192
193 % When you are sure there is an entry \index{\"U...}.
194 \index{\"U@\indexcapstyle{\"U}\gobblepageref}%
195
196 \index{\"Uber}%
197 \index{\"Uberhaupt}%
198
199 % There is a nerdy way:
200 \index{\"N@\protect\nxtletre \protect\def \nwletre {\"O}\gobblepageref}
201 \index{\"P@\relax\gobblepageref}
202
203 % Now look what happens if you leave out the next line
204 \index{\"Osterreich}
205
206 % Similarly
207 \index{\A>@\protect\nxtletre \protect\def \nwletre {\AA}\gobblepageref}
208 \index{\AB@\relax\gobblepageref}
209
210 \index{\AA ngstrom}
211
212
213
214 \setindex{b1}\index{page range!risky@this $\vert$is$\vert$ complicated|)textbf}
215
216
217 \index{page range|)textit}%
218
219 %\sindex[b1]{page range!risky@this $\vert$is$\vert$ complicated|textbf}
220
221 %
222 \index{page range!with risky label\label{range}}
223 % This label actually works and was used above in a \pageref{range} command.
224 %
225 \sindex[b1]{simpler!page range|)}%
226 \index{simplest page range|)}%
227
228
229 % If you want the index in the table of contents, you may do
230 %
231 % \clearpage
232 % \phantomsection
233 % \addcontentsline{toc}{chapter}{\indexname}
234 %
235 % We have a command for this:
236
237 \indexincontents % before \printindex
238
239
240
241 \renewcommand{\indexname}{Index}
242 \setindex{main}
243 \printindex
244
245 \sindex[b1]{page range!risky@this $\vert$is$\vert$ complicated|textbf}
246
247 \renewcommand{\indexname}{Index bis}
248 \setindex{bis}
249 \printindex
250
251
252 \renewcommand{\indexname}{Index with tag a1}
253 \setindex{a1}
254 \printindex
255
256
257 \renewcommand{\indexname}{Index with tag b1}
258 \setindex{b1}
259 \printindex
260 \subsection*{Embellishment}
261 The command \verb!\indexcapstyle!
262 takes one argument. Its original definition is \verb!\newcommand{\indexcapstyle}[1]{\indexspace}!.
263
264 One may embellish an index with letter headings, like this.\\
265
266 \setindex{main}\index{animal!ruminant!cow}
267
268
269 \verb!\renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}!%
270
271
272 \verb!\printindex[main][Index with headings]! \\
273
274 \noindent This gives
275
276
277
278 \renewcommand{\indexcapstyle}[1]{\indexspace\textsc{#1}\par}
279 \printindex[main][Index with headings]
280
281
282
283 \end{document}
284