summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries-extra/sample-autoindex.tex
blob: da2b32d6d9c13ecdec71efd8d86e08a6b18caf0c (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
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: makeindex
% arara: pdflatex
\documentclass{report}

\usepackage[T1]{fontenc}

\usepackage{makeidx}
\usepackage[abbreviations,counter=chapter,nopostdot=false]{glossaries-extra}

\renewcommand*{\abbreviationsname}{List of Abbreviations}
\renewcommand*{\glossarypreamble}{\emph{Numbers refer to the 
\textbf{chapter} where the entry was referenced.}}

\makeindex
\makeglossaries

% Automatically index the location of entry in the glossary
% for those entries that are in the "general" category:

\glssetcategoryattribute{general}{indexname}{textbf}
\glssetcategoryattribute{general}{dualindex}{true}

% Only index first use for the glossary location lists
% (doesn't affect the indexing from "dualindex" attribute):
%\glssetcategoryattribute{general}{indexonlyfirst}{true}

% Automatically index the location of entry in the glossary
% for those entries that are in the "abbreviation" category
% and use "textbf" as the encap:

\glssetcategoryattribute{abbreviation}{indexname}{textbf}
\glssetcategoryattribute{abbreviation}{dualindex}{true}

% Only index first use for the glossary location lists
% (doesn't affect the indexing from "dualindex" attribute):
%\glssetcategoryattribute{abbreviation}{indexonlyfirst}{true}

% Convert the first letter of the name to upper case in the 
% glossary for general entries:
\glssetcategoryattribute{general}{glossname}{firstuc}

% Allow "format" key to override "dualindex" attribute.
\GlsXtrEnableIndexFormatOverride

% use first field instead of name field
\renewcommand*{\glsxtrautoindexentry}[1]{\string\glsentryfirst{#1}}

% use long form for the sort value, if provided:
\renewcommand*{\glsxtrautoindexassignsort}[2]{%
  \ifglshaslong{#2}%
  {\glsletentryfield{#1}{#2}{long}}%
  {\glsletentryfield{#1}{#2}{sort}}%
}

% Define general entries:

\newglossaryentry{duck}{name=duck,%
  description={a waterbird with webbed feet}}

\newglossaryentry{parrot}{name=parrot,%
  description={mainly tropical bird with bright plumage}}

\newglossaryentry{at}{name={@},%
  description={makeindex's default for the ``actual value''}}

\newglossaryentry{esc}{name={"},%
  description={makeindex's default for the ``escape value''}}

\newglossaryentry{level}{name={!},%
  description={makeindex's default for the ``level value''}}

\newglossaryentry{encap}{name={|},%
  description={makeindex's default for the ``encap value''}}

% Set abbreviation style:

\setabbreviationstyle{long-short-sc}

% Define abbreviations:

\newabbreviation
 {html}% identifying label
 {html}% short form
 {hypertext markup language}% long form

\newabbreviation
 {xml}% identifying label
 {xml}% short form
 {extensible markup language}% long form

\title{Sample document testing the glossaries-extra package}
\author{Nicola Talbot}

\begin{document}
\maketitle

\chapter{Introduction}

This is a sample\index{sample} document testing the
\texttt{glossaries-extra} package.

\chapter{General Entries}

Sample entries: \gls{duck} and \gls{parrot}.

Test makeindex's special characters: \gls{at} (actual)
\gls{esc} (escape) \gls{level} (level) and \gls{encap} (encap).

\chapter{Abbreviations}

First use: \gls{html} and \gls{xml}.

Next use: \gls{html} and \gls{xml}.

\newpage

Uses some entries again: \gls{duck} and \gls[format=textit]{parrot}.

\printglossaries

\printindex

\end{document}