Debian Codegraph @

texmf-dist/doc/latex/datatool/samples/sample-index.tex

raw
1 \documentclass{article}
2
3 \usepackage[T1]{fontenc}
4 \usepackage[utf8]{inputenc}
5
6 % Two LaTeX runs are required to ensure this document is up-to-date
7
8 % It can take a long time to sort the index, in which case you can
9 % use the optimize option.
10 % This has values: off (no optimize, sorting is done every
11 % run), low (sort every second run) or high (write sorted database
12 % to file and read in next time round). Don't modify the
13 % index/glossary databases while the optimize option is set to
14 % high. Do the modifications while the optimize option is set to
15 % low or off. Alternatively, delete the .aux and .gidx files before rerunning
16 % LaTeX.
17
18 \usepackage
19 [
20 % locales = en, % this option requires datatool-english to be installed
21 % optimize=high, % for draft documents to avoid sorting on every build
22 % verbose
23 ]
24 {datagidx}%[=v2.32]
25
26 \usepackage[colorlinks]{hyperref}
27
28 % Define some convenient commands
29
30 \newcommand*{\principleloc}[1]{\textbf{#1}}
31 \newcommand*{\appname}[1]{\texttt{#1}}
32
33 % Later we'll switch to a fancy small caps Roman page numbering
34
35 \newcommand*{\myscroman}[1]{%
36 \myscromannum{\value{#1}}%
37 }
38
39 \newcommand*{\myscromannum}[1]{%
40 \textsc{\romannumeral#1}%
41 }
42
43 % Don't let \appname interfere with the sorting and labelling of
44 % terms:
45
46 \appto\newtermlabelhook{\let\appname\DTLgidxNoFormat}
47
48 % (datagidx also does this for \MakeUppercase, \MakeTextUppercase,
49 % \MakeLowercase, \MakeTextLowercase, \textsc and \acronymfont.)
50
51 % Make an index database labelled 'index' with given title.
52
53 \newgidx{index}{Index}
54
55 % Define some terms for the index (entries must be defined in the
56 % preamble).
57
58 % Either use "database" key in optional argument
59 % or set the default database. It's less typing to set the default
60 % database, so let's do that:
61
62 \DTLgidxSetDefaultDB{index}
63
64
65 % All the following definitions will add terms to the "index" database:
66
67 \newterm{\DTLgidxName{Jane}{Doe}}
68
69 % NB recent versions of the LaTeX kernel provide improved support
70 % with UTF-8 characters in labels.
71
72 \newterm{macédoine}
73 \newterm{macramé}
74 \newterm{élite}
75 % This term has a label that's different to the name
76 \newterm[label=manoeuvre]{manœuvre}
77
78 % Sometimes the default sort may not suit your requirements. In
79 % which case you can override it:
80
81 \newterm
82 [
83 sort={Ten Downing Street}
84 ]
85 {10 Downing Street}
86
87 \newterm{singular}
88 \newterm{plural}
89 \newterm{group}
90 \newterm[see=group]{scope}
91 \newterm[label={glossary}]{glossary}
92 \newterm
93 [%
94 label={index},
95 seealso={glossary},
96 ]
97 {index}
98 \newterm
99 [
100 seealso={glossary}
101 ]
102 {acronym}
103
104 \newterm[parent=acronym]{reset}
105 \newterm[parent=acronym]{unset}
106
107 \newterm
108 [%
109 parent=acronym,
110 label={firstuse},
111 ]
112 {first use}
113 \newterm
114 [%
115 parent=acronym,
116 label={acronymlist},
117 text={list of acronyms},
118 plural={lists of acronyms}
119 ]
120 {list}
121
122 \newterm{reptile}
123
124 \newterm
125 [%
126 seealso={reptile}
127 ]
128 {crocodylian}
129
130 \newterm
131 [%
132 parent=crocodylian
133 ]
134 {crocodile}
135
136 \newterm
137 [%
138 parent=crocodylian
139 ]
140 {caiman}
141
142 \newterm
143 [%
144 parent=crocodylian
145 ]
146 {alligator}
147
148 \newterm{seal}
149 \newterm{sea lion}
150 \newterm{sea}
151 \newterm{sea anchor}
152 \newterm{sea urchin}
153 \newterm{seam bowler}
154 \newterm{seam}
155
156 % Be careful if a value contains a comma or an equal sign. The
157 % entire value must be grouped.
158 \newterm
159 [%
160 label={comma},
161 sort={,},
162 text={comma (,)},
163 plural={commas (,)}
164 ]%
165 {, (comma)}
166
167 \newterm
168 [%
169 label={equals},
170 sort={=},
171 text={equal sign (=)},
172 plural={equal signs (=)},
173 ]%
174 {= (equal sign)}
175
176 % Don't need to worry about makeindex's special characters (since
177 % we're not using makeindex!)
178 \newterm
179 [%
180 label={"},
181 sort={"},
182 text={double quote (")},
183 plural={double quotes (")},
184 ]%
185 {" (double quote)}
186
187 \newterm
188 [%
189 label={!},
190 sort={!},
191 text={exclamation mark (!)},
192 plural={exclamation marks (!)},
193 ]%
194 {! (exclamation mark)}
195
196 \newterm
197 [%
198 label={|},
199 sort={|},
200 text={vertical bar (\textbar)},
201 plural={vertical bars (\textbar)},
202 ]%
203 {\textbar\ (vertical bar)}
204
205
206 % Be careful of special characters
207
208 \newterm
209 [%
210 label={amp},
211 sort={\DTLgidxStripBackslash{\&}},
212 text={ampersand (\&)},
213 plural={ampersands (\&)},
214 ]
215 {\& (ampersand)}
216
217 \newterm
218 [%
219 label={underscore},
220 sort={\DTLgidxStripBackslash{\_}},
221 text={underscore (\_)},
222 plural={underscores (\_)},
223 ]
224 {\_ (underscore)}
225
226 \newterm
227 [%
228 label={dollar},
229 sort={\DTLgidxStripBackslash{\$}},
230 text={dollar (\$)},
231 plural={dollars (\$)},
232 ]
233 {\$ (dollar)}
234
235 \newterm
236 [%
237 label={circum},
238 sort={\DTLgidxStripBackslash{\^}},
239 text={circumflex (\textasciicircum)},
240 plural={circumflexes (\textasciicircum)},
241 ]
242 {\textasciicircum\ (circumflex)}
243
244 \newterm
245 [%
246 label={tilde},
247 sort={\string~},
248 text={tilde (\textasciitilde)},
249 plural={tildes (\textasciitilde)},
250 ]
251 {\textasciitilde\ (tilde)}
252
253 \newterm{0\DTLgidxParen{zero}}
254
255 \newterm{1\DTLgidxParen{one}}
256
257 \newterm{2\DTLgidxParen{two}}
258
259 \newterm{3\DTLgidxParen{three}}
260
261 \newterm{10\DTLgidxParen{ten}}
262
263 \newterm{100\DTLgidxParen{one hundred}}
264
265 \newterm{20\DTLgidxParen{twenty}}
266
267 \newterm{alpine}
268
269 % Let's index a person
270 % The label is formed from the surname.
271 % If you are indexing more than one person with the same surname,
272 % you'll have to provide your own labels via the label key.
273
274 \newterm{\DTLgidxName{Donald E.}{Knuth}}
275
276 % Let's have some examples from the Oxford Style Manual:
277
278 \newterm{highwater}
279 \newterm{highlights}
280 \newterm{highbrow}
281 \newterm{Highclere Castle}
282 \newterm{highball}
283 \newterm{high chair}
284 \newterm{high heels}
285 \newterm{high-fliers}
286
287 % parenthetical material
288 \newterm{high\DTLgidxParen{light-headed}}
289
290 \newterm
291 [% label needed to distinguish from previous entry
292 label=highheight,
293 ]
294 {high\DTLgidxParen{height}}
295
296 \newterm{\emph{High Water}\DTLgidxParen{play}}
297
298 \newterm{high water}
299
300 % Label will be "New York New York".
301 % the comma and \emph will be stripped
302 \newterm{\emph{New York, New York}}
303
304 % Using \DTLgidxName allows the sort key to work with \dtlwordindexcompare
305
306 \newterm{\DTLgidxName{J.}{High}}
307
308 \newterm{\DTLgidxName{P.}{High-Smith}}
309
310 \newterm{\DTLgidxName{A.}{Highsmith}}
311
312 \newterm{\DTLgidxName{Earl of}{New York}}
313
314 % Some more examples from the Oxford Style Manual
315
316 \newterm
317 [
318 label={DrMeynell}
319 ]
320 {\DTLgidxName{\DTLgidxRank{Dr}{A.}}{Meynell}}
321
322 \newterm
323 [%
324 label={AliceMeynell}
325 ]
326 {\DTLgidxName{Alice}{Meynell}}
327
328 \newterm
329 [%
330 label={AMeynell}
331 ]
332 {\DTLgidxName{A}{Meynell}}
333
334 \newterm
335 [%
336 label={FMeynell}
337 ]
338 {\DTLgidxName{F.}{Meynell}}
339
340 \newterm
341 [%
342 label={WGMeynell}
343 ]
344 {\DTLgidxName{W.~G.}{Meynell}}
345
346 \newterm
347 [%
348 label={WMeynell}
349 ]
350 {\DTLgidxName{W.}{Meynell}}
351
352 \newterm
353 [%
354 label={SirMeynell}
355 ]
356 {\DTLgidxName{\DTLgidxRank{Sir}{F.}}{Meynell}}
357
358
359 % Using \DTLgidxMac allows the sort key to sort on ``Mac'' rather
360 % than the argument to \DTLgidxMac
361
362 \newterm{\DTLgidxName{Joe}{\DTLgidxMac{Mc}Cullers}}
363
364 \newterm{\DTLgidxName{Bob}{\DTLgidxMac{M'}Fingal}}
365
366 % The labels need to be set here as we have identical surnames
367
368 \newterm
369 [%
370 label={TomMacFarlane}
371 ]%
372 {\DTLgidxName{Tom}{\DTLgidxMac{Mac}Farlane}}
373
374 \newterm
375 [%
376 label={DickMacFarlane}
377 ]%
378 {\DTLgidxName{Dick}{\DTLgidxMac{Mac}Farlane}}
379
380 \newterm{\DTLgidxName{Harry}{\DTLgidxMac{Mc}Namee}}
381
382 \newterm{\DTLgidxMac{Mc}Carthyism}
383 \newterm{\DTLgidxMac{Mc}Guffin}
384 \newterm{\DTLgidxMac{Mc}Coy}
385
386 \newterm{macadam}
387 \newterm{ma'am}
388 \newterm{ma}
389 \newterm{macabre}
390 \newterm{machete}
391
392
393 \newterm{deem}
394 \newterm{demote}
395 \newterm{deerstalker}
396 \newterm{deface}
397 \newterm{de facto}
398
399 % Don't let the hyphen be considered a word boundary:
400 \newterm{de\DTLgidxIgnore{-}escalate}
401
402 % Ignore particles such as "de", "von", "of"
403 % The label defaults to deWinter but the name is displayed as
404 % de~Winter
405
406 \newterm{\DTLgidxName{Fred}{\DTLgidxParticle{de}{Winter}}}
407
408 \newterm{\DTLgidxName{Wilma}{Winter}}
409
410 \newterm{\DTLgidxName{Betty}{Winters}}
411
412 \newterm{\DTLgidxOffice{Rollo}{ruler of Normandy}}
413
414 \newterm{\DTLgidxRank{Lady}{Felicity}}
415
416 % these all need labels added to ensure uniqueness:
417
418 \newterm
419 [
420 label={HenrySonJohn}
421 ]
422 {\DTLgidxOffice{son \DTLgidxParticle{of}{John}}{Henry}}
423
424 \newterm
425 [
426 label={HenryBeaumont}
427 ]
428 {\DTLgidxOffice{bishop \DTLgidxParticle{of}{Bayeux}}%
429 {\DTLgidxName{Henry}{\DTLgidxParticle{de}{Beaumont}}}}
430
431 \newterm
432 [
433 label={HenryScribe}
434 ]
435 {\DTLgidxOffice{scribe \DTLgidxParticle{of}{Bury}
436 \DTLgidxSaint{St}~Edmunds}{Henry}}
437
438 \newterm
439 [
440 label={HenryKing}
441 ]
442 {\DTLgidxOffice{king \DTLgidxParticle{of}{England}}{Henry}}
443
444 \newterm
445 [
446 label={HenryBlois}
447 ]
448 {\DTLgidxOffice{bishop \DTLgidxParticle{of}{Winchester}}{Henry
449 \DTLgidxParticle{of}{Blois}}}
450
451 \newterm
452 [
453 label={HenryBlund}
454 ]
455 {Henry Blund}
456
457 \newterm
458 [
459 label={HenryEssex}
460 ]
461 {Henry \DTLgidxParticle{of}{Essex}}
462
463 \newterm
464 [
465 label={HenryLittle}
466 ]
467 {Henry \DTLgidxParticle{the}{Little}}
468
469 \newterm
470 [
471 label={HenryMowbray}
472 ]
473 {Henry \DTLgidxParticle{de}{Mowbray}}
474
475 \newterm
476 [
477 label={HenryFitzRobert}
478 ]
479 {Henry \DTLgidxParticle{Fitz}{Robert}}
480
481 \newterm
482 [
483 label={JBSaint}
484 ]
485 {\DTLgidxName{J.~B.}{Saint}}
486
487 \newterm
488 [
489 label={StAndrews}
490 ]
491 {\DTLgidxPlace{\DTLgidxSaint{St}~Andrews}{Fife}}
492
493 \newterm
494 [
495 label={StBenetsHall}
496 ]
497 {\DTLgidxSaint{St}~Benet's Hall}
498
499 \newterm
500 [
501 label={StJamesInfirmary}
502 ]
503 {\DTLgidxSaint{St}~James Infirmary}
504
505 \newterm
506 [
507 label={QStJohnSmythe}
508 ]
509 {\DTLgidxName{Q.}{\DTLgidxSaint{St}~John-Smythe}}
510
511 \newterm
512 [
513 label={SaintJulian}
514 ]
515 {\DTLgidxSaint{Saint}-Julian}
516
517 \newterm
518 [
519 label={StJustinRoseland}
520 ]
521 {\DTLgidxSaint{St}~Just-in-Roseland}
522
523 % Names with an associated number
524
525 % The following gets the label 'James I' and sort 'James 01'
526
527 \newterm{James~\DTLgidxNameNum{1}}
528
529 % The following gets the label 'James II' and sort 'James 02'
530
531 \newterm{James~\DTLgidxNameNum{2}}
532
533 % etc
534 \newterm{James~\DTLgidxNameNum{3}}
535 \newterm{James~\DTLgidxNameNum{4}}
536 \newterm{James~\DTLgidxNameNum{5}}
537
538 % In the following, the label and name default to 'New York, population'
539 % The text defaults to 'population'.
540 % Using \DTLgidxSubject allows the sort key to work with \dtlwordindexcompare
541 % Here both the label and the text have been changed from their
542 % defaults.
543 \newterm
544 [
545 label={popNY},% give it a short, easy to type label
546 text={population of New York}
547 ]
548 {\DTLgidxSubject{population}{New York}}
549
550 % In the following, the becomes 'New York, USA' and the
551 % label becomes 'New York USA'
552 % The text becomes 'New York'.
553 \newterm{\DTLgidxPlace{USA}{New York}}
554
555 \newterm{\ensuremath{\alpha}-iron}% gets label and sort keys 'alpha-iron'
556
557 \newterm{\ensuremath{\alpha} chain}% label & sort -> 'alpha chain'
558
559 \newterm{\ensuremath{\alpha} Centauri}% label & sort -> 'alpha Centauri'
560
561 \newterm{alphabet}
562
563 \newterm{\ensuremath{\Lambda} calculus}% label & sort -> 'Lambda calculus'
564
565 % and have a few more entries in the same letter group to test case
566 % ordering:
567 \newterm{kite}
568 \newterm{koala}
569
570 % Earlier I modified \newtermlabelhook so
571 % that \appname won't interfere with the sorting
572 % and labelling mechanism, so I don't need to specify separate sort
573 % and label keys here:
574
575 \newterm{\appname{makeindex}}% label and sort both set to just 'makeindex'
576 \newterm{\appname{xindy}}% label and sort both set to just 'xindy'
577
578 \title{Sample Document Using the datagidx Package}
579 \author{Nicola L. C. Talbot}
580
581 \begin{document}
582 \pagenumbering{roman}
583
584 The datagidx package was developed to follow the word order indexing
585 style described by the Oxford Style Manual. Many of the examples
586 here are taken from that manual. Two \LaTeX\ runs are required. If
587 you get a pdfTeX warning that a destination has been referenced but
588 does not exist, this may mean the index is out-of-date and you need
589 to do another \LaTeX\ run.
590
591 With word ordering a word break (space or hyphen) comes before all
592 other letters of the alphabet (\gls{sea lion} comes before \gls{seal}).
593 With letter ordering word breaks are ignored (so \gls{seal} comes
594 before \gls{sea lion}).
595
596 Use a few terms here: \gls{index}, \gls{group}, \gls{singular}, \gls{plural}.
597
598 \newpage
599
600 \Gls{singular}, \glspl{plural}. \gls{glossary}.
601 \Gls{acronym}: \gls{reset}, \gls{firstuse}.
602
603 \newpage
604 \pagenumbering{arabic}
605
606 Switched page numbering style. \Gls{singular}, \gls{kite},
607 \gls{koala}, \gls{crocodile}, \gls{seal}.
608
609 \Gls{sea},
610 \gls{sea anchor},
611 \gls{sea urchin}.
612
613 Some characters: \gls{comma}, \gls{equals}, \gls{"}, \gls{!}, \gls{|}
614 \gls{amp}, \gls{underscore}, \gls{dollar}, \gls{circum},
615 \gls{tilde}.
616
617 Some numbers: \gls{0}, \gls{1}, \gls{2}, \gls{3}, \gls{20}, \gls{10}.
618
619 \newpage
620
621 Some numbers again: \gls{0}, \gls{1}, \gls{2}, \gls{3}, \gls{100},
622 \gls{10}, \gls{20}.
623
624 Case mixture: \gls{kite},
625 \gls{Knuth} and
626 \gls{[principleloc]koala}.
627
628 \Gls{de-escalate}, \gls{deem}, \gls{demote}.
629
630 We don't need to use \gls{makeindex} or \gls{xindy}!
631 However, \TeX\ takes longer to sort and collate than either
632 \gls{makeindex} or \gls{xindy}, so document compilation time will
633 take longer.
634
635 \newpage
636
637 \Gls{kite}, \gls{highwater}, \gls{koala}, \gls{caiman}, \gls{sea
638 lion}, \gls{high},
639 \gls{highbrow}, \gls{high chair}, \gls{highball}, \gls{reptile},
640 \gls{highlights}, \gls{high heels}, \gls{high-fliers}.
641 \Gls{seam} and \gls{seam bowler}.
642
643 \gls{New York New York}. \gls{New York}.
644 \Gls{popNY}. \gls{New York USA}.
645 \gls{Highclere Castle}.
646
647 \gls{High}. \gls{High-Smith}, \gls{Highsmith}, \gls{High Water}
648 as opposed to \gls{high water}. \Gls{alphabet}. \Gls{alpine}.
649
650 Some terms with Greek letters: \gls{alpha-iron},
651 \gls{Lambda calculus}, \gls{alpha chain}, \gls{alpha Centauri}.
652
653 \newpage
654
655 \renewcommand{\thepage}{\myscroman{page}}%
656 Switching to small caps Roman page numbering.
657
658 \Gls{kite}. \Glspl{alligator}. \Gls{highheight}.
659
660 \gls{deWinter}.
661 \gls{Winter}.
662 \gls{Winters}.
663
664 \gls{McCullers}.
665
666 \gls{M'Fingal}.
667
668 \gls{TomMacFarlane}.
669
670 \gls{DickMacFarlane}.
671
672 \gls{McNamee}.
673
674 \gls{McCarthyism},
675 \gls{McGuffin},
676 \gls{McCoy}.
677
678 \Gls{macadam},
679 \gls{ma'am},
680 \gls{ma},
681 \gls{macabre},
682 \gls{macramé},
683 \gls{macédoine},
684 \gls{manoeuvre}.
685
686 \Gls{élite},
687 \gls{deem},
688 \gls{demote},
689 \gls{deerstalker},
690 \gls{deface},
691 \gls{de facto}.
692
693
694 \gls{AliceMeynell}.
695 \gls{AMeynell}.
696 \gls{DrMeynell}.
697 \gls{SirMeynell}.
698 \gls{FMeynell}.
699 \gls{WGMeynell}.
700 \gls{WMeynell}.
701
702 \gls{HenrySonJohn}. \gls{HenryBlois}.
703 \gls{HenryBeaumont}. \gls{HenryBlund}.
704 \gls{HenryLittle}. \gls{HenryEssex}. \gls{HenryMowbray}.
705 \gls{HenryFitzRobert}.
706 \gls{HenryKing}. \gls{HenryScribe}.
707
708 \gls{James V}.
709 \gls{James I}.
710 \gls{James IV}.
711 \gls{James III}.
712 \gls{James II}.
713
714 \gls{JBSaint}.
715 \gls{StAndrews}.
716 \gls{StBenetsHall}.
717 \gls{StJamesInfirmary}.
718 \gls{QStJohnSmythe}.
719 \gls{SaintJulian}.
720 \gls{StJustinRoseland}.
721
722 \gls{10 Downing Street}.
723
724 \newpage
725
726 % This will take a while as the sorting algorithm is complex.
727
728 % NB locales=en will do this automatically (but it requires
729 % datatool-english to be installed):
730 \renewcommand{\dtlnonlettergroup}[1]{Symbols}
731
732 \printterms
733 [
734 heading={\section[Word Sorted Index]},% make a numbered section
735 database=index,% 'index' database
736 prelocation=dotfill,% put a dotted line before the location list
737 columns=3,% page layout
738 style=index,% use 'index' style
739 %balance=false,% don't balance columns
740 postheading={Locations in bold indicate primary reference.
741 (Word sort.)},
742 showgroups, % show letter groups
743 % NB élite will end up in the É letter group by default.
744 % There will also be a second "Symbols" group at the end
745 % for characters with codepoints after "z".
746 % Use locales=en to treat "é" as "e" and gather the symbols
747 ]
748
749
750 \end{document}