Debian Codegraph @

texmf-dist/doc/latex/glossaries/glossariesbegin.tex

raw
1 % arara: lualatex
2 % arara: bib2gls: { group: on }
3 % arara: lualatex
4 % arara: bib2gls: { group: on } if found ("log", "Glossary entry `sym.")
5 % arara: lualatex
6 % arara: lualatex if found ("log", "Rerun to")
7 \documentclass[titlepage=false,oneside,
8 fontsize=12pt,captions=tableheading]{scrarticle}
9
10 \usepackage{pifont}
11 \usepackage[noatsymgroup]{nlctuserguide}
12
13 \renewcommand*{\thispackagename}{glossaries}
14
15 \glsxtrnewgls{opt.glostyle.}{\glostyle}
16 \glsxtrnewgls{opt.acrstyle.}{\acrstyle}
17 \glsxtrnewgls{opt.abbrstyle.}{\abbrstyle}
18
19 \defsemanticcmd{\glostylefmt}{\textsf}{}
20 \defsemanticcmd{\acrstylefmt}{\textsf}{}
21 \defsemanticcmd{\abbrstylefmt}{\textsf}{}
22
23 \newcommand{\atentry}[1]{\texorpdfstring{\code{@#1}}{@#1}}
24
25 \glsxtrnewgls{opt.printgloss.}{\printglossopt}
26 \newcommand{\printglossoptval}[2]{\optval{printgloss.#1}{#2}}
27 \newcommand{\printglossoptvalm}[2]{\optval{printgloss.#1}{\marg{#2}}}
28
29 \glsxtrnewgls{opt.gloskey.}{\gloskey}
30 \newcommand{\gloskeyval}[2]{\optval{gloskey.#1}{\marg{#2}}}
31
32 \newcommand*{\catfmt}{\csoptfmt}
33
34 \glsxtrnewgls{opt.cat.}{\cat}
35 \glsxtrnewgls{opt.catattr.}{\catattr}
36 \glsxtrnewgls{opt.resource.}{\resourceopt}
37 \newcommand{\resourceoptval}[2]{\optval{resource.#1}{#2}}
38 \newcommand{\resourceoptvalm}[2]{\optval{resource.#1}{\marg{#2}}}
39
40 \renewcommand{\optionlistprefix}{idx.opt.}
41 \renewcommand{\glsxtrtaggedlistsep}{~}
42 \newcommand{\idxoptiondef}[1]{\hypertarget{option\glsentrytext{idx.opt.#1}}{}\inlineidxdef{opt.#1}}
43
44 \renewcommand{\nlctuserguidecustomentryaliases}{%
45 glossarystyle=index,
46 acronymstyle=index,
47 abbreviationstyle=index,
48 }
49
50 \newcommand{\comxr}{\comment{\glslink{pkg.glossaries-extra}{glossaries-extra.sty}}}
51 \newcommand{\comxronly}{\comment{\glslink{pkg.glossaries-extra}{glossaries-extra.sty} only}}
52 \newcommand{\comxrkey}{\comment{\glslink{pkg.glossaries-extra}{glossaries-extra.sty} key}}
53 \newcommand{\comxropt}[1]{\comment{requires \glslink{pkg.glossaries-extra}{glossaries-extra.sty} '\opt{#1}' option}}
54
55 \nlctuserguidegls
56 {
57 \def\gprintglossopt#1#2{%
58 \glsbibwriteentry{commandoption}{opt.printgloss.#1}{%
59 \field{name}{\csoptfmt{#1}}\parent{idx.printglossopt}#2}}%
60 \def\gglosty#1#2{\glsbibwriteentry{glossarystyle}{opt.glostyle.#1}%
61 {\field{name}{\glostylefmt{#1}}\parent{idx.glossarystyle}#2}}%
62 \def\gacrsty#1#2{\glsbibwriteentry{acronymstyle}{opt.acrstyle.#1}%
63 {\field{name}{\acrstylefmt{#1}}\parent{idx.acrstyle}#2}}%
64 \def\gabbrsty#1#2{\glsbibwriteentry{abbreviationstyle}{opt.abbrstyle.#1}%
65 {\field{name}{\abbrstylefmt{#1}}\parent{idx.abbrstyle}#2}}%
66 \def\ggloskey#1#2{%
67 \glsbibwriteentry{commandoption}{opt.gloskey.#1}{%
68 \field{name}{\csoptfmt{#1}}\parent{idx.gloskey}#2}}%
69 \def\gglsopt#1#2{%
70 \glsbibwriteentry{commandoption}{opt.glsopt.#1}{%
71 \field{name}{\csoptfmt{#1}}\parent{gls}#2}}%
72 \def\gcat#1#2{%
73 \glsbibwriteentry{optionvalue}{opt.cat.#1}{%
74 \field{name}{\catfmt{#1}}\parent{idx.category}#2}}%
75 \def\gcatattr#1#2{%
76 \glsbibwriteentry{optionvalue}{opt.catattr.#1}{%
77 \field{name}{\csoptfmt{#1}}\parent{idx.categoryattribute}#2}}%
78 \def\gresourceopt#1#2{%
79 \glsbibwriteentry{commandoption}{opt.resource.#1}{%
80 \field{name}{\csoptfmt{#1}}\parent{GlsXtrLoadResources}#2}}%
81 \gidx{category}{\field{plural}{categories}}
82 \gidx{glossarystyle}{\name{glossary styles}\field{text}{glossary style}}
83 \gidx{acrstyle}{\name{acronym styles}\field{text}{acronym style}
84 \field{see}{setacronymstyle}}
85 \gidx{abbrstyle}{\name{abbreviation styles}\field{text}{abbreviation style}
86 \field{see}{setabbreviationstyle}}
87 \gidx{printglossopt}{\name{print [unsrt|noidx] glossary options}%
88 \field{text}{print glossary option}%
89 }
90 % \newglossary
91 \gcmd{new\-glossary}
92 {
93 \providedby{\sty{glossaries}}
94 \syntax{\oargm{log-ext}\margm{glossary-label}\margm{out-ext}\margm{in-ext}\margm{title}}
95 \desc{defines a \idx{glossary} identified by \meta{glossary-label} (which can
96 be referenced by the \gloskey{type} key when defining an entry)}
97 }
98 % \newglossary*
99 \gcmd{new\-glos\-sary*}%
100 {%
101 \providedby{\sty{glossaries} v4.08+}
102 \syntax{\margm{glossary-label}\margm{title}}
103 \desc{a shortcut that supplies file extensions based on the
104 \idx{glossary} label:\begin{compactcodebox}%
105 \gls{newglossary}\oarg{\meta{glossary-label}-glg}\margm{glossary-label}\marg{\meta{glossary-label}-gls}\marg{\meta{glossary-label}-glo}\margm{title}%
106 \end{compactcodebox}\glsxtrnopostpunc
107 }
108 }
109 % \GlsSetQuote
110 \gcmd{Gls\-Set\-Quote}
111 {
112 \providedby{\sty{glossaries} v4.24+}
113 \syntax{\margm{character}}
114 \desc{set \app{makeindex}['s] quote character to \meta{character}}
115 }
116 % \glsdisablehyper
117 \gcmd{gls\-disable\-hyper}
118 {
119 \providedby{\sty{glossaries}}%
120 \desc{suppresses all \idx{glossary} related hyperlinks}
121 }
122 % \glsenablehyper
123 \gcmd{gls\-enable\-hyper}
124 {
125 \providedby{\sty{glossaries}}%
126 \desc{enables \idx{glossary} related hyperlinks. This is the
127 default if \sty{hyperref} is loaded. Has no effect if
128 \sty{hyperref} wasn't loaded}
129 }
130 % \setglossarystyle
131 \gcmd{set\-glossary\-style}
132 {
133 \providedby{\sty{glossaries}}%
134 \syntax{\margm{style name}}
135 \desc{set the current \idx{glossarystyle} to \meta{style name}}
136 }
137 % \printglossary
138 \gcmd{print\-glos\-sary}
139 {
140 \providedby{\sty{glossaries}}%
141 \syntax{\oargm{options}}
142 \desc{displays the \idx{glossary} by inputting a file created by
143 \app+{makeindex} or \app+{xindy}. Must be used with
144 \gls{makeglossaries} and either \app{makeindex} or \app{xindy}}
145 }
146 % \printglossaries
147 \gcmd{print\-glos\-saries}
148 {
149 \providedby{\sty{glossaries}}%
150 \desc{iterates over all glossaries and does
151 \code{\gls{printglossary}\oarg{\printglossoptval{type}{\meta{type}}}}
152 for each \idx{glossary}}
153 }
154 % \printnoidxglossary
155 \gcmd{print\-no\-idx\-glos\-sary}%
156 {%
157 \providedby{\sty{glossaries} v4.04+}
158 \syntax{\oargm{options}}
159 \desc{displays the \idx{glossary} by obtaining the \gls{indexing} information from
160 the \ext+{aux} file and using \TeX\ to sort and collate. Must be used with
161 \gls{makenoidxglossaries}. This method can be very slow and has limitations}
162 }%
163 % \printnoidxglossaries
164 \gcmd{print\-no\-idx\-glos\-saries}%
165 {%
166 \providedby{\sty{glossaries} v4.04+}
167 \desc{iterates over all glossaries and does
168 \code{\gls{printnoidxglossary}\oarg{\printglossoptval{type}{\meta{type}}}}
169 for each \idx{glossary}}
170 }
171 % \printunsrtglossary
172 \gcmd{print\-un\-srt\-glos\-sary}%
173 {%
174 \providedby{\sty{glossaries-extra} v1.08+}
175 \syntax{\oargm{options}}
176 \desc{displays the \idx{glossary} by iterating over all entries
177 associated with the given \idx{glossary} (in the order in which they
178 were added to the \idx{glossary}). The location lists and group headers
179 will only be present if the associated fields have been set
180 (typically by \app{bib2gls})}
181 }%
182 % \printunsrtglossaries
183 \gcmd{print\-un\-srt\-glos\-saries}%
184 {%
185 \providedby{\sty{glossaries-extra} v1.08+}
186 \desc{iterates over all glossaries and does
187 \code{\gls{printunsrtglossary}\oarg{\printglossoptval{type}{\meta{type}}}}
188 for each \idx{glossary}}
189 }
190 % \glsdefaulttype
191 \gcmd{gls\-default\-type}%
192 {%
193 \providedby{\sty{glossaries}}
194 \initval{main}%
195 \desc{expands to the label of the default \idx{glossary}}
196 }%
197 % \acronymname
198 \gcmd{acronym\-name}%
199 {%
200 \providedby{\sty{glossaries}}
201 \initval{Acronyms}%
202 \note{language-sensitive}
203 \desc{expands to the title of the \code{acronym} \idx{glossary}}
204 }%
205 % \loadglsentries
206 \gcmd{load\-gls\-entries}
207 {
208 \providedby{\sty{glossaries}}%
209 \syntax{\oargm{type}\margm{filename}}
210 \desc{locally assigns \gls{glsdefaulttype} to \meta{type} and
211 inputs \meta{filename}. If the optional argument is omitted,
212 the default glossary is assumed. Note that if any entries within
213 \meta{filename} have the \gloskey{type} key set (including
214 implicitly in commands like \gls{newacronym}), then this will
215 override the type given in the optional argument}
216 }
217 % \makeglossaries
218 \gcmd{make\-glos\-saries}
219 {
220 \providedby{\sty{glossaries}}
221 \desc{opens the associated \idx{glossary} files that need to be
222 processed by \app+{makeindex} or \app+{xindy}}
223 }
224 % \makenoidxglossaries
225 \gcmd{make\-no\-idx\-glos\-saries}%
226 {%
227 \providedby{\sty{glossaries} v4.04+}
228 \desc{sets up all glossaries so that they can be displayed
229 with \gls{printnoidxglossary}}
230 }
231 % \GlsXtrLoadResources
232 \gcmd{Gls\-Xtr\-Load\-Resources}%
233 {%
234 \providedby{\sty{glossaries-extra} v1.11+}
235 \syntax{\oargm{options}}
236 \desc{for use with \app{bib2gls}, this both sets up the resource options
237 (which \app{bib2gls} can detect from the \ext{aux} file) and
238 inputs the \ext{glstex} file created by \app{bib2gls}}
239 }
240 % \newglossaryentry
241 \gcmd{new\-glos\-sary\-entry}
242 {
243 \providedby{\sty{glossaries}}
244 \syntax{\margm{label}\marg{\keyvallist}}
245 \desc{defines a new \idx{glossary} entry with the given label. The
246 second argument is a comma-separated list of \idxpl{gloskey}}
247 }
248 % \longnewglossaryentry
249 \gcmd{long\-new\-glos\-sary\-entry}%
250 {%
251 \providedby{\sty{glossaries}}
252 \syntax{\margm{label}\margm{key=value list}\margm{description}}
253 \desc{defines a new \idx{glossary} entry with the given label. The
254 second argument is a comma-separated list of \idxpl{gloskey}.
255 The third argument is the description, which may include
256 paragraph breaks}
257 }
258 % \newterm
259 \gcmd{new\-term}%
260 {%
261 \syntax{\oargm{key=value list}\margm{entry-label}}
262 \note{requires \opt{index} package option}
263 \desc{defines a new \idx{glossary} entry with the given label,
264 \gloskey{type} set to \code{index}, the \gloskey{name}
265 set to \meta{entry-label} and the \gloskey{description}
266 set to \gls{nopostdesc}. The
267 optional argument is a comma-separated list of \idxpl{gloskey},
268 which can be used to override the defaults}
269 }
270 % \glsnamefont
271 \gcmd{gls\-name\-font}
272 {
273 \providedby{\sty{glossaries}}
274 \syntax{\margm{text}}
275 \desc{used within the predefined glossary styles to apply a font change to the
276 \gloskey{name}}
277 }
278 % \gls
279 \gcmdsp{gls}
280 {
281 \providedby{\sty{glossaries}}
282 \syntax{\oargm{options}\margm{label}\oargm{insert}}
283 \desc{references the entry identified by \meta{label}. The text
284 produced may vary depending on whether or not this is the \idx{firstuse}}
285 }
286 % \glspl
287 \gcmdsp{glspl}
288 {
289 \providedby{\sty{glossaries}}
290 \syntax{\oargm{options}\margm{label}\oargm{insert}}
291 \desc{as \gls{gls} but uses the plural form}
292 }
293 % \Gls
294 \gcmdsp{Gls}
295 {
296 \providedby{\sty{glossaries}}
297 \syntax{\oargm{options}\margm{label}\oargm{insert}}
298 \desc{as \gls{gls} but converts the first character of the
299 \idx{linktext} to \idx{uppercase}\glsadd{idx.sentencecase} (for
300 the start of a sentence) using \gls{makefirstuc}}
301 }
302 % \Glspl
303 \gcmdsp{Glspl}
304 {
305 \providedby{\sty{glossaries}}
306 \syntax{\oargm{options}\margm{label}\oargm{insert}}
307 \desc{as \gls{Gls} but uses the plural form}
308 }
309 % \glssymbol
310 \gcmdsp{gls\-symbol}{%
311 \syntax{\oargm{options}\margm{label}\oargm{insert}}
312 \desc{references the entry identified by \meta{label}. The text
313 produced is obtained from the \gloskey{symbol} value.
314 The \meta{insert} argument will be inserted at the end of the
315 \idx{linktext}. This command does not alter or depend on the
316 \idx{firstuseflag}}
317 }
318 % \glslink
319 \gcmdsp{gls\-link}
320 {
321 \providedby{\sty{glossaries}}
322 \syntax{\oargm{options}\margm{label}\margm{text}}
323 \desc{references the entry identified by \meta{label} with the
324 given \meta{text} as the \idx{linktext}. This command doesn't
325 change the \idx{firstuseflag}}
326 }
327 % \glsadd
328 \gcmd{gls\-add}
329 {
330 \providedby{\sty{glossaries}}
331 \syntax{\oargm{options}\margm{label}}
332 \desc{indexes the entry identified by \meta{label} without
333 producing any text. This ensures the entry appears in the
334 \idx{glossary}}
335 }
336 % \glsfmttext
337 \gcmd{gls\-fmt\-text}
338 {
339 \syntax{\margm{entry-label}}
340 \desc{for use within captions or section titles to display the
341 formatted \gloskey{text}}
342 }
343 % \glsfmtshort
344 \gcmd{gls\-fmt\-short}
345 {
346 \syntax{\margm{entry-label}}
347 \desc{for use within captions or section titles to display the
348 formatted short form}
349 }
350 % \glsentrytext
351 \gcmd{gls\-entry\-text}
352 {%
353 \providedby{\sty{glossaries}}
354 \syntax{\margm{entry-label}}
355 \desc{simply expands to the value of the \gloskey{text} field.
356 Does nothing if the entry hasn't been defined. May be used in
357 expandable contexts provided that the \gloskey{text} field doesn't
358 contain any fragile commands}
359 }
360 % \glsentryshort
361 \gcmd{gls\-entry\-short}
362 {%
363 \providedby{\sty{glossaries}}
364 \syntax{\margm{entry-label}}
365 \desc{simply expands to the value of the \gloskey{short} field.
366 Does nothing if the entry hasn't been defined. May be used in
367 expandable contexts provided that the \gloskey{short} field doesn't
368 contain any fragile commands}
369 }
370 % \glsentrylong
371 \gcmd{gls\-entry\-long}
372 {%
373 \providedby{\sty{glossaries}}
374 \syntax{\margm{entry-label}}
375 \desc{simply expands to the value of the \gloskey{long} field.
376 Does nothing if the entry hasn't been defined. May be used in
377 expandable contexts provided that the \gloskey{long} field doesn't
378 contain any fragile commands}
379 }
380 % \glsabbrvscfont
381 \gcmd{gls\-abbrv\-sc\-font}
382 {
383 \providedby{\sty{glossaries-extra} v1.17+}
384 \syntax{\margm{text}}
385 \desc{short form font used by the small-caps \qt{sc} abbreviation styles}
386 }
387 % \glslongonlyfont
388 \gcmd{gls\-long\-only\-font}
389 {
390 \providedby{\sty{glossaries-extra} v1.17+}
391 \syntax{\margm{text}}
392 \desc{long form font used by the \qt{only} abbreviation styles}
393 }
394 % \glsabbrvonlyfont
395 \gcmd{gls\-abbrv\-only\-font}
396 {
397 \providedby{\sty{glossaries-extra} v1.17+}
398 \syntax{\margm{text}}
399 \desc{short form font used by the \qt{only} abbreviation styles}
400 }
401 % \glsxtrnewsymbol
402 \gcmd{gls\-xtr\-new\-symbol}%
403 {%
404 \syntax{\oargm{key=value list}\margm{label}\margm{sym}}
405 \providedby{\sty{glossaries-extra}}
406 \note{requires \code{\csfmt{usepackage}\oarg{\opt{symbols}}\marg{glossaries-extra}}}
407 \desc{defines a new \idx{glossary} entry with the given label,
408 \gloskey{type} set to \code{symbols}, the \gloskey{category} set
409 to \code{symbol}, the \gloskey{name} set to \meta{sym} and the \gloskey{sort}
410 set to \meta{label}. The optional argument is a comma-separated list of \idxpl{gloskey},
411 which can be used to override the defaults}
412 }
413 % \newacronym
414 \gcmd{new\-acronym}
415 {
416 \providedby{\sty{glossaries}}
417 \syntax{\oargm{options}\margm{label}\margm{short}\margm{long}}
418 \desc{this command is provided by the base \sty{glossaries}
419 package but is redefined by \sty{glossaries-extra} to use
420 \gls{newabbreviation} with the \gloskey{category} key set to
421 \cat{acronym}. With just the base \sty{glossaries} package, use
422 \gls{setacronymstyle} to set the style. With
423 \sty{glossaries-extra}, use
424 \code{\gls{setabbreviationstyle}\oarg{\cat{acronym}}\margm{style}} to
425 set the style that governs \gls{newacronym}}
426 }
427 % \setacronymstyle
428 \gcmd{set\-acronym\-style}
429 {
430 \providedby{\sty{glossaries}}
431 \syntax{\oargm{glossary-type}\margm{style-name}}
432 \desc{sets the acronym style. Don't use with \sty{glossaries-extra}}
433 }
434 % \newabbreviation
435 \gcmd{new\-abbreviation}
436 {
437 \providedby{\sty{glossaries-extra}}
438 \syntax{\oargm{options}\margm{label}\margm{short}\margm{long}}
439 \desc{defines a new entry that represents an abbreviation.
440 This internally uses \gls{newglossaryentry} and any provided
441 \meta{options} (\idxpl{gloskey}) will be appended. The
442 \gloskey{category} is set to \cat{abbreviation} by default, but
443 may be overridden in \meta{options}. The
444 appropriate style should be set before the abbreviation is
445 defined with \gls{setabbreviationstyle}}
446 }
447 % \setabbreviationstyle
448 \gcmd{set\-abbreviation\-style}
449 {
450 \providedby{\sty{glossaries-extra}}
451 \syntax{\oargm{category}\margm{style-name}}
452 \desc{sets the current \idx{abbrstyle} to \meta{style-name}
453 for the category identified by \meta{category}. If the
454 optional argument is omitted, \cat{abbreviation} is assumed}
455 }
456 % \acrlong
457 \gcmdsp{acr\-long}
458 {
459 \providedby{\sty{glossaries}}
460 \syntax{\oargm{options}\margm{label}\oargm{insert}}
461 \desc{displays the long form of an acronym. Only for use with
462 the base \sty{glossaries} package's acronym mechanism. With
463 \sty{glossaries-extra}, use \gls{glsxtrlong} instead}
464 }
465 % \acrshort
466 \gcmdsp{acr\-short}
467 {
468 \providedby{\sty{glossaries}}
469 \syntax{\oargm{options}\margm{label}\oargm{insert}}
470 \desc{displays the short form of an acronym. Only for use with
471 the base \sty{glossaries} package's acronym mechanism. With
472 \sty{glossaries-extra}, use \gls{glsxtrshort} instead}
473 }
474 % \glsxtrlong
475 \gcmdsp{gls\-xtr\-long}
476 {
477 \providedby{\sty{glossaries-extra}}
478 \syntax{\oargm{options}\margm{label}\oargm{insert}}
479 \desc{displays the long form of an abbreviation}
480 }
481 % \glsxtrshort
482 \gcmdsp{gls\-xtr\-short}
483 {
484 \providedby{\sty{glossaries-extra}}
485 \syntax{\oargm{options}\margm{label}\oargm{insert}}
486 \desc{displays the short form of an abbreviation}
487 }
488 % \ifglsused
489 \gcmd{if\-gls\-used}
490 {
491 \providedby{\sty{glossaries}}
492 \syntax{\margm{label}\margm{true text}\margm{false text}}
493 \desc{does \meta{true} if the entry has been marked as
494 \idxc{firstuseflag}{used} and does \meta{false} if the entry is
495 marked as \idxc{firstuseflag}{unused}}
496 }
497 % \glsnoexpandfields
498 \gcmd{gls\-no\-expand\-fields}
499 {
500 \providedby{\sty{glossaries}}
501 \desc{don't expand field values when defining entries, except
502 for those that explicitly have expansion enabled}
503 }
504 % \glsreset
505 \gcmd{gls\-reset}
506 {
507 \providedby{\sty{glossaries}}
508 \syntax{\margm{label}}
509 \desc{globally resets the entry's \idx{firstuseflag}. That is, this marks the entry
510 as \qt{not used}}
511 }
512 % \glsunset
513 \gcmd{gls\-unset}
514 {
515 \providedby{\sty{glossaries}}
516 \syntax{\margm{label}}
517 \desc{globally unsets the entry's \idx{firstuseflag}. That is, this marks the entry
518 as \qt{used}}
519 }
520 % \glsresetall
521 \gcmd{gls\-reset\-all}
522 {
523 \providedby{\sty{glossaries}}
524 \syntax{\oargm{types}}
525 \desc{globally resets all entries associated with the listed
526 glossaries or all glossaries if \meta{types} is omitted}
527 }
528 % \glsunsetall
529 \gcmd{gls\-unset\-all}
530 {
531 \providedby{\sty{glossaries}}
532 \syntax{\oargm{types}}
533 \desc{globally unsets all entries associated with the listed
534 glossaries or all glossaries if \meta{types} is omitted}
535 }
536 % \glslowercase
537 \gcmd{gls\-lower\-case}
538 {
539 \providedby{\sty{glossaries} v4.50+}
540 \syntax{\margm{text}}
541 \desc{converts \meta{text} to \idx{lowercase} using the modern \LaTeX3
542 case-changing command, which is expandable}
543 }
544 % \makefirstuc
545 \gcmd{make\-first\-uc}%
546 {%
547 \syntax{\margm{text}}
548 \providedby{\sty{mfirstuc}}
549 \desc{robust command that converts the first character of \meta{text} to
550 \idx{uppercase} (\idx{sentencecase}). See the \sty{mfirstuc}
551 documentation for further details, either:
552 \texdocref{mfirstuc} or visit \ctanpkg{mfirstuc}}
553 }
554 % \nopostdesc
555 \gcmd{no\-post\-desc}
556 {%
557 \providedby{\sty{glossaries} v1.17+}
558 \desc{when placed at the end of the \gloskey{description}, this
559 switches off the post-description punctuation (if it has been
560 enabled). Does nothing outside of the \idx{glossary}}
561 }
562 % \seename
563 \gcmd{see\-name}
564 {
565 \providedby{\sty{glossaries}}
566 \initval{see}
567 \note{language-sensitive}
568 \desc{used as a cross-reference tag}
569 }
570 % \seealsoname
571 \gcmd{see\-also\-name}
572 {
573 \providedby{\sty{glossaries-extra}}
574 \initval{see also}
575 \note{language-sensitive}
576 \desc{used as a cross-reference tag}
577 }
578 % \newglossaryentry (glossentry) keys
579 \gidxpl{gloskey}{%
580 \common
581 \field{text}{glossary entry key}
582 \desc{these are options that can be passed to commands that
583 define entries, such as \gls{newglossaryentry} or
584 \gls{newabbreviation}}
585 }
586 % glossentry name
587 \ggloskey{name}%
588 {%
589 \syntax{\margm{text}}
590 \desc{the entry's name, as displayed in the \idx{glossary}}
591 }
592 % glossentry description
593 \ggloskey{description}%
594 {%
595 \syntax{\margm{text}}
596 \desc{the entry's description, as displayed in the \idx{glossary}}
597 }
598 % glossentry type
599 \ggloskey{type}%
600 {%
601 \syntax{\meta{\idx{glossary}-label}}
602 \initval{\gls{glsdefaulttype}}%
603 \desc{assigns the entry to the \idx{glossary} identified by
604 \meta{\idx{glossary}-label}}
605 }
606 % glossentry parent
607 \ggloskey{parent}%
608 {%
609 \syntax{\meta{parent-label}}
610 \desc{the label of the entry's parent (from which the entry's
611 hierarchical level is obtained)}
612 }
613 % glossentry category
614 \ggloskey{category}%
615 {%
616 \syntax{\meta{category-label}}%
617 \initval{general}%
618 \providedby{\sty{glossaries-extra}}
619 \desc{the entry's \idx{category} (must be a simple label)}
620 }
621 % glossentry sort
622 \ggloskey{sort}%
623 {%
624 \syntax{\meta{value}}
625 \initval{\meta{entry name}}
626 \desc{specifies the value to use for sorting (overrides the
627 default). This key is usually required for \app+{xindy} if the
628 \gloskey{name} key only contains commands (for example, the
629 entry is a symbol), but explicitly using this key in other
630 contexts can break certain sort methods.
631 \gallerypage{bib2gls-sorting}{Don't use the \gloskey{sort} field
632 with \app{bib2gls}}}
633 }
634 % glossentry see
635 \ggloskey{see}%
636 {%
637 \syntax{\oargm{tag}\margm{label-list}}
638 \desc{indexes each item in \meta{label-list} with the
639 cross-reference in place of a normal location}
640 }
641 % glossentry seealso
642 \ggloskey{see\-also}%
643 {%
644 \providedby{\sty{glossaries-extra}}
645 \syntax{\margm{label-list}}
646 \desc{like \gloskey{see} but always uses \gls{seealsoname} as the tag}
647 }
648 % glossentry alias
649 \ggloskey{alias}%
650 {%
651 \providedby{\sty{glossaries-extra}}
652 \syntax{\margm{xr-label}}
653 \desc{like \gloskey{see} but only allows a single
654 cross-reference with no optional tag, and sets up aliasing, which
655 changes the hyperlink target}
656 }
657 % glossentry text
658 \ggloskey{text}%
659 {%
660 \syntax{\margm{text}}
661 \desc{the entry's text, as displayed on \idx{subsequentuse} of
662 \gls{glslike} commands. If omitted, this value is assumed to be
663 the same as the \gloskey{name} key}
664 }
665 % glossentry plural
666 \ggloskey{plural}%
667 {%
668 \syntax{\margm{text}}
669 \desc{the entry's plural form, as displayed on \idx{subsequentuse} of
670 plural \gls{glslike} commands, such as \gls{glspl}. This should
671 be the appropriate plural form of the value provided by the
672 \gloskey{text} key. If omitted, this value is assumed to be the
673 value of the \gloskey{text} key with \gls{glspluralsuffix}
674 appended}
675 }
676 % glossentry symbol
677 \ggloskey{symbol}%
678 {%
679 \initval{\gls{relax}}
680 \syntax{\margm{symbol}}
681 \desc{the entry's associated symbol (optional), which can be
682 displayed with \gls{glssymbol} (if \gls{indexing} and hyperlinks are
683 required) or with \gls{glsentrysymbol}}
684 }
685 % glossentry first
686 \ggloskey{first}%
687 {%
688 \syntax{\margm{first}}
689 \desc{the entry's text, as displayed on \idx{firstuse} of
690 \gls{glslike} commands. If omitted,
691 this value is assumed to be the same as the \gloskey{text} key}
692 }
693 % glossentry firstplural
694 \ggloskey{first\-plural}%
695 {%
696 \syntax{\margm{text}}
697 \desc{the entry's plural form, as displayed on \idx{firstuse} of
698 plural \gls{glslike} commands, such as \gls{glspl}. If this key
699 is omitted, then the value will either be the same as the
700 \gloskey{plural} field, if the \gloskey{first} key wasn't used, or
701 the value will be taken from the \gloskey{first} key with
702 \gls{glspluralsuffix} appended}
703 }
704 % glossentry short
705 \ggloskey{short}%
706 {%
707 \syntax{\margm{short form}}
708 \desc{a key that is set implicitly by \gls{newabbreviation}
709 and \gls{newacronym} to the entry's short (abbreviated) form. It
710 typically shouldn't be used explicitly with
711 \gls{newglossaryentry}. However, if you are using \app{bib2gls}
712 then this field should be used in the \ext{bib} file when
713 defining abbreviations}
714 }
715 % glossentry long
716 \ggloskey{long}%
717 {%
718 \syntax{\margm{long form}}
719 \desc{a key that is set implicitly by \gls{newabbreviation}
720 and \gls{newacronym} to the entry's long (unabbreviated) form. It
721 typically shouldn't be used explicitly with
722 \gls{newglossaryentry}. However, if you are using \app{bib2gls}
723 then this field should be used in the \ext{bib} file when
724 defining abbreviations}
725 }
726 % glossentry shortplural
727 \ggloskey{short\-plural}%
728 {%
729 \syntax{\margm{plural short form}}
730 \desc{the plural corresponding to the \gloskey{short} key if the
731 default value is inappropriate}
732 }
733 % glossentry longplural
734 \ggloskey{long\-plural}%
735 {%
736 \syntax{\margm{plural long form}}
737 \desc{the plural corresponding to the \gloskey{long} key if the
738 default value is inappropriate}
739 }
740 % glossentry user1
741 \ggloskey{user1}%
742 {%
743 \syntax{\margm{text}}
744 \desc{a generic field, which can be
745 displayed with \gls{glsuseri} (if \gls{indexing} and hyperlinks are
746 required) or with \gls{glsentryuseri}}
747 }
748 % package option style
749 \gstyopt{style}%
750 {%
751 \syntax{\meta{style-name}}
752 }
753 % package option nogroupskip
754 \gstyopt{no\-group\-skip}
755 {
756 \initval{false}
757 \defval{true}
758 \syntax{\meta{boolean}}
759 }
760 % package option nopostdot
761 \gstyopt{no\-post\-dot}
762 {
763 \initval{false}
764 \defval{true}
765 \syntax{\meta{boolean}}
766 }
767 % package option postdot
768 \gstyopt{post\-dot}{\providedby{\sty{glossaries-extra}}}
769 % package option nonumberlist
770 \gstyopt{no\-number\-list}{}
771 % package option symbols
772 \gstyopt{symbols}{}
773 % package option numbers
774 \gstyopt{numbers}{}
775 % package option index
776 \gstyopt{index}{}
777 % package option abbreviations
778 \gstyopt{abbreviations}{}
779 % package option counter
780 \gstyopt{counter}%
781 {%
782 \syntax{\meta{counter-name}}
783 }
784 % package option toc
785 \gstyopt{toc}%
786 {%
787 \syntax{\meta{boolean}}
788 }
789 % package option section
790 \gstyopt{section}
791 {
792 \syntax{\meta{value}}
793 }
794 % package option acronym
795 \gstyopt{acronym}%
796 {%
797 \initval{false}
798 \defval{true}
799 \syntax{\meta{boolean}}
800 }
801 % package option acronyms
802 \gstyopt{acronyms}{}
803 % package option stylemods
804 \gstyopt{style\-mods}{}
805 % package option sort
806 \gstyopt{sort}%
807 {%
808 \syntax{\meta{setting}}
809 }
810 % package option sanitizesort
811 \gstyopt{sanitize\-sort}{}
812 % package option record
813 \gstyopt{record}%
814 {%
815 \initval{off}
816 \defval{only}
817 \syntax{\meta{setting}}
818 }
819 % package option automake
820 \gstyopt{auto\-make}{}
821 % package option xindy
822 \gstyopt{xindy}{}
823 % package option makeindex
824 \gstyopt{make\-index}{}
825 % package option upmendex
826 \gstyopt{up\-mendex}{}
827 % package option order
828 \gstyopt{order}{}
829 % package option nohypertypes
830 \gstyopt{no\-hyper\-types}{\syntax{\margm{label list}}}
831 % package option hyperfirst
832 \gstyopt{hyper\-first}
833 {
834 \initval{true}
835 \defval{true}
836 \syntax{\meta{boolean}}
837 }
838 % category: abbreviation
839 \gcat{abbreviation}{}
840 % category: acronym
841 \gcat{acronym}{}
842 % glossary style: index
843 \gglosty{index}{}
844 % glossary style: indexgroup
845 \gglosty{index\-group}{}
846 % glossary style: mcolindex
847 \gglosty{mcol\-index}{}
848 % glossary style: altlist
849 \gglosty{alt\-list}{}
850 % glossary style: long4col
851 \gglosty{long4col}{}
852 % acronym style: long-short
853 \gacrsty{long\dhyphen short}{}
854 % acronym style: long-sc-short
855 \gacrsty{long\dhyphen sc\dhyphen short}{}
856 % acronym style: long-short-desc
857 \gacrsty{long\dhyphen short\dhyphen desc}{}
858 % acronym style: short-long
859 \gacrsty{short\dhyphen long}{}
860 % acronym style: short-long-desc
861 \gacrsty{short\dhyphen long\dhyphen desc}{}
862 % abbreviation style: long-short
863 \gabbrsty{long\dhyphen short}{}
864 % abbreviation style: long-short-sc
865 \gabbrsty{long\dhyphen short\dhyphen sc}{}
866 % abbreviation style: short-nolong
867 \gabbrsty{short\dhyphen nolong}{}
868 % abbreviation style: long-only-short-only
869 \gabbrsty{long\dhyphen only\dhyphen short\dhyphen only}{}
870 % resource option src
871 \gresourceopt{src}{\syntax{bib list}}
872 % resource option type
873 \gresourceopt{type}{\syntax{glossary-label}}
874 % resource option sort
875 \gresourceopt{sort}{\syntax{method}}
876 % resource option sort-field
877 \gresourceopt{sort\dhyphen field}{\syntax{field name}}
878 % resource option save-locations
879 \gresourceopt{save\dhyphen locations}{\syntax{\meta{boolean}}}
880 % printgloss style
881 \gprintglossopt{style}{%
882 \syntax{\meta{style-name}}
883 }
884 % printgloss type
885 \gprintglossopt{type}{%
886 \syntax{\meta{glossary-label}}
887 }
888 % printgloss nonumberlist
889 \gprintglossopt{no\-number\-list}{}
890 % printgloss toctitle
891 \gprintglossopt{toc\-title}{}
892 % printgloss sort
893 \gprintglossopt{sort}{}
894 % general commands and environments
895 \gcmd{textsc}{}% \textsc
896 \gcmd{item}{}% \item
897 \gcmd{tex\-or\-pdf\-string}{}% \texorpdfstring
898 \genv{description}{}
899 % applications:
900 \gapp{make\-index}{}% makeindex
901 \gapp{up\-mendex}{}% upmendex
902 \gapp{xindy}{}
903 \gapp{make\-glos\-saries}{}
904 \gapp{make\-glos\-saries\dhyphen lite}{}% makeglossaries-lite
905 \gapp{bib2gls}{}
906 \gapp{arara}{}
907 % --group
908 \glongswitch{group}{\inapp{bib2gls}}
909 % -g
910 \gshortswitch{g}{\inapp{bib2gls}\field{alias}{switch.group}}
911 % packages
912 \gpkg{glossaries}{\common}% glossaries.sty
913 \gpkg{glossaries\dhyphen extra}{\common}% glossaries-extra.sty
914 \gpkg{glossary\dhyphen mcols}{}% glossary-mcols.sty
915 \gpkg{data\-tool}{}% datatool.sty
916 \gpkg{data\-tool\dhyphen base}{}% datatool-base.sty
917 \gmodule{data\-tool\dhyphen english}{}% datatool-english
918 \gpkg{mfirst\-uc}{}% mfirstuc.sty
919 \gpkg{hyper\-ref}{}% hyperref.sty
920 \gpkg{babel}{}% babel.sty
921 \gpkg{poly\-glossia}{}% polyglossia.sty
922 \gpkg{input\-enc}{}% inputenc.sty
923 \gpkg{font\-enc}{}% fontenc.sty
924 % files
925 \gfilemeta{glossaries\dhyphen}{language}{}{}% glossaries-<language>
926 \gfile{glossaries\dhyphen french}{}% glossaries-french
927 \gfile{glossaries\dhyphen german}{}% glossaries-german
928 \gext{log}{}
929 \gext{tex}{}
930 \gext{bib}{}
931 \gext{glo}{}
932 \gext{gls}{}
933 \gext{glg}{}
934 \gext{ist}{}
935 \gext{xdy}{}
936 \gext{aux}{}
937 \gext{glstex}{}
938 \gext{alg}{}
939 \gext{acr}{}
940 \gext{acn}{}
941 % terms
942 \gterm{field}%
943 {%
944 \name{field}
945 \desc{entry data is stored in fields. These may have a
946 corresponding key used to set the value, such as \gloskey{name}
947 or \gloskey{description}}
948 }
949 \gterm{indexing}{%
950 \name{indexing (or recording)}
951 \field{text}{indexing}
952 \desc{the process of saving the location (for example, the page number) and any
953 associated information that is required in the \idx{glossary}.
954 The data may be sorted and collated by an indexing application
955 as part of the document build}
956 }
957 \gterm{glossary}%
958 {%
959 \common
960 \name{glossary}
961 \field{plural}{glossaries}
962 \desc{technically a glossary is an alphabetical list of words
963 relating to a particular topic. For the purposes of describing
964 the \styfmt{glossaries} and \sty{glossaries-extra} packages, a
965 glossary is either the list produced by commands like
966 \gls{printglossary} or \gls{printunsrtglossary} (which may or
967 may not be ordered alphabetically) or a glossary is a set of
968 entry labels where the set is identified by the glossary label
969 or type}
970 }
971 \gterm{firstuseflag}{\name{first use flag}%
972 \common
973 \desc{a conditional that keeps track of whether or not an entry
974 has been referenced by any of the \gls{glslike} commands (which
975 can adjust their behaviour according to whether or not this flag is
976 true). The conditional is true if the entry hasn't been used by
977 one of these commands
978 (or if the flag has been reset) and false if it has been used
979 (or if the flag has been unset)}
980 }
981 \gterm{firstuse}{\name{first use}%
982 \common
983 \desc{the first time an entry is used by a command that unsets
984 the \idx{firstuseflag} (or the first time since the flag was
985 reset)}
986 }
987 \gterm{firstusetext}{\name{first use text}%
988 \common
989 \desc{the \idx{linktext} that is displayed on \idx{firstuse} of
990 the \gls{glslike} commands}
991 }
992 \gterm{subsequentuse}{\name{subsequent use}
993 \common
994 \desc{using an entry that unsets the \idx{firstuseflag} when it
995 has already been unset}
996 }
997 \gterm{glslike}{\common\name{{}\csfmt{gls}-like}
998 \desc{commands like \gls{gls} that change the
999 \idx{firstuseflag}. These commands index the entry (if indexing
1000 is enabled), create a hyperlink to the entry's \idx{glossary} listing (if enabled)
1001 and unset the \idx{firstuseflag}}
1002 }
1003 \gterm{linktext}{\name{link text}%
1004 \desc{the text produced by commands like \gls{gls} that have the
1005 potential to be a hyperlink}
1006 }
1007 \gterm{semanticcommand}{\name{semantic command}
1008 \desc{essentially, a semantic command is one that's associated with a
1009 particular document element, idea or topic that hides the font
1010 and other stylistic formatting inside its definition. For
1011 example, Latin taxonomy is usually displayed in italic.
1012 Explicitly using font commands, for example
1013 \code{\cmd{textit}\marg{Clostridium}}, is syntactic markup.
1014 Whereas defining a command called, say, \csfmt{bacteria} that
1015 displays its argument in italics is a semantic command. The
1016 actual styling is hidden and the command relates specifically to
1017 a particular concept.
1018 \begin{codebox}
1019 Syntactic: \cmd{textit}\marg{Clostridium}\codepar
1020 \cmd{newrobustcmd}*\marg{\cmd{bacteria}}[1]\marg{\cmd{emph}\marg{\#1}}\%\newline
1021 Semantic: \cmd{bacteria}\marg{Clostridium}
1022 \end{codebox}
1023 The end result is the same:
1024 \begin{resultbox}
1025 Syntactic: \textit{Clostridium}\glspar
1026 Semantic: \emph{Clostridium}
1027 \end{resultbox}
1028 The advantage with semantic commands is that it's much easier to
1029 change the style, simply by adjusting the command definition.
1030 Note that I've used \csfmt{newrobustcmd} to make the semantic
1031 command robust as the style commands can cause a problem if they
1032 expand too soon. Alternatively, use \csfmt{NewDocumentCommand}}
1033 }
1034 % index only
1035 \gidx{uppercase}{\field{seealso}{idx.sentencecase}}
1036 \gidx{lowercase}{}
1037 \gidx{sentencecase}{\name{sentence case}}
1038 \gidx{allcaps}{\name{all caps}}
1039 % punctuation
1040 \gpunc{sym.nbsp}{\name{\code{\textasciitilde} (non-breaking space)}
1041 \field{see}{idx.nbsp}
1042 }
1043 \gidx{nbsp}{\name{non-breaking space (\code{\textasciitilde})}
1044 \field{symbol}{\code{\textasciitilde}}
1045 }
1046 \gpunc{sym.colon}{\name{\code{:} (colon)}}
1047 \gpunc{unknowntag}{\name{\code{??} (unknown entry marker)}
1048 \field{text}{\code{??}}}
1049 % indexing options
1050 \gidx{opt.noidx}{\name{Option 1 (\qt{noidx})}\field{text}{1}}
1051 \gidx{opt.mkidx}{\name{Option 2 (\appfmt{makeindex}\slash\appfmt{upmendex})}\field{text}{2}}
1052 \gidx{opt.xdy}{\name{Option 3 (\appfmt{xindy})}\field{text}{3}}
1053 \gidx{opt.b2g}{\name{Option 4 (\appfmt{bib2gls})}\field{text}{4}}
1054 }
1055
1056 \title{The glossaries package v5.1:
1057 a guide for beginners}
1058 \author{Nicola L.C. Talbot\\\href{https://www.dickimaw-books.com/}{\nolinkurl{dickimaw-books.com}}}
1059 \date{2026-04-21}
1060
1061 \begin{document}
1062 \maketitle
1063
1064 \begin{abstract}
1065 The \sty{glossaries} package is very flexible, but this means
1066 that it has a~lot of options, and since a user guide is supposed to
1067 provide a complete list of all the high-level user commands, the main
1068 user manual is quite big. This can be rather
1069 daunting for beginners, so this document is a brief introduction
1070 just to help get you started. If you find yourself saying,
1071 \qt{but how can I do\ldots?} then it's time to move on to the
1072 \docref{main user manual}{glossaries-user}.
1073
1074 I've made some statements in this document that don't actually tell
1075 you the full truth, but it would clutter the document and cause
1076 confusion if I keep writing \qt{except when \ldots} or \qt{but you can
1077 also do this, that or the other} or \qt{you can do it this way but
1078 you can also do it that way, but that way may cause complications
1079 under certain circumstances}.
1080 \end{abstract}
1081
1082 \tableofcontents
1083
1084 \section{Getting Started}
1085 \label{sec:start}
1086
1087 As with all packages, you need to load \sty+{glossaries} with
1088 \csfmt{usepackage}, but there are certain packages that must be loaded
1089 before \styfmt{glossaries}, \emph{if} they are required: \sty{hyperref},
1090 \sty{babel}, \sty{polyglossia}, \sty{inputenc} and \sty{fontenc}.
1091 (You don't have to load these packages, but if you want them, you
1092 must load them before \sty{glossaries}.)
1093
1094 \begin{important}
1095 If you require multilingual support you must also install
1096 the relevant language module. Each language module is called
1097 \file{glossaries-language}, where \meta{language} is the
1098 root language name. For example, \file{glossaries-french}
1099 or \file{glossaries-german}. If a language module is required,
1100 the \sty{glossaries} package will automatically try to load it
1101 and will give a warning if the module isn't found.
1102 \end{important}
1103
1104 Once you have loaded the \sty{glossaries} package, you need to define
1105 your terms in the preamble and then you can use them throughout the
1106 document. Here's a simple example:
1107 \begin{codebox*}
1108 \cmd{documentclass}\marg{article}
1109 \cmd{usepackage}\marg{glossaries}
1110 \comment{define a term:}
1111 \gls{newglossaryentry}\marg{\strong{ex}}\marg{\gloskeyval{name}{sample},
1112 \gloskeyval{description}{an example}}
1113 \cbeg{document}
1114 Here's my \gls{gls}\marg{\strong{ex}} term.
1115 \cend{document}
1116 \end{codebox*}
1117 The above defines a simple term identified by the label \qt{ex}.
1118 When the term is referenced by its label with \gls{gls}, the
1119 provided text (\qt{sample}) is inserted into the document:
1120 \begin{resultbox}
1121 Here's my sample term.
1122 \end{resultbox}
1123 Note that a description has been given in the definition but it doesn't
1124 appear in the document yet.
1125
1126 In general, it's best to choose a label that's easy to remember and
1127 makes the source code (reasonably) easy to read. In the above example, a better
1128 label would be \qt{sample}, the same as the term itself. However,
1129 bear in mind that labels mustn't contain non-expandable content.
1130 The next example defines a term that's actually a symbol.
1131 In this case, the label must be
1132 different from the provided term, which contains the commands to
1133 typeset the symbol:
1134 \begin{codebox*}
1135 \cmd{documentclass}\marg{article}
1136 \cmd{usepackage}\marg{glossaries}
1137 \gls{newglossaryentry}\marg{\strong{emptyset}}\marg{
1138 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1139 \gloskeyval{description}{the empty set}}
1140 \cbeg{document}
1141 The empty set is denoted \gls{gls}\marg{\strong{emptyset}}.
1142 \cend{document}
1143 \end{codebox*}
1144 This produces:
1145 \begin{resultbox}
1146 The empty set is denoted $\emptyset$.
1147 \end{resultbox}
1148
1149 The next example defines a term with the label \qt{svm} that has both
1150 a long form (\qt{support vector machine}) and a short form (\qt{SVM}):
1151 \begin{codebox*}
1152 \cmd{documentclass}\marg{article}
1153 \cmd{usepackage}\marg{glossaries}
1154 \gls{setacronymstyle}\marg{\acrstyle{long-short}}
1155 \gls{newacronym}\marg{\strong{svm}}\marg{SVM}\marg{support vector machine}
1156 \cbeg{document}
1157 First use: \gls{gls}\marg{\strong{svm}}. Second use: \gls{gls}\marg{\strong{svm}}.
1158 \cend{document}
1159 \end{codebox*}
1160 This has used a different command to define the term, but the term is
1161 still referenced with \gls{gls} in the same way as before. However,
1162 the text produced by \gls{gls} now varies:
1163 \begin{resultbox}
1164 First use: support vector machine (SVM). Second use: SVM.
1165 \end{resultbox}
1166 In this case, the text (the \qt{\idx{linktext}}) produced by
1167 \code{\gls{gls}\marg{svm}}
1168 changed after the \idx{firstuse}. The \idx{firstuse} produced the
1169 long form followed by the short form in parentheses because I set
1170 the acronym style to \acrstyle{long-short}. The \idx{subsequentuse}
1171 just showed the short form.
1172
1173 I suggest you try the above examples to make sure you have the
1174 package correctly installed. If you get an \qt{undefined control
1175 sequence} error for any of the examples provided in this guide, check that the version
1176 number at the top of this document matches the version you have
1177 installed. (Open the \ext+{log} file and search for the line that
1178 starts with \qt{Package: glossaries} followed by a date and
1179 version.)
1180
1181 \begin{important}
1182 Be careful of fragile commands. If a command causes a problem when
1183 used in one of the \gls{newglossaryentry} fields, consider adding
1184 \gls{glsnoexpandfields} before you start defining your entries.
1185 Where possible use robust \idxpl{semanticcommand}.
1186 \end{important}
1187
1188 Abbreviations are slightly different if you use the extension package
1189 \sty+{glossaries-extra} (which needs to be installed separately).
1190 This automatically loads \sty{glossaries} so you don't need to
1191 explicitly load it:
1192 \begin{codebox*}
1193 \cmd{documentclass}\marg{article}
1194 \cmd{usepackage}\marg{glossaries-extra}
1195 \comment{commands provided by \sty{glossaries-extra}:}
1196 \gls{setabbreviationstyle}\marg{\abbrstyle{long-short}}
1197 \gls{newabbreviation}\marg{svm}\marg{SVM}\marg{support vector machine}
1198 \cbeg{document}
1199 First use: \gls{gls}\marg{svm}. Second use: \gls{gls}\marg{svm}.
1200 \cend{document}
1201 \end{codebox*}
1202 Since \abbrstyle{long-short} happens to be the default for
1203 \gls{newabbreviation} you may omit the \gls{setabbreviationstyle}
1204 line in this example.
1205
1206 If you still want to use \gls{newacronym} (rather than
1207 \gls{newabbreviation}) then you need the optional
1208 argument of \gls{setabbreviationstyle}:
1209 \begin{codebox*}
1210 \cmd{documentclass}\marg{article}
1211 \cmd{usepackage}\marg{glossaries-extra}
1212 \gls{setabbreviationstyle}\oarg{\cat{acronym}}\marg{\abbrstyle{long-short}}
1213 \gls{newacronym}\marg{svm}\marg{SVM}\marg{support vector machine}
1214 \cbeg{document}
1215 First use: \gls{gls}\marg{svm}. Second use: \gls{gls}\marg{svm}.
1216 \cend{document}
1217 \end{codebox*}
1218 In this example, if you omit the \gls{setabbreviationstyle} line you
1219 will notice a difference because the \abbrstyle{short-nolong} style (not
1220 the \abbrstyle{long-short} style) is the default with \gls{newacronym}.
1221 With the \abbrstyle{short-nolong} style the first use simply shows just
1222 the short form.
1223
1224 \begin{important}
1225 You can't use \gls{setacronymstyle} with \sty{glossaries-extra}.
1226 \end{important}
1227
1228 If you like, you can put all your definitions in another file (for
1229 example, \filefmt{defns.tex}) and load that file in the preamble using
1230 \gls{loadglsentries} with the filename as the argument. For example:
1231 \begin{codebox}
1232 \gls{loadglsentries}\marg{defns}
1233 \end{codebox}
1234 If you find you have a really large number of definitions that are
1235 hard to manage in a \ext+{tex} file, you might want to have a
1236 look at \app{bib2gls} (installed separately) which requires
1237 a \ext+{bib} format instead.
1238
1239 Avoid explicitly using formatting commands in abbreviation definitions
1240 as they can interfere with the underlying mechanism. Instead, the
1241 formatting should be done by the style. For example, suppose I~want
1242 to replace \code{SVM} with \code{\gls{textsc}\marg{svm}}, then
1243 I~need to select a style that uses \gls{textsc}, like this (for the
1244 base \sty{glossaries} style):
1245 \begin{codebox*}
1246 \cmd{documentclass}\marg{article}
1247 \cmd{usepackage}\marg{glossaries}
1248 \gls{setacronymstyle}\marg{\strong{\acrstyle{long-sc-short}}}
1249 \gls{newacronym}\marg{svm}\marg{svm}\marg{support vector machine}
1250 \cbeg{document}
1251 First use: \gls{gls}\marg{svm}. Second use: \gls{gls}\marg{svm}.
1252 \cend{document}
1253 \end{codebox*}
1254 The abbreviation styles have a different naming scheme with
1255 \sty{glossaries-extra}:
1256 \begin{codebox*}
1257 \cmd{documentclass}\marg{article}
1258 \cmd{usepackage}\marg{glossaries-extra}
1259 \comment{commands provided by \sty{glossaries-extra}:}
1260 \gls{setabbreviationstyle}\marg{\strong{\abbrstyle{long-short-sc}}}
1261 \gls{newabbreviation}\marg{svm}\marg{svm}\marg{support vector machine}
1262 \cbeg{document}
1263 First use: \gls{gls}\marg{svm}. Second use: \gls{gls}\marg{svm}.
1264 \cend{document}
1265 \end{codebox*}
1266 With \sty{glossaries-extra} you can have different abbreviation
1267 styles for different categories. Many of these styles have their
1268 own associated formatting commands that can be redefined
1269 for minor adjustments. See the \sty{glossaries-extra} manual for
1270 further details or \gallerypage{sample-name-font}{Gallery: Mixing Styles}.
1271
1272 As you can hopefully see from the above examples, there are two main ways of
1273 defining a term: as a general entry (\gls{newglossaryentry}) or as an
1274 abbreviation (\gls{newacronym} or, with \sty{glossaries-extra},
1275 \gls{newabbreviation}).
1276
1277 \begin{information}
1278 Regardless of the method of defining a term, the term is always
1279 given a label which is used to uniquely identify the term (like the standard
1280 \csfmt{label}\slash\csfmt{ref} or \csfmt{cite} mechanism). The label may be
1281 the same as the text produced with \gls{gls} (provided it doesn't
1282 contain any formatting commands) or may be completely different.
1283 \end{information}
1284
1285 The labels are identified in bold in the following:
1286 \begin{codebox}
1287 \gls{newglossaryentry}\marg{\strong{elite}}\marg{\gloskeyval{name}{\'elite},
1288 \gloskeyval{description}{select group}}
1289 \gls{newglossaryentry}\marg{\strong{set}}\marg{\gloskeyval{name}{set},
1290 \gloskeyval{description}{collection of distinct elements}}
1291 \gls{newglossaryentry}\marg{\strong{sym.set}}\marg{
1292 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{mathcal}\marg{S}}},
1293 \gloskeyval{description}{a set}}
1294 \gls{newacronym}\marg{\strong{tool.cnc}}\marg{CNC}\marg{computer numerical control}
1295 \gls{newacronym}\marg{\strong{police.cnc}}\marg{CNC}\marg{civil nuclear constabulary}
1296 \gls{newacronym}\marg{\strong{miltary.cnc}}\marg{CNC}\marg{commander in chief}
1297 \end{codebox}
1298
1299 With modern \TeX\ installations you should now be able to use UTF-8
1300 characters in the label, but beware of active characters. For
1301 example, \sty{babel} makes some punctuation characters, such as
1302 \idx{sym.colon}, active for certain languages. This means that the
1303 character behaves like a command which is unsuitable for a label.
1304
1305 For example, the following works:
1306 \begin{codebox}
1307 \cmd{documentclass}\marg{article}
1308 \cmd{usepackage}\marg{glossaries}
1309 \gls{newglossaryentry}\marg{sym:set}\marg{\gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{mathcal}\marg{S}}},
1310 \gloskeyval{description}{a set}}
1311 \cbeg{document}
1312 \gls{gls}\marg{sym:set}
1313 \cend{document}
1314 \end{codebox}
1315 However, if \sty{babel} is loaded with \optfmt{french} then the
1316 \idx{sym.colon} character becomes active.
1317 \begin{badcodebox}
1318 \cmd{documentclass}\marg{article}
1319 \cmd{usepackage}[T1]\marg{fontenc}
1320 \cmd{usepackage}[french]\marg{babel}
1321 \cmd{usepackage}\marg{glossaries}
1322 \codepar
1323 \comment{the colon : is a normal character here}
1324 \gls{newglossaryentry}\marg{sym:set}\marg{
1325 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{mathcal}\marg{S}}},
1326 \gloskeyval{description}{a set}}
1327 \codepar
1328 \cbeg{document}
1329 \comment{the colon : is now an active character}
1330 \gls{gls}\marg{sym:set}
1331 \cend{document}
1332 \end{badcodebox}
1333 You may find that the above example seems to work, but a problem
1334 will occur if \sty{hyperref} and a \idx{glossary} list are added to the
1335 document as the active character will interfere with the hyperlink
1336 target name.
1337
1338 \begin{important}
1339 Don't use \gls{gls} in chapter or section headings as it can have
1340 some unpleasant side-effects. Instead use \gls{glsentrytext} for
1341 regular entries and either \gls{glsentryshort} or \gls{glsentrylong}
1342 for acronyms. Alternatively use
1343 \sty{glossaries-extra} which provides special commands for use in
1344 section headings and captions, such as \gls{glsfmttext} and \gls{glsfmtshort}.
1345 \end{important}
1346
1347 The above examples are reasonably straightforward. The difficulty
1348 comes if you want to display a \emph{sorted} list of all the entries you
1349 have used in the document. The \sty{glossaries-extra} package
1350 provides an easy way of listing all the defined entries:
1351 \begin{codebox}
1352 \cmd{documentclass}\marg{article}
1353 \codepar
1354 \cmd{usepackage}[\optval{sort}{none}]\marg{glossaries-extra}
1355 \codepar
1356 \gls{newglossaryentry}\marg{potato}\marg{\gloskeyval{name}{potato},
1357 \gloskeyval{plural}{potatoes},
1358 \gloskeyval{description}{starchy tuber}}
1359 \codepar
1360 \gls{newglossaryentry}\marg{cabbage}\marg{\gloskeyval{name}{cabbage},
1361 \gloskeyval{description}{vegetable with thick green
1362 or purple leaves}}
1363 \codepar
1364 \gls{newglossaryentry}\marg{turnip}\marg{\gloskeyval{name}{turnip},
1365 \gloskeyval{description}{round pale root vegetable}}
1366 \codepar
1367 \gls{newglossaryentry}\marg{carrot}\marg{\gloskeyval{name}{carrot},
1368 \gloskeyval{description}{orange root}}
1369 \codepar
1370 \cbeg{document}
1371 Chop the \gls{gls}\marg{cabbage}, \gls{glspl}\marg{potato} and
1372 \gls{glspl}\marg{carrot}.
1373 \codepar
1374 \gls+{printunsrtglossaries} \comment{list all entries}
1375 \cend{document}
1376 \end{codebox}
1377 However this method doesn't sort the entries (they're listed in
1378 order of definition) and it will display all the defined entries,
1379 regardless of whether or not you've used them all in the document,
1380 so \qt{turnip} appears in the glossary even though there's
1381 no \code{\gls{gls}\marg{turnip}} (or similar) in the document.
1382
1383 The \optval{sort}{none} option isn't essential in this case (there's
1384 no other sort option available for this document), but it prevents
1385 the automatic construction of the sort value and so slightly
1386 improves the document build time.
1387
1388 This example document uses the same command
1389 (\gls{printunsrtglossaries}) that's used with \app{bib2gls} (\option{b2g})
1390 but with \app{bib2gls} you instead need to use the
1391 \opt{record} package option (not \opt{sort}) and one or more instances of
1392 \gls{GlsXtrLoadResources} in the preamble (more on this later).
1393
1394 Most users prefer to have an automatically sorted list that only
1395 contains entries that have been used in the document, optionally
1396 with a page list (\gls{indexing}).
1397 The \sty{glossaries} package provides
1398 three options: use \TeX\ to perform the sorting (\option{noidx}); use
1399 \app{makeindex} or \app{upmendex} to perform the sorting (\option{mkidx}); use \app{xindy} to
1400 perform the sorting (\option{xdy}). The extension package \sty{glossaries-extra}
1401 provides a fourth method: use \app{bib2gls} (\option{b2g}).
1402
1403 The first option (using \TeX) is the simplest method, as it doesn't
1404 require an external tool. It works best with at least version 3.0 of
1405 the \sty{datatool-base} package, which is provided with
1406 \sty{datatool} (and automatically loaded by \sty{glossaries}).
1407 That version introduced the ability to provide localisation support,
1408 which needs to be installed separately. (See the \sty{datatool}
1409 manual for further details.)
1410
1411 To use this method, add
1412 \gls{makenoidxglossaries} to the preamble (before the entries are
1413 defined) and put \gls{printnoidxglossaries} at the place where
1414 you want your glossary.
1415 For example:
1416 \begin{codebox}
1417 \cmd{documentclass}\marg{article}
1418 \codepar
1419 \cmd{usepackage}\marg{glossaries}
1420 \codepar
1421 \gls{makenoidxglossaries} \comment{use TeX to sort}
1422 \codepar
1423 \gls{newglossaryentry}\marg{potato}\marg{\gloskeyval{name}{potato},
1424 \gloskeyval{plural}{potatoes},
1425 \gloskeyval{description}{starchy tuber}}
1426 \codepar
1427 \gls{newglossaryentry}\marg{cabbage}\marg{\gloskeyval{name}{cabbage},
1428 \gloskeyval{description}{vegetable with thick green
1429 or purple leaves}}
1430 \codepar
1431 \gls{newglossaryentry}\marg{turnip}\marg{\gloskeyval{name}{turnip},
1432 \gloskeyval{description}{round pale root vegetable}}
1433 \codepar
1434 \gls{newglossaryentry}\marg{carrot}\marg{\gloskeyval{name}{carrot},
1435 \gloskeyval{description}{orange root}}
1436 \codepar
1437 \cbeg{document}
1438 Chop the \gls{gls}\marg{cabbage}, \gls{glspl}\marg{potato} and
1439 \gls{glspl}\marg{carrot}.
1440 \codepar
1441 \gls{printnoidxglossaries}
1442 \cend{document}
1443 \end{codebox}
1444
1445 Try this out and run \LaTeX\ (or \pdfLaTeX) \emph{twice}. The first
1446 run won't show the \idx{glossary}. It will only appear on the second run.
1447 This doesn't include \qt{turnip} in the \idx{glossary} because that term
1448 hasn't been referenced (with commands like \code{\gls{gls}\marg{turnip}})
1449 in the document.
1450
1451 The glossary has a vertical gap between the \qt{carrot} term and the
1452 \qt{potato} term. This is because the entries in the glossaries are
1453 grouped according to their first letter. If you don't want this gap,
1454 just add \opt{nogroupskip} to the package options:
1455 \begin{codebox}
1456 \cmd{usepackage}[\opt{nogroupskip}]\marg{glossaries}
1457 \end{codebox}
1458 or you may want to try out a style that shows the group headings:
1459 \begin{codebox*}
1460 \cmd{usepackage}[\optval{style}{\glostyle{indexgroup}}]\marg{glossaries}
1461 \end{codebox*}
1462 If you try out this example you may also notice that the description
1463 is followed by a full stop (period) and a number. The number is the
1464 location in the document where the entry was referenced (page~1 in this
1465 case), so you can look up the term in the \idx{glossary} and be directed to
1466 the relevant pages. It may be that you don't want this
1467 back-reference, in which case you can suppress it using the
1468 \opt{nonumberlist} package option:
1469 \begin{codebox}
1470 \cmd{usepackage}[\opt{nonumberlist}]\marg{glossaries}
1471 \end{codebox}
1472 If you don't like the terminating full stop, you can suppress that
1473 with the \opt{nopostdot} package option:
1474 \begin{codebox}
1475 \cmd{usepackage}[\opt{nopostdot}]\marg{glossaries}
1476 \end{codebox}
1477 The \sty{glossaries-extra} package has this option as the default,
1478 so if you want terminating full stop, you need to explicitly add it
1479 with the \opt{postdot} option:
1480 \begin{codebox}
1481 \cmd{usepackage}[\opt{postdot}]\marg{glossaries-extra}
1482 \end{codebox}
1483
1484 You may have noticed that I've used another command in the above examples:
1485 \glsadd{glslike}\gls{glspl}. This displays the plural form. By default, this is just
1486 the singular form with the letter \qt{s} appended, but in the case of
1487 \qt{potato} I had to specify the correct plural using the
1488 \gloskey{plural} key.
1489
1490 Using \TeX\ to sort the entries is the simplest but least efficient
1491 method. If you have a large \idx{glossary}, then you will have a
1492 much faster build time if you use \app{makeindex} (\option{mkidx})
1493 or \app{xindy} (\option{xdy}) or \app{bib2gls} (\option{b2g}). If
1494 you are using extended Latin or non-Latin characters, then
1495 \app{upmendex} or \app{xindy} or \app{bib2gls} are the recommended methods. These
1496 methods are described in more detail in
1497 \sectionref{sec:printglossaries}.
1498
1499 The rest of this document briefly describes the main commands
1500 provided by the \sty{glossaries} package. (Most of these are also
1501 available with \sty{glossaries-extra} but may behave slightly
1502 differently.)
1503
1504 \section{Defining Terms}
1505 \label{sec:defterm}
1506
1507 When you use the \sty{glossaries} package, you need to define
1508 glossary entries before you can reference them. This is best
1509 done in the document preamble, as shown in the earlier examples, or
1510 in a separate file that's input in the preamble.
1511
1512 These entries could be a~word, phrase, abbreviation or symbol.
1513 They're usually accompanied by a~description, which could be a short
1514 sentence or an in-depth explanation that spans multiple paragraphs.
1515 The simplest method of defining an entry is to use:
1516 \cmddef{newglossaryentry}
1517 where \meta{label} is a unique label that identifies this entry.
1518 (Don't include the angle brackets \meta{ }. They just indicate the parts of
1519 the code that you need to change when you use this command in your document.)
1520 The two most important keys are \gloskey{name} and
1521 \gloskey{description}:
1522 \begin{compactcodebox}
1523 \gls{newglossaryentry}\margm{label}
1524 \marg{
1525 \gloskeyval{name}{\meta{name}},
1526 \gloskeyval{description}{\meta{description}},
1527 \meta{other options}
1528 }
1529 \end{compactcodebox}%
1530 The \meta{name} is the word, phrase or symbol you are defining,
1531 and \meta{description} is the description to be displayed in the
1532 glossary.
1533
1534 This command is a \qt{short} command, which means that
1535 \meta{description} can't contain a~paragraph break. If you have
1536 a~long description, you can instead use:
1537 \cmddef{longnewglossaryentry}
1538 In this case the \gloskey{name} key is in the second argument but the
1539 description is supplied in the third argument instead of via a key.
1540 \begin{compactcodebox}
1541 \gls{longnewglossaryentry}\margm{label}
1542 \marg{
1543 \gloskeyval{name}{\meta{name}},
1544 \meta{other options}
1545 }
1546 \margm{description}
1547 \end{compactcodebox}
1548
1549 Examples:
1550 \begin{enumerate}
1551 \item Define the term \qt{set} with the label \code{set}:
1552 \begin{codebox}
1553 \gls{newglossaryentry}\marg{set}
1554 \marg{
1555 \gloskeyval{name}{set},
1556 \gloskeyval{description}{a collection of objects}
1557 }
1558 \end{codebox}
1559
1560 \item Define the symbol $\emptyset$ with the label
1561 \code{emptyset}:
1562 \begin{codebox}
1563 \gls{newglossaryentry}\marg{emptyset}
1564 \marg{
1565 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1566 \gloskeyval{description}{the empty set}
1567 }
1568 \end{codebox}
1569 (This will also need a \gloskey{sort} key if you use \optionsor{noidx,xdy}, see
1570 below.)
1571
1572 \item Define the phrase \qt{Fish Age} with the label
1573 \code{fishage}:
1574 \begin{codebox}
1575 \gls{longnewglossaryentry}\marg{fishage}
1576 \marg{\gloskeyval{name}{Fish Age}}
1577 \marg{\%
1578 A common name for the Devonian geologic period
1579 spanning from the end of the Silurian Period to
1580 the beginning of the Carboniferous Period.
1581 \codepar
1582 This age was known for its remarkable variety of
1583 fish species.
1584 }
1585 \end{codebox}
1586 (The percent character discards the end of line character that would
1587 otherwise cause an unwanted space to appear at the start of the
1588 description.)
1589
1590 \item If you are using UTF-8 characters with the \sty{inputenc}
1591 package, make sure you have \sty{mfirstuc} v2.08+ installed:
1592 \begin{codebox}
1593 \comment{\sty{mfirstuc} v2.08+}
1594 \gls{newglossaryentry}\marg{\'elite}
1595 \marg{
1596 \gloskeyval{name}{\'elite},
1597 \gloskeyval{description}{select group or class}
1598 }
1599 \end{codebox}
1600 If you have an older version of \sty{mfirstuc} then any initial
1601 character that is an extended Latin or non-Latin character must be
1602 grouped in order to work with sentence-casing commands, such as
1603 \gls{Gls}. An older version possibly also means there may not be support
1604 for UTF-8 characters in labels either:
1605 \begin{codebox}
1606 \comment{\sty{mfirstuc} v2.07 or older}
1607 \gls{newglossaryentry}\marg{elite}
1608 \marg{
1609 \gloskeyval{name}{\marg{\'e}lite},
1610 \gloskeyval{description}{select group or class}
1611 }
1612 \end{codebox}
1613 Likewise if accent commands are used:
1614 \begin{codebox}
1615 \gls{newglossaryentry}\marg{elite}
1616 \marg{
1617 \gloskeyval{name}{\marg{\cmd{'}e}lite},
1618 \gloskeyval{description}{select group or class}
1619 }
1620 \end{codebox}
1621 \end{enumerate}
1622
1623 If you use \app{bib2gls} with \sty{glossaries-extra} then the
1624 terms must be defined in a \ext+{bib} file. For example:
1625 \begin{codebox}
1626 \comment{Encoding: UTF-8}
1627 \codepar
1628 \atentry{entry}\marg{set,
1629 \gloskeyval{name}{set},
1630 \gloskeyval{description}{a collection of objects}
1631 }
1632 \codepar
1633 \atentry{entry}\marg{emptyset,
1634 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1635 \gloskeyval{description}{the empty set}
1636 }
1637 \codepar
1638 \atentry{entry}\marg{fishage,
1639 \gloskeyval{name}{Fish Age},
1640 \gloskeyval{description}{A common name for the Devonian
1641 geologic period spanning from the end of the
1642 Silurian Period to the beginning of the
1643 Carboniferous Period.
1644 \codepar
1645 This age was known for its remarkable variety of
1646 fish species.}
1647 }
1648 \codepar
1649 \atentry{entry}\marg{\'elite,
1650 \gloskeyval{name}{\'elite},
1651 \gloskeyval{description}{select group or class}
1652 }
1653 \end{codebox}
1654 (The \ext+{bib} format doesn't allow spaces in labels so you can't
1655 have \code{fish age} as the label, but you can have
1656 \code{fish-age}.)
1657 This method requires \sty{glossaries-extra}['s] \opt{record}
1658 package option:
1659 \begin{codebox}
1660 \cmd{usepackage}[\opt{record}]\marg{glossaries-extra}
1661 \end{codebox}
1662 The \ext{bib} file is specified in the resource command. For
1663 example, if the \ext{bib} file is called \filefmt{entries.bib}
1664 then put the following line in the document preamble:
1665 \begin{codebox}
1666 \gls{GlsXtrLoadResources}\oarg{\resourceoptvalm{src}{entries}}
1667 \end{codebox}
1668 You can have a comma-separated list. For example, if you also
1669 have entries defined in the file \filefmt{entries2.bib}:
1670 \begin{codebox}
1671 \gls{GlsXtrLoadResources}\oarg{\resourceoptvalm{src}{entries,entries2}}
1672 \end{codebox}
1673
1674 There are other keys you can use when you define an entry. For
1675 example, the \gloskey{name} key indicates how the term
1676 should appear in the list of entries (\idx{glossary}), but if the term should
1677 appear differently when you reference it with \code{\gls{gls}\margm{label}} in
1678 the document, you need to use the \gloskey{text} key as well.
1679
1680 For example:
1681 \begin{codebox}
1682 \gls{newglossaryentry}\marg{latinalph}
1683 \marg{
1684 \gloskeyval{name}{alphabet, Latin},
1685 \gloskeyval{text}{Latin alphabet},
1686 \gloskeyval{description}{alphabet consisting of the letters
1687 a, \cmd{ldots}, z, A, \cmd{ldots}, Z}
1688 }
1689 \end{codebox}
1690 This will appear in the text as \qt{Latin alphabet} but will be listed in
1691 the glossary as \qt{alphabet, Latin} (and therefore sorted under
1692 \qt{A} not \qt{L}).
1693 With \app{bib2gls} this entry is defined in the \ext{bib}
1694 file as:
1695 \begin{codebox}
1696 \atentry{entry}\marg{latinalph,
1697 \gloskeyval{name}{alphabet, Latin},
1698 \gloskeyval{text}{Latin alphabet},
1699 \gloskeyval{description}{alphabet consisting of the letters
1700 a, \cmd{ldots}, z, A, \cmd{ldots}, Z}
1701 }
1702 \end{codebox}
1703
1704 Another commonly used key is \gloskey{plural} for specifying the
1705 plural of the term. This defaults to the value of the \gloskey{text}
1706 key with an \qt{s} appended, but if this is incorrect, just use the
1707 \gloskey{plural} key to override it:
1708 \begin{codebox}
1709 \gls{newglossaryentry}\marg{oesophagus}
1710 \marg{
1711 \gloskeyval{name}{\oe{}sophagus},
1712 \gloskeyval{plural}{\oe{}sophagi},
1713 \gloskeyval{description}{canal from mouth to stomach}
1714 }
1715 \end{codebox}
1716
1717 Abbreviations can be defined using:
1718 \cmddef{newacronym}
1719 where \meta{label} is the label (as per \gls{newglossaryentry}),
1720 \meta{short} is the short form and \meta{long} is the long form.
1721 For example, the
1722 following defines an abbreviation:
1723 \begin{codebox}
1724 \gls{newacronym}\marg{svm}\marg{SVM}\marg{support vector machine}
1725 \end{codebox}
1726 This internally uses \gls{newglossaryentry} to define an entry with
1727 the label \code{svm}. By default, the \gloskey{name} key is set to
1728 \meta{short} (\qt{SVM} in the above example) and the
1729 \gloskey{description} key is set to \meta{long} (\qt{support vector
1730 machine} in the above example). If, instead, you want to be able to
1731 specify your own description you can do this using the optional
1732 argument:
1733 \begin{codebox}
1734 \gls{newacronym}
1735 \oarg{\gloskeyval{description}{statistical pattern recognition
1736 technique}}
1737 \marg{svm}\marg{SVM}\marg{support vector machine}
1738 \end{codebox}
1739
1740 Before you define your acronyms, you need to specify which style to use with:
1741 \cmddef{setacronymstyle}
1742 where \meta{style-name} is the name of the style. There are a number
1743 of predefined styles, such as: \acrstyle{long-short} (on \idx{firstuse}
1744 display the long form with the short form in parentheses);
1745 \acrstyle{short-long} (on \idx{firstuse} display the short form with the
1746 long form in parentheses); \acrstyle{long-short-desc} (like
1747 \acrstyle{long-short} but you need to specify the description); or
1748 \acrstyle{short-long-desc} (like \acrstyle{short-long} but you need to
1749 specify the description). There are some other styles as well that
1750 use \gls{textsc} to typeset the acronym in small-caps or that use a footnote on
1751 first use. See the main user guide for further details.
1752
1753 The \sty{glossaries-extra} package provides improved abbreviation
1754 handling with \gallerypage{sample-abbr-styles}{a lot more predefined styles}.
1755 With this extension package, abbreviations are defined using:
1756 \cmddef{newabbreviation}
1757 You can still use \gls{newacronym} but it's redefined to
1758 use the new abbreviation interface. The style must now be set using:
1759 \cmddef{setabbreviationstyle}
1760 The default \meta{category} is \cat{abbreviation}. If you use
1761 \gls{newacronym} the category is \cat{acronym}, which is why you
1762 need to use the optional argument if you define abbreviations with
1763 \gls{newacronym} when \sty{glossaries-extra} has been loaded:
1764 \begin{compactcodebox*}
1765 \gls{setabbreviationstyle}\oarg{\cat{acronym}}\margm{style name}
1766 \end{compactcodebox*}
1767 If you use \app{bib2gls} then abbreviations are defined in the
1768 \ext{bib} file in the format:
1769 \begin{compactcodebox*}
1770 \atentry{abbreviation}\marg{\meta{label},
1771 \gloskeyval{long}{\meta{long form}},
1772 \gloskeyval{short}{\meta{short form}}
1773 }
1774 \end{compactcodebox*}
1775
1776 The plural forms for abbreviations can be specified using the
1777 \gloskey{longplural} and \gloskey{shortplural} keys. For example:
1778 \begin{codebox}
1779 \gls{newacronym}
1780 \oarg{\gloskeyval{longplural}{diagonal matrices}}
1781 \marg{dm}\marg{DM}\marg{diagonal matrix}
1782 \end{codebox}
1783 or (with \sty{glossaries-extra}):
1784 \begin{codebox}
1785 \gls{newabbreviation} \comxr
1786 \oarg{\gloskeyval{longplural}{diagonal matrices}}
1787 \marg{dm}\marg{DM}\marg{diagonal matrix}
1788 \end{codebox}
1789 If omitted, the defaults are again obtained by appending an \qt{s} to
1790 the singular versions. (The \sty{glossaries-extra} package provides
1791 a way of not appending \qt{s} for abbreviation plurals via category
1792 attributes.) With \app{bib2gls}, the definition in the
1793 \ext{bib} file is:
1794 \begin{codebox}
1795 \atentry{abbreviation}\marg{dm,
1796 \gloskeyval{short}{DM},
1797 \gloskeyval{long}{diagonal matrix},
1798 \gloskeyval{longplural}{diagonal matrices}
1799 }
1800 \end{codebox}
1801
1802 It's also possible to have both a~name and a~corresponding symbol.
1803 Just use the \gloskey{name} key for the name and the \gloskey{symbol} key
1804 for the symbol. For example:
1805 \begin{codebox}
1806 \gls{newglossaryentry}\marg{emptyset}
1807 \marg{
1808 \gloskeyval{name}{empty set},
1809 \gloskeyval{symbol}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1810 \gloskeyval{description}{the set containing no elements}
1811 }
1812 \end{codebox}
1813 or with \app{bib2gls} the definition in the \ext{bib} file is:
1814 \begin{codebox}
1815 \atentry{entry}\marg{emptyset,
1816 \gloskeyval{name}{empty set},
1817 \gloskeyval{symbol}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1818 \gloskeyval{description}{the set containing no elements}
1819 }
1820 \end{codebox}
1821 If you want commands such as \csfmt{emptyset} in the \gloskey{name} field
1822 then you must supply a \gloskey{sort} value with \options{noidx,xdy}
1823 otherwise you'll end up with errors from \TeX\ or \app{xindy}. With \option{mkidx}
1824 (\app{makeindex}) you're unlikely to get an error, but you may find
1825 the resulting order is a little odd. For example:
1826 \begin{codebox}
1827 \gls{newglossaryentry}\marg{emptyset}
1828 \marg{
1829 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1830 \gloskeyval{sort}{empty set},
1831 \gloskeyval{description}{the set containing no elements}
1832 }
1833 \end{codebox}
1834 This displays the symbol as $\emptyset$ but sorts according to
1835 \qt{empty set}. You may want to consider using
1836 \sty{glossaries-extra}['s] \opt{symbols} package option which
1837 provides
1838 \cmddef{glsxtrnewsymbol}
1839 This internally uses \gls{newglossaryentry} but automatically sets
1840 the \gloskey{sort} key to the \meta{label}. For example:
1841 \begin{codebox}
1842 \cmd{documentclass}\marg{article}
1843 \cmd{usepackage}[\opt{symbols}]\marg{glossaries-extra}
1844 \gls{makeglossaries}
1845 \gls{glsxtrnewsymbol}
1846 \oarg{\gloskeyval{description}{the set containing no elements}}
1847 \marg{emptyset}\comment{label (and sort value)}
1848 \marg{\cmd{ensuremath}\marg{\cmd{emptyset}}}\comment{symbol}
1849 \cbeg{document}
1850 \gls{gls}\marg{emptyset}
1851 \gls{printglossaries}
1852 \cend{document}
1853 \end{codebox}
1854 Now the sort value is automatically set to the label \qt{emptyset}.
1855
1856 With \app{bib2gls} you can define this entry in the \ext{bib} file
1857 as
1858 \begin{codebox}
1859 \atentry{entry}\marg{emptyset,
1860 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1861 \gloskeyval{description}{the set containing no elements}
1862 }
1863 \end{codebox}
1864 in which case \app{bib2gls} will try to interpret the \gloskey{name}
1865 field to determine the sort value. Alternatively you can use:
1866 \begin{codebox}
1867 \strong{\atentry{symbol}}\marg{emptyset,
1868 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1869 \gloskeyval{description}{the set containing no elements}
1870 }
1871 \end{codebox}
1872 which will use the label (\code{emptyset}) as the sort value.
1873 (You don't need the \opt{symbols} package option in this case,
1874 unless you want a separate symbols list.) The corresponding document
1875 (where the definition is in the file \filefmt{entries.bib}) is now:
1876 \begin{codebox}
1877 \cmd{documentclass}\marg{article}
1878 \cmd{usepackage}[\opt{record}]\marg{glossaries-extra}
1879 \gls{GlsXtrLoadResources}\oarg{\resourceoptvalm{src}{entries}}
1880 \cbeg{document}
1881 \gls{gls}\marg{emptyset}
1882 \gls{printunsrtglossaries}
1883 \cend{document}
1884 \end{codebox}
1885
1886 Note that, while the \gloskey{sort} key is advised for symbols when
1887 using \gls{makeglossaries} or \gls{makenoidxglossaries}, the
1888 \gloskey{sort} field shouldn't be used with \app{bib2gls}. Instead,
1889 \app{bib2gls} has its own algorithm for determining the sort value
1890 based on the entry type (\atentry{entry}, \atentry{symbol} etc) and
1891 various settings. See
1892 \gallerypage{bib2gls-sorting}{bib2gls gallery: sorting} for further
1893 details.
1894
1895 \section{Using Entries}
1896 \label{sec:useterm}
1897
1898 Once you have defined your entries, as described above, you can
1899 reference them in your document. There are a~number of commands to
1900 do this, but the most common one is:
1901 \cmddef{gls}
1902 where \meta{label} is the label you assigned to the entry when you
1903 defined it. For example, \code{\gls{gls}\marg{fishage}} will display \qt{Fish
1904 Age} in the text (given the definition from the previous section).
1905 If you are using \app{bib2gls} then this will display \idx{unknowntag} (like
1906 \csfmt{ref} and \csfmt{cite}) until \app{bib2gls} has created the
1907 relevant files and \LaTeX\ is rerun.
1908
1909 If you are using the \sty{hyperref} package (remember to load it
1910 before \sty{glossaries}) \gls{gls} will create a hyperlink to the
1911 corresponding entry in the glossary. If you want to suppress the
1912 hyperlink for a particular instance, use the starred form \code{\gls{gls}*}
1913 for example, \code{\gls{gls}*\marg{fishage}}. The other commands described in
1914 this section all have a similar starred form.
1915
1916 If the entry was defined as an acronym (using \gls{newacronym} with
1917 \sty{glossaries} described above) or an abbreviation (using
1918 \gls{newabbreviation} with \sty{glossaries-extra}), then \gls{gls}
1919 will display the full form the first time it's used (\idx{firstuse}) and just the
1920 short form on \idx{subsequentuse}. For example, if the style is
1921 set to \acrstyle{long-short}, then \code{\gls{gls}\marg{svm}} will display
1922 \qt{support vector machine (SVM)} the first time it's used, but the
1923 next occurrence of \code{\gls{gls}\marg{svm}} will just display \qt{SVM}.
1924 (If you use \gls{newacronym} with \sty{glossaries-extra} the default
1925 doesn't show the long form on \idx{firstuse}. You'll need to change the
1926 style first, as described earlier.)
1927
1928 If you want the plural form, you can use:
1929 \cmddef{glspl}
1930 instead of \code{\gls{gls}\margm{label}}. For example,
1931 \code{\gls{glspl}\marg{set}} displays \qt{sets}.
1932
1933 If the term appears at the start of a~sentence, you can convert the
1934 first letter to \idx{uppercase} (\idx{sentencecase}) using:
1935 \cmddef{Gls}
1936 for the singular form or
1937 \cmddef{Glspl}
1938 for the plural form. For example:
1939 \begin{codebox}
1940 \gls{Glspl}\marg{set} are collections.
1941 \end{codebox}
1942 produces \qt{Sets are collections}.
1943
1944 If you've specified a symbol using the \gloskey{symbol} key, you can
1945 display it using:
1946 \cmddef{glssymbol}
1947 For example
1948 \begin{codebox}
1949 \cmd{documentclass}\marg{article}
1950 \cmd{usepackage}\marg{glossaries}
1951 \gls{newglossaryentry}\marg{emptyset}
1952 \marg{
1953 \gloskeyval{name}{empty set},
1954 \gloskeyval{symbol}{\cmd{ensuremath}\marg{\cmd{emptyset}}},
1955 \gloskeyval{description}{the set containing no elements}
1956 }
1957 \cbeg{document}
1958 The \gls{gls}\marg{emptyset} is denoted \gls{glssymbol}\marg{emptyset}.
1959 \cend{document}
1960 \end{codebox}
1961 \begin{resultbox}
1962 The empty set is denoted $\emptyset$.
1963 \end{resultbox}
1964
1965 \section{Displaying a List of Entries}
1966 \label{sec:printglossaries}
1967
1968 In \sectionref{sec:start}, I mentioned that there are three options
1969 you can choose from to create an automatically sorted glossary with the base
1970 \sty{glossaries} package. These are also available with the
1971 extension package \sty{glossaries-extra} along with a fourth
1972 option. These four options are listed below in a little more detail.
1973 \Tableref{tab:optionsp+c} summarises the main advantages and
1974 disadvantages. (There's a more detailed summary in the main
1975 \sty{glossaries} user manual.) See also
1976 \dickimawhref{latex/buildglossaries/}{Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build}.
1977
1978 Note that \app{makeindex}, \app{upmendex} and \app{xindy} are general purpose
1979 indexing applications that are developed independently of
1980 \sty{glossaries} and \sty{glossaries-extra}. This makes them harder
1981 to integrate, as glossaries have more complex requirements than a
1982 simple index, particularly for documents where some terms may only
1983 appear in the description of another term. (There's also the
1984 possibility that they may change in a manner that becomes
1985 incompatible with \sty{glossaries} or may even be declared obsolete.)
1986 The \app{bib2gls} application, on the other hand, is designed
1987 specifically for, and developed alongside, the
1988 \sty{glossaries-extra} package.
1989
1990 \begin{table}[htbp]
1991 \caption{Comparison of Glossary Options}
1992 \label{tab:optionsp+c}
1993 {%
1994 \centering
1995 \begin{tabular}{>{\raggedright}p{0.3\textwidth}cccc}
1996 & \bfseries \option{noidx}
1997 & \bfseries \option{mkidx}
1998 & \bfseries \option{xdy}
1999 & \bfseries \option{b2g}\\
2000 Requires \sty{glossaries-extra}? &
2001 \conno & \conno & \conno & \conyes\\
2002 Requires an external application? &
2003 \conno & \conyes & \conyes & \conyes\\
2004 Requires Perl? &
2005 \conno & \conno & \conyes & \conno\\
2006 Requires Java? &
2007 \conno & \conno & \conno & \conyes\\
2008 Can sort extended Latin
2009 or non-Latin alphabets? &
2010 \prono\tablefnmark{\asteriskmarker} & \prono & \proyes & \proyes\\
2011 Efficient sort algorithm? &
2012 \prono & \proyes & \proyes & \proyes\\
2013 Can use different sort methods for each glossary? &
2014 \proyes & \prono & \prono & \proyes\\
2015 Any problematic sort values? &
2016 \conyes & \conyes & \conyes & \conno\\
2017 Can form ranges in the location lists? &
2018 \prono & \proyes & \proyes & \proyes\\
2019 Can have non-standard locations? &
2020 \proyes & \prono & \proyes\tablefnmark{\textdagger} & \proyes
2021 \end{tabular}
2022 \par}\medskip
2023 \tablefntext{\asteriskmarker}{Requires corresponding \sty{datatool} v3.0+
2024 localisation support.}
2025 \tablefntext{\textdagger}{Requires some setting up.}
2026 \end{table}
2027
2028 \begin{deflist}
2029 \itemtitle{\idxoptiondef{noidx}}
2030
2031 \begin{itemdesc}
2032 This method works best with at least version
2033 3.0 of the \sty{datatool-base} package (which is supplied with
2034 \sty{datatool} and automatically loaded by \sty{glossaries}).
2035 If available, ensure that you have the applicable language
2036 support. (At the time of writing, only \sty{datatool-english} is
2037 available.) Note that it does have limitations, such as no range
2038 formations in the location list and it can be slower than using an
2039 indexing application.
2040
2041 If you have an old version of \sty{datatool},
2042 this method can be very slow and if you want a sorted list,
2043 it can be problematic with extended or non-Latin alphabets.
2044
2045 For example, with \sty{datatool} v3.0+ and \sty{datatool-english}
2046 installed:
2047 \begin{codebox}
2048 \cmd{usepackage}\oarg{locales={en}}\marg{glossaries}
2049 \end{codebox}
2050 or:
2051 \begin{codebox}
2052 \cmd{usepackage}\oarg{english}\marg{babel}
2053 \cmd{usepackage}\marg{glossaries}
2054 \end{codebox}
2055
2056 \begin{enumerate}
2057 \item Add \gls{makenoidxglossaries} to your preamble (before you
2058 start defining your entries, as described in
2059 \sectionref{sec:defterm}).
2060
2061 \item Put
2062 \begin{compactcodebox*}
2063 \gls{printnoidxglossary}\oarg{\printglossoptval{sort}{\meta{order}},\meta{other options}}
2064 \end{compactcodebox*}
2065 where you want your list of entries to appear. The sort
2066 \meta{order} may be one of: \code{word} (word ordering),
2067 \code{letter} (letter ordering), \code{case} (case-sensitive
2068 ordering), \code{def} (in order of definition) or
2069 \code{use} (in order of use). Alternatively, use
2070 \begin{compactcodebox*}
2071 \gls{printnoidxglossaries}
2072 \end{compactcodebox*}%
2073 to display all your glossaries (if you have more than one).
2074
2075 This option allows you to have different sort methods. For
2076 example:
2077 \begin{codebox}
2078 \gls{printnoidxglossary}\oarg{\printglossoptval{sort}{word}}\comment{main glossary}
2079 \gls{printnoidxglossary}\oarg{
2080 \printglossoptval{type}{symbols},\comment{symbols glossary}
2081 \printglossoptval{sort}{use}}
2082 \end{codebox}
2083
2084 \item Run \LaTeX\ twice on your document. (As you would do to
2085 make a~table of contents appear.) For example, click twice on
2086 the \qt{typeset} or \qt{build} or \qt{PDF\LaTeX} button in your editor.
2087 \end{enumerate}
2088 Here's a complete document (\filefmt{myDoc.tex}):
2089 \begin{codebox}
2090 \cmd{documentclass}\marg{article}
2091 \codepar
2092 \cmd{usepackage}\marg{glossaries}
2093 \codepar
2094 \gls{makenoidxglossaries}\comment{use TeX to sort}
2095 \codepar
2096 \gls{newglossaryentry}\marg{sample}\marg{\gloskeyval{name}{sample},
2097 \gloskeyval{description}{an example}}
2098 \codepar
2099 \cbeg{document}
2100 A \gls{gls}\marg{sample}.
2101 \codepar
2102 \comment{iterate over all indexed entries:}
2103 \gls{printnoidxglossaries}
2104 \cend{document}
2105 \end{codebox}
2106 Document build:
2107 \begin{terminal}
2108 pdflatex myDoc
2109 pdflatex myDoc
2110 \end{terminal}
2111 \end{itemdesc}
2112
2113 \itemtitle{\idxoptiondef{mkidx}}
2114
2115 \begin{itemdesc}
2116 This option uses an application called \app{makeindex} to sort
2117 the entries. This application comes with all modern \TeX\ distributions,
2118 but it's hard-coded for the non-extended Latin alphabet. This process
2119 involves making \LaTeX\ write the glossary information to a temporary
2120 file which \app{makeindex} reads. Then \app{makeindex} writes
2121 a~new file containing the code to typeset the glossary. \LaTeX\ then
2122 reads this file on the next run. The \app{makeindex}
2123 application is automatically invoked by the helper
2124 \app{makeglossaries} script, which works out all the
2125 appropriate settings from the \ext+{aux} file.
2126
2127 \begin{enumerate}
2128 \item If you have UTF-8 or a non-Latin alphabet, then use \app{upmendex}
2129 (a \app{makeindex} substitute) instead of \app{makeindex}. You
2130 can indicate this with the \opt{upmendex} package option:
2131 \begin{compactcodebox}
2132 \cmd{usepackage}\oarg{\opt{upmendex}}\marg{glossaries}
2133 \end{compactcodebox}
2134
2135 \item Add \gls{makeglossaries} to your preamble (before you start
2136 defining your entries).
2137
2138 \item Put
2139 \begin{compactcodebox*}
2140 \gls{printglossary}\oargm{options}
2141 \end{compactcodebox*}%
2142 where you want your list of entries (\idx{glossary}) to appear. (The
2143 \printglossopt{sort} key isn't available in \meta{options}.)
2144 Alternatively, use
2145 \begin{compactcodebox*}
2146 \gls{printglossaries}
2147 \end{compactcodebox*}%
2148 which will display all glossaries (if you have more than one).
2149
2150 \begin{important}
2151 All glossaries are sorted using the same method
2152 which may be identified with one of the package options:
2153 \optval{sort}{standard} (default), \optval{sort}{use}
2154 or \optval{sort}{def}.
2155 \end{important}
2156
2157 \item Run \LaTeX\ on your document. This creates files with the
2158 extensions \ext+{glo} and \ext+{ist} (for example, if your
2159 \LaTeX\ document is called \filefmt{myDoc.tex}, then you'll have
2160 two extra files called \filefmt{myDoc.glo} and \filefmt{myDoc.ist}).
2161 If you look at your document at this point, you won't see the
2162 \idx{glossary} as it hasn't been created yet.
2163
2164 \item Run \app{makeglossaries} with the base name of your
2165 document (without the \ext{tex} extension). If
2166 you have access to a terminal or a command prompt then you need
2167 to run the command:
2168 \begin{terminal}
2169 makeglossaries myDoc
2170 \end{terminal}%
2171 (Replace \filefmt{myDoc} with the base name of your \LaTeX\
2172 document file without the extension.) If you don't have Perl installed
2173 use \app{makeglossaries-lite} instead:
2174 \begin{terminal}
2175 makeglossaries-lite myDoc
2176 \end{terminal}
2177
2178 \begin{important}
2179 Some beginners get confused by \app{makeglossaries} the
2180 application (run as a system command) and \gls{makeglossaries}
2181 the \LaTeX\ command which should be typed in the document
2182 preamble. These are two different concepts that happen to have
2183 similar looking names.
2184 \end{important}
2185
2186 If you don't know how to use the command prompt, then you can
2187 probably configure your text editor to add
2188 \app{makeglossaries} (or \app{makeglossaries-lite})
2189 as a build tool, but each editor has a
2190 different method of doing this, so I~can't give a~general
2191 description. However, there are some guidelines in
2192 \dickimawhref{latex/buildglossaries/}{Incorporating
2193 makeglossaries or makeglossaries-lite or bib2gls into the document
2194 build}.
2195 If you still have problems, try adding the \opt{automake}
2196 package option:
2197 \begin{compactcodebox}
2198 \cmd{usepackage}[\opt{automake}]\marg{glossaries}
2199 \end{compactcodebox}
2200
2201 The default sort is word order (\qt{sea lion} comes before \qt{seal}).
2202 If you want letter ordering you need to add the
2203 \optval{order}{letter} package option
2204 \begin{compactcodebox}
2205 \cmd{usepackage}[\optval{order}{letter}]\marg{glossaries}
2206 \end{compactcodebox}
2207
2208 \item Once you have successfully completed the previous step,
2209 you can now run \LaTeX\ on your document again.
2210 \end{enumerate}
2211 Here's a complete document (\filefmt{myDoc.tex}):
2212 \begin{codebox}
2213 \cmd{documentclass}\marg{article}
2214 \codepar
2215 \cmd{usepackage}\oarg{
2216 \comment{add \opt{upmendex} for UTF-8 support}
2217 }\marg{glossaries}
2218 \codepar
2219 \gls{makeglossaries} \comment{create \app{makeindex} files}
2220 \codepar
2221 \gls{newglossaryentry}\marg{sample}\marg{\gloskeyval{name}{sample},
2222 \gloskeyval{description}{an example}}
2223 \codepar
2224 \cbeg{document}
2225 A \gls{gls}\marg{sample}.
2226 \codepar
2227 \comment{input files created by makeindex/upmendex:}
2228 \gls{printglossaries}
2229 \cend{document}
2230 \end{codebox}
2231 Document build:
2232 \begin{terminal}
2233 pdflatex myDoc
2234 makeglossaries myDoc
2235 pdflatex myDoc
2236 \end{terminal}
2237 or
2238 \begin{terminal}
2239 pdflatex myDoc
2240 makeglossaries-lite myDoc
2241 pdflatex myDoc
2242 \end{terminal}
2243 \end{itemdesc}
2244
2245 \itemtitle{\idxoptiondef{xdy}}
2246
2247 \begin{itemdesc}
2248 This option uses an application called
2249 \app{xindy} to sort the entries. This application is more
2250 flexible than \app{makeindex} and is able to sort extended
2251 Latin or non-Latin alphabets. It comes with both \TeX~Live and
2252 MiK\TeX. Since \app{xindy} is a Perl script, you will also
2253 need to ensure that Perl is installed. In a~similar way to \option{mkidx}, this
2254 option involves making \LaTeX\ write the glossary information to
2255 a~temporary file which \app{xindy} reads. Then \app{xindy}
2256 writes a~new file containing the code to typeset the glossary.
2257 \LaTeX\ then reads this file on the next run. The \app{xindy}
2258 application is automatically invoked by the helper
2259 \app{makeglossaries} script, which works out all the
2260 appropriate settings from the \ext+{aux} file.
2261 See \url{http://www.xindy.org/} for further information about
2262 \app{xindy} and links to its mailing list and issue tracker.
2263
2264 \begin{enumerate}
2265 \item Add the \opt{xindy} option to the \sty{glossaries}
2266 package option list:
2267 \begin{compactcodebox}
2268 \cmd{usepackage}[\opt{xindy}]\marg{glossaries}
2269 \end{compactcodebox}%
2270 If you aren't using a Latin script, you may need to suppress the
2271 default number group:
2272 \begin{compactcodebox}
2273 \cmd{usepackage}[\optvalm{xindy}{glsnumbers=false}]\marg{glossaries}
2274 \end{compactcodebox}
2275
2276 \item Add \gls{makeglossaries} to your preamble (before you start
2277 defining your entries).
2278
2279 \item Put
2280 \begin{compactcodebox*}
2281 \gls{printglossary}\oargm{options}
2282 \end{compactcodebox*}%
2283 where you want your list of entries (glossary) to appear. (The
2284 \printglossopt{sort} key isn't available in \meta{options}.)
2285 Alternatively, use
2286 \begin{compactcodebox*}
2287 \gls{printglossaries}
2288 \end{compactcodebox*}
2289
2290 \begin{important}
2291 All \idxpl{glossary} are sorted using the same method
2292 which may be identified with one of the package options:
2293 \optval{sort}{standard} (default), \optval{sort}{use}
2294 or \optval{sort}{def}.
2295 \end{important}
2296
2297 \item Run \LaTeX\ on your document. This creates files with the
2298 extensions \ext+{glo} and \ext+{xdy} (for example, if your
2299 \LaTeX\ document is called \filefmt{myDoc.tex}, then you'll have
2300 two extra files called \filefmt{myDoc.glo} and \filefmt{myDoc.xdy}).
2301 If you look at your document at this point, you won't see the
2302 \idx{glossary} as it hasn't been created yet.
2303
2304 \item Run \app{makeglossaries} with the base name of the
2305 document (omitting the \ext{tex} extension).
2306 If you have access to a terminal or a command prompt then
2307 you need to run the command:
2308 \begin{terminal}
2309 makeglossaries myDoc
2310 \end{terminal}%
2311 (Replace \filefmt{myDoc} with the base name of your \LaTeX\
2312 document file without the \ext{tex} extension.)
2313 If you don't know how to use the command prompt, then as mentioned above, you may
2314 be able to configure your text editor to add
2315 \app{makeglossaries} as a build tool. Note that the \opt{automake} option
2316 won't work in \TeX's restricted mode, as \app{xindy} isn't on the
2317 list of trusted applications.
2318
2319 The default sort is word order (\qt{sea lion} comes before \qt{seal}).
2320 If you want letter ordering you need to add the
2321 \optval{order}{letter} package option:
2322 \begin{compactcodebox}
2323 \cmd{usepackage}[\opt{xindy},\optval{order}{letter}]\marg{glossaries}
2324 \end{compactcodebox}
2325
2326 \item Once you have successfully completed the previous step,
2327 you can now run \LaTeX\ on your document again.
2328
2329 \end{enumerate}
2330 Here's a complete document (\filefmt{myDoc.tex}):
2331 \begin{codebox}
2332 \cmd{documentclass}\marg{article}
2333 \codepar
2334 \cmd{usepackage}[\opt{xindy}]\marg{glossaries}
2335 \codepar
2336 \gls{makeglossaries} \comment{create \app{xindy} files}
2337 \codepar
2338 \gls{newglossaryentry}\marg{sample}\marg{\gloskeyval{name}{sample},
2339 \gloskeyval{description}{an example}}
2340 \codepar
2341 \cbeg{document}
2342 A \gls{gls}\marg{sample}.
2343 \codepar
2344 \gls{printglossaries} \comment{input files created by \app{xindy}}
2345 \cend{document}
2346 \end{codebox}%
2347 Document build:
2348 \begin{terminal}
2349 pdflatex myDoc
2350 makeglossaries myDoc
2351 pdflatex myDoc
2352 \end{terminal}
2353
2354 If you use \app{xindy} and the \gloskey{name} only contains a command or
2355 commands (such as \csfmt{P} or
2356 \code{\cmd{ensuremath}\marg{\cmd{pi}}}) you must add the
2357 \gloskey{sort} key. This is also advisable for the other options
2358 (except \option{b2g}, \gallerypage{bib2gls-sorting}{which, in general, shouldn't
2359 have the \optfmt{sort} field set}), but is essential for \option{xdy}. For example:
2360 \begin{codebox}
2361 \gls{newglossaryentry}\marg{P}\marg{\gloskeyval{name}{\cmd{P}},\gloskeyval{sort}{P},
2362 \gloskeyval{description}{paragraph symbol}}
2363 \end{codebox}
2364
2365 \end{itemdesc}
2366
2367 \itemtitle{\idxoptiondef{b2g}}
2368
2369 \begin{itemdesc}
2370 This requires the extension package \sty+{glossaries-extra} and
2371 an application called \app{bib2gls}. This application is able
2372 to sort extended Latin or non-Latin alphabets. It comes with both
2373 \TeX~Live and MiK\TeX\ but requires Java. This method
2374 works differently to \options{mkidx,xdy}. Instead of creating a file
2375 containing the code to typeset the glossary it creates a
2376 \ext+{glstex} file containing the entry definitions obtained from
2377 data that was fetched from the \ext+{bib} file (or files), but only those entries
2378 that are required in the document are defined and they are
2379 defined in the order obtained from the chosen sort method.
2380 This means that you can just use
2381 \gls{printunsrtglossary} to display each glossary (or
2382 \gls{printunsrtglossaries} to display them all).
2383
2384 \begin{enumerate}
2385 \item Add the \opt{record} option to the \sty{glossaries-extra}
2386 package option list:
2387 \begin{compactcodebox}
2388 \cmd{usepackage}\oarg{\opt{record}}\marg{glossaries-extra}
2389 \end{compactcodebox}
2390
2391 \item Add one or more
2392 \begin{compactcodebox*}
2393 \gls{GlsXtrLoadResources}\oarg{\resourceoptvalm{src}{\meta{bib list}},\meta{options}}
2394 \end{compactcodebox*}%
2395 to your preamble where \meta{bib list} is the
2396 list of \ext{bib} files containing the entries. You may
2397 use different sort methods for each resource set. For example:
2398 \begin{codebox*}
2399 \cmd{usepackage}\oarg{\opt{record},\comment{using \app{bib2gls}}
2400 \opt{abbreviations},\comment{create abbreviations list}
2401 \opt{symbols},\comment{create symbols list}
2402 \opt{numbers}\comment{create numbers list}
2403 }\marg{glossaries-extra}
2404 \codepar
2405 \gls{GlsXtrLoadResources}\oarg{
2406 \resourceoptvalm{src}{terms},\comment{entries in terms.bib}
2407 \comment{put these entries in the 'main' list:}
2408 \resourceoptval{type}{main},
2409 \comment{sort according to this locale:}
2410 \resourceoptval{sort}{de-CH-1996}
2411 }
2412 \gls{GlsXtrLoadResources}\oarg{
2413 \resourceoptvalm{src}{abbrvs},\comment{entries in abbrvs.bib}
2414 \comment{put these entries in the 'abbreviations' list:}
2415 \resourceoptvalm{type}{abbreviations},
2416 \comment{case-sensitive letter (non-locale) sort:}
2417 \resourceoptval{sort}{letter-case}
2418 }
2419 \gls{GlsXtrLoadResources}\oarg{
2420 \resourceoptvalm{src}{syms},\comment{entries in syms.bib}
2421 \comment{put these entries in the 'symbols' list:}
2422 \resourceoptval{type}{symbols},
2423 \comment{sort according to first use in the document:}
2424 \resourceoptval{sort}{use}
2425 }
2426 \gls{GlsXtrLoadResources}\oarg{
2427 \resourceoptvalm{src}{constants},\comment{entries in constants.bib}
2428 \comment{put these entries in the 'numbers' list:}
2429 \resourceoptval{type}{numbers},
2430 \comment{sort according to the \gloskey{user1} field:}
2431 \resourceoptval{sort-field}{user1},
2432 \resourceoptval{sort}{double}\comment{double-precision numeric sort}
2433 }
2434 \end{codebox*}%
2435 The last resource set assumes that the entries defined in the
2436 file \filefmt{constants.bib} have a number stored in the \gloskey{user1}
2437 field. For example:
2438 \begin{compactcodebox}
2439 \atentry{number}\marg{pi,
2440 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{pi}}},
2441 \gloskeyval{description}{pi},
2442 \gloskeyval{user1}{3.141592654}
2443 }
2444 \end{compactcodebox}
2445
2446 \item Put
2447 \begin{compactcodebox*}
2448 \gls{printunsrtglossary}\oarg{\printglossoptval{type}{\meta{type}},\meta{options}}
2449 \end{compactcodebox*}%
2450 where you want your list of entries (\idx{glossary}) to appear. (The
2451 \printglossopt{sort} key isn't available in \meta{options}. The
2452 \resourceopt{sort} setting needs to be
2453 used in \gls{GlsXtrLoadResources} instead.)
2454 Alternatively, use
2455 \begin{compactcodebox*}
2456 \gls{printunsrtglossaries}
2457 \end{compactcodebox*}
2458 which will display all glossaries (if you have more than one).
2459
2460 \item Run \LaTeX\ on your document. The \opt{record} option
2461 adds information to the \ext+{aux} file that provides
2462 \app{bib2gls} with all required details for each resource set.
2463 For example, if the file is called \filefmt{myDoc.tex}:
2464 \begin{terminal}
2465 pdflatex myDoc
2466 \end{terminal}
2467
2468 \item Run \app{bib2gls}
2469 \begin{terminal}
2470 bib2gls myDoc
2471 \end{terminal}%
2472 or (if you need letter groups)
2473 \begin{terminal}
2474 bib2gls \switch{group} myDoc
2475 \end{terminal}
2476
2477 \item Run \LaTeX\ again.
2478 \end{enumerate}
2479 Here's a complete document (\filefmt{myDoc.tex}) with only one
2480 resource set for brevity:
2481 \begin{codebox}
2482 \cmd{documentclass}\marg{article}
2483 \codepar
2484 \cmd{usepackage}[\opt{record}]\marg{glossaries-extra}
2485 \comment{input the \ext{glstex} file created by \app{bib2gls}:}
2486 \gls{GlsXtrLoadResources}
2487 \oarg{\comment{instructions to \app{bib2gls}:}
2488 \resourceoptvalm{src}{entries}, \comment{data in entries.bib}
2489 \resourceoptval{sort}{en-GB}\comment{sort according to this locale}
2490 }
2491 \codepar
2492 \cbeg{document}
2493 A \gls{gls}\marg{sample}.
2494 \codepar
2495 \comment{iterate over all defined entries:}
2496 \gls{printunsrtglossaries}
2497 \cend{document}
2498 \end{codebox}
2499 The accompanying \filefmt{entries.bib} file:
2500 \begin{compactcodebox}
2501 \atentry{entry}\marg{sample,
2502 \gloskeyval{name}{sample},
2503 \gloskeyval{description}{an example}
2504 }
2505 \end{compactcodebox}
2506 Document build:
2507 \begin{terminal}
2508 pdflatex myDoc
2509 bib2gls myDoc
2510 pdflatex myDoc
2511 \end{terminal}
2512 \end{itemdesc}
2513
2514 \end{deflist}
2515
2516 If you are having difficulty integrating \app{makeglossaries} (or
2517 \app{makeglossaries-lite}) or \app{bib2gls}
2518 into your document build process, you may want to consider using
2519 \app{arara}, which is a Java application that searches the
2520 document for special comment lines that tell \app{arara} which
2521 applications to run. For example, the file \filefmt{myDoc.tex} might
2522 start with:
2523 \begin{codebox}
2524 \araraline{pdflatex}
2525 \araraline{makeglossaries}
2526 \araraline{pdflatex}
2527 \cmd{documentclass}\marg{article}
2528 \cmd{usepackage}\marg{glossaries}
2529 \gls{makeglossaries}
2530 \end{codebox}
2531 then to build the document you just need the single system call:
2532 \begin{terminal}
2533 arara myDoc
2534 \end{terminal}
2535 Alternatively, if you want to use \app{makeglossaries-lite}, change
2536 the second line to:
2537 \begin{compactcodebox}
2538 \araraline{makeglossarieslite}
2539 \end{compactcodebox}
2540 There's also a rule for \app{bib2gls}. For example, the following
2541 indicates that letter groups are required:
2542 \begin{codebox}
2543 \araraline{pdflatex}
2544 \araraline{bib2gls: \marg{ group: on }}
2545 \araraline{pdflatex}
2546 \cmd{documentclass}\marg{article}
2547 \cmd{usepackage}\oarg{\opt{record}}\marg{glossaries-extra}
2548 \gls{GlsXtrLoadResources}
2549 \end{codebox}
2550
2551 \section{Customising the Glossary}
2552 \label{sec:glosstyle}
2553
2554 The default glossary style uses the \env{description} environment
2555 to display the entry list. Each entry name is set in the optional
2556 argument of \gls{item} which means that it will typically be
2557 displayed in bold. You can switch to medium weight by redefining
2558 \gls{glsnamefont}:
2559 \begin{codebox}
2560 \cmd{renewcommand}*\marg{\gls{glsnamefont}}[1]\marg{\cmd{textmd}\marg{\#1}}
2561 \end{codebox}
2562 Some classes and packages redefine the \env{description} environment
2563 in such as way that's incompatible with the \sty{glossaries}
2564 package. In which case you'll need to select a different glossary
2565 style (see below).
2566
2567 By default, a~full stop is appended to the description (unless you
2568 use \sty{glossaries-extra}). To prevent
2569 this from happening use the \opt{nopostdot} package option:
2570 \begin{codebox}
2571 \cmd{usepackage}[\opt{nopostdot}]\marg{glossaries}
2572 \end{codebox}
2573 or to add it with \sty{glossaries-extra}:
2574 \begin{codebox}
2575 \cmd{usepackage}[\opt{postdot}]\marg{glossaries-extra}
2576 \end{codebox}
2577
2578 By default, a~location list is displayed for each entry (except
2579 when \gls{printunsrtglossary} is used without \app{bib2gls}). This refers
2580 to the document locations (for example, the page number) where the
2581 entry has been referenced. If you use \optionsor{mkidx,xdy} described in
2582 \sectionref{sec:printglossaries} or \option{b2g} (with \app{bib2gls} and
2583 \sty{glossaries-extra}) then location ranges will be compressed.
2584 For example, if an entry was used on pages~1, 2 and~3, then with
2585 \optionsor{mkidx,xdy,b2g} the location list will appear as 1--3, but
2586 with \option{noidx} it
2587 will appear as 1, 2, 3. If you don't want the locations displayed
2588 you can hide them using the \opt{nonumberlist} package option:
2589 \begin{codebox}
2590 \cmd{usepackage}[\opt{nonumberlist}]\marg{glossaries}
2591 \end{codebox}
2592 or with \app{bib2gls} use \resourceoptval{save-locations}{false} in the
2593 optional argument of the appropriate \gls{GlsXtrLoadResources}
2594 (it's possible to have some resource sets with locations and some
2595 without).
2596
2597 Entries are grouped according to the first letter of
2598 each entry's \gloskey{sort} value. By default a~vertical gap is placed
2599 between letter groups for most of the predefined styles. You can suppress this with the
2600 \opt{nogroupskip} package option:
2601 \begin{codebox}
2602 \cmd{usepackage}[\opt{nogroupskip}]\marg{glossaries}
2603 \end{codebox}
2604
2605 If the default style doesn't suit your document, you can change the
2606 style using:
2607 \cmddef{setglossarystyle}
2608 \dickimawhref{gallery/glossaries-styles/}{There are a~number of predefined styles.} Glossaries can vary from
2609 a~list of symbols with a~terse description to a~list of words or
2610 phrases with descriptions that span multiple paragraphs, so there's
2611 no \qt{one style fits all} solution. You need to choose a~style that
2612 suits your document. For example:
2613 \begin{codebox*}
2614 \gls{setglossarystyle}\marg{\glostyle{index}}
2615 \end{codebox*}
2616 You can also use the \opt{style} package option for the preloaded
2617 styles. For example:
2618 \begin{codebox}
2619 \cmd{usepackage}[\optval{style}{index}]\marg{glossaries}
2620 \end{codebox}
2621
2622 Examples:
2623 \begin{enumerate}
2624 \item You have entries where the name is a~symbol and the
2625 description is a~brief phrase or short sentence. Try one of the
2626 \qt{mcol} styles defined in the \sty{glossary-mcols} package. For example:
2627 \begin{codebox}
2628 \cmd{usepackage}[\opt{nopostdot}]\marg{glossaries}
2629 \cmd{usepackage}\marg{glossary-mcols}
2630 \gls{setglossarystyle}\marg{\glostyle+{mcolindex}}
2631 \end{codebox}
2632 or
2633 \begin{codebox*}
2634 \cmd{usepackage}[\optval{stylemods}{mcols},\optval{style}{mcolindex}]\marg{glossaries-extra}
2635 \end{codebox*}
2636
2637 \item You have entries where the name is a~word or phrase and the
2638 description spans multiple paragraphs. Try one of the \qt{altlist} styles. For
2639 example:
2640 \begin{codebox}
2641 \cmd{usepackage}[\opt{nopostdot}]\marg{glossaries}
2642 \gls{setglossarystyle}\marg{\glostyle+{altlist}}
2643 \end{codebox}
2644 or
2645 \begin{codebox}
2646 \cmd{usepackage}[\opt{stylemods},\optval{style}{altlist}]\marg{glossaries-extra}
2647 \end{codebox}
2648
2649 \item You have entries where the name is a~single word, the
2650 description is brief, and an associated symbol has been set.
2651 Use one of the styles that display the symbol (not all of them do).
2652 For example, one of the tabular styles:
2653 \begin{codebox}
2654 \cmd{usepackage}[\opt{nopostdot},\opt{nonumberlist},
2655 \optval{style}{\glostyle+{long4col}}]\marg{glossaries}
2656 \end{codebox}
2657 or one of the \qt{tree} styles:
2658 \begin{codebox}
2659 \cmd{usepackage}[\opt{nopostdot},\opt{nonumberlist},\optval{style}{tree}]\marg{glossaries}
2660 \end{codebox}
2661 \end{enumerate}
2662
2663 If your glossary consists of a~list of abbreviations and you also want to
2664 specify a~description as well as the long form, then you need to use
2665 an abbreviation style that will suit the glossary style. For example,
2666 use the \acrstyle{long-short-desc} acronym style:
2667 \begin{codebox*}
2668 \gls{setacronymstyle}\marg{\acrstyle{long-short-desc}}
2669 \end{codebox*}
2670 Define the acronyms with a~description:
2671 \begin{codebox*}
2672 \gls{newacronym}
2673 \oarg{\gloskeyval{description}{statistical pattern
2674 recognition technique}}
2675 \marg{svm}\marg{SVM}\marg{support vector machine}
2676 \end{codebox*}
2677 Alternatively with \sty{glossaries-extra}:
2678 \begin{codebox*}
2679 \gls{setabbreviationstyle}\marg{\acrstyle{long-short-desc}}
2680 \codepar
2681 \gls{newabbreviation}
2682 \oarg{\gloskeyval{description}{statistical pattern
2683 recognition technique}}
2684 \marg{svm}\marg{SVM}\marg{support vector machine}
2685 \end{codebox*}
2686
2687 Choose a~glossary style that suits wide entry names. For example:
2688 \begin{codebox*}
2689 \gls{setglossarystyle}\marg{\glostyle{altlist}}
2690 \end{codebox*}
2691
2692 \section{Multiple Glossaries}
2693 \label{sec:multigloss}
2694
2695 The \sty{glossaries} package predefines a~default \code{main}
2696 \idx{glossary}. When you define an entry (using one of the commands
2697 described in \sectionref{sec:defterm}), that entry is automatically
2698 assigned to the default \idx{glossary}, unless you indicate otherwise
2699 using the \gloskey{type} key. However you first need to
2700 make sure the desired \idx{glossary} has been defined. This is done using:
2701 \cmddef{newglossary}
2702 The \meta{glossary-label} is a~label that uniquely identifies this new
2703 \idx{glossary}. As with other types of identifying labels, be careful not
2704 to use active characters in \meta{label}. The final argument
2705 \meta{title} is the section or chapter title used by
2706 \gls{printglossary}, \gls{printnoidxglossary} or
2707 \gls{printunsrtglossary}. The other arguments
2708 indicate the file extensions used by
2709 \app{makeindex}\slash \app{upmendex} or \app{xindy} (described in
2710 \sectionref{sec:printglossaries}). If you're not using
2711 \app{makeindex}, \app{upmendex} or \app{xindy},
2712 then the \meta{log-ext}, \meta{in-ext} and \meta{out-ext} arguments aren't
2713 relevant, in which case you may prefer to use the starred version
2714 where those arguments are omitted:
2715 \cmddef{newglossary*}
2716
2717 In the case of \optionsor{mkidx,xdy}, all new \idxpl{glossary} must
2718 be defined before \gls{makeglossaries}. (\emph{Entry} definitions
2719 should come after \gls{makeglossaries}.) In the case of
2720 \option{b2g}, all new \idxpl{glossary} must be defined before any
2721 \gls{GlsXtrLoadResources} that requires them.
2722
2723 Since it's quite common for documents to have both a~list of terms
2724 and a~list of abbreviations, the \sty{glossaries} package provides the
2725 package option \opt{acronyms} (or \opt{acronym}), which
2726 is a~convenient shortcut for
2727 \begin{compactcodebox}
2728 \gls{newglossary}\oarg{\ext+{alg}}\marg{acronym}\marg{\ext+{acr}}\marg{\ext+{acn}}\marg{\gls+{acronymname}}
2729 \end{compactcodebox}
2730 The option also changes the behaviour of \gls{newacronym} so that acronyms
2731 are automatically put in the list of acronyms instead of the main
2732 glossary. The \sty{glossaries-extra} package also supports the
2733 \opt{acronyms} option for abbreviations defined using \gls{newacronym} but
2734 additionally has the package option \opt{abbreviations} to create
2735 a list of abbreviations for \gls{newabbreviation}.
2736
2737 There are some other package options for creating commonly used
2738 lists: \opt{symbols} (lists of symbols), \opt{numbers} (lists
2739 of numbers), \opt{index} (an index). Since indexes don't
2740 typically have descriptions, the \opt{index} option also defines:
2741 \cmddef{newterm}
2742 This is just a shortcut that uses \gls{newglossaryentry} with the
2743 \gloskey{name} set to \meta{entry-label} and the \gloskey{description} is
2744 suppressed.
2745
2746 For example, suppose you want a~main glossary for terms, a~list of
2747 acronyms and a~list of notation:
2748 \begin{codebox}
2749 \cmd{usepackage}[\opt{acronyms}]\marg{glossaries}
2750 \gls{newglossary}\oarg{nlg}\marg{notation}\marg{not}\marg{ntn}\marg{Notation}
2751 \end{codebox}
2752 After \gls{makeglossaries} (or \gls{makenoidxglossaries}) you can
2753 define the entries in the preamble. For example:
2754 \begin{codebox}
2755 \gls{newglossaryentry}\marg{gls:set}
2756 \marg{\comment{This entry goes in the `main' glossary}
2757 \gloskeyval{name}{set},
2758 \gloskeyval{description}{A collection of distinct objects}
2759 }
2760 \codepar
2761 \comment{This entry goes in the `acronym' glossary:}
2762 \gls{newacronym}\marg{svm}\marg{svm}\marg{support vector machine}
2763 \codepar
2764 \gls{newglossaryentry}\marg{not:set}
2765 \marg{\comment{This entry goes in the `notation' glossary:}
2766 \gloskeyval{type}{notation},
2767 \gloskeyval{name}{\cmd{ensuremath}\marg{\cmd{mathcal}\marg{S}}},
2768 \gloskeyval{description}{A set},
2769 \gloskeyval{sort}{S}}
2770 \end{codebox}
2771 or if you don't like using \csfmt{ensuremath}:
2772 \begin{codebox}
2773 \gls{newglossaryentry}\marg{not:set}
2774 \marg{\comment{This entry goes in the `notation' glossary:}
2775 \gloskeyval{type}{notation},
2776 \gloskeyval{name}{\$\cmd{mathcal}\marg{S}\$},
2777 \gloskeyval{text}{\cmd{mathcal}\marg{S}},
2778 \gloskeyval{description}{A set},
2779 \gloskeyval{sort}{S}
2780 }
2781 \end{codebox}
2782
2783 Each glossary is displayed using:
2784 \begin{compactcodebox*}
2785 \gls{printnoidxglossary}\oarg{\printglossoptval{type}{\meta{type}}}
2786 \end{compactcodebox*}%
2787 (\option{noidx}) or
2788 \begin{compactcodebox*}
2789 \gls{printglossary}\oarg{\printglossoptval{type}{\meta{type}}}
2790 \end{compactcodebox*}%
2791 (\options{mkidx,xdy}). Where \meta{type} is the glossary label. If the
2792 type is omitted the default \code{main} glossary is assumed.
2793
2794 If you're using \app{bib2gls} then each glossary is displayed
2795 using:
2796 \begin{compactcodebox*}
2797 \gls{printunsrtglossary}\oarg{\printglossoptval{type}{\meta{type}}}
2798 \end{compactcodebox*}%
2799 With this method you don't use \gls{makeglossaries} or
2800 \gls{makenoidxglossaries}. Instead you can assign the entry type
2801 with the resource command. For example:
2802 \begin{codebox*}
2803 \cmd{usepackage}[\opt{record},\opt{abbreviations},\opt{symbols}]\marg{glossaries-extra}
2804 \codepar
2805 \gls{GlsXtrLoadResources}\oarg{
2806 \resourceoptvalm{src}{terms}, \comment{entries defined in terms.bib}
2807 \resourceoptval{type}{main}\comment{put in main glossary}
2808 }
2809 \gls{GlsXtrLoadResources}\oarg{
2810 \resourceoptvalm{src}{abbrvs}, \comment{entries defined in abbrvs.bib}
2811 \resourceoptval{type}{abbreviations}\comment{put in abbreviations glossary}
2812 }
2813 \gls{GlsXtrLoadResources}\oarg{
2814 \resourceoptvalm{src}{syms}, \comment{entries defined in syms.bib}
2815 \resourceoptval{type}{symbols}\comment{put in symbols glossary}
2816 }
2817 \end{codebox*}
2818 Later in the document:
2819 \begin{codebox*}
2820 \gls{printunsrtglossary} \comment{main}
2821 \gls{printunsrtglossary}\oarg{\printglossoptval{type}{abbreviations}}
2822 \gls{printunsrtglossary}\oarg{\printglossoptval{type}{symbols}}
2823 \end{codebox*}
2824
2825 There's a~convenient shortcut that will display all the defined
2826 glossaries depending on the indexing method:
2827 \cmddef{printnoidxglossaries}
2828 (\option{noidx}) or
2829 \cmddef{printglossaries}
2830 (\options{mkidx,xdy}) or (\sty{glossaries-extra} only)
2831 \cmddef{printunsrtglossaries}
2832
2833 If you use \optionsor{noidx,b2g}, you don't need to do anything different
2834 for a document with multiple \idxpl{glossary}. If you use
2835 \optionsor{mkidx,xdy} with the \app{makeglossaries} Perl script or the
2836 \app{makeglossaries-lite} Lua script, you
2837 similarly don't need to do anything different to the document build
2838 (compared to building a document with only one \idx{glossary}).
2839
2840 If you use \optionsor{mkidx,xdy} without the helper \app{makeglossaries}
2841 Perl script or \app{makeglossaries-lite} Lua script then you need to
2842 make sure you run \app{makeindex}\slash\app{upmendex} or \app{xindy} \emph{for each
2843 defined glossary}. The \meta{gls} and \meta{glo} arguments of
2844 \gls{newglossary} specify the file extensions to use instead of
2845 \ext+{gls} and \ext+{glo}. The optional argument \meta{glg} is the
2846 file extension for the transcript file. This should be different for
2847 each glossary in case you need to check for
2848 \app{makeindex}\slash\app{upmendex}\slash\app{xindy} errors or warnings if things go
2849 wrong.
2850
2851 For example, suppose you have three glossaries in your document
2852 (\code{main}, \code{acronym} and \code{notation}),
2853 specified using:
2854 \begin{codebox}
2855 \cmd{usepackage}[\opt{acronyms}]\marg{glossaries}
2856 \gls{newglossary}\oarg{nlg}\marg{notation}\marg{not}\marg{ntn}\marg{Notation}
2857 \end{codebox}
2858 Then (assuming your \LaTeX\ document is in a~file called
2859 \filefmt{myDoc.tex}):
2860
2861 \begin{description}
2862 \item\option{mkidx}:
2863 Either use one \app{makeglossaries} or
2864 \app{makeglossaries-lite} call:
2865 \begin{terminal}
2866 makeglossaries myDoc
2867 \end{terminal}
2868 or
2869 \begin{terminal}
2870 makeglossaries-lite myDoc
2871 \end{terminal}
2872 Or you need to run \app{makeindex} three times:
2873 \begin{terminal}
2874 makeindex -t myDoc.glg -s myDoc.ist -o myDoc.gls myDoc.glo
2875 makeindex -t myDoc.alg -s myDoc.ist -o myDoc.acr myDoc.acn
2876 makeindex -t myDoc.nlg -s myDoc.ist -o myDoc.not myDoc.ntn
2877 \end{terminal}
2878 Or if you are using \app{upmendex}:
2879 \begin{terminal}
2880 upmendex -t myDoc.glg -s myDoc.ist -o myDoc.gls myDoc.glo
2881 upmendex -t myDoc.alg -s myDoc.ist -o myDoc.acr myDoc.acn
2882 upmendex -t myDoc.nlg -s myDoc.ist -o myDoc.not myDoc.ntn
2883 \end{terminal}
2884
2885 \item\option{xdy}:
2886 Either use one \app{makeglossaries} call:
2887 \begin{terminal}
2888 makeglossaries myDoc
2889 \end{terminal}
2890 Or you need to run \app{xindy} three times (be careful not to insert
2891 line breaks where the line has wrapped.)
2892 \begin{terminal}
2893 xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.glg -o myDoc.gls myDoc.glo
2894 xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.alg -o myDoc.acr myDoc.acn
2895 xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.nlg -o myDoc.not myDoc.ntn
2896 \end{terminal}
2897
2898 \item\option{b2g}:
2899 With \app{bib2gls} only one call is required:
2900 \begin{terminal}
2901 pdflatex myDoc
2902 bib2gls \switch{group} myDoc
2903 pdflatex myDoc
2904 \end{terminal}
2905 (Omit \switch{group} if you don't need letter groups.)
2906 \end{description}
2907
2908 \section{Hyperlinks (\stytext{glossaries} and \stytext{hyperref})}
2909 \label{sec:hyperref}
2910
2911 Take care if you use the \sty{glossaries} package with
2912 \sty{hyperref}. Contrary to the usual advice that \sty{hyperref}
2913 should be loaded last, \sty{glossaries} (and \sty{glossaries-extra})
2914 must be loaded \emph{after} \sty{hyperref}:
2915 \begin{codebox}
2916 \cmd{usepackage}[colorlinks]\marg{hyperref}
2917 \cmd{usepackage}\marg{glossaries}
2918 \end{codebox}
2919
2920 By default, if the \sty{hyperref} package has been loaded, commands
2921 like \gls{gls} will form a~hyperlink to the relevant entry in the
2922 \idx{glossary}. If you want to disable this for \emph{all} your
2923 glossaries, then use:
2924 \cmddef{glsdisablehyper}
2925 If you want hyperlinks suppressed for entries in specific
2926 glossaries, then use the \opt{nohypertypes} package option. For
2927 example, if you don't want hyperlinks for entries in the \code{acronym} and
2928 \code{notation} glossaries but you do want them for entries in the
2929 \code{main} glossary, then do:
2930 \begin{codebox}
2931 \cmd{usepackage}[colorlinks]\marg{hyperref}
2932 \cmd{usepackage}[\opt{acronym},\optvalm{nohypertypes}{acronym,notation}]\marg{glossaries}
2933 \gls{newglossary}\oarg{nlg}\marg{notation}\marg{not}\marg{ntn}\marg{Notation}
2934 \end{codebox}
2935
2936 If you want the hyperlinks suppressed the first time an entry is
2937 used, but you want hyperlinks for subsequence references then use
2938 the \optval{hyperfirst}{false} package option:
2939 \begin{codebox}
2940 \cmd{usepackage}[colorlinks]\marg{hyperref}
2941 \cmd{usepackage}[\optval{hyperfirst}{false}]\marg{glossaries}
2942 \end{codebox}
2943 The \sty{glossaries-extra} extension package provides another method
2944 using category attributes. See the \sty{glossaries-extra} user
2945 manual for further details.
2946
2947 Take care not to use non-expandable commands in PDF bookmarks. This
2948 isn't specific to the \sty{glossaries} package but is a~limitation
2949 of PDF bookmarks. Non-expandable commands include commands like
2950 \gls{gls}, \gls{glspl}, \gls{Gls} and \gls{Glspl}. The \sty{hyperref}
2951 package provides a~way of specifying alternative text for the PDF
2952 bookmarks via \gls{texorpdfstring}. For example:
2953 \begin{codebox}
2954 \cmd{section}\marg{The \gls{texorpdfstring}\marg{\gls{gls}\marg{fishage}}\marg{Fish Age}}
2955 \end{codebox}
2956 However, it's not a~good idea to use commands like \gls{gls} in
2957 a~section heading as you'll end up with the table of contents page in
2958 your location list and it will unset the \idx{firstuseflag} too soon.
2959 Instead you can use
2960 \cmddef{glsentrytext}
2961 This is expandable provided that the \gloskey{text} key doesn't
2962 contain non-expandable code. For example, the following works:
2963 \begin{codebox}
2964 \cmd{section}\marg{The \gls{glsentrytext}\marg{fishage}}
2965 \end{codebox}
2966 and it doesn't put the table of contents in the location list.
2967
2968 If you use \sty{glossaries-extra} then use the commands that are
2969 provided specifically for use in section headers. For example:
2970 \begin{codebox*}
2971 \cmd{section}\marg{The \gls{glsfmttext}\marg{fishage}}
2972 \end{codebox*}
2973
2974 \section{Cross-References}
2975 \label{sec:xr}
2976
2977 You can add a~reference to another entry in a~location list using
2978 the \gloskeyval{see}{\meta{label-list}} key when you define an entry.
2979 The referenced entry (or entries) must also be defined.
2980
2981 For example:
2982 \begin{codebox}
2983 \gls{longnewglossaryentry}\marg{devonian}\marg{\gloskeyval{name}{Devonian}}\comment{}
2984 \marg{\comment{}
2985 The geologic period spanning from the end of the
2986 Silurian Period to the beginning of the
2987 Carboniferous Period.
2988 \codepar
2989 This age was known for its remarkable variety of
2990 fish species.
2991 }
2992 \codepar
2993 \gls{newglossaryentry}\marg{fishage}
2994 \marg{
2995 \gloskeyval{name}{Fish Age},
2996 \gloskeyval{description}{Common name for the Devonian period},
2997 \gloskeyval{see}{devonian}
2998 }
2999 \end{codebox}
3000 The cross-reference will appear as \qt{\emph{see} Devonian}. You can
3001 change the \qt{see} tag for an individual entry using the format
3002 \gloskeyval{see}{\oargm{tag}\meta{label-list}}. For example:
3003 \begin{codebox}
3004 \gls{newglossaryentry}\marg{latinalph}
3005 \marg{
3006 \gloskeyval{name}{Latin alphabet},
3007 \gloskeyval{description}{alphabet consisting of the letters
3008 a, \cmd{ldots}, z, A, \cmd{ldots}, Z},
3009 \gloskey{see}=[see also]\marg{exlatinalph}
3010 }
3011 \gls{newglossaryentry}\marg{exlatinalph}
3012 \marg{
3013 \gloskeyval{name}{extended Latin alphabet},
3014 \gloskeyval{description}{The Latin alphabet
3015 extended to include other letters such as
3016 ligatures or diacritics.}
3017 }
3018 \end{codebox}
3019 In the above, I haven't enclosed the entire value of the
3020 \gloskey{see} key in braces.
3021 If you use the \gloskey{see} key in an optional argument, such as
3022 the optional argument of \gls{newacronym}, make sure you enclose the
3023 value (including the optional tag) in braces. For example:
3024 \begin{codebox}
3025 \gls{newacronym}\marg{ksvm}\marg{ksvm}\marg{kernel support vector machine}
3026 \gls{newacronym}
3027 \oarg{\gloskeyval{see}{[see also]\marg{ksvm}}}
3028 \marg{svm}\marg{svm}\marg{support vector machine}
3029 \end{codebox}
3030 The \sty{glossaries-extra} package provides a \gloskey{seealso}
3031 key. This doesn't allow a tag but behaves much like
3032 \gloskeyval{see}{[\gls{seealsoname}]\margm{label-list}}. For example:
3033 \begin{codebox}
3034 \gls{newabbreviation}\marg{ksvm}\marg{ksvm}
3035 \marg{kernel support vector machine}
3036 \gls{newabbreviation}
3037 \oarg{\gloskeyval{seealso}{ksvm}}
3038 \marg{svm}\marg{svm}\marg{support vector machine}
3039 \end{codebox}
3040 Additionally, the \sty{glossaries-extra} package provides
3041 an \gloskey{alias} key where the value must be just a single label.
3042 See \gallerypage{aliases}{glossaries-extra gallery: aliases} for an example.
3043
3044 Since the cross-reference appears in the location list, if you
3045 suppress the location list using the \opt{nonumberlist} package
3046 option, then the cross-reference will also be suppressed. With
3047 \app{bib2gls}, don't use the \opt{nonumberlist} package
3048 option in this case, but instead use
3049 \resourceoptval{save-locations}{false} in the resource
3050 options. For example:
3051 \begin{codebox}
3052 \cmd{usepackage}[\opt{record},\opt{abbreviations},\opt{symbols}]\marg{glossaries-extra}
3053 \codepar
3054 \gls{GlsXtrLoadResources}\oarg{
3055 \resourceoptvalm{src}{terms}, \comment{entries defined in terms.bib}
3056 \resourceoptval{type}{main}\comment{put in main glossary}
3057 }
3058 \gls{GlsXtrLoadResources}\oarg{
3059 \resourceoptvalm{src}{abbrvs}, \comment{entries defined in abbrvs.bib}
3060 \resourceoptval{type}{abbreviations},\comment{put in abbreviations glossary}
3061 \comment{no number list for these entries:}
3062 \resourceoptval{save-locations}{false}
3063 }
3064 \gls{GlsXtrLoadResources}\oarg{
3065 \resourceoptvalm{src}{syms}, \comment{entries defined in syms.bib}
3066 \resourceoptval{type}{symbols}\comment{put in symbols glossary}
3067 }
3068 \end{codebox}
3069
3070 \section{Further Information}
3071 \label{sec:moreinfo}
3072
3073 \begin{itemize}
3074 \item \ctanmirrordocnofn{support/bib2gls/bib2gls-begin}{\styfmt{glossaries-extra}
3075 and \appfmt{bib2gls}: an introductory guide}.
3076 \item The main \sty{glossaries} \docref{user manual}{glossaries-user}.
3077 \item The \dickimawhrefnofn{faqs/glossariesfaq.html}{glossaries FAQ}.
3078 \item \dickimawhrefnofn{latex/buildglossaries/}{Incorporating
3079 makeglossaries or makeglossaries-lite or bib2gls into the document
3080 build}.
3081 \item The \href{https://ctan.org/pkg/glossaries-extra}{\styfmt{glossaries-extra}} package.
3082 \item The \href{https://ctan.org/pkg/bib2gls}{\appfmt{bib2gls}}
3083 application.
3084 \end{itemize}
3085 The \gallery{Dickimaw Books Gallery} provides additional example documents.
3086
3087 \printterms
3088 \printsummary
3089 \clearpage
3090 \printuserguideindex
3091
3092 \end{document}