Debian Codegraph @

texmf-dist/doc/latex/testidx/testidx-manual.tex

raw
1 \documentclass[widecs]{nlctdoc}
2
3 \usepackage[marginpar=1in]{geometry}
4 \usepackage[T1]{fontenc}
5 \usepackage[utf8]{inputenc}
6
7 \usepackage{metalogo}
8 \usepackage{cmap}
9 \usepackage{upquote}
10 \usepackage{testidx}
11 \usepackage[colorlinks,
12 bookmarks,
13 hyperindex=false,
14 pdfauthor={Nicola L.C. Talbot},
15 pdftitle={testidx.sty: dummy text for testing indexes},
16 pdfkeywords={LaTeX,package,dummy text}]{hyperref}
17
18
19 \IndexPrologue{\section*{\indexname}
20 \addcontentsline{toc}{section}{\indexname}%
21 \markboth{\indexname}{\indexname}}
22
23 \setcounter{IndexColumns}{2}
24
25 \renewcommand*{\main}[1]{\hyperpage{#1}}
26 \renewcommand*{\usage}[1]{\hyperpage{#1}}
27
28 \begin{document}
29
30 \title{testidx.sty v1.2:
31 dummy text for testing indexes}
32 \author{Nicola L.C. Talbot\\[10pt]
33 \url{http://www.dickimaw-books.com/}}
34
35 \date{2019-09-29}
36 \maketitle
37 \tableofcontents
38
39 \section{Introduction}
40 \label{sec:intro}
41
42 The \styfmt{testidx} package is for testing indexes (\cs{index},
43 \env{theindex} and indexing applications, such as \app{makeindex}
44 and \app{xindy}). See also
45 \href{http://tug.org/TUGboat/tb38-3/tb120talbot.pdf}{Testing
46 indexes: \texttt{testidx.sty}} in
47 \href{http://tug.org/TUGboat/Contents/contents38-3.html}{TUGboat issue 38:3, 2017}.
48
49 As with packages like \sty{lipsum} and \sty{blindtext}, this package
50 provides dummy text, but it's interspersed with \cs{index} commands.
51 The filler text is mostly English not lorum ipsum, as this makes it
52 slightly easier to check the words in the index against the words in
53 the document. (For those who don't understand English, it's at least
54 no worse than lorum ipsum.) There are some terms (words, phrases or proper
55 nouns) that include extended Latin characters or digraphs to allow
56 for testing with a variety of Latin alphabets. The dummy text is
57 designed to cause problems that can occur in real documents to help
58 test your chosen indexing application or index style. The main
59 issues this package tries to replicate are:
60 \begin{itemize}
61 \item Multiple encaps. For example, the word \qt{paragraph} is
62 indexed within the same block using no encap and each of the three
63 test encap values. This causes the \app{makeindex} warning
64 \qt{Conflicting entries: multiple encaps for the same page under
65 same key.}
66
67 \item An explicit range formation conflicting with a mid-range encap.
68 The word \qt{range} has an explicit range formation (starting in
69 block~4 and ending in block~9), but \qt{range} is also indexed in
70 block~5 with one of the test encap values. This causes the
71 \app{makeindex} warning \qt{Inconsistent page encapsulator \ldots\
72 within range.}
73
74 \item Page breaking mishaps. This is largely dependent on the font
75 size and page geometry, but the dummy text contains some long
76 paragraphs and has enough entries to result in at least some awkward
77 page breaks. These may include a page or column break between an
78 index group heading and the first entry in that group or between an
79 index item and the first sub-item following it. Also check for
80 indexing that occurs in paragraphs that span page breaks to ensure
81 the location number is correct.
82
83 \item Untidy page lists. This again depends on the font size and
84 page geometry, but some entries are sporadically indexed throughout
85 the dummy text, which can lead to a long list that can't be formed
86 into a neat range.
87
88 \item Mid-list cross-referencing. The word \qt{lyuk} is indexed
89 and then cross-referenced in block~3, and indexed again in block~7.
90 This can result in the rather odd occurrence of a cross-reference
91 appearing in the middle of the location list for that entry, depending on the
92 indexing method.
93
94 \item Collation-level homographs. (Same spelling except for
95 accents.) The words \qt{resume}
96 and \qt{r\'esum\'e} are both indexed. These should be treated as
97 separate entries in the index, even if the comparator considers
98 them identical. Different indexing methods may
99 produce different ordering or may even merge the two words, so check
100 they are both present.
101
102 \item Compound entries. The index contains a mixture of
103 single words, compound words, names, titles and phrases. The ordering may vary
104 depending on the sorting method. For example, check the ordering
105 of \qt{sea}, \qt{sea lion}, \qt{seaborne} and \qt{seal}, and
106 also the words starting with \qt{vice}, such as \qt{vice admiral},
107 \qt{viceroy} and \qt{vice-president}.
108
109 \item Long entries can cause awkward line breaks and justification
110 in a multicolumn index with narrow columns.
111
112 \item Interference caused by whatsits. Block~8 has a whatsit caused
113 by the indexing that interferes with limits of a summation in an
114 equation.
115
116 \item Symbols and numbers that don't have a natural word order.
117 The numbers may or may not be ordered numerically, depending on the
118 indexing method.
119
120 \item An item with just a single sub-item. (Perhaps the document
121 author intended to index more sub-items but they weren't needed in
122 the end.) Ideally this needs to be flagged and have the hierarchy
123 removed. There are actually two lonely sub-items. The first is
124 \qt{properties} as a sub-item of \qt{document}. In this case the
125 parent \qt{document} has also been indexed and has a location. The
126 second is \qt{lonely} as a sub-item of \qt{sub-items}. In this case
127 the parent \qt{sub-items} hasn't been indexed and so doesn't have a
128 location.
129 \end{itemize}
130 In addition, words containing extended Latin characters, digraphs and a
131 trigraph are indexed to help test various Latin alphabets, such as
132 Swedish, Icelandic, Welsh, Dutch, Polish and Hungarian. These may or
133 may not be recognised by indexing applications.
134
135 As from version 1.1, \sty{testidx} now comes with a supplementary package
136 \sty{testidx-glossaries} which provides a similar way of testing the
137 \sty{glossaries} or \sty{glossaries-extra} package.
138
139 Example document:
140 \begin{verbatim}
141 \documentclass{article}
142
143 \usepackage{makeidx}
144 \usepackage{testidx}
145
146 \makeindex
147
148 \begin{document}
149 \testidx
150 \printindex
151 \end{document}
152 \end{verbatim}
153
154 If the document is called, say, \texttt{myDoc.tex}, then
155 the PDF can be built using:
156 \begin{verbatim}
157 pdflatex myDoc
158 makeindex myDoc.idx
159 pdflatex myDoc
160 \end{verbatim}
161
162 \begin{important}
163 There will be warnings about multiple encaps. This is intentional
164 to test how the indexing applications deal with this problem.
165 \end{important}
166
167 Note that as from 2018, \LaTeX\ now automatically provides limited
168 UTF-8 support even if the document doesn't load \sty{inputenc}. Therefore
169 the above document will use the ASCII indexing tests with pre-2018
170 \LaTeX, but will use the UTF-8 indexing tests with newer versions of
171 the \LaTeX\ kernel (because \cs{inputencodingname} is now defined as
172 \texttt{utf8}). If you specifically want to test ASCII indexing
173 then you either need to switch to ASCII encoding:
174 \begin{verbatim}
175 \usepackage[ascii]{inputenc}
176 \usepackage{makeidx}
177 \usepackage{testidx}
178 \end{verbatim}
179 or use \sty{testidx}'s \pkgopt{ascii} option:
180 \begin{verbatim}
181 \usepackage{makeidx}
182 \usepackage[ascii]{testidx}
183 \end{verbatim}
184
185 If you want to use \app{xindy}, you'll need to define the
186 attributes (encaps) used in the dummy text. For example:
187 \begin{verbatim}
188 \documentclass{article}
189
190 \usepackage{filecontents}
191 \usepackage[T1]{fontenc}
192 \usepackage[utf8]{inputenc}
193 \usepackage{makeidx}
194 \usepackage{testidx}
195
196 \begin{filecontents*}{\jobname.xdy}
197 ; list of allowed attributes
198
199 (define-attributes ((
200 "tstidxencapi"
201 "tstidxencapii"
202 "tstidxencapiii"
203 )))
204
205 ; define format to use for locations
206
207 (markup-locref :open "\tstidxencapi{"
208 :close "}"
209 :attr "tstidxencapi")
210
211 (markup-locref :open "\tstidxencapii{"
212 :close "}"
213 :attr "tstidxencapii")
214
215 (markup-locref :open "\tstidxencapiii{"
216 :close "}"
217 :attr "tstidxencapiii")
218
219 (markup-locref-list :sep ", ")
220 (markup-range :sep "--")
221 \end{filecontents*}
222
223 \makeindex
224
225 \begin{document}
226 \testidx
227
228 \printindex
229 \end{document}
230 \end{verbatim}
231
232 If this document is called, say, \texttt{myDoc.tex} then the
233 build process is:
234 \begin{verbatim}
235 pdflatex myDoc
236 xindy -L english -C utf8 -M myDoc.xdy -M texindy -t myDoc.ilg myDoc.idx
237 pdflatex myDoc
238 \end{verbatim}
239 You can substitute \texttt{english} for another language (for
240 example, \texttt{swedish} or \texttt{danish}) to test how the
241 extended Latin characters are sorted for a particular language.
242
243 \XeLaTeX\ can be used instead:
244 \begin{verbatim}
245 \documentclass{article}
246
247 \usepackage{filecontents}
248 \usepackage{fontspec}
249 \usepackage{makeidx}
250 \usepackage{testidx}
251
252 \begin{filecontents*}{\jobname.xdy}
253 ; list of allowed attributes
254
255 (define-attributes ((
256 "tstidxencapi"
257 "tstidxencapii"
258 "tstidxencapiii"
259 )))
260
261 ; define format to use for locations
262
263 (markup-locref :open "\tstidxencapi{"
264 :close "}"
265 :attr "tstidxencapi")
266
267 (markup-locref :open "\tstidxencapii{"
268 :close "}"
269 :attr "tstidxencapii")
270
271 (markup-locref :open "\tstidxencapiii{"
272 :close "}"
273 :attr "tstidxencapiii")
274
275 (markup-locref-list :sep ",")
276 (markup-range :sep "--")
277 \end{filecontents*}
278
279 \makeindex
280
281 \begin{document}
282 \testidx
283
284 \printindex
285 \end{document}
286
287 \end{verbatim}
288 The build process is now:
289 \begin{verbatim}
290 xelatex myDoc
291 xindy -L english -C utf8 -M myDoc.xdy -M texindy -t myDoc.ilg myDoc.idx
292 xelatex myDoc
293 \end{verbatim}
294 (Similarly for \LuaLaTeX.)
295
296 If you want to use \app{makeindex}'s \texttt{-g} option (German)
297 you can use the package option \pkgopt{german} or \pkgopt{ngerman},
298 which will change the \app{makeindex} quote character to
299 \texttt{+} but remember you need to add this to a style file.
300 For example:
301 \begin{verbatim}
302 \documentclass{article}
303
304 \usepackage{filecontents}
305 \usepackage{makeidx}
306 \usepackage{ngerman}
307 \usepackage[german,ascii]{testidx}
308
309 \begin{filecontents*}{\jobname.ist}
310 quote '+'
311 \end{filecontents*}
312
313 \makeindex
314
315 \begin{document}
316 \testidx
317
318 \printindex
319 \end{document}
320 \end{verbatim}
321 This document can be built using:
322 \begin{verbatim}
323 pdflatex myDoc
324 makeindex -g -s myDoc.sty myDoc.idx
325 pdflatex myDoc
326 \end{verbatim}
327 (Note the different position of the \qt{Numbers} group
328 in the index.)
329
330 Alternatively:
331 \begin{verbatim}
332 \documentclass[ngerman]{article}
333
334 \usepackage{filecontents}
335 \usepackage{makeidx}
336 \usepackage{babel}
337 \usepackage[ascii]{testidx}
338
339 \begin{filecontents*}{\jobname.ist}
340 quote '+'
341 \end{filecontents*}
342
343 \makeindex
344
345 \begin{document}
346 \testidx
347
348 \printindex
349 \end{document}
350 \end{verbatim}
351
352 The \styfmt{testidx-glossaries} package automatically loads
353 \styfmt{testidx} and will also load either \sty{glossaries} or
354 \sty{glossaries-extra}. For example:
355 \begin{verbatim}
356 \documentclass{report}
357
358 \usepackage[T1]{fontenc}
359 \usepackage[ascii]{testidx-glossaries}
360
361 \renewcommand*{\glstreenamefmt}[1]{#1}
362
363 \tstidxmakegloss
364
365 \begin{document}
366
367 \testidx
368
369 \tstidxprintglossaries
370
371 \end{document}
372 \end{verbatim}
373 This automatically sets the \texttt{mcolsindexgroup} glossary style
374 to mimic the style commonly used with indexes.
375 This document can be built using:
376 \begin{verbatim}
377 pdflatex myDoc
378 makeglossaries myDoc
379 pdflatex myDoc
380 \end{verbatim}
381 Note that the \texttt{mcolsindexgroup} style sets the \texttt{name}
382 field in \cs{glstreenamefmt}, which defaults to bold. This has been
383 redefined in the above example to simply do its argument.
384
385 \section{Package Options}
386 \label{sec:pkgopt}
387
388 \subsection{\texorpdfstring{\styfmt{testidx}}{testidx} options}
389 \label{sec:testidxpkgopt}
390
391 The following package options are provided:
392 \begin{description}
393 \item[\pkgopt{ascii}] Use only ASCII tests even if the document
394 supports UTF-8. Any characters outside
395 that range are produced with \LaTeX\ commands.
396
397 \item[\pkgopt{noascii}] (Default.) Don't enforce ASCII tests. This option
398 doesn't actually provide UTF-8 support but will simply
399 determine whether or not to use ASCII tests depending on the
400 document's input encoding.
401
402 \item[\pkgopt{german} or \pkgopt{ngerman}]
403 This redefines the indexing \qt{quote} character to use \texttt{+}
404 instead of the double-quote character. Remember to add this
405 to your style file and call \app{makeindex} with the
406 \texttt{-g} (German) switch. (See example above in
407 the previous section.) This option may also be implemented
408 using
409 \begin{definition}[\DescribeMacro\testidxGermanOn]
410 \cs{testidxGermanOn}
411 \end{definition}
412
413 \item[\pkgopt{nogerman}]
414 Counteract the effect of the previous option.
415 This option may also be implemented using
416 \begin{definition}[\DescribeMacro\testidxGermanOff]
417 \cs{testidxGermanOff}
418 \end{definition}
419
420 \item[\pkgopt{stripaccents}]
421 Strips accent commands from the sort key when using the
422 ASCII option (see \sectionref{sec:exlatin}).
423 This option may also be implemented using
424 \begin{definition}[\DescribeMacro\testidxStripAccents]
425 \cs{testidxStripAccents}
426 \end{definition}
427 Note that the \pkgopt{german} or \pkgopt{ngerman} package option
428 won't strip the umlaut accent when used with this option.
429
430 \item[\pkgopt{nostripaccents}]
431 Doesn't strip accent commands from the sort key when using the
432 ASCII option (see \sectionref{sec:exlatin}).
433 This option may also be implemented using
434 \begin{definition}[\DescribeMacro\testidxNoStripAccents]
435 \cs{testidxNoStripAccents}
436 \end{definition}
437
438 \item[\pkgopt{sanitize}]
439 Sanitize the terms before indexing them when using
440 the UTF-8 option to prevent the UTF-8 characters from being
441 expanded to \sty{inputenc}'s internal macros such as \cs{IeC}.
442 This option is the default unless \XeLaTeX\ or \LuaLaTeX\
443 are in use.
444 This option may also be implemented using
445 \begin{definition}[\DescribeMacro\testidxSanitizeOn]
446 \cs{testidxSanitizeOn}
447 \end{definition}
448
449 \item[\pkgopt{nosanitize}]
450 Don't sanitize the terms before indexing them when using
451 the UTF-8 option.
452 This option may also be implemented using
453 \begin{definition}[\DescribeMacro\testidxSanitizeOff]
454 \cs{testidxSanitizeOff}
455 \end{definition}
456 Note that as from \LaTeX\ 2019/10/01 UTF-8 characters are no longer
457 expanded while they are written to the \texttt{.idx} file. This
458 means that there may be no difference between \pkgopt{sanitize} and
459 \pkgopt{nosanitize} depending on the \LaTeX\ kernel in use.
460
461 \item[\pkgopt{showmarks}]
462 (Default.) Show the location of the \cs{index} commands
463 in the dummy text with markers.
464 This option may also be implemented using
465 \begin{definition}[\DescribeMacro\testidxshowmarkstrue]
466 \cs{testidxshowmarkstrue}
467 \end{definition}
468
469 \item[\pkgopt{hidemarks} or \pkgopt{noshowmarks}]
470 Hide the markers.
471 This option may also be implemented using
472 \begin{definition}[\DescribeMacro\testidxshowmarksfalse]
473 \cs{testidxshowmarksfalse}
474 \end{definition}
475
476 \item[\pkgopt{verbose}]
477 Show the actual indexing commands within the dummy text.
478 This will most likely cause a high number of overfull lines.
479 This option may also be implemented using
480 \begin{definition}[\DescribeMacro\testidxverbosetrue]
481 \cs{testidxverbosetrue}
482 \end{definition}
483
484 \item[\pkgopt{noverbose}]
485 (Default.) Cancel the \pkgopt{verbose} option.
486 This option may also be implemented using
487 \begin{definition}[\DescribeMacro\testidxverbosefalse]
488 \cs{testidxverbosefalse}
489 \end{definition}
490
491 \item[\pkgopt{notestencaps}]
492 Suppress the testing of the encaps. Note that this only affects
493 the commands used within \ics{testidx}, which have an optional
494 argument to specify the encap. Some of these commands have the
495 default value of the optional argument set to one of the test
496 encaps. This option changes the command definition so that the
497 optional argument is blank. Therefore this setting can only
498 be used as a package option. However, this doesn't prevent
499 you from explicitly testing an encap either directly using
500 \ics{index} (e.g.\ \verb"\index{word|emph}") or implicitly
501 using one of the helper commands described in the documented
502 code (e.g.\ \verb"\tstidxsty[emph]{testidx}").
503
504 \item[\pkgopt{testencaps}]
505 (Default.) Cancels the \pkgopt{notestencaps} option.
506 This option ensures that \ics{testidx} uses the three test
507 encaps.
508
509 \item[\pkgopt{prefix}]
510 (Default.) Inserts a prefix in the sort value for certain (symbol) entries to
511 keep them together in the index. These entries represent markers
512 (prefixed with \ics{tstidxindexmarkerprefix}) and maths symbols (prefixed with
513 \ics{tstidxmathsymprefix}).
514
515 \item[\pkgopt{noprefix}]
516 Doesn't insert a prefix for the markers and maths symbol entries.
517 This option doesn't alter the entries starting with a
518 hyphen (such as \texttt{-l}) which always have that prefix
519 since it's part of the display name.
520
521 \item[\pkgopt{diglyphs}]
522 Words with \tstidxqt{ll}, \tstidxqt{ij} and \tstidxqt{dz} digraphs
523 will have the two characters forming the digraph replaced with a
524 single UTF-8 glyph. This option only works if UTF-8 is supported
525 \emph{and the document font recognises the glyphs}. (The trigraph
526 \tstidxqt{dzw} and other digraphs,
527 such as \tstidxqt{th} aren't affected by this option.)
528
529 \item[\pkgopt{nodiglyphs}]
530 (Default.) Don't use single glyphs for the \tstidxqt{ll},
531 \tstidxqt{ij} and \tstidxqt{dz} digraphs. (This option doesn't
532 affect other glyphs, such as \ae\ or \th, that are more commonly
533 used in some languages.)
534 \end{description}
535
536 \subsection{\texorpdfstring{\styfmt{testidx-glossaries}}{testidx-glossaries}
537 options}
538 \label{sec:testidxglospkgopt}
539
540 Most of the package options provided by \styfmt{testidx} can also be
541 used with \styfmt{testidx-glossaries}. The \pkgopt{verbose} option
542 has a slightly different effect. With \styfmt{testidx}, that option
543 shows the indexing command within the text. However, the
544 \sty{glossaries} package requires entries to first be defined and
545 doesn't use \cs{index} but uses its own internal custom commands
546 that depend on the indexing method, so for
547 \styfmt{testidx-glossaries}, the \pkgopt{verbose} option instead
548 writes information in the transcript file (\texttt{.log}) when the
549 dummy entries are defined. For example:
550 \begin{verbatim}
551 Package testidx-glossaries Info: new term label={packages},
552 (testidx-glossaries) name={packages},
553 (testidx-glossaries) text={packages},
554 (testidx-glossaries) parent={},
555 (testidx-glossaries) see={}
556 (testidx-glossaries) on input line 1.
557 \end{verbatim}
558 When used with the \pkgopt{tex} option, the \pkgopt{verbose}
559 option will additionally write information while \TeX\ is
560 sorting, since this can take a while and may give the appearance
561 that the build process has hung.
562
563 When used with the \pkgopt{bib2gls} option, the \pkgopt{verbose}
564 option will show the syntax used by \ics{tstidxmakegloss}
565 to load each resource. If you search the \texttt{.log} file for
566 instances of \ics{GlsXtrLoadResource}, you'll find the commands
567 needed to replicate the behaviour of \cs{tstidxmakegloss}.
568
569 In addition to the options listed above, the following options are
570 also available for \styfmt{testidx-glossaries}:
571 \begin{description}
572 \item[\pkgopt{extra}]
573 Load the \sty{glossaries-extra} package.
574
575 \item[\pkgopt{noextra}]
576 Don't load the \sty{glossaries-extra} package. Just load the
577 base \sty{glossaries} package. (Default.)
578
579 \item[\pkgopt{makeindex}]
580 (Default.) Passes the \pkgopt{makeindex} option to
581 \sty{glossaries}. This option also sets up \ics{tstidxmakegloss}
582 to use \ics{makeglossaries}, \ics{tstidxprintglossaries} to use
583 \ics{printglossaries} and \ics{tstidxprintglossary} to use
584 \ics{printglossary}. Use \app{makeglossaries} (or
585 \app{makeglossaries-lite}) in the build process.
586
587 \item[\pkgopt{xindy}] Passes the \pkgopt{xindy} option to
588 \sty{glossaries}. This option also sets up \ics{tstidxmakegloss}
589 to use \ics{makeglossaries}, \ics{tstidxprintglossaries} to use
590 \ics{printglossaries} and \ics{tstidxprintglossary} to use
591 \ics{printglossary}. Use \app{makeglossaries} (or
592 \app{makeglossaries-lite}) in the build process.
593
594 \item[\pkgopt{tex}] This option also sets up \ics{tstidxmakegloss}
595 to use \ics{makenoidxglossaries}, \ics{tstidxprintglossaries} to use
596 \ics{printnoidxglossaries} and \ics{tstidxprintglossary} to use
597 \ics{printnoidxglossary}. (\TeX\ is used for to sort and collate the
598 entries. Don't use \app{makeglossaries} or \app{makeglossaries-lite}
599 in the build process.)
600
601 \item[\pkgopt{bib2gls}] Passes the \pkgopt{record} option to
602 \sty{glossaries-extra}. (This option automatically implements the
603 \pkgopt{extra} option.) This option also sets up
604 \ics{tstidxmakegloss} to use \ics{GlsXtrLoadResources},
605 \ics{tstidxprintglossaries} to use
606 \ics{printunsrtglossaries} and \ics{tstidxprintglossary} to use
607 \ics{printunsrtglossary}. Use \app{bib2gls} in the build process.
608 Note that this option ignores the commands
609 \ics{tstidxindexmarkerprefix} and \ics{tstidxmathsymprefix}.
610
611 \item[\pkgopt{manual}] Indicates that the test document
612 doesn't use \cs{tstidxmakegloss}. (This disables the check
613 that ensures that command has been used.) Use this option if you
614 want to customize the glossary set-up. This option may be used in
615 addition to the above options, but it will disable
616 \cs{tstidxmakegloss}, \cs{tstidxprintglossary} and
617 \cs{tstidxprintglossaries}.
618
619 The sample files can be loaded using
620 \begin{definition}[\DescribeMacro\tstidxloadsamples]
621 \cs{tstidxloadsamples}
622 \end{definition}
623 (which \cs{tstidxmakegloss} does implicitly) except in the case of
624 \pkgopt{bib2gls} where the sample files need to be loaded in
625 \cs{GlsXtrLoadResource}.
626
627 \item[\pkgopt{seekey}]
628 (Default.)
629 Use the \texttt{see} key for cross-references instead of using \ics{glssee}.
630 If the \texttt{seealso} key has been defined (\sty{glossaries-extra}
631 v1.16+), then this will be used for the \qt{see also}
632 cross-references (otherwise \verb|see=[\seealsoname]|\marg{label}
633 will be used).
634
635 \item[\pkgopt{noseekey}]
636 Use \ics{glssee} for cross-references and don't set the \texttt{see}
637 (or \texttt{seealso}) key.
638
639 \item[\pkgopt{noglsnumbers}] Passes the \pkgopt{glsnumbers=false} option to
640 \sty{glossaries}.
641
642 \item[\pkgopt{glsnumbers}] Passes the \pkgopt{glsnumbers=true} option to
643 \sty{glossaries}. (This is the default for the \sty{glossaries}
644 package.)
645
646 \item[\pkgopt{desc}] Provide descriptions for the dummy entries.
647 This setting automatically implements the \sty{glossaries}
648 package's \pkgopt{nopostdot=false} option and sets the
649 \texttt{indexgroup} glossary style.
650
651 \item[\pkgopt{nodesc}]
652 (Default.) Don't provide descriptions for the dummy entries.
653 (The \texttt{description} field is set to empty.)
654 This setting automatically implements the \sty{glossaries}
655 package's \pkgopt{nopostdot} option and sets the
656 \texttt{mcolindexgroup} glossary style. (The \sty{glossary-mcols} package
657 is automatically loaded.)
658 \end{description}
659
660 Both the \texttt{mcolindexgroup} and \texttt{indexgroup} styles set
661 the \texttt{name} field in \ics{glstreenamefmt}, which by default
662 uses \cs{textbf}. This can be redefined as appropriate.
663 You can switch to a different glossary style using
664 \cs{setglossarystyle}\marg{style-name}.
665
666 \section{Basic Commands}
667 \label{sec:basic}
668
669 This section only covers the basic commands provided by
670 \styfmt{testidx} and \styfmt{testidx-glossaries}.
671 For more advanced commands, see the documented code.
672
673 \begin{definition}[\DescribeMacro\testidx]
674 \cs{testidx}\oarg{blocks}
675 \end{definition}
676 This is the principle command provided by the \sty{testidx} package. It
677 generates the predefined dummy text that's interspersed
678 with indexing commands. (The text varies slightly according to the
679 document settings.) There are \number\tstidxmaxblocks\
680 blocks in total. This number can be accessed through the register:
681 \begin{definition}[\DescribeMacro\tstidxmaxblocks]
682 \cs{tstidxmaxblocks}
683 \end{definition}
684
685 If the optional argument \oarg{blocks} is omitted, all the blocks
686 will be used. Each block starts with a number identifying it.
687 This number prefix is formatted using:
688 \begin{definition}[\DescribeMacro\tstidxprefixblock]
689 \cs{tstidxprefixblock}\marg{n}
690 \end{definition}
691 where \meta{n} is the block number. If you want to suppress the
692 number prefix, just redefine this command to ignore its argument.
693
694 By default, the blocks are separated by a paragraph break.
695 If the starred form is used, the blocks are separated by a~space.
696 Note that some of the blocks contain paragraph breaks for
697 displayed material. The starred form won't eliminate
698 paragraph breaks \emph{within} the blocks, just those
699 used as separators between the blocks.
700
701 If you use \sty{testidx-glossaries}, you additionally need
702 \begin{definition}[\DescribeMacro\tstidxmakegloss]
703 \cs{tstidxmakegloss}\oarg{options}
704 \end{definition}
705 in the preamble. This loads the files that provide the dummy entries
706 and uses \cs{makeglossaries} or \cs{makenoidxglossaries} or
707 \cs{GlsXtrLoadResources} depending on the package options. The
708 optional argument \meta{options} is appended to the optional argument of
709 \cs{GlsXtrLoadResources} if the \pkgopt{bib2gls} package option has
710 been used, otherwise \meta{options} is ignored.
711
712 To display the glossary, either use
713 \begin{definition}[\DescribeMacro\tstidxprintglossaries]
714 \cs{tstidxprintglossaries}
715 \end{definition}
716 or
717 \begin{definition}[\DescribeMacro\tstidxprintglossary]
718 \cs{tstidxprintglossary}\marg{options}
719 \end{definition}
720 where you want the glossary to be displayed. This will use the
721 appropriate command according to the package set up.
722
723 The intention of the dummy text is to provide an index that should
724 typically span at least three pages for A4 or letter paper, to allow
725 testing of headers and footers across a double-paged spread and to
726 test the effects of page breaking. Some of the indexing commands intentionally
727 cause warnings from \app{makeindex} to test for certain situations.
728 Phrases are indexed as well as just individual words to increase the
729 chances of indexed terms spanning a page break. However, the page
730 dimensions, fonts and other material in the document will obviously
731 alter where the page breaks occur.
732
733 You can display only a subset of the blocks using the optional
734 argument, which may be a comma-separated list of block identifiers
735 or hyphen-separated range. Note that some of the blocks contain the
736 start or end of an indexing range. If you only display a subset
737 of the blocks that contains any of these, you need to make
738 sure that you include the blocks that contain matching open
739 and closing ranges (unless you're testing for mis-matched ranges).
740
741 The optional argument may be a mixture of individual block
742 identifiers and ranges. Examples:
743 \begin{enumerate}
744 \item Just display block~6:
745 \begin{verbatim}
746 \testidx[6]
747 \end{verbatim}
748 \item Display blocks~4 to 6:
749 \begin{verbatim}
750 \testidx[4-6]
751 \end{verbatim}
752 \item Display blocks~1, 4 to 6, and the last block:
753 \begin{verbatim}
754 \testidx[1,4-6,\tstidxmaxblocks]
755 \end{verbatim}
756 \item Intersperse the blocks with sections:
757 \begin{verbatim}
758 \section{Sample}
759 \testidx[1-6]
760 \section{Another Sample}
761 \testidx[7-\tstidxmaxblocks]
762 \end{verbatim}
763 \end{enumerate}
764
765 If for some bizarre and wacky reason you want the blocks
766 in the reverse order, you can do so. For example:
767 \begin{verbatim}
768 \testidx[\tstidxmaxblocks-1]
769 \end{verbatim}
770 However the open and close range formations are likely to
771 confuse \app{makeindex}\slash\app{xindy}, but perhaps that's
772 your intention. Just remember to stay within the range
773 1--\cs{tstidxmaxblocks} as you'll get an error if you
774 go out of those bounds.
775
776 With just \sty{testidx}, the actual indexing is performed using:
777 \begin{definition}[\DescribeMacro\tstindex]
778 \cs{tstindex}\marg{text}
779 \end{definition}
780 This defaults to just \cs{index}\marg{text} but may be redefined. For
781 example, if you are testing multiple indexes, you can
782 redefine \cs{tstindex} to use a specific index.
783
784 With \sty{testidx-glossaries}, the above command isn't used.
785 Instead \cs{gls}, \cs{glspl}, \cs{glsadd} or \cs{glssee} will be
786 used depending on the context.
787
788 The dummy text includes markers to identify where the instances
789 of \cs{tstindex} have been used. To reduce the possibility of
790 package conflict, \styfmt{testidx} loads a bare minimum of
791 packages\footnote{only \sty{color}, \sty{ifxetex} and
792 \sty{ifluatex} are loaded}
793 and tries to rely as much as possible on \LaTeX\ kernel
794 commands, so the markers are fairly primitive. If you prefer
795 fancier markers, you can change them by redefining the
796 commands listed below. Multiple markers in the dummy text
797 indicate multiple instances of \cs{tstindex} without any
798 intervening text. (Naturally, \sty{testidx-glossaries} requires more
799 packages as it loads \sty{glossaries}, and possibly also
800 \sty{glossaries-extra}.)
801
802 \begin{definition}[\DescribeMacro\tstidxmarker]
803 \cs{tstidxmarker}
804 \end{definition}
805 This is the marker used to show an instance of \cs{tstindex}
806 for a top-level entry that doesn't start or end a range.
807 Default: \tstidxmarker
808
809 \begin{definition}[\DescribeMacro\tstidxopenmarker]
810 \cs{tstidxopenmarker}
811 \end{definition}
812 This is the marker used to show an instance of \cs{tstindex}
813 for a top-level entry that starts a range.
814 Default: \tstidxopenmarker
815
816 \begin{definition}[\DescribeMacro\tstidxclosemarker]
817 \cs{tstidxclosemarker}
818 \end{definition}
819 This is the marker used to show an instance of \cs{tstindex}
820 for a top-level entry that ends a range.
821 Default: \tstidxclosemarker
822
823 \begin{definition}[\DescribeMacro\tstidxsubmarker]
824 \cs{tstidxsubmarker}
825 \end{definition}
826 This is the marker used to show an instance of \cs{tstindex}
827 for a sub-entry that doesn't start or end a range.
828 Default: \tstidxsubmarker
829
830 \begin{definition}[\DescribeMacro\tstidxopensubmarker]
831 \cs{tstidxopensubmarker}
832 \end{definition}
833 This is the marker used to show an instance of \cs{tstindex}
834 for a sub-entry that starts a range.
835 Default: \tstidxopensubmarker
836
837 \begin{definition}[\DescribeMacro\tstidxclosesubmarker]
838 \cs{tstidxclosesubmarker}
839 \end{definition}
840 This is the marker used to show an instance of \cs{tstindex}
841 for a sub-entry that ends a range.
842 Default: \tstidxclosesubmarker
843
844 \begin{definition}[\DescribeMacro\tstidxsubsubmarker]
845 \cs{tstidxsubsubmarker}
846 \end{definition}
847 This is the marker used to show an instance of \cs{tstindex}
848 for a sub-sub-entry that doesn't start or end a range.
849 Default: \tstidxsubsubmarker
850
851 \begin{definition}[\DescribeMacro\tstidxopensubsubmarker]
852 \cs{tstidxopensubsubmarker}
853 \end{definition}
854 This is the marker used to show an instance of \cs{tstindex}
855 for a sub-sub-entry that starts a range.
856 Default: \tstidxopensubsubmarker
857
858 \begin{definition}[\DescribeMacro\tstidxclosesubsubmarker]
859 \cs{tstidxclosesubsubmarker}
860 \end{definition}
861 This is the marker used to show an instance of \cs{tstindex}
862 for a sub-sub-entry that ends a range.
863 Default: \tstidxclosesubsubmarker
864
865 \begin{definition}[\DescribeMacro\tstidxseemarker]
866 \cs{tstidxseemarker}
867 \end{definition}
868 This is the marker used to show an instance of \cs{tstindex}
869 that uses a cross-reference. Additionally, the cross-referenced
870 information will appear in a marginal note.
871 Default: \tstidxseemarker
872
873 \begin{definition}[\DescribeMacro\tstidxsubseemarker]
874 \cs{tstidxsubseemarker}
875 \end{definition}
876 This is the marker used to show an instance of \cs{tstindex}
877 that uses a cross-reference in a sub-entry.
878 Default: \tstidxsubseemarker\ (the sub-level and cross-reference
879 markers superimposed, not to be confused with a sub-level marker
880 followed by a cross-reference marker, which indicates
881 consecutive occurrences of \cs{tstindex}).
882 As above the cross-reference information appears in a marginal
883 note. The main term and the sub-entry term are separated with
884 the symbol given by
885 \begin{definition}[\DescribeMacro\tstidxsubseesep]
886 \cs{tstidxsubseesep}
887 \end{definition}
888 which defaults to \tstidxsubseesep
889
890 There are three encap values used:
891 \begin{definition}[\DescribeMacro\tstidxencapi]
892 \cs{tstidxencapi}\marg{location}
893 \end{definition}
894 \begin{definition}[\DescribeMacro\tstidxencapii]
895 \cs{tstidxencapii}\marg{location}
896 \end{definition}
897 \begin{definition}[\DescribeMacro\tstidxencapiii]
898 \cs{tstidxencapiii}\marg{location}
899 \end{definition}
900 By default these just set \meta{location} in a different
901 text colour.
902
903 If you are using \app{xindy}, you'll need to add these
904 to a \texttt{.xdy} file that can be loaded using \app{xindy}'s
905 \texttt{-M} switch. For example, with just \sty{testidx}, include the following
906 in your \texttt{.xdy} file:
907 \begin{verbatim}
908 ; list of allowed attributes
909
910 (define-attributes ((
911 "tstidxencapi"
912 "tstidxencapii"
913 "tstidxencapiii"
914 )))
915
916 ; define format to use for locations
917
918 (markup-locref :open "\tstidxencapi{"
919 :close "}"
920 :attr "tstidxencapi")
921
922 (markup-locref :open "\tstidxencapii{"
923 :close "}"
924 :attr "tstidxencapii")
925
926 (markup-locref :open "\tstidxencapiii{"
927 :close "}"
928 :attr "tstidxencapiii")
929 \end{verbatim}
930 You may also want to add the list and range separators, if you
931 haven't already done so:
932 \begin{verbatim}
933 (markup-locref-list :sep ",")
934 (markup-range :sep "--")
935 \end{verbatim}
936 If you use \sty{testidx-glossaries}, the \sty{glossaries} package
937 provides commands to add information to the automatically generated
938 \texttt{.xdy} file. For example:
939 \begin{verbatim}
940 \GlsAddXdyAttribute{tstidxencapi}
941 \GlsAddXdyAttribute{tstidxencapii}
942 \GlsAddXdyAttribute{tstidxencapiii}
943 \end{verbatim}
944 If you want to provide your own custom cross-reference class
945 you can use
946 \begin{definition}[\DescribeMacro\tstidxSetSeeEncap]
947 \cs{tstidxSetSeeEncap}\marg{encap name}
948 \end{definition}
949 to change the \texttt{see} encap to \meta{encap name} and
950 \begin{definition}[\DescribeMacro\tstidxSetSeeAlsoEncap]
951 \cs{tstidxSetSeeAlsoEncap}\marg{encap name}
952 \end{definition}
953 to change the \texttt{seealso} encap to \meta{encap name}.
954 For example:
955 \begin{verbatim}
956 \tstidxSetSeeAlsoEncap{uncheckedseealso}
957 \end{verbatim}
958 and in the \texttt{.xdy} file:
959 \begin{verbatim}
960 (define-crossref-class "uncheckedseealso" :unverified)
961 (markup-crossref-list :class "uncheckedseealso"
962 :open "\seealso" :close "{}")
963 \end{verbatim}
964 which creates an unverified alternative to \texttt{seealso}.
965
966 The \cs{tstindex} command is sometimes placed before the term
967 or phrase being indexed and sometimes afterwards. To clarify
968 what's being indexed, the adjacent word or phrase is surrounded
969 by
970 \begin{definition}[\DescribeMacro\tstidxtext]
971 \cs{tstidxtext}\marg{text}
972 \end{definition}
973 This defaults to using a dark grey text colour. If an
974 encap has been used, the corresponding encap command (see
975 above) is included within the argument of \cs{tstidxtext}:
976 \begin{definition}
977 \cs{tstidxtext}\{\meta{cs}\marg{text}\}
978 \end{definition}
979 where \meta{cs} is the encap command. This means that with
980 the default definitions, the dark grey text colour will
981 only be visible when there's no encap, as the encap command
982 will override the colour change.
983
984 Note that the marker is included within \meta{text}.
985 Some of the examples have consecutive uses of
986 \cs{tstindex}, such as a top-level entry followed
987 by a sub-entry. For example, a person's name is indexed twice:
988 \begin{verbatim}
989 Donald Knuth\index{Knuth, Donald}\index{people!Knuth, Donald}
990 \end{verbatim}
991 (It's actually done using \verb|\tstidxperson{Donald}{Knuth}|
992 for better consistency. These markup commands typically
993 won't need changing, but if they do, see the documented code
994 for further detail.)
995
996 In the case of \sty{testidx-glossaries}, the above example would be
997 \begin{verbatim}
998 \gls{DonaldKnuth}\glsadd{people.DonaldKnuth}
999 \end{verbatim}
1000 (\cs{index} isn't used).
1001
1002 Example (using just \sty{testidx}):
1003 \begin{verbatim}
1004 \renewcommand*{\tstindex}[1]{}
1005 \textsf{\testidx[1,\tstidxmaxblocks]}
1006 \end{verbatim}
1007 This produces the two paragraphs (first and last blocks) shown below:
1008
1009 \medskip\par
1010 \renewcommand*{\tstindex}[1]{}
1011 \textsf{\testidx[1,\tstidxmaxblocks]}
1012 \par\medskip
1013
1014 Note that I've redefined \cs{tstindex} to ignore its argument
1015 in this document so those terms won't actually be indexed
1016 in this case. The block references (such as \qt{block~1})
1017 in the dummy text don't use the standard
1018 \cs{label}\slash\cs{ref} mechanism as the references must still
1019 work even if the referenced block has been omitted. This
1020 means they won't have hyperlinks even if you include the
1021 \sty{hyperref} package as the target may not be defined.
1022 They are provided primarily so you can easily find out which
1023 blocks need adding if you're only using a subset and need to
1024 close a range.
1025
1026 \section{Indexing Special Characters}
1027 \label{sec:idxspchars}
1028
1029 If you need to change the indexing special characters, you
1030 can redefine the commands listed in this section. Remember
1031 that you will also need to make the relevant changes to your
1032 indexing style file. (These commands only apply to \sty{testidx} not
1033 \sty{testidx-glossaries}.)
1034
1035 \begin{definition}[\DescribeMacro\tstidxquote]
1036 \cs{tstidxquote}
1037 \end{definition}
1038 The \qt{quote} character. The default is: \texttt{\tstidxquote}.
1039 Note that the \pkgopt{german} or \pkgopt{ngerman} package option
1040 will automatically redefine \cs{tstidxquote} to \texttt{+}
1041 (plus).
1042
1043 \begin{definition}[\DescribeMacro\tstidxactual]
1044 \cs{tstidxactual}
1045 \end{definition}
1046 The \qt{actual} character. The default is: \texttt{\tstidxactual}.
1047
1048 \begin{definition}[\DescribeMacro\tstidxlevel]
1049 \cs{tstidxlevel}
1050 \end{definition}
1051 The \qt{level} character. The default is: \texttt{\tstidxlevel}.
1052
1053 \begin{definition}[\DescribeMacro\tstidxencap]
1054 \cs{tstidxencap}
1055 \end{definition}
1056 The \qt{encap} character. The default is: \texttt{\tstidxencap}.
1057
1058 \begin{definition}[\DescribeMacro\tstidxopenrange]
1059 \cs{tstidxopenrange}
1060 \end{definition}
1061 The \qt{open range} character. The default is:
1062 \texttt{\tstidxopenrange}.
1063
1064 \begin{definition}[\DescribeMacro\tstidxcloserange]
1065 \cs{tstidxcloserange}
1066 \end{definition}
1067 The \qt{close range} character. The default is:
1068 \texttt{\tstidxcloserange}.
1069
1070 \section{Extended Latin Characters}
1071 \label{sec:exlatin}
1072
1073 The dummy text includes words or phrases that have extended
1074 Latin characters. (The document encoding should be correctly set
1075 before loading \sty{testidx}.) There are two modes:
1076
1077 \begin{description}
1078 \item[ASCII] This mode is on by default \emph{unless} you are using
1079 \XeLaTeX\ or \LuaLaTeX, or the document has the encoding set to \pkgopt{utf8}.
1080 Note that with new versions of \LaTeX, \cs{inputencodingname} is now
1081 automatically defined as \pkgopt{utf8} by the kernel. You can
1082 explicitly switch this mode on with the \pkgopt{ascii} package
1083 option.
1084
1085 Example that will switch on ASCII mode:
1086 \begin{verbatim}
1087 \documentclass{article}
1088
1089 \usepackage[latin1]{inputenc}
1090 \usepackage{makeidx}
1091 \usepackage{testidx}
1092
1093 \makeindex
1094
1095 \begin{document}
1096 \testidx
1097
1098 \printindex
1099 \end{document}
1100 \end{verbatim}
1101 (With new versions of \LaTeX\ this document will start with
1102 \cs{inputencodingname} set to \texttt{utf8} and then it will be
1103 changed to \texttt{latin1} when \sty{inputenc} is loaded.)
1104
1105 Alternatively use the \pkgopt{ascii} package option:
1106 \begin{verbatim}
1107 \documentclass{article}
1108
1109 \usepackage{makeidx}
1110 \usepackage[ascii]{testidx}
1111
1112 \makeindex
1113
1114 \begin{document}
1115 \testidx
1116
1117 \printindex
1118 \end{document}
1119 \end{verbatim}
1120
1121 \item[UTF-8] This mode is on by default \emph{if} you are using
1122 \XeLaTeX\ or \LuaLaTeX, or if \cs{inputencodingname} is set to \pkgopt{utf8}.
1123
1124 Example that will switch on UTF-8 mode (\XeLaTeX\ or \LuaLaTeX):
1125 \begin{verbatim}
1126 \documentclass{article}
1127
1128 \usepackage{fontspec}
1129 \usepackage{makeidx}
1130 \usepackage{testidx}
1131
1132 \makeindex
1133
1134 \begin{document}
1135 \testidx
1136
1137 \printindex
1138 \end{document}
1139 \end{verbatim}
1140 Or (\sty{inputenc} sets the encoding to UTF-8):
1141 \begin{verbatim}
1142 \documentclass{article}
1143
1144 \usepackage[T1]{fontenc}
1145 \usepackage[utf8]{inputenc}
1146 \usepackage{makeidx}
1147 \usepackage{testidx}
1148
1149 \makeindex
1150
1151 \begin{document}
1152 \testidx
1153
1154 \printindex
1155 \end{document}
1156 \end{verbatim}
1157 Or with new versions of the \LaTeX\ kernel (which automatically
1158 provides UTF-8 support):
1159 \begin{verbatim}
1160 \documentclass{article}
1161
1162 \usepackage[T1]{fontenc}
1163 \usepackage{makeidx}
1164 \usepackage{testidx}
1165
1166 \makeindex
1167
1168 \begin{document}
1169 \testidx
1170
1171 \printindex
1172 \end{document}
1173 \end{verbatim}
1174
1175 If the UTF-8 mode is on, you can additionally use the
1176 \pkgopt{diglyphs} package option to replace the
1177 \tstidxqt{ll}, \tstidxqt{ij} and \tstidxqt{dz} digraphs with
1178 a single glyph, but you'll need a font that supports
1179 those glyphs. (The trigraph \tstidxqt{dzw} and other digraphs,
1180 such as \tstidxqt{th} aren't affected by this option.) For example:
1181 \begin{verbatim}
1182 \documentclass{article}
1183
1184 \usepackage{fontspec}
1185 \setmainfont{Linux Libertine O}
1186
1187 \usepackage{makeidx}
1188 \usepackage[diglyphs]{testidx}
1189
1190 \makeindex
1191
1192 \begin{document}
1193 \testidx
1194
1195 \printindex
1196 \end{document}
1197 \end{verbatim}
1198
1199 \end{description}
1200
1201 When the ASCII mode is on, words or phrases with UTF-8
1202 characters use the standard \LaTeX\ accent commands, such
1203 as \cs{'} (acute accent) or \cs{o} (\o). There are two
1204 package options that determine whether or not to include these
1205 commands in the sort key: \pkgopt{stripaccents} will remove
1206 the accent commands (except for the umlaut shortcut \verb|"|
1207 if the \pkgopt{german} or \pkgopt{ngerman} package option has been
1208 used), and \pkgopt{nostripaccents} will keep the accent commands
1209 in the sort key.
1210
1211 For example, with the ASCII mode on with the \pkgopt{stripaccents}
1212 option, \qt{Anders Jonas \AA ngstr\"om} is indexed as
1213 \begin{verbatim}
1214 Angstrom, Anders Jonas@\AA ngstr\""om, Anders Jonas
1215 \end{verbatim}
1216 unless the \pkgopt{german} or \pkgopt{ngerman} option is on,
1217 in which case it's indexed as
1218 \begin{verbatim}
1219 Angstr"om, Anders Jonas@\AA ngstr"om, Anders Jonas
1220 \end{verbatim}
1221 Whereas with the \pkgopt{nostripaccents} option, this name is
1222 indexed as
1223 \begin{verbatim}
1224 \r Angstr\""om, Anders Jonas@\AA ngstr\""om, Anders Jonas
1225 \end{verbatim}
1226 unless the \pkgopt{german} or \pkgopt{ngerman} option is
1227 on, in which case it's indexed as
1228 \begin{verbatim}
1229 \r Angstr"om, Anders Jonas@\AA ngstr"om, Anders Jonas
1230 \end{verbatim}
1231
1232 When the UTF-8 mode is on, UTF-8 characters are used instead.
1233 For example, \qt{Anders Jonas \AA ngstr\"om} is indexed
1234 as
1235 \begin{flushleft}\ttfamily
1236 \AA ngstr\"om, Anders Jonas
1237 \end{flushleft}
1238 (The \pkgopt{stripaccents} and \pkgopt{nostripaccents} options
1239 are ignored.)
1240
1241 \XeLaTeX\ and \LuaLaTeX\ both natively support UTF-8, so
1242 when either of those engines are in use, the UTF-8 characters
1243 will be written to the indexing file as they are. So the above
1244 example will appear in the \texttt{.idx} file as:
1245 \begin{flushleft}\ttfamily
1246 \cs{indexentry}\{\AA ngstr\"om, Anders Jonas\}\marg{location}
1247 \end{flushleft}
1248 Regular \LaTeX\ (\app{latex} or \app{pdflatex}) requires the
1249 \sty{inputenc} package to support
1250 UTF-8 characters, but each UTF-8 character is treated as
1251 two tokens (the first and second octets) where the first token is an
1252 active character that takes the second token as the argument.
1253 This means that expansion will occur when writing these
1254 active characters to an external file. This means that the
1255 above will appear in the \texttt{.idx} file as:
1256 \begin{verbatim}
1257 \indexentry{\IeC {\r A}ngstr\IeC {\"o}m, Anders Jonas}{3}
1258 \end{verbatim}
1259 (where 3 is the page number).
1260
1261 Since this expansion can confuse the indexing application,
1262 \styfmt{testidx} provides a \pkgopt{sanitize} package option
1263 which will first sanitize the UTF-8 characters before
1264 indexing them. This option is on by default for regular \LaTeX\ and
1265 off for \XeLaTeX\ and \LuaLaTeX. You can switch it off
1266 using the \pkgopt{nosanitize} package option.
1267
1268 Whether it should be on or off really depends on what you want
1269 to test. For example, if you want to test how an indexing
1270 application deals with UTF-8 characters, then switch it on, but
1271 if you want to test how your indexing command (whatever
1272 \cs{tstindex} is defined as) behaves with these characters, then
1273 switch it off.
1274
1275 \begin{important}
1276 As from \LaTeX\ 2019/10/01 this behaviour has changed and the UTF-8
1277 characters are no longer expanded while they are written to the
1278 \texttt{.idx} file. This means that the tests may produce different
1279 results depending on the \LaTeX\ kernel in use.
1280 \end{important}
1281
1282 Note that this \pkgopt{sanitize} option isn't adjusting the
1283 definition of \cs{index} or \cs{tstindex}, but is essentially
1284 pretending that the user is doing something like:
1285 \begin{flushleft}\ttfamily\obeylines
1286 \cs{makeatletter}
1287 Anders Jonas \AA ngstr\"om\%
1288 \cs{def}\cs{tmp}\{\AA ngstr\"om, Anders Jonas\}\%
1289 \cs{@onelevel@sanitize}\cs{tmp}
1290 \cs{exandafter}\cs{index}\cs{expandafter}\{\cs{tmp}\}\%
1291 \cs{edef}\cs{tmp}\{people\cs{tstidxlevel}\cs{tmp}\}\%
1292 \cs{exandafter}\cs{index}\cs{expandafter}\{\cs{tmp}\}\%
1293 \end{flushleft}
1294 instead of simulating:
1295 \begin{flushleft}\ttfamily\obeylines
1296 Anders Jonas \AA ngstr\"om\%
1297 \cs{tstindex}\{\AA ngstr\"om, Anders Jonas\}\%
1298 \cs{tstindex}\{people\tstidxlevel\AA ngstr\"om, Anders Jonas\}\%
1299 \end{flushleft}
1300
1301 Note that the sanitization isn't applied to the entire argument
1302 of \cs{tstindex}, but only selected parts of it.
1303
1304 \PrintIndex
1305
1306 \end{document}