• No results found

dickimaw-books.com/contact 2022-10-14

N/A
N/A
Protected

Academic year: 2022

Share "dickimaw-books.com/contact 2022-10-14"

Copied!
706
0
0

Full text

(1)

Nicola L.C. Talbot

dickimaw-books.com/contact 2022-10-14

This document is also available as HTML (glossaries-user.html).

Abstract

Theglossariespackage provides a means to define terms or acronyms or sym- bols that can be referenced within your document. Sorted lists with collated locations can be generated either using TEX or using a supplementary indexing application. Sample documents are provided with theglossariespackage. These are listed in §18.

glossaries-extra Additional features not provided here may be available through the extension package glossaries-extrawhich, if required, needs to be installed separately. New features will be added toglossaries-extra. Versions of theglossariespackage after v4.21 will mostly be just bug fixes or minor maintenance. The most significant update to theglossaries package since then is version 4.50, which involved the integration of mfirstuc v2.08 and the phasing out the use of the now deprecatedtextcasepackage.

Note that glossaries-extra provides an extra indexing option (bib2gls) which isn’t available with just the baseglossariespackage.

If you require multilingual support you must also install the relevant language module.

Each language module is calledglossaries-hlanguagei, where hlanguageiis the root lan- guage name. For example,glossaries-frenchorglossaries-german. If a language mod- ule is required, theglossariespackage will automatically try to load it and will give a warning if the module isn’t found. See §1.5 for further details. If there isn’t any support available for your language, use thenolangwarn package option to suppress the warning and provide your own translations. (For example, use thetitlekey in\printglossary.)

(2)

of terms or notation. People have their own preferences and to a large extent this is determined by the kind of information that needs to go in the glossary. They may just have symbols with terse descriptions or they may have long technical words with complicated descriptions. The glossariespackage is flexible enough to accommodate such varied requirements, but this flexibility comes at a price: a big manual.

If you’re freaking out at the size of this manual, start with “The glossariespack- age: a guide for beginners” (glossariesbegin.pdf). You should find it in the same directory as this document or try

� texdoc glossariesbegin

Once you’ve got to grips with the basics, then come back to this manual to find out how to adjust the settings.

Theglossariesbundle includes the following documentation:

Theglossariespackage: a guide for beginners (glossariesbegin.pdf)

If you want some brief information and examples to get you going, start with the guide for beginners.

User Manual for glossaries.sty (glossaries-user.pdf)

This document is the main user guide for theglossariespackage.

Documented Code for glossaries (glossaries-code.pdf)

Advanced users wishing to know more about the inner workings of all the packages provided in theglossariesbundle should read “Documented Code for glossaries v4.50”.

CHANGES

Change log.

README.md

Package summary.

Depends.txt

List of all packages unconditionally required by glossaries. Other unlisted packages may be required under certain circumstances. For help on installing packages see, for example, How do I update my TEX distribution?1 or (for Linux users) Updating TEX on Linux.2

1tex.stackexchange.com/questions/55437

2tex.stackexchange.com/questions/14925

(3)

• glossariesFAQ4

• glossariesgallery5

• a summary of all glossary styles provided byglossariesandglossaries-extra6

• glossariesperformance7(comparing document build times for the different options pro- vided byglossariesandglossaries-extra).

• Using LaTeX to Write a PhD Thesis8(chapter 6).

• Incorporatingmakeglossariesormakeglossaries-liteorbib2glsinto the doc- ument build9

• Theglossaries-extrapackage10

• bib2gls11

� If you usehyperref andglossaries, you must load hyperreffirst (although, in general, hyperrefshould be loaded after other packages).

3mirrors.ctan.org/support/bib2gls/bib2gls-begin.pdf

4dickimaw-books.com/faqs/glossariesfaq.html

5dickimaw-books.com/gallery/#glossaries

6dickimaw-books.com/gallery/glossaries-styles/

7dickimaw-books.com/gallery/glossaries-performance.shtml

8dickimaw-books.com/latex/thesis/

9dickimaw-books.com/latex/buildglossaries/

10ctan.org/pkg/glossaries-extra

11ctan.org/pkg/bib2gls

(4)

List of Tables vi

List of Examples vii

I. User Guide 1

1. Introduction 2

1.1. Rollback . . . 6

1.2. Integrating Other Packages and Known Issues . . . 7

1.3. Indexing Options . . . 8

1.3.1. Option 1 (“noidx”) . . . 9

1.3.2. Option 2 (makeindex) . . . 14

1.3.3. Option 3 (xindy) . . . 18

1.3.4. Option 4 (bib2gls) . . . 22

1.3.5. Option 5 (“unsrt”) . . . 27

1.3.6. Option 6 (“standalone”) . . . 29

1.4. Dummy Entries for Testing . . . 36

1.5. Multi-Lingual Support . . . 42

1.5.1. Changing the Fixed Names . . . 44

1.5.2. Creating a New Language Module . . . 47

1.6. Generating the Associated Glossary Files . . . 52

1.6.1. Using themakeglossariesPerl Script . . . 56

1.6.2. Using themakeglossaries-liteLua Script . . . 60

1.6.3. Usingxindyexplicitly (Option 3) . . . 63

1.6.4. Usingmakeindexexplicitly (Option 2) . . . 64

1.7. Note to Front-End and Script Developers . . . 65

1.7.1. MakeIndex and Xindy . . . 65

1.7.2. Entry Labels . . . 67

1.7.3. Bib2Gls . . . 67

2. Package Options 69 2.1. General Options . . . 69

2.2. Sectioning, Headings and TOC Options . . . 77

2.3. Glossary Appearance Options . . . 82

2.4. Indexing Options . . . 91

2.5. Sorting Options . . . 96

(5)

2.6. Glossary Type Options . . . 108

2.7. Acronym andAbbreviationOptions . . . 112

2.8. Deprecated Acronym Style Options . . . 115

2.9. Other Options . . . 119

2.10. Setting Options After the Package is Loaded . . . 121

3. Setting Up 122 3.1. Option 1 . . . 122

3.2. Options 2 and 3 . . . 122

4. Defining Glossary entries 126 4.1. Plurals . . . 137

4.2. Other Grammatical Constructs . . . 138

4.3. Additional Keys . . . 139

4.3.1. Document Keys . . . 139

4.3.2. Storage Keys . . . 141

4.4. Expansion . . . 147

4.5. Sub-Entries . . . 148

4.5.1. Hierarchy . . . 149

4.5.2. Homographs . . . 150

4.6. Loading Entries From a File . . . 152

4.7. Moving Entries to Another Glossary . . . 155

4.8. Drawbacks With Defining Entries in the Document Environment . . . 155

4.8.1. Technical Issues . . . 156

4.8.2. Good Practice Issues . . . 157

5. Referencing Entries in the Document 158 5.1. Links to Glossary Entries . . . 158

5.1.1. Options . . . 161

5.1.2. The\gls-Like Commands (First Use Flag Queried) . . . 163

5.1.3. The\glstext-Like Commands (First Use Flag Not Queried) . . . 167

5.1.4. Changing the Format of the\gls-like Link Text . . . 174

5.1.5. Hooks . . . 180

5.1.6. Enabling and Disabling Hyperlinks to Glossary Entries . . . 180

5.2. Using Glossary Terms Without Indexing . . . 183

6. Acronyms and Other Abbreviations 191 6.1. Displaying the Long, Short and Full Forms (Independent of First Use) . . . . 195

6.2. Changing the Acronym Style . . . 201

6.2.1. Predefined Acronym Styles . . . 203

6.2.2. Defining A Custom Acronym Style . . . 210

6.3. Displaying the List of Acronyms . . . 225

6.4. Upgrading From theglossaryPackage . . . 226

(6)

7. Unsetting and Resetting Entry Flags 228 7.1. Counting the Number of Times an Entry has been Used (First Use Flag Unset) 232

8. Displaying a Glossary 239

8.1. \printh…iglossaryOptions . . . 241

8.2. Glossary Markup . . . 244

9. Defining New Glossaries 251 10.Adding an Entry to the Glossary Without Generating Text 254 11.Cross-Referencing Entries 259 11.1. Customising Cross-Reference Text . . . 262

12.Number Lists 265 12.1. Encap Values (Location Formats) . . . 266

12.2. Range Formations . . . 271

12.3. Locations . . . 273

12.4. Page Precedence . . . 276

12.5. Problematic Locations . . . 276

12.6. Iterating Over Locations . . . 288

13.Glossary Styles 291 13.1. Predefined Styles . . . 293

13.1.1. List Styles . . . 296

13.1.2. Longtable Styles . . . 299

13.1.3. Longtable Styles (Ragged Right) . . . 303

13.1.4. Longtable Styles (booktabs) . . . 306

13.1.5. Supertabular Styles . . . 308

13.1.6. Supertabular Styles (Ragged Right) . . . 311

13.1.7. Tree-Like Styles . . . 314

13.1.8. Multicols Style . . . 319

13.1.9. In-Line Style . . . 321

13.2. Defining your own glossary style . . . 324

13.2.1. Commands For Use in Glossary Styles . . . 325

13.2.2. Hyper Group Navigation . . . 329

13.2.3. Glossary Style Commands . . . 331

14.Xindy (Option 3) 337 14.1. Required Styles . . . 338

14.2. Language and Encodings . . . 339

14.3. Locations and Number lists . . . 340

14.4. Glossary Groups . . . 350

(7)

15.Utilities 352

15.1. hyperref . . . 352

15.2. Case-Changing . . . 353

15.3. Loops . . . 355

15.4. Conditionals . . . 357

15.5. Fetching and Updating the Value of a Field . . . 364

16.Prefixes or Determiners 367 17.Accessibility Support 375 17.1. Accessibility Keys . . . 375

17.2. Incorporating Accessibility Support . . . 378

17.3. Incorporating the Access Field Values . . . 380

17.4. Obtaining the Access Field Values . . . 383

17.5. Developer’s Note . . . 386

18.Sample Documents 387 18.1. Basic . . . 387

18.2. Acronyms and First Use . . . 393

18.3. Non-Page Locations . . . 411

18.4. Multiple Glossaries . . . 422

18.5. Sorting . . . 434

18.6. Child Entries . . . 441

18.7. Cross-Referencing . . . 455

18.8. Custom Keys . . . 458

18.9. Xindy (Option 3) . . . 462

18.10.No Indexing Application (Option 1) . . . 474

18.11.Other . . . 475

19.Troubleshooting 491

II. Summaries and Index 492

Symbols 493

Terms 494

Glossary Entry Keys Summary 501

\Gls-Like and \Glstext-Like Options Summary 510

\printh…iglossary Options Summary 513

Acronym Style Summary 517

(8)

Glossary Styles Summary 521

Command Summary 537

Command Summary: @ . . . 537

Command Summary: A . . . 538

Command Summary: B . . . 546

Command Summary: C . . . 546

Command Summary: D . . . 548

Command Summary: E . . . 551

Command Summary: F . . . 551

Command Summary: G . . . 553

Command Summary: Glo . . . 553

Command Summary: Gls . . . 556

Command Summary: Glsxtr . . . 620

Command Summary: H . . . 633

Command Summary: I . . . 634

Command Summary: L . . . 639

Command Summary: M . . . 640

Command Summary: N . . . 641

Command Summary: O . . . 644

Command Summary: P . . . 644

Command Summary: R . . . 648

Command Summary: S . . . 649

Command Summary: T . . . 653

Command Summary: W . . . 653

Command Summary: X . . . 654

Environment Summary 655

Package Option Summary 656

Index 666

(9)

1.1. Glossary Options: Pros and Cons . . . 10

1.2. Customised Text . . . 45

1.3. Commands and package options that have no effect when using xindy or makeindexexplicitly . . . 56

4.1. Key to Field Mappings . . . 148

6.1. Synonyms provided by theshortcutspackage option . . . 199

6.2. The effect of usingxspacewith\oldacronym. . . 227

12.1. Predefined Hyperlinked Location Formats . . . 267

13.1. Glossary Styles . . . 294

13.2. Multicolumn Styles . . . 320

(10)

1. Simple document with no glossary . . . 3

2. Simple document with unsorted glossaries . . . 5

3. Simple document that uses TEX to sort entries . . . 12

4. Simple document that usesmakeindexto sort entries . . . 15

5. Simple document that usesxindyto sort entries . . . 19

6. Simple document that usesbib2glsto sort entries . . . 24

7. Simple document with an unsorted list of all defined entries . . . 28

8. Simple document with standalone entries . . . 31

9. Mixing Alphabetical and Order of Definition Sorting . . . 99

10. Customizing Standard Sort (Options 2 or 3) . . . 100

11. Defining Custom Keys . . . 140

12. Defining Custom Storage Key (Acronyms and Initialisms) . . . 141

13. Defining Custom Storage Key (Acronyms and Non-Acronyms with Descrip- tions) . . . 144

14. Hierarchical Divisions — Greek and Roman Mathematical Symbols . . . 149

15. Loading Entries from Another File . . . 152

16. Custom Entry Display in Text . . . 178

17. Custom Format for Particular Glossary . . . 179

18. First Use With Hyperlinked Footnote Description . . . 181

19. Suppressing Hyperlinks on First Use Just For Acronyms . . . 181

20. Only Hyperlink in Text Mode Not Math Mode . . . 182

21. One Hyper Link Per Entry Per Chapter . . . 182

22. Simple document with acronyms . . . 191

23. Defining and Using an Acronym . . . 194

24. Defining and Using an Acronym (Rollback) . . . 202

25. Small-Caps Acronym . . . 204

26. Adapting a Predefined Acronym Style . . . 206

27. Defining a Custom Acronym Style . . . 213

28. Italic and Upright Abbreviations . . . 220

29. Abbreviations with Full Stops (Periods) . . . 223

30. Don’t index entries that are only used once . . . 238

31. Switch to Two Column Mode for Glossary . . . 248

32. Dual Entries . . . 257

33. Changing the Font Used to Display Entry Names in the Glossary . . . 292

34. Creating a completely new style . . . 333

35. Creating a new glossary style based on an existing style . . . 335

(11)

36. Example: creating a glossary style that uses theuser1, …,user6keys . . . . 335

37. Custom Font for Displaying a Location . . . 342

38. Custom Numbering System for Locations . . . 343

39. Locations as Dice . . . 344

40. Locations as Words not Digits . . . 346

41. Defining Determiners . . . 368

42. Using Prefixes . . . 371

43. Adding Determiner to Glossary Style . . . 373

(12)

User Guide

(13)

\usepackage[hoptionsi]{glossaries}

Theglossariespackage is provided to assist generating lists of terms, symbols or acronyms.

For convenience, these lists are all referred to as glossaries in this manual. The terms, symbols and acronyms are collectively referred to as glossary entries.

The package has a certain amount of flexibility, allowing the user to customize the format of the glossary and define multiple glossaries. It also supports glossary styles that include an associated symbol (in addition to a name and description) for each glossary entry.

There is provision for loading a database of glossary entries. Only those entries indexed in the document will be displayed in the glossary. (Unless you use Option 5, which doesn’t use any indexing but will instead list all defined entries in order of definition.)

It’s not necessary to actually have a glossary in the document. You may be interested in using this package just as means to consistently format certain types of terms, such as acronyms, or you may prefer to have descriptions scattered about the document and be able to easily link to the relevant description (Option 6).

The simplest document is one without a glossary:

\documentclass{article}

\usepackage[

sort=none % no sorting or indexing required ]{glossaries}

\newglossaryentry {cafe}% label {% definition:

name={café},

description={small restaurant selling refreshments}

}

\setacronymstyle{long-short}

\newacronym {html}% label {HTML}% short form

(14)

{hypertext markup language}% long form

\newglossaryentry {pi}% label {% definition:

name={\ensuremath{\pi}},

description={Archimedes' Constant}

}

\newglossaryentry {distance}% label {% definition:

name={distance},

description={the length between two points}, symbol={m}

}

\begin{document}

First use: \gls{cafe}, \gls{html}, \gls{pi}.

Next use: \gls{cafe}, \gls{html}, \gls{pi}.

\Gls{distance} (\glsentrydesc{distance}) is measured in

\glssymbol{distance}.

\end{document}

(This is a trivial example. For a real document I recommend you usesiunitxfor units.)

Example 1: Simple document with no glossary �

First use: caf´e, hypertext markup language (HTML), π. Next use: caf´e, HTML, π.

Distance (the length between two points) is measured in m.

Theglossaries-extrapackage, which is distributed as a separate bundle, extends the capa- glossaries -extra

bilities of theglossariespackage. The simplest document with a glossary can be created with glossaries-extra(which internally loads theglossariespackage):

\documentclass{article}

\usepackage[

sort=none,% no sorting or indexing required abbreviations,% create list of abbreviations

(15)

symbols,% create list of symbols

postdot, % append a full stop after the descriptions stylemods,style=index % set the default glossary style ]{glossaries-extra}

\newglossaryentry % glossaries.sty {cafe}% label

{% definition:

name={café},

description={small restaurant selling refreshments}

}

\setabbreviationstyle{long-short}% glossaries-extra.sty

\newabbreviation % glossaries-extra.sty {html}% label

{HTML}% short form

{hypertext markup language}% long form

% requires glossaries-extra.sty 'symbols' option

\glsxtrnewsymbol

[description={Archimedes' constant}]% options {pi}% label

{\ensuremath{\pi}}% symbol

\newglossaryentry % glossaries.sty {distance}% label

{% definition:

name={distance},

description={the length between two points}, symbol={m}

}

\begin{document}

First use: \gls{cafe}, \gls{html}, \gls{pi}.

Next use: \gls{cafe}, \gls{html}, \gls{pi}.

\Gls{distance} is measured in \glssymbol{distance}.

\printunsrtglossaries % list all defined entries

\end{document}

(16)

� Example 2: Simple document with unsorted glossaries �

First use: caf´e, hypertext markup language (HTML), π. Next use: caf´e, HTML, π.

Distance is measured in m.

Glossary

caf´e small restaurant selling refreshments.

distance (m) the length between two points.

Symbols

π Archimedes’ constant.

Abbreviations

HTML hypertext markup language.

Note the difference in the way theabbreviation(HTML) and symbol (π) are defined in the two above examples. Theabbreviations,postdotandstylemodsoptions are specific to glossaries-extra. Other options are passed to the baseglossariespackage.

glossaries-extra In this user manual, commands and options displayed in tan, such as \new- abbreviationandstylemods, are only available with theglossaries-extrapackage.

There are also some commands and options (such as\makeglossariesandsymbols) that are provided by the base glossariespackage but are redefined by the glossaries -extrapackage. See theglossaries-extrauser manual for further details of those com- mands.

One of the strengths of theglossaries package is its flexibility, however the drawback of this is the necessity of having a large manual that covers all the various settings. If you are daunted by the size of the manual, try starting off with the much shorter guide for beginners (glossariesbegin.pdf).

� There’s a common misconception that you have to have Perl installed in order to use the glossariespackage. Perl is not a requirement (as demonstrated by the above ex-

(17)

amples) but it does increase the available options, particularly if you use an extended Latin alphabet or a non-Latin alphabet.

This document uses theglossaries-extrapackage withbib2gls(Option 4). For example, when viewing thePDFversion of this document in a hyperlinked-enabledPDFviewer (such as Adobe Reader or Okular) if you click on the word “indexing” you’ll be taken to the entry in the main glossary where there’s a brief description of the term. This is the way theglossaries mechanism works. An indexing application (bib2glsin this case) is used to generate the sorted list of terms. The indexing applications areCLI tools, which means they can be run directly from a command prompt or terminal, or can be integrated into some text editors, or you can use a build tool such asararato run them.

In addition to standard glossaries, this document has “standalone” definitions (Option 6).

For example, if you click on the command\gls, the hyperlink will take you to main part of the document where the command is described. The index and summaries are also glossaries.

The technique used is too complicated to describe in this manual, but an example can be found in “bib2gls: Standalone entries and repeated lists (a little book of poisons)”TUGboat, Volume 43 (2022), No. 1.

Neither of the above two examples require an indexing application. The first is just using theglossariespackage for consistent formatting, and there is no list. The second has lists but they are unsorted (see Option 5).

The remainder of this introductory section covers the following:

• §1.3 lists the available indexing options.

• §1.4 lists the files provided that contain dummy glossary entries which may be used for testing.

• §1.5 provides information for users who wish to write in a language other than English.

• §1.6 describes how to use an indexing application to create the sorted glossaries for your document (Options 2 or 3).

In addition to the examples provided in this document, there are some sample documents provided with theglossariespackage. They are described in §18.

Theglossariespackage comes with a number of sample documents that illustrate the var- ious functions. These are listed in §18.

1.1. Rollback

The following rollback releases are available:

• Version 4.49 (2021-11-01):

(18)

\usepackage{glossaries}[=v4.49]

Note that this should also rollbackmfirstucto version 2.07 if you have a later version installed.

• Version 4.46 (2020-03-19):

\usepackage{glossaries}[=v4.46]

If you rollback usinglatexreleaseto an earlier date, then you will need to specify v4.46 for glossariesas there are no earlier rollback versions available. You may want to consider using one of the historic TEX Live Docker images instead. See, for example, Legacy Documents and TeX Live Docker Images.1

1.2. Integrating Other Packages and Known Issues

If you usehyperrefandglossaries, you must loadhyperreffirst (although, in general,hyperref should be loaded after other packages).

Occasionally you may find that certain packages need to be loadedafter packages that are required byglossariesbut need to also be loaded beforeglossaries. For example, a package hXi might need to be loaded after amsgen but before hyperref (which needs to be loaded beforeglossaries). In which case, load the required package first (for example,amsgen), then hXi, and finally loadglossaries.

\usepackage{amsgen}% load before hXi

\usepackage{hXi}% must be loaded after amsgen

\usepackage{hyperref}% load after hXi

\usepackage{glossaries}% load after hyperref

Some packages don’t work with some glossary styles. For example,classicthesis doesn’t work with the styles that use thedescriptionenvironment, such as theliststyle. Since this is the default style, theglossariespackage checks forclassicthesisand will change the default to theindexstyle if it has been loaded.

Some packages conflict with a package that’s required by a glossary style style pack- age. For example, xtab conflicts with supertabular, which is required by glossary-super.

In this case, ensure the problematic glossary style package isn’t loaded. For example, use thenosuperoption and (withglossaries-extra) don’t usestylemods=superorstylemods=

all. Theglossariespackage now (v4.50+) checks forxtaband will automatically implement nosuperif it has been loaded.

1dickimaw-books.com/blog/legacy-documents-and-tex-live-docker-images

(19)

The language-support is implemented usingtracklang. This needs to know the document languages that have to be supported. It currently (version 1.6 at the time of writing) can’t detect the use of\babelprovide. Thetracklangpackage is able to pick up known language labels from the document class options, for example:

\documentclass[german]{article}

\usepackage[translate=true]{glossaries}

The above doesn’t loadbabelorpolyglossiaortranslator, but thetranslate=truesetting will ensure thattracklangis loaded and the language-sensitive command provided byglossaries will use the definitions inglossaries-german.ldf(which needs to be installed separately, see §1.5) becausetracklangcan pick up thegermandocument class option.

Thetracklangpackage is also able to pick up languages passed as package options tobabel ortranslator, provided they were loaded beforetracklang. For example,

\usepackage[french]{babel}

\usepackage[translate=babel]{glossaries}

Thetracklangpackage used to be able to detect languages identified bypolyglossia’s\set- mainlanguageand \setotherlanguage, but tracklang v1.5 can’t with newer versions of polyglossia. You will need to upgrade totracklangv1.6+ to allow this to work again.

In the event thattracklangcan’t pick up the required languages, it’s also possible to identify them with thelanguagesoption. For example:

\usepackage[nil]{babel}

\babelprovide{french}

\usepackage[languages=french]{glossaries}

1.3. Indexing Options

The basic idea behind theglossariespackage is that you first define your entries (terms, sym- bols or acronyms). Then you can reference these within your document (analogous to\cite or\ref). You can also, optionally, display a list of the entries you have referenced in your document (the glossary). This last part, displaying the glossary, is the part that most new users find difficult. There are three options available with the baseglossariespackage (Op- tions 1 – 3). The glossaries-extra extension package provides two extra options for lists ( Options 4 and 5) as well as an option for standalone descriptions within the document body (Option 6).

An overview of Options 1 – 5 is given in Table 1.1 on page 10. Option 6 is omitted from

(20)

the table as it doesn’t produce a list. For a more detailed comparison of the various methods, see theglossariesperformance page.2 If, for some reason, you want to know what indexing option is in effect, you can test the value of:

\glsindexingsetting This is initialised to:

\ifglsxindy xindy\else makeindex\fi

If the sort=none or sort=clear options are used, \glsindexingsetting will be rede- fined tonone. If\makeglossariesis used\glsindexingsettingwill be updated to either makeindexorxindyas appropriate (that is, the conditional will no longer be part of the def- inition). If\makenoidxglossariesis used then\glsindexingsettingwill be updated to noidx. This means that\glsindexingsettingcan’t be fully relied on until the start of the documentenvironment. (If you are using glossaries-extrav1.49+, then this command will also be updated to take therecordsetting into account.)

� If you are developing a class or package that loads glossaries, I recommend that you don’t force the user into a particular indexing method by adding an unconditional

\makeglossariesinto your class or package code. Aside from forcing the user into a particular indexing method, it means that they’re unable to use any commands that must come before\makeglossaries(such as\newglossary) and they can’t switch off the indexing whilst working on a draft document. (If you are using a class or pack- age that has done this, pass thedisablemakeglossoption toglossaries. For example, via the document class options.)

Strictly speaking, Options 5 and 6 aren’t actually indexing options as no indexing is per- formed. In the case of Option 5, all defined entries are listed in order of definition. In the case of Option 6, the entry hypertargets and descriptions are manually inserted at appropri- ate points in the document. These two options are included here for completeness and for comparison with the actual indexing options.

1.3.1. Option 1 (“noidx”)

This option isn’t generally recommended for reasons given below. It’s best used withsort=

use(order of use) orsort=def(order of definition). Example Document:

2dickimaw-books.com/gallery/glossaries-performance.shtml

(21)

Table 1.1.: Glossary Options: Pros and Cons

Option 1 2 3 4 5

Requiresglossaries-extra? 8 8 8 4 4

Requires an external application? 8 4 4 4 8

Requires Perl? 8 8 4 8 8

Requires Java? 8 8 8 4 8

Can sort extended Latin alphabets

or non-Latin alphabets? 8 8 4 4 N/A

Efficient sort algorithm? 8 4 4 4 N/A

Can use a different sort method for

each glossary? 4 8 8 4 N/A

Any problematic sort values? 4 4 4 8 8

Are entries with identical sort values treated as separate unique entries?

4 4 8§ 4 4

Can automatically form ranges in

the location lists? 8 4 4 4 8

Can have non-standard locations

in the location lists? 4 8 4 4 4

Maximum hierarchical depth (style-dependent)

# 3 ∞ ∞ ∞

\glsdisplaynumberlist

reliable? 4 8 8 4 8

\newglossaryentryallowed in documentenvironment? (Not recommended.)

8 4 4 8 4**

Requires additional write

registers? 8 4 4 8 8?

Default value ofsanitizesort

package option false true true true^true^

Strips standard LATEX accents (that is, accents generated by core LATEX commands) so, for example,\AAis treated the same as A.

Only with the hybrid method provided withglossaries-extra.

Providedsort=noneis used.

§Entries with the same sort value are merged.

Requires some setting up.

The locations must be set explicitly through the customlocationfield provided by glossaries-extra.

#Unlimited but unreliable.

Entries are defined inbibformat.\newglossaryentryshould not be used explicitly.

**Provideddocdef=trueordocdef=restrictedbut not recommended.

?Provideddocdef=falseordocdef=restricted.

^Irrelevant withsort=none. (Therecord=onlyoption automatically switches this on.)

(22)

\documentclass{article}

\usepackage[style=indexgroup]{glossaries}

\makenoidxglossaries % use TeX to sort

\newglossaryentry{parrot}{name={parrot},

description={a brightly coloured tropical bird}}

\newglossaryentry{duck}{name={duck}, description={a waterbird}}

\newglossaryentry{puffin}{name={puffin},

description={a seabird with a brightly coloured bill}}

\newglossaryentry{penguin}{name={penguin},

description={a flightless black and white seabird}}

% a symbol:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, sort={alpha},description={a variable}}

% an acronym:

\setacronymstyle{short-long}

\newacronym{arpanet}{ARPANET}

{Advanced Research Projects Agency Network}

\begin{document}

\Gls{puffin}, \gls{duck} and \gls{parrot}.

\gls{arpanet} and \gls{alpha}.

Next use: \gls{arpanet}.

\printnoidxglossary

\end{document}

You can place all your entry definitions in a separate file and load it in the document preamble with\loadglsentries (after \makenoidxglossaries). Note that six entries have been defined but only five are referenced (indexed) in the document so only those five appear in the glossary.

(23)

� Example 3: Simple document that uses TEX to sort entries �

Puffin, duck and parrot. ARPANET (Advanced Research Projects Agency Network) and α. Next use: ARPANET.

Glossary

A

α a variable. 1

ARPANET Advanced Research Projects Agency Network. 1 D

duck a waterbird. 1 P

parrot a brightly coloured tropical bird. 1 puffin a seabird with a brightly coloured bill. 1

This uses the indexgroupstyle, which puts a heading at the start of each letter group. The letter group is determined by the first character of the sort value. For a preview of all available styles, see Gallery: Predefined Styles.3 The number 1 after each description is the number list (or location list). This is the list of locations (page numbers, in this case) where the entry was indexed. In this example, all entries were indexed on page 1.

This option doesn’t require an external indexing application but, with the default alpha- betic sorting, it’s very slow with severe limitations. If you want a sorted list, it doesn’t work well for extended Latin alphabets or non-Latin alphabets. However, if you use the sanitizesort=falsepackage option (the default for Option 1) then the standard LATEX ac- cent commands will be ignored, so if an entry’s name is set to\'elitethen the sort value will default to elite if sanitizesort=false is used and will default to the literal string

\'eliteifsanitizesort=trueis used.

� Previously, it was also possible to strip accents fromUTF-8 characters, but that’s not possible following updates to the LATEX kernel. The kernel updates are beneficial as they make it possible to useUTF-8 characters in labels, but the trick of stripping accents was a hack that no longer works.

If you have any other kinds of commands that don’t expand toASCIIcharacters, such as

\alpha, then you must usesanitizesort=trueor change the sort method (sort=useor

3dickimaw-books.com/gallery/index.php?label=glossaries-styles

(24)

sort=def) in the package options or explicitly set thesortkey when you define the relevant entries, as shown in the above example which has:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, sort={alpha},description={a variable}

}

glossaries-extra The glossaries-extra package has a modified symbolspackage option that provides

\glsxtrnewsymbol, which automatically sets thesortkey to the entry label (instead of thename).

This option works best with the sort=def orsort=use setting. For any other setting, be prepared for a long document build time, especially if you have a lot of entries defined.

This option is intended as a last resort for alphabetical sorting. This option allows a mixture of sort methods. (For example, sorting by word order for one glossary and order of use for another.) This option is not suitable for hierarchical glossaries and does not form ranges in the location lists. If you really can’t use an indexing application consider using Option 5 instead.

Summary:

1. Add

\makenoidxglossaries

to your preamble (before you start defining your entries, as described in §4).

2. Put

\printnoidxglossary

where you want your list of entries to appear (described in §8). Alternatively, to display all glossaries use the iterative command:

\printnoidxglossaries

3. Run LATEX twice on your document. (As you would do to make a table of contents appear.) For example, click twice on the “typeset” or “build” or “pdfLATEX” button in your editor.

(25)

1.3.2. Option 2 (makeindex)

Example document:

\documentclass{article}

\usepackage[style=indexgroup]{glossaries}

\makeglossaries % open indexing files

\newglossaryentry{parrot}{name={parrot},

description={a brightly coloured tropical bird}}

\newglossaryentry{duck}{name={duck}, description={a waterbird}}

\newglossaryentry{puffin}{name={puffin},

description={a seabird with a brightly coloured bill}}

\newglossaryentry{penguin}{name={penguin},

description={a flightless black and white seabird}}

% a symbol:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, sort={alpha},description={a variable}}

% an acronym:

\setacronymstyle{short-long}

\newacronym{arpanet}{ARPANET}

{Advanced Research Projects Agency Network}

\begin{document}

\Gls{puffin}, \gls{duck} and \gls{parrot}.

\gls{arpanet} and \gls{alpha}.

Next use: \gls{arpanet}.

\printglossary

\end{document}

You can place all your entry definitions in a separate file and load it in the preamble with

\loadglsentries(after \makeglossaries). The result is the same as for Example 3 on page 12.

(26)

� Example 4: Simple document that usesmakeindexto sort entries �

Puffin, duck and parrot. ARPANET (Advanced Research Projects Agency Network) and α. Next use: ARPANET.

Glossary

A

α a variable. 1

ARPANET Advanced Research Projects Agency Network. 1 D

duck a waterbird. 1 P

parrot a brightly coloured tropical bird. 1 puffin a seabird with a brightly coloured bill. 1

This option uses aCLIapplication called makeindexto sort the entries. This application comes with all modern TEX distributions, but it’s hard-coded for the non-extended Latin alphabet. It can’t correctly sort accent commands (such as\' or\c) and fails withUTF-8 characters, especially for any sort values that start with aUTF-8 character (as it separates the octets resulting in an invalid file encoding). This process involves making LATEX write the glossary information to a temporary file whichmakeindexreads. Thenmakeindex writes a new file containing the code to typeset the glossary. Then\printglossaryreads this file in on the next run.

� There are other applications that can read makeindex files, such as texindy and xindex, but theglossariespackage uses a customizediststyle file (created by\make- glossaries) that adjusts the special characters and input keyword and also ensures that the resulting file (which is input by \printglossary) adheres to the glossary style. If you want to use an alternative, you will need to ensure that it can honour the settings in theistfile.

This option works best if you want to sort entries according to the English alphabet and you don’t want to install Perl or Java. This method can also work with the restricted shell escape since makeindex is considered a trusted application, which means you should be able to use theautomake=immediateorautomake=truepackage option provided the shell escape hasn’t been completely disabled.

(27)

This method can form ranges in the number list but only accepts limited number formats:

\arabic,\roman,\Roman,\alphand\Alph.

This option does not allow a mixture of sort methods. All glossaries must be sorted accord- ing to the same method: word/letter ordering or order of use or order of definition. If you need word ordering for one glossary and letter ordering for another you’ll have to explicitly callmakeindexfor each glossary type.

glossaries-extra Theglossaries-extrapackage allows a hybrid mix of Options 1 and 2 to provide word/

letter ordering with Option 2 and order of use/definition with Option 1. See the glossaries-extra documentation for further details. See also the glossaries-extra al- ternative tosampleSort.texin §18.5.

Summary:

1. If you want to usemakeindex’s-goption you must change the quote character using

\GlsSetQuote. For example:

\GlsSetQuote{+}

This must be used before \makeglossaries. Note that if you are using babel, the shorthands aren’t enabled until the start of the document, so you won’t be able to use the shorthands in definitions that occur in the preamble.

2. Add

\makeglossaries

to your preamble (before you start defining your entries, as described in §4).

3. Put

\printglossary

where you want your list of entries to appear (described in §8). Alternatively, to display all glossaries use the iterative command:

\printglossaries

(28)

4. Run LATEX on your document. This creates files with the extensionsgloandist(for example, if your LATEX document is calledmyDoc.tex, then you’ll have two extra files called myDoc.gloand myDoc.ist). If you look at your document at this point, you won’t see the glossary as it hasn’t been created yet. (If you useglossaries-extrayou’ll see the section heading and some boilerplate text.)

If you have used package options such assymbolsthere will also be other sets of files corresponding to the extra glossaries that were created by those options.

5. Runmakeindexwith theglofile as the input file and theistfile as the style so that it creates an output file with the extensiongls:

� makeindex -s myDoc.ist -o myDoc.gls myDoc.glo

(ReplacemyDoc with the base name of your LATEX document file. Avoid spaces in the file name if possible.)

� The file extensions vary according to the glossary type. See §1.6.4 for further details. makeindexmust be called for each set of files.

If you don’t know how to use the command prompt, then you can probably access makeindex via your text editor, but each editor has a different method of doing this.

See Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build4for some examples.

Alternatively, runmakeindexindirectly via themakeglossariesscript:

� makeglossaries myDoc

Note that the file extension isn’t supplied in this case. (Replacemakeglossarieswith makeglossaries-lite if you don’t have Perl installed.) This will pick up all the file extensions from theauxfile and runmakeindexthe appropriate number of times with all the necessary switches.

The simplest approach is to useararaand add the following comment lines to the start of your document:

% arara: pdflatex

% arara: makeglossaries

% arara: pdflatex

4dickimaw-books.com/latex/buildglossaries/

(29)

(Replacemakeglossarieswithmakeglossarieslitein the second line above if you don’t have Perl installed. Note that there’s no hyphen in this case.)

The default sort is word order (“sea lion” comes before “seal”). If you want letter or- dering you need to add the-lswitch:

� makeindex -l -s myDoc.ist -o myDoc.gls myDoc.glo

(See §1.6.4 for further details on using makeindex explicitly.) If you usemakeglos- saries ormakeglossaries-lite then use the order=letter package option and the-loption will be added automatically.

6. Once you have successfully completed the previous step, you can now run LATEX on your document again.

You’ll need to repeat the last step if you have used the toc option (unless you’re using glossaries-extra) to ensure the section heading is added to the table of contents. You’ll also need to repeat steps 5 and 6 if you have any cross-references which can’t be indexed until the indexing file has been created.

1.3.3. Option 3 (xindy)

Example document:

\documentclass{article}

\usepackage[xindy,style=indexgroup]{glossaries}

\makeglossaries % open indexing files

\newglossaryentry{parrot}{name={parrot},

description={a brightly coloured tropical bird}}

\newglossaryentry{duck}{name={duck}, description={a waterbird}}

\newglossaryentry{puffin}{name={puffin},

description={a seabird with a brightly coloured bill}}

\newglossaryentry{penguin}{name={penguin},

description={a flightless black and white seabird}}

% a symbol:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, sort={alpha},description={a variable}}

% an acronym:

\setacronymstyle{short-long}

\newacronym{arpanet}{ARPANET}

{Advanced Research Projects Agency Network}

\begin{document}

(30)

\Gls{puffin}, \gls{duck} and \gls{parrot}.

\gls{arpanet} and \gls{alpha}.

Next use: \gls{arpanet}.

\printglossary

\end{document}

You can place all your entry definitions in a separate file and load it in the preamble with

\loadglsentries(after \makeglossaries). The result is the same as for Example 3 on page 12 and Example 4 on page 15.

� Example 5: Simple document that usesxindyto sort entries �

Puffin, duck and parrot. ARPANET (Advanced Research Projects Agency Network) and α. Next use: ARPANET.

Glossary

A

α a variable. 1

ARPANET Advanced Research Projects Agency Network. 1 D

duck a waterbird. 1 P

parrot a brightly coloured tropical bird. 1 puffin a seabird with a brightly coloured bill. 1

This option uses aCLIapplication calledxindyto sort the entries. This application is more flexible thanmakeindexand is able to sort extended Latin alphabets or non-Latin alphabets, however it does still have some limitations.

Thexindyapplication comes with both TEX Live and MikTEX, but since xindyis a Perl script, you will also need to install Perl, if you don’t already have it. In a similar way to Option 2, this option involves making LATEX write the glossary information to a temporary file which xindy reads. Then xindy writes a new file containing the code to typeset the glossary. Then\printglossaryreads this file in on the next run.

This is the best option with just the baseglossariespackage if you want to sort according to a language other than English or if you want non-standard location lists, but it can require some setting up (see §14). There are some problems with certain sort values:

• entries with the same sort value are merged by xindy into a single glossary line so

(31)

you must make sure that each entry has a unique sort value;

• xindyforbids empty sort values;

• xindy automatically strips control sequences, the math-shift character $ and braces {} from the sort value, which is usually desired but this can cause the sort value to collapse to an empty string whichxindyforbids.

In these problematic cases, you must set thesortfield explicitly, as in the above example which has:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, sort={alpha},description={a variable}

}

glossaries-extra The glossaries-extra package has a modified symbolspackage option that provides

\glsxtrnewsymbol, which automatically sets thesortkey to the entry label (instead of thename).

All glossaries must be sorted according to the same method (word/letter ordering, order of use, or order of definition).

glossaries-extra Theglossaries-extrapackage allows a hybrid mix of Options 1 and 3 to provide word/

letter ordering with Option 3 and order of use/definition with Option 2. See the glossaries-extradocumentation for further details.

Summary:

1. Add thexindyoption to theglossariespackage option list:

\usepackage[xindy]{glossaries}

If you are using a non-Latin script you’ll also need to either switch off the creation of the number group:

\usepackage[xindy={glsnumbers=false}]{glossaries}

or use either \GlsSetXdyFirstLetterAfterDigits{hletteri} (to indicate the first letter group to follow the digits) or\GlsSetXdyNumberGroupOrder{hspeci}to indi- cate where the number group should be placed (see §14).

(32)

2. Add \makeglossariesto your preamble (before you start defining your entries, as described in §4).

3. Run LATEX on your document. This creates files with the extensionsgloandxdy(for example, if your LATEX document is calledmyDoc.tex, then you’ll have two extra files called myDoc.gloand myDoc.xdy). If you look at your document at this point, you won’t see the glossary as it hasn’t been created yet. (If you’re using theglossaries-extra extension package, you’ll see the section header and some boilerplate text.)

If you have used package options such assymbolsthere will also be other sets of files corresponding to the extra glossaries that were created by those options.

4. Run xindy with the glofile as the input file and the xdyfile as a module so that it creates an output file with the extensiongls. You also need to set the language name and input encoding, as follows (all on one line):

� xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.glg -o

myDoc.gls myDoc.glo

(ReplacemyDoc with the base name of your LATEX document file. Avoid spaces in the file name. If necessary, also replaceenglishwith the name of your language andutf8 with your input encoding, for example,-L german -C din5007-utf8.)

� The file extensions vary according to the glossary type. See §1.6.3 for further details. xindymust be called for each set of files.

It’s much simpler to usemakeglossariesinstead:

� makeglossaries myDoc

Note that the file extension isn’t supplied in this case. This will pick up all the file extensions from theauxfile and runxindythe appropriate number of times with all the necessary switches.

There’s no benefit in usingmakeglossaries-litewithxindy. (Remember thatxindy is a Perl script so if you can usexindythen you can also usemakeglossaries, and if you don’t want to usemakeglossaries because you don’t want to install Perl, then you can’t usexindyeither.)

If you don’t know how to use the command prompt, then you can probably access xindyormakeglossariesvia your text editor, but each editor has a different method of doing this. See Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build5for some examples.

5dickimaw-books.com/latex/buildglossaries/

(33)

Again, a convenient method is to use araraand add the follow comment lines to the start of your document:

% arara: pdflatex

% arara: makeglossaries

% arara: pdflatex

The default sort is word order (“sea lion” comes before “seal”). If you want letter or- dering you need to add theorder=letterpackage option:

\usepackage[xindy,order=letter]{glossaries}

(and return to the previous step). This option is picked up bymakeglossaries. If you are explicitly usingxindy then you’ll need to add -M ord/letorderto the options list. See §1.6.3 for further details on usingxindyexplicitly.

5. Once you have successfully completed the previous step, you can now run LATEX on your document again. As with makeindex (Option 2), you may need to repeat the previous step and this step to ensure the table of contents and cross-references are resolved.

1.3.4. Option 4 (bib2gls)

This option is only available with theglossaries-extraextension package. This method uses glossaries -extra

bib2glsto both fetch entry definitions frombibfiles and to hierarchically sort and collate.

Example document:

\documentclass{article}

\usepackage[record,style=indexgroup]{glossaries-extra}

\setabbreviationstyle{short-long}

% data in sample-entries.bib:

\GlsXtrLoadResources[src={sample-entries}]

\begin{document}

\Gls{puffin}, \gls{duck} and \gls{parrot}.

\gls{arpanet} and \gls{alpha}.

Next use: \gls{arpanet}.

\printunsrtglossary

\end{document}

Note that theabbreviationstyle must be set before\GlsXtrLoadResources. The filesample- entries.bibcontains:

(34)

@entry{parrot, name={parrot},

description={a brightly coloured tropical bird}

}@entry{duck, name={duck},

description={a waterbird}

}@entry{puffin, name={puffin},

description={a seabird with a brightly coloured bill}

}@entry{penguin, name={penguin},

description={a flightless black and white seabird}

}@symbol{alpha,

name={\ensuremath{\alpha}}, description={a variable}

}@abbreviation{arpanet, short={ARPANET},

long={Advanced Research Projects Agency Network}

}

The result is slightly different from the previous examples. Letter groups aren’t created by default withbib2glsso, even though the glossary style supports letter groups, there’s no group information.

(35)

� Example 6: Simple document that usesbib2glsto sort entries �

Puffin, duck and parrot. ARPANET (Advanced Research Projects Agency Network) and α. Next use: ARPANET.

Glossary

α a variable 1

ARPANET Advanced Research Projects Agency Network 1 duck a waterbird 1

parrot a brightly coloured tropical bird 1 puffin a seabird with a brightly coloured bill 1

All entries must be provided in one or morebibfiles. (See thebib2glsuser manual for the required format.) In this example, the terms “parrot”, “duck”, “puffin” and “penguin” are defined using@atentry, the symbol alpha (α) is defined using@symboland theabbreviation

“ARPANET” is defined using@abbreviation.

� Note that the sort key should not be used. Each entry type (@entry, @symbol,

@abbreviation) has a particular field that’s used for the sort value by default (name, the label, short). You will break this mechanism if you explicitly use thesort key.

Seebib2glsgallery: sortingafor examples.

adickimaw-books.com/gallery/index.php?label=label=bib2gls-sorting

Theglossaries-extrapackage needs to be loaded with therecordpackage option:

\usepackage[record]{glossaries-extra}

or (equivalently)

\usepackage[record=only]{glossaries-extra}

or (withglossaries-extrav1.37+ andbib2glsv1.8+):

\usepackage[record=nameref]{glossaries-extra}

Therecord=namerefoption is the best method if you are usinghyperref.

(36)

Each resource set is loaded with\GlsXtrLoadResources. For example:

\GlsXtrLoadResources

[% definitions in entries1.bib and entries2.bib:

src={entries1,entries2},

sort={de-CH-1996}% sort according to this locale ]

Thebibfiles are identified as a comma-separated list in the value of thesrckey. Thesort option identifies the sorting method. This may be a locale identifier for alphabetic sorting, but there are other sort methods available, such as character code or numeric. One resource set may cover multiple glossaries or one glossary may be split across multiple resource sets, forming logical sub-blocks.

If you want to ensure that all entries are selected, even if they haven’t been referenced in the document, then add the optionselection=all. (There are also ways of filtering the selection or you can even have a random selection by shuffling and truncating the list. See thebib2glsuser manual for further details.)

The glossary is displayed using:

\printunsrtglossary

Alternatively all glossaries can be displayed using the iterative command:

\printunsrtglossaries The document is built using:

� pdflatex myDoc

bib2gls myDoc pdflatex myDoc

If letter groups are required, you need the--groupswitch:

� bib2gls --group myDoc

or witharara:

% arara: bib2gls: { group: on }

(37)

(You will also need an appropriate glossary style.)

Unlike Options 2 and 3, this method doesn’t create a file containing the typeset glossary but simply determines which entries are needed for the document, their associated locations and (if required) their associated letter group. This option allows a mixture of sort methods.

For example, sorting by word order for one glossary and order of use for another or even sorting one block of the glossary differently to another block in the same glossary. See bib2glsgallery: sorting.6

This method supports Unicode and uses the Common Locale Data Repository, which pro- vides more extensive language support thanxindy. (Except for Klingon, which is supported byxindy, but not by the CLDR.) The locations in the number list may be in any format. If bib2glscan deduce a numerical value it will attempt to form ranges otherwise it will simply list the locations.

Summary:

1. Useglossaries-extrawith therecordpackage option:

\usepackage[record]{glossaries-extra}

2. Use\GlsXtrLoadResourcesto identify thebibfile(s) andbib2glsoptions. Thebib extension may be omitted:

\GlsXtrLoadResources[src={terms.bib,abbreviations.bib},sort=

en]

3. Put

\printunsrtglossary

where you want your list of entries to appear. Alternatively to display all glossaries use the iterative command:

\printunsrtglossaries

4. Run LATEX on your document.

5. Runbib2glswith just the document base name.

6dickimaw-books.com/gallery/index.php?label=label=bib2gls-sorting

(38)

6. Run LATEX on your document.

Seeglossaries-extraandbib2gls: An Introductory Guide7or thebib2glsuser manual for further details of this method, and also Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.8

1.3.5. Option 5 (“unsrt”)

This option is only available with the extension packageglossaries-extra. No indexing appli- glossaries -extra

cation is required.

Example document:

\documentclass{article}

\usepackage[style=indexgroup]{glossaries-extra}

\newglossaryentry{parrot}{name={parrot},

description={a brightly coloured tropical bird}}

\newglossaryentry{duck}{name={duck}, description={a waterbird}}

\newglossaryentry{puffin}{name={puffin},

description={a seabird with a brightly coloured bill}}

\newglossaryentry{penguin}{name={penguin},

description={a flightless black and white seabird}}

% a symbol:

\newglossaryentry{alpha}{name={\ensuremath{\alpha}}, description={a variable}}

% an abbreviation:

\setabbreviationstyle{short-long}

\newabbreviation{arpanet}{ARPANET}

{Advanced Research Projects Agency Network}

\begin{document}

\Gls{puffin}, \gls{duck} and \gls{parrot}.

\gls{arpanet} and \gls{alpha}.

Next use: \gls{arpanet}.

\printunsrtglossary

\end{document}

You can place all your entry definitions in a separate file and load it in the preamble with

\loadglsentries. There’s no “activation” command (such as \makeglossariesfor Op- tions 2 and 3).

The result is different from the previous examples. Now all entries are listed in the glossary, including “penguin” which hasn’t been referenced in the document, and the list is in the order

7mirrors.ctan.org/support/bib2gls/bib2gls-begin.pdf

8dickimaw-books.com/latex/buildglossaries/

(39)

that the entries were defined. There are no number lists.

� Example 7: Simple document with an unsorted list of all defined entries �

Puffin, duck and parrot. ARPANET (Advanced Research Projects Agency Network) and α. Next use: ARPANET.

Glossary

P

parrot a brightly coloured tropical bird D

duck a waterbird P

puffin a seabird with a brightly coloured bill penguin a flightless black and white seabird A

α a variable

ARPANET Advanced Research Projects Agency Network

Note that the letter groups are fragmented because the list isn’t in alphabetical order, so there are two “P” letter groups.

The\printunsrtglossary command simply iterates over the set of all defined entries associated with the given glossary and lists them in the order of definition. This means that child entries must be defined immediately after their parent entry if they must be kept together in the glossary. Some glossary styles indent entries that have a parent but it’s the indexing application that ensures the child entries are listed immediately after the parent. If you’re opting to use this manual approach then it’s your responsibility to define the entries in the correct order.

Theglossaries-extrapackage requires entries to be defined in the preamble by default. It’s possible to remove this restriction, but bear in mind that any entries defined after\print- unsrtglossarywon’t be listed.

The glossary is displayed using:

\printunsrtglossary

(40)

Alternatively all glossaries can be displayed using the iterative command:

\printunsrtglossaries

This method will displayall defined entries, regardless of whether or not they have been used in the document. Note that this uses the same command for displaying the glossary as Option 4. This is becausebib2glstakes advantage of this method by defining the wanted entries in the required order and setting the locations (and letter group information, if re- quired). See theglossaries-extramanual for further details.

Therefore, the above example document has a glossary containing the entries: parrot, duck, puffin, penguin,α and ARPANET (in that order). Note that the “penguin” entry has been included even though it wasn’t referenced in the document.

This just requires a single LATEX call:

� pdflatex myDoc

unless the glossary needs to appear in the table of contents, in which case a second run is required:

� pdflatex myDoc

pdflatex myDoc

(Naturally if the document also contains citations, and so on, then additional steps are re- quired. Similarly for all the other options above.)

See theglossaries-extradocumentation for further details of this method.

1.3.6. Option 6 (“standalone”)

This option is only available with theglossaries-extraextension package. (You can just use glossaries -extra

the baseglossariespackage for the first case, but it’s less convenient. You’d have to manually insert the entry target before the sectioning command and use \glsentryname{hlabeli} or\Glsentryname{hlabeli} to display the entry name.) Instead of creating a list, this has standalone definitions throughout the document. The entry name may or may not be in a section heading.

You can either define entries in the preamble (or in an external file loaded with\loadgls- entries), as with Option 5, for example:

\documentclass{article}

\usepackage[colorlinks]{hyperref}

(41)

\usepackage[sort=none,

nostyles% <- no glossary styles are required ]{glossaries-extra}

\newglossaryentry{set}{name={set},

description={a collection of any kind of objects}, symbol={\ensuremath{\mathcal{S}}}

}

\newglossaryentry{function}{name={function},

description={a rule that assigns every element in the domain \gls{set} to an element in the range \gls{set}}, symbol={\ensuremath{f(x)}}

}\newcommand*{\termdef}[1]{%

\section{\glsxtrglossentry{#1} \glsentrysymbol{#1}}%

\begin{quote}\em\Glsentrydesc{#1}.\end{quote}%

}\begin{document}

\tableofcontents

\section{Introduction}

Sample document about \glspl{function} and \glspl{set}.

\termdef{set}

More detailed information about \glspl{set} with examples.

\termdef{function}

More detailed information about \glspl{function} with examples.

\end{document}

This allows the references to hyperlink to the standalone definitions rather than to a glossary.

(42)

Example 8: Simple document with standalone entries �

Contents

1 Introduction 1

2 set S 1

3 function f(x) 1

1 Introduction

Sample document about functions and sets.

2 set S

A collection of any kind of objects.

More detailed information about sets with examples.

3 function f (x)

A rule that assigns every element in the domainsetto an element in the range set.

More detailed information about functionswith examples.

Or you can usebib2glsif you want to manage a large database of terms. For example:

\documentclass{article}

\usepackage[colorlinks]{hyperref}

\usepackage[record,

nostyles% <- no glossary styles are required ]{glossaries-extra}

\GlsXtrLoadResources[src={terms},sort=none,save-locations=false]

\newcommand*{\termdef}[1]{%

(43)

\section{\glsxtrglossentry{#1} \glossentrysymbol{#1}}%

\glsadd{#1}% <- index this entry

\begin{quote}\em\Glsentrydesc{#1}.\end{quote}%

}\begin{document}

\tableofcontents

\section{Introduction}

Sample document about \glspl{function} and \glspl{set}.

\termdef{set}

More detailed information about \glspl{set} with examples.

\termdef{function}

More detailed information about \glspl{function} with examples.

\end{document}

Where the fileterms.bibcontains:

@entry{set, name={set},

description={a collection of any kind of objects}, symbol={\ensuremath{\mathcal{S}}}

}@entry{function, name={function},

description={a rule that assigns every element in the domain

\gls{set} to an element in the range \gls{set}}, symbol={\ensuremath{f(x)}}

}

The advantage in this approach (with\loadglsentriesorbib2gls) is that you can use an existing database of entries shared across multiple documents, ensuring consistent notation for all of them.

In both cases, there’s no need to load all the glossary styles packages, as they’re not re- quired, so I’ve used thenostylespackage option to prevent them from being loaded.

In the first case, you just need to define the terms (preferably in the preamble or in a file that’s input in the preamble). No external tool is required. Just run LATEX as normal. (Twice to ensure that the table of contents is up to date.)

References

Related documents

A blank page is provided at the back of the test, in case you need extra

A blank page is provided at the back of the test, in case you need extra

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 – 12 in the

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 – 8 in the

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 – 8 in the

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 – 11 in the

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 –11 in the

If you need more room for any answer, use the extra space provided at the back of this booklet and clearly number the question.. Check that this booklet has pages 2 –12 in the

¥ Write the Course, Elective Name, and Question Number on the cover of each Elective Answer Book.. ¥ You may ask for extra Elective Answer Books if you

As a mode of teaching and learning delivery, the online writing skills quiz can be said to have accomplished the modest goal we set out to achieve: a means to identify

If the option foot was passed to the package, you may consider numbering authors’ names so that you can use numbered footnotes for the affiliations. \author{author one$^1$ and

You must remain inside an allocated room at the quarantine centre for a period of 14 days commencing from the date and time that you enter Western Australia (unless otherwise

Note that, if the colophon is not clearing any pages, it will not set the colophon page style, so \colophonpagestyle and the pagestyle package option will do nothing.. Note also

If you want to restore the old behavior, set this option to old, but note that then you can neither change the amounts for a given number of persons nor change the unit of \cutext

MR PLAISIER: If you were aware that time of the farm sites, which we didn‟t know, did you know that we have a, in partnership with the Queen Elizabeth

If you load a package that changes the \catcode of a character in this list, such as a language package that makes one of them active, and you want the extra kerning to be added

The package fcolumn provides the macros for an extra tabular specifier that makes creating financial tables easy. The column specifier f itself is rather simple; it is the

Optionally, if you have a long caption you can tell the package how many extra lines of text that should be allowed for on the page as well.... Then, just include the graphic using

The optional argument is the entry label in case it’s required, but the wrglossary counter is globally used by all

This command is used in the definition of \glsxtrshort and in some of the predefined abbreviation styles to format the short value of the entry identified by hentry-labeli with

When converting a document that currently uses the obsolete glossary package to the re- placement glossaries package, it should be fairly obvious that the first thing you need to do

If you want your handout be organized with the same sectioning commands as your main paper, you can use the option sectioning when loading the package.. See

You can remove a contact from a contact group (such as frequent contacts), and you can also remove a contact from the contact list, which will remove the contact from all groups