Note that glossaries-extra provides an extra indexing option (bib2gls) which isn’t available with just the base glossaries package.
If you require multilingual support you must also install
the relevant language module. Each language module is called
glossaries-, where is the
root language name. For example, glossaries-french
or glossaries-german. If a language module is required,
the glossaries package 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
the nolangwarn package option to suppress the warning
and provide your own translations. (For example, use
the title key in \printglossary
.)
😱 If you’re freaking out at the size of this manual, start with “The glossaries package: a guide for beginners”. You should find it in the same directory as this document or try
texdoc glossariesbeginOnce you’ve got to grips with the basics, then come back to this manual to find out how to adjust the settings.
The glossaries bundle includes the following documentation:
- The glossaries package: a guide for beginners
- 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 manual for the glossaries package and is divided into two parts: Part I is the user guide that describes all available commands and options with examples. Part II has alphabetical summaries of those commands and options for quick reference.
- Documented Code for glossaries (glossaries-code.pdf)
- Advanced users wishing to know more about the inner workings of all the packages provided in the glossaries bundle should read “Documented Code for glossaries v4.55”.
- 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? or (for Linux users) Updating TeX on Linux.
- •glossaries-extra and bib2gls: An Introductory Guide.
- •glossaries FAQ
- •glossaries gallery
- •a summary of all glossary styles provided by glossaries and
glossaries-extra
- •glossaries
performance (comparing document build times for the different
options provided by glossaries and glossaries-extra).
- •Using LaTeX to Write a PhD Thesis
(chapter 6).
- •Incorporating
makeglossaries or makeglossaries-lite or
bib2gls into the document build
- •The glossaries-extra package
- •bib2gls
List of Tables[link]
List of Examples[link]
If an example shows the icon 📥🖹 then you can click on that icon to try downloading the example source code from a location relative to this document. You can also try using:
texdoc -l glossaries-user-examplewhere is the example number zero-padded to three digits to find out if the example files are installed on your device.
1. Introduction[link]
The glossaries package 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).
Example 1 demonstrates a basic document without a glossary. For simplicity, the article class is used and the only package loaded is glossaries. Note that the terms must be defined before they can be referenced in the document:
(This is a trivial example. For a real document I recommend you use siunitx for units.)\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 {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}
The glossaries-extra package, which is distributed as a separate bundle, extends the capabilities of the glossaries package. The simplest document with a glossary can be created with glossaries-extra (which internally loads the glossaries package). Example 2 demonstrates this:
\documentclass
{article}\usepackage
[ sort=none,% no sorting or indexing required abbreviations,% create list of abbreviations symbols,% create list of symbols postdot, % append a full stop after the descriptions stylemods,style=index % set the 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}
Note the difference in the way the abbreviation (HTML) and symbol (π) are defined in the two above examples. The abbreviations, postdot and stylemods options are specific to glossaries-extra. Other options are passed to the base glossaries package.
\newabbreviation
and stylemods, are only available with
the glossaries-extra package. There are also some commands and options (such
as \makeglossaries
and symbols) that are provided by the
base glossaries package but are redefined by the
glossaries-extra package. See the glossaries-extra user
manual for further details of those commands.
One of the strengths of the glossaries 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.
This user manual uses the glossaries-extra package with bib2gls (Option 4). For example, when viewing the PDF version of this document in a hyperlinked-enabled PDF viewer (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 that the glossaries mechanism works. An indexing application (bib2gls in this case) is used to generate the sorted list of terms. The indexing applications are CLI 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 as arara to 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 the 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 the glossaries package 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 the glossaries package. They are described in §18.
1.1. Rollback[link]
The following rollback releases are available:
- •Version 4.54 (2024-04-03):
This version is the last version that doesn’t test for the newer datatool-base commands that may now be used to sort glossaries with\usepackage
{glossaries}[=v4.54]\printnoidxglossary
. It will always use the older, slower method. - •Version 4.52 (2022-11-03):
This is the last version that uses an internal comma-separated list for the hyper group information in glossary-hypernav. Version 4.53 has switched to using a sequence.\usepackage
{glossaries}[=v4.52] - •Version 4.49 (2021-11-01):
Note that this should also rollback mfirstuc to version 2.07 if you have a later version installed.\usepackage
{glossaries}[=v4.49] - •Version 4.46 (2020-03-19):
\usepackage
{glossaries}[=v4.46]
If you rollback using latexrelease to an earlier date, then you will need to specify v4.46 for glossaries as 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.2. Integrating Other Packages and Known Issues[link]
If you use hyperref and glossaries, you must load hyperref first (although, in general, hyperref should be loaded after other packages).
Occasionally you may find that certain packages need to be loaded after packages that are required by glossaries but need to also be loaded before glossaries. For example, a package might need to be loaded after amsgen but before hyperref (which needs to be loaded before glossaries). In which case, load the required package first (for example, amsgen), then , and finally load glossaries.
\usepackage
{amsgen}% load before\usepackage
{ }% must be loaded after amsgen\usepackage
{hyperref}% load after\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 the description environment, such as the list style. Since this is the default style, the glossaries package checks for classicthesis and will change the default to the index style if it has been loaded.
Some packages conflict with a package that’s required by a glossary style style package. 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 the nosuper option and (with glossaries-extra) don’t use stylemods=super or stylemods=all. The glossaries package now (v4.50+) checks for xtab and will automatically implement nosuper if it has been loaded.
The language-support is implemented using tracklang. See §1.5 for further details.
1.3. Indexing Options[link]
The basic idea behind the glossaries package is that you first
define your entries (terms, symbols 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 base
glossaries package (Options 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. Option 6 is omitted from the table as it doesn’t produce a list. For a more detailed comparison of the various methods, see the glossaries performance page. If, for some reason, you want to know what indexing option is in effect, you can test the expansion of:
The definition is initialised to:If the sort=none or sort=clear options are used,\ifglsxindy
xindy\else
makeindex\fi
\glsindexingsetting
will be redefined to none
.
If \makeglossaries
is used \glsindexingsetting
will be
updated to either makeindex
or xindy
as appropriate
(that is, the conditional will no longer be part of the definition).
If \makenoidxglossaries
is used then \glsindexingsetting
will
be updated to noidx
. This means that \glsindexingsetting
can’t be fully relied on until the start of the document
environment. (If you are using glossaries-extra
v1.49+, then this command will also be updated to take the
record setting into account.)
\makeglossaries
into 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 package
that has done this, pass the disablemakegloss option to
glossaries. For example, via the document class options.)
Strictly speaking, Options 5 and 6 aren’t actually indexing options as no indexing is performed. 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 appropriate points in the document. These two options are included here for completeness and for comparison with the actual indexing options.
Option | 1 | 2 | 3 | 4 | 5 |
---|---|---|---|---|---|
Requires glossaries-extra? | ✖ | ✖ | ✖ | ✔ | ✔ |
Requires an external application? | ✖ | ✔ | ✔ | ✔ | ✖ |
Requires Perl? | ✖ | ✖ | ✔ | ✖ | ✖ |
Requires Java? | ✖ | ✖ | ✖ | ✔ | ✖ |
Designed for glossaries[-extra]? | ✔ | ✖‡ | ✖‡ | ✔ | ✔ |
Can sort extended Latin alphabets or non-Latin alphabets? | ✖∗ | ✖ | ✔ | ✔ | N/A |
Efficient sort algorithm? | ✖ | ✔ | ✔ | ✔ | N/A |
Can use a different sort method for each glossary? | ✔ | ✖† | ✖† | ✔ | N/A |
Any problematic sort values? | ✔ | ✔ | ✔ | ✖ | N/A |
Are entries with identical sort values treated as separate unique entries? | ✔ | ✔ | ✖§ | ✔ | ✔ |
Can automatically form ranges in the location lists? | ✖ | ✔ | ✔ | ✔ | ✖ |
Can have non-standard locations in the location lists? | ✔ | ✖ | ✔⧫ | ✔ | ✔¶ |
Maximum hierarchical depth (style-dependent) | ∞# | 3 | ∞ | ∞ | ∞ |
\glsdisplaynumberlist reliable? |
✔ | ✖ | ✖ | ✔ | ✖ |
\newglossaryentry allowed in document environment?
(Not recommended.) |
✖ | ✔ | ✔ | ✖※ | ✔⁑ |
Requires additional write registers? | ✖ | ✔ | ✔ | ✖ | ✖★ |
Default value of sanitizesort package option | false | true | true | true✾ | true✾ |
1.3.1. Option 1 (“noidx”)[link]
This option isn’t generally recommended as it’s slow, doesn’t automatically provide localisation support, and can’t form location ranges. It’s best used with sort=use (order of use) or sort=def (order of definition) with no location lists. For alphabetical sorting, ensure you have at least version 3.0 of datatool and, where available, datatool localisation support. If an older version is detected, a slower, less efficient sort method will be used.
Example 3 demonstrates this method:
You can place all your entry definitions in a separate file and load it in the document preamble with\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}
\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.
This uses the indexgroup style, 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.
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 alphabetic sorting and old versions of datatool, it’s very slow with severe limitations, particularly if the sort value contains extended Latin characters or non-Latin characters. However, if you have both datatool v3.0+ and datatool-english installed, and at least glossaries v4.55, then make sure you specify the locale. For example:
Or:\usepackage
[locales=en]{datatool-base}\usepackage
{glossaries}
\usepackage
[locales=en]{glossaries}
Other languages will need to have the appropriate datatool
localisation support provided. Examples are provided in the
datatool manual. In general, it’s best to use
xindy or bib2gls if you need to sort terms that use an
extended Latin alphabet or non-Latin alphabet.
If you have any commands that cause problems when
expanding, such as \alpha
, then you must use
sanitizesort=true or change the sort method
(sort=use or sort=def) in the package options
or explicitly set the sort key when you define the
relevant entries, as shown in the above example which has:
\newglossaryentry
{alpha}{name={\ensuremath
{\alpha
}}, sort={alpha},description={a variable} }
\glsxtrnewsymbol
, which automatically sets the
sort key to the entry label (instead of the name).
This option works best with the sort=def or sort=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 can be problematic with 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
to your preamble (before you start defining your entries, as described in §4).\makenoidxglossaries
- 2.Put
where you want your list of entries to appear (described in §8). Alternatively, to display all glossaries use the iterative command:\printnoidxglossary
\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.
1.3.2. Option 2 (makeindex)[link]
You can place all your entry definitions in a separate file and load it in the preamble with\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}
\loadglsentries
(after
\makeglossaries
). The result is the same as for
Example 3.
This option uses a CLI application called makeindex to 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
with UTF-8 characters, especially for any sort values that start
with a UTF-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 which makeindex
reads. Then makeindex writes a new file containing the code
to typeset the glossary. Then \printglossary
reads this file in
on the next run.
\makeglossaries
) 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 the ist file or find some way to
convert the ist file into an equivalent set of instructions.
This option works best if you want to sort entries according to the Basic Latin 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 the automake=immediate or automake=true package option provided the shell escape hasn’t been completely disabled.
This method can form ranges in the number list but only
accepts limited number formats: \arabic
, \roman
,
\Roman
, \alph
and \Alph
.
This option does not allow a mixture of sort methods. All glossaries must be sorted according 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 call makeindex for each glossary type.
Summary:
- 1.If you want to use makeindex’s -g option
you must change the quote character using
\GlsSetQuote
. For example:
This must be used before\GlsSetQuote
{+}\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
to your preamble (before you start defining your entries, as described in §4).\makeglossaries
- 3.Put
where you want your list of entries to appear (described in §8). Alternatively, to display all glossaries use the iterative command:\printglossary
\printglossaries
- 4.Run LaTeX on your document. This creates files with the
extensions glo and ist (for example, if your
LaTeX document is called myDoc.tex, then you’ll have
two extra files called myDoc.glo and 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 use
glossaries-extra you’ll see the section heading and some
boilerplate text.)
If you have used package options such as symbols there will also be other sets of files corresponding to the extra glossaries that were created by those options.
- 5. Run makeindex with the glo file as the
input file and the ist file as the style so that
it creates an output file with the extension gls:
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. makeindex must 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 build for some examples.
Alternatively, run makeindex indirectly via the makeglossaries script:
makeglossaries myDoc
Note that the file extension isn’t supplied in this case. (Replace makeglossaries with makeglossaries-lite if you don’t have Perl installed.) This will pick up all the file extensions from the aux file and run makeindex the appropriate number of times with all the necessary switches.The simplest approach is to use arara and add the following comment lines to the start of your document:
% arara: pdflatex % arara: makeglossaries % arara: pdflatex
(Replacemakeglossaries
withmakeglossarieslite
in 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 ordering you need to add the -l switch:
makeindex -l -s myDoc.ist -o myDoc.gls myDoc.glo
(See §1.6.4 for further details on using makeindex explicitly.) If you use makeglossaries or makeglossaries-lite then use the order=letter package option and the -l option will be added automatically. - 6. Once you have successfully completed the previous step, you can now run LaTeX on your document again.
1.3.3. Option 3 (xindy)[link]
You can place all your entry definitions in a separate file and load it in the preamble with\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}
\Gls
{puffin},\gls
{duck} and\gls
{parrot}.\gls
{arpanet} and\gls
{alpha}. Next use:\gls
{arpanet}.\printglossary
\end{document}
\loadglsentries
(after
\makeglossaries
). The result is the same as for
Example 3 and Example 4.
This option uses a CLI application called xindy to sort the entries. This application is more flexible than makeindex and is able to sort extended Latin alphabets or non-Latin alphabets, however it does still have some limitations. (See Example 9 for an example with UTF-8 characters.)
The xindy application comes with both TeX Live and
MikTeX, but since xindy is 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 \printglossary
reads this file in on the next run.
This is the best option with just the base glossaries package 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 you must make sure that each entry has a unique sort value;
- •xindy forbids 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 which xindy forbids.
\newglossaryentry
{alpha}{name={\ensuremath
{\alpha
}}, sort={alpha},description={a variable} }
\glsxtrnewsymbol
, which automatically sets the
sort key to the entry label (instead of the name).
All glossaries must be sorted according to the same method (word/letter ordering, order of use, or order of definition).
Summary:
- 1.Add the xindy option to the glossaries
package option list:
If you are using a non-Latin script you’ll also need to either switch off the creation of the number group:\usepackage
[xindy]{glossaries}
or use either\usepackage
[xindy={glsnumbers=false}]{glossaries}
(to indicate the first letter group to follow the digits) or\GlsSetXdyFirstLetterAfterDigits
{ }
to indicate where the number group should be placed (see §14).\GlsSetXdyNumberGroupOrder
{ } - 2.Add
\makeglossaries
to your preamble (before you start defining your entries, as described in §4). - 3.Run LaTeX on your document. This creates files with the
extensions glo and xdy (for example, if your
LaTeX document is called myDoc.tex, then you’ll have
two extra files called myDoc.glo and 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 the
glossaries-extra extension package, you’ll see the section
header and some boilerplate text.)
If you have used package options such as symbols there will also be other sets of files corresponding to the extra glossaries that were created by those options.
- 4.Run xindy with the glo file as the
input file and the xdy file as a module so that
it creates an output file with the extension gls. 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 replaceenglish
with 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. xindy must be called for each set of files.It’s much simpler to use makeglossaries instead:
makeglossaries myDoc
Note that the file extension isn’t supplied in this case. This will pick up all the file extensions from the aux file and run xindy the appropriate number of times with all the necessary switches.There’s no benefit in using makeglossaries-lite with xindy. (Remember that xindy is a Perl script so if you can use xindy then you can also use makeglossaries, and if you don’t want to use makeglossaries because you don’t want to install Perl, then you can’t use xindy either.) If you don’t know how to use the command prompt, then you can probably access xindy or makeglossaries 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 build for some examples.
Again, a convenient method is to use arara and 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 ordering you need to add the order=letter package option:
(and return to the previous step). This option is picked up by makeglossaries. If you are explicitly using xindy then you’ll need to add\usepackage
[xindy,order=letter]{glossaries}-M ord/letorder
to the options list. See §1.6.3 for further details on using xindy explicitly. - 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)[link]
This option is only available with the glossaries-extra extension package. This method uses bib2gls to both fetch entry definitions from bib files and to hierarchically sort and collate. The bib2gls application is designed specifically for, and developed alongside, the glossaries-extra package.
Example 6 demonstrates a simple document that requires bib2gls:
Note that the abbreviation style must be set before\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}
\GlsXtrLoadResources
.
The file sample-entries.bib contains:
The result is slightly different from the previous examples. Letter groups aren’t created by default with bib2gls so, even though the glossary style supports letter groups, there’s no group information. This can be added by invoking bib2gls with the --group switch.@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} }
All entries must be provided in one or more bib files.
(See the bib2gls user 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 @symbol
and the abbreviation
“ARPANET” is defined using @abbreviation
.
See Example 10 for an example with UTF-8
content.
@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 the sort key. See
bib2gls gallery: sorting for examples.
The glossaries-extra package needs to be loaded with the record package option:
\usepackage
[record]{glossaries-extra}
or (equivalently)
\usepackage
[record=only]{glossaries-extra}
or (with glossaries-extra v1.37+ and bib2gls v1.8+):
\usepackage
[record=nameref]{glossaries-extra}
The record=nameref option is the best method if you are
using hyperref.
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
]
The bib files are identified as a comma-separated list in the
value of the src key. The sort 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 option selection=all. (There are also ways of filtering the selection or you can even have a random selection by shuffling and truncating the list. See the bib2gls user 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 myDocIf letter groups are required, you need the --group switch:
bib2gls --group myDocor with arara:
% arara: bib2gls: { group: on }(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 bib2gls gallery: sorting.
This method supports Unicode and uses the CLDR, which provides more extensive language support than xindy. (Except for Klingon, which is supported by xindy, but not by the CLDR.) The locations in the number list may be in any format. If bib2gls can deduce a numerical value it will attempt to form ranges otherwise it will simply list the locations.
Summary:
- 1.Use glossaries-extra with the record package
option:
\usepackage
[record]{glossaries-extra} - 2.Use
\GlsXtrLoadResources
to identify the bib file(s) and bib2gls options. The bib extension may be omitted:\GlsXtrLoadResources
[src={terms.bib,abbreviations.bib},sort=en] - 3.Put
where you want your list of entries to appear. Alternatively to display all glossaries use the iterative command:\printunsrtglossary
\printunsrtglossaries
- 4.Run LaTeX on your document.
- 5.Run bib2gls with just the document base name.
- 6.Run LaTeX on your document.
See glossaries-extra and bib2gls: An Introductory Guide or the bib2gls user manual for further details of this method, and also Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.
1.3.5. Option 5 (“unsrt”)[link]
This option is only available with the extension package glossaries-extra. No indexing application is required.
Example 7 demonstrates this method:
You can place all your entry definitions in a separate file and load it in the preamble with\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}
\loadglsentries
.
There’s no “activation” command (such as \makeglossaries
for
Options 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 that the entries were defined. There are no number lists.
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.
The glossaries-extra package 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 \printunsrtglossary
won’t be listed.
The glossary is displayed using:
\printunsrtglossary
Alternatively all glossaries can be displayed using the iterative
command:
\printunsrtglossaries
This method will display all 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 because bib2gls takes advantage of this method by defining the wanted entries in the required order and setting the locations (and letter group information, if required). See the glossaries-extra manual 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 myDocunless 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 required. Similarly for all the other options above.)
See the glossaries-extra documentation for further details of this method.
1.3.6. Option 6 (“standalone”)[link]
This option is only available with the glossaries-extra extension package. (You can just use the base glossaries package 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
{ }
or
\Glsentryname
{ }
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 \loadglsentries
), as with
Option 5, or use bib2gls if you want to manage a large
database of terms.
Example 8 demonstrates standalone definitions without bib2gls:
This allows the references to hyperlink to the standalone definitions rather than to a glossary.\documentclass
{article}\usepackage
[colorlinks]{hyperref}\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}
The above example can be modified to use bib2gls if the terms are defined in one or more bib files:
Where the file terms.bib contains:\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]{%\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}
The advantage in this approach (with@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)}} }
\loadglsentries
or
bib2gls) 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 required, so I’ve used the nostyles package 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.)
pdflatex myDoc pdflatex myDoc
In the second case, you need the record package option (as in Option 4) since bib2gls is needed to select the required entries, but you don’t need a sorted list:
\GlsXtrLoadResources
[src={terms},sort=none]
This will ensure that any entries indexed in the document (through
commands like \gls
or \glsadd
) will be selected by
bib2gls, but it will skip the sorting step.
(The chances are you probably also won’t need location lists either.
If so, you can add the option save-locations=false.)
Remember that for this second case you need to run bib2gls as per Option 4:
pdflatex myDoc bib2gls myDoc pdflatex myDoc pdflatex myDoc
For both cases (with or without bib2gls), instead of listing
all the entries using \printunsrtglossary
, you use
where you want the name (and
anchor with hyperref) to appear in the document. This will
allow the link text created by commands like \glsxtrglossentry
{ }\gls
to link
to that point in the document. The description can simply be
displayed with
or
\glsentrydesc
{ }
, as in the above examples. In both
examples, I’ve defined a custom command \Glsentrydesc
{label}\termdef
to simplify the
code and ensure consistency. Extra styling, such as placing the
description in a coloured frame, can be added to this custom
definition as required.
(Instead of using \glsentrydesc
or \Glsentrydesc
, you can use
, which will obey
category attributes such as
glossdesc and glossdescfont. See the glossaries-extra
manual for further details.)
\glossentrydesc
{ }
The symbol (if required) can be displayed with either
or
\glsentrysymbol
{ }
.
In the first example, I’ve used \glossentrysymbol
{ }\glsentrysymbol
. In the
second I’ve used \glossentrysymbol
. The latter is
necessary with bib2gls if the symbol needs to go in a
section title as the entries aren’t defined on the first LaTeX run.
In normal document text, \glsentrysymbol
will silently do nothing
if the entry hasn’t been defined, but when used in a section heading
it will expand to an undefined internal command when written to the
aux file, which triggers an error.
The \glossentrysymbol
command performs an existence check,
which triggers a warning if the entry is undefined. (All entries
will be undefined before the first bib2gls call.) You need at
least glossaries-extra v1.42 to use this command in a section
title. (\glossentrysymbol
is defined by the base
glossaries package but is redefined by
glossaries-extra.) If hyperref has been loaded, this
will use \texorpdfstring
to allow a simple expansion for the
PDF bookmarks (see the glossaries-extra user manual for
further details).
If you want to test if the symbol field has been set, you
need to use \ifglshassymbol
outside of the section title. For
example:
\ifglshassymbol
{#1}% {\section
{\glsxtrglossentry
{#1}\glossentrysymbol
{#1}}} {\section
{\glsxtrglossentry
{#1}}}
In both of the above examples, the section titles start with a lowercase character (because the name value is all lowercase in entry definitions). You can apply automatic case change with the glossname category attribute. For example:
\glssetcategoryattribute
{general}{glossname}{firstuc}
or (for title-case)
\glssetcategoryattribute
{general}{glossname}{title}
However, this won’t apply the case change in the table of contents
or bookmarks. Instead you can use helper commands provided by
glossaries-extra v1.49+ but make sure you have up-to-date
versions of glossaries and mfirstuc.
In the second example, you can instead use bib2gls to apply a case change. For example, to apply sentence case to the name field:
\GlsXtrLoadResources
[src={terms},
sort=none,save-locations=false,
replicate-fields={name=text},
name-case-change=firstuc
]
(Or name-case-change=title for title case.)
This copies the name value to the text field and
then applies a case change to the name field (leaving the
text field unchanged). The name in the section titles now
starts with a capital but the link text produced by commands like
\gls
is still lowercase.
In the first example (without bib2gls) you can do this manually. For example:
A more automated solution can be obtained with the standalone helper commands for the PDF bookmark and heading text (glossaries-extra v1.49+).\newglossaryentry
{set}{name={Set},text={set}, description={a collection of any kind of objects}, symbol={\ensuremath
{\mathcal
{S}}} }
Note that if you use the default save-locations=true with bib2gls, it’s possible to combine Options 4 and 6 to have both standalone definitions and an index. In this case, a glossary style is required. In the example below, I’ve use bookindex, which is provided in the glossary-bookindex package (bundled with glossaries-extra). I don’t need any of the other style packages, so I can still keep the nostyles option and just load glossary-bookindex:
\usepackage
[record=nameref,% <- using bib2gls
nostyles,% <- don't load default style packages
stylemods=bookindex,% <- load glossary-bookindex.sty
style=bookindex% <- set the default style to 'bookindex'
]{glossaries-extra}
I also need to sort the entries, so the resource command is now:
\GlsXtrLoadResources
[src={terms},% definitions in terms.bib
sort=en-GB,% sort by this locale
replicate-fields={name=text},
name-case-change=firstuc
]
At the end of the document, I can add the glossary:
\printunsrtglossary
[title=Index,target=false]
Note that I’ve had to switch off the hypertargets with
target=false (otherwise there would be duplicate
targets). If you want letter group headings you need to use the
--group switch:
bib2gls --group myDocor if you are using arara:
% arara: bib2gls: { group: on }
The bookindex style doesn’t show the description, so only the name and location is displayed. Remember that the name has had a case change so it now starts with an initial capital. If you feel this is inappropriate for the index, you can adjust the bookindex style so that it uses the text field instead. For example:
See the glossaries-extra user manual for further details about this style.\renewcommand
*{\glsxtrbookindexname
}[1]{%\glossentrynameother
{#1}{text}}
Note that on the first LaTeX run none of the entries will be defined. Once they are defined, the page numbers may shift due to the increased amount of document text. You may therefore need to repeat the document build to ensure the page numbers are correct.
If there are extra terms that need to be included in the index that
don’t have a description, you can define them with @index
in the bib file. For example:
They can be used in the document as usual:@index
{element}@index
{member,alias={element}}
The objects that make up a set are theSee glossaries-extra and bib2gls: An Introductory Guide or the bib2gls user manual for further details.\glspl
{element} or\glspl
{member}.
1.4. Dummy Entries for Testing[link]
In addition to the sample files described in §18, glossaries
also provides some files containing lorum ipsum dummy entries. These
are provided for testing purposes and are on TeX’s path (in
tex/latex/glossaries/test-entries) so
they can be included via \input
or \loadglsentries
. The
glossaries-extra package provides bib versions of
all these files for use with bib2gls. The files are as
follows:
These entries all have brief descriptions. For example:
\newglossaryentry
{lorem}{name={lorem},description={ipsum}}
This file is based on example-glossaries-brief.tex but random characters have been converted to accented characters to test UTF-8 support.
These entries all have long descriptions. For example:
\newglossaryentry
{loremipsum}{name={lorem ipsum},
description={dolor sit amet, consectetuer adipiscing
elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida
mauris.}}
These entries all have multi-paragraph descriptions. For example:
\longnewglossaryentry
{loremi-ii}{name={lorem 1--2}}%
{%
Lorem ipsum ...
Nam dui ligula...
}
These entries all use the symbol key. For example:
\newglossaryentry
{alpha}{name={alpha}, symbol={\ensuremath
{\alpha
}}, description={Quisque ullamcorper placerat ipsum.}}
Similar to the previous file but the symbol key isn’t used. Instead the symbol is stored in the name key. For example:
\newglossaryentry
{sym.alpha}{sort={alpha}, name={\ensuremath
{\alpha
}}, description={Quisque ullamcorper placerat ipsum.}}
The top level (level 0) entries have the symbol key and all user1, …, user6 keys set. For example:
There are also some level 1 entries, which may or may not have the symbol and user keys set. For example:\newglossaryentry
{sample-a} {name={a name}, description={a description}, symbol={\ensuremath
{\alpha
}}, user1={A}, user2={1}, user3={i}, user4={A-i}, user5={25.2020788573521}, user6={1585-11-06}}
There are no deeper hierarchical entries. Where set, the user1 key is an uppercase letter (A–Z), the user2 key is an integer, the user3 key is a lowercase Roman numeral, the user4 key is in the form - where is either an upper or lowercase letter (a–z or A–Z) and is either an upper or lowercase Roman numeral. The user5 key is a random number (in the range (−50,+50) for top level (level 0) entries and (−1,+1) for child entries). The user6 key is a random date between 1000-01-01 and 2099-12-31.\newglossaryentry
{sample-b-0} {parent={sample-b}, name={b/0 name}, description={child 0 of b}, symbol={\ensuremath
{\sigma
}}, user2={0}, user4={a-i}}
These entries use the user1 key to store the name of an image file. (The images are provided by the mwe package and should be on TeX’s path.) One entry doesn’t have an associated image to help test for a missing key. The descriptions are long to allow for tests with the text wrapping around the image. For example:
\longnewglossaryentry
{sedfeugiat}{name={sed feugiat},
user1={example-image}}%
{%
Cum sociis natoque...
Etiam...
}
These entries are all acronyms. For example:
\newacronym
[type={\glsdefaulttype
}]{lid}{LID}{lorem ipsum dolor}
\newacronym
is redefined to use \newabbreviation
with the category key set to acronym (rather
than the default abbreviation). This means that you need to
set the abbreviation style for the acronym category. For
example:
\setabbreviationstyle
[acronym]{long-short}
This file contains entries that are all acronyms that use the description key. For example:
\newacronym
[type={\glsdefaulttype
}, description={fringilla a, euismod sodales, sollicitudin vel, wisi}]{ndl}{NDL}{nam dui ligula}
\newacronym
is redefined to use \newabbreviation
with the category key set to acronym (rather
than the default abbreviation). This means that you need to
set the abbreviation style for the acronym category. For
example:
\setabbreviationstyle
[acronym]{long-short-desc}
These entries are all acronyms, where some of them have a translation supplied in the user1 key. For example:
\newacronym
[type={\glsdefaulttype
},user1={love itself}] {li}{LI}{lorem ipsum}
\newacronym
is redefined to use \newabbreviation
with the category key set to acronym (rather
than the default abbreviation). This means that you need to
set the abbreviation style for the acronym category. For
example:
\setabbreviationstyle
[acronym]{long-short-user}
These are hierarchical entries where the child entries use the name key. For example:
\newglossaryentry
{sedmattis}{name={sed mattis}, description={erat sit amet}}\newglossaryentry
{gravida}{parent={sedmattis}, name={gravida},description={malesuada}}
These are hierarchical entries where the child entries don’t use the name key. For example:
\newglossaryentry
{scelerisque}{name={scelerisque}, description={at}}\newglossaryentry
{vestibulum}{parent={scelerisque}, description={eu, nulla}}
These entries all have long descriptions and there are some child entries. For example:
\newglossaryentry
{longsedmattis}{name={sed mattis}, description={erat sit amet dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.}}\newglossaryentry
{longgravida}{parent={longsedmattis},name={gravida}, description={malesuada libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo.}}
This consists of parent entries with single paragraph descriptions and child entries with multi-paragraph descriptions. Some entries have the user1 key set to the name of an image file provided by the mwe package. For example:
\newglossaryentry
{hiersedmattis}{name={sed mattis},user1={example-image}, description={Erat sit amet dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Ut pellentesque augue sed urna. Vestibulum diam eros, fringilla et, consectetuer eu, nonummy id, sapien. Nullam at lectus. In sagittis ultrices mauris. Curabitur malesuada erat sit amet massa. Fusce blandit. Aliquam erat volutpat.}}\longnewglossaryentry
{hierloremi-ii} {name={lorem 1--2},parent={hiersedmattis}}% {% Lorem ipsum ... Nam dui ligula... }
These entries use the user1 key to store a citation key (or comma-separated list of citation keys). The citations are defined in xampl.bib, which should be available on all modern TeX distributions. One entry doesn’t have an associated citation to help test for a missing key. For example:
\newglossaryentry
{fusce}{name={fusce},
description={suscipit cursus sem},user1={article-minimal}}
These entries use the user1 key to store an URL associated with the entry. For example:
\newglossaryentry
{aenean-url}{name={aenean},
description={adipiscing auctor est},
user1={http://uk.tug.org/}}
The sample file glossary-lipsum-examples.tex in the doc/latex/glossaries/samples directory uses all these files. See also glossaries gallery.
The glossaries-extra package provides the additional test file: These entries use the see key provided by the base glossaries package and also the alias and seealso keys that require glossaries-extra. For example:
\newglossaryentry
{alias-lorem}{name={alias-lorem}, description={ipsum},alias={lorem}}\newglossaryentry
{amet}{name={amet},description={consectetuer}, see={dolor}}\newglossaryentry
{arcu}name={arcu},description={libero}, seealso={placerat,vitae,curabitur}
1.5. Multi-Lingual Support[link]
\babelprovide
. In the event that
tracklang can’t detect the language, use the languages
or locales package option.
See §1.2 and also
Localisation
with tracklang.tex for further details.
For example (using babel):
This can pick up the language setting but will also automatically load translator. Compare this with:\documentclass
{article}\usepackage
[german]{babel}\usepackage
{glossaries}
This will pick up the language setting but won’t automatically load translator.\documentclass
{article}\usepackage
[german]{babel}\usepackage
{glossaries-extra}
In both the above cases, tracklang will automatically be loaded and the language-sensitive commands provided by glossaries will use the definitions in glossaries-german.ldf (which needs to be installed separately).
In the event that tracklang can’t pick up the required languages, it’s also possible to identify them with the languages or locales option. For example:
\usepackage
[nil]{babel}\babelprovide
{french}\usepackage
[languages={french}]{glossaries}
Another example (no language package):
The above document doesn’t load babel or polyglossia or translator, but the translate=true setting will ensure that tracklang is loaded, which will pick up the document class option.\documentclass
[german]{article}\usepackage
[translate=true]{glossaries}
Alternatively, using the locales package option:
\usepackage
[locales={de-DE,en-GB}]{glossaries}
This will required both glossaries-german.ldf and
glossaries-english.ldf to be installed.
Note that the locales option is a synonym of the
languages option, but semantically locales makes more
sense when using language identifiers that include regions.
Note that if another package has already been loaded that uses tracklang, then the list of supported locales will be picked up from that package. For example:
\usepackage
[de-DE,en-GB]{datetime2}\usepackage
{glossaries}
The best method to sort terms that use an extended Latin alphabet or non-Latin alphabet is with glossaries-extra and bib2gls. This means using a bib file to store the entry data (see Option 4). If you prefer to only use the base glossaries package, then xindy (Option 3) is the best option, but be aware that xindy is a general purpose indexing application that’s developed independently of glossaries (as opposed to bib2gls, which is specifically designed for, and developed alongside, glossaries-extra and therefore provides better integration).
Note also that bib2gls can support any language provided by the CLDR, whereas xindy only has a limited number of built-in languages (although more can be added).
\GlsSetXdyFirstLetterAfterDigits
to indicate the first
letter group that should follow the number group.
Example 9 demonstrates a document with UTF-8 characters that requires xindy. If you try this example and encounter errors, check that you have an up-to-date TeX distribution. Note that with the modern LaTeX kernel, the default encoding is assumed to be UTF-8 so I haven’t bothered loading the inputenc package.
Note the use of the xindy package option, which ensures that all the indexing information is written in the correct format.\documentclass
{article}\usepackage
[T1]{fontenc}\usepackage
[main=english,brazilian]{babel}\usepackage
[xindy]{glossaries}
This example is a multilingual document so a second glossary is defined for the Brazilian terms:
I could just supply the actual title, but using the language-sensitive\newglossary*
{dictionary}{\glossaryname
}
\glossaryname
(which is also the title
provided for the main glossary) demonstrates the language
support.
This document will need to have both glossaries-english and glossaries-portuges installed in addition to the base glossaries package.
To ensure that the files required by xindy are opened:
\makeglossaries
Now define some English terms:
And here are the terms that need to go in the custom “dictionary” glossary:\newglossaryentry
{élite}{name={élite}, description={select group or class}}\newglossaryentry
{elephant}{name={elephant}, description={large animal with trunk and tusks}}\newglossaryentry
{elk}{name={elk}, description={large deer}}
The main body of the document contains references using the labels provided in the first argument of\newglossaryentry
{água}{name={água}, type={dictionary}, description={water}}\newglossaryentry
{árvore}{name={árvore}, type={dictionary}, description={tree}}\newglossaryentry
{ano}{name={ano}, type={dictionary}, description={year}}
\newglossaryentry
and the
glossary lists are placed at the desired location, at the end
of each section:
If the document is saved in the file myDoc.tex then the document build is:\begin{document}
\section
{English} An\gls
{elk} and an\gls
{elephant} belonged to an\gls
{élite} group.\printglossary
\selectlanguage
{brazilian}\section
{Brasileiro} A\gls
{árvore} tive\gls
{água} este\gls
{ano}.\printglossary
[type=dictionary]\end{document}
pdflatex myDoc makeglossaries myDoc pdflatex myDoc
Example 10 is a modification of the previous example which uses bib2gls (and therefore requires glossaries-extra). The entry data must now be provided in one or more bib files. For example, the file sample-utf8-en.bib contains:
% Encoding: UTF-8and the file sample-utf8-pt.bib contains:@entry
{élite, name={élite}, description={select group or class} }@entry
{elephant, name={elephant}, description={large animal with trunk and tusks} }@entry
{elk, name={elk}, description={large deer} }
% Encoding: UTF-8@entry
{água, name={água}, description={water} }@entry
{árvore, name={árvore}, description={tree} }@entry
{ano, name={ano}, description={year} }
The document now requires glossaries-extra with the record option:
As before a custom glossary is defined:\documentclass
{article}\usepackage
[T1]{fontenc}\usepackage
[main=english,brazilian]{babel}\usepackage
[record]{glossaries-extra}
Instead of using\newglossary*
{dictionary}{\glossaryname
}
\makeglossaries
, the document now needs:
The main body of the document is similar to the previous example, but a different command is needed to display the glossary.\GlsXtrLoadResources
[ sort=en,% sort according to English language rules src={sample-utf8-en}% data in sample-utf8-en.bib ]\GlsXtrLoadResources
[ sort=pt-BR,% sort according to pt-BR language rules src={sample-utf8-pt},% data in sample-utf8-pt.bib type=dictionary ]
The document build is slightly different:\begin{document}
\section
{English} An\gls
{elk} and an\gls
{elephant} belonged to an\gls
{élite} group.\printunsrtglossary
\selectlanguage
{brazilian}\section
{Brasileiro} A\gls
{árvore} tive\gls
{água} este\gls
{ano}.\printunsrtglossary
[type=dictionary]\end{document}
pdflatex myDoc bib2gls myDoc pdflatex myDoc
With old versions of mfirstuc (pre v2.08), if you use a UTF-8
character at the start of an entry name, you must place it in a
group, or it will cause a problem for sentence case commands
(e.g. \Gls
). For example:
% mfirstuc v2.07:
\newglossaryentry
{elite}{name={{é}lite},
description={select group or class}}
This isn’t necessary with glossaries v4.50+ and mfirstuc
v2.08+, and with a newer LaTeX kernel the UTF-8 character may
occur in the label:
% mfirstuc v2.08:
\newglossaryentry
{élite}{name={élite},
description={select group or class}}
If you are using xindy or bib2gls, the application needs to know the encoding of the tex file. This information is added to the aux file and can be picked up by makeglossaries and bib2gls.
Note that makeindex doesn’t support UTF-8 so, although it
can be used with some Latin alphabet languages, you will need to ensure
that the sort value doesn’t contain any UTF-8.
If you have the double-quote character ("
) as an
active character (for example, a babel shorthand) and you
want to use makeindex’s -g (German) option, you’ll
need to change makeindex’s quote character using:
?
(question mark),
|
(pipe) or !
(exclamation mark).
For example:
\GlsSetQuote
{+}
This must be done before \makeglossaries
and any entry
definitions. It’s only applicable for makeindex. This option
in conjunction with ngerman will also cause
makeglossaries to use the -g switch when invoking
makeindex.
For example:
\documentclass
{article}\usepackage
[ngerman]{babel}\usepackage
{glossaries}\GlsSetQuote
{+}\makeglossaries
\newglossaryentry
{rna}{name=ribonukleinsäure, sort={ribonukleins"aure}, description={eine Nukleinsäure}}\begin{document}
\gls
{rna}\printglossaries
\end{document}
1.5.1. Changing the Fixed Names[link]
The fixed names are produced using the commands listed in Table 1.2. If you aren’t using a language package such as babel or polyglossia that uses caption hooks, you can just redefine these commands as appropriate. If you are using babel or polyglossia, you need to use their caption hooks to change the defaults. See changing the words babel uses or read the babel or polyglossia documentation. If you have loaded babel, then glossaries will attempt to load translator, unless you have used the notranslate, translate=false or translate=babel package options.
If the translator package is loaded, the translations are provided by dictionary files (for example, glossaries-dictionary-English.dict). See the translator package for advice on changing translations provided by translator dictionaries. If you can’t work out how to modify these dictionary definitions, try switching to babel’s interface using translate=babel:
and then use babel’s caption hook mechanism. Note that if you pass the language options directly to babel rather that using the document class options or otherwise passing the same options to translator, then translator won’t pick up the language and no dictionaries will be loaded and babel’s caption hooks will be used instead.\documentclass
[english,french]{article}\usepackage
{babel}\usepackage
[translate=babel]{glossaries}
Command Name | Translator Key Word | Purpose |
---|---|---|
\glossaryname |
Glossary |
Title of the main glossary. |
\acronymname |
Acronyms |
Title of the list of acronyms (when used with package option acronym). |
\entryname |
Notation (glossaries) |
Header for first column in the glossary (for 2, 3 or 4 column glossaries that support headers). |
\descriptionname |
Description (glossaries) |
Header for second column in the glossary (for 2, 3 or 4 column glossaries that support headers). |
\symbolname |
Symbol (glossaries) |
Header for symbol column in the glossary for glossary styles that support this option. |
\pagelistname |
Page List (glossaries) |
Header for the page list column in the glossary for glossaries that support this option. |
\glssymbolsgroupname |
Symbols (glossaries) |
Header for symbols section of the glossary for glossary styles that support this option. |
\glsnumbersgroupname |
Numbers (glossaries) |
Header for numbers section of the glossary for glossary styles that support this option. |
As from version 4.12, multilingual support is provided by separate language modules that need to be installed in addition to installing the glossaries package. You only need to install the modules for the languages that you require. If the language module has an unmaintained status, you can volunteer to take over the maintenance by contacting me at https://www.dickimaw-books.com/contact. The translator dictionary files for glossaries are now provided by the appropriate language module. For further details about information specific to a given language, please see the documentation for that language module.
Examples of use:
- •Using babel and translator:
(translator is automatically loaded).\documentclass
[english,french]{article}\usepackage
{babel}\usepackage
{glossaries} - •Using babel:
(translator isn’t loaded). The glossaries-extra package has translate=babel as the default if babel has been loaded.\documentclass
[english,french]{article}\usepackage
{babel}\usepackage
[translate=babel]{glossaries} - •Using polyglossia:
\documentclass
{article}\usepackage
{polyglossia}\setmainlanguage
{english}\usepackage
{glossaries}
Due to the varied nature of glossaries, it’s likely that the
predefined translations may not be appropriate. If you are using the
babel package and the glossaries package option
translate=babel, you need to be familiar with the advice given in
changing
the words babel uses. If you are using the translator
package, then you can provide your own dictionary with the necessary
modifications (using \deftranslation
) and load it using
\usedictionary
. If you simply want to change the title of a
glossary, you can use the title key in
commands like \printglossary
(but not the iterative commands
like \printglossaries
).
\deftranslation
in the preamble. It should be put in your personal dictionary
instead (as in the example below). See the translator
documentation for further details.
Your custom dictionary doesn’t have to be just a translation from English to another language. You may prefer to have a dictionary for a particular type of document. For example, suppose your institution’s in-house reports have to have the glossary labelled as “Nomenclature” and the location list should be labelled “Location”, then you can create a file called, say, myinstitute-glossaries-dictionary-English.dict that contains the following:
You can now load it using:\ProvidesDictionary
{myinstitute-glossaries-dictionary}{English}\deftranslation
{Glossary}{Nomenclature}\deftranslation
{Page List (glossaries)}{Location}
\usedictionary
{myinstitute-glossaries-dictionary}
(Make sure that myinstitute-glossaries-dictionary-English.dict
can be found by TeX.) If you want to share your custom dictionary,
you can upload it to CTAN.
If you are using babel and don’t want to use the translator interface, you can use the package option translate=babel. For example:
\documentclass
[british]{article}\usepackage
{babel}\usepackage
[translate=babel]{glossaries}\addto
\captionsbritish
{%\renewcommand
*{\glossaryname
}{List of Terms}%\renewcommand
*{\acronymname
}{List of Acronyms}% }
Note that xindy and bib2gls provide much better multi-lingual support than makeindex, so I recommend that you use Options 2 or 3 if you have glossary entries that contain non-Latin characters. See §14 for further details on xindy, and see the bib2gls user manual for further details of that application.
1.5.2. Creating a New Language Module[link]
The glossaries package now uses the tracklang package to determine which language modules need to be loaded. If you want to create a new language module, you should first read the tracklang documentation.
To create a new language module, you need to at least create two
files called: glossaries-.ldf and
glossaries-dictionary-.dict where
is the root language name (for example,
english
) and is the language name used by
translator (for example, English
).
Here’s an example of glossaries-dictionary-English.dict:
You can use this as a template for your dictionary file. Change\ProvidesDictionary
{glossaries-dictionary}{English}\providetranslation
{Glossary}{Glossary}\providetranslation
{Acronyms}{Acronyms}\providetranslation
{Notation (glossaries)}{Notation}\providetranslation
{Description (glossaries)}{Description}\providetranslation
{Symbol (glossaries)}{Symbol}\providetranslation
{Page List (glossaries)}{Page List}\providetranslation
{Symbols (glossaries)}{Symbols}\providetranslation
{Numbers (glossaries)}{Numbers}
English
to the translator name for your language
(so that it matches the file name glossaries-dictionary-.dict)
and, for each \providetranslation
, change the second argument to
the appropriate translation.
Here’s an example of glossaries-english.ldf:
This is a somewhat longer file, but again you can use it as a template. Replace\ProvidesGlossariesLang
{english}\glsifusedtranslatordict
{English} {%\addglossarytocaptions
{\CurrentTrackedLanguage
}%\addglossarytocaptions
{\CurrentTrackedDialect
}% } {%\@ifpackageloaded
{polyglossia}% {%\newcommand
*{\glossariescaptionsenglish
}{%\renewcommand
*{\glossaryname
}{\textenglish
{Glossary}}%\renewcommand
*{\acronymname
}{\textenglish
{Acronyms}}%\renewcommand
*{\entryname
}{\textenglish
{Notation}}%\renewcommand
*{\descriptionname
}{\textenglish
{Description}}%\renewcommand
*{\symbolname
}{\textenglish
{Symbol}}%\renewcommand
*{\pagelistname
}{\textenglish
{Page List}}%\renewcommand
*{\glssymbolsgroupname
}{\textenglish
{Symbols}}%\renewcommand
*{\glsnumbersgroupname
}{\textenglish
{Numbers}}% }% }% {%\newcommand
*{\glossariescaptionsenglish
}{%\renewcommand
*{\glossaryname
}{Glossary}%\renewcommand
*{\acronymname
}{Acronyms}%\renewcommand
*{\entryname
}{Notation}%\renewcommand
*{\descriptionname
}{Description}%\renewcommand
*{\symbolname
}{Symbol}%\renewcommand
*{\pagelistname
}{Page List}%\renewcommand
*{\glssymbolsgroupname
}{Symbols}%\renewcommand
*{\glsnumbersgroupname
}{Numbers}% }% }%\ifcsdef
{captions\CurrentTrackedDialect
} {%\csappto
{captions\CurrentTrackedDialect
}% {%\glossariescaptionsenglish
}% }% {%\ifcsdef
{captions\CurrentTrackedLanguage
} {%\csappto
{captions\CurrentTrackedLanguage
}% {%\glossariescaptionsenglish
}% }% % % }%\glossariescaptionsenglish
}\renewcommand
*{\glspluralsuffix
}{s}\renewcommand
*{\glsacrpluralsuffix
}{\glspluralsuffix
}\renewcommand
*{\glsupacrpluralsuffix
}{\glstextup
{\glspluralsuffix
}}
English
with the translator
language label used for the dictionary file and
replace english
with the root language name . Within the
definition of \glossariescaptions
, replace the
English text (such as “Glossaries”) with the appropriate
translation.
The suffixes used to generate the plural forms when the plural
hasn’t been specified are given by \glspluralsuffix
(for
general entries). For acronyms defined with the base
\newacronym
, \glsupacrpluralsuffix
is used for the
small caps acronym styles where the suffix needs to be
set using \glstextup
to counteract the effects of \textsc
and \glsacrpluralsuffix
for other acronym styles.
There’s no guarantee when these commands will be expanded. They may
be expanded on definition or they may be expanded on use, depending
on the glossaries configuration.
\captions
hook as that’s typically not implemented
until the start of the document. This means that the suffix
in effect will be for the last loaded language that redefined these
commands. It’s best to initialise these commands to the most common
suffix required in your document and use the plural,
longplural, shortplural etc keys to override
exceptions.
If you want to add a regional variation, create a file called glossaries--.ldf, where is the ISO language code and is the ISO country code. For example, glossaries-en-GB.ldf. This file can load the root language file and make the appropriate changes, for example:
\ProvidesGlossariesLang
{en-GB}\RequireGlossariesLang
{english}\glsifusedtranslatordict
{British} {%\addglossarytocaptions
{\CurrentTrackedLanguage
}%\addglossarytocaptions
{\CurrentTrackedDialect
}% } {%\@ifpackageloaded
{polyglossia}% {% % Modify\glossariescaptionsenglish
as appropriate for % polyglossia }% {% % Modify\glossariescaptionsenglish
as appropriate for % non-polyglossia }% }
If the translations includes non-Latin characters, it’s a good idea to provide code that’s independent of the input encoding. Remember that while some users may use UTF-8 (and it’s now the default encoding with modern LaTeX kernels), others may use Latin-1 or any other supported encoding, but while users won’t appreciate you enforcing your preference on them, it’s useful to provide a UTF-8 version.
The glossaries-irish.ldf file provides this as follows:
(Again you can use this as a template. Replace\ProvidesGlossariesLang
{irish}\glsifusedtranslatordict
{Irish} {%\addglossarytocaptions
{\CurrentTrackedLanguage
}%\addglossarytocaptions
{\CurrentTrackedDialect
}% } {%\ifdefstring
{\inputencodingname
}{utf8} {\input
{glossaries-irish-utf8.ldf}}% {%\ifdef
\XeTeXinputencoding
% XeTeX defaults to UTF-8 {\input
{glossaries-irish-utf8.ldf}}% {\input
{glossaries-irish-noenc.ldf}} }\ifcsdef
{captions\CurrentTrackedDialect
} {%\csappto
{captions\CurrentTrackedDialect
}% {%\glossariescaptionsirish
}% }% {%\ifcsdef
{captions\CurrentTrackedLanguage
} {\csappto
{captions\CurrentTrackedLanguage
}% {%\glossariescaptionsirish
}% }% {% }% }%\glossariescaptionsirish
}
irish
with
your root language label and Irish
with the
translator dictionary label.)
There are now two extra files: glossaries-irish-noenc.ldf (no encoding information) and glossaries-irish-utf8.ldf (UTF-8).
These both define \glossariescaptionsirish
but the *-noenc.ldf
file uses LaTeX accent commands:
whereas the *-utf8.ldf file replaces the accent commands with the appropriate UTF-8 characters.\@ifpackageloaded
{polyglossia}% {%\newcommand
*{\glossariescaptionsirish
}{%\renewcommand
*{\glossaryname
}{\textirish
{Gluais}}%\renewcommand
*{\acronymname
}{\textirish
{Acrainmneacha}}%\renewcommand
*{\entryname
}{\textirish
{Ciall}}%\renewcommand
*{\descriptionname
}{\textirish
{Tuairisc}}%\renewcommand
*{\symbolname
}{\textirish
{Comhartha}}%\renewcommand
*{\glssymbolsgroupname
}{\textirish
{Comhartha\'
\i
}}%\renewcommand
*{\pagelistname
}{\textirish
{Leathanaigh}}%\renewcommand
*{\glsnumbersgroupname
}{\textirish
{Uimhreacha}}% }% }% {%\newcommand
*{\glossariescaptionsirish
}{%\renewcommand
*{\glossaryname
}{Gluais}%\renewcommand
*{\acronymname
}{Acrainmneacha}%\renewcommand
*{\entryname
}{Ciall}%\renewcommand
*{\descriptionname
}{Tuairisc}%\renewcommand
*{\symbolname
}{Comhartha}%\renewcommand
*{\glssymbolsgroupname
}{Comhartha\'
\i
}%\renewcommand
*{\pagelistname
}{Leathanaigh}%\renewcommand
*{\glsnumbersgroupname
}{Uimhreacha}% }% }
1.6. Generating the Associated Glossary Files[link]
If this section seriously confuses you, and you can’t work out how to run external tools like makeglossaries or makeindex, you can try using the automake package option, described in §2.5, but you will need TeX’s shell escape enabled. See also Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build. Since makeindex is on the trusted list, the restricted shell escape may be used, which is safer than the unrestricted mode. For example:
If the document source is in the file myDoc.tex then this requires:\usepackage
[automake]{glossaries}\makeglossaries
pdflatex -shell-restricted myDoc pdflatex -shell-restricted myDoc(you may find that
-shell-restricted
is the default for your
system, in which case it may be omitted).
Whereas:
requires:\usepackage
[xindy,automake]{glossaries}\makeglossaries
pdflatex -shell-escape myDoc pdflatex -shell-escape myDocBe aware that this unrestricted mode is a security risk, so it’s best avoided.
In order to generate a sorted glossary with compact number lists, it is necessary to use an external indexing application as an intermediate step (Option 1, which uses TeX to do the sorting, can’t compact number lists). It is this application that creates the file containing the code required to typeset the glossary. If this step is omitted, the glossaries will not appear in your document.
The two oldest indexing applications most commonly used with LaTeX are makeindex and xindy. The glossaries package can be used with either of these applications. Any other application that can support makeindex’s syntax and style file may be used instead of makeindex. Simply follow the makeindex instructions and substitute the call to makeindex with the appropriate call to the alternative.
Commands that only have an effect when xindy is used are described in §14.
% arara: pdflatex % arara: makeglossaries % arara: pdflatexWith latexmk you need to set up the required dependencies.
The glossaries package comes with the Perl script
makeglossaries which will run makeindex or xindy
on all the indexing files using a customized style file (which is
created by \makeglossaries
). See
§1.6.1 for further
details. Perl is stable, cross-platform, open source software that
is used by a number of TeX-related applications (including
xindy and latexmk). Most Unix-like
operating systems come with a Perl interpreter. TeX Live also comes
with a Perl interpreter. As far as I know, MikTeX doesn’t come with a Perl
interpreter so if you are a Windows MikTeX user you will need to
install Perl if you want to use makeglossaries or xindy.
Further information is available at http://www.perl.org/about.html
and
MikTeX and Perl scripts (and one Python script).
The advantages of using makeglossaries:
- •It automatically detects whether to use makeindex or
xindy and sets the relevant application switches.
- •One call of makeglossaries will run
makeindex/xindy for each glossary type.
- •If things go wrong, makeglossaries will scan the
messages from makeindex or xindy and attempt to diagnose
the problem in relation to the glossaries package. This
will hopefully provide more helpful messages in some cases. If it
can’t diagnose the problem, you will have to read the relevant transcript
file and see if you can work it out from the makeindex or
xindy messages.
- •If makeindex warns about multiple encap values,
makeglossaries v2.18+ will detect this and attempt to correct the
problem. This correction is only provided by makeglossaries when
makeindex is used since xindy uses the order of the
attributes list to determine which format should take precedence.
(see §14.3.) This correction can be switched off with the -e
switch.
- •If makeindex warns about invalid or
empty locations, makeglossaries v4.50+ will detect this
and attempt to alter the location to fit makeindex’s syntax.
This may or may not cause unexpected results in the
location list, but it’s useful if the nonumberlist option
is used.
- •If makeindex has a warning that could be the result of a
command occurring within the location, makeglossaries v4.50+
will attempt to repair it by moving the command out of the location
and into the encap.
- •If the output directory has been set when running LaTeX (which puts all the associated files in another directory), makeglossaries has a -d switch that can be used to identify the output directory. This means that makeglossaries can change to that directory before running makeindex or xindy.
As from version 4.16, the glossaries package also comes with a Lua script called makeglossaries-lite. This is a trimmed-down alternative to the makeglossaries Perl script. It doesn’t have some of the options that the Perl version has and it doesn’t attempt to diagnose any problems, but since modern TeX distributions come with LuaTeX (and therefore have a Lua interpreter) you don’t need to install anything else in order to use makeglossaries-lite so it’s an alternative to makeglossaries if you want to use Option 2 (makeindex).
If things go wrong and you can’t work out why your glossaries aren’t being generated correctly, you can use makeglossariesgui as a diagnostic tool. Once you’ve fixed the problem, you can then go back to using makeglossaries or makeglossaries-lite.
Whilst I strongly recommended that you use the makeglossaries Perl script or the makeglossaries-lite Lua script, it is possible to use the glossaries package without using those applications. However, note that some commands and package options have no effect if you explicitly run makeindex/xindy. These are listed in Table 1.3.
Below, references to makeglossaries can usually be substituted with makeglossaries-lite, except where noted otherwise.
If any of your entries use an entry that is not referenced outside the glossary (for example, the entry is only referenced in the description of another entry), you will need to do an additional makeglossaries, makeindex or xindy run, as appropriate. For example, suppose you have defined the following entries:
and suppose you have\newglossaryentry
{citrusfruit}{name={citrus fruit}, description={fruit of any citrus tree. (See also\gls
{orange})}}\newglossaryentry
{orange}{name={orange}, description={an orange coloured fruit.}}
\gls
{citrusfruit}
in your document
but don’t reference the “orange” entry, then the
orange entry won’t appear in your glossary until
you first create the glossary and then do another run
of makeglossaries, makeindex or xindy.
For example, if the document is called myDoc.tex, then
you must do:
pdflatex myDoc makeglossaries myDoc pdflatex myDoc makeglossaries myDoc pdflatex myDoc(In the case of Option 4, bib2gls will scan the description for instances of commands like
\gls
to ensure they are selected but
an extra bib2gls call is required to ensure the locations are
included, if location lists are required. See the
bib2gls manual for further details.)
Likewise, an additional makeglossaries and LaTeX run may be required if the document pages shift with re-runs. For example, if the page numbering is not reset after the table of contents, the insertion of the table of contents on the second LaTeX run may push glossary entries across page boundaries, which means that the number lists in the glossary may need updating.
The examples in this document assume that you are accessing makeglossaries, xindy or makeindex via a terminal. Windows users can use the command prompt which is usually accessed via the Start➜All Programs menu or Start➜All Programs➜Accessories menu or Start➜Windows System.
Alternatively, your text editor may have the facility to create a function that will call the required application. See Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build.
If any problems occur, remember to check the transcript files (e.g. glg or alg) for messages.
Command or Package Option | makeindex | xindy |
---|---|---|
order=letter | use -l |
use -M ord/letorder |
order=word | default | default |
xindy={language={lang},codepage={code}} | N/A | use -L -C |
|
N/A |
use -L |
|
N/A |
use -C
|
1.6.1. Using the makeglossaries Perl Script[link]
makeglossaries
The makeglossaries script picks up the relevant information from the auxiliary (aux) file and will either call xindy or makeindex, depending on the supplied information. Therefore, you only need to pass the document’s name without the extension to makeglossaries. For example, if your document is called myDoc.tex, type the following in your terminal:
pdflatex myDoc makeglossaries myDoc pdflatex myDocIf you only want one glossary processed (for example, if you are working on a draft of a large document and want to concentrate on one specific glossary) then include the extension supplied to
\newglossary
, such as glo for the main
glossary. Note that if you do specify the extension and your
document has multiple glossaries defined, then
makeglossaries will tell you how many glossaries have
been ignored unless the -q switch has been used.
Windows users: TeX Live on Windows has its own internal Perl interpreter and provides makeglossaries.exe as a convenient wrapper for the makeglossaries Perl script. MikTeX also provides a wrapper makeglossaries.exe but doesn’t provide a Perl interpreter (as far as I know), which is still required even if you run MikTeX’s makeglossaries.exe, so with MikTeX you’ll need to install Perl. There’s more information about this at MikTeX and Perl scripts (and one Python script).
Some of the options are only applicable to makeindex and some are only applicable to xindy.
Shows a summary of all available options.
Shows the version details.
Dry run mode. This doesn’t actually run makeindex/xindy but just prints the command it would execute based on the information given in the aux file and the supplied options.
Instructs makeglossaries to change to the given directory, which should be where the aux, glo etc files are located. For example:
pdflatex -output-directory myTmpDir myDoc makeglossaries -d myTmpDir myDoc
Don’t check for multiple encaps (only applicable with makeindex). By default, if you are using makeindex, makeglossaries will check the makeindex transcript for multiple encap warnings.
The multiple encap warning is where different location encap values (location formats) are used on the same location for the same entry. For example:
If you explicitly use makeindex, this will cause a warning and the location list will be “1, 1”. That is, the page number will be repeated with each format. As from v2.18, makeglossaries will check for this warning and, if found, will attempt to correct the problem by removing duplicate locations and retrying. If you actually want the duplicate location, you can prevent makeglossaries from checking and correcting the duplicates with -e.\documentclass
{article}\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={an example}}\begin{document}
\gls
{sample},\gls
[format=textbf]{sample}.\printglossaries
\end{document}
There’s no similar check for xindy as xindy won’t produce any warning and will simply discard duplicates.
Suppresses messages. The makeglossaries script attempts to fork the makeindex/xindy process using
open()
on the
piped redirection 2>&1 |
and parses the processor output to
help diagnose problems. If this method fails makeglossaries
will print an “Unable to fork” warning and will retry without
redirection. Without this redirection, the -q switch
doesn’t work as well. Some operating systems don’t support
redirection.
Suppresses the “Unable to fork” warning.
Don’t attempt redirection.
The makeindex application. Only the name is required if it’s on the operating system’s path, otherwise the full path name will be needed.
If you want to use an application that is capable of reading makeindex files (including support for makeindex style files via -s), then you can use -m to specify the alternative application to use instead of makeindex. Note that both xindex and texindy can read makeindex files using the default makeindex syntax but, as of the time of writing this, they don’t support makeindex style files.
The xindy application. Only the name is required if it’s on the operating system’s path, otherwise the full path name will be needed.
Compress intermediate blanks. This will pass -c to makeindex. (Ignored if xindy should be called.)
Disable implicit page range formation. This will pass -r to makeindex. (Ignored if xindy should be called.)
Set the starting page number. This will pass
-p
to makeindex.
(Ignored if xindy should be called.)
The following switches may be used to override settings written to the aux file.
Use letter ordering. This will pass -l to makeindex or
-M ord/letorder
to xindy.
The language to pass to xindy. (Ignored if makeindex should be called.)
Employ German word ordering. This will pass -g to makeindex. (Ignored if xindy should be called.)
Set the style file. This will pass
-s
to makeindex
or -M
to xindy (where
is with the xdy extension
removed). This will generate an error if the extension is xdy
when makeindex should be called, or if the extension isn’t
xdy when xindy should be called.
Sets the output file name. Note that this should only be used when only one glossary should be processed. The default is to set the output filename to the basename supplied to makeglossaries with the extension associated with the glossary (the argument of
\newglossary
).
Sets the transcript file name. Note that this should only be used when only one glossary should be processed. The default is to set the transcript filename to the basename supplied to makeglossaries with the extension associated with the glossary (the argument of
\newglossary
).
1.6.2. Using the makeglossaries-lite Lua Script[link]
makeglossaries-lite
The Lua alternative to the makeglossaries Perl script requires a Lua interpreter, which should already be available if you have a modern TeX distribution that includes LuaTeX. Lua is a light-weight, cross-platform scripting language, but because it’s light-weight it doesn’t have the full-functionality of heavy-weight scripting languages, such as Perl. The makeglossaries-lite script is therefore limited by this and some of the options available to the makeglossaries Perl script aren’t available here. (In particular the -d option.) Whilst it may be possible to implement those features by requiring Lua packages, this would defeat the purpose of providing this script for those don’t want the inconvenience of learning how to install interpreters or their associated packages.
The makeglossaries-lite script can be invoked in the same way as makeglossaries. For example, if your document is called myDoc.tex, then do
makeglossaries-lite myDocNote that the arara rule doesn’t contain the hyphen:
% arara: makeglossarieslite
Some of the options are only applicable to makeindex and some are only applicable to xindy. There’s no equivalent to the -d available to makeglossaries but it may work if you prefix the basename with the path.
Shows a summary of all available options.
Shows the version details.
Dry run mode. This doesn’t actually run makeindex/xindy but just prints the command it would execute based on the information given in the aux file and the supplied options.
Quiet mode. This suppresses some but not all messages.
The makeindex application. Only the name is required if it’s on the operating system’s path, otherwise the full path name will be needed.
The xindy application. Only the name is required if it’s on the operating system’s path, otherwise the full path name will be needed.
Compress intermediate blanks. This will pass -c to makeindex. (Ignored if xindy should be called.)
Disable implicit page range formation. This will pass -r to makeindex. (Ignored if xindy should be called.)
Set the starting page number. This will pass
-p
to makeindex.
(Ignored if xindy should be called.)
The following switches may be used to override settings written to the aux file.
Use letter ordering. This will pass -l to makeindex or
-M ord/letorder
to xindy.
The language to pass to xindy. (Ignored if makeindex should be called.)
Employ German word ordering. This will pass -g to makeindex. (Ignored if xindy should be called.)
Set the style file.
Sets the output file name. Note that this should only be used when only one glossary should be processed. The default is to set the output filename to the basename supplied to makeglossaries with the extension associated with the glossary (the argument of
\newglossary
).
Sets the transcript file name. Note that this should only be used when only one glossary should be processed. The default is to set the transcript filename to the basename supplied to makeglossaries with the extension associated with the glossary (the argument of
\newglossary
).
1.6.3. Using xindy explicitly (Option 3)[link]
xindy comes with TeX Live. It has also been added to MikTeX, but if you don’t have it installed, see How to use Xindy with MikTeX.
If you want to use xindy to process the glossary files, you must make sure you have used the xindy package option:
\usepackage
[xindy]{glossaries}
This is required regardless of whether you use xindy
explicitly or whether it’s called implicitly via applications such
as makeglossaries. This causes the glossary
entries to be written in raw xindy format, so you need to
use -I xindy
not -I tex
.
To run xindy type the following in your terminal (all on one line):
xindy -L -C -I xindy -M -t .glg -o .gls .glowhere is the required language name, is the encoding, is the name of the document without the tex extension and is the name of the xindy style file without the xdy extension. The default name for this style file is xdy but can be changed via
\setStyleFile
. As usual for command line
applications, if any of the file names contain spaces, you must
delimit them using double-quotes.
For example, if your document is called myDoc.tex and you are using UTF-8 encoding in English, then type the following in your terminal:
xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.glg -o myDoc.gls myDoc.glo
Note that this just creates the main
glossary. You need to do
the same for each of the other glossaries (including the
list of acronyms if you have used the acronym
package option), substituting glg, gls
and glo with the relevant extensions. For example,
if you have used the acronym package option, then
you would need to do:
xindy -L english -C utf8 -I xindy -M myDoc -t myDoc.alg -o myDoc.acr myDoc.acnFor additional glossaries, the extensions are those supplied when you created the glossary with
\newglossary
.
Note that if you use makeglossaries instead, you can replace all those calls to xindy with just one call to makeglossaries:
makeglossaries myDocNote also that some commands and package options have no effect if you use xindy explicitly instead of using makeglossaries. These are listed in Table 1.3.
1.6.4. Using makeindex explicitly (Option 2)[link]
If you want to use makeindex explicitly, you must make sure that you haven’t used the xindy package option or the glossary entries will be written in the wrong format. To run makeindex, type the following in your terminal:
makeindex -s .ist -t .glg -o .gls .glowhere is the name of your document without the tex extension and ist is the name of the makeindex style file. By default, this is ist, but may be changed via
\setStyleFile
. Note that there are other options,
such as -l (letter ordering). See the makeindex
manual for further details.
For example, if your document is called myDoc.tex, then type the following at the terminal:
makeindex -s myDoc.ist -t myDoc.glg -o myDoc.gls myDoc.gloNote that this only creates the
main
glossary. If you have
additional glossaries (for example, if you have used the
acronym package option) then you must call
makeindex for each glossary, substituting
glg, gls and glo with the
relevant extensions. For example, if you have used the
acronym package option, then you need to type the
following in your terminal:
makeindex -s myDoc.ist -t myDoc.alg -o myDoc.acr myDoc.acnFor additional glossaries, the extensions are those supplied when you created the glossary with
\newglossary
.
Note that if you use makeglossaries instead, you can replace all those calls to makeindex with just one call to makeglossaries:
makeglossaries myDocNote also that some commands and package options have no effect if you use makeindex explicitly instead of using makeglossaries. These are listed in Table 1.3.
1.7. Note to Front-End and Script Developers[link]
The information needed to determine whether to use xindy, makeindex or bib2gls is stored in the aux file. This information can be gathered by a front-end, editor or script to make the glossaries where appropriate. This section describes how the information is stored in the auxiliary file. See also “Decyphering the Aux File Commands Provided by glossaries.sty and glossaries-extra.sty”.
1.7.1. MakeIndex and Xindy[link]
The file extension of the indexing files used for each defined glossary (not including any ignored glossaries) are given by:
where is the extension of the indexing application’s input file (the output file from the glossaries package’s point of view), such as glo, is the extension of the indexing application’s output file (the input file from the glossaries package’s point of view), such as gls, and is the extension of the indexing application’s transcript file, such as glg. The label for the glossary is also given. This isn’t required with makeindex, but with xindy it’s needed to pick up the associated language and encoding (see below). For example, the information for the defaultmain
glossary is
written as:
\@newglossary
{main}{glg}{gls}{glo}
If glossaries-extra’s hybrid method has been used (with
\makeglossaries
[ ]), then the sub-list
of glossaries that need to be processed will be identified with:
The indexing application’s style file is specified by:
The file extension indicates whether to use makeindex (ist) or xindy (xdy). Note that the glossary information has a different syntax depending on which indexing application is supposed to be used, so it’s important to call the correct one.For example, with arara you can easily determine whether to run makeglossaries:
% arara: makeglossaries if found("aux", "@istfilename")It’s more complicated if you want to explicitly run makeindex or xindy.
Word or letter ordering is specified by:
where can be eitherword
or letter
(obtained from the order package option).
If xindy should be used, the language for each glossary is specified by:
where identifies the glossary and is the root language (for example,english
).
The codepage (file encoding) for all glossaries is specified by:
where is the encoding (for example,utf8
). The above
two commands are omitted if makeindex should be used.
If Option 1 has been used, the aux file will contain
for every time an entry has been referenced.
1.7.2. Entry Labels[link]
If you need to gather labels for auto-completion, the writeglslabels package option will create a file containing the labels of all defined entries (regardless of whether or not the entry has been used in the document). As from v4.47, there is a similar option writeglslabelnames that writes both the label and name (separated by a tab).
1.7.3. Bib2Gls[link]
If Option 4 has been used, the aux file will contain one or more instances of: where is the basename of the glstex file that needs to be created by bib2gls. If src={ isn’t present in } then also indicates the name of the associated bib file.
For example, with arara you can easily determine whether or not to run bib2gls:
% arara: bib2gls if found("aux", "glsxtr@resource")(It gets more complicated if both
\glsxtr@resource
and
\@istfilename
are present as that indicates the hybrid
record=hybrid option.)
Remember that with bib2gls, the glossary entries will never be defined on the first LaTeX call (because their definitions are contained in the glstex file created by bib2gls). You can also pick up labels from the records in aux file, which will be in the form:
or (with record=nameref): or (with\glssee
):
You can also pick up the commands defined with
\glsxtrnewglslike
, which are added to the aux file
for bib2gls’s benefit:
If \GlsXtrSetAltModifier
is used, then the modifier is
identified with:
Label prefixes (for the \dgls
set of commands) are identified
with:
2. Package Options[link]
This section describes the available glossaries package
options. You may omit the =true
for boolean options. (For
example, acronym is equivalent to acronym=true).
2.1. General Options[link]
This suppresses all warnings generated by the glossaries package. Don’t use this option if you’re new to using glossaries as the warnings are designed to help detect common mistakes (such as forgetting to use
\makeglossaries
).
Note that if you use debug with any value other than
false it will override this option.
This suppresses the warning generated by a missing language module.
If you load glossaries with a class or another package that already defines glossary related commands, by default glossaries will warn you that it’s redefining those commands. If you are aware of the consequences of using glossaries with that class or package and you don’t want to be warned about it, use this option to suppress those warnings. Other warnings will still be issued unless you use the nowarn option described above. (This option is automatically switched on by glossaries-extra.)
Debugging mode may write information to the transcript file or add markers to the document. The following values are available: Switches off debugging mode.
This will write the following line to the transcript file if any attempt at indexing occurs before the associated files have been opened by
\makeglossaries
:
wrglossary(Note that this setting will also cancel )( ) nowarn.
As debug=true but also adds a marker where the glossary-related hyperlinks and targets occur in the document.
The debug=showtargets option will additionally use:
to show the hypertarget or hyperlink name when\glsdohypertarget
is used by commands like \glstarget
and when \glsdohyperlink
is used by commands like \gls
.
In math mode or inner mode, this uses:
which typesets the target name as:
[\glsshowtargetfonttext
{ }]
just before the link or anchor. This uses the text-block command:
which checks for math-mode before applying the font change.
In outer mode \glsshowtarget
uses:
which by default places the target name in the margin with a symbol
produced with:
which defaults to a small right facing triangle.
The font used by both \glsshowtargetfonttext
and
\glsshowtargetouter
is given by the declaration:
As debug=true but also adds a marker where the glossary-related accessibility information occurs (see glossaries-accsupp) using:
The purpose of the debug mode can be demonstrated with the following example document:
In this case, only the “sample1” entry has been indexed, even though\documentclass
{article}\usepackage
{glossaries}\newglossaryentry
{sample1}{name={sample1},description={example}}\newglossaryentry
{sample2}{name={sample2},description={example}}\glsadd
{sample2}% <- does nothing here\makeglossaries
\begin{document}
\gls
{sample1}.\printglossaries
\end{document}
\glsadd
{sample2}
appears in the source code.
This is because \glsadd
{sample2}
has been used before the
associated file is opened by \makeglossaries
. Since the file
isn’t open yet, the information can’t be written to it, which is why
the “sample2” entry doesn’t appear in the glossary.
Without \makeglossaries
the indexing is suppressed with
Options 2 and 3 but, other than that, commands like \gls
behave as usual.
This situation doesn’t cause any errors or warnings as it’s
perfectly legitimate for a user to want to use glossaries to
format the entries (for example, to show a different form on
first use) but not display any glossaries (or the user
may prefer to use the unsorted Options 5 or 6). It’s
also possible that the user may want to temporarily comment out
\makeglossaries
in order to suppress the indexing while
working on a draft version to speed compilation, or the user may
prefer to use Options 1 or 4 for indexing, which don’t
use \makeglossaries
.
Therefore \makeglossaries
can’t be used to enable
\newglossaryentry
and commands like \gls
and \glsadd
.
These commands must be enabled by default. (It does, however, enable
the see key as that’s a more common problem. See below.)
The debug mode, enabled with the debug option,
\usepackage
[debug]{glossaries}
will write information to the log file when the indexing
can’t occur because the associated file isn’t open.
The message is written in the form
Package glossaries Info: wrglossary( )( ) on input line .where is the glossary label and is the line of text that would’ve been written to the associated file if it had been open. So if any entries haven’t appeared in the glossary but you’re sure you used commands like
\glsadd
or \glsaddall
, try switching on the debug option
and see if any information has been written to the log file.
This is a boolean option to minimise the number of write registers used by the glossaries package. The default is savewrites=false. With Options 2 and 3, one write register is required per (non-ignored) glossary and one for the style file.
With all options except Options 1 and 414, another write register is required if the glsdefs file is needed to save document definitions. With both Options 1 and 4, no write registers are required (document definitions aren’t permitted and indexing information is written to the aux file). If you really need document definitions but you want to minimise the number of write registers then consider using docdef=restricted with glossaries-extra.
There are only a limited number of write registers, and if you have a large number of glossaries or if you are using a class or other packages that create a lot of external files, you may exceed the maximum number of available registers. If savewrites is set, the glossary information will be stored in token registers until the end of the document when they will be written to the external files.
By way of comparison, sample-multi2.tex provided with bib2gls has a total of 15 glossaries. With Options 2 or 3, this would require 46 associated files and 16 write registers. (These figures don’t include standard files and registers provided by the kernel or hyperref, such as aux and out.) With bib2gls, no write registers are required and there are only 10 associated files for that particular document (9 resource files and 1 transcript file).
This can take one of the values listed below. If no supported language package has been loaded the default is translate=false otherwise the default is translate=true for the base glossaries package and translate=babel for glossaries-extra.
If babel has been loaded and the translator package is installed, translator will be loaded and the translations will be provided by the translator package interface. You can modify the translations by providing your own dictionary. If the translator package isn’t installed and babel is loaded, the glossaries-babel package will be loaded and the translations will be provided using babel’s
\addto
\captions
mechanism. If
polyglossia has been loaded, glossaries-polyglossia will
be loaded.
Don’t provide translations, even if babel or polyglossia has been loaded. (Note that babel provides the command
\glossaryname
so that will still be translated if you have
loaded babel.)
Don’t load the translator package. Instead load glossaries-babel.
See §1.5.1 for further details.
This is equivalent to translate=false and may be passed via the document class options.
This automatically implements translate=babel (which means that translator won’t automatically be loaded) but will also add the list of languages to tracklang’s list of tracked languages. Each element in the may be an ISO language tag (such as
pt-BR
) or one of tracklang’s
known language labels (such as british
).
Synonym of languages.
If true, terms on first use will have a hyperlink, if supported, unless the hyperlink is explicitly suppressed using starred versions of commands such as
\gls
*
.
If false, only subsequent use instances will have a hyperlink
(if supported).
Note that nohypertypes overrides hyperfirst=true.
This option only affects commands that check the first use flag, such
as the \gls
-like commands (for example, \gls
or
\glsdisp
), but not the \glstext
-like commands
(for example, \glslink
or \glstext
).
The hyperfirst setting applies to
all glossary types (unless identified by nohypertypes or
defined with \newignoredglossary
). It can be overridden on an
individual basis by explicitly setting the hyper key
when referencing an entry (or by using the plus or starred
version of the referencing command).
It may be that you only want to suppress hyperlinks for just the acronyms
(where the first use explains the meaning of the acronym) but not
for ordinary glossary entries (where the first use is identical to
subsequent use). In this case, you can use hyperfirst=false and
apply \glsunsetall
to all the regular (non-acronym)
glossaries.
For example:
\usepackage
[acronym,hyperfirst=false]{glossaries} % acronym and glossary entry definitions % at the end of the preamble\glsunsetall
[main
]
Alternatively you can redefine the hook
which is used by the commands that check the first use flag, such as\gls
. Within the definition of this command, you can use
\glslabel
to reference the entry label and \glstype
to
reference the glossary type. You can also use \ifglsused
to determine if the entry has been used. You can test if an
entry is an acronym by checking if it has the long key set using
\ifglshaslong
(or if the short key has been set using
\ifglshasshort
). For example, to switch off the hyperlink on
first use just for acronyms:
\renewcommand
*{\glslinkcheckfirsthyperhook
}{%\ifglsused
{\glslabel
}{}% {%\ifglshaslong
{\glslabel
}{\setkeys
{glslink}{hyper=false}}% }% }
Note that this hook isn’t used by the commands that don’t check the
first use flag, such as \glstext
. (You can, instead, redefine
\glslinkpostsetkeys
, which is used by both the \gls
-like and
\glstext
-like commands.)
This option will create a file called
\jobname
.glslabels
at the end of the document.
This file simply contains a list of all defined entry labels
(including those in any ignored glossaries). It’s provided for
the benefit of text editors that need to know labels for
auto-completion. If you also want the name, use
writeglslabelnames. (See also glossaries-extra’s
docdef=atom package option.)
Similar to writeglslabels but writes both the label and name (separated by a tab).
Only available with glossaries-extra, the value for this option may be one of:
Generates an error if a referenced entry is undefined (default, and the only available setting with just the base glossaries package).
Only warns if a referenced entry is undefined (automatically activated with Option 4).
Only available with glossaries-extra, this
option governs the use of \newglossaryentry
. Available
values:
This setting means that
\newglossaryentry
is not permitted in
the document environment (default with glossaries-extra
and for Option 1 with just the base glossaries package).
This setting means that
\newglossaryentry
is only permitted in
the document environment if it occurs before
\printglossary
(not available for some indexing options, such
as Option 4).
This setting is as docdef=restricted but creates the glsdefs file for use by atom (without the limitations of docdef=true).
This setting means that
\newglossaryentry
is permitted in the
document environment where it would normally be permitted by
the base glossaries package. This will create the
glsdefs file if \newglossaryentry
is found in the
document environment.
2.2. Sectioning, Headings and TOC Options[link]
Adds the glossaries to the table of contents (toc file). Note that an extra LaTeX run is required with this option. Alternatively, you can switch this function on and off using and You can test whether or not this option is set using: The default value is toc=false for the base glossaries package and toc=true for glossaries-extra.
When used with toc=true option, this will add
\numberline
{}
in the final argument of
\addcontentsline
. This will align the table of contents
entry with the numbered section titles. Note that this option has no
effect with toc=false. If toc=true is used
without numberline, the glossary title will be aligned
with the section numbers rather than the section titles.
This option indicates the sectional unit to use for the glossary.
The value should be the control sequence name without the
leading backslash or following star (for example, just chapter
not \chapter
or chapter*
).
The default behaviour is for the glossary heading to use
\chapter
, if that command exists, or \section
otherwise. The
starred or unstarred form is determined by the numberedsection option.
Example:
\usepackage
[section=subsection]{glossaries}
You can omit the value if you want to use \section
:
\usepackage
[section]{glossaries}
is equivalent to
\usepackage
[section=section]{glossaries}
You can change this value later in the document using
where is the sectional unit.
The start of each glossary adds information to the page header via
\glsglossarymark
(see §8.2).
If ucmark=true, this will make
\glsglossarymark
use
all caps in the header, otherwise no case change will be
applied.
The default is
ucmark=false, unless memoir has been loaded, in
which case the default is ucmark=true.
You can test if this option has been set using:
For example:\renewcommand
{\glsglossarymark
}[1]{%\ifglsucmark
\markright
{\glsuppercase
{#1}}%\else
\markright
{#1}%\fi
}
The glossaries are placed in unnumbered sectional units by default, but this can be changed using numberedsection. This option can take one of the following values:
No number, that is, use the starred form of sectioning command (for example,
\chapter*
or
\section*
).
Use a numbered section, that is, the unstarred form of sectioning command (for example,
\chapter
or \section
), but
no label is automatically added.
Use numbered sections with automatic labelling. Each glossary uses the unstarred form of a sectioning command (for example,
\chapter
or \section
) and is assigned a label
(via \label
). The label is formed from the glossary’s
label prefixed with:
The default value of \glsautoprefix
is empty. For example,
if you load glossaries using:
\usepackage
[section,numberedsection=autolabel]
{glossaries}
then each glossary will appear in a numbered section, and can
be referenced using something like:
The main glossary is in sectionIf you can’t decide whether to have the acronyms in the main glossary or a separate list of acronyms, you can use~
\ref
{main} and the list of acronyms is in section~
\ref
{acronym}.
\acronymtype
which is set to main
if the
acronym option is not used and is set to acronym
if the acronym option is used. For example:
The list of acronyms is in sectionYou can redefine the prefix if the default label clashes with another label in your document. For example:~
\ref
{\acronymtype
}.
will add\renewcommand
*{\glsautoprefix
}{glo:}
glo:
to the automatically generated label, so
you can then, for example, refer to the list of acronyms as follows:
The list of acronyms is in sectionOr, if you are undecided on a prefix:~
\ref
{glo:\acronymtype
}.
The list of acronyms is in section~
\ref
{\glsautoprefix
\acronymtype
}.
This setting is like numberedsection=autolabel but uses an unnumbered sectioning command (for example,
\chapter*
or \section*
). It’s
designed for use with the nameref package. For example:
Alternatively, since nameref is automatically loaded by hyperref:\usepackage
{nameref}\usepackage
[numberedsection=nameref]{glossaries}
Now\usepackage
{hyperref}\usepackage
[numberedsection=nameref]{glossaries}
\nameref
{main}
will display the
(table of contents) section title
associated with the main
glossary. As above, you can
redefine \glsautoprefix
to provide a prefix for the label.
2.3. Glossary Appearance Options[link]
This is a boolean option that specifies whether or not to gather and store the number list for each entry. The default is savenumberlist=false with Options 2 and 3. (See
\glsentrynumberlist
and \glsdisplaynumberlist
in
§5.2.) This setting is always true if you use
Option 1 as a by-product of the way that indexing method works.
If set, this will create the counter: Each top level (level 0) entry will increment and display that counter at the start of the entry line when using glossary styles that support this setting. Note that if you also use subentrycounter the option order makes a difference. If entrycounter is specified first, the sub-entry counter will be dependent on the glossaryentry counter.
If you use this option (and are using a glossary style that supports this option) then you can reference the entry number within the document using:
where is the label associated with that glossary entry. This will use\ref
if either entrycounter=true or
subentrycounter=true, with the label , where
is the entry’s label and is given by:
If both entrycounter=false and
subentrycounter=false, \gls
{ }
will
be used instead.
\glsrefentry
, you must run LaTeX twice after
creating the indexing files using makeglossaries,
makeindex or xindy (or after creating the glstex
file with bib2gls) to ensure the cross-references are
up-to-date. This is because the counter can’t be incremented and
labelled until the glossary is typeset.
The glossaryentry counter can be reset back to zero with:
This does nothing if entrycounter=false. The glossaryentry counter can be simultaneously incremented and labelled (using\refstepcounter
and \label
) with:
This command is within the definition of \glsentryitem
, which is
typically used in glossary styles at the start of
top level (level 0) entries. The argument is the entry label.
The value of the glossaryentry counter can be displayed with:
This command is defined when the glossaryentry counter is defined, so won’t be available otherwise. The formatted value is more usually displayed with: This will do\theglossaryentry
.\space
if
entrycounter=true, otherwise does nothing. This is
therefore more generally useful in glossary styles as it will
silently do nothing if the setting isn’t on. This command is used
within the definition of \glsentryitem
.
If you want to test whether or not this option is currently enabled, use the conditional:
You can later switch it off using: and switch it back on with: but note that this won’t define glossaryentry if entrycounter=true wasn’t used initially. You can also locally enable or disable this option for a specific glossary using the entrycounter\print
option glossary.
If used, this option will automatically set entrycountertrue and the glossaryentry counter will be reset every time is incremented. An empty value indicates that glossaryentry has no parent counter (but glossaryentry will still be defined).
If you want the counter reset at the start of each glossary, you can
modify the glossary preamble (\glossarypreamble
) to use
\glsresetentrycounter
. For example:
or if you are using\renewcommand
{\glossarypreamble
}{%\glsresetentrycounter
}
\setglossarypreamble
, add it to each
glossary preamble, as required. For example:
\setglossarypreamble
[acronym
]{%\glsresetentrycounter
The preamble text here for the list of acronyms. }\setglossarypreamble
{%\glsresetentrycounter
The preamble text here for themain
glossary. }
If set, each level 1 glossary entry will be numbered at the start of its entry line when using glossary styles that support this option. This option creates the counter If the entrycounter option is used before subentrycounter, then glossarysubentry will be added to the reset list for glossaryentry. If subentrycounter is used without entrycounter then the glossarysubentry counter will be reset by
\glsentryitem
. If
subentrycounter is used before entrycounter then the two
counters are independent.
As with the entrycounter option, you can
reference the number within the document using
\glsrefentry
. There are analogous commands to those for
entrycounter.
The glossarysubentry counter can be reset back to zero with:
This does nothing if subentrycounter=false. This command is used within the definition of\glsentryitem
if
entrycounter=false.
The glossarysubentry counter can be simultaneously incremented and labelled (using
\refstepcounter
and \label
) with:
\glssubentryitem
if
subentrycounter=true, otherwise it does nothing. The
argument is the entry label and is passed to \label
is as for
\glsrefentry
.
The value of the glossarysubentry counter can be displayed with:
This command is defined when the glossarysubentry counter is defined, so won’t be available otherwise. The formatted value is more usually displayed with: This will do\theglossarysubentry
)\space
if
subentrycounter=true, otherwise does nothing. This is
therefore more generally useful in glossary styles as it will
silently do nothing if the setting isn’t on. This command is used in
\glssubentryitem
.
If you want to test whether or not this option is currently enabled, use the conditional:
You can later switch it off using: and switch it back on with: but note that this won’t define glossarysubentry if subentrycounter=true wasn’t used initially. You can also locally enable or disable this option for a specific glossary using the subentrycounter\print
option glossary.
This option sets the default glossary style to . This is initialised to style=list unless classicthesis has been loaded, in which case the default is style=index. (The styles that use the description environment, such as the list style, are incompatible with classicthesis.)
This setting may only be used for styles that are defined when the glossaries package is loaded. This will usually be the styles in the packages glossary-list, glossary-long, glossary-super or glossary-tree, unless they have been suppressed through options such as nostyles. Style packages can also be loaded by the stylemods option provided by glossaries-extra.
Alternatively, you can set the style later using:
or use the style\print
option glossary.
(See §13 for further details.)
This prevents the glossaries package from automatically loading glossary-long (which means that the longtable package also won’t be loaded). This reduces overhead by not defining unwanted styles and commands. Note that if you use this option, you won’t be able to use any of the glossary styles defined in the glossary-long package (unless you explicitly load glossary-long).
This prevents the glossaries package from automatically loading glossary-super (which means that the supertabular package also won’t be loaded). This reduces overhead by not defining unwanted styles and commands. Note that if you use this option, you won’t be able to use any of the glossary styles defined in the glossary-super package (unless you explicitly load glossary-super).
This prevents the glossaries package from automatically loading glossary-list. This reduces overhead by not defining unwanted styles. Note that if you use this option, you won’t be able to use any of the glossary styles defined in the glossary-list package (unless you explicitly load glossary-list). Note that since the default style is list (unless classicthesis has been loaded), you will also need to use the style option to set the style to something else.
This prevents the glossaries package from automatically loading glossary-tree. This reduces overhead by not defining unwanted styles. Note that if you use this option, you won’t be able to use any of the glossary styles defined in the glossary-tree package (unless you explicitly load glossary-tree). Note that if classicthesis has been loaded, the default style is index, which is provided by glossary-tree.
This prevents all the predefined styles from being loaded. If you use this option, you need to load a glossary style package (such as glossary-mcols). Also if you use this option, you can’t use the style package option (unless you use stylemods with glossaries-extra). Instead you must either use
\setglossarystyle
or the
style \print
option glossary. Example:
Alternatively:\usepackage
[nostyles]{glossaries}\usepackage
{glossary-mcols}\setglossarystyle
{mcoltree}
\usepackage
[nostyles,stylemods=mcols,style=mcoltree]{glossaries-extra}
This option will suppress the associated number lists in the glossaries (see also §12). This option can also be locally switched on or off for a specific glossary with the nonumberlist
\print
options glossary.
Remember that number list includes any cross-references, so suppressing the number list will also hide the cross-references (in which case, you may want to use seeautonumberlist).
If you suppress the number lists with nonumberlist, described above, this will also suppress any cross-referencing information supplied by the see key in
\newglossaryentry
or \glssee
. If you
use seeautonumberlist, the see key will
automatically implement nonumberlist=false for that entry.
(Note this doesn’t affect \glssee
.) For further details see
§11.
This setting indicates that should be the default counter to use in the number lists (see §12). This option can be overridden for a specific glossary by the optional argument of
\newglossary
or the counter key when defining an
entry or by the counter option when referencing an entry.
This option will redefine:
to .If true, this option suppresses the default terminating full stop in glossary styles that use the post-description hook
\glspostdescription
.
The default setting is nopostdot=false for the base glossaries package and nopostdot=true for glossaries-extra.
If true, this option suppresses the default vertical gap between letter groups used by some of the predefined glossary styles. This option can also be locally switched on or off for a specific glossary with the nogroupskip
\print
options glossary.
This option is only relevant for glossary styles that use the conditional:
to test for this setting.
Loads the glossaries-extra-stylemods package, which patches the predefined glossary styles. The argument is optional. If present, this will also load glossary- for each .sty in the comma-separated . See the glossaries-extra manual for further details.
2.4. Indexing Options[link]
(This option is only relevant with makeindex and xindy.) The see key automatically indexes the cross-referenced entry using\glssee
. This means that if this
key is used in an entry definition before the relevant
indexing file has been opened, the indexing can’t be performed.
Since this is easy to miss, the glossaries package by
default issues an error message if the see key is used
before \makeglossaries
.
This option may take one of the following values:
This is the default setting that issues an error message.This setting will trigger a warning rather than an error.
This setting will do nothing.
For example, if you want to temporarily comment out
\makeglossaries
to speed up the compilation of a draft document
by omitting the indexing, you can use
seenoindex=warn or seenoindex=ignore.
Only applicable to makeindex and xindy. As from v4.50, the initial setting is now esclocations=false. Previously it was esclocations=true.
Both makeindex and xindy are fussy about the location syntax (makeindex more so than xindy) so, if esclocations=true, the glossaries package will try to ensure that special characters are escaped, which allows for the location to be substituted for a format that’s more acceptable to the indexing application. This requires a bit of trickery to circumvent the problem posed by TeX’s asynchronous output routine, which can go wrong and also adds to the complexity of the document build.
If you’re sure that your locations will always expand to an acceptable format (or you’re prepared to post-process the glossary file before passing it to the relevant indexing application) then use esclocations=false to avoid the complex escaping of location values. This is now the default.
If, however, your locations (for example, \thepage
with the
default counter=page) expand to a robust command
then you may need to use esclocations=true. You may
additionally need to set the following conditional to true:
\thepage
.
Since this hack may cause some issues and isn’t necessary for the
majority of documents, this is off by default.
This conditional can be switched on with:
but remember that it will have no effect with esclocations=false. If can be switched off with:
If you are using makeindex and your location expands to
content in the form , where { } is
a command (optionally preceded by
\protect
) and is a
location acceptable to makeindex, then you can use
makeglossaries to make a suitable adjustment without
esclocations=true. See §12.5
for furthe details.
This isn’t an issue for Options 1 or 4 as the locations are written to the aux file and both methods use LaTeX syntax, so no conversion is required.
If true, this setting will only index on first use. The default setting indexonlyfirst=false, will index the entry every time one of the
\gls
-like or \glstext
-like commands are used. Note that \glsadd
will always add information to the external glossary
file (since that’s the purpose of that command).
You can test if this setting is on using the conditional:
This setting can also be switched on with: and off with:
\glsreset
after an entry has been indexed will cause that entry to be
indexed multiple times if it’s used again after the reset.
Likewise unsetting the first use flag before an entry has been
indexed will prevent it from being indexed (unless specifically
indexed with \glsadd
).
You can customise the default behaviour by redefining
where is the entry’s label and is the code that writes the entry’s information to the external file. The default definition of\glswriteentry
is:
This does unless indexonlyfirst=true and the entry identified by has been marked as used\newcommand
*{\glswriteentry
}[2]{%\ifglsindexonlyfirst
\ifglsused
{#1}{}{#2}%\else
#2%\fi
}
For example, suppose you only want to index the first use for
entries in the acronym
glossary and not in the
main
(or any other) glossary:
Here I’ve used\renewcommand
*{\glswriteentry
}[2]{%\ifthenelse
\equal
{\glsentrytype
{#1}}{acronym} {\ifglsused
{#1}{}{#2}}% {#2}% }
\ifthenelse
to ensure the arguments of
\equal
are fully expanded before the comparison is made.
There are other methods of performing an expanded string comparison,
which you may prefer to use.
With the glossaries-extra package it’s possible to only index first use for particular categories. For example, if you only want this enabled for abbreviations then you can set the indexonlyfirst attribute for the abbreviation and, if appropriate, acronym categories. (Instead of using the indexonlyfirst package option.) See the glossaries-extra manual for further details.
This option is only available with glossaries-extra.
If true, this will automatically index (\glsadd
) any
cross-referenced entries that haven’t been marked as used at the end
of the document. Note that this increases the document build time. See
glossaries-extra manual for further details.
This option is only available with glossaries-extra. The base glossaries package always implements autoseeindex=true.
If true, this makes the see and
seealso keys automatically index the entry
(with \glssee
) when the entry is defined. This means that any
entry with the see (or seealso) key will
automatically be added to the glossary. See the
glossaries-extra manual for further details.
This option is only available with glossaries-extra. See glossaries-extra manual for further details. A brief summary of available values:
This default setting indicates that bib2gls isn’t being used.
This setting indicates that bib2gls is being used to fetch entries from one or more bib files, to sort the entries and collate the number lists, where the location information is the same as for Options 1, 2 and 3.
This setting is like record=only but provides extra information that allows the associated title to be used instead of the location number and provides better support for hyperlinked locations.
This setting indicates a hybrid approach where bib2gls is used to fetch entries from one or more bib files but makeindex or xindy are used for the indexing. This requires a more complicated document build and isn’t recommended.
This option is only available with glossaries-extra. If true, this option will cause the default location counter to automatically switch to equation when inside a numbered equation environment.
This option is only available with glossaries-extra.
If true, this option will cause the default location counter
to automatically switch to the corresponding counter when inside a
float. (Remember that with floats it’s the \caption
command that
increments the counter so the location will be incorrect if an entry
is indexed within the float before the caption.)
This option is only available with glossaries-extra. This valueless option is primarily intended for use with bib2gls and hyperref allowing the page location hyperlink target to be set to the relevant point within the page (rather than the top of the page). Unexpected results will occur with other indexing methods. See glossaries-extra manual for further details.
2.5. Sorting Options[link]
This section is mostly for Options 2 and 3. Only the sort and order options are applicable for Option 1.
\GlsXtrLoadResources
not with the sort package option. There’s no sorting
with Options 5 and 6.
This option determines whether or not to sanitize the sort value when writing to the external indexing file. For example, suppose you define an entry as follows:
The sort value () must be sanitized before writing it to the indexing file, otherwise LaTeX will try to interpret it as a parameter reference. If, on the other hand, you want the sort value expanded, you need to switch off the sanitization. For example, suppose you do:\newglossaryentry
{hash}{name={\#
},sort={}, description={hash symbol}}
and you actually want\newcommand
{\mysortvalue
}{AAA}\newglossaryentry
{sample}{% name={sample}, sort={\mysortvalue
}, description={an example}}
\mysortvalue
expanded, so that the entry
is sorted according to AAA
, then use the package option
sanitizesortfalse.
The default for Options 2 and 3 is sanitizesort=true, and the default for Option 1 is sanitizesort=false.
If you use Options 2 or 3, this package option is the only way of specifying how to sort the glossaries. Only Option 1 allows you to specify sort methods for individual glossaries via the sort key in the optional argument of
\printnoidxglossary
. If you have multiple
glossaries in your document and you are using Option 1, only use
the package options
sort=def or sort=use if you want to set this
sort method for all your glossaries.
This setting is only for documents that don’t use
\makeglossaries
(Options 2 or 3) or
\makenoidxglossaries
(Option 1). It omits the code used
to sanitize or escape the sort value, since it’s not required. This
can help to improve the document build speed, especially if there
are a large number of entries. This setting may be used if no
glossary is required or if \printunsrtglossary
is used
(Option 5). If you want an unsorted glossary with
bib2gls, use the resource option sort=none
instead. This option will redefine \glsindexingsetting
to
none
.
As sort=none but sets the sort key to an empty value. This will affect letter group formations in
\printunsrtglossary
with Option 5. See the
glossaries-extra manual for further details. This option will
redefine \glsindexingsetting
to none
. The remaining
sort options listed below don’t change \glsindexingsetting
.
Entries are sorted in the order in which they were defined. With Option 1, this is implemented by simply iterating over all defined entries so there’s no actual sorting. With Options 2 and 3, sorting is always performed (since that’s the purpose of makeindex and xindy). This means that to obtain a list in order of definition, the sort key is assigned a numeric value that’s incremented whenever a new entry is defined.
Entries are sorted according to the order in which they are used in the document. With Option 1, this order is obtained by iterating over a list that’s formed with the aux file is input at the start of the document. With Options 2 and 3, again the sort key is assigned a numeric value, but in this case the value is incremented, and the sort key is assigned, the first time an entry is indexed.
Both sort=def and sort=use zero-pad the sort key to a six digit number using:
This can be redefined, if required, before the entries are defined (in the case of sort=def) or before the entries are used (in the case of sort=use).Note that the group styles (such as listgroup) are incompatible with the sort=use and sort=def options.
Entries are sorted according to the value of the sort key used in
\newglossaryentry
(if present) or the name
key (if sort key is missing).
When the standard sort option is in use, you can hook into the sort mechanism by redefining:
where is a temporary control sequence that stores the sort value (which was either explicitly set via the sort key or implicitly set via the name key) before any escaping of the makeindex/xindy special characters is performed. By default\glsprestandardsort
just does:
which sanitizes if sanitizesort=true
(or does nothing if sanitizesort=false).
The other arguments, glossary type and the entry label for the current entry. Note that
will always be a control sequence, but will
be in the form used in the first argument of \newglossaryentry
.
\glsprestandardsort
won’t affect any entries that
have already been defined and will have no effect at all if you
use another sort setting.
main
,
acronym
and notation
, and let’s suppose
I want the main
and acronym
glossaries to be
sorted alphabetically, but the notation
type should be
sorted in order of definition.
For Option 1, the sort option can be
used in \printnoidxglossary
:
\printnoidxglossary
[sort=word]\printnoidxglossary
[type=acronym
,sort=word]\printnoidxglossary
[type=notation,sort=def]
For Options 2 or 3, I can set sort=standard
(which is the default), and I can either define
all my main
and acronym
entries, then
redefine \glsprestandardsort
to set to
an incremented integer, and then define all my
notation
entries. Alternatively, I can redefine
\glsprestandardsort
to check for the glossary type and only
modify if is notation
.
The first method can be achieved as follows:
The second method can be achieved as follows:\newcounter
{sortcount}\renewcommand
{\glsprestandardsort
}[3]{%\stepcounter
{sortcount}%\edef
#1{\glssortnumberfmt
{\arabic
{sortcount}}}% }
(\newcounter
{sortcount}\renewcommand
{\glsprestandardsort
}[3]{%\ifdefstring
{#2}{notation}% {%\stepcounter
{sortcount}%\edef
#1{\glssortnumberfmt
{\arabic
{sortcount}}}% }% {%\glsdosanitizesort
}% }
\ifdefstring
is defined by the etoolbox package, which
is automatically loaded by glossaries.)
For a complete document, see the sample file sampleSort.tex.
\name
{first-name}{surname} that you can use in the
name key when you define the entry, but hook into the
standard sort mechanism to temporarily redefine \name
while the
sort value is being set.
First, define two commands to set the person’s name:
and\newcommand
{\sortname
}[2]{#2, #1}\newcommand
{\textname
}[2]{#1 #2}
\name
needs to be initialised to \textname
:
Now redefine\let
\name
\textname
\glsprestandardsort
so that it temporarily sets
\name
to \sortname
and expands the sort value, then sets
\name
to \textname
so that the person’s name appears as
in the text:
(The somewhat complicate use of\renewcommand
{\glsprestandardsort
}[3]{%\let
\name
\sortname
\edef
#1{\expandafter
\expandonce
\expandafter
{#1}}%\let
\name
\textname
\glsdosanitizesort
}
\expandafter
etc helps to
protect fragile commands, but care is still needed.)
Now the entries can be defined:
For a complete document, see the sample file samplePeople.tex.\newglossaryentry
{joebloggs}name={\name
{Joe}{Bloggs}}, description={some information about Joe Bloggs}\newglossaryentry
{johnsmith}{name={\name
{John}{Smith}}, description={some information about John Smith}}
This may take two values:
Word order (“sea lion” before “seal”).
Letter order (“seal” before “sea lion”).
If you use Option 1, this setting will be used if you use
sort=standard in
the optional argument of \printnoidxglossary
:
\printnoidxglossary
[sort=standard]
Alternatively, you can specify the order for individual
glossaries:
\printnoidxglossary
[sort=word]\printnoidxglossary
[type=acronym
,sort=letter]
The glossary information and indexing style file will be written in makeindex format. If you use makeglossaries or makeglossaries-lite, it will automatically detect that it needs to call makeindex. If you don’t use makeglossaries, you need to remember to use makeindex not xindy. The indexing style file will been given a ist extension.
You may omit this package option if you are using Option 2 as this is the default. It’s available in case you need to override the effect of an earlier occurrence of xindy in the package option list.
The glossary information and indexing style file will be written in xindy format. If you use makeglossaries, it will automatically detect that it needs to call xindy. If you don’t use makeglossaries, you need to remember to use xindy not makeindex. The indexing style file will been given a xdy extension.
This package option may additionally have a value that is a xindy. See §14 for further details on using xindy with the glossaries package.
= comma-separated list to override some default options. Note that these options are irrelevant if you explicitly callYou can test if this option has been set using the conditional:
Note that this conditional should not be changed after\makeglossaries
otherwise the syntax in the glossary
files will be incorrect. If this conditional is false, it means that
any option other than Option 3 is in effect. (If you need to
know which indexing option is in effect, check the definition of
\glsindexingsetting
instead.)
The
value may be omitted. If set, it should be a = list, where the following three options may be used:The language module to use, which is passed to xindy with the -L switch. The default is obtained from
\languagename
but note that this may not be correct as xindy has a different
labelling system to babel and polyglossia.
The makeglossaries script has a set of mappings of known babel language names to xindy language names, but new babel dialect names may not be included. The makeglossaries-lite script doesn’t have this feature (but there’s no benefit in use makeglossaries-lite instead of makeglossaries when using xindy). The automake=option that calls xindy explicitly also doesn’t use any mapping.
However, even if the appropriate mapping is available,
\languagename
may still not expand to the language required for
the glossary. In which case, you need to specify the correct
xindy language. For example:
If you have multiple glossaries in different languages, use\usepackage
[brazilian,english]{babel}\usepackage
[xindy=language=portuguese]{glossaries}
\GlsSetXdyLanguage
to set the language for each glossary.
The codepage is the file encoding for the xindy files and is passed to xindy with the -C switch. The default codepage is obtained from
\inputencodingname
. As from v4.50, if
\inputencodingname
isn’t defined, UTF-8 is assumed (which is
identified by the label utf8
). If this is incorrect, you will
need to use the codepage option but make sure you
use the xindy codepage label (for example, cp1252
or
latin9
). See the xindy documentation for further
details.
ij-as-y-utf8
or
din5007-utf8
. See §14.2.
For example:
\usepackage
[xindy=language=english,codepage=cp1252]
{glossaries}
If true, this option will define the number group in the xindy style file, which by default will be placed before the “A” letter group. If you don’t want this letter group, set this option to false. Note that the “A” letter group is only available with Latin alphabets, so if you are using a non-Latin alphabet, you will either need to switch off the number group or identify the letter group that it should come before with
\GlsSetXdyNumberGroupOrder
.
This is equivalent to xindy without any value supplied and may be used as a document class option. The language and code page can be set via
\GlsSetXdyLanguage
and
\GlsSetXdyCodePage
if the defaults are inappropriate
(see §14.2.)
This is equivalent to xindy={glsnumbers=false} and may be used as a document class option.
This option will attempt to use the shell escape to run the appropriate indexing application. You will still need to run LaTeX twice. For example, if the document in the file myDoc.tex contains:
Then the document build is now:\usepackage
[automake]{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={an example}}\begin{document}
\gls
{sample}\printglossaries
\end{document}
pdflatex myDoc pdflatex myDocThis will run makeindex on every LaTeX run. If you have a large glossary with a complex document build, this can end up being more time-consuming that simply running makeindex (either explicitly or via makeglossaries) the minimum number of required times.
If this option doesn’t seem to work, open the log file in
your text editor and search for “runsystem
”. For example, if the
document is in a file called myDoc.tex and it has:
\usepackage
[automake]{glossaries}
and you run LaTeX in restricted mode, then if call was
successful, you should find the following line in the file
myDoc.log:
runsystem(makeindex -s myDoc.ist -t myDoc.glg -o myDoc.gls myDoc.glo)...executed safely (allowed).The parentheses immediately after “
runsystem
” show how the
command was called. The bit after the three dots ...
indicates whether or not the command was run and, if so, whether it
was successful. In the above case, it has “executed safely
(allowed)”. This means that it was allowed to run in restricted
mode because makeindex is on the list of trusted applications.
If you change the package option to:
\usepackage
[automake=makegloss]{glossaries}
and rerun LaTeX in restricted mode, then the line in
myDoc.log will now be:
runsystem(makeglossaries myDoc)...disabled (restricted).This indicates that an attempt was made to run makeglossaries (rather than a direct call to makeindex), which isn’t permitted in restricted mode. There will be a similar message with automake=lite or if the xindy option is used. These cases require the unrestricted shell escape.
runsystem
” to find out exactly
what system calls are being attempted.
If the document is compiled in unrestricted mode, the corresponding line in the log file should now be:
runsystem(makeglossaries myDoc)...executed.This means that makeglossaries was run. If it has “failed” instead of “executed”, then it means there was a fatal error. Note that just because the log file has “executed” doesn’t mean that the application ran without a problem as there may have been some warnings or non-fatal errors. If you get any unexpected results, check the indexing application’s transcript file (for example, the glg file, myDoc.glg in the above, for the
main
glossary).
No attempt is made to use the shell escape.
This is now a deprecated synonym for automake=delayed. This used to be the default if the value to automake wasn’t supplied, but the default switched to the less problematic automake=immediate in version 4.50.
A direct call to makeindex or xindy (as appropriate) for each non-empty glossary will be made at the end of the document using a delayed write to ensure that the glossary files are complete. (It’s necessary to delay writing to the indexing files in order to ensure that
\thepage
is
correct.) Unfortunately, there are situations where the delayed
write never occurs, for example, if there are floats on the final
page. In those cases, it’s better to use an immediate write (any of
the following options).
A direct call to makeindex or xindy (as appropriate) for each non-empty glossary will be made at the start of
\makeglossaries
using an immediate write. This ensures that the
indexing files are read by the indexing application before they
are opened (which will clear their content).
If you are using xindy, then automake=makegloss is a better option that this one. Either way, you will need Perl and the unrestricted mode, but with makeglossaries you get the benefit of the language mappings and diagnostics.
A call to makeglossaries will be made at the start of
\makeglossaries
using an immediate write if the aux file
exists. On the one hand, it’s better to use makeglossaries as
it has some extra diagnostic functions, but on the other hand it
both requires Perl and the unrestricted shell escape.
A call to makeglossaries-lite will be made at the start of
\makeglossaries
using an immediate write if the aux file
exists. There’s little benefit in this option over
automake=immediate and it has the added disadvantage
of requiring the unrestricted mode.
This valueless option is equivalent to automake=makegloss.
This valueless option is equivalent to automake=lite.
This valueless option indicates that
\makeglossaries
and
\makenoidxglossaries
should be disabled. This option is
provided in the event that you have to use a class or package that
disregards the advice in §1.3 and
automatically performs \makeglossaries
or
\makenoidxglossaries
but you don’t want this. (For example,
you want to use a different indexing method or you want to
disable indexing while working on a draft document.)
Naturally, if there’s a particular reason why the class or package insists on a specific indexing method, for example, it’s an editorial requirement, then you will need to abide by that decision.
This option may be passed in the standard document class option list
or passed using \PassOptionsToPackage
before glossaries is
loaded. Note that this does nothing if
\makeglossaries
or \makenoidxglossaries
has already
been used whilst enabled.
Cancels the effect of disablemakegloss. This option may be used in
\setupglossaries
. It issues a warning if \makeglossaries
or
\makenoidxglossaries
has already been used whilst enabled.
Note that this option removes the check for \nofiles
, as this
option is an indication that the output files are actually required.
For example, suppose the class customclass.cls
automatically loads glossaries and does \makeglossaries
but you need an extra glossary, which has to be defined before
\makeglossaries
, then you can do:
or\documentclass
[disablemakegloss]{customclass}\newglossary*
{functions}{Functions}\setupglossaries
{restoremakegloss}\makeglossaries
\PassOptionsToPackage
{disablemakegloss}{glossaries}\documentclass
{customclass}\newglossary*
{functions}{Functions}\setupglossaries
{restoremakegloss}\makeglossaries
Note that restoring these commands doesn’t necessarily mean that they can be
used. It just means that their normal behaviour given the current
settings will apply. For example, if you use the record=only
or record=nameref options with glossaries-extra
then you can’t use \makeglossaries
or \makenoidxglossaries
regardless of restoremakegloss.
2.6. Glossary Type Options[link]
Use this option if you have multiple glossaries and you want to suppress the entry hyperlinks for a particular glossary or glossaries. The value of this option should be a comma-separated list of glossary types where
\gls
etc
shouldn’t have hyperlinks by default. Make sure you enclose the
value in braces if it contains any commas. Example:
As illustrated above, the glossary doesn’t need to exist when you identify it in nohypertypes.\usepackage
[acronym,nohypertypes={acronym
,notation}] {glossaries}\newglossary
[nlg]{notation}{not}{ntn}{Notation}
You may also use:
instead or additionally. See §5.1 for further details.
This suppresses the creation of the
main
glossary and associated glo file, if unrequired. Note that
if you use this option, you must create another glossary in which to
put all your entries (either via the acronym (or
acronyms) package option described in
§2.7 or via the symbols,
numbers or index options described in
§2.9 or via \newglossary
described in
§9). Even if you don’t intend to display
the glossary, a default glossary is still required.
If you don’t use the main
glossary and you don’t use this
option to suppress its creation, makeglossaries will produce a warning:
Warning: File ' .glo' is empty. Have you used any entries defined in glossary 'If you did actually want to use themain
'? Remember to use package option 'nomain' if you don't want to use themain
glossary.
main
glossary and you see this
warning, check that you have referenced the entries in that glossary
via commands such as \gls
.
This valueless option defines a new glossary type with the label
symbols
via
It also defines which is a synonym for\newglossary
[slg]{symbols
}{sls}{slo}{\glssymbolsgroupname
}
\printglossary
[type=symbols
, ]
If you use Option 1, you need to use:
to display the list of symbols.\printnoidxglossary
[type=symbols
, ]
symbols
glossary and don’t intend
to use the main
glossary.
\glsxtrnewsymbol
as a convenient shortcut method for defining symbols. See the
glossaries-extra manual for further details.
This valueless option defines a new glossary type with the label
numbers
via
It also defines which is a synonym for\newglossary
[nlg]{numbers
}{nls}{nlo}{\glsnumbersgroupname
}
\printglossary
[type=numbers
, ]
If you use Option 1, you need to use:
to display the list of numbers.\printnoidxglossary
[type=numbers
, ]
numbers
glossary and don’t intend
to use the main
glossary.
\glsxtrnewnumber
as a convenient shortcut method for defining numbers. See the
glossaries-extra manual for further details.
This valueless option defines a new glossary type with the label
index
via
It also defines which is a synonym for\newglossary
[ilg]{index
}{ind}{idx}{\indexname
}
and which is a synonym for\newglossaryentry
{ }{type={index
},name={entry-label}, description={\nopostdesc
}, }
\printglossary
[type=index
, ]
If you use Option 1, you need to use:
to display this glossary.\printnoidxglossary
[type=index
, ]
index
glossary and don’t intend to
use the main
glossary. Note that you
can’t mix this option with \index
. Either use
glossaries for the indexing or use a custom indexing
package, such as makeidx, imakeidx.
(You can, of course, load one of those packages and
load glossaries without the index package option.)
Since the index isn’t designed for terms with descriptions, you might also want to disable the hyperlinks for this glossary using the package option nohypertypes=index or the command
However, it can also be useful to link to the index in order to look up the term’s location list to find other parts of the document where it might be used. For example, this manual will have a hyperlink to the index for general terms, such as “table of contents”, or general commands, such as\GlsDeclareNoHyperList
{index
}
\index
, that aren’t defined anywhere in the document.
The example file sample-index.tex illustrates the use of the index package option.
This valueless option switches off index if index has been passed implicitly (for example, through global document options). This option can’t be used in
\setupglossaries
.
2.7. Acronym and Abbreviation Options[link]
If true, this creates a new glossary with the labelacronym
. This is equivalent to:
It will also provide (if not already defined) that’s equivalent to\newglossary
[alg]{acronym
}{acr}{acn}{\acronymname
}
\printglossary
[type=acronym
, ]
If you are using Option 1, you need to use
to display the list of acronyms.\printnoidxglossary
[type=acronym
, ]
If the acronym package option is used, \acronymtype
is
set to acronym
otherwise it is set to
\glsdefaulttype
(which is normally the main
glossary.) Entries that are defined using \newacronym
are
placed in the glossary whose label is given by \acronymtype
,
unless another glossary is explicitly specified with the
type key.
acronym
glossary. (That is, you
don’t intend to use the main
glossary.)
abbreviations
and sets the command
\glsxtrabbrvtype
to this. If the acronym option hasn’t
also been used, then \acronymtype
will be set to
\glsxtrabbrvtype
. This enables both \newacronym
and
\newabbreviation
to use the same glossary.
Make sure you have at least v1.42 of glossaries-extra if you use the acronym (or acronyms) package option with the extension package to avoid a bug that interferes with the abbreviation style.
This is equivalent to acronym=true and may be used in the document class option list.
This valueless option provided by glossaries-extra creates a new
glossary type with the label
abbreviations
using:
The label can be accessed with\newglossary
[glg-abr]{abbreviations
}{gls-abr}{glo-abr}{\abbreviationsname
}
\glsxtrabbrvtype
, which is
analogous to \acronymtype
. See glossaries-extra manual for
further details.
This option is used to identify the glossaries that contain acronyms so that they can have their entry format adjusted by
\setacronymstyle
. (It also enables \forallacronyms
to
work.)
By default, if the list is empty when \setacronymstyle
is used
then it will automatically add \acronymtype
to the list.
If you have other lists of acronyms, you can specify them as
a comma-separated list in the value of acronymlists. For
example, if you use the acronym package option but you also
want the main
glossary to also contain a list of
acronyms, you can do:
No check is performed to determine if the listed glossaries exist, so you can add glossaries you haven’t defined yet. For example:\usepackage
[acronym,acronymlists=main
]{glossaries}
You can use instead of or in addition to the acronymlists option. This will add the glossaries given in to the list of glossaries that are identified as lists of acronyms. To replace the list of acronym lists with a new list use:\usepackage
[acronym,acronymlists={main
,acronym2}] {glossaries}\newglossary
[alg2]{acronym2}{acr2}{acn2}% {Statistical Acronyms}
If the list is changed after \setacronymstyle
then it will result in inconsistencies in the formatting. If this does
happen, and is for some reason unavoidable (such as
\setacronymstyle
occurring in a package that loads
glossaries), you will need to set the entry format to
match the style:
\DeclareAcronymList
{ }\defglsentryfmt
[ ]{\GlsUseAcrEntryDispStyle
}{ }
You can determine if a glossary has been identified as being a list of acronyms using:
This option provides shortcut commands for acronyms. See §6 for further details. Alternatively you can use:
2.8. Deprecated Acronym Style Options[link]
The package options listed in this section were deprecated in version 4.02 (2013-12-05) and have now been removed. You will need to use rollback with them (see §1.1). These options started generating warnings in version 4.47 (2021-09-20) and as from version 4.50 will now generate an error unless you use rollback.
If you want to change the acronym style, use \setacronymstyle
instead. See §6 for further details.
This option changed the definition of
\newacronym
to allow a description.
This option may be replaced by:
\setacronymstyle
{long-short-desc}
or (with smallcaps)
\setacronymstyle
{long-sc-short-desc}
or (with smaller)
\setacronymstyle
{long-sm-short-desc}
or (with footnote)
\setacronymstyle
{footnote-desc}
or (with footnote and smallcaps)
\setacronymstyle
{footnote-sc-desc}
or (with footnote and smaller)
\setacronymstyle
{footnote-sm-desc}
or (with dua)
\setacronymstyle
{dua-desc}
This option changed the definition of
\newacronym
and the way that acronyms are displayed.
This option may be replaced by:
\setacronymstyle
{long-sc-short}
or (with description)
\setacronymstyle
{long-sc-short-desc}
or (with description and footnote)
\setacronymstyle
{footnote-sc-desc}
This option changed the definition of
\newacronym
and the way that acronyms are displayed.
This option may be replaced by:
\setacronymstyle
{long-sm-short}
or (with description)
\setacronymstyle
{long-sm-short-desc}
or (with description and footnote)
\setacronymstyle
{footnote-sm-desc}
This option changed the definition of
\newacronym
and the way that acronyms are displayed.
This option may be replaced by:
\setacronymstyle
{footnote}
or (with smallcaps)
\setacronymstyle
{footnote-sc}
or (with smaller)
\setacronymstyle
{footnote-sm}
or (with description)
\setacronymstyle
{footnote-desc}
or (with smallcaps and description)
\setacronymstyle
{footnote-sc-desc}
or (with smaller and description)
\setacronymstyle
{footnote-sm-desc}
This option changed the definition of
\newacronym
so that acronyms are always expanded.
This option may be replaced by:
\setacronymstyle
{dua}
or (with description)
\setacronymstyle
{dua-desc}
2.9. Other Options[link]
Other available options that don’t fit any of the above categories are described below.
Only available with glossaries-extra, this option loads the glossaries-accsupp package, which needs to be loaded either before glossaries-extra or while glossaries-extra is loaded to ensure both packages are properly integrated.
Only available with glossaries-extra, this option loads the glossaries-prefix package.
This option may be used to suppress the boilerplate text generated
by \printglossary
if the indexing file is missing.
The value may be either expanded or unexpanded and performs the same function as mfirstuc’s expanded and unexpanded package options. Note that there’s no value corresponding to mfirstuc’s other package option.
The default is mfirstuc=unexpanded to safeguard against
glossary styles that convert the description to
sentence case. With older versions of mfirstuc
(pre v2.08), fragile commands in the description would not have been
affected by the case change, but now, if the entire description is passed
to \MFUsentencecase
, it will be expanded, which could break
existing documents.
Compatibility mode for old documents created using version 2.07 or below. This option is now only available with rollback (see §1.1).
Compatibility mode for old documents created using version 3.07 or below. This option is now only available with rollback (see §1.1).
As a legacy from the precursor glossary package, the standard glossary commands provided by the LaTeX kernel (
\makeglossary
and \glossary
) are redefined in terms of the glossaries
package’s commands. However, they were never documented in this
user manual, and the conversion guide (“Upgrading from the
glossary package to the glossaries package”)
explicitly discourages their use.
The redefinitions of these commands was removed in v4.10, but unfortunately it turned out that some packages had hacked the internal commands provided by glossaries and no longer worked when they were removed, so they were restored in v4.41 with this option to undo the effect with kernelglossredefs=true as the default. As from v4.50, the default is now kernelglossredefs=false.
Don’t redefine
\glossary
and \makeglossary
. If they have
been previously redefined by kernelglossredefs their original
definitions (at the time glossaries was loaded) will be
restored.
Redefine
\glossary
and \makeglossary
, but their use will
trigger warnings.
Redefine
\glossary
and \makeglossary
without any warnings.
The only glossary-related commands provided by the LaTeX kernel are \makeglossary
and \glossary
. Other packages
or classes may provide additional glossary-related commands or
environments that conflict with glossaries (such as
\printglossary
and theglossary). These non-kernel commands
aren’t affected by this package option, and you will have to find
some way to resolve the conflict if you require both glossary
mechanisms. (The glossaries package will override the existing
definitions of \printglossary
and theglossary.)
In general, if possible, it’s best to stick with just one package that
provides a glossary mechanism. (The glossaries package does
check for the doc package and patches \PrintChanges
.)
2.10. Setting Options After the Package is Loaded[link]
Some of the options described above may also be set after the glossaries package has been loaded using
The following package options can’t be used in\setupglossaries
: xindy, xindygloss,
xindynoglsnumbers, makeindex,
nolong, nosuper, nolist,
notree, nostyles, nomain,
compatible-2.07, translate, notranslate,
languages, acronym. These options have to be set while the package is
loading, except for the xindy sub-options which can be set
using commands like \GlsSetXdyLanguage
(see
§14 for further details).
3. Setting Up[link]
In the preamble you need to indicate which method you want to use to generate the glossary (or glossaries). The available options with both glossaries and glossaries-extra are summarized in §1.3. This chapter documents Options 1, 2 and 3, which are provided by the base package. See the glossaries-extra and bib2gls manuals for the full documentation of the other options.
If you don’t need to display any glossaries, for example, if you are just using the glossaries package to enable consistent formatting, then skip ahead to §4.
3.1. Option 1[link]
The command
must be placed in the document preamble. This sets up the internal commands required to make Option 1 work. If you omit\makenoidxglossaries
none of
the glossaries will be displayed.
3.2. Options 2 and 3[link]
The command
must be placed in the document preamble in order to create the customised makeindex (ist) or xindy (xdy) style file (for Options 2 or 3, respectively) and to ensure that glossary entries are written to the appropriate output files. If you omit\makeglossaries
none of
the indexing files will be created.
\makeglossaries
has an
optional argument that allows you to have a hybrid of Options 1 or 2 or
Options 1 or 3. See glossaries-extra manual for further details.
\makeglossaries
as they are
required when creating the customised style file. If you attempt
to use those commands after \makeglossaries
you will generate
an error.
Similarly, there are some commands that must not be used before
\makeglossaries
because they require the associated
indexing files to be open, if those files should be created.
These may not necessarily generate an error or warning as a
different indexing option may be chosen that doesn’t require
those files (such as Options 5 or 6).
The \makeglossaries
command internally uses:
\relax
so
that it can only be used once. In general, there should be no reason
to use or alter this command.
The default name for the customised style file is given by
(Option 2) or
\jobname
.ist
(Option 3). This name may be
changed using:
\jobname
.xdy
There is a hook near the end of \writeist
that can be set with:
\writeist
to prevent an
unnecessary write register from being created in the event that neither makeindex
nor xindy is required.
If you use the \GlsSetWriteIstHook
hook to write extra
information to the style file, make sure you use the appropriate
syntax for the desired indexing application. For example, with
makeindex:
This changes the page precedence and the maximum line length used by makeindex.\GlsSetWriteIstHook
{%\write
\glswrite
{page_precedence "arnAR"}%\write
\glswrite
{line_max 80}% }
Remember that if you switch to xindy, this will no longer be valid code.
You can suppress the creation of the customised xindy or makeindex style file using:
This is provided in the event that you want to supply your own customized style file that can’t be replicated with the available options and commands provided by the glossaries package. This command sets\writeist
to \relax
(making it do
nothing) but will also update the xindy
attribute list if applicable.
If you have a custom xdy file created when using glossaries version 2.07 (2010-0710) or below, you will need to use rollback and the compatible-2.07 package option with it. However, that is now so dated and the LaTeX kernel has changed significantly since that time that you may need to use a legacy distribution (see Legacy Documents and TeX Live Docker Images).
Each glossary entry is assigned a number list that lists all the locations in the document where that entry was used. By default, the location refers to the page number but this may be overridden using the counter package option. The default form of the location number assumes a full stop compositor (for example, 1.2), but if your location numbers use a different compositor (for example, 1-2) you need to set this using
{symbol} For example:\glsSetCompositor
{-}
This command must not be used after \makeglossaries
. Note that
with makeindex, any locations with the wrong compositor
(or one that hasn’t been correctly identified with
\glsSetCompositor
) will cause makeindex to reject the
location with an invalid number/digit message. As from
v4.50, makeglossaries will check for this message and attempt
a correction, but this can result in an incorrectly formatted
location in the number list. See the information about
makeglossaries’s -e switch
in §1.6.1 for further details.
An invalid page number will also cause xindy to fail with a “did not match any location-class” warning. This is also something that makeglossaries will check for and will provided diagnostic information, but it won’t attempt to make any correction.
If you use Option 3, you can have a different compositor for page numbers starting with an upper case alphabetical character using:
This command is only available with xindy. For example, if you want number lists containing a mixture of A-1 and 2.3 style formats, then do:See §12 for further information about number lists.\glsSetCompositor
{.}\glsSetAlphaCompositor
{-}
4. Defining Glossary Entries[link]
Acronyms are covered in §6 but they use the
same underlying mechanism as all the other glossary entries, so it’s a good
idea to read this chapter first. The keys provided for
\newglossaryentry
can also be used in the optional argument of
\newacronym
, although some of them, such as first and
plural, interfere with the acronym styles.
All glossary entries must be defined before they are used, so it is
better to define them in the document preamble to ensure this. In fact, some
commands such as \longnewglossaryentry
may only be used in the preamble. See §4.8 for
a discussion of the problems with defining entries within the
document instead of in the preamble. (The glossaries-extra
package has an option that provides a restricted form of document
definitions that avoids some of the issues discussed in
§4.8.)
\newglossaryentry
. Option 4 requires that definitions are provided
in bib format. Options 5 and 6 work best with either
preamble-only
definitions or the use of the glossaries-extra package option
docdef=restricted.
Bear in mind that with docdef=restricted, the
entries must be defined before any entries are used,
including when they are displayed in the glossary (for example, with
\printunsrtglossary
) or where they appear in the
table of contents or list of floats. This is essentially the
same problem as defining a robust command mid-document and using it
in a section title or caption.
Only those entries that are indexed in the document (using any of the commands described in §5.1, §10 or §11) will appear in the glossary. See §8 to find out how to display the glossary.
New glossary entries are defined using the command:
This is a short command, so values in can’t contain any paragraph breaks. Take care to enclose values containing any commas (,
) or equal signs (=
) with braces to hide them
from the = list parser.
If you have a long description that needs to span multiple paragraphs, use the following instead:
Note that this command may only be used in the preamble (regardless of docdef).
\longnewglossaryentry
will remove trailing spaces in the
description (via \unskip
) but won’t remove leading spaces. This
command also appends \nopostdesc
to the end of the description,
which suppresses the post-description hook (since the terminating
punctuation is more likely to be included in a multi-paragraph
description). The glossaries-extra package provides a starred
version of \longnewglossaryentry
that doesn’t append either
\unskip
or \nopostdesc
.
There are also commands that will only define the entry if it hasn’t already been defined:
and (These are both preamble-only commands.)
For all the above commands, the first argument, entry. This can’t contain
any non-expandable or fragile commands. The reason for
this restriction is that the label is used to construct internal commands
that store the associated information (similarly to commands
like \label
) and therefore must be able to expand to a valid
control sequence name. With modern LaTeX kernels, you should now
be able to use UTF-8 characters in the label.
:
) or double-quote
("
), to active characters.
The second argument, description and either name or parent.
The description is set in the third argument of
\longnewglossaryentry
and \longprovideglossaryentry
. With
the other commands it’s set via the description key.
As is typical with ,
) or equal sign (=
) must be
enclosed in braces. Available fields
are listed below. Additional fields are provided by the
supplementary packages glossaries-prefix
(§16) and glossaries-accsupp
(§17) and also by glossaries-extra.
You can also define your own custom keys (see
§4.3).
The name of the entry (as it will appear in the glossary). If this key is omitted and the parent key is supplied, this value will be the same as the parent’s name.
A brief description of this term (to appear in the glossary). Within this value, you can use: to suppress the description terminator for this entry. For example, if this entry is a parent entry that doesn’t require a description, you can do description={
\nopostdesc
}. If you want a paragraph
break in the description use:
or, better, use \longnewglossaryentry
.
However, note that not all glossary styles support multi-line
descriptions. If you are using one of the tabular-like
glossary styles that permit multi-line descriptions and you
really need an explicit line break, use \newline
not \\
(but in general, avoid \\
outside of tabular contexts anyway
and use a ragged style if you are having problems
with line breaks in a narrow column).
\glsxtrnopostpunc
instead of
\nopostdesc
to suppress the post-description punctuation.
This key establishes the entry’s hierarchical level. The value must be the label of the parent entry (not the name, although they may be the same). The value must match the used when the parent entry was defined. See §4.5 for further details.
The plural form of the description, if required. If omitted, the value is set to the same as the description key.
How this entry will appear in the document text when using
\gls
on subsequent use. If this
field is omitted, the value of the name key is used.
This key is automatically set by \newacronym
. Although it is
possible to override it by using text in the optional
argument of \newacronym
, it will interfere with the
acronym style and cause unexpected results.
How the entry will appear in the document text on first use with
\gls
. If this field is omitted, the value of the
text key is used. Note that if you use \glspl
,
\Glspl
, \GLSpl
, \glsdisp
before using \gls
, the
first value won’t be used with \gls
.
You may prefer to use acronyms (§6) or the
abbreviations or the category post-link hook (\glsdefpostlink
) provided by
glossaries-extra if you would like to automatically append
content on first use in a consistent manner. See, for example,
Gallery: Units (glossaries-extra.sty).
Although it is possible to use first in the optional
argument of \newacronym
, it can interfere with the
acronym style and cause unexpected results.
How the entry will appear in the document text when using
\glspl
on subsequent use. If this
field is omitted, the value is obtained by appending
\glspluralsuffix
to the value of the text field.
Although it is possible to use plural in the optional
argument of \newacronym
, it can interfere with the
acronym style and cause unexpected results. Use shortplural
instead, if the default value is inappropriate.
How the entry will appear in the document text on first use with
\glspl
.
If this field is omitted, the value is obtained
from the plural key, if the first key is omitted,
or by appending \glspluralsuffix
to the value of the
first field, if the first field is present. Note
that if you use \gls
, \Gls
, \GLS
, \glsdisp
before
using \glspl
, the firstplural value won’t be used
with \glspl
.
Although it is possible to use firstplural in the optional
argument of \newacronym
, it can interfere with the
acronym style and cause unexpected results. Use shortplural
and longplural instead, if the default value is inappropriate.
This field is provided to allow the user to specify an associated symbol. If omitted, the value is set to
\relax
. Note that not all glossary styles display the symbol.
This is the plural form of the symbol. If omitted, the value is set to the same as the symbol key.
This value indicates the text to be used by the sort comparator when ordering all the glossary entries. If omitted, the value is given by the name field unless one of the package options sort=def and sort=use have been used. With Option 2 it’s best to use the sort key if the name contains commands (for example,
\ensuremath
{\alpha}
) and with
Options 2 and 3, it’s strongly recommended as the indexing
may fail if you don’t (see below).
You can also override the sort key by redefining
\glsprestandardsort
(see §2.5).
Option 1 by default strips the standard LaTeX accents (that is, accents generated by core LaTeX commands) from the name key when it sets the sort key. So with Option 1:
This is equivalent to:\newglossaryentry
{elite}{ name={\'
elite}, description={select group of people} }
Unless you use the package option sanitizesort=true, in which case it’s equivalent to:\newglossaryentry
{elite}{ name={\'
elite}, description={select group of people} sort={elite} }
This will place the entry before the “A” letter group since the sort value starts with a symbol (a literal backslash\newglossaryentry
{elite}{ name={\'
elite}, description={select group of people} sort={\
'
elite}, }
\
).
Note that Option 1 shouldn’t be used with UTF-8
characters. With old LaTeX kernels, it was able to convert a
UTF-8 character, such as é
, to an ASCII
equivalent but this is no longer possible.
With Options 2 and 3, the default value of sort will either be set to the name key (if sanitizesort=true) or it will set it to the expansion of the name key (if sanitizesort=false).
\alpha
}).
Take care if you use Option 1 and the name contains fragile commands. You will either need to explicitly set the sort key or use the sanitizesort=true package option (unless you use the def or use sort methods).
This specifies the label of the glossary in which this entry belongs. If omitted, the default glossary identified by
\glsdefaulttype
is assumed unless \newacronym
is used (see
§6).
Six keys are provided for any additional information the user may want
to specify. (For example, an associated dimension or an alternative
plural or some other grammatical construct.) Alternatively, you can
add new keys using \glsaddkey
or \glsaddstoragekey
(see §4.3).
The first user key.
The second user key.
The third user key.
The fourth user key.
The fifth user key.
The sixth user key.
If the value is missing or is true, this will suppress the number list just for this entry. Conversely, if you have used the package option nonumberlist=true, you can activate the number list just for this entry with nonumberlist={false}. (See §12.)
This key works by adding \glsnonextpages
(nonumberlist={true}) or \glsnextpages
(nonumberlist={false}) to the indexing information
for Options 2 and 3. Note that this means that if the entry is
added to the glossary simply because it has an indexed descendent (and has not been indexed itself) then the first
indexed sub-entry that follows will have its number list suppressed
instead.
With Option 1, this key saves the appropriate command in the
prenumberlist internal field, which is used by
\glsnoidxprenumberlist
.
This key essentially provides a convenient shortcut that performs
\glssee
[ ]{ }{ }
after the entry has been defined. (See §11.)
It was originally designed for synonyms that may not occur in the
document text but needed to be included in the glossary in order to
redirect the reader. Note that it doesn’t index the cross-referenced
entry (or entries) as that would interfere with their number lists.
For example:
This defines two entries (courgette and zucchini) and automatically adds a cross-reference from zucchini to courgette. (That is, it adds “see courgette” to zucchini’s number list.) This doesn’t automatically index courgette since this would create an unwanted location in courgette’s number list. (Page 1, if the definitions occur in the preamble.)\newglossaryentry
{courgette}{name={courgette}, description={variety of small marrow}}\newglossaryentry
{zucchini}{name={zucchini}, description={(North American)}, see={courgette}}
Note that while it’s possible to put the cross-reference in the description instead, for example:
this won’t index the zucchini entry, so if zucchini isn’t indexed elsewhere (with commands like\newglossaryentry
{zucchini}{name={zucchini}, description={(North American) see\gls
{courgette}}}
\gls
or \glsadd
) then it won’t
appear in the glossary even if courgette does.
The referenced entry should be supplied as the value to this key. If you want to override the “see” tag, you can supply the new tag in square brackets before the label. For example see={[see also]{anotherlabel}}.
You can override this for individual glossary entries using nonumberlist={false}. Alternatively, you can use the seeautonumberlist package option. For further details, see §11.
\makeglossaries
must be used before any occurrence of
\newglossaryentry
that contains the see key.
Since it’s useful to suppress the indexing while working on a draft
document, consider using the seenoindex package option to
warn about or ignore the see key while \makeglossaries
is
commented out.
If you use the see key, you may want to consider using the glossaries-extra package which additionally provides a seealso and alias key. If you want to avoid the automatic indexing triggered by the see key, consider using Option 4. See also the FAQ item Why does the see key automatically index the entry?
This key is only available with glossaries-extra and is similar to see but it doesn’t allow for the optional tag. The glossaries-extra package provides
\seealsoname
and
seealso={xr-list} is essentially like
see={[\seealsoname
] }
(Options 3 and 4 may treat these differently).
This key is only available with glossaries-extra and is another form of cross-referencing. An entry can be aliased to another entry with alias={other-label}. This behaves like see={other-label} but also alters the behaviour of commands like
\gls
so that they index the entry
given by instead of the original entry. (See, for example,
Gallery: Aliases.)
This key will set the default location counter for the given entry. This will override the counter assigned to the entry’s glossary in the final optional argument of
\newglossary
(if provided) and the counter
identified by the counter package option. The
location counter can be overridden by the counter
option when using the \gls
-like and \glstext
-like commands.
This key is only available with glossaries-extra and is used to assign a category to the entry. The value should be a label that can be used to identify the category. See glossaries-extra manual for further details.
The following keys are reserved for \newacronym
(see
§6) and also for \newabbreviation
(see the
glossaries-extra manual): long,
longplural,
short and
shortplural.
You can use longplural and shortplural in the
optional argument of \newacronym
(or \newabbreviation
) to
override the defaults, but don’t explicitly use the long
or short keys as that may interfere with
acronym style (or abbreviation style).
The supplementary packages glossaries-prefix (§16) and glossaries-accsupp (§17) provide additional keys.
\gls
-like or \glstext
-like commands within
the text, first, short or
long keys (or their plural equivalent) or any
other key that you plan to access through those commands.
(For example, the symbol key if you intend to use
\glssymbol
.) Otherwise you can up with nested links, which
can cause complications. You can use them within the value of keys
that won’t be accessed through those commands. For example,
the description key if you don’t use \glsdesc
.
Additionally, they’ll confuse the formatting placeholder commands, such as
\glslabel
. The glossaries-extra package provides
\glsxtrp
for this type of situation.
With older LaTeX kernels and pre-2.08 versions of mfirstuc,
if the name starts with non-Latin character, you need to group the character,
otherwise it will cause a problem for commands like \Gls
and \Glspl
.
For example:
% mfirstuc v2.07Note that the same applies with inputenc:\newglossaryentry
{elite}{name={{\'
e}lite}, description={select group or class}}
% mfirstuc v2.07
\newglossaryentry
{elite}{name={{é}lite},
description={select group or class}}
This doesn’t apply for XeLaTeX or LuaLaTeX documents or with
mfirstuc v2.08+.
% mfirstuc v2.08
\newglossaryentry
{elite}{name={élite},
description={select group or class}}
See the mfirstuc manual for further details.
Note that in the above UTF-8 examples, you will also need to supply the sort key if you are using Options 1 or 2 whereas xindy (Option 3) is usually able to sort non-Latin characters correctly.
4.1. Plurals[link]
You may have noticed from above that you can specify the plural form when you define an entry. If you omit this, the plural will be obtained by appending:
to the singular form. This command may expand when the entry is defined, if expansion is on for the relevant keys, or may not expand until the entry is referenced, if expansion is off or if the suffix has been hidden inside non-expanding context (which can happen when defining acronyms or abbreviations).For example:
\newglossaryentry
{cow}{name={cow},description={a fully grown
female of any bovine animal}}
defines a new entry whose singular form is “cow” and plural form
is “cows”. However, if you are writing in archaic English, you
may want to use “kine” as the plural form, in which case you
would have to do:
\newglossaryentry
{cow}{name={cow},plural={kine},
description={a fully grown female of any bovine animal}}
If you are writing in a language that supports multiple plurals (for a given term) then use the plural key for one of them and one of the user keys to specify the other plural form. For example:
\newglossaryentry
{cow}{
name={cow},
description={a fully grown female of any bovine animal
(plural cows, archaic plural kine)},
user1={kine}}
You can then use \glspl
{cow}
to produce “cows” and
\glsuseri
{cow}
to produce “kine”. You can, of course,
define an easy to remember synonym. For example:
Then you don’t have to remember which key you used to store the second plural. (Be careful with using\let
\glsaltpl
\glsuseri
\let
as it doesn’t
check if the command already exists.)
Alternatively, you can define your own keys using
\glsaddkey
, described in §4.3 (or simply use
\glsdisp
or \glslink
with the appropriate text).
If you are using a language that usually forms plurals
by appending a different letter, or sequence of letters, you can
redefine \glspluralsuffix
as required. However, this must be
done before the entries are defined and is unreliable for
multilingual documents. For languages that don’t
form plurals by simply appending a suffix, all the plural forms must be
specified using the plural key (and the firstplural
key where necessary).
4.2. Other Grammatical Constructs[link]
You can use the six user keys to provide alternatives, such as participles. For example:
With the above definitions, I can now define terms like this:\let
\glsing
\glsuseri
\let
\glsd
\glsuserii
\newcommand
*{\ingkey
}{user1}\newcommand
*{\edkey
}{user2}\newcommand
*{\newword
}[3][]{%\newglossaryentry
{#2}{% name={#2},% description={#3},%\edkey
={#2ed},%\ingkey
={#2ing},#1% }}
and use them in the text:\newword
{play}{to take part in activities for enjoyment}\newword
[\edkey
={ran},\ingkey
={running}]{run}{to move fast using the legs}
Peter is\glsing
{play} in the park today. Jane\glsd
{play} in the park yesterday. Peter and Jane\glsd
{run} in the park last week.
Alternatively, you can define your own keys using
\glsaddkey
, described below in §4.3.
It may, however, be simpler just to use \glslink
or
\glsdisp
with the appropriate link text.
4.3. Additional Keys[link]
You can define your own custom keys using the commands described in this section. There are two types of keys: those for use within the document and those to store information used behind the scenes by other commands.
For example, if you want to add a key that indicates the associated
unit for a term, you might want to reference this unit in your
document. In this case use \glsaddkey
described in
§4.3.1. If, on the other hand, you want to add a
key to indicate to a glossary style or acronym style that
this entry should be formatted differently to other
entries, then you can use \glsaddstoragekey
described in
§4.3.2.
In both cases, a new command \glsentrytext
). This can be used in an expandable
context (provided any fragile commands stored in the key have been
protected). The new keys must be added using \glsaddkey
or
\glsaddstoragekey
before glossary entries are defined.
4.3.1. Document Keys[link]
A custom key that can be used in the document is defined using:
where the arguments are as follows:\newglossaryentry
(or similar commands such as \longnewglossaryentry
);
is the default value to use if this key
isn’t used in an entry definition (this may reference the current
entry label via \glslabel
, but you will have to switch on
expansion via the starred version of \glsaddkey
and protect
fragile commands);
is the control sequence to use analogous
to commands like \glsentrytext
;
is the control sequence to use analogous
to commands like \Glsentrytext
;
is the control sequence to use analogous
to commands like \glstext
;
is the control sequence to use analogous
to commands like \Glstext
;
is the control sequence to use analogous
to commands like \GLStext
.
\glsaddkey
switches on expansion for this
key. The unstarred version doesn’t override the current expansion
setting.
% Define "ed" key:Now I can define some entries:\glsaddkey
* {ed}% key {\glsentrytext
{\glslabel
}ed}% default value {\glsentryed
}% command analogous to\glsentrytext
{\Glsentryed
}% command analogous to\Glsentrytext
{\glsed
}% command analogous to\glstext
{\Glsed
}% command analogous to\Glstext
{\GLSed
}% command analogous to\GLStext
% Define "ing" key:\glsaddkey
* {ing}% key {\glsentrytext
{\glslabel
}ing}% default value {\glsentrying
}% command analogous to\glsentrytext
{\Glsentrying
}% command analogous to\Glsentrytext
{\glsing
}% command analogous to\glstext
{\Glsing
}% command analogous to\Glstext
{\GLSing
}% command analogous to\GLStext
% No need to override defaults for this entry:\newglossaryentry
{jump}{name={jump},description={}} % Need to override defaults on these entries:\newglossaryentry
{run}{name={run}, ed={ran}, ing={running}, description={}}\newglossaryentry
{waddle}{name={waddle}, ed={waddled}, ing={waddling}, description={}}
These entries can later be used in the document:
The dogFor a complete document, see the sample file sample-newkeys.tex.\glsed
{jump} over the duck. The duck was\glsing
{waddle} round the dog. The dog\glsed
{run} away from the duck.
4.3.2. Storage Keys[link]
A custom key that can be used for simply storing information is defined using:
where the arguments are as the first three arguments of\glsaddkey
, described above in §4.3.1.
This is essentially the same as \glsaddkey
except that it
doesn’t define the additional commands. You can access or update
the value of your new field using the commands described in
§15.6.
Here I can define a new key that determines whether the term is actually an acronym rather than some other form of abbreviation. I’m going to call this key abbrtype (since type already exists):
\glsaddstoragekey
{abbrtype}% key/field name {word}% default value if not explicitly set {\abbrtype
}% custom command to access the value if required
Now I can define a style that looks up the value of this new key to determine how to display the full form:
Remember that the new style needs to be set before defining any terms:\newacronymstyle
{mystyle}% style name {% Use the generic display\ifglshaslong
{\glslabel
}{\glsgenacfmt
}{\glsgenentryfmt
}% }% {% Put the long form in the description\renewcommand
*{\GenericAcronymFields
}{% description={\the
\glslongtok
}}% % For the full format, test the value of the "abbrtype" key. % If it's set to "word" put the short form first with % the long form in brackets.\renewcommand
*{\genacrfullformat
}[2]{%\ifglsfieldeq
{##
1}{abbrtype}{word} {% is a proper acronym\protect
\firstacronymfont
{\glsentryshort
{##
1}}##
2\space
(\glsentrylong
{##
1})% }% {% is another form of abbreviation\glsentrylong
{##
1}##
2\space
(\protect
\firstacronymfont
{\glsentryshort
{##
1}})% }% }% % sentence case version:\renewcommand
*{\Genacrfullformat
}[2]{%\ifglsfieldeq
{##
1}{abbrtype}{word} {% is a proper acronym\protect
\firstacronymfont
{\Glsentryshort
{##
1}}##
2\space
(\glsentrylong
{##
1})% } {% is another form of abbreviation\Glsentrylong
{##
1}##
2\space
(\protect
\firstacronymfont
{\glsentryshort
{##
1}})% }% }% % plural\renewcommand
*{\genplacrfullformat
}[2]{%\ifglsfieldeq
{##
1}{abbrtype}{word}% {% is a proper acronym\protect
\firstacronymfont
{\glsentryshortpl
{##
1}}##
2\space
(\glsentrylong
{##
1})% }% {% is another form of abbreviation\glsentrylongpl
{##
1}##
2\space
(\protect
\firstacronymfont
{\glsentryshortpl
{##
1}})% }% }% % plural and sentence case\renewcommand
*{\Genplacrfullformat
}[2]{%\ifglsfieldeq
{##
1}{abbrtype}{word}% {% is a proper acronym\protect
\firstacronymfont
{\Glsentryshortpl
{##
1}}##
2\space
(\glsentrylong
{##
1})% }% {% is another form of abbreviation\Glsentrylongpl
{##
1}##
2\space
(\protect
\firstacronymfont
{\glsentryshortpl
{##
1}})% }% }% % Just use the short form as the name part in the glossary:\renewcommand
*{\acronymentry
}[1]{%\acronymfont
{\glsentryshort
{##
1}}}% % Sort by the short form:\renewcommand
*{\acronymsort
}[2]{##
1}% % Just use the surrounding font for the short form:\renewcommand
*{\acronymfont
}[1]{##
1}% % Same for first use:\renewcommand
*{\firstacronymfont
}[1]{\acronymfont
{##
1}}% % Default plural suffix if the plural isn't explicitly set\renewcommand
*{\acrpluralsuffix
}{\glspluralsuffix
}% }
\setacronymstyle
{mystyle}
Since it may be a bit confusing to use \newacronym
for something
that’s not technically an acronym, let’s define a new command for
initialisms:
Now the entries can all be defined:\newcommand
*{\newinitialism
}[4][]{%\newacronym
[abbrtype=initialism,#1]{#2}{#3}{#4}% }
On first use,\newacronym
{radar}{radar}{radio detecting and ranging}\newacronym
{laser}{laser}{light amplification by stimulated emission of radiation}\newacronym
{scuba}{scuba}{self-contained underwater breathing apparatus}\newinitialism
{dsp}{DSP}{digital signal processing}\newinitialism
{atm}{ATM}{automated teller machine}
\gls
{radar}
will produce “radar (radio
detecting and ranging)” but \gls
{dsp}
will produce “DSP
(digital signal processing)”.
For a complete document, see the sample file sample-storage-abbr.tex.
In the above example, if \newglossaryentry
is explicitly used
(instead of through \newacronym
) the abbrtype key will
be set to its default value of “word” but the \ifglshaslong
test in the custom acronym style will be false (since the
long key hasn’t been set) so the display style will switch
to that given by \glsgenentryfmt
and they’ll be no test
performed on the abbrtype field.
This may seem a little odd for non-abbreviated entries that are defined using\glsaddstoragekey
{abbrtype}% key/field name {acronym}% default value if not explicitly set {\abbrtype
}% custom command to access the value if required
\newglossaryentry
directly, but \ifglshaslong
can be used
to determine whether or not to reference the value of this new
abbrtype field.
The new acronym style has a minor modification that forces the user to specify a description. In the previous example, the line:
needs to be changed to:\renewcommand
*{\GenericAcronymFields
}{% description={\the
\glslongtok
}}%
Additionally, to accommodate the change in the default value of the abbrtype key, all instances of\renewcommand
*{\GenericAcronymFields
}{}%
need to be changed to:\ifglsfieldeq
{##
1}{abbrtype}{word}
\ifglsfieldeq
{##
1}{abbrtype}{acronym}
Once this new style has been set, the new acronyms can be defined using the optional argument to set the description:
\newacronym
[description={system for detecting the position and
speed of aircraft, ships, etc}]{radar}{radar}{radio detecting
and ranging}
No change is required for the definition of \newinitialism
but
again the optional argument is required to set the description:
\newinitialism
[description={mathematical manipulation of an
information signal}]{dsp}{DSP}{digital signal processing}
We can also accommodate contractions in a similar manner to the initialisms:
The contractions can similarly been defined using this new command:\newcommand
*{\newcontraction
}[4][]{%\newacronym
[abbrtype=contraction,#1]{#2}{#3}{#4}% }
\newcontraction
[description={front part of a ship below the
deck}]{focsle}{fo'c's'le}{forecastle}
Since the custom acronym style just checks if abbrtype is “acronym”, the contractions will be treated the same as the initialisms, but the style could be modified by a further test of the abbrtype value if required.
To test regular non-abbreviated entries, I’ve also defined a simple word:
\newglossaryentry
{apple}{name={apple},description={a fruit}}
Now for a new glossary style that provides information about the abbreviation (in addition to the description):
This uses\newglossarystyle
{mystyle}% style name {% base it on the "list" style\setglossarystyle
{list}%\renewcommand
*{\glossentry
}[2]{%\item
[\glsentryitem
{##
1}%\glstarget
{##
1}{\glossentryname
{##
1}}]\ifglshaslong
{##
1}% { (\abbrtype
{##
1}:\glsentrylong
{##
1})\space
}{}%\glossentrydesc
{##
1}\glspostdescription
\space
##
2}% }
\ifglshaslong
to determine whether or not the term is
an abbreviation. (An alternative is to use \ifglshasshort
. The
long and short keys are only set for
acronyms/abbreviations.)
If the entry has an short/long value, the full form is
supplied in parentheses and \abbrtype
(defined by
\glsaddstoragekey
earlier) is used to indicate the type of
abbreviation.
With this style set, the “apple” entry is simply displayed in the glossary as:
-
apple a fruit.
-
laser (acronym: light amplification by
stimulated emission of radiation) device that creates a narrow beam
of intense light.
-
DSP (initialism: digital signal processing) mathematical
manipulation of an information signal.
-
fo’c’s’le (contraction: forecastle) front part of a ship
below the deck.
For a complete document, see sample-storage-abbr-desc.tex.
4.4. Expansion[link]
When you define new glossary entries expansion is performed by
default, except for the name, description,
descriptionplural, symbol, symbolplural
and sort keys (these keys all have expansion suppressed via
\glssetnoexpandfield
).
You can switch expansion on or off for individual keys using:
or respectively, where is the internal field label corresponding to the key. In most cases, this is the same as the name of the key except for those listed in Table 4.1.
Key | Field |
---|---|
sort | sortvalue |
firstplural | firstpl |
description | desc |
descriptionplural | descplural |
user1 | useri |
user2 | userii |
user3 | useriii |
user4 | useriv |
user5 | userv |
user6 | uservi |
longplural | longpl |
shortplural | shortpl |
Any keys that haven’t had the expansion explicitly set using
\glssetexpandfield
or \glssetnoexpandfield
are governed by
If your entries contain any fragile commands, I recommend you switch
off expansion via \glsnoexpandfields
. (This should be used
before you define the entries.)
\newacronym
and \newabbreviation
partially suppress
expansion of some keys regardless of the above expansion settings.
4.5. Sub-Entries[link]
A sub-entry is created by setting the parent key. These will normally be sorted so that they are placed immediately after their parent entry. However, some sort methods aren’t suitable when there are sub-entries. In particular, sub-entries are problematic with Option 1, and with Option 5 the sub-entries must be defined immediately after their parent entry (rather than at any point after the parent entry has been defined).
The hierarchical level indicates the sub-entry level. An entry with no parent (a top level entry) is a hierarchical level 0 entry. An entry with a parent has a hierarchical level that’s one more than its parent’s level. The level is calculated when an entry is defined.
\glsfieldfetch
or (with glossaries-extra)
\glsxtrusefield
, but neither the level nor the
parent values should be altered as it can cause
inconsistencies in the sorting and glossary formatting. The
indexing syntax for Options 2 and 3 is generated when the
entry is first defined, so it’s too late to change the hierarchy
after that, and bib2gls obtains the hierarchical
information from the bib files and the resource options.
Note, however, that glossaries-extra does allow the ability to
locally alter the level with the leveloffset option,
which is mainly intended for nested glossary. See the
glossaries-extra manual for further details and also
Gallery: Inner or Nested Glossaries.
There are two different types of sub-entries: those that have the same name as their parent (homographs, see §4.5.2) and those that establish a hierarchy (see §4.5.1). Both types are considered hierarchical entries from the point of view of the glossaries package and the indexing applications, but typically homographs will have the name key obtained from the parent, rather than have it explicitly set, and have a maximum hierarchical level of 1.
Not all glossary styles support hierarchical entries and may display all the entries in a flat format. Of the styles that support sub-entries, some display the sub-entry’s name whilst others don’t. Therefore you need to ensure that you use a suitable style. (See §13 for a list of predefined glossary styles.) If you want level 1 sub-entries automatically numbered (in glossary styles that support it) use the subentrycounter package option (see §2.3 for further details).
Note that the parent entry will automatically be added to the glossary if any of its child entries are used in the document. If the parent entry is not referenced in the document, it will not have a number list. Note also that makeindex has a restriction on the maximum hierarchical depth.
4.5.1. Hierarchy[link]
To create a glossary with hierarchical divisions, you need to first define the division, which will be a top level (level 0) entry, and then define the sub-entries using the relevant higher level entry as the value of the parent key. (In a hierarchical context, a higher level indicates a numerically smaller level number, so level 0 is one level higher than level 1.) The top level entry may represent, for example, a topic or classification. A level 1 entry may represent, for example, a sub-topic or sub-classification.
Suppose I want a glossary of mathematical symbols that are divided into Greek letters and Roman letters. Then I can define the divisions as follows:
\newglossaryentry
{greekletter}{name={Greek letters}, description={\nopostdesc
}}\newglossaryentry
romanletter{name={Roman letters}, description={\nopostdesc
}}
Note that in this example, the top level entries don’t need a
description so I have set the descriptions to \nopostdesc
.
This gives a blank description and suppresses the
description terminator.
I can now define my sub-entries as follows:
For a complete document, see the sample file sampletree.tex.\newglossaryentry
{pi}name={\ensuremath
{\pi
}},sort={pi}, description={ratio of the circumference of a circle to the diameter}, parent={greekletter}\newglossaryentry
{C}{name={\ensuremath
{C}},sort={C}, description={Euler's constant}, parent={romanletter}}
4.5.2. Homographs[link]
Sub-entries that have the same name as the parent entry don’t need to have the name key explicitly set. For example, the word “glossary” can mean a list of technical words or a collection of glosses. In both cases the plural is “glossaries”. So first define the parent entry:
As in the previous example, the parent entry has no description, so the description terminator needs to be suppressed using\newglossaryentry
{glossary}{name={glossary}, description={\nopostdesc
}, plural={glossaries}}
\nopostdesc
.
Now define the two different meanings of the word with the parent key set to the above parent entry label:
Note that if I reference the parent entry (for example,\newglossaryentry
{glossarylist}{ description={list of technical words}, sort={1}, parent={glossary}}\newglossaryentry
{glossarycol}{ description={collection of glosses}, sort={2}, parent={glossary}}
\gls
{glossary}
), the location will be added to
the parent’s number list, whereas if I reference any of the
child entries (for example, \gls
{glossarylist}
),
the location will be added to the child entry’s number list.
Note also that since the sub-entries have the same name, the
sort key is required with Option 3 (xindy) and recommended
with Option 2 (makeindex). You can use the subentrycounter package
option to automatically number the level 1 child entries in the
glossary (if you use a glossary style that supports it).
See §2.3 for further details.
In the above example, the plural form for both of the child entries is the same as the parent entry, so the plural key was not required for the child entries. However, if the sub-entries have different plurals, they will need to be specified. For example:
For a complete document, see the sample file sample.tex.\newglossaryentry
{bravo}{name={bravo}, description={\nopostdesc
}}\newglossaryentry
{bravocry}{description={cry of approval (pl. bravos)}, sort={1}, plural={bravos}, parent={bravo}}\newglossaryentry
{bravoruffian}{description={hired ruffian or killer (pl. bravoes)}, sort={2}, plural={bravoes}, parent={bravo}}
4.6. Loading Entries From a File[link]
You can store all your glossary entry definitions in another file and use:
where is the name of the file containing all the\newglossaryentry
, \longnewglossaryentry
, \newacronym
etc commands. The optional argument is the name of the
glossary to which those entries should belong, for those
entries where the type key has been omitted (or, more
specifically, for those entries whose type has been set to
\glsdefaulttype
, which is what \newglossaryentry
uses by
default). See sampleDB.tex for a complete example document.
\newacronym
, \newabbreviation
,
\newterm
, \glsxtrnewsymbol
and \glsxtrnewnumber
all
set the type key to the appropriate glossary. This
means that the optional argument won’t apply to those
commands, unless they have type={\glsdefaulttype
}.
This is a preamble-only command. You may also use \input
to load
the file but don’t use \include
. If you find that your file is
becoming unmanageably large, you may want to consider switching to
bib2gls and use an application such as JabRef to manage the
entry definitions.
\AtBeginDocument
to \input
all your
entries automatically at the start of the document, add the
\AtBeginDocument
command before you load the
glossaries package (and babel, if you are also loading
that) to avoid the creation of the
glsdefs file and any associated problems that are caused
by defining commands in the document environment.
(See §4.8.) Alternatively, if you are using
glossaries-extra, use the docdef=restricted
package option.
and suppose in my preamble I use the command:\newglossaryentry
{perl}{type={main
}, name={Perl}, description={A scripting language}}\newglossaryentry
{tex}{name={\TeX
}, description={A typesetting language},sort={TeX}}\newglossaryentry
{html}{type={\glsdefaulttype
}, name={html}, description={A mark up language}}
\loadglsentries
[languages]{myentries}
then this will add the entries “tex” and “html”
to the glossary whose type is given by languages, but
the entry “perl” will be added to the main
glossary, since
it explicitly sets the type to main
.
Now suppose I have a file myacronyms.tex that contains:
\newacronym
{aca}{aca}{a contrived acronym}
then (supposing I have defined a new glossary type called
altacronym)
\loadglsentries
[altacronym]{myacronyms}
will add “aca” to the glossary type acronym
, if the
package option acronym has been specified, or will add
“aca” to the glossary type altacronym, if the
package option acronym is not specified. This is
because \acronymtype
is set to \glsdefaulttype
if the
acronym package option is not used so the optional argument of
\loadglsentries
will work in that case, but if the
acronym option is used then \acronymtype
will be
redefined to acronym
.
If you want to use \loadglsentries
with the acronym
package option set, there are two possible solutions to this problem:
- 1.Change myacronyms.tex so that entries are defined in
the form:
and do:\newacronym
[type={\glsdefaulttype
}]{aca}{aca}{a contrived acronym}\loadglsentries
[altacronym]{myacronyms} - 2.Temporarily change
\acronymtype
to the target glossary:\let
\orgacronymtype
\acronymtype
\renewcommand
{\acronymtype
}{altacronym}\loadglsentries
myacronyms\let
\acronymtype
\orgacronymtype
Note that only those entries that have been indexed in the text will appear in the relevant glossaries.
Note also that \loadglsentries
may only be used in the
preamble.
Remember that you can use \provideglossaryentry
rather than
\newglossaryentry
. Suppose you want to maintain a large database
of acronyms or terms that you’re likely to use in your documents,
but you may want to use a modified version of some of those entries.
(Suppose, for example, one document may require a more detailed
description.) Then if you define the entries using
\provideglossaryentry
in your database file, you can override
the definition by simply using \newglossaryentry
before loading
the file. For example, suppose your file (called, say,
terms.tex) contains:
\provideglossaryentry
{mallard}{name={mallard},
description={a type of duck}}
but suppose your document requires a more detailed description, you
can do:
Now the “mallard” definition in the terms.tex file will be ignored.\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{mallard}{name={mallard}, description={a dabbling duck where the male has a green head}}\loadglsentries
{terms}
4.7. Moving Entries to Another Glossary[link]
You can move an entry from one glossary to another using:
where is the unique label identifying the required entry and is the unique label identifying the glossary in which to put the entry. If you are using Options 2 or 3, entries shouldn’t be moved after the indexing files have been opened by\makeglossaries
.
\glsfielddef
won’t correctly move the entry, since the label
needs to be removed from the old glossary’s internal list
and added to the new glossary’s internal list to allow
commands such as \glsaddall
and \glsunsetall
to work.
Note that no check is performed to determine the existence of
the target glossary. If you want to move an entry to a glossary
that’s skipped by \printglossaries
, then define an
ignored glossary with \newignoredglossary
. (See
§9.) With Options 4 and 5, it’s also
possible to copy an entry to another glossary with
\glsxtrcopytoglossary
. See the glossaries-extra manual
for further details.
4.8. Drawbacks With Defining Entries in the Document Environment[link]
Originally, \newglossaryentry
(and \newacronym
) could only
be used in the preamble. I reluctantly removed this
restriction in version 1.13, but there are issues with defining
commands in the document environment instead of the
preamble, which is why the restriction is maintained
for newer commands. This restriction is also reimposed for
\newglossaryentry
by Option 1 because in that case the
entries must be defined before the aux file is input.
(The glossaries-extra package automatically reimposes the
preamble-only restriction but provides the
docdef package option to allow document definitions for
Options 2 and 3 if necessary.)
\GlsXtrLoadResources
, which is a preamble-only command.
4.8.1. Technical Issues[link]
- 1.If you define an entry mid-way through your document, but
subsequently shuffle sections around, you could end up using an
entry before it has been defined. This is essentially the same
problem as defining a command with
\newcommand
in the middle of the document and then moving things around so that the command is used before it has been defined. - 2.Entry information is required when displaying the glossary.
If this occurs at the start of the document, but the entries aren’t
defined until later, then the entry details are
being looked up before the entry has been defined. This means that
it’s not possible to display the content of the glossary unless the
entry definitions are saved on the previous LaTeX run and can be
picked up at the start of the document environment on the next run
(in a similar way that
\label
and\ref
work). - 3.If you use a package, such as babel, that makes
certain characters active at the start of the document
environment, there can be a problem if those characters have
a special significance when defining glossary entries.
These characters include
"
(double-quote),!
(exclamation mark),?
(question mark), and|
(pipe). They must not be active when defining a glossary entry where they occur in the sort key (and they should be avoided in the label if they may be active at any point in the document). Additionally, the comma (,
) character and the equals (=
) character should not be active when using commands that have = arguments.
To overcome the first two problems, as from version 4.0 the
glossaries package modifies the definition of
\newglossaryentry
at the beginning of the document
environment so that the definitions are written to an external file
(\jobname
.glsdefs) which is then read in at the start
of the document on the next run. This means that the entry can now
be looked up in the glossary, even if the glossary occurs at the
beginning of the document.
There are drawbacks to this mechanism: if you modify an entry
definition, you need a second run to see the effect of your
modification in \printglossary
(if it occurs at the start of the
document); this method requires an extra \newwrite
, which may
exceed TeX’s maximum allocation; unexpected expansion issues could
occur.
Version 4.47 has introduced changes that have removed some of the issues involved, and there are now warning messages if there is an attempt to multiply define the same entry label.
The glossaries-extra package provides a setting (but not for
Options 1 or 4) that allows \newglossaryentry
to occur in the
document environment but doesn’t create the glsdefs
file. This circumvents some problems but it means that you can’t
display any of the glossaries before all the entries have been
defined (so it’s all right if all the glossaries are at the end of
the document but not if any occur in the front matter).
4.8.2. Good Practice Issues[link]
§4.8.1 above covers technical issues that can cause your document to have compilation errors or produce incorrect output. This section focuses on good writing practice. The main reason cited by users wanting to define entries within the document environment rather than in the preamble is that they want to write the definition as they type in their document text. This suggests a “stream of consciousness” style of writing that may be acceptable in certain literary genres but is inappropriate for factual documents.
When you write technical documents, regardless of whether it’s a PhD thesis or an article for a journal or proceedings, you must plan what you write in advance. If you plan in advance, you should have a fairly good idea of the type of terminology that your document will contain, so while you are planning, create a new file with all your entry definitions. If, while you’re writing your document, you remember another term you need, then you can switch over to your definition file and add it. Most text editors have the ability to have more than one file open at a time. The other advantage to this approach is that if you forget the label, you can look it up in the definition file rather than searching through your document text to find the definition.
5. Referencing Entries in the Document[link]
Once you have defined a glossary entry using a command such as
\newglossaryentry
(§4) or
\newacronym
(§6), you can refer to that
entry in the document with one of the provided commands that are
describe in this manual. (There are some additional commands
provided by glossaries-extra.) The text produced at that point
in the document (the link text) is determined by the command and can also be
governed by whether or not the entry has been
marked as used.
Some of these commands are more complicated than others. Many of them are robust and can’t be used in fully expandable contexts, such as in PDF bookmarks.
The commands are broadly divided into:
- 1.Those that display text in the document (where the formatting
can be adjusted by a style or hook) and also index the
entry (so that it’s added to the glossary) are described in
§5.1. This set of commands can
be further sub-divided into those that mark the entry as having been
used (the
\gls
-like commands, §5.1.2) and those that don’t (the\glstext
-like commands, §5.1.3). - 2.Those that display text in the document without indexing or applying any additional formatting (§5.2). These typically aren’t robust or can partially expand so that they can be used in PDF bookmarks (with a few exceptions).
\newacronym
that are described in §6.1.
5.1. Links to Glossary Entries[link]
The text which appears at the point in the document when using any
of the commands described in §5.1.2 or
§5.1.3 is referred to as the link text
(even if there are no hyperlinks). These commands also add
content to an external indexing file that is used to generate the relevant
entry line in the glossary. This information includes an associated
location that is added to the number list for that entry. By
default, the location refers to the page number. For further
information on number lists, see §12.
These external indexing file need to be post-processed by
makeindex or xindy if you have chosen
Options 2 or 3. If you don’t use \makeglossaries
these
external files won’t be created. (Options 1 and 4 write the
information to the aux file instead.)
Note that repeated use of these commands for the same entry can
cause the number list to become quite long, which may not be
particular helpful to the reader. In this case, you can use the
non-indexing commands described in §5.2 or
you can use the glossaries-extra package, which
provides a means to suppress the automated indexing of the commands listed
in this chapter. (For example, in this manual, common terms such as
glossary have too many references in the document to list them
all in their number list in the index. They have a custom
key created with \glsaddstoragekey
that’s used
to set their default indexing option.)
\chapter
or \caption
.
Aside from problems with expansion issues, PDF bookmarks and possible nested hyperlinks in the table of contents (or list of whatever) any use of the commands described in §5.1.2 will have their first use flag unset when they appear in the table of contents (or list of whatever) which is usually too soon and will not match the actual heading or caption in the document if there is a different first/subsequent use.
The above warning is particularly important if you are using the
glossaries package in conjunction with the hyperref
package. Instead, use one of the expandable commands listed in
§5.2 (such as \glsentrytext
). Alternatively, provide an
alternative via the optional argument to the sectioning/caption
command or use hyperref’s \texorpdfstring
. Examples:
(You can use\chapter
An overview of\glsentrytext
{perl}\chapter
[An overview of Perl]An overview of\gls
{perl}\chapter
{An overview of\texorpdfstring
{\gls
{perl}}{Perl}}
\glstexorpdfstring
instead of \texorpdfstring
if you don’t know whether or not hyperref will be needed.)
\glsfmttext
,
that overcome some of the problems.
If you want the link text to produce a hyperlink to the
corresponding entry line in the glossary, you should load the
hyperref package before the glossaries
package. That’s what I’ve done in this manual, so if you encounter a
hyperlinked term, such as link text, you can click on the word
or phrase and it will take you to a brief description in this
document’s glossary or you can click on a command name, such
as \gls
, and it will take you to the relevant part of the
document where the command is described or you can click on a
general word or phrase, such as table of contents, and it will
take you to the relevant line in the index where
you can find the number list to navigate to other parts of the
document that are pertinent. If, however, you click on
“number list”, you’ll find it leads you to the
location list entry in the index instead. This is because
number list has been aliased to location list using the
alias key. Whereas if you click on “page list”
it will take you to the corresponding page list entry in the glossary
that has a cross-reference to location list, because the
see key was used instead.
These are limitations of the DVI format not of the glossaries package.
It may be that you only want terms in certain glossaries to have hyperlinks, but not for other glossaries. In this case, you can use the package option nohypertypes to identify the glossary lists that shouldn’t have hyperlinked link text. See §2.1 for further details.
The way the link text is displayed depends on
For example, to make all link text appear in a sans-serif font, do:Further customisation can be done via\renewcommand
*{\glstextformat
}[1]{\textsf
{#1}}
\defglsentryfmt
or by
redefining \glsentryfmt
. See §5.1.4 for
further details.
Each entry has an associated conditional referred to as the
first use flag. Some of the commands described in this chapter
automatically unset this flag and can also use it
to determine what text should be displayed. These types of commands
are the \gls
-like commands and are described in
§5.1.2. The commands that don’t reference or change
the first use flag are \glstext
-like commands and are described
in §5.1.3. See §7 for
commands that unset (mark the entry as having been used) or reset
(mark the entry as not used) the first use flag without referencing
the entries.
The \gls
-like and \glstext
-like commands all take a first
optional argument that is a comma-separated list of = options, described below. They also have a star-variant,
which inserts hyper=false at the start of the list of
options and a plus-variant, which inserts
hyper=true at the start of the list of options. For
example
is the same as
\gls
*
{sample}
and
\gls
[hyper=false]{sample}
is the same as
\gls
+
{sample}
, whereas
just \gls
[hyper=true]{sample}
will use the default
hyperlink setting which depends on a number of factors (such
as whether the entry is in a glossary that has been identified
in the nohypertypes list). You can override the
hyper key in the variant’s optional argument, for example,
\gls
{sample}
but this creates redundancy and is best avoided. The
glossaries-extra package provides the option to add a third
custom variant and commands to override the behaviour of the
star and plus variants.
\gls
*
[hyper=true]{sample}
\glslink
{ }{\gls
{ }}
as this is likely to cause problems. By implication, this
means that you should avoid using any of these commands within
the text, first, short or
long keys (or their plural equivalent) or any
other key that you plan to access through these commands.
(For example, the symbol key if you intend to use
\glssymbol
.) The glossaries-extra package provides
\glsxtrp
to use instead, which helps to mitigate against
nesting problems.
5.1.1. Options[link]
The keys listed below are available for the optional first argument
of the \gls
-like and \glstext
-like commands.
The glossaries-extra package provides additional keys.
(See the glossaries-extra manual for further details.)
If true, this option can be used to enable/disable the hyperlink to the relevant entry line in the glossary. If this key is omitted, the value is determined by the current settings. For example, when used with a
\gls
-like
command, if this is the first use and the hyperfirst=false
package option has been used, then the default value is
hyper=false. The hyperlink can be forced on using
hyper=true unless the hyperlinks have been
suppressed using \glsdisablehyper
. You must load the
hyperref package before the glossaries package to ensure
the hyperlinks work.
This specifies how to format the associated location number within the location list (see §12.1).
This specifies which counter to use for this location. This overrides the default counter used by the entry, the default counter associated with the glossary (supplied in the final optional argument of
\newglossary
) and the default counter identified by
the counter package option. See also §12.
The glossaries-extra package has additional options that
affect the counter used, such as floats and equations.
This manual uses the floats option to automatically switch the
counter to table for any entries indexed in tables (such as
those in Table 12.1).
This is a boolean key that only makes a difference when used with
\gls
-like commands that change the entry’s first use flag.
If local=true, the change to the first use flag
will be localised to the current scope.
If true, this option will suppress the indexing. Only available with glossaries-extra. This manual doesn’t use noindex for common entries. Instead it uses format=glsignore, which is preferable with bib2gls.
If true, this will put the hyperlink outside of
\glstextformat
.
Only available with glossaries-extra.
This key determines whether to index before (wrgloss=before) or after (wrgloss=after) the link text, which alters where the whatsit occurs. Only available with glossaries-extra.
The value is the name of the control sequence (without the leading backslash) to encapsulate the link text instead of the default
\glstextformat
. Only available with glossaries-extra.
This key locally redefines
\glolinkprefix
to the given value.
Only available with glossaries-extra.
This key explicitly sets the location value instead of obtaining it from the location counter. Only available with glossaries-extra.
This key explicitly sets the hyperlink location value instead of obtaining it from the location counter. Only available with glossaries-extra.
Determines whether or not to reset the first use flag before the link text. Only available with glossaries-extra.
Determines whether or not to unset the first use flag before the link text. Only available with glossaries-extra.
Determines whether or not to unset the first use flag after the link text. Only available with glossaries-extra.
5.1.2. The \gls
-Like Commands (First Use Flag Queried)[link]
This section describes the \gls
-like commands that unset (mark
as used) the first use flag after the link text, and in
most cases they use the current state of the flag to determine the
text to be displayed. As described above, these
commands all have a star-variant (hyper=false)
and a plus-variant (hyper=true) and have an
optional first argument that is a = list. These commands use
\glsentryfmt
or the equivalent definition provided by
\defglsentryfmt
to determine the automatically generated text
and its format (see
§5.1.4).
Apart from \glsdisp
, the commands described in this section
also have a final optional argument which may
be used to insert material into the automatically generated text.
\relax
or an empty set of
braces {}
immediately before the opening square bracket to
prevent it from being interpreted as the final argument. For
example:
Use of a semantic command can also help avoid this problem. For example:\gls
{sample}[] [Editor's comment]\gls
{sample}{} [Editor's comment]\gls
{sample}\relax
[Editor's comment]
\newcommand
{\edcom
}[1][#1] % later:\gls
{sample}\edcom
{Editor's comment}
Don’t use any of the \gls
-like or \glstext
-like commands in the
argument.
Take care using these commands within commands or environments that
are processed multiple times as this can confuse the first use flag
query and state change. This includes frames with overlays in
beamer and the tabularx environment provided by tabularx.
The glossaries package automatically deals with this issue
in amsmath’s align environment. You can apply a patch
to tabularx by placing the command \glspatchtabularx
in the
preamble.
This does nothing if tabularx hasn’t been loaded. There’s no
patch available for beamer. See §7 for
more details and also §15.5.
Most of the commands below have case-changing variants to convert
the link text to sentence case or all caps. The
sentence case conversion is performed by \glssentencecase
and the all caps is performed by \glsuppercase
.
Ensure you have at least version 2.08 of mfirstuc to use the
modern LaTeX3 case-changing commands instead of the now deprecated
textcase package. See the mfirstuc manual for further
details.
This command typically determines the link text from the values of the text or first keys supplied when the entry was defined using
\newglossaryentry
. However, if the
entry was defined using \newacronym
and \setacronymstyle
was
used, then the link text will usually be determined from the long or
short keys (similarly for \newabbreviation
).
The case-changing variants:
(sentence case) and (all caps).
There are plural forms that are analogous to \gls
:
\newglossaryentry
or, if the entry was defined
with \newacronym
and \setacronymstyle
was used, from the
longplural or shortplural keys. (Similarly for
\newabbreviation
.)
and later you use it in math mode:\newglossaryentry
{Falpha}{name={F\alpha
}, description={sample}}
$\gls
{Falpha}2$
This will result in Fα2 instead of F2α. In this
situation it’s best to bring the superscript into the hyperlink using
the final optional argument:
$\gls
{Falpha}[^
2]$
This behaves in the same way as
\gls
, except
that the is explicitly set. There’s no final
optional argument as any inserted material can be added to the
argument. Even though the
first use flag doesn’t influence the link text, it’s still
unset after the link text and so may influence the post-link hook.
For example:
This ensures that the entry is indexed and, if enabled, creates a hyperlink to the entry line in the glossary. It will also follow the display style and have the link text encapsulated with\newglossaryentry
{locationcounter}{ name={location counter}, description={...} } % later in the document: The\glsdisp
{locationcounter}{counter} identifying the location.
\glstextformat
.
Since the actual text is being supplied, any case-changing can be placed in the argument. For example:
\glsdisp
{locationcounter}{Counters} associated with locations
However, a sentence case variant is provided:
This essentially does:
The main reason for providing this command is to set up a mapping for\glsdisp
[ ]{ }{\glssentencecase
{ }}
\makefirstuc
. See the mfirstuc manual for further
details about mappings.
5.1.3. The \glstext
-Like Commands (First Use Flag Not Queried)[link]
This section describes the commands that don’t change or reference
the first use flag. As described above, these commands all have a
star-variant (hyper=false) and a plus-variant
(hyper=true) and have an optional first argument
that is a = list. These commands also don’t
use \glsentryfmt
or the equivalent definition provided by
\defglsentryfmt
(see §5.1.4).
They do, however, have their link text encapsulated with
\glstextformat
.
Additional commands for acronyms are described in §6. (Additional commands for abbreviations are described in the glossaries-extra manual.)
Apart from \glslink
, the commands described in this section
also have a final optional argument which may
be used to insert material into the automatically generated text.
See the caveat above in §5.1.2. As with the
\gls
-like commands described in §5.1.2, these
commands also have case-changing variants.
This command explicitly sets the link text as given in the final argument. As with
\glsdisp
, there’s a sentence case
variant to allow a sentence case mapping to be established:
See the mfirstuc package for further details.
\gls
-like or \glstext
-like commands in the
argument of \glslink
. By extension, this means that you can’t
use them in the value of fields that are used to form link text.
This command always uses the value of the text key as the link text.
The case-changing variants are:
(sentence case) and (all caps).
There’s no equivalent command for title case, but you
can use the more generic command \glsentrytitlecase
in combination with \glslink
. For example:
(See §5.2.)\glslink
{sample}{\glsentrytitlecase
{sample}{text}}
This command always uses the value of the first key as the link text.
The case-changing variants are:
(sentence case) and (all caps).
\gls
(or
\glspl
) on first use as the link text used by
\gls
may be modified through entry
formatting commands like \defglsentryfmt
. (Similarly, the value
of the text and plural keys don’t necessarily
match the link text used by \gls
or \glspl
on
subsequent use.)
This command always uses the value of the plural key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the firstplural key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the name key as the link text. Note that this may be different from the values of the text or first keys. In general it’s better to use
\glstext
or \glsfirst
instead of \glsname
,
unless you have a particular need for the actual name.
The case-changing variants are:
(sentence case) and (all caps).
\glsname
with acronyms. Instead,
consider using \acrlong
, \acrshort
or \acrfull
.
Alternatively, for abbreviations defined with
glossaries-extra, use \glsxtrlong
, \glsxtrshort
or
\glsxtrfull
.
This command always uses the value of the symbol key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the description key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user1 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user2 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user3 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user4 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user5 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).This command always uses the value of the user6 key as the link text.
The case-changing variants are:
(sentence case) and (all caps).
5.1.4. Changing the Format of the \gls
-like Link Text[link]
The default entry format (display style) of the link text for the
\gls
-like commands is governed by:
\glsgenentryfmt
. The glossaries-extra package redefines
\glsentryfmt
to allow it to integrated with the
abbreviation styles.
\gls
-like
commands, not the \glstext
-like commands. However, both sets of
commands use \glstextformat
for the font.
You can redefine \glsentryfmt
(but beware of breaking
abbreviations with glossaries-extra), but if you only want the
change the display style for a given glossary, use:
\glsentryfmt
. The optional first argument
is the glossary type. This defaults to
\glsdefaulttype
if omitted. The second argument is the
entry format definition, which needs to use the placeholder commands
described in this section.
In the remainder of this section, \defglsentryfmt
or to the definition of
\glsentryfmt
.
\glsentryfmt
is the default display style for
glossary entries. Once the display style has been changed for an individual
glossary using \defglsentryfmt
, redefining \glsentryfmt
won’t have an effect on that glossary, you must instead use
\defglsentryfmt
again. Note that glossaries that have
been identified as lists of acronyms (via the package option
acronymlists or the command \DeclareAcronymList
,
see §2.7) use
\defglsentryfmt
to set their display style.
(The glossaries-extra package provides abbreviation
support within its redefinition of \glsentryfmt
.)
Within
you may use the following commands: This expands to the label of the entry being referenced.You can also access the entry’s glossary type using:
This is defined using\protected@edef
so the replacement text is the
actual glossary type rather than
\glsentrytype
{\glslabel
}
.
Expands to the final optional argument to
\gls
,
\glspl
and their case-changing variants (or empty if
was omitted).
If the plural commands
\glspl
, \Glspl
or \GLSpl
was used, this command expands to otherwise it expands
to .
If
\gls
, \glspl
or \glsdisp
were used, this expands
to . If the sentence case commands \Gls
or \Glspl
were used, this expands to . If the all caps
commands \GLS
or \GLSpl
were used, this expands to .
Expands to the custom text supplied in
\glsdisp
. It’s always empty
for \gls
, \glspl
and their case-changing variants. (You can
use etoolbox’s \ifdefempty
to determine if
\glscustomtext
is empty.)
\Glsdisp
is used, \glscustomtext
will include the
sentence case command (\glssentencecase
), but
\glscapscase
will expand to (since
\Glsdisp
simply uses \glsdisp
without modifying the
placeholder commands). However, the generic \glsgenentryfmt
doesn’t use \glscapscase
(or \glsifplural
) if
\glscustomtext
isn’t empty.
This will do if the hyperlinks are on for the current reference, otherwise it will do . The hyperlink may be off even if it wasn’t explicitly switched off with hyper=false key or the use of a starred (
*
) command.
It may be off because the hyperref package hasn’t been loaded
or because \glsdisablehyper
has been used or because the entry
is in a glossary type that’s had the hyperlinks switched off (using
nohypertypes) or because it’s the first use and the
hyperlinks have been suppressed on first use.
If you want to know if the calling command used to reference
the entry was used with the star (*
) or plus
(+
) variant, you can use:
\GlsXtrSetAltModifier
will make \glslinkvar
expand to
.
Note that this doesn’t take into account if the
hyper key was used to override the default
setting, so this command shouldn’t be used to guess whether or not
the hyperlink is on for this reference. This command is
therefore of limited use. If you want to make the star or
plus behave differently, you can try
\GlsXtrSetStarModifier
or \GlsXtrSetPlusModifier
instead,
if you are using glossaries-extra.
Note that you can also use commands such as \ifglsused
within
(see §7), but don’t use
\ifglsused
in the post-link hook.
The commands \glslabel
, \glstype
, \glsifplural
,
\glscapscase
, \glsinsert
and \glscustomtext
are
typically updated at the start of the \gls
-like and
\glstext
-like
commands so they can usually be accessed in the hook user commands,
such as \glspostlinkhook
and \glslinkpostsetkeys
.
\gls
within the fields
that are accessed using the \gls
-like or \glstext
-like commands
(such as the first, text, long
or short keys) will cause a problem. The definitions of
the placeholder commands can’t be scoped otherwise they won’t be
available for the post-link hook, and grouping can also cause
unwanted spacing issues in math mode.
If you only want to make minor modifications to \glsentryfmt
,
you can use the generic entry formatting command:
symbols
glossary:
\defglsentryfmt
[symbols
]{\glsgenentryfmt
(\glsentrysymbol
{\glslabel
})}
The acronym styles use a similar method to adjust the formatting. For example, the long-short style implements:
For each glossary that has been identified as a list of acronyms. This uses the generic entry format command\defglsentryfmt
[ ]{\ifglshaslong
{\glslabel
}{\glsgenacfmt
}{\glsgenentryfmt
}}
\glsgenentryfmt
for general entries (that don’t have the long key set),
otherwise it uses the generic acronym format:
This uses the values from the long, short,
longplural and shortplural keys, rather than
using the text, plural, first
and firstplural keys. The first use singular text is obtained via:
instead of from the first key, and the first use plural
text is obtained via:
instead of from the firstplural key.
In both cases, is the entry’s label and
is the insert text provided in the final optional argument of
commands like \gls
. The default behaviour is to do the long
form (or plural long form) followed by and a space and
the short form (or plural
short form) in parentheses, where the short form is in the argument
of \firstacronymfont
. There are also sentence case
versions:
and
See §6 for details on changing the style of acronyms.
\glsentryfmt
(or the formatting given by \defglsentryfmt
)
is not used by the \glstext
-like commands.
\newglossaryentry
{distance}{name={distance},
description={The length between two points},
symbol={km}}
and now suppose you want \gls
{distance}
to produce
“distance (km)” on first use, then you can redefine
\glsentryfmt
as follows:
\renewcommand
*{\glsentryfmt
}%\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\space
(\glsentrysymbol
{\glslabel
})}%
(Note that I’ve used \glsentrysymbol
rather than \glssymbol
to avoid nested hyperlinks.)
All of the link text will be formatted according
to \glstextformat
(described earlier). So if you do, say:
then\renewcommand
{\glstextformat
}[1]{\textbf
{#1}}\renewcommand
*{\glsentryfmt
}{%\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\space
(\glsentrysymbol
{\glslabel
})}% }
\gls
{distance}
will produce “distance (km)”.
This is different from using the post-link hook which is
outside of \glstextformat
.
For a complete document, see the sample file sample-entryfmt.tex.
Now suppose you have defined an entry as follows:\defglsentryfmt
[notation]{\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\space
(denoted\glsentrysymbol
{\glslabel
})}}
The first time you reference this entry it will be displayed as: “set (denoted S)” (assuming\newglossaryentry
{set}{type={notation}, name={set}, description={A collection of objects}, symbol={\ensuremath
S} }
\gls
was used).
Remember that if you use the symbol key, you need to use a glossary style that displays the symbol, as many of the styles ignore it.
5.1.5. Hooks[link]
Both the \gls
-like and \glstext
-like commands use:
\glslinkpresetkeys
.
There is also a hook (the post-link hook) that’s implemented at the end:
This is done after the link text has been displayed and also after the first use flag has been unset (see example 31). This means that it’s too late to use\ifglsused
in the definition of \glspostlinkhook
. The
glossaries-extra package provides \glsxtrifwasfirstuse
for use in the post-link hook.
\glspostlinkhook
to allow for additional hooks that can vary according to the entry’s
category. If you migrate over from only using the base
glossaries package to glossaries-extra and
you have redefined \glspostlinkhook
, consider moving your
modifications to the category post-link hook to avoid breaking the
extended post-link hook features. See the glossaries-extra
manual for further details.
5.1.6. Enabling and Disabling Hyperlinks to Glossary Entries[link]
If you load hyperref prior to loading the glossaries
package, the \gls
-like and \glstext
-like commands will
automatically have hyperlinks to the relevant
glossary entry, unless the hyper option has been switched off
(either explicitly or through implicit means, such as via the
nohypertypes package option).
You can disable or enable hyperlinks using
\glsdisablehyper
and \glsenablehyper
respectively. The effect can be localised by placing the commands
within a group. Note that you should only use \glsenablehyper
if the commands \hyperlink
and \hypertarget
have been
defined, otherwise you will get undefined control sequence errors.
If the hyperref package is loaded before glossaries,
\glsenablehyper
will be use automatically.
You can disable just the first use links using the package
option hyperfirst=false. Note that this option only
affects the \gls
-like commands that recognise the
first use flag.
\usepackage
[hyperfirst=false]{glossaries}
Now I need to redefine \glsentryfmt
(see
§5.1.4):
\renewcommand
*{\glsentryfmt
}{%\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\footnote
{\glsentrydesc
{\glslabel
}}}% }
Now the first use won’t have hyperlinked text, but will be followed by a footnote. See the sample file sample-FnDesc.tex for a complete document.
Note that the hyperfirst option applies to all defined
glossaries. It may be that you only want to disable the
hyperlinks on first use for glossaries that have a
different form on first use (such as list of acronyms). This
can be achieved by noting that since the entries that require
hyperlinking for all instances have identical first
and subsequent text, they can be unset via \glsunsetall
(see
§7) so that the hyperfirst option
doesn’t get applied.
main
glossary. I can load
the glossaries package using:
\usepackage
[hyperfirst=false,acronym]{glossaries}
Once all glossary entries have been defined I then do:
(Alternatively use the nohyperfirst category attribute with glossaries-extra.)\glsunsetall
[main
]
For more complex requirements, you might find it easier to switch
off all hyperlinks via \glsdisablehyper
and put the
hyperlinks (where required) within the definition of
\glsentryfmt
(see §5.1.4) via
\glshyperlink
(see §5.2).
\gls
-like commands to have
hyperlinks when used in text mode, but not in math mode. I can do
this by adding the glossary to the list of nohypertypes and redefining
\glsentryfmt
:
Note that this doesn’t affect the\GlsDeclareNoHyperList
{main
}\renewcommand
*{\glsentryfmt
}{%\ifmmode
\glsgenentryfmt
\else
\glsifhyperon
{\glsgenentryfmt
}% hyperlink already on {\glshyperlink
[\glsgenentryfmt
]{\glslabel
}}%\fi
}
\glstext
-like commands, which will
have the hyperlinks off unless they’re forced on using the
plus variant or with an explicit use of hypertrue.
See the sample file sample-nomathhyper.tex for a complete document.
\glsaddstoragekey
(see
§4.3.2) that keeps track of the chapter
number that the entry was last used in:
This creates a new user command called\glsaddstoragekey
{chapter}{0}{\glschapnum
}
\glschapnum
that’s
analogous to \glsentrytext
. The default value for this key is 0.
I then define my glossary entries as usual.
Next I redefine the hook \glslinkpostsetkeys
(see §5.1.4) so that it determines the current
chapter number (which is stored in \currentchap
using
\edef
). This value is then compared with the value of the
entry’s chapter key that I defined earlier. If they’re the
same, this entry has already been used in this chapter so the
hyperlink is switched off using xkeyval’s \setkeys
command. If the chapter number isn’t the same, then this entry
hasn’t been used in the current chapter. The chapter field
is updated using \glsfieldxdef
(§15.6)
provided the user hasn’t switched off the hyperlink.
(This test is performed using \glsifhyperon
.)
Note that this will be confused if you use\renewcommand
*{\glslinkpostsetkeys
}{%\edef
\currentchap
{\arabic
{chapter}}%\ifnum
\currentchap
=\glschapnum
{\glslabel
}\relax
\setkeys
{glslink}{hyper=false}%\else
\glsifhyperon
{\glsfieldxdef
{\glslabel
}{chapter}{\currentchap
}}%\fi
}
\gls
etc when the
chapter counter is 0. (That is, before the first \chapter
.)
See the sample file sample-chap-hyperfirst.tex for a complete document.
5.2. Using Glossary Terms Without Indexing[link]
The commands described in this section display entry details without
adding any information to the glossary. They don’t use
\glstextformat
or the entry format, they don’t have any
optional arguments, they don’t affect the first use flag and,
apart from \glshyperlink
and the number list commands,
they don’t produce hyperlinks.
\Glsentrytext
, ensure you have at least version 2.08 of
mfirstuc. Inside PDF bookmarks, those commands will expand
with the sentence case applied using the expandable
\MFUsentencecase
. Outside of PDF bookmarks those commands will expand
to an internal robust command that applies the sentence case
with \glssentencecase
(which defaults to \makefirstuc
).
If you want to title case a field, you can use:
where is the label identifying the glossary entry, is the internal field label (see Table 4.1). This internally uses\glscapitalisewords
. Within PDF bookmarks,
this command will expand to sentence case using the expandable
\MFUsentencecase
. (The title case command
\capitalisewords
isn’t expandable.)
\glscapitalisewords
to use \capitalisefmtwords
instead of \capitalisewords
. See the mfirstuc manual for
further details.
For example, to convert the description to title case for the entry identified by the label “sample”:
\glsentrytitlecase
{sample}{desc}
(If you want title-casing in your
glossary style, you might want to
investigate the glossaries-extra package.) This command will
trigger an error if the entry is undefined.
If you want a hyperlink to an entry’s line in the
glossary but don’t want the indexing or
formatting associated with the \gls
-like and \glstext
-like
commands, you can use:
\glsentrytext
{ }
. Note that the hyperlink will
be suppressed if you have used \glsdisablehyper
or if you
haven’t loaded the hyperref package.
\glshyperlink
, you need to ensure that the relevant
entry has been added to the glossary using any of the commands
described in §5.1 or §10
otherwise you will end up with an undefined hyperlink target.
The following commands in form form \glsentry
expand to the associated field value for the
entry identified by for the non-case-changing versions. Those commands don’t check if the entry has been defined.
The sentence case versions \Glsentry
only
expand in PDF bookmarks. In both cases, any fragile commands within the field
values will need to be protected or made robust if the field values
are required in a moving argument.
There are also commands in the form \glossentry
for the name, description and symbol
that are used by the glossary styles. Those commands will
issue a warning if the entry hasn’t been defined. See
§13 for further information.
Expands to the value of the name field. Note that within glossary styles, the name is displayed using
\glossentryname
.
The corresponding sentence case command is:
\Glsentryname
with acronyms
or abbreviations. Instead,
consider using \Glsentrylong
, \Glsentryshort
or \Glsentryfull
.
Expands to the value of the text field. The corresponding sentence case command is:
Expands to the value of the plural field. The corresponding sentence case command is:
Expands to the value of the first field. The corresponding sentence case command is:
Expands to the value of the firstplural field. The corresponding sentence case command is:
Expands to the value of the description field. Note that within glossary styles, the description is displayed using
\glossentrydesc
.
The corresponding sentence case command is:
Expands to the value of the descriptionplural field. The corresponding sentence case command is:
Expands to the value of the symbol field. Note that within glossary styles, the description is displayed using
\glossentrysymbol
.
The corresponding sentence case command is:
Expands to the value of the symbolplural field. The corresponding sentence case command is:
Expands to the value of the user1 field. The corresponding sentence case command is:
Expands to the value of the user2 field. The corresponding sentence case command is:
Expands to the value of the user3 field. The corresponding sentence case command is:
Expands to the value of the user4 field. The corresponding sentence case command is:
Expands to the value of the user5 field. The corresponding sentence case command is:
Expands to the value of the user6 field. The corresponding sentence case command is:
The next two commands, \glsentrynumberlist
and
\glsdisplaynumberlist
, display the entry’s number list. This
information is readily available with Options 1 and 4 (where the
number list is stored in the loclist or
location internal fields) but not for
Options 2 and 3 (where the number list is simply part of
the code to typeset the glossary written in the glossary file).
If you need to parse the number list, split it into groups based on the location counter, or extract a primary location then Option 4 (bib2gls) is your best option.
Displays the number list for the given entry in the same format as it’s shown by default in the glossary. The locations will have hyperlinks if supported.
This command is at its simplest with Option 4, where it just
displays the value of the location internal field that’s
set by bib2gls in the glstex file. This will use the
delimiters supplied by bib2gls (\bibglsdelimN
and
\bibglslastDelimN
) for individual locations as well as \delimR
for ranges, as used in the glossary.
With Option 1, \glsentrynumberlist
passes the value of
the entry’s loclist internal field (that’s created when
the aux file is input) to \glsnoidxloclist
(which is
also used by \printnoidxglossary
). This will result in a simple
list with each location separated with \delimN
, as used in
the glossary. Note that this doesn’t allow for ranges (as with
\printnoidxglossary
).
With Options 2 and 3, you will need the savenumberlist
package option, which will attempt to gather the number list
information when the glossary file is input by
\printglossary
. Since glossaries often occur at the end
of the document, this means that the information has to be saved in
the aux file for the next LaTeX run. Therefore an extra
LaTeX call is required if \glsentrynumberlist
is needed with
makeindex or xindy. This will use the same \delimN
and \delimR
as used in the glossary.
This attempts to display the number list with the separators: between each location except for the last pair and between the last pair.
As with \glsentrynumberlist
, this is again at its simplest with
Option 4. This works by locally setting \bibglsdelimN
to
\glsnumlistsep
and \bibglslastDelimN
to
\glsnumlistlastsep
and then displaying the value of the
location field. You can instead simply redefine
\bibglsdelimN
and \bibglslastDelimN
as desired and use
\glsentrynumberlist
.
With Option 1, the number list information is stored in
the loclist internal field, which is in the format of an
etoolbox internal list. So with Option 1,
\glsdisplaynumberlist
uses etoolbox’s \forlistloop
to iterate over the field value using the handler macro:
If hyperref has been loaded, \glsdisplaynumberlist
doesn’t work with Options 2 and 3. In which case, a warning will
be triggered and \glsentrynumberlist
will be used instead.
Without hyperref, the savenumberlist package option is
still required, and an attempt will be made to parse the formatted
number list created by makeindex/xindy in
order to obtain the desired result.
\glsdisplaynumberlist
is fairly experimental. It works best with
Option 4, works with limited results with Option 1, but
for Options 2 or 3 it only works when the default
location format is used (that is, with the default
formatglsnumberformat). This command will only work with
hyperref if you choose Options 1 or 4.
6. Acronyms and Other Abbreviations[link]
Acronyms internally use \newglossaryentry
, so you can
reference them with \gls
and \glspl
as with other
entries. Whilst it is possible to simply use
\newglossaryentry
explicitly with the
first and text keys set to provide a full form on
first use and a shortened form on subsequent use, using
\newacronym
establishes a consistent format. It also makes it
possible to shift the optional argument of the
\gls
-like commands inside the full form, so that it is placed
before the parentheses.
The way the acronym is displayed on first use is
governed by the acronym style that’s identified with
\setacronymstyle
. This should be set before you define
your acronyms.
\newacronym
:
\documentclass
{article}\usepackage
{glossaries}\setacronymstyle
{long-short}\newacronym
{html}{HTML}{hypertext markup language}\newacronym
{xml}{XML}{extensible markup language}\begin{document}
First use:\gls
{html} and\gls
{xml}. Next use:\gls
{html} and\gls
{xml}.\end{document}
Acronyms are defined using:
This creates a glossary entry with the given label. This automatically sets type={\acronymtype
} but if the acronym should go in
another glossary you can set the type in the
optional argument , which is added to the end of
the in \newglossaryentry
.
The \newacronym
command also uses the long,
longplural, short and shortplural keys
in \newglossaryentry
to store the long and short forms and
their plurals.
\newacronym
with glossaries-extra, you need to
first set the abbreviation style for the acronym category with:
\setabbreviationstyle
[acronym]{ }
Note that the same restrictions on \newglossaryentry
also apply to \newacronym
(see
§4). Since \newacronym
is defining
the entry with \newglossaryentry
, you can use \glsreset
to
reset the first use flag.
\DeclareAcronymList
) if you have multiple lists of
acronyms. See §2.7.
Alternatively, use glossaries-extra to have better support for
a mixed glossaries.
The optional argument \newglossaryentry
can also be used here in
, but be careful about overriding any keys that are set
by the acronym style, such as name, short
and long.
For example, you may need to supply description (when used with one of the styles that require a description, described in §6.2) or you can override plural forms of or using the shortplural or longplural keys. For example:
\newacronym
[longplural={diagonal matrices}]
{dm}{DM}{diagonal matrix}
If the first use uses the plural form, \glspl
{dm}
will
display: diagonal matrices (DMs).
As with plural, if longplural is missing, it’s
obtained by appending \glspluralsuffix
to the singular form. The
short plural shortplural is obtained (if not explicitly
set in ) by appending:
\newacronym
implicitly sets
type={\acronymtype
}, if you want to load a
file containing acronym definitions using \loadglsentries
, the
optional argument that specifies the glossary will not have an
effect unless you explicitly set
type={\glsdefaulttype
} in the optional argument to
\newacronym
. See §4.6.
Example 25 defines the acronym IDN and then uses it in the document text. It then resets the first use flag and uses it again.
The reset (\setacronymstyle
{long-short}\newacronym
{idn}{IDN}{identification number}\begin{document}
First use:\gls
{idn}. Next use:\gls
{idn}.\glsreset
{idn}% reset first use The\gls
{idn}['s] prefix is a capital letter. Next use: the\gls
{idn}['s] prefix is a capital letter.\end{document}
\glsreset
) makes the next instance of \gls
behave as first use. Note also the way the final
optional argument is treated.
If the acronym had simply been defined with:
\newglossaryentry
{idn}{
nameIDN,
firstidentification number (IDN),
descriptionidentification number
}
then the first use of \gls
{idn}['s]
would have placed in the
after the parentheses:
If you want to use one of the small caps acronym styles, described in §6.2, you need to use lowercase characters for the shortened form:
\setacronymstyle
{long-sc-short}\newacronym
{idn}{idn}{identification number}
Recall from the warning in §4 that you
should avoid using the \gls
-like and \glstext
-like commands
within the value of keys like text and first due
to complications arising from nested links. The same applies to
acronyms defined using \newacronym
.
For example, suppose you have defined:
you may be tempted to do:\newacronym
{ssi}{SSI}{server side includes}\newacronym
{html}{HTML}{hypertext markup language}
Don’t! This will break the case-changing commands, such as\newacronym
{shtml}{S\gls
{html}}{\gls
{ssi} enabled\gls
{html}}
\Gls
, it will cause inconsistencies on first use, and,
if hyperlinks are enabled, will cause nested
hyperlinks, and it will index the nested
entries every time the dependent entry is indexed,
which creates unnecessary locations. It will
also confuse the commands used by the entry formatting (such as
\glslabel
).
Instead, consider doing:
or if the font needs to match the style:\newacronym
[description={\gls
{ssi} enabled\gls
{html}}] {shtml}{SHTML}{SSI enabled HTML}
Alternatively:\newacronym
[description={\gls
{ssi} enabled\gls
{html}}] {shtml}{SHTML}{\acronymfont
{SSI} enabled\acronymfont
{HTML}}
Similarly for the\newacronym
[description={\gls
{ssi} enabled\gls
{html}}] {shtml}{SHTML} {server side includes enabled hypertext markup language}
\glstext
-like commands.
6.1. Displaying the Long, Short and Full Forms (Independent of First Use)[link]
It may be that you want the long, short or full form regardless of whether or not the acronym has already been used in the document. You can do so with the commands described in this section.
The \acr…
commands described below are part of the set
of \glstext
-like commands. That is, they index
and can form hyperlinks, and they don’t modify or test the
first use flag. However, unlike the other \glstext
-like
commands, their display is governed by
\defglsentryfmt
with \glscustomtext
set to the appropriate
link text. So, for example,
\acrshort
{ }[ ]
is similar to:
except that the first use flag isn’t unset.\glsdisp
{%\acronymfont
{\glsentryshort
{ }} }
All caveats that apply to the \glstext
-like commands also apply
to the following commands. (Including the above warning about
nested links.)
\glsxtr…
or \glsfmt…
commands. For example, \glsxtrshort
instead of \acrshort
or, if needed in a heading, \glsfmtshort
. (Similarly for the
case-changing variants.)
The optional arguments are the same as those for the \glstext
-like
commands, and there are similar star (*
) and plus
(+
) variants that switch
off or on the hyperlinks. As with the \glstext
-like commands, the
link text is placed in the argument of \glstextformat
.
This sets the link text to the short form (within the argument of
\acronymfont
) for the acronym given by . The short
form is as supplied by the short key, which
\newacronym
implicitly sets.
There are also analogous case-changing variants:
(sentence case) and (all caps).There are also plural versions:
As\acrshort
but uses the shortplural value.
(sentence case) and
(all caps).
This sets the link text to the long form for the acronym given by . The long form is as supplied by the long key, which
\newacronym
implicitly sets.
There are also analogous case-changing variants:
(sentence case) and (all caps).Again there are also plural versions:
As\acrlong
but uses the longplural value.
(sentence case) and
(all caps).
This sets the link text to show the full form according to the format governed by the acronym style. This may not necessarily be the same format as that produced on the first use of
\gls
.
For example, the footnote style has the long form in a
footnote on the first use of \gls
but \acrfull
has the long form in
parentheses instead.
There are also analogous case-changing variants:
(sentence case) and (all caps).The plural version is:
with case-changing variants: (sentence case) and (all caps).If you find the above commands too cumbersome to write, you can use the shortcuts package option to activate the shorter command names listed in Table 6.1.
Shortcut Command | Equivalent Command |
---|---|
\acs |
\acrshort |
\Acs |
\Acrshort |
\acsp |
\acrshortpl |
\Acsp |
\Acrshortpl |
\acl |
\acrlong |
\Acl |
\Acrlong |
\aclp |
\acrlongpl |
\Aclp |
\Acrlongpl |
\acf |
\acrfull |
\Acf |
\Acrfull |
\acfp |
\acrfullpl |
\Acfp |
\Acrfullpl |
\ac |
\gls |
\Ac |
\Gls |
\acp |
\glspl |
\Acp |
\Glspl
|
It is also possible to access the long and short forms without
indexing using commands analogous to \glsentrytext
(described in §5.2). These don’t include the
acronym font commands, such as \acronymfont
.
Expands to the long form (that is, the value of the long key, which is internally set by
\newacronym
).
The corresponding sentence case command is:
Expands to the long plural form (that is, the value of the longplural). The corresponding sentence case command is:
Expands to the short form (that is, the value of the short key, which is internally set by
\newacronym
).
The corresponding sentence case command is:
An similar command is available for the full form:
This command is redefined by the acronym style. Unlike\glsentrylong
and \glsentryshort
, this does include
\acronymfont
, so if you need to use it in a section heading,
you may need to disable it in PDF bookmarks:
\pdfstringdefDisableCommands
{% provided by hyperref\let
\acronymfont
\@firstofone
\let
\firstacronymfont
\@firstofone
}
This is like
\glsentryfull
but applies sentence case.
The analogous plural commands are:
(no case change) and (sentence case).
6.2. Changing the Acronym Style[link]
\setabbreviationstyle
to set
the abbreviation style. This uses a different (but more consistent) naming
scheme. For example, long-noshort instead of
dua. See the “Abbreviations” chapter in the
glossaries-extra manual for further details.
The acronym style is set using:
where is the name of the required style. The style must be set before the acronyms are defined otherwise you will end up with inconsistencies.For example:
\usepackage
[acronym]{glossaries}\makeglossaries
\setacronymstyle
{long-sc-short}\newacronym
{html}{html}{hypertext markup language}\newacronym
{xml}{xml}{extensible markup language}
Unpredictable results will occur if you try to use multiple styles
since each acronym style redefines commands like
\glsentryfull
and \genacrfullformat
that govern the way
the full form is displayed. The closest you can get to different
styles if you only want to use the base glossaries package is
to adjust the entry format (see §5.1.4)
or to provide a custom acronym style such as in
Example 14.
The \setacronymstyle
command will redefine \newacronym
to
use the newer acronym mechanism introduced in version 4.02
(2013-12-05). The older mechanism was available, but deprecated, for
backward-compatibility until version 4.50 when it was removed. If
the pre-4.02 acronym styles are required, you will need to use
rollback. As from v4.50, if you don’t use \setacronymstyle
, the
first instance of \newacronym
will automatically implement:
\setacronymstyle
{long-short}
which is the closest match to the old default.
Example 26 is a modification of the earlier
Example 25 so that it uses rollback in order to
demonstrate the difference:
This produces: The most noticeable difference is the way the optional argument is treated with\usepackage
{glossaries}[=v4.46]% rollback to v4.46 % no\setacronymstyle
so old style used\newacronym
{idn}{IDN}{identification number}\begin{document}
First use:\gls
{idn}. Next use:\gls
{idn}.\glsreset
{idn}% reset first use The\gls
{idn}['s] prefix is a capital letter. Next use: the\gls
{idn}['s] prefix is a capital letter.\end{document}
\gls
on first use (\gls
{idn}['s]
).
With the old way, \newacronym
simply set
firstidentification number (IDN) when it internally used
\newglossaryentry
to define the acronym. The default
entry format simply appends the after the value of
the first key.
Unlike the original pre-4.02 behaviour of \newacronym
, the
styles set via \setacronymstyle
don’t use the first
key, but instead they use \defglsentryfmt
to
set a custom display style that uses the long and short
keys (or their plural equivalents). This means that these styles
cope better with plurals that aren’t formed by simply appending the
singular form with the letter “s”. In fact, most of the predefined
styles use \glsgenacfmt
and modify the definitions of commands
like \genacrfullformat
. If the original behaviour is still
required for some reason, use rollback.
In both the old and new implementation, the text key is set to
the short form. Since the first isn’t set with the new
form, it will default to the value of the text key. This
means that with the new implementation, \glsfirst
will
produce the same result as \glstext
. This is why you need to
use \acrlong
or \acrfull
instead. Alternatively, reset the
first use flag and use \gls
.
When you use \setacronymstyle
the name key is set to:
\newacronym
. Protected expansion is performed on \acronymsort
when the acronym is defined.
6.2.1. Predefined Acronym Styles[link]
The glossaries package provides a number of predefined acronym styles. These styles apply:
to the short form on first use and on subsequent use. The styles modify the definition of\acronymfont
and \firstacronymfont
as required. Usually,
\firstacronymfont
{ }
simply does
\acronymfont
{ }
.
If you want the short form displayed differently on first use, you
can redefine \firstacronymfont
after the acronym style is
set.
The predefined small caps styles that contain “sc” in their
name (for example long-sc-short) redefine
\acronymfont
to use \textsc
, which means that the short
form needs to be specified in lowercase if it should be
rendered in small caps. This is because small caps has
small capital glyphs for lowercase letters but normal sized
capital glyphs for uppercase letters, which means there’s no
visual difference between a normal upright font and a
small caps font if the text is in all caps.
This is demonstrated in
\setacronymstyle
{long-sc-short}\newacronym
{mathml}{MathML}{mathematical markup language}\begin{document}
\acrshort
{mathml}\end{document}
\glsnamefont
(see §8) to switch to
medium weight if you are using a glossary style that displays
entry names in bold and you have chosen an acronym style that uses
\textsc
. (Alternatively, switch to a font that does support bold
small caps.)
The predefined glossary styles that contain “sm” in their name
(for example long-sm-short) redefine \acronymfont
to
use \textsmaller
.
\textsmaller
. If you use one of the acronym styles that
set \acronymfont
to \textsmaller
you must
explicitly load the relsize package or otherwise define
\textsmaller
.
The remaining predefined styles redefine \acronymfont
to simply do its argument without any font change.
\acrfull
and
\glsentryfull
(and their plural and case-changing variants) to
reflect the style.
When acronyms are defined, \newacronym
will set the
sort key to \acronymsort
.
The acronym styles redefine this to suit the style. This
command must fully expand in order for the indexing application to pick
up the correct sort value.
If the sort key is set in the optional argument of
\newacronym
, it will override this.
The name key is set to \acronymentry
.
Again, the acronym styles redefine this to suit the style.
If the name key is set in the optional argument of
\newacronym
, it will override this.
The type key is set to \acronymtype
.
If the type key is set in the optional argument of
\newacronym
, it will override this.
The shortplural is set to the short form appended by:
This is redefined by the acronym styles to the appropriate suffix. In most cases, it will simply be defined to\glspluralsuffix
, but the small caps styles define it to:
This uses:
to cancel the effect of the small caps font command \textsc
.
If the shortplural key is set in the optional argument of
\newacronym
, it will override this default.
The longplural is set to the long form appended by
\glspluralsuffix
.
If the longplural key is set in the optional argument of
\newacronym
, it will override this default.
Some styles set the description key to the long form, but others don’t.
If you use a style that doesn’t set it, you will have to supply the
description in the optional argument of \newacronym
.
6.2.1.1. Long (Short)[link]
With the “long (short)” styles, acronyms are displayed in the form:
\firstacronymfont
{ })
on (first use and
\acronymfont
{ }
on subsequent use.
They also set \acronymsort
so that it just expands to its first
argument . This means that the acronyms are sorted according to
their short form. In addition, \acronymentry
{label} is set
to just the short form (enclosed in \acronymfont
) and the
description key is set to the long form.
This is the default style that will be implemented if
\setacronymstyle
isn’t used (as from v4.50, which has removed
the default deprecated style). This shows the long form followed by
the short form in parentheses on first use and also with
\acrfull
. This redefines \acronymfont
to simply do its
argument.
This is like long-short but uses small caps for the short form, so it redefines
\acronymfont
to use \textsc
and \acrpluralsuffix
to \glsacrpluralsuffix
.
This is like long-short but uses
\textsmaller
for the
short form, so it redefines \acronymfont
to use
\textsmaller
. This style will require relsize to be
loaded.
This is like long-short but instead of simply using a space between the long and short form, it uses: This measures the short form for the given entry and, if the width is smaller than 3em, it will use non-breaking space (
~
). Otherwise it will use
\space
.
\glsacspace
to use
\glsacspacemax
instead of the hard-coded 3em, as
\glsacspace
may also be useful in abbreviation styles.
\setacronymstyle
{footnote-sc-desc}
and then redefine \acronymsort
and \acronymentry
:
(I’ve used\renewcommand
*{\acronymsort
}[2]{#1}% sort by short form\renewcommand
*{\acronymentry
}[1]{% short (long) name\acronymfont
{\glsentryshort
{#1}}\space
(\glsentrylong
{#1})}%
\space
for extra clarity, but you can just use an
actual space instead.)
Note that the default Computer Modern fonts don’t support bold small caps, so another font is required. For example:
\usepackage
[T1]{fontenc}
The alternative is to redefine \acronymfont
so that it
always switches to medium weight to ensure the small caps setting is
used. For example:
\renewcommand
*{\acronymfont
}[1]{\textmd
{\scshape
#1}}
The sample file sampleFnAcrDesc.tex illustrates this example.
6.2.1.2. Short (Long)[link]
With the “short (long)” styles, acronyms are displayed in the form:
\firstacronymfont
{ } ( )
on first use and
\acronymfont
{ }
on subsequent use.
They also set \acronymsort
{short}{long} to just
. This means that the acronyms are sorted according to
their short form. In addition, \acronymentry
{label} is set
to just the short form (enclosed in \acronymfont
) and the
description key is set to the long form.
This shows the short form followed by the long form in parentheses on first use and also with
\acrfull
. This redefines \acronymfont
to simply do its
argument.
This is like short-long but uses small caps for the short form, so it redefines
\acronymfont
to use \textsc
and \acrpluralsuffix
to \glsacrpluralsuffix
.
This is like short-long but uses
\textsmaller
for the
short form, so it redefines \acronymfont
to use
\textsmaller
. This style will require relsize to be
loaded.
6.2.1.3. Long (Short) User Supplied Description[link]
This is like long-short but the description key must be provided in the optional argument of
\newacronym
.
The sort value command \acronymsort
is redefined to expand to
its second argument ( ), and \acronymentry
is
redefined to show the long form followed by the short form in
parentheses.
This is like long-short-desc except that it uses small caps, as long-sc-short.
This is like long-short-desc except that it uses
\textsmaller
, as long-sm-short.
This is like long-short-desc except that it uses
\glsacspace
, as long-sp-short.
6.2.1.4. Short (Long) User Supplied Description[link]
This is like short-long but the description key must be provided in the optional argument of
\newacronym
.
The sort value command \acronymsort
is redefined to expand to
its second argument ( ), and \acronymentry
is
redefined to show the long form followed by the short form in
parentheses.
This is like short-long-desc except that it uses small caps, as long-sc-short.
This is like short-long-desc except that it uses
\textsmaller
, as long-sm-short.
6.2.1.5. Do Not Use Acronym (DUA)[link]
With these styles, the \gls
-like commands always display the long form
regardless of whether the entry has been first useused or not.
However, \acrfull
and \glsentryfull
will display the long form followed by the
short form, as per the long-short style.
The sort value command
\acronymsort
expands to just its second
argument (the long form), and \acronymentry
shows just the
long form.
The sort value command
\acronymsort
expands to just its second
argument (the long form), and \acronymentry
shows just the
long form.
6.2.1.6. Footnote[link]
With these styles, the \gls
-like commands show the short form
followed by the long form in a footnote on first use.
The footnote is simply added with \footnote
.
The \acrfull
set of commands show the short form followed by the
long form in parentheses (as per styles like short-long).
The definitions of \acronymsort
and \acronymentry
are as
for the “short (long)” styles described in §6.2.1.2.
This defines
\acronymentry
, \acronymsort
and \acronymfont
in the same way as the short-long style
This defines
\acronymentry
, \acronymsort
,
\acronymfont
and \acrpluralsuffix
in the same way as the
sc-short-long style
This defines
\acronymentry
, \acronymsort
and
\acronymfont
in the same way as the
sm-short-long style
This defines
\acronymentry
, \acronymsort
and \acronymfont
in the same way as the short-long-desc style
This defines
\acronymentry
, \acronymsort
and \acronymfont
in the same way as the sc-short-long-desc style
This defines
\acronymentry
, \acronymsort
and \acronymfont
in the same way as the sm-short-long-desc style
6.2.2. Defining A Custom Acronym Style[link]
You may find that the predefined acronym styles that come with the glossaries package don’t suit your requirements. In this case you can define your own style using:
where is the name of the new style (avoid active characters). The second argument, , is equivalent to the argument of\defglsentryfmt
. You can simply use
\glsgenacfmt
or you can customize the display using commands
like \ifglsused
, \glsifplural
and \glscapscase
.
(See §5.1.4 for further details.)
If the style is likely to be used with a mixed glossary (that
is, entries in that glossary are defined both with \newacronym
and
\newglossaryentry
) then you can test if the entry is an
acronym and use \glsgenacfmt
if it is or \glsgenentryfmt
if it
isn’t. For example, the long-short style sets
as
(You can use\ifglshaslong
{\glslabel
}{\glsgenacfmt
}{\glsgenentryfmt
}
\ifglshasshort
instead of \ifglshaslong
to
test if the entry is an acronym if you prefer.)
The third argument, \acronymfont
and \genacrfullformat
.
##
rather than
to reference parameters in command definitions within
.
Note that \setacronymstyle
redefines \glsentryfull
and
\acrfullfmt
to use \genacrfullformat
(and similarly for
the plural and case-changing variants). If this isn’t appropriate for the
style (as in the case of styles like footnote and
dua) \newacronymstyle
should redefine these commands
within .
Within \newacronymstyle
’s argument you
can also redefine:
\newglossaryentry
, when it’s internally called by
\newacronym
.
You can use the following token registers to access information
passed to the arguments of \newacronym
.
Contains the options.
Contains the .
Contains the form argument.
Contains the form argument.
As with all token registers, you can obtain the value of the
register with \the
. For example, the
long-short style does:
which sets the description field to the long form of the acronym whereas the long-short-desc style does:\renewcommand
*{\GenericAcronymFields
}{% description={\the
\glslongtok
}}
since the description needs to be specified by the user.\renewcommand
*{\GenericAcronymFields
}{}
It may be that you want to define a new acronym style that’s based on an existing style. Within of the new style, you can use
to use the definition from the style given by .Within
of the new style, you can use to use the from the style given by .For example, the long-sc-short acronym style is based on the long-short style with minor modifications:
\newacronymstyle
{long-sc-short}% {% use the same display as long-short\GlsUseAcrEntryDispStyle
{long-short}% }% {% use the same definitions as long-short\GlsUseAcrStyleDefs
{long-short}% % Minor modifications:\renewcommand
{\acronymfont
}[1]{\textsc
{##
1}}%\renewcommand
*{\acrpluralsuffix
}{\glstextup
{\glspluralsuffix
}}% }
\gls
on first use
to display:
on subsequent use:\textsc
{ }\footnote
{ : }
\textsc
{ }
and in the list of acronyms, each entry will be displayed in the
form:
( )
Let’s suppose it’s possible that I may have a mixed glossary. I can
check this in the second argument ( ) of \newacronymstyle
using:
This will use\ifglshaslong
{\glslabel
}{\glsgenacfmt
}{\glsgenentryfmt
}
\glsgenentryfmt
if the entry isn’t an acronym,
otherwise it will use \glsgenacfmt
. The third argument
( ) of
\newacronymstyle
needs to redefine \genacrfullformat
etc
so that the first use displays the short form in the text with the
long form in a footnote followed by the description. This is done as
follows:
% No case change, singular first use:If you think it inappropriate for the short form to be capitalised at the start of a sentence you can change the above to:\renewcommand
*{\genacrfullformat
}[2]{%\firstacronymfont
{\glsentryshort
{##
1}}##
2%\footnote
{\glsentrylong
{##
1}:\glsentrydesc
{##
1}}% }% % Sentence case, singular first use:\renewcommand
*{\Genacrfullformat
}[2]{%\firstacronymfont
{\Glsentryshort
{##
1}}##
2%\footnote
{\glsentrylong
{##
1}:\glsentrydesc
{##
1}}% }% % No case change, plural first use:\renewcommand
*{\genplacrfullformat
}[2]{%\firstacronymfont
{\glsentryshortpl
{##
1}}##
2%\footnote
{\glsentrylongpl
{##
1}:\glsentrydesc
{##
1}}% }% % Sentence case, plural first use:\renewcommand
*{\Genplacrfullformat
}[2]{%\firstacronymfont
{\Glsentryshortpl
{##
1}}##
2%\footnote
{\glsentrylongpl
{##
1}:\glsentrydesc
{##
1}}% }
% No case change, singular first use:Another variation is to use\renewcommand
*{\genacrfullformat
}[2]{%\firstacronymfont
{\glsentryshort
{##
1}}##
2%\footnote
{\glsentrylong
{##
1}:\glsentrydesc
{##
1}}% }% % No case change, plural first use:\renewcommand
*{\genplacrfullformat
}[2]{%\firstacronymfont
{\glsentryshortpl
{##
1}}##
2%\footnote
{\glsentrylongpl
{##
1}:\glsentrydesc
{##
1}}% }%\let
\Genacrfullformat
\genacrfullformat
\let
\Genplacrfullformat
\genplacrfullformat
\Glsentrylong
and
\Glsentrylongpl
in the footnote instead of \glsentrylong
and
\glsentrylongpl
.
Now let’s suppose that commands such as \glsentryfull
and
\acrfull
shouldn’t
use a footnote, but instead use the format:
( ).
This means that the style needs to redefine \glsentryfull
,
\acrfullfmt
and their plural and case-changing variants.
First, the non-linking commands:
Now for the linking commands:\renewcommand
*{\glsentryfull
}[1]{%\glsentrylong
{##
1}\space
(\acronymfont
{\glsentryshort
{##
1}})% }%\renewcommand
*{\Glsentryfull
}[1]{%\Glsentrylong
{##
1}\space
(\acronymfont
{\glsentryshort
{##
1}})% }%\renewcommand
*{\glsentryfullpl
}[1]{%\glsentrylongpl
{##
1}\space
(\acronymfont
{\glsentryshortpl
{##
1}})% }%\renewcommand
*{\Glsentryfullpl
}[1]{%\Glsentrylongpl
{##
1}\space
(\acronymfont
{\glsentryshortpl
{##
1}})% }
(This may cause problems with long hyperlinks, in which case adjust the definitions so that, for example, only the short form is inside the argument of\renewcommand
*{\acrfullfmt
}[3]{%\glslink
[##
1]{##
2}%\glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% % }%\renewcommand
*{\Acrfullfmt
}[3]{%\glslink
[##
1]{##
2}%\Glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% % }%\renewcommand
*{\ACRfullfmt
}[3]{%\glslink
[##
1]{##
2}%\glsuppercase
{%\glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% }% % }%\renewcommand
*{\acrfullplfmt
}[3]{%\glslink
[##
1]{##
2}%\glsentrylongpl
{##
2}##
3\space
(\acronymfont
{\glsentryshortpl
{##
2}})% % }%\renewcommand
*{\Acrfullplfmt
}[3]{%\glslink
[##
1]{##
2}%\Glsentrylongpl
{##
2}##
3\space
(\acronymfont
{\glsentryshortpl
{##
2}})% % }%\renewcommand
*{\ACRfullplfmt
}[3]{%\glslink
[##
1]##
2%\glsuppercase
{%\glsentrylongpl
{##
2}##
3 (\acronymfont
{\glsentryshortpl
{##
2}})% }% % }
\glslink
.)
The style also needs to redefine \acronymsort
so that the
acronyms are sorted according to the long form:
If you prefer them to be sorted according to the short form you can change the above to:\renewcommand
*{\acronymsort
}[2]{##
2}
The acronym font needs to be set to\renewcommand
*{\acronymsort
}[2]{##
1}
\textsc
and the plural
suffix adjusted so that the “s” suffix in the plural short form
doesn’t get converted to small caps:
There are a number of ways of dealing with the format in the list of acronyms. The simplest way is to redefine\renewcommand
*{\acronymfont
}[1]{\textsc
{##
1}}%\renewcommand
*{\acrpluralsuffix
}{\glsupacrpluralsuffix
}%
\acronymentry
to the
long form followed by the upper case short form in parentheses:
(I’ve used\renewcommand
*{\acronymentry
}[1]{%\Glsentrylong
{##
1}\space
(\glsuppercase
\glsentryshort
{##
1})}
\Glsentrylong
instead of \glsentrylong
to
capitalise the name in the glossary.)
An alternative approach is to set \acronymentry
to just the
long form and redefine \GenericAcronymFields
to set the
symbol key to the short form and use a glossary style that
displays the symbol in parentheses after the name (such as
the tree style) like this:
I’m going to use the first approach and set\renewcommand
*{\acronymentry
}[1]{\Glsentrylong
{##
1}}%\renewcommand
*{\GenericAcronymFields
}{% symbol={\protect
\glsuppercase
{\the
\glsshorttok
}}}%
\GenericAcronymFields
to do nothing:
\renewcommand
*{\GenericAcronymFields
}{}%
Finally, this style needs to switch off hyperlinks on first use to avoid nested links:
\glshyperfirstfalse
Putting this all together:
\newacronymstyle
{custom-fn}% new style name {% entry format\ifglshaslong
{\glslabel
}{\glsgenacfmt
}{\glsgenentryfmt
}% }% {%\renewcommand
*{\GenericAcronymFields
}{}%\glshyperfirstfalse
% No case change, singular first use:\renewcommand
*{\genacrfullformat
}[2]{%\firstacronymfont
{\glsentryshort
{##
1}}##
2%\footnote
{\glsentrylong
{##
1}:\glsentrydesc
{##
1}}% }% % Sentence case, singular first use:\renewcommand
*{\Genacrfullformat
}[2]{%\firstacronymfont
{\Glsentryshort
{##
1}}##
2%\footnote
{\glsentrylong
{##
1}:\glsentrydesc
{##
1}}% }% % No case change, plural first use:\renewcommand
*{\genplacrfullformat
}[2]{%\firstacronymfont
{\glsentryshortpl
{##
1}}##
2%\footnote
{\glsentrylongpl
{##
1}:\glsentrydesc
{##
1}}% }% % Sentence case, plural first use:\renewcommand
*{\Genplacrfullformat
}[2]{%\firstacronymfont
{\Glsentryshortpl
{##
1}}##
2%\footnote
{\glsentrylongpl
{##
1}:\glsentrydesc
{##
1}}% }% % non-linking commands\renewcommand
*{\glsentryfull
}[1]{%\glsentrylong
{##
1}\space
(\acronymfont
{\glsentryshort
{##
1}})% }%\renewcommand
*{\Glsentryfull
}[1]{%\Glsentrylong
{##
1}\space
(\acronymfont
{\glsentryshort
{##
1}})% }%\renewcommand
*{\glsentryfullpl
}[1]{%\glsentrylongpl
{##
1}\space
(\acronymfont
{\glsentryshortpl
{##
1}})% }%\renewcommand
*{\Glsentryfullpl
}[1]{%\Glsentrylongpl
{##
1}\space
(\acronymfont
{\glsentryshortpl
{##
1}})% }% % linking commands\renewcommand
*{\acrfullfmt
}[3]{%\glslink
[##
1]{##
2}%\glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% % }%\renewcommand
*{\Acrfullfmt
}[3]{%\glslink
[##
1]{##
2}%\Glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% % }%\renewcommand
*{\ACRfullfmt
}[3]{%\glslink
[##
1]{##
2}%\glsuppercase
{%\glsentrylong
{##
2}##
3\space
(\acronymfont
{\glsentryshort
{##
2}})% }% % }%\renewcommand
*{\acrfullplfmt
}[3]{%\glslink
[##
1]{##
2}%\glsentrylongpl
{##
2}##
3\space
(\acronymfont
{\glsentryshortpl
{##
2}})% % }%\renewcommand
*{\Acrfullplfmt
}[3]{%\glslink
[##
1]{##
2}%\Glsentrylongpl
{##
2}##
3\space
(\acronymfont
{\glsentryshortpl
{##
2}})% % }%\renewcommand
*{\ACRfullplfmt
}[3]{%\glslink
[##
1]##
2%\glsuppercase
{%\glsentrylongpl
{##
2}##
3 (\acronymfont
{\glsentryshortpl
{##
2}})% }% % }% % font\renewcommand
*{\acronymfont
}[1]{\textsc
{##
1}}%\renewcommand
*{\acrpluralsuffix
}{\glsupacrpluralsuffix
}% % sort\renewcommand
*{\acronymsort
}[2]{##
2}% % name\renewcommand
*{\acronymentry
}[1]{%\Glsentrylong
{##
1}\space
(\glsuppercase
\glsentryshort
{##
1})}% }
Now I need to specify that I want to use this new style:
\setacronymstyle
{custom-fn}
I also need to use a glossary style that suits this acronym style,
for example altlist:
\setglossarystyle
{altlist}
Once the acronym style has been set, I can define my acronyms:
\newacronym
[description={set of tags for use in developing hypertext documents}]{html}{html}{Hyper Text Markup Language}\newacronym
[description={language used to describe the layout of a document written in a markup language}]{css} {css}{Cascading Style Sheet}
The sample file sample-custom-acronym.tex illustrates this example.
\newacronym
can cause complications.
This example uses \glsaddstoragekey
to add an extra field that
can be used to store the formatting declaration (such as \em
).
This defines a new field/key called font, which defaults to nothing if it’s not explicitly set. This also defines a command called\glsaddstoragekey
{font}{}{\entryfont
}
\entryfont
that’s analogous to \glsentrytext
. A new
style is then created to format acronyms that access this field.
There are two ways to do this. The first is to create a style that
doesn’t use \glsgenacfmt
but instead provides a modified
version that doesn’t use \acronymfont
but instead uses
{The full format given by commands such as\entryfont
{\glslabel
} }.
\genacrfullformat
need to be similarly adjusted. For example:
This will deal with commands like\renewcommand
*{\genacrfullformat
}[2]{%\glsentrylong
{##
1}##
2\space
({\entryfont
{##
1}\glsentryshort
{##
1}})% }%
\gls
but not commands like
\acrshort
which still use \acronymfont
. Another approach
is to redefine \acronymfont
to look up the required font
declaration. Since \acronymfont
doesn’t take the entry label as
an argument, the following will only work if \acronymfont
is
used in a context where the label is provided by \glslabel
.
This is true in \gls
, \acrshort
and \acrfull
. The
redefinition is now:
So the new style can be defined as:\renewcommand
*{\acronymfont
}[1]{{\entryfont
{\glslabel
}##
1}}%
Remember the style needs to be set before defining the entries:\newacronymstyle
{long-font-short} {%\GlsUseAcrEntryDispStyle
{long-short}% }% {%\GlsUseAcrStyleDefs
{long-short}%\renewcommand
*{\genacrfullformat
}[2]{%\glsentrylong
{##
1}##
2\space
({\entryfont
{##
1}\glsentryshort
{##
1}})% }%\renewcommand
*{\Genacrfullformat
}[2]{%\Glsentrylong
{##
1}##
2\space
({\entryfont
{##
1}\glsentryshort
{##
1}})% }%\renewcommand
*{\genplacrfullformat
}[2]{%\glsentrylongpl
{##
1}##
2\space
({\entryfont
{##
1}\glsentryshort
{##
1}})% }%\renewcommand
*{\Genplacrfullformat
}[2]{%\Glsentrylongpl
{##
1}##
2\space
({\entryfont
{##
1}\glsentryshort
{##
1}})% }%\renewcommand
*{\acronymfont
}[1]{{\entryfont
{\glslabel
}##
1}}%\renewcommand
*{\acronymentry
}[1]{{\entryfont
{##
1}\glsentryshort
{##
1}}}% }
\setacronymstyle
{long-font-short}
The complete document is contained in the sample file sample-font-abbr.tex.
Some writers and publishing houses have started to drop
full stops (periods) from uppercase initials but may
still retain them for lowercase abbreviations, while others
may still use them for both upper and
lowercase. This can cause complications. Chapter 12 of
The TeXbook discusses the spacing between words but,
briefly, the default behaviour of TeX is to assume that an
uppercase character followed by a full stop and space is
an abbreviation, so the space is the default inter-word space
whereas a lowercase character followed by a full stop and
space is a word occurring at the end of a sentence, which requires
an inter-sentence space (which may or may not be the same as an
inter-word space). In the event that this isn’t true, you need
to make a manual adjustment using \␣
(backslash space)
in place of just a space character for an inter-word mid-sentence
space and use \@
before the full stop to indicate the end
of the sentence.
For example:
I was awarded a B.Sc. and a Ph.D. (From the same place.)is typeset as
\ttfamily
I was awarded a B.Sc. and a Ph.D. (From the same place.)
is typeset as
I was awarded a B.Sc.\
and a Ph.D\@
. (From the same place.)
This situation is a bit problematic for glossaries. The
full stops can form part of the argument of
\newacronym
and the B.Sc.
part can be dealt with by
remembering to add \␣
\␣
(for example,
but the end of sentence case is more troublesome as you need to omit
the sentence terminating full stop (to avoid two dots) which can
make the source code look a little strange but you also need to
adjust the space factor, which is usually done by inserting
\gls
{bsc}\␣
\@
before the full stop.
The next example shows one way of achieving this.
\glspostlinkhook
)
is called at the very end of the \gls
-like and \glstext
-like
commands. This can be redefined to check if the following character
is a full stop. The amsgen package (which is automatically
loaded by glossaries) provides an internal command
called \new@ifnextchar
that can be used to determine if the
given character appears next. (For more information see the
amsgen documentation. Alternatively, LaTeX3 may provide a
better way of doing this.)
It’s possible that I may also want acronyms or contractions (without full stops) in my document, so I need some way to differentiate between them. Here I’m going to use the same method as in Example 14 where a new field is defined to indicate the type of abbreviation:
Now I just use\glsaddstoragekey
{abbrtype}{word}{\abbrtype
}\newcommand
*{\newabbr
}[1][]{\newacronym
[abbrtype=initials,#1]}
\newacronym
for the acronyms, for example,
\newacronym
{laser}{laser}{light amplification by stimulated
emission of radiation}
and my new command \newabbr
for initials, for example,
Within\newabbr
{eg}{e.g.}{exempli gratia}\newabbr
{ie}{i.e.}{id est}\newabbr
{bsc}{B.Sc.}{Bachelor of Science}\newabbr
{ba}{B.A.}{Bachelor of Arts}\newabbr
{agm}{A.G.M.}{annual general meeting}
\glspostlinkhook
the entry’s label can be accessed using
\glslabel
and \ifglsfieldeq
can be used to determine if
the current entry has the new abbrtype field set to
“initials”. If it doesn’t, then nothing needs to happen, but if
it does, a check is performed to see if the next character is
a full stop. If it is, this signals the end of a sentence otherwise it’s
mid-sentence.
Remember that internal commands within the document file (rather
than in a class or package) need to be placed between
\makeatletter
and \makeatother
:
In the event that a full stop is found then\makeatletter
\renewcommand
{\glspostlinkhook
}{%\ifglsfieldeq
{\glslabel
}{abbrtype}{initials}% {\new@ifnextchar
.
\doendsentence
\doendword
} {}% }\makeatother
\doendsentence
is
performed, but it will be followed by the full stop, which needs to
be discarded. Otherwise \doendword
will be done, but it won’t be
followed by a full stop so there’s nothing to discard. The
definitions for these commands are:
Now, I can just do\newcommand
{\doendsentence
}[1]{\spacefactor
=10000 }\newcommand
{\doendword
}{\spacefactor
=1000 }
\gls
{bsc}
mid-sentence and
\gls
{phd}.
at the end of the sentence.
The terminating full stop will be discarded in the latter case,
but it won’t be discarded in, say,
\gls
{laser}.
as that doesn’t have the
abbrtype field set to “initials”.
This also works on first use when the style is set to one of the
( ) styles but it will fail with the
( ) styles as in this case the terminating
full stop shouldn’t be discarded. Since \glspostlinkhook
is
used after the first use flag has been unset for the entry, this
can’t be fixed by simply checking with \ifglsused
. One possible
solution to this is to redefine \glslinkpostsetkeys
to check
for the first use flag and define a macro that can then be used in
\glspostlinkhook
.
The other thing to consider is what to do with plurals. One
possibility is to check for plural use within \doendsentence
(using \glsifplural
) and put the full stop back if the plural
has been used.
The complete document is contained in the sample file sample-dot-abbr.tex.
6.3. Displaying the List of Acronyms[link]
The list of acronyms is just like any other type of glossary and can
be displayed on its own using the appropriate
\print
glossary command, according to the
indexing method.
For example, Option 1:
\printnoidxglossary
[type=\acronymtype
]
Or if you have used the acronym or acronyms package option:\printglossary
[type=\acronymtype
]
\printacronyms
See §2.7.)
Alternatively, the list of acronyms can be displayed with all the other
glossaries using \printnoidxglossaries
(Option 1)
or \printglossaries
(Options 2 or 3).
The remaining indexing methods require glossaries-extra, which has its own abbreviation commands that are incompatible with the base acronym commands.
6.4. Upgrading From the glossary Package[link]
Users of the obsolete glossary package may recall that
the syntax used to define new acronyms has changed with the
replacement glossaries package. In addition, the old
glossary package created the command
\
when defining the acronym .
In order to facilitate migrating from the old glossary package to the new one, the glossaries package provides the command:
This uses the same syntax as the glossary package’s method of defining acronyms. It is equivalent to:\newacronym
[ ]{ }{ }{ }
In addition, \oldacronym
also defines the commands
\
, which is equivalent to
\gls
{ }
, and \
, which is
equivalent to the *sentence case \Gls
{ }
.
If is omitted, is used. Since commands
names must consist only of alphabetical characters,
must also only consist of alphabetical characters. Note that
\
doesn’t allow you to use the first optional
argument of \gls
or \Gls
—you will need to explicitly
use \gls
or \Gls
to change the settings.
\
unless you additionally load the xspace
package, but be aware that there are some issues with using
xspace. (See David Carlisle’s explanation in
Drawbacks
of xspace.)
The glossaries package doesn’t load the xspace package
since there are both advantages and disadvantages to using
\xspace
in \
. If you don’t use the
xspace package, then you need to explicitly force a space
using \␣
(backslash space). On the other hand, you can
follow the \
command with the optional
text in square brackets (the final optional argument
to \gls
). If you use the xspace package you don’t need to
escape the spaces but you can’t use the optional argument to insert
text (you will have to explicitly use \gls
to achieve that).
To illustrate this, suppose I define the acronym “abc” as follows:
\oldacronym
{abc}{example acronym}{}
This will create the command \abc
and its starred version
\abc*
. Table 6.2 illustrates the effect of
\abc
(on subsequent use) according to whether or not the
xspace package has been loaded. As can be seen from the
final row in the table, the xspace package prevents the
optional argument from being recognised.
Code | With xspace | Without xspace |
---|---|---|
\abc. |
abc. | abc. |
\abc xyz |
abc xyz | abcxyz |
\abc |
abc xyz | abc xyz |
\abc* xyz |
Abc xyz | Abc xyz |
\abc['s] xyz |
abc [’s] xyz | abc’s xyz |
7. Unsetting and Resetting Entry Flags[link]
When using the \gls
-like commands it is possible that you may
want to use the value given by the first key, even though
you have already used the glossary entry.
Conversely, you may want to use the value given by the
text key, even though you haven’t used the
glossary entry.
The former can be achieved by one of the following commands:
which globally resets the first use flag and which locally resets the first use flag.The latter can be achieved by one of the following commands:
which globally unsets the first use flag and which locally unsets the first use flag.The above commands are for the specific entry identified by the argument . You can also reset or unset all entries for a given glossary or multiple glossaries using:
which globally resets the first use flags and which locally resets the first use flags or which globally unsets the first use flags and which locally unsets the first use flags.The optional argument glossary labels. If omitted, the list of all non-ignored glossaries is assumed.
should be a comma-separated list of
For example, to reset all entries in the main
glossary and the
acronym
list:
\glsresetall
[main
,acronym
]
\gls
-like
commands, that will unset or reset the first use flag before the
link text, which will make the \gls
-like command behave
as though it was the subsequent use or first use,
irrespective of whether or not the entry has actually been
used.
You can determine whether an entry’s first use flag is set with
\ifglsused
. With bib2gls, you may need to use
\GlsXtrIfUnusedOrUndefined
instead.
\gls
-like commands within an
environment or command argument that gets processed multiple times
as it can cause unwanted side-effects when the first use displayed
text is different from subsequent use.
For example, the frame environment in beamer processes its argument for each overlay. This means that the first use flag will be unset on the first overlay and subsequent overlays will use the subsequent use form.
Consider the following example:
\documentclass
{beamer}\usepackage
{glossaries}\newacronym
{svm}{SVM}{support vector machine}\begin{document}
\begin{frame}
\frametitle
{Frame 1}\begin{itemize}
\item
<+->\gls
{svm}\item
<+-> Stuff.\end{itemize}
\end{frame}
\end{document}
On the first overlay,
produces “support vector
machine (SVM)” and then unsets the first use flag. When the second
overlay is processed, \gls
{svm}
now produces “SVM”, which
is unlikely to be the desired effect. I don’t know anyway around
this and I can only offer the following suggestions.
\gls
{svm}
- 1.Unset all acronyms at the start of the document and
explicitly use
\acrfull
when you want the full version to be displayed:\documentclass
{beamer}\usepackage
{glossaries}\newacronym
{svm}{SVM}{support vector machine}\glsunsetall
\begin{document}
\begin{frame}
\frametitle
{Frame 1}\begin{itemize}
\item
<+->\acrfull
{svm}\item
<+-> Stuff.\end{itemize}
\end{frame}
\end{document}
- 2.Explicitly reset each acronym on first use:
Alternatively, with glossaries-extra:\begin{frame}
\frametitle
{Frame 1}\begin{itemize}
\item
<+->\glsreset
{svm}\gls
{svm}\item
<+-> Stuff.\end{itemize}
\end{frame}
\documentclass
{beamer}\usepackage
{glossaries-extra}\newabbreviation
{svm}{SVM}{support vector machine}\begin{document}
\begin{frame}
\frametitle
{Frame 1}\begin{itemize}
\item
<+->\gls
[prereset]{svm}\item
<+-> Stuff.\end{itemize}
\end{frame}
\end{document}
- 3.Use the glossaries-extra package’s unset buffering
mechanism:
See the glossaries-extra manual for further details.\documentclass
{beamer}\usepackage
{glossaries-extra}\newabbreviation
{svm}{SVM}{support vector machine}\begin{document}
\GlsXtrStartUnsetBuffering
\GlsXtrUnsetBufferEnableRepeatLocal
\begin{frame}
\GlsXtrResetLocalBuffer
\frametitle
{Frame 1}\begin{itemize}
\item
<+->\gls
{svm}\item
<+-> Stuff.\end{itemize}
\end{frame}
\GlsXtrStopUnsetBuffering
\end{document}
These are non-optimal, but the beamer class is too complex for me to provide a programmatic solution. Other potentially problematic environments are some tabular-like environments (but not tabular itself) that process the contents in order to work out the column widths and then reprocess the contents to do the actual typesetting.
The amsmath environments, such as align, also process
their contents multiple times, but the glossaries package now
checks for this. For tabularx, you need to explicitly patch it
by placing \glspatchtabularx
in the preamble (or anywhere
before the problematic use of tabularx).
7.1. Counting the Number of Times an Entry has been Used (First Use Flag Unset)[link]
It’s possible to keep track of how many times an entry is used. That is, how many times the first use flag is unset. Note that the supplemental glossaries-extra package improves this function and also provides per-unit counting, which isn’t available with the glossaries package.
\newglossaryentry
(and therefore \newacronym
) into
a preamble-only command.
To enable this function, use:
before defining your entries. This adds two extra (internal) fields to entries: currcount and prevcount.
The currcount field keeps track of how many times
\glsunset
is used within the document. A local unset (using
\glslocalunset
) performs a local rather than global increment to
currcount. Remember that not all commands use
\glsunset
. Only the \gls
-like commands do this.
The behaviour of the reset commands depend on the conditional:
If true, the reset commands\glsreset
and \glslocalreset
will reset the value of the currcount field back to 0.
This conditional can be set to true with:
and to false with:
The default is false, as from version 4.50.
The prevcount field stores the final value of the currcount field from the previous run. This value is read from the aux file at the beginning of the document environment.
You can access these fields using
for the currcount field, and for the prevcount field.
For example:
On the first LaTeX run,\documentclass
{article}\usepackage
{glossaries}\makeglossaries
\glsenableentrycount
\newglossaryentry
{apple}{name={apple},description={a fruit}}\begin{document}
Total usage on previous run:\glsentryprevcount
{apple}.\gls
{apple}.\gls
{apple}.\glsadd
{apple}\glsentrytext
{apple}.\glslink
{apple}{apple}.\glsdisp
{apple}{apple}.\Gls
{apple}. Number of times apple has been used:\glsentrycurrcount
{apple}.\end{document}
\glsentryprevcount
{apple}
produces 0. At the end of the document,
\glsentryprevcount
{apple}
produces 4. This is because
the only commands that have incremented the entry count are those
that use \glsunset
. That is: \gls
, \glsdisp
and
\Gls
. The other commands used in the above example, \glsadd
,
\glsentrytext
and \glslink
, don’t use \glsunset
so they
don’t increment the entry count. On the next LaTeX run,
\glsentryprevcount
{apple}
now produces 4 as that was the
value of the currcount field for the “apple” entry
at the end of the document on the previous run.
When you enable the entry count using \glsenableentrycount
, you
also enable the following commands:
\gls
)
(no case-change, plural, analogous to \glspl
)
(first letter uppercase, singular, analogous to \Gls
), and
(first letter uppercase, plural, analogous to \Glspl
).
If you don’t use \glsenableentrycount
, these commands behave
like their counterparts \gls
, \glspl
, \Gls
and \Glspl
,
respectively, but there will be a warning that you haven’t enabled
entry counting.
If you have enabled entry counting with
\glsenableentrycount
then these commands test if
equals 1. If it doesn’t then the
analogous \glsentryprevcount
{ }\gls
etc will be used. If it is 1, then the first optional
argument will be ignored and
\glsunset
{ }
will be performed, where { }{ } is a command that takes
two arguments. The command used depends whether you have used
\cgls
, \cglspl
, \cGls
or \cGlspl
.
The formatting command
will be one of the following: This command is used by\cgls
and defaults to
\glsentrylong
{ }
if the entry given by has a long form or
\glsentryfirst
{ }
otherwise.
This command is used by
\cglspl
and defaults to
\glsentrylongpl
{ }
if the entry given by has a long form or
\glsentryfirstplural
{ }
otherwise.
This command is used by
\cGls
and defaults to
\Glsentrylong
{ }
if the entry given by has a long form or
\Glsentryfirst
{ }
otherwise.
This command is used by
\cGlspl
and defaults to
\Glsentrylongpl
{ }
if the entry given by has a long form or
\Glsentryfirstplural
{ }
otherwise.
This means that if the previous count for the given entry was 1, the
entry won’t be hyperlinked with the
\cgls
-like commands and those commands won’t
index (that is, they won’t add a line to the
external glossary file). If you haven’t used any of the other
commands that index (such as \glsadd
or the
\glstext
-like commands) then the entry won’t appear in the
glossary.
Remember that since these commands use \glsentryprevcount
you
need to run LaTeX twice to ensure they work correctly. The
document build requires a second LaTeX call before running the
indexing application. For example, if the document is in a file called
myDoc.tex, then the document build needs to be:
pdflatex myDoc pdflatex myDoc makeglossaries myDoc pdflatex myDoc
In
Example 32, the acronyms that have only been used once (on the previous run) only have their long form shown with\cgls
:
After a complete document build the list of acronyms only includes the entries HTML, CSS and RDSMS. The entries SQL, RDBMS and XML only have their long forms displayed and don’t have a hyperlink.\documentclass
{article}\usepackage
[colorlinks]{hyperref}\usepackage
[acronym]{glossaries}\makeglossaries
\glsenableentrycount
\setacronymstyle
{long-short}\newacronym
{html}{HTML}{hypertext markup language}\newacronym
{css}{CSS}{cascading style sheets}\newacronym
{xml}{XML}{extensible markup language}\newacronym
{sql}{SQL}{structured query language}\newacronym
{rdbms}{RDBMS}{relational database management system}\newacronym
{rdsms}{RDSMS}{relational data stream management system}\begin{document}
These entries are only used once:\cgls
{sql},\cgls
{rdbms},\cgls
{xml}. These entries are used multiple times:\cgls
{html},\cgls
{html},\cgls
{css},\cgls
{css},\cgls
{css},\cgls
{rdsms},\cgls
{rdsms}.\printglossaries
\end{document}
8. Displaying a Glossary[link]
All defined glossaries may be displayed using the appropriate
command, such as \printglossary
, that matches the
indexing method. These commands are collectively referred to
as the \print
set of commands.
glossary
\newglossary
), as applicable,
to see if there is a problem. With Option 1, you just need
two LaTeX runs to make the glossaries appear, but you may
need further runs to make the number lists up-to-date.
If you have used the automake option, check the log
file for “runsystem” lines (see the information about the
automake option in §2.5 for further
details).
Option 1
(must be used with \makenoidxglossaries
in the document preamble):
\glsdefaulttype
. This command iterates over a list of
entry labels, which it will have to first sort with
sort=standard. The list will only include those
entries that have been indexed and the appropriate
glossary markup is added within the loop. This makes it
unsuitable for the tabular-like glossary styles, such as
long and super.
The following is an iterative command:
which internally uses\printnoidxglossary
for each
non-ignored glossary.
Options 2 and 3
(must be used with \makeglossaries
in the document preamble):
\glsdefaulttype
. This command internally inputs the associated
glossary file (created by the relevant indexing application) if it exists.
The glossary file contains the markup to typeset the
glossary. See §1.6 for information
on how to create the glossary file.
The following is an iterative command:
which internally uses\printglossary
for each
non-ignored glossary.
\printglossary
will just do
\null
for each missing glossary to assist dictionary style
documents that just use \glsaddall
without inserting any text.
This use of \null
ensures that all indexing information is
written before the final page is shipped out. Once the external
glossary files are present \null
will no longer be used. This can cause a
spurious blank page on the first LaTeX run before the
glossary files have been created. Once these files are present, \null
will no longer be used and so shouldn’t cause interference for the
final document. With glossaries-extra, placeholder text is
used instead.
Options 4 and 5 (glossaries-extra only):
This displays the glossary identified by the type option in or, if omitted, the glossary identified by\glsdefaulttype
. This command is similar to
\printnoidxglossary
, in that it iterates over a list of
entry labels, but in this case all defined entries within the
given glossary are included and the list is in the order in which
they were defined (that is, the order in which they were added to
the glossary’s internal label list).
The reason this command works with bib2gls is because bib2gls writes the entry definitions in the glstex file in the order obtained by the sort resource option, and bib2gls will only include the entries that match the required selection criteria.
With Option 5 (that is, without bib2gls) the result will be in the order the entries were defined in the tex file. There’s no attempt to gather child entries (see §4.5). This means that if you don’t define child entries immediately after their parent, you will have a strange result (depending on the glossary style).
As with \printnoidxglossary
, the glossary markup is
inserted during the loop but, unlike that command,
\printunsrtglossary
performs the loop outside of the
glossary style, which means that there are no issues with the
tabular-like styles. See the glossaries-extra manual for
further details.
The following is an iterative command:
which internally uses\printunsrtglossary
for each
non-ignored glossary.
The glossaries-extra package also provides
which is designed for inner or nested glossaries. It allows many, but not all, of the options listed below. There’s an example available in the gallery: Inner or Nested Glossaries. See the glossaries-extra package for further details.
All the individual glossary commands \print
glossary
have an optional argument. Available options are listed
in §8.1.
After the options have been set, the following command will be defined:
This expands to the label of the current glossary (identified by the type option). It may be used within glossary style hooks, if required.
8.1. \print
Options glossary[link]
These options may be used in the optional argument of the
\print
glossary set of commands.
Some options are available for all those commands, but those that aren’t
are noted. Before the options are set, the following commands are
defined to their defaults for the given glossary. They may
then be redefined by applicable options.
Identifies the glossary to display. The value should be the glossary label. Note that you can only display an ignored glossary with
\printunsrtglossary
or
\printunsrtinnerglossary
, otherwise
should correspond to a glossary that was defined with
\newglossary
or \altnewglossary
.
Sets the glossary’s title (
\glossarytitle
). This option isn’t available
with \printunsrtinnerglossary
.
Sets the glossary’s table of contents title (
\glossarytoctitle
). This option isn’t available
with \printunsrtinnerglossary
.
The glossary style to use with this glossary (overriding the current style that was either set with the style package option or with
\setglossarystyle
).
This option isn’t available with \printunsrtinnerglossary
.
This may be used to override the numberedsection package option, and has the same syntax as that option (see §2.2). This option isn’t available with
\printunsrtinnerglossary
.
This may be used to override the nonumberlist package option. Note that, unlike the valueless package option, this option is boolean.
This may be used to override the nogroupskip package option. Only relevant if the glossary style uses the conditional
\ifglsnogroupskip
to test for this option.
This may be used to override the nopostdot package option. This option is only applicable if the glossary style uses
\glspostdescription
.
This may be used to override the entrycounter package option. Note that one of the package options entrycounter=true or subentrycounter=true must be used to make
\glsrefentry
work correctly. The setting can then
be switched off with this option for individual glossaries
where the setting shouldn’t apply.
This may be used to override the subentrycounter package option. Note that one of the package options entrycounter=true or subentrycounter=true must be used to make
\glsrefentry
work correctly. The setting can then
be switched off with this option for individual glossaries
where the setting shouldn’t apply.
\glsrefentry
won’t work).
In general, it’s best to enable these settings via the package
options and switch them off for the glossaries where they don’t
apply.
This key is only available with
\printnoidxglossary
.
If you don’t get an error with sort=use and sort=def but you do get an error with one of the other sort options, then you probably need to use the sanitizesort=true package option or make sure none of the entries have fragile commands in their sort field.
Order of use. There’s no actual sorting in this case. The order is obtained from the indexing information in the aux file.
Order of definition. There’s no actual sorting in this case. The order is obtained from the glossary’s internal list of labels.
For a locale-sensitive sort, you must use either xindy (Option 3) or bib2gls (Option 4). Note that bib2gls provides many other sort options.
Case-insensitive order.
Case-sensitive order.
Word order.
Letter order.
Word or letter order according to the order package option.
The word and letter order sort methods use datatool’s
\dtlwordindexcompare
and \dtlletterindexcompare
handlers.
The case-insensitive sort method uses datatool’s
\dtlicompare
handler. The case-sensitive sort method uses
datatool’s \dtlcompare
handler. See the datatool
documentation for further details.
This key is only available with glossaries-extra and labels the glossary with
\label
{ }
. This is an alternative to
the package option numberedsection=autolabel.
This option isn’t available with \printunsrtinnerglossary
.
This key is only available with glossaries-extra and can be used to switch off the automatic hypertarget for each entry. (This refers to the target used by commands like
\gls
and \glslink
.)
This option is useful with \printunsrtglossary
as it allows
the same list (or sub-list) of entries to be displayed multiple
times without causing duplicate hypertarget names.
This key is only available with glossaries-extra and provides another way of avoiding duplicate hypertarget names. In this case it uses a different prefix for those names. This locally redefines
\glolinkprefix
but note this will also affect the target for any entry
referenced within the glossary with commands like \gls
,
\glslink
or \glshyperlink
.
This key is only available with glossaries-extra. This is similar to the prefix option, but it alters the prefix of the hypertarget anchors without changing
\glolinkprefix
(so it
won’t change the hyperlinks for any entries referenced in the
glossary).
This key is only available with
\printunsrtglossary
and
\printunsrtinnerglossary
.
If true, the “unsrt” function that creates the code for
typesetting the glossary will insert letter group
headers whenever a change is detected in the letter group
label between entries of the same hierarchical level.
See the glossaries-extra manual for further details.
This key is only available with
\printunsrtglossary
and
\printunsrtinnerglossary
.
It can be used to locally adjust the
hierarchical level used by the glossary style. See the
glossaries-extra manual for further details and also
Gallery: Inner or Nested Glossaries.
This key is only available with
\printunsrtglossary
and
\printunsrtinnerglossary
. It can be used to locally remove the
hierarchical level used by the glossary style. See the
glossaries-extra manual for further details.
8.2. Glossary Markup[link]
This section describes the commands that are used to display the
glossary. If you want to suppress the number lists
you can use the nonumberlist option. If you want to save the
number lists for some other purpose outside of the
glossary, you can use the savenumberlist option.
If you want information about an entry’s parent then you can use
\ifglshasparent
(to determine if the entry has a parent)
or \glsentryparent
(to expand to the parent’s label).
The hierarchical level is provided in \subglossentry
(and is 0 with \glossentry
) but it’s also stored in the
level internal field.
If you’re trying to work out how to parse the glossary in
order to gather indexing information, consider using
bib2gls instead, which stores all the indexing
information, such as location lists and letter group
labels, in internal fields. It can also store lists of sibling
entries or child entries. If you really want to input the
glossary file in order to gather information obtained by
makeindex or xindy without actually displaying anything
(by redefining the markup commands to not produce any text), use
\input
rather than \printglossary
.
The glossary is always started with:
This creates the heading. This command sets the page header with:\glossarysection
[\glossarytoctitle
]{\glossarytitle
}
If this is unsuitable for your chosen class file or page style package, you will need to redefine\glsglossarymark
{\glossarytoctitle
}
\glsglossarymark
. If
\phantomsection
is defined (hyperref) then
\glossarysection
will start with:
\glsclearpage
\phantomsection
By default, this command uses either
\chapter*
or
\section*
, depending on whether or not \chapter
is
defined. This can be overridden by the section package option
or the \setglossarysection
command. Numbered sectional units
can be obtained using the numberedsection package option.
If the default unnumbered section setting is on, then the
will only be added to the table of contents if
the toc option is set. If numberedsection is on, the
addition to the table of contents is left to the sectional
command.
This sets the page header, if supported by the current page style. Originally the command
\glossarymark
was provided for
this purpose, but this command is also provided by other packages
and classes, notably memoir which has a different syntax.
Therefore the command \glossarymark
will
only be defined if it doesn’t already exist. In which case,
\glsglossarymark
will simply use \glossarymark
.
If memoir has been loaded, \glsglossarymark
will be
defined to use \markboth
otherwise, if some other class or
package has defined \glossarymark
, \glsglossarymark
will
be defined to use \@mkboth
(using the same definition as the
glossaries package’s version of \glossarymark
).
If ucmark=true, the case change will be applied
using \memUChead
if memoir has been loaded, otherwise it
will use \glsuppercase
.
So if you want to redefine the way the header mark is set for the
glossaries, you need to redefine \glsglossarymark
not
\glossarymark
.
For example, to only change the right header:
or to prevent it from changing the headers:\renewcommand
{\glsglossarymark
}[1]{\markright
{#1}}
If you want\renewcommand
{\glsglossarymark
}[1]{}
\glsglossarymark
to use all caps in the header, use the
ucmark option described below.
With hyperref and unnumbered section headings, \phantomsection
is need to create an appropriate anchor (see the hyperref
manual). This will need the page cleared for \chapter*
,
which is done with:
\glsclearpage
will use \cleardoublepage
, if it’s defined
and if the \if@openright
conditional (provided by classes with
an openright option such as book and report) isn’t
defined or is defined and is true, otherwise \clearpage
is
used.
Occasionally you may find that another package defines
\cleardoublepage
when it is not required. This may cause an
unwanted blank page to appear before each glossary
If you only want a single page cleared, you can redefine
\glsclearpage
. For example:
Note that this will no longer take the section package option into account.\renewcommand
*{\glsclearpage
}{\clearpage
}
This expands to the title that should be used by the glossary section header. It’s initialised to the title provided in
\newglossary
when the glossary was defined. The
title option will redefined this command.
This expands to the table of contents title that’s supplied in the optional argument of the glossary section command. It will only be added to the table of contents is the toc package option is on, but it may also be used in the page header (depending on the definition of
\glsglossarymark
and the current page style).
The \glossarytoctitle
command is initialised to \glossarytitle
.
The toctitle option will redefine this command.
If neither the title nor toctitle are
used, \glossarytoctitle
will be defined via:
\glossarytoctitle
to the title
provided in \newglossary
when the glossary was defined.
This means that if neither title nor
toctitle are set, the glossary’s associated
title will be used for both. If only title is used,
then it will also apply to the table of contents title, and if
only toctitle is used, then \glossarytoctitle
will
be defined to that value but \glossarytitle
will be the
glossary’s associated title.
After the heading, but before the main body of the glossary, is the glossary preamble which is given by:
You can redefine this before the glossary is shown. For example:A glossary may have its own specific preamble. If it has one defined, then the\renewcommand
{\glossarypreamble
}{Numbers in italic indicate primary definitions.}
\print
glossary set of commands will
locally redefine \glossarypreamble
to that preamble instead.
Since this change is scoped, the previous definition will be
restored after the \print
glossary command.
You can globally assign a preamble to a specific glossary with:
If is omitted,\glsdefaulttype
is used.
For example:
\setglossarypreamble
{Numbers in italic
indicate primary definitions.}
This will set the given preamble text for just the
main
glossary, not for any other glossary. The
glossaries-extra package additionally provides:
which locally appends to the preamble for the specific
glossary and
which locally prepends to the preamble for
the specific glossary.
There is also a postamble at the end of each glossary which is given by:
This is less useful than a preamble and so there’s no analogous command to\setglossarypreamble
.
(You may prefer to use the mcolalttree style if you’re not interested in the column headers or borders.)\renewcommand
*{\glossarysection
}[2][]{%\twocolumn
[{\chapter
*{#2}}]%\setlength
\glsdescwidth
{0.6\linewidth
}%\glsglossarymark
{\glossarytoctitle
}% }\renewcommand
*{\glossarypostamble
}{\onecolumn
}
The actual glossary content is contained within the theglossary environment, which will typically be in the form:
\begin{theglossary}
\glossaryheader
\glsgroupheading
{ }\relax
\glsresetentrylist
\glossentry
{ }{ }\subglossentry
{ }{ }{ } % …\glsgroupskip
\glsgroupheading
{ }\relax
\glsresetentrylist
\glossentry
{ }{ }\subglossentry
{ }{ }{ } % …\end{theglossary}
The entire number list for each entry is encapsulated with:
This command allows\glsnonextpages
, \glsnextpages
, and
the nonumberlist and savenumberlist options to work.
The \glossaryentrynumbers
command is reset by:
With Option 1, this command is preceded by:
The default behaviour is to use the value of the prenumberlist internal field. This command is not used with Options 2 and 3.If you want to suppress the number list for a particular entry, you can add the following to the entry’s description:
Within the glossary, this will redefine\glossaryentrynumbers
to ignore its argument and then reset itself. This means that the
next number list will be suppressed. Note that if the entry
doesn’t have a number list (for example, it’s a parent entry
that only appears in the glossary because it has an indexed descendent entry) then the next number list will be for the
first child entry that’s been indexed. This command does nothing
outside of the glossary.
Similarly, if you want to override the nonumberlist option to ensure that the next number list is shown, then use:
This command does nothing outside of the glossary.
\glsnonextpages
or
\glsnextpages
to the indexing information before
\glossentry
or \subglossentry
with Options 2 and 3.
With Option 1, the relevant command is put in the
prenumberlist internal field, but since
\printnoidxglossary
only uses \glsnoidxprenumberlist
and \glossaryentrynumbers
when the loclist field is
set, it won’t affect sub-entries.
The theglossary environment, and the other commands
(\glossaryheader
, \glsgroupskip
, \glsgroupheading
,
\glossentry
and \subglossentry
) are all redefined by
glossary styles and are described in
§13.2.
9. Defining New Glossaries[link]
A new glossary can be defined using:
where is the label to assign to this glossary. This label is used to reference the glossary in the value of the type key when defining entries or, the similarly named, type option in the\print
glossary commands.
The arguments files for that glossary, is the default title for this new glossary, and the final optional argument specifies which location counter to use for the associated number lists (see also §12). If not specified, the default location counter will be the one identified in the counter option, if that option is used, otherwise it will be the page counter.
and specify the extensions of the input and output (from TeX’s point of view)The first optional argument indexing application’s transcript file (this information is used by makeglossaries which picks up the information from the aux file and also by the automake option). If omitted, glg is used.
specifies the extension for theThe file extensions only apply to Options 2 and 3. For the other options, the indexing information is written to the aux file for Options 1 and 4. No input file is required for Option 1 and Option 4 always has the glstex file extension. Since the file extensions are only relevant for Options 2 and 3, there is a starred version that omits those arguments:
This is equivalent to\newglossary
[ -glg]{ }{ -gls}{ -glo}{ }[ ]
or you can use:
which is equivalent to
\newglossary
[ -glg]{ }{ -gls}{ -glo}{ }[ ]
Note that in both cases distinct file extensions are defined so these
commands are still useful with Options 2 and 3.
It may be that you have some terms that are so common
that they don’t need to be listed. In this case, you can define
a special type of glossary that doesn’t create any associated files.
This is referred to as an “ignored glossary” and it’s ignored by
commands that iterate over all the glossaries, such as
\printglossaries
. To define an ignored glossary, use
\newignoredglossary
where is the glossary label (as above). This
glossary type will automatically be added to the
nohypertypes list, since there are no hypertargets for
the entries in an ignored glossary.
(The sample file sample-entryfmt.tex defines an ignored glossary.)
An ignored glossary can’t be displayed with
\printnoidxglossary
or \printglossary
but can be displayed
with \printunsrtglossary
and \printunsrtinnerglossary
.
\newignoredglossary*
that doesn’t suppress
hyperlinks (since ignored glossaries can be
useful with bib2gls). There is also an analogous
\provideignoredglossary
command.
You can test if a glossary is an ignored one using:
This does if was defined as an ignored glossary, otherwise it does .
Note that the main
(default) glossary is automatically created as:
so it can be identified by the label\newglossary
{main}{gls}{glo}{\glossaryname
}
main
(unless the
nomain package option is used). If the doc package has
been loaded (which uses the gls and glo extensions for
the change log) then the main
glossary will instead be
defined as:
If you are using a class or package that similarly requires gls and glo as file extensions, you will need to use the nomain option and define your own custom glossary, but be aware of other possible conflicts, such as different definitions of commands and environments like\newglossary
[glg2]{main}{gls2}{glo2}{\glossaryname
}
\printglossary
or
theglossary.
The acronym (or acronyms) package option is equivalent to:
so it can be identified by the label\newglossary
[alg]{acronym
}{acr}{acn}{\acronymname
}
acronym
. If you are
not sure whether the acronym option has been used, you
can identify the list of acronyms by the command:
The default definition is simply \glsdefaulttype
. The
acronym or acronyms option will redefine \acronymtype
to
acronym
. If you want additional glossaries for
use with acronyms, remember to declare them with
acronymlists.
The symbols package option creates a new glossary with the
label symbols
using:
The numbers package option creates a new glossary with the label\newglossary
[slg]{symbols
}{sls}{slo}{\glssymbolsgroupname
}
numbers
using:
The index package option creates a new glossary with the label\newglossary
[nlg]{numbers
}{nls}{nlo}{\glsnumbersgroupname
}
index
using:
\newglossary
[ilg]{index
}{ind}{idx}{\indexname
}
\makeglossaries
to ensure that the relevant output
files are opened.
See §1.5.1 if you want to redefine \glossaryname
,
especially if you are using a language package.
(Similarly for \glssymbolsgroupname
and
\glsnumbersgroupname
.) If you want to redefine \indexname
,
just follow the advice in
How to change LaTeX’s “fixed names”.
10. Adding an Entry to the Glossary Without Generating Text[link]
It is possible to \index
indexing an entry without
\glstext
-like commands, only it doesn’t produce
any text. Therefore, there is no hyper key
available in but all the other base options that can
be used with the \glstext
-like commands can be passed to \glsadd
.
The glossaries-extra package provides addition options, such
as textformat, that aren’t applicable when there’s no
link text, so they are also not available.
This ensures that the given entry is listed in the glossary
and that the current location is included in the entry’s
number list.
This command is particularly useful to create an explicit range that covers an entire section or block of text that might otherwise end up with a long, ragged number list. For example, suppose I have defined an entry with the label “set”:
\newglossaryentry
{set}{name={set},
description={a collection}}
Suppose I have a section about sets spanning from page 3 to page 8
with repeated use of \gls
{set}
on pages 3, 5, 7
and 8. This will result in the number list “3, 5, 7, 8”
which is a bit untidy. It would look far more compact, and better
emphasize that the section of the document from page 3 to 8 covers
sets, if the number list was simply “3–8”.
This can be done with an explicit range:
See §12.1 for more information about the location encap.\glsadd
[format=(
]{set} Lots of text about sets spanning page 3 to page 8.\glsadd
[format=)
]{set}
\glsstartrange
and \glsendrange
with glossaries-extra. You can also add
a subset of entries with \glsaddeach
.
To add all entries that have been defined, use:
The optional argument is the same as for\glsadd
, except
there is also a key types which can be
used to specify which glossaries to use. This should be a
comma-separated list. For example, if you only want to add
all the entries belonging to the list of acronyms (specified by
the glossary type \acronymtype
) and a list of
notation (specified by the glossary type notation) then you can
do:
\glsaddall
[types={\acronymtype
,notation}]
\glsaddall
. Instead use the selection=all
resource option to select all entries in the given bib files.
(You can use \glsaddeach
with bib2gls.)
\glsadd
and \glsaddall
add the current
location to the number list. In the case of \glsaddall
,
all entries in the listed glossaries will have the same
location in the number list (the location at the point in
the document where \glsaddall
was used, which will be page 1 if
it occurs in the preamble). If you want to use
\glsaddall
, it’s best to suppress the number list with the
nonumberlist package option. (See
sections 2.3 and 12.)
If you want to ensure that all entry are added to the glossary, but only want the locations of entries that have actually been used in the document, then you can use:
Note that in this case, the optional argument is simply a list of glossary labels. The options available to\glsadd
and
\glsaddall
aren’t available here. If the optional argument is
omitted, the list of all non-ignored glossaries is assumed.
This command implements:
\glsadd
[format=glsignore]{ }
for each entry in each glossary listed in the optional
argument if the entry has been marked as used.
Since \glsignore
discards its argument, this effectively
creates an invisible location. This is necessary because
makeindex and xindy require an associated location for
each line in the indexing file. (They are
indexing applications not glossary
applications, so they expect page numbers.)
This means that \glsaddallunused
adds
to
the number list of all the unused entries.
If any of those number lists have other locations (for
example, the first use flags was reset before
\glsignore
{ }\glsaddallunused
or only the \glstext
-like commands were
used or if any indexing occurs after \glsaddallunused
)
then this will cause spurious commas or en-dashes in the
number list that have been placed before or after the
invisible location.
\glsaddallunused
, it’s best to place the
command at the end of the document to ensure that all the commands
you intend to use have already been used and make sure to use the
\gls
-like commands and don’t issue any resets (\glsreset
etc).
\glsaddallunused
with bib2gls. However,
since bib2gls was designed specifically for
glossaries-extra, it recognises glsignore as a special
format that indicates the location shouldn’t be added to the
location list but the entry should be selected.
So you can index an entry with format=glsignore
to ensure that the entry is selected without adding a location to
the number list.
Alternatively, the selection=all resource option can be used, which will ensure all entries are selected but only those indexed with one or more non-ignored locations will have a location list.
Base glossaries package only:
Corresponding glossaries-extra and bib2gls document code:\documentclass
{article}\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{cat}{name={cat},description={feline}}\newglossaryentry
{dog}{name={dog},description={canine}}\begin{document}
\gls
{cat}.\printglossaries
\glsaddallunused
% <- make sure dog is also listed\end{document}
With the file entries.bib:\documentclass
{article}\usepackage
[record]{glossaries-extra}\GlsXtrLoadResources
[src=entries,selection=all]\begin{document}
\gls
{cat}.\printunsrtglossaries
\end{document}
@entry
{cat,name={cat},description={feline}}@entry
{dog,name={dog},description={canine}}
\glsadd
to
allow for an entry that should appear both in the main
glossary and
in the list of acronyms. This example sets up the list of
acronyms using the acronym package option:
\usepackage
[acronym]{glossaries}
A new command (\newdualentry
) is then defined to make it easier to define dual
entries:
This has the following syntax:\newcommand
*{\newdualentry
}[5][]{%\newglossaryentry
{main-#2}{name={#4},% text={#3\glsadd
{#2}},% description={#5},% #1 }%\newacronym
{#2}{#3\glsadd
{main-#2}}{#4}% }
\newdualentry
[ ]{ }{ }{ }{ }
You can then define a new dual entry:
\newdualentry
{svm}% label
{SVM}% abbreviation
{support vector machine}% long form
{Statistical pattern recognition technique}% description
Now you can reference the acronym with \gls
{svm}
or you can
reference the entry in the main
glossary with
\gls
{main-svm}
.
This is just an example. In general, think twice before you add this kind of duplication. If all information (short, long and description) can be provided in a single list, it’s redundant to provide a second list unless any of the short forms start with a different letter to the associated long form, which may make it harder to look up.
\glsadd
with bib2gls.
(Although it can still be useful, for example with Option 6.)
11. Cross-Referencing Entries[link]
\makeglossaries
(Options 2 or 3) or
\makenoidxglossaries
(Option 1) before defining
any entries that cross-reference other entries. If any
of the entries that you have cross-referenced don’t appear
in the glossary, check that you have put
\makeglossaries
/\makenoidxglossaries
before all entry
definitions. The glossaries-extra package provides better
cross-reference handling.
There are several ways of cross-referencing entry in the glossaries:
- 1. You can use commands such as
\gls
in the entries description. For example:
Note that with this method, if you don’t use the cross-referenced term in the main part of the document, you will need two runs of makeglossaries:\newglossaryentry
{apple}{name={apple}, description={firm, round fruit. See also\gls
{pear}}}pdflatex filename makeglossaries filename pdflatex filename makeglossaries filename pdflatex filename
This is because the\gls
in the description won’t be detected until the glossary has been created (unless the description is used elsewhere in the document with\glsentrydesc
). Take care not to use\glsdesc
(or\Glsdesc
) in this case as it will cause a nested link. - 2. After you have defined the entry, use
where is a comma-separated list of entry
labels to be cross-referenced, is the label of the
entry doing the cross-referencing and is the “see” tag.
(The default value of is
\seename
.)This command is essentially performing:
where is a special form of location encap that includes and . Remember from §10 that makeindex always requires a location. This special location encap discards the provided location (which\glsadd
[format=]{ }\glssee
sets to “Z” to push the cross-reference to the end of the number list) and replaces it with the cross-reference in the form “see . ”This means that
\glssee
indexes so that appears in the glossary but it doesn’t index any of the entries listed in .For example:
This indexes the entry identified by the label “series” and adds a location to the “series” number list that looks something like:\glssee
[see also]{series}{FourierSeries,TaylorsTheorem}see also
(The actual format is performed with\glsentryname
{FourierSeries}\&
\glsentryname
{TaylorsTheorem}\glsseeformat
.) - 3. As described in §4, you can use the
see key when you define the entry. For example:
This key was provided as a simple shortcut that does:\newglossaryentry
{MaclaurinSeries}{name={Maclaurin series}, description={Series expansion}, see={TaylorsTheorem}}
This means that “MaclaurinSeries” will automatically be added to the glossary with something like\newglossaryentry
{MaclaurinSeries}{name={Maclaurin series}, description={Series expansion}}\glssee
{MaclaurinSeries}{TaylorsTheorem}
in its number list, but “TaylorsTheorem” will need to be indexed elsewhere to ensure that it also appears in the glossary otherwise, it would end up with the preamble location (page 1) in its number list, assuming that the entry was defined in the preamble.\emph
{see}\glsentryname
{TaylorsTheorem}You therefore need to ensure that you use the cross-referenced term with the commands described in §5.1 or §10.
The “see” tag is produce using
\seename
, but can be overridden in specific instances using square brackets at the start of the see value. For example:
Take care if you want to use the optional argument of commands such as\newglossaryentry
{MaclaurinSeries}{name={Maclaurin series}, description={Series expansion}, see=[see also]{TaylorsTheorem}}\newacronym
or\newterm
as the value will need to be grouped. For example:
Similarly if the value contains a list. For example:\newterm
{seal}\newterm
[see={[see also]seal}]{sea lion}\glossaryentry
{lemon} { name={lemon}, description={Yellow citrus fruit} }\glossaryentry
{lime} { name={lime}, description={Green citrus fruit} }\glossaryentry
{citrus} { name={citrus}, description={Plant in the Rutaceae family}, see={lemon,lime} }
In both cases 2 and 3 above, the
cross-referenced information appears in the number list,
whereas in case 1, the cross-referenced information
appears in the description. (See the sample-crossref.tex example
file that comes with this package.) This means that in
cases 2 and 3, the cross-referencing
information won’t appear if you have suppressed the
number list. In this case, you will need to activate the
number list for the given entries using
nonumberlistfalse. Alternatively, if you just use the
see key instead of \glssee
, you can automatically
activate the number list using the seeautonumberlist
package option.
11.1. Customising Cross-Reference Text[link]
When you use either the see key or the
\glssee
command, the cross-referencing information will be typeset in the
glossary (within the number list) according to:
Note that the argument is always ignored. (makeindex will always assign a location number, even if it’s not needed, so it needs to be discarded.) For example, if you want the tag to appear in bold, you can do:\emph
{ }\glsseelist
{ }
\renewcommand
*{\glsseeformat
}[3][\seename
]{\textbf
{#1}\glsseelist
{#2}}
The list of labels is formatted by:
This iterates through the comma-separated list of entry labels and formats each entry in the list. The entries are separated by: between all but the last pair, and between the last pair.Each entry item in the list is formatted with:
This does:which creates a hyperlink, if enabled, to the cross-referenced entry. The hyperlink text is given by: This does:\glshyperlink
[\glsseeitemformat
{#1}]{#1}
which uses the text field for acronyms and the name field otherwise.\ifglshasshort
{ } {\glsentrytext
{ }}% acronym {\glsentryname
{ }}% non-acronym
\glssee
was first introduced in v1.17, the cross-referenced entry was
displayed with just \glsentryname
, but this caused problems because
back then the name field had to be sanitized because it was
written to the glossary file, which caused strange results if
the name contained any commands. So in v3.0, the default
definition was switched to using \glsentrytext
to avoid the
issue. In v3.08a, the information written to the glossary file
was changed and the name was no longer sanitized, but the
new definition was retained for backward-compatibility.
However, the original definition is more appropriate in some ways, as it makes more sense for the cross-reference to show the name as it appears in the glossary, except for acronyms which could have wide names if the long form is included. So in v4.50, which had major compatibility-breaking changes to remove the unconditional dependency on the now deprecated textcase package, the original use of name was restored for non-acronyms, which brings it into line with glossaries-extra.
For example, to make the cross-referenced list use small caps with the text (not name) field:
\renewcommand
{\glsseeitemformat
}[1]{%\textsc
{\glsentrytext
{#1}}}
\glsseeitemformat
to use \glsfmttext
for abbreviations and
\glsfmtname
otherwise. Additionally, it provides
\glsxtrhiername
which can be used as an alternative for
hierarchical entries. See the glossaries-extra manual for
further details.
\glsseeformat
and \glsseelist
in the main body
of the text, but they won’t automatically add the cross-referenced
entries to the glossary. If you want them added with that location,
you can do:
Some information (see also\glsseelist
{FourierSeries,TaylorsTheorem}%\glsadd
{FourierSeries}\glsadd
{TaylorsTheorem}).
12. Number Lists[link]
Each entry in the glossary has an associated
number list (or location list). By default, these
numbers (the entry locations) refer to the pages on which
that entry has been indexed (using any of the commands
described in §5.1 and §10)
and will also include any cross-references obtained with \glssee
(or the see key).
The locations in the number list are separated with:
The number list can be suppressed using the nonumberlist package option, or an alternative counter can be set as the default using the counter package option. The glossaries-extra package additionally provides the equations and floats options that can be used to automatically switch the location counter in certain environments.
Number lists are more common with indexes rather than glossaries (although you can use the glossaries package for indexes as well). However, Options 2 and 3 makes use of makeindex or xindy to hierarchically sort and collate the entries. These applications are readily available with most modern TeX distributions, but because they are both designed as indexing applications they both require that terms either have a valid location or a cross-reference.
If you’re not interested in the locations, each entry only needs to be indexed once, so consider using indexonlyfirst, which can improve the document build time by only indexing the first use of each term.
The \glsaddall
command (see §10), which is used to
automatically index all entries, iterates over
all defined entries (in non-ignored glossaries)
and does
for each
entry (where is that entry’s label).
This means that \glsadd
{ }\glsaddall
automatically
adds the same location to every entry’s number list, which
looks weird if the number list hasn’t been suppressed.
With Option 4, the indexing is performed by bib2gls, which was specifically designed for the glossaries-extra package. So it will allow empty or unusual locations. (As from bib2gls v3.0, empty locations will be converted to ignored locations.) Additionally, the selection=all resource option option will select all entries without adding an unwanted location to the number list. If bib2gls can deduce a numerical value for a location, it will attempt to form a range over consecutive locations, otherwise it won’t try to form a range and the location will just form an individual item in the list.
Option 1 also allows any location but it doesn’t form ranges. Any empty locations or location with the glsignore format will result in an invisible location in the number list.
12.1. Encap Values (Location Formats)[link]
The location encap or format is the encapsulating command used to format an entry location. That is, it’s a command that takes an argument that will be the location.
The “encap” usually refers to the control sequence name without
the leading backslash (such as textbf) and is essentially
the same as the makeindex encap value that can be provided within
the standard \index
command.
\bfseries
) instead of a text-block command (such as
\textbf
) as the effect is not guaranteed to be localised,
either within the number list or throughout the glossary.
There is a special format:
which simply ignores its argument. With Options 1, 2 and 3 this creates an empty (invisible) location which can lead to spurious commas or en-dashes if the number list contains other locations. However, with bib2gls, this format identifies the location as a special ignored location which won’t be added to the location list but will influence selection.If you want to apply more than one style to a given location (for example, bold and italic) you will need to create a command that applies both formats. For example:
and use that command.\newcommand
*{\textbfem
}[1]{\textbf
{\emph
{#1}}}
In this document, standard location format refer to the standard text
block commands such as \textbf
or \emph
or any of the
commands listed in Table 12.1.
\GlsAddXdyAttribute
to identify any
non-standard formats
that you want to use with the format key. So if you use
xindy with the above example \textbfem
, you would need to add:
\GlsAddXdyAttribute
{textbfem}
See §14 for further details.
If you are using hyperlinks and you want to change the font
of the hyperlinked location don’t use \hyperpage
(provided
by the hyperref package) as the locations may not refer to a
page number and the location argument may contain the range delimiter \delimR
.
Instead, the glossaries package provides
hyperlink-supported encaps listed in
Table 12.1. These commands all use \glshypernumber
(described below) and so shouldn’t be used in other contexts.
The \hyper
can also be used without hyperref, since
\glshypernumber
will simply do its argument if \hyperlink
hasn’t been defined. In which case, only the font change will be
applied.
hyperrm | serif (\textrm ) hyperlink |
hypersf | sans-serif (\textsf ) hyperlink |
hypertt | monospaced (\texttt ) hyperlink |
hyperbf | bold (\textbf ) hyperlink |
hypermd | medium weight (\textmd ) hyperlink |
hyperit | italic (\textit ) hyperlink |
hypersl | slanted (\textsl ) hyperlink |
hyperup | upright (\textup ) hyperlink |
hypersc | small caps (\textsc ) hyperlink |
hyperemph | emphasized (\emph ) hyperlink
|
If you want to make a new location format that supports
hyperlinks, you
will need to define a command which takes one argument and use that
with the location encapsulated with \glshypernumber
or the
appropriate \hyper
command.
For example, if you want the location number to be in a bold
sans-serif font, you can define a command called, say,
\hyperbsf
:
and then use hyperbsf as the value for the format key.\newcommand
{\hyperbsf
}[1]{\textbf
{\hypersf
{#1}}}
\hyper
commands, make sure
that the argument of \hyper
is just the location.
Any formatting must be outside of \hyper
(as in the
above \hyperbfsf
example).
Remember that if you use xindy, you will need to add this to the list of location xindy attributes:
\GlsAddXdyAttribute
{hyperbsf}
Complications can arise if you use different encap values for the same location. For example, suppose on page 10 you have both the default glsnumberformat and hyperbf encaps. While it may seem apparent that hyperbf should override glsnumberformat in this situation, the indexing application may not know it. This is therefore something you need to be careful about if you use the format key or if you use a command that implicitly sets it.
In the case of xindy, it only accepts one encap (according to the order of precedence given in the xindy module) and discards the others for identical locations (for the same entry). This can cause a problem if a discarded location forms the start or end of a range.
In the case of makeindex, it accepts different encaps for the same location, but warns about it (“multiple encaps”). This leads to a number list with the same location repeated in different formats. If you use the makeglossaries Perl script with Option 2 it will detect makeindex’s warning and attempt to fix the problem, ensuring that the glsnumberformat encap always has the least precedence unless it includes a range identifier. Other conflicting encaps will have the last one override earlier ones for the same location with range identifiers taking priority. If you actually want the repeat, you can disable this feature with the -e switch.
No discard occurs with Option 1 so again you get the same location repeated in different formats. With Option 4, bib2gls will discard according to order of precedence, giving priority to start and end ranges. (See the bib2gls manual for further details.)
The default location format is:
This will simply do its argument if hyperref hasn’t been loaded, otherwise it will use: This will create a hyperlink to the location or will simply do its argument if hyperref hasn’t been loaded. The argument may contain multiple locations. If so, they must be separated with\delimR
or \delimN
. (Usually
\delimN
won’t occur. The \delimR
separator may occur with
ranges and makeindex.) Any other markup is likely to cause a
problem (see §12.5).
Each location within \glshypernumber
will have a
hyperlink created with:
\hyperlink
{ }{ }
where the is the location encapsulated with:
This just does its argument by default.
The location counter, which first have to be set with:
is constructed from the location but requires the prefix and This command will be automatically inserted before the location in the number list by the appropriate indexing method. In the case of makeindex, this will be inserted at the start of the encap information, but with xindy the counter will form part of the attribute and a helper command has to be provided that uses\setentrycounter
. With
Option 1 the command occurs inside the definition of
\glsnoidxdisplayloc
.
The
will be stored in: and may be used in the hooks described below. Note that the prefix can’t be referenced as\glswrglossdisableanchorcmds
is also
used when obtaining the prefix during indexing.
The
is then constructed as follows:- 1.Use the
\glswrglossdisableanchorcmds
hook to disable problematic commands (scoped). - 2.Expand (protected)
\glswrglosslocationtarget
{ } - 3.Sanitize the result.
will essentially do:\setentrycounter
[]{page}% page counter and empty prefix\glshypernumber
{1}
\hyperlink
{page.1}1
whereas
will essentially do:\setentrycounter
[1]{equation}%\glshypernumber
{2}
\hyperlink
{equation.1.2}2
The initial hook to disable the problematic commands is:
By default, this is defined to:If hyperref is loaded the definition will also include:\let
\glstexorpdfstring
\@secondoftwo
The location is encapsulated with: This must expand but may be used to make adjustments. The default definition is to simply expand to its argument. The\let
\texorpdfstring
\@secondoftwo
\pdfstringdefPreHook
\glswrglossdisableanchorcmds
hook may be used to alter the
definition if some condition is required, but bear in mind that
\glswrglosslocationtarget
won’t be used when the prefix is
obtained during indexing.
Any leftover robust or protected commands will end up sanitized to prevent an obscure error from occurring, but an invalid target name is likely to result. See §12.5 for an example.
The use of \setentrycounter
to set the prefix and counter is
necessary because the hypertarget can’t be included in the
indexing information supplied to makeindex or
xindy, because neither the makeindex nor xindy
syntax supports it. Unfortunately, not all definitions of
\theH
can be split into a prefix and location that can
be recombined in this way. This problem can occur, for example,
with counter=equation when it depends on the chapter
counter. This can result in warnings in the form:
name{ } has been referenced but does not exist, replaced by a fixed oneThe sampleEq.tex sample file deals with this issue by redefining
\theHequation
as follows:
\renewcommand
*\theHequation
{\theHchapter
.\arabic
{equation}}
12.2. Range Formations[link]
There are two types of ranges: explicit and implicit. Neither are supported with Option 1. Both are supported by Options 2, 3 and 4. Implicit ranges can be switched off using the appropriate option for the required indexing application. The start and end of a range is separated with:
Options 2 and 3 can merge implicit and explicit ranges that overlap. With Option 4, individual locations can be merged into an explicit range, but an individual location on either side of the explicit range won’t be merged into the explicit range.
As with \index
, the characters (
and )
can be used at the start of the format value to specify the
beginning and ending of a number range. They must be in matching
pairs with the same encap. For example,
on one page to start the range and later:\gls
[format=(
emph]{sample}
to close the range. This will create an explicit range in the number list that’s encapsulated with\gls
[format=)
emph]{sample}
\emph
. If the default
glsnumberformat should be used, you can omit it and just
have the (
and )
characters.
Implicit ranges are formed by concatenating a sequence of three or more consecutive locations. For example, if an entry is indexed on pages 3, 4, 5, and 6, this will be compacted into “3–6”.
With Option 3, you can vary the minimum sequence length using
\GlsSetXdyMinRangeLength
where the argument is either the minimum number or the keyword
none, which indicates that no implicit ranges should be
formed. See §14.3 for further details.
With both makeindex and xindy (Options 2 and 3), you can replace the separator and the closing number at the end of the range using:
to set the suffix for two consecutive locations and to set the suffix for three or more consecutive locations. Option 4 provides a similar feature with the suffixF and suffixFF resource options.For example:
Note that if you use xindy (Option 3), you will also need to set the minimum range length to 1 if you want to change these suffixes:\glsSetSuffixF
{f.}\glsSetSuffixFF
{ff.}
\GlsSetXdyMinRangeLength
{1}
If you use the hyperref package, you will need
to use \nohyperpage
in the suffix to ensure that the
hyperlinks work correctly. For example:
\glsSetSuffixF
{\nohyperpage
{f.}}\glsSetSuffixFF
{\nohyperpage
{ff.}}
\glsSetSuffixF
and \glsSetSuffixFF
must be used
before \makeglossaries
and have no effect if \noist
is
used.
12.3. Locations[link]
Each location in an entry’s number list is the
result of indexing the entry at the point
in the document that corresponds to the location (typically where a
command such as \gls
occurred). By default, this
is the page number, but can be changed with the counter
package option, the optional argument in
\newglossary
, the counter key in
\newglossaryentry
or the counter option in the
\gls
-like and \glstext
-like commands (or in \glsadd
).
The syntax of the location must be valid for the given
indexing application if you use Options 2 or 3. In the case of
makeindex, the syntax is quite restricted. The location may
be a digit (\arabic
), upper or lowercase Roman numerals
(\Roman
or \roman
) or upper or lowercase ASCII
letters (\Alph
or \alph
). The syntax also allows
composite locations formed by combining the allowed digits, numerals and
letters with a compositor (which can be identified with
\glsSetCompositor
).
The following locations are valid, assuming the default full stop compositor:
- •“325”: a numeric location (
\arabic
); - •“IV”: a Roman numeral location (
\Roman
); - •“B”: an alphabetic location (
\Alph
); - •“12.3.4”: a composite location.
- •“I-3.2”: mixed compositors not permitted;
- •“X7”: a separator must be used in composite locations;
- •“Ø”: letters must be ASCII;
- •“
”: commands not permitted in locations;\textsc
{iv} - •“”: locations can’t be empty.
In the case of xindy, the location syntax must be declared
in the xdy style file. This covers both the way that the
location appears in the indexing file as a result of protected
expansion but also the counter used to obtain the
location, and is described in more detail in
§14.3. The standard digit (\arabic
), upper
or lowercase Roman numerals (\Roman
or \roman
) or upper or
lowercase ASCII letters (\Alph
or \alph
) are
automatically added for the page counter.
If a location doesn’t match any declared syntax, a warning will be written to xindy’s transcript file (glg):
WARNING: location-reference "{ }{ }" did not match any location-class! (ignored)As with makeindex when it encounters an invalid location, xindy will drop that location, which will result in the entry being dropped from the glossary if it has no valid locations.
Additional problems can occur with xindy if any of
xindy’s special characters occur in the location. This
includes the backslash \
character, which is particularly
problematic if any robust or protected commands are written in the location
as \
will have to be written to the file as
. This is quite difficult to do without
prematurely expanding \\
\thepage
.
If esclocationstrue, an attempt will be made to hack commands
like \@arabic
and \@roman
to enable this, but, like all
hacks, this is problematic and liable to break in awkward
situations or with future releases of the LaTeX kernel or other
packages. This setting is now off by default and it’s better to use
the hooks below to ensure that the content written to the file is valid.
\glsdohypertarget
when it tries to create hyperlinks.
The following hook is used during the protected write:
This does nothing by default but may be used to disable problematic commands that could lead to an invalid location. Note that this can lead to unexpected results in the number list, but you may be able to correct this with a custom encap or (if\glshypernumber
creates a hyperlink) a custom
definition of \glswrglosslocationtextfmt
. See
§12.5 for an example.
\glswrglossdisablelocationcmds
hook occurs after
\protected@write
sets \thepage
to \relax
.
By the time \thepage
actually gets expanded when it’s written
to the indexing file, any changes made within the hook will be
lost.
Both Options 1 and 4 write the indexing information in the aux file and will accept any location syntax (that’s valid in a LaTeX document). In the case of Option 4, bib2gls will try parsing the location and if it fits a common pattern that allows it to obtain a numeric value, then it will be able to form an implicit range (if required), otherwise it will accept the location but not form any implicit ranges.
With Options 1–4 (except with record=nameref)
the location anchor isn’t included in the indexing
information. If a hyperlink is required for the location, the
target (anchor name) has to be constructed from the location. The
hyperref package provides \hyperpage
for normal indexes
(with \index
), but this forms the anchor from
page.
which isn’t suitable with
glossaries as the location counter may not be the default
page. Therefore the counter is saved within the encap. A
prefix is also necessary if \theH
is defined and
isn’t equivalent to \the
.
The assumption here is that \theH
expands to the
equivalent of
.
If \the
\theH
and \the
are equivalent then
will be empty.
The prefix is found as follows:
- 1.Use the
\glswrglossdisableanchorcmds
hook to disable problematic commands (scoped). - 2.Perform a protected expansion on
\theH
( ) and\the
( ). If ends with , so that is , then the prefix is the substring.In this step,
\thepage
may be incorrect, due to TeX’s asynchronous output routine, but it will be incorrect in both and and shouldn’t occur in the prefix (unless you have an unusual numbering system that’s reset on every page, in which case you may have other problems), so it shouldn’t affect the prefix formation. When the actual write operation occurs,\thepage
should then expand correctly.
Unfortunately, not all definitions of \theH
will expand
in the form
. In which case a
warning will occur:
\the
Hyper target ` ' can't be formed by prefixing
location ` '. You need to modify the definition of \theH
otherwise you will get the warning: "`name{ . }' has been
referenced but does not exist"
If you need the location hyperlink, you will either have to
redefine \theH
or switch to Option 4 and
record=nameref.
12.4. Page Precedence[link]
The page precedence indicates the location ordering within the number list based on the location syntax. For example, if an entry has been indexed on pages 5, 7, i and ii, then the number list will be “i, ii, 5, 7” with the default order of precedence.
With makeindex, the default precedence is rnaRA
, which
indicates: lowercase Roman
(\roman
), numeric (\arabic
), lowercase alphabetic
(\alph
), uppercase Roman (\Roman
), and
uppercase alphabetic (\Alph
). This order can be changed
by adding the page_precedence
parameter to the ist
file. There’s no specific command provided for this, so you will
need to use the \GlsSetWriteIstHook
to add this. For example:
\GlsSetWriteIstHook
{%\write
\glswrite
{page_precedence "arnAR"}% }
With xindy, the precedence is given by the order the
location classes are listed in define-location-class-order
within the xdy style file. This order can either be changed
in a custom xdy file or can be set with
\GlsSetXdyLocationClassOrder
.
Since neither Options 1 and 4 recognise specific location classes, they have no concept of page precedence. They will both create location lists that are in the same order as the locations were indexed, which means they will match the order those locations occur in the document. However, with bib2gls, it’s possible to gather the locations into sub-groups according to the associated counter or split off locations with identified primary formats. See the bib2gls manual for further details.
12.5. Problematic Locations[link]
The default location counter is the page counter, the
value of which is obtained with \thepage
. Due to TeX’s
asynchronous output routine, \thepage
may be incorrect at the
start of a new page. To ensure that the page number is correct, a
delayed write is needed, which is what is usually done when writing
information to the aux and toc files (and to
indexing files).
This works fine with Options 1 and 4 since neither of those options have any restrictions on the location syntax (provided that it’s valid LaTeX code). With bib2gls, if it can’t work out a numeric value for the location then it simply won’t be able to form a range. Additionally, bib2gls v3.0+, converts an empty location into an ignored location, which means the entry will still be selected so that it can be included in the glossary, but it won’t cause a spurious comma or en-dash as there won’t be an invisible location in the number list.
The only problematic locations with Options 1 and 4 are where
hyperlinks are required but the target name can’t be formed
from the prefix, counter and location information (see
§12.3). The best solution with
bib2gls in this case is to use record=nameref, which
saves the actual target name in the indexing record.
With Option 1 you will have to redefine \theH
as
appropriate.
With Options 2 and 3, the location must expand to content that is compatible with the indexing application’s syntax. The syntax for makeindex is quite restrictive and is described in §12.3.
For example, \thepart
is normally formatted as an
uppercase Roman numeral. There’s no Roman numeral for 0 so if
the part counter is 0 (that is, before the first \part
)
then \thepart
will expand to nothing.
This can be demonstrated in the following document:
In the above, the first instance of\documentclass
{article}\usepackage
[counter=part]{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={}}\begin{document}
\gls
{sample}% part = 0\part
{Sample Part}\section
{Sample Section}\gls
{sample}.\printglossaries
\end{document}
\gls
{sample}
will have an empty location. This will cause makeindex to
reject the location with the following message in the transcript
(assuming the document file is called myDoc.tex):
!! Input index error (file = myDoc.glo, line = 1): -- Illegal page number or page_precedence rnaRA.If makeglossaries encounters this warning, it will replace the empty location with “0” and change the location encap to glsignore. In the above example, this will lead to an invisible location in the number list, but that’s exactly what an empty location would do if makeindex allowed it.
Similarly, if the page compositor hasn’t been correctly identified, then it can also result in an invalid location. For example:
This will cause makeindex to reject the location with the following message in the transcript:\documentclass
{article}\usepackage
[counter=section]{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={}} % default compositor is '.' not '-'\renewcommand
{\thesection
}{\thepart
-\arabic
{section}}\begin{document}
\part
{Sample Part}\section
{Sample Section}\gls
{sample}.\printglossaries
\end{document}
!! Input index error (file = myDoc.glo, line = 1): -- Illegal Roman number: position 2 in I-1.If makeglossaries encounters this warning, it will replace any invalid content (the hyphen, in this case) with the page compositor specified in the ist file.
In both of the above examples, using makeglossaries will help the document build to complete without the entries disappearing from the glossary, however the resulting number list may look strange. If you are using nonumberlist then this isn’t a problem.
If you don’t use makeglossaries but explicitly call
makeindex then you won’t have those corrections, and some or
all of your entries may be omitted from the glossary.
In which case, you will have to adjust the location so that it fits
makeindex’s syntax even if you have
nonumberlist. In the case of the invalid page compositor
problem, you can simply use \glsSetCompositor
to set the
correct compositor. In the case of empty locations you will
need to chose a different location counter.
Other problems occur with commands that don’t fully expand, which results
in LaTeX markup in the location in the indexing file.
For example, if babel is used with spanish,
lowercase Roman numerals (which may occur in the front matter)
will expand to the internal command \es@scroman
, as in the
following:
The first instance of\documentclass
{book}\usepackage
[T1]{fontenc}\usepackage
[spanish]{babel}\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={un ejemplo}}\begin{document}
\frontmatter
\chapter
{Foreword}\gls
{sample}% problem location\mainmatter
\chapter
{Sample}\gls
{sample}\printglossaries
\end{document}
\gls
occurs in the front matter on
page i, which in this case is formatted in faked small caps with
\es@scroman
. This can be found in the glo file, which
contains:
Each line in the glo file corresponds to a single indexing instance (created with\glossaryentry
{sample?\glossentry
{sample}|setentrycounter[]{page}"
\glsnumberformat
}{\es@scroman
{i}}\glossaryentry
{sample?\glossentry
{sample}|setentrycounter[]{page}"
\glsnumberformat
}{1}
\gls
in this case).
The double-quote ("
) is makeindex’s escape
character (which can be changed with \GlsSetQuote
). It’s not
necessary in the above but was added as a by-product of the internal
escaping of special characters (the backslash isn’t a special
character for makeindex, except in the ist file,
but is for xindy).
The indexing data is contained in the arguments of:
This isn’t a defined command but is simply used as a keyword in the indexing file. By default, makeindex expects\indexentry
. The custom ist style file created by
\makeglossaries
identifies \glossaryentry
as the keyword:
keyword "\\glossaryentry"
The syntax for the second argument 12.3. The syntax for the first argument is in the form:
is as described in §or for sub-entries:?
|
The question mark (?
!
?
|
?
) is the “actual character”
and separates the sort value from the actual text that’s written to
the gls file (which is input by \printglossary
).
By default, makeindex uses @
as the actual character but
this caused a problem for early versions of glossaries where
there was a greater chance of internal commands occurring in the
glo file. The custom ist file identifies
?
as the actual character:
actual '?'
You may remember from §12.1 that the
format option specifies the encap, which I claimed
was essentially the same as the encap with \index
, but as
can be seen from the above example, that’s not strictly speaking
true. The real encap has to include \setentrycounter
so
that (if hyperlinks are supported) the appropriate target
name can be constructed.
The way that makeindex works is that it will write
\
{ }
in the gls (or equivalent) file. What glossaries
actually needs for the hyperlinks to work is:
where is the real formatting command name (identified in the format option).\setentrycounter
[ ]{ }\
{ }
So from makeindex’s point of view, the real encap in the above example is the literal string:
setentrycounter[]{page}\glsnumberformat
In the above example, the location has ended up as
which is invalid, as
makeindex requires the location to consist solely of digits,
Roman numerals or alphabetic, optionally separated by a compositors.
\es@scroman
{i}
That means that this example will trigger a message from makeindex which will be written to the glg transcript file:
Scanning input file myDoc.glo... !! Input index error (file = myDoc.glo, line = 1): -- Illegal space within numerals in second argument. .done (1 entries accepted, 1 rejected). Sorting entries...done (0 comparisons). Generating output file myDoc.gls....done (6 lines written, 0 warnings).Note that 1 entry has been rejected, but it also shows 0 warnings and it has a 0 exit code, which means that it won’t interrupt the overall document build.
If you run makeglossaries instead of running makeindex explicitly, then makeglossaries will search the glg transcript for the “( line, and if entries accepted, rejected)” is greater than 0 it will attempt to diagnose and fix the problem.
Messages about the “second argument” (as in “Illegal space
within numerals in second argument”) indicate that the problem is
with the location, so makeglossaries will search the
locations for content that matches \
{ }
(with any or no spaces after the command name and
optionally preceded by \protect
). If it
finds a match, it will shift into the encap with
the following message:
Encap/location issue: potential LaTeX commands in location detected. Attempting to remedy.
Reading myDoc.glo...
Invalid location '\es@scroman
{i}' detected for entry 'sample'. Replaced with 'i'
Writing myDoc.glo...
Retrying
The altered glo file now contains:
and makeglossaries will re-run makeindex.\glossaryentry
{sample?\glossentry
{sample}|setentrycounter[]{page}"
\glslocationcstoencap
{glsnumberformat}{es@scroman}}{i}\glossaryentry
{sample?\glossentry
{sample}|setentrycounter[]{page}"
\glsnumberformat
}{1}
Following this correction, the number list for the “sample” entry now contains:
The corrected location needs to be encapsulated with both the designated encap (glsnumberformat in this case) and the formatting command that needs to be applied to the location. This is done via: This is simply defined to do:\setentrycounter
[]{page}\glslocationcstoencap
{glsnumberformat}{es@scroman}{i}\delimN
\setentrycounter
[]{page}\glsnumberformat
{1}
This puts the intended encap (glsnumberformat in this case) closer to the location to enable it to work better with hyperlinks, although this may not always work, particularly if the command with the name expects a numerical argument.\csuse
{ }{\csuse
{ }{ }}
In the above example, the location command is \es@scroman
which is
provided by babel-spanish and performs fake
small caps. Internal commands provided by other packages for
their own private use can’t be relied upon. So the glossaries
package can’t assume they will stay the same, and the above example
document may produce a different result with different versions of
babel. However, in this case (provided you use
makeglossaries), the document will correctly end up with
the number list “i, 1” for the “sample” entry in
the glossary, which matches the document
page numbering. If you use makeindex explicitly, the
number list will simply be “1”.
This become more complicated if hyperref is added to the
document (before glossaries). Now \glsnumberformat
uses
\glshypernumber
, which needs to take into account that its
argument may contain a range with the start and end location
separated by \delimR
(the range delimiter), and it needs to
create a separate hyperlink for each location component.
Here’s a modified example that has an implicit range in the front matter and an explicit range in the main matter.
This again has problematic locations, but makeglossaries can shift the\documentclass
{book}\usepackage
[T1]{fontenc}\usepackage
[spanish]{babel}\usepackage
[colorlinks]{hyperref}\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={un ejemplo}}\begin{document}
\frontmatter
\chapter
{Foreword}\gls
{sample}\newpage
\gls
{sample}\newpage
\gls
{sample}\mainmatter
\chapter
{Sample}\gls
[format=(
hyperbf]{sample}\newpage
Some text\newpage
\gls
[format=)
hyperbf]{sample}\printglossaries
\end{document}
\es@scroman
into the encap as before. The
resulting gls file has the following number list for the
“sample” entry:
Both ranges have been compacted so that the range, including the\setentrycounter
[]{page}% prefix and counter\glslocationcstoencap
{glsnumberformat}{es@scroman}{i\delimR
iii}\delimN
\setentrycounter
[]{page}% prefix and counter\hyperbf
{1\delimR
3}
\delimR
separator, is in the argument of the
encap command.
The default definition of \glslocationcstoencap
means that the
first range is formatted according to:
This allows\es@scroman
{\glshypernumber
{i\delimR
iii}}
\glshypernumber
to detect the delimiter and split
up the range so that it can apply a separate hyperlink to the start and
end locations, so that it effectively becomes:
In this type of situation, the most problematic document is one where the can’t handle\es@scroman
{\hyperlink
{ }{i}\delimR
\hyperlink
{ }{iii}}
\hyperlink
in its argument
and needs to be shifted into the hyperlink text. In the above
example document, no actual error occurs, but there are warnings from pdfTeX:
pdfTeX warning (dest): name{page.iii} has been referenced but does not exist, replaced by a fixed one [...] pdfTeX warning (dest): name{page.i} has been referenced but does not exist, replaced by a fixed oneThis is due to the way that
\glshypernumber
forms the target
name. Since the actual target name isn’t saved in the
indexing data, it has to be reconstituted from available
information: the prefix, the counter and the location.
So the targets become page.i
for location “i” and
page.iii
for location “iii”. This usually works for common
page formats, but it doesn’t in this case. Adding debug to
hyperref’s package options reveals the following information
in the transcript:
Package hyperref Info: Anchor `page.I' [...] Package hyperref Info: Anchor `page.II'So the correct anchors are “page.I” and “page.II”.
The case change occurs as a result of the fake small caps,
but since \es@scroman
is outside of \glshypernumber
, the
case change isn’t part of the location and so doesn’t affect
the anchor name.
I can redefine \glslocationcstoencap
to swap them around:
However, now the transcript shows:\renewcommand
{\glslocationcstoencap
}[3]{\csuse
{#1}{\csuse
{#2}{#3}}}
pdfTeX warning (dest): name{page.\\protect\040\\es@scroman\040\040{i--iii}} has been referenced but does not exist, replaced by a fixed oneThis is because
\es@scroman
doesn’t fully expand.
The \glswrglossdisableanchorcmds
hook provides a workaround
for the problematic command:
This will cause\appto
\glswrglossdisableanchorcmds
{\csletcs
{es@scroman}{text_uppercase:n}}
\es@scroman
to be locally redefined to just
convert its argument to uppercase while the anchor is being
constructed. Unfortunately this patch is only partially successful
as the transcript now has:
pdfTeX warning (dest): name{page.I-- III} has been referenced but does not exist, replaced by a fixed oneThe problem now is that
\glshypernumber
can’t split on the
range delimiter, so the location is now “I--III”.
If the number list doesn’t contain any ranges, then the
above redefinition of \glslocationcstoencap
and the addition to
\glswrglossdisableanchorcmds
will fix the hyperlink.
Instead of redefining \glslocationcstoencap
and altering
\glswrglossdisableanchorcmds
, a solution that works with
ranges can be achieved by redefining
\glswrglosslocationtarget
to convert its argument to
uppercase. You can do this with:
\renewcommand
{\glswrglosslocationtarget
}[1]{\glsuppercase
{#1}}
This will successfully construct the anchor names page.I
and
page.III
. It won’t affect the anchors for the main matter as
digits aren’t affected by the case-changing command.
If you’re not using makeglossaries and are either calling
makeindex explicitly or via makeglossaries-lite or
with the automake option, then you will need to find another
way of converting problematic location into a form that won’t be
discarded by makeindex. This is quite difficult if the
problematic content is inside \thepage
since its delayed
expansion means that any attempt at locally changing the problematic
within \glswrglossdisablelocationcmds
will be lost.
The earlier example can be rewritten to (sort of!) work without makeglossaries:
Note that the custom\documentclass
{book}\usepackage
[T1]{fontenc}\usepackage
[spanish]{babel}\usepackage
[colorlinks]{hyperref}\usepackage
{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={un ejemplo}}\newcommand
{\locthepage
}{\Roman
{page}}\newcommand
{\delayedlocthepage
}{\expandonce
{\locthepage
}}\appto
\glswrglossdisablelocationcmds
{\let
\thepage
\delayedlocthepage
}\begin{document}
\frontmatter
\chapter
{Foreword}\gls
{sample}\newpage
\gls
{sample}\newpage
\gls
{sample}\mainmatter
\renewcommand
{\locthepage
}{\arabic
{page}}\chapter
{Sample}\gls
[format=(
hyperbf]{sample}\newpage
Some text\newpage
\gls
[format=)
hyperbf]{sample}\printglossaries
\end{document}
\locthepage
command needs to be
redefined after the page numbering changes at the start of the main
matter.
This ensures that the locations are valid in the glo file, so makeindex will process it without losing any rejecting any entry lines. The hyperlink targets will also be correct. The only problem now is that the front matter locations will be in uppercase in the glossary.
The above problems are all due to makeindex having a
restrictive location syntax. With xindy, you can define
location classes for custom locations. Unfortunately, the backslash
\
is a special character for xindy that indicates an
escape sequence that indicates the next character should be
interpreted literally, which means that any LaTeX commands that end up
in the xindy indexing file must have their initial
backslash escaped. This is quite tricky to do given the delayed
expansion of \thepage
. If it’s expanded early in order to
pre-process it then the page number could end up being incorrect.
The sample file samplexdy.tex provides a custom page format that
uses a robust command called \tallynum
, which ends up in the
glo file. With the default esclocations=false
setting, the location for the first page is written to the file as:
:locref "{}{\tallynum
{1}}"
This results in the following message from xindy:
WARNING: location-reference "{}{tallynum {1}}" did not match any location-class! (ignored)Note that the backslash has gone from the start of
tallynum
.
As with makeindex, invalid locations are dropped.
If you use makeglossaries rather than running xindy directly, makeglossaries will detect the warning and provide some diagnostic information:
You may have forgotten to add a location
class with \GlsAddXdyLocation
or you may have
the format incorrect or you may need
the package option esclocations=true.
In this case, you need to use the package option
esclocations=true. This will use a hack to provide a way
to escape the backslash without prematurely expanding the actual
value of the page counter. As this is a hack, it may not work
and can result in obscure error messages.
Returning to the earlier babel-spanish example, if it’s converted to use xindy instead of makeindex, a similar problem arises. For example, simply adding the xindy package option:
The glo file now contains locations with\documentclass
{book}\usepackage
[T1]{fontenc}\usepackage
[spanish]{babel}\usepackage
[colorlinks]{hyperref}\usepackage
[xindy]{glossaries}\makeglossaries
\newglossaryentry
{sample}{name={sample},description={un ejemplo}}\begin{document}
\frontmatter
\chapter
{Foreword}\gls
{sample}\newpage
\gls
{sample}\newpage
\gls
{sample}\mainmatter
\chapter
{Sample}\gls
[format=(
hyperbf]{sample}\newpage
Some text\newpage
\gls
[format=)
hyperbf]{sample}\printglossaries
\end{document}
\es@scroman
, but
as with the \tallynum
example, the leading backslash hasn’t
been escaped:
:locref "{}{\es@scroman
{i}}"
This needs esclocations=true to escape the backslash.
\usepackage
[xindy,esclocations]{glossaries}
Note that this produces a different result in the glo file:
:locref "{}{\\protect \\es@scroman {i}}"This results from the partial protected expansion used on
\thepage
before the special characters are escaped.
If you inspect the xdy file created by \makeglossaries
,
you should find the following:
(define-location-class "roman-page-numbers" ( :sep "{}{" :sep "This is because the non-default behaviour of\protect
\es@scroman
{" "roman-numbers-lowercase" :sep "}" :sep "}" ) :min-range-length 2 )
\roman
has been
detected and a custom location class has automatically been supplied.
(Whereas with the samplexdy.tex sample file, it was necessary to
provide the custom class to support \tallynum
with \GlsAddXdyLocation
.)
12.6. Iterating Over Locations[link]
The \printnoidxglossary
command displays the location list
using:
\forlistloop
to iterate
over all the locations in the list with the handler macro:
This keeps track of the previous element in the list to determine whether or
not to insert the \delimN
separator. Note that it doesn’t attempt to
determine whether or not any of the locations are ranges.
\printunsrtglossary
command will also use \glsnoidxloclist
if the
loclist field has been set but the location
field hasn’t, but in general it’s better to instruct bib2gls
to save the formatted location list (which is the default).
You can iterate over an entry’s loclist field using:
where is the entry’s label and is a handler control sequence with the syntax:where { }{ }{ }{ } is the hypertarget prefix, is the name of the location counter, is the location encap (for example, textbf) and is the location.
The third argument
is the control sequence that will be applied to any cross-references in the list. This handler should have the syntax:where [ ]{ }{ } is the cross-referenced textual tag (for example, “see”) and is a comma-separated list of entry labels. The final argument will always be empty, but it allows for
\glsseeformat
to be used as the handler.
For example, if on page 12 I have:
\gls
[format=textbf]{apple}
and on page 18 I have:
\gls
[format=emph]{apple}
then
will be equivalent to:\glsnumberlistloop
{apple}{\myhandler
}
There is a predefined handler that’s used to display the number list in\myhandler
{}{page}{textbf}{12}%\myhandler
{}{page}{emph}{18}%
\printnoidxglossary
:
This simply does:
which sets up the hyperlink information needed for\setentrycounter
[ ]{ }%\csuse
{ }{ }
\glshypernumber
(in case it’s required by the encap)
and encapsulates the location, with the provided formatting
command.
Internally, \glsnumberlistloop
uses etoolbox’s
\forlistloop
with the handler:
\glsnoidxdisplayloc
{ }{ }{ }{ }
The \glsnumberlistloop
works by temporarily redefining \glsnoidxdisplayloc
to and \glsseeformat
to .
\glsxtrfieldforlistloop
and provide your own handler that can
be customized to suit record=only or
record=nameref.
13. Glossary Styles[link]
The markup used in the glossary is described in §8.2. §13.2 describes how to define a new glossary style. Commands that may be used in styles, but should not be redefined by styles, are described in §§13.2.1 & 13.2.2. The commands that should be redefined by the glossary style are described in §13.2.3.
Glossary styles typically use \glossentryname
to display
the entry’s name, but some may use the sentence case version
\Glossentryname
instead. Both encapsulate the name with:
\glsentryname
or \Glsentryname
).
By default, \glsnamefont
simply displays its argument in
whatever the surrounding font happens to be, but bear in mind that
the glossary style may switch the font.
\glossentryname
only, case-changing.
For example, the tree style displays the name as follows:
which is essentially (ignoring the hyperlink target):\glstreenamefmt
{\glstarget
{ }{\glossentryname
{ }}}
Since\glstreenamefmt
{\glsnamefont
{\glsentryname
{ }}}
\glstreenamefmt
is defined to display its argument in
bold, the name will end up in bold unless \glsnamefont
is
redefined to change it.
The list style displays the name in the option argument
of \item
:
which is essentially (ignoring the entry counter and hyperlink target):\item
[\glsentryitem
{ }\glstarget
{ }{\glossentryname
{ }}]
This occurs within the description environment, which by default uses bold for the item text. However, this may be changed by various classes or packages. So the name may end up in bold or may be in some other font, such as sans-serif.\item
[\glsnamefont
{\glsentryname
{ }}]
The long style displays the name in the first column of a longtable:
So the only font change will come from\glsentryitem
{ }\glstarget
{ }{\glossentryname
{ }}&
\glsnamefont
, which
doesn’t apply any change by default.
Glossary styles will typically display the description with
\glossentrydesc
but may not show the symbol. If the symbol is
shown, it should be displayed with \glossentrysymbol
.
There’s no analogous font command for the description or symbol, but the glossaries-extra package provides the glossdescfont and glosssymbolfont attributes to change the font according to the entry’s category.
Some styles may supply their own helper commands (such as \glstreenamefmt
)
to make it easier to adjust the formatting without having to define
a new glossary style.
\renewcommand
{\glsnamefont
}[1]{\textsc
{\mdseries
#1}}
Some styles support groups. These may simply insert a
vertical gap between groups, but some may also include
a heading with the group title. The base glossaries
package only has a simple mechanism for obtaining the title from the
group label via \glsgetgrouptitle
, which will test if
\
groupname exists where the
is glssymbols
, glsnumbers
or a single character.
\glsxtrsetgrouptitle
and \glsxtrlocalsetgrouptitle
to set the group title,
which take precedence over \
groupname.
13.1. Predefined Styles[link]
The predefined styles can accommodate numbered top level (level 0) and level 1 entries. See the package options entrycounter, counterwithin and subentrycounter described in §2.3. There is a summary of available styles in Table 13.1. You can view samples of all the predefined styles at dickimaw-books.com/gallery/glossaries-styles/. Note that glossaries-extra provides additional styles in the supplementary packages glossary-bookindex, glossary-topic and glossary-longextra. See the glossaries-extra manual for further details.
The group title is obtained using \glsgetgrouptitle
{label},
which is described in §13.2.
Style | Maximum Level | Homograph | Symbol |
---|---|---|---|
listdotted |
0 | ||
sublistdotted |
1 | ||
list* |
1 | ✔ | |
altlist* |
1 | ✔ | |
long*3col* |
1 | ✔ | |
long4col* |
1 | ✔ | ✔ |
altlong*4col* |
1 | ✔ | ✔ |
long* |
1 | ✔ | |
super*3col* |
1 | ✔ | |
super4col* |
1 | ✔ | ✔ |
altsuper*4col* |
1 | ✔ | ✔ |
super* |
1 | ✔ | |
*index* |
2 | ✔ | |
treenoname* |
∞ | ✔ | ✔ |
*alttree* |
∞ | ✔ | |
*tree* |
∞ | ✔ | |
inline |
1 | ✔ |
The tabular-like styles that allow multi-line descriptions and number lists use the length:
to set the width of the description column and the length to set the width of the number list column.
These will need to be changed using \setlength
if the
glossary is too wide. Note that the long4col and
super4col styles (and their header and border variations)
don’t use these lengths as they are designed for single line
entries. Instead you should use the analogous altlong4col
and altsuper4col styles. If you need to
explicitly create a line-break within a multi-line description in
a tabular-like style it’s better to use \newline
instead of
\\
(but consider using a ragged style with narrow columns).
Note that if you use the style key in the
optional argument to \print
glossary, it will override any
previous style settings for the given glossary, so if, for example,
you do
then the new definition of\renewcommand
*{\glsgroupskip
}{}% no effect\printglossary
[style=long]
\glsgroupskip
will not have an affect
for this glossary, as \glsgroupskip
is redefined by
style=long. Likewise, \setglossarystyle
will also
override any previous style definitions, so, again
will reset\renewcommand
*{\glsgroupskip
}% no effect\setglossarystyle
{long}
\glsgroupskip
back to its default definition for the
named glossary style (long in this case). If you want to
modify the styles, either use \newglossarystyle
(described
in the next section) or make the modifications after
\setglossarystyle
. For example:
In this case, it’s better to use nogroupskip to suppress the gap between groups for the default styles instead of redefining\setglossarystyle
{long}\renewcommand
*{\glsgroupskip
}{}
\glsgroupskip
.
All the styles except for the three- and four-column styles and the listdotted style use the post-description hook:
after the description. This simply displays a full stop by default. To eliminate this full stop (or replace it with something else, say, a comma) you will need to redefine\glspostdescription
before
the glossary is displayed. Alternatively, you can suppress it for a
given entry by placing \nopostdesc
in the entry’s description.
Note that \longnewglossaryentry
puts \nopostdesc
at the end
of the description. The glossaries-extra package provides a
starred version that doesn’t.
Alternatively, you can use the package option nopostdot to suppress this full stop. This is implemented by default with glossaries-extra. You can switch it back on with nopostdot=false or postdot=or you can use postpunc for a different punctuation character.
13.1.1. List Styles[link]
The glossary styles described in this section are all defined in the package glossary-list. Since they all use the description environment, they are governed by the same parameters as that environment. These styles all ignore the entry’s symbol. Note that these styles will automatically be available unless you use the nolist or nostyles package options.
There is an initialisation hook that provides a patch if the gettitlestring package is loaded, since this is used by hyperref.
Note that this automatically implements:\GetTitleStringSetup
{expand}
This patch should ensure that the combination of hyperref and
entrycounter will correctly expand the entry name to the
aux file. The name is expanded using:
This uses \glsunexpandedfieldvalue
. If you need the name to
fully expand, you can redefine this. For example:
\newcommand
{\glslistexpandedname
}[1]{\glsentryname
{#1}}
If nogroupskip=false, the \glsgroupskip
command creates
a vertical space using:
For the styles that should group headings, the group title is encapsulated with:
This simply does its argument by default, but it occurs inside the optional argument of\item
so may appear bold from the item
font change.
For the styles that have a navigation line, the line is formatted according to:
This puts its argument inside the optional argument of\item
,
which can cause a problem if the navigation line is too long, in
which case you will need to redefine \glslistnavigationitem
. For example:
You may prefer to use the tree-like styles, such as treehypergroup instead.\renewcommand
*{\glslistnavigationitem
}[1]{\item
\textbf
{#1}}
The list style uses the description environment. The entry name is placed in the optional argument of the
\item
command (so it will usually appear in bold by default). The
description follows, and then the associated number list for
that entry. The symbol is ignored. If the entry has child entries,
the description and number list follows (but not the name) for each
child entry. Groups are separated using \indexspace
with the
default nogroupskip=true.
The closest matching non-list style is the index style.
The listgroup style is like list but the groups have headings obtained using
\glsgetgrouptitle
,
which is described in §13.2.
The listhypergroup style is like listgroup but has a navigation line at the start of the glossary with links to each group that is present in the glossary, which is displayed in the glossary header with
\glslistnavigationitem
.
This requires an additional run through LaTeX to ensure the group
information is up to date. Within the navigation line, each
group item is separated by \glshypernavsep
.
The altlist style is like list but the description starts on the line following the name. (As with the list style, the symbol is ignored.) Each child entry starts a new line, but as with the list style, the name associated with each child entry is ignored.
The closest matching non-list style is the index style with the following adjustment:
\renewcommand
{\glstreepredesc
}{%\glstreeitem
\parindent
\hangindent
}
The altlistgroup style is like altlist but the glossary groups have headings.
The altlisthypergroup style is like altlistgroup but has a set of links to the glossary groups. The navigation line is the same as that for listhypergroup, described above.
This style uses the description environment.1 Each entry starts with
\item
[]
, followed by the name followed by a
dotted line, followed by the description. Note that this style
ignores both the number list and the symbol. The length
governs where the description should start. This is a flat style, so
child entries are formatted in the same way as the parent entries.
A non-list alternative is to use the index style with
Note that this doesn’t use\renewcommand
{\glstreepredesc
}{\dotfill
}\renewcommand
{\glstreechildpredesc
}{\dotfill
}
\glslistdottedwidth
and causes
the description to be flush-right and will display the
symbol, if provided. (It also doesn’t suppress
the number list, but that can be achieved with the
nonumberlist option.)
This is a variation on the listdotted style designed for hierarchical glossaries. The main entries have just the name displayed. The sub entries are displayed in the same manner as listdotted. Unlike the listdotted style, this style is incompatible with classicthesis.
13.1.2. Longtable Styles[link]
The glossary styles described in this section are all defined in the package glossary-long. Since they all use the longtable environment, they are governed by the same parameters as that environment. Note that these styles will automatically be available unless you use the nolong or nostyles package options. These styles fully justify the description and number list columns. If you want ragged right formatting instead, use the analogous styles described in §13.1.3. If you want to incorporate rules from the booktabs package, try the styles described in §13.1.4.
Groups are separated with a blank row unless nogroupskip is used before the style is set. For example:
Both may be combined in the same option list. For example:\usepackage
[nogroupskip]{glossaries}\setglossarystyle
{long}
\usepackage
[nogroupskip,style=long]{glossaries}
Or
\printglossary
[nogroupskip,style=longragged]
The following doesn’t work:
This is because the\setglossarystyle
{long}\printglossary
[nogroupskip]% too late
\ifglsnogroupskip
conditional needs to be
outside of \glsgroupskip
with tabular-like styles, so the
conditional is in the style definition to determine the appropriate
definition of \glsgroupskip
.
The long style uses the longtable
environment (defined by the longtable package). It has two
columns: the first column contains the entry’s name and the second
column contains the description followed by the number list.
The entry’s symbol is ignored. The width of the
first column is governed by the widest entry in that column. The
width of the second column is governed by the length
\glsdescwidth
. Child entries have a similar format to the
parent entries except that their name is suppressed.
The longborder style is like long but has horizontal and vertical lines around it.
The longheader style is like long but has a header row. You may prefer the long-booktabs style instead.
The longheaderborder style is like longheader but has horizontal and vertical lines around it. The long-booktabs style is generally better.
The long3col style is like
long but has three columns. The first column contains
the entry’s name, the second column contains the description
and the third column contains the number list.
The entry’s symbol is ignored. The width of the
first column is governed by the widest entry in that column, the
width of the second column is governed by the length
\glsdescwidth
, and the width of the third column is governed by the
length \glspagelistwidth
.
The long3colborder style is like the long3col style but has horizontal and vertical lines around it.
The long3colheader style is like long3col but has a header row. You may prefer the long3col-booktabs style instead.
The long3colheaderborder style is like long3colheader but has horizontal and vertical lines around it. The long3col-booktabs style is generally better.
The long4col style is like long3col but has an additional column in which the entry’s associated symbol appears. This style is used for brief single line descriptions. The column widths are governed by the widest entry in the given column. Use altlong4col for multi-line descriptions.
The long4colborder style is like the long4col style but has horizontal and vertical lines around it.
The long4colheader style is like long4col but has a header row. You may prefer the long4col-booktabs style instead.
The long4colheaderborder style is like long4colheader but has horizontal and vertical lines around it.
The altlong4col style is like long4col but
allows multi-line descriptions and number lists. The width of the
description column is governed by the length \glsdescwidth
and
the width of the number list column is governed by the length
\glspagelistwidth
. The widths of the name and symbol columns
are governed by the widest entry in the given column.
The altlong4colborder style is like the long4colborder but allows multi-line descriptions and number lists.
The altlong4colheader style is like long4colheader but allows multi-line descriptions and number lists. You may prefer the altlong4col-booktabs style instead.
The altlong4colheaderborder style is like long4colheaderborder but allows multi-line descriptions and number lists.
13.1.3. Longtable Styles (Ragged Right)[link]
\usepackage
{glossary-longragged}
\usepackage
[stylemods=longragged]{glossaries-extra}
The glossary styles described in this section are all defined in the package glossary-longragged. These styles are analogous to those defined in glossary-long but the multiline columns are left justified instead of fully justified. Since these styles all use the longtable environment, they are governed by the same parameters as that environment. The glossary-longragged package additionally requires the array package. Note that these styles will only be available if you explicitly load glossary-longragged:
Note that you can’t set these styles using the style package option since the styles aren’t defined until after the glossaries package has been loaded. If you want to incorporate rules from the booktabs package, try the styles described in §13.1.4.\usepackage
{glossaries}\usepackage
{glossary-longragged}\setglossarystyle
{longragged3col}
With glossaries-extra, you can load both the package and style with the style and stylemods options. For example:
\usepackage
[style=longragged3col,stylemods=longragged]{glossaries-extra}
As with the glossary-long styles, groups are separated with a blank row unless nogroupskip is used before the style is set. For example:
Or\usepackage
[nogroupskip]{glossaries}\usepackage
{glossary-longragged}\setglossarystyle
{longragged}
\printglossary
[nogroupskip,style=longragged]
The longragged style has two columns: the first column
contains the entry’s name and the second column contains the
(left-justified) description followed by the number list. The
entry’s symbol is ignored. The width of the first column is governed
by the widest entry in that column. The width of the second column
is governed by the length \glsdescwidth
. Child entries have a
similar format to the parent entries except that their name is
suppressed.
The longraggedborder style is like longragged but has horizontal and vertical lines around it.
The longraggedheader style is like longragged but has a header row. You may prefer the longragged-booktabs style instead.
The longraggedheaderborder style is like longraggedheader but has horizontal and vertical lines around it.
The longragged3col style is like longragged
but has three columns. The first column contains the entry’s name,
the second column contains the (left justified) description and the
third column contains the (left justified) number list. The
entry’s symbol is ignored. The width of the first column is governed
by the widest entry in that column, the width of the second column
is governed by the length \glsdescwidth
, and the width of the
third column is governed by the length \glspagelistwidth
.
The longragged3colborder style is like the longragged3col style but has horizontal and vertical lines around it.
The longragged3colheader style is like longragged3col but has a header row. You may prefer the longragged3col-booktabs style instead.
The longragged3colheaderborder style is like longragged3colheader but has horizontal and vertical lines around it.
The altlongragged4col style is like
longragged3col but has an additional column in which the
entry’s associated symbol appears. The width of the description
column is governed by the length \glsdescwidth
and the width of
the number list column is governed by the length
\glspagelistwidth
. The widths of the name and symbol columns
are governed by the widest entry in the given column.
The altlongragged4colborder style is like the altlongragged4col but has horizontal and vertical lines around it.
The altlongragged4colheader style is like altlongragged4col but has a header row. You may prefer the altlongragged4col-booktabs style instead.
The altlongragged4colheaderborder style is like altlongragged4colheader but has horizontal and vertical lines around it.
13.1.4. Longtable Styles (booktabs)[link]
\usepackage
{glossary-longbooktabs}
\usepackage
[stylemods=longbooktabs]{glossaries-extra}
The glossary styles described in this section are all defined in the package glossary-longbooktabs.
Since these styles all use the longtable environment, they are governed by the same parameters as that environment. The glossary-longbooktabs package automatically loads the glossary-long (§13.1.2) and glossary-longragged (§13.1.3) packages. Note that these styles will only be available if you explicitly load glossary-longbooktabs:
Note that you can’t set these styles using the style package option since the styles aren’t defined until after the glossaries package has been loaded.\usepackage
{glossaries}\usepackage
{glossary-longbooktabs}
With glossaries-extra, you can load both the package and style with the style and stylemods options. For example:
\usepackage
[style=long3col-booktabs,stylemods=longbooktabs]{glossaries-extra}
As with the glossary-long styles, groups are separated with a blank row unless nogroupskip is used before the style is set. For example:
Or\usepackage
[nogroupskip]{glossaries}\usepackage
{glossary-longbooktabs}\setglossarystyle
{long-booktabs}
\printglossary
[nogroupskip,style=long-booktabs]
These styles are similar to the “header” styles in the glossary-long and
glossary-longragged packages, but they add the rules
provided by the booktabs package, \toprule
, \midrule
and
\bottomrule
. Additionally these styles patch the
longtable environment to check for instances of the group
skip occurring at a page break. If you don’t want this patch to
affect any other use of longtable in your document, you can
scope the effect by only setting the style through the
style key in the optional argument of
\print
glossary.
Alternatively, you can restore the original longtable behaviour with:
The penalty check is tested with:
The default definition is:\ifnum
\outputpenalty
=-50\vskip
-\normalbaselineskip
\relax
\fi
With the default nogroupskip=false, \glsgroupskip
will be defined to use:
\noalign
{\penalty
-50\vskip
\normalbaselineskip
}
This style is similar to the longheader style but adds
rules above and below the header (\toprule
and \midrule
) and
inserts a rule at the bottom of the table (\bottomrule
).
This style is similar to the long3colheader style but adds rules as per long-booktabs.
This style is similar to the long4colheader style but adds rules as above.
This style is similar to the altlong4colheader style but adds rules as above.
This style is similar to the longraggedheader style but adds rules as above.
This style is similar to the longragged3colheader style but adds rules as above.
This style is similar to the altlongragged4colheader style but adds rules as above.
13.1.5. Supertabular Styles[link]
The glossary styles described in this section are all defined in the package glossary-super. Since they all use the supertabular environment, they are governed by the same parameters as that environment. Note that these styles will automatically be available unless you use the nosuper or nostyles package options. In general, the longtable environment is better, but there are some circumstances where it is better to use supertabular. (For example, with the flowfram package.) These styles fully justify the description and number list columns. If you want ragged right formatting instead, use the analogous styles described in §13.1.6.
As with the glossary-long styles, groups are separated with a blank row unless nogroupskip is used before the style is set. For example:
Or\usepackage
[nogroupskip]{glossaries}\setglossarystyle
{super}
\usepackage
[nogroupskip,style=super]{glossaries}
Or
\printglossary
[nogroupskip,style=super]
The super style uses the supertabular
environment (defined by the supertabular package). It has two
columns: the first column contains the entry’s name and the second
column contains the description followed by the number list.
The entry’s symbol is ignored. The width of the
first column is governed by the widest entry in that column. The
width of the second column is governed by the length
\glsdescwidth
. Child entries have a similar format to the
parent entries except that their name is suppressed.
The superborder style is like super but has horizontal and vertical lines around it.
The superheader style is like super but has a header row.
The superheaderborder style is like superheader but has horizontal and vertical lines around it.
The super3col style is like super but has
three columns. The first column contains the entry’s name, the
second column contains the description and the third column contains
the number list. The entry’s symbol is ignored. The width of
the first column is governed by the widest entry in that column. The
width of the second column is governed by the length
\glsdescwidth
. The width of the third column is governed by the
length \glspagelistwidth
.
The super3colborder style is like the super3col style but has horizontal and vertical lines around it.
The super3colheader style is like super3col but has a header row.
The super3colheaderborder style is like the super3colheader style but has horizontal and vertical lines around it.
The super4col style is like super3col but has an additional column in which the entry’s associated symbol appears. This style is designed for entries with brief single line descriptions. The column widths are governed by the widest entry in the given column. Use altsuper4col for multi-line descriptions.
The super4colborder style is like the super4col style but has horizontal and vertical lines around it.
The super4colheader style is like super4col but has a header row.
The super4colheaderborder style is like the super4colheader style but has horizontal and vertical lines around it.
The altsuper4col style is like super4col but
allows multi-line descriptions and number lists. The width of the
description column is governed by the length \glsdescwidth
and
the width of the number list column is governed by the length
\glspagelistwidth
. The width of the name and symbol columns is
governed by the widest entry in the given column.
The altsuper4colborder style is like the super4colborder style but allows multi-line descriptions and number lists.
The altsuper4colheader style is like super4colheader but allows multi-line descriptions and number lists.
The altsuper4colheaderborder style is like super4colheaderborder but allows multi-line descriptions and number lists.
13.1.6. Supertabular Styles (Ragged Right)[link]
\usepackage
{glossary-superragged}
\usepackage
[stylemods=superragged]{glossaries-extra}
The glossary styles described in this section are all defined in the package glossary-superragged. These styles are analogous to those defined in glossary-super but the multiline columns are left justified instead of fully justified. Since these styles all use the supertabular environment, they are governed by the same parameters as that environment. The glossary-superragged package additionally requires the array package. Note that these styles will only be available if you explicitly load glossary-superragged:
Note that you can’t set these styles using the style package option since the styles aren’t defined until after the glossaries package has been loaded.\usepackage
{glossaries}\usepackage
{glossary-superragged}
With glossaries-extra, you can load both the package and style with the style and stylemods options. For example:
\usepackage
[style=superragged3col,stylemods=superragged]{glossaries-extra}
As with the glossary-long styles, groups are separated with a blank row unless nogroupskip is used before the style is set. For example:
Or\usepackage
[nogroupskip]{glossaries}\usepackage
{glossary-superragged}\setglossarystyle
{superragged}
\printglossary
[nogroupskip,style=superragged]
The superragged style uses the supertabular
environment (defined by the supertabular package). It has two
columns: the first column contains the entry’s name and the
second column contains the (left justified) description followed by
the number list. The entry’s symbol is ignored. The width of
the first column is governed by the widest entry in that column. The
width of the second column is governed by the length
\glsdescwidth
. Child entries have a similar format to the
parent entries except that their name is suppressed.
The superraggedborder style is like superragged but has horizontal and vertical lines around it.
The superraggedheader style is like superragged but has a header row.
The superraggedheaderborder style is like superraggedheader but has horizontal and vertical lines around it.
The superragged3col style is like
superragged but has three columns. The first column
contains the entry’s name, the second column contains the (left
justified) description and the third column contains the (left
justified) number list. The entry’s symbol is ignored. The
width of the first column is governed by the widest entry in that
column. The width of the second column is governed by the length
\glsdescwidth
. The width of the third column is governed by the
length \glspagelistwidth
.
The superragged3colborder style is like the superragged3col style but has horizontal and vertical lines around it.
The superragged3colheader style is like superragged3col but has a header row.
The superragged3colheaderborder style is like the above but has horizontal and vertical lines around it.
The altsuperragged4col style is like superragged3col but has an additional column in which the entry’s associated symbol appears. The column widths for the name and symbol column are governed by the widest entry in the given column.
The altsuperragged4colborder style is like the altsuperragged4col style but has horizontal and vertical lines around it.
The altsuperragged4colheader style is like altsuperragged4col but has a header row.
The altsuperragged4colheaderborder style is like the above but has horizontal and vertical lines around it.
13.1.7. Tree-Like Styles[link]
The glossary styles described in this section are all defined in the package glossary-tree. These styles are designed for hierarchical glossaries but can also be used with glossaries that don’t have sub-entries. These styles will display the entry’s symbol if it has been set. Note that these styles will automatically be available unless you use the notree or nostyles package options.
These styles all format the entry name using:
This defaults to\textbf
{ }
, but note that
will include \glsnamefont
so the bold setting in \glstreenamefmt
may be counteracted by another font change in \glsnamefont
(or
in \acronymfont
). The tree-like styles that also display the
header use
to format the heading. This defaults to
\glstreenamefmt
{ }
. The tree-like styles that display
navigation links to the groups (such as indexhypergroup), format
the navigation line using
which defaults to \glstreenamefmt
{ }
.
Note that this is different from \glslistnavigationitem
,
provided with the styles such as listhypergroup, as that
also includes \item
.
With the exception of the alttree style (and those derived from it), the space before the description for top-level entries is produced with
This defaults to\space
.
With the exception of the treenoname and alttree styles (and those derived from them), the space before the description for child entries is produced with
This defaults to\space
.
The index style is similar to the way standard indices
are usually formatted in that it has a hierarchical structure up
to three levels (the main level plus two sub-levels). If the symbol
is present it is set in parentheses after the name and before the
description. Sub-entries are indented and also include the name,
the symbol in brackets (if present) and the description.
Groups are separated using \indexspace
.
Each main level item is started with
The level 1 entries are started withThe level 2 entries are started with
Note that the index style automatically sets
at the start of the theglossary environment for backward compatibility.\let
\item
\glstreeitem
\let
\subitem
\glstreesubitem
\let
\subsubitem
\glstreesubsubitem
The index style isn’t suitable for multi-paragraph descriptions, but this limitation can be overcome by redefining the above commands. For example:
\renewcommand
{\glstreeitem
}{%\parindent
0pt\par
\hangindent
40pt\everypar
{\parindent
50pt\hangindent
40pt}}
The indexgroup style is similar to the index
style except that each group has a heading obtained using
\glsgetgrouptitle
.
The indexhypergroup style is like indexgroup
but has a set of links to the glossary groups. The navigation
line is the same as that for listhypergroup, described
above, but is formatted using \glstreenavigationfmt
.
The tree style is similar to the index style except that it can have arbitrary hierarchical levels. (Note that makeindex is limited to three levels, so you will need to use another indexing method if you want more than three levels.) Each sub-level is indented according to the length
This value can be changed with\setlength
.
Note that the name, symbol (if present) and description are placed in the same paragraph block. If you want the name to be apart from the description, use the alttree style instead. (See below.)
The treegroup style is similar to the tree style except that each group has a heading.
The treehypergroup style is like
treegroup but has a set of links to the glossary
groups. The navigation line is the same as that for
listhypergroup, described above, but is formatted using
\glstreenavigationfmt
.
The treenoname style is like the tree style except that the name for each sub-entry is ignored.
The treenonamegroup style is similar to the treenoname style except that each group has a heading.
The treenonamehypergroup style is like
treenonamegroup but has a set of links to the glossary
groups. The navigation line is the same as that for
listhypergroup, described above, but is formatted using
\glstreenavigationfmt
.
The alttree style is similar to the tree style except that the indentation for each level is determined by the width of the text specified by
The optional argument indicates the hierarchical level, where 0 indicates the top-most level, 1 indicates the first level sub-entries, etc. If\glssetwidest
hasn’t been used for a given sub-level, the level 0 widest text is
used instead. If is omitted, 0 is assumed.
This requires keeping track of which entry has the widest name, which may not be practical for large glossaries. Instead you can use:
This iterates over all entries in the glossaries identified by the comma-separated list and determines the widest top level (level 0) entry. If the optional argument is omitted, all non-ignored glossaries are assumed.For example, to have the same name width for all glossaries:
Alternatively, to compute the widest entry for each glossary before it’s displayed:\glsfindwidesttoplevelname
\setglossarystyle
{alttree}\printglossaries
\renewcommand
{\glossarypreamble
}{%\glsfindwidesttoplevelname
[\currentglossary
]}\setglossarystyle
{alttree}\printglossaries
\glssetwidest
command also affects the styles provided by
glossary-topic.
The glossaries-extra-stylemods package provides additional
commands. With bib2gls, you may prefer the
set-widest resource option.
For each level, the name is placed to the left of the paragraph block containing the symbol (optional) and the description. If the symbol is present, it is placed in parentheses before the description.
The name is placed inside a left-aligned \makebox
, created with:
\renewcommand
*{\glstreenamebox
}[2]{%\makebox
[#1][r]{#2}% }
The alttreegroup is like the alttree style except that each group has a heading.
The alttreehypergroup style is like alttreegroup but has a set of links to the glossary groups.
13.1.8. Multicols Style[link]
The glossary-mcols package provides tree-like
glossary styles that are in the multicols environment
(defined by the multicol package). The style names are as
their analogous tree styles (as defined in
§13.1.7) but are prefixed with “mcol”. For
example, the mcolindex style is essentially the
index style but put in a multicols environment.
For the complete list, see Table 13.2. The
glossary-tree package is automatically loaded by
glossary-mcols (even if the notree package option is
used when loading glossaries). The formatting commands
\glstreenamefmt
, \glstreegroupheaderfmt
and
\glstreenavigationfmt
are all used by the corresponding
glossary-mcols styles.
Note that these styles will only be available if you explicitly load glossary-mcols:
Note that you can’t set these styles using the style package option since the styles aren’t defined until after the glossaries package has been loaded.\usepackage
{glossaries}\usepackage
{glossary-mcols}
With glossaries-extra, you can load both the package and style with the style and stylemods options. For example:
\usepackage
[style=mcolindex,stylemods=mcols]{glossaries-extra}
The default number of columns is 2, but can be changed by redefining:
For example, for a three column glossary:\usepackage
{glossary-mcols}\renewcommand
*{\glsmcols
}{3}\setglossarystyle
{mcolindex}
glossary-mcols Style | Analogous Tree Style |
---|---|
mcolindex | index |
mcolindexgroup | indexgroup |
mcolindexhypergroup or mcolindexspannav | indexhypergroup |
mcoltree | tree |
mcoltreegroup | treegroup |
mcoltreehypergroup or mcoltreespannav | treehypergroup |
mcoltreenoname | treenoname |
mcoltreenonamegroup | treenonamegroup |
mcoltreenonamehypergroup or mcoltreenonamespannav | treenonamehypergroup |
mcolalttree | alttree |
mcolalttreegroup | alttreegroup |
mcolalttreehypergroup or mcolalttreespannav | alttreehypergroup |
The styles with a navigation line, such as mcoltreehypergroup, now have a variant (as from v4.22) with “hypergroup” replaced with “spannav” in the style name. The original “hypergroup” styles place the navigation line at the start of the first column. The newer “spannav” styles put the navigation line in the optional argument of the multicols environment so that it spans across all the columns.
13.1.9. In-Line Style[link]
\usepackage
{glossary-inline}
\usepackage
[stylemods=inline]{glossaries-extra}
This section covers the glossary-inline package that supplies the inline style. This is a glossary style that is designed for in-line use (as opposed to block styles, such as lists or tables). This style doesn’t display the number list.
Note that this style will only be available if you explicitly load glossary-inline:
\usepackage
{glossaries}\usepackage
{glossary-inline}
With glossaries-extra, you can load both the package and style with the style and stylemods options. For example:
\usepackage
[style=inline,stylemods=inline]{glossaries-extra}
You will most likely need to redefine \glossarysection
with
this style. For example, suppose you are required to have your
glossaries and list of acronyms in a footnote, you can do:
Then where you need to include your glossaries as a footnote you can do:\usepackage
{glossary-inline}\renewcommand
*{\glossarysection
}[2][]{\textbf
{#1}: }\setglossarystyle
{inline}
\footnote
{\printglossaries
}
This is the only style provided by glossary-inline.
The group skip command \glsgroupskip
is defined to do nothing,
regardless of the nogroupskip option. Likewise,
\glsgroupheading
is defined to do nothing. If you want to
create a custom style base on the inline style that shows
a heading, then add \glsinlinedopostchild
to the definition of
\glsgroupheading
in case a group heading follows a child
entry.
\glsinlinedopostchild
. It’s provided as a user
command to make it easier to add it to the start of a custom definition
of \glossaryheader
to enable group headings.
If you need to adjust the content between a sub-entry and the next
entry, redefine \glsinlinepostchild
instead.
The inline style is governed by the following commands.
This is used between top level (level 0) entries.
This is used between sub-entries.
This is used between a top level (level 0) parent entry and its first sub-entry.
This is used at the end of the glossary. The default definition is:
This is the only place that the post-description hook is used in this style.\glspostdescription
\space
This is used to create the target, where is provided in the form
\glossentryname
{ }
and
is the entry’s label.
The default definition is:
\glstarget
{ }{ }
For example, if you want the name to appear in small caps:
\renewcommand
*{\glsinlinenameformat
}[2]{\glstarget
{#1}{\textsc
{#2}}}
This style needs to know if an entry has any children. This test is performed with:
The default definition simply uses\ifglshaschildren
, which is
inefficient as it has to iterate through all entries (in the
same glossary as ) to determine
which ones have the given entry as a parent. This can be
time-consuming for large glossaries, but the assumption here is
that an inline glossary is unlikely to be used with a large
set of entries. However, if you are using bib2gls with the
save-child-count resource option, it’s more efficient
to use \GlsXtrIfHasNonZeroChildCount
instead (particularly if
you are using \printunsrtglossary
with a filtered subset). For example:
\renewcommand
{\glsinlineifhaschildren
}[3]{%\GlsXtrIfHasNonZeroChildCount
{ }{#2}{#3}% }
Sub-entry names are formatted according to:
which has the same syntax as\glsinlinenameformat
but a
different definition:
\glstarget
{ }{}
which means that the sub-entry name is ignored.
If the description is empty or has been suppressed (according to
\ifglshasdesc
and \ifglsdescsuppressed
, respectively) then:
\space
so the symbol and
location list are ignored.
For example, if you want a colon between the name and the description:
\renewcommand
*{\glsinlinedescformat
}[3]{: #1}
The sub-entry description is formatted according to:
This defaults to just .This hook is used at the start of a top level (level 0) entry that immediate follows a sub-entry. It does nothing by default.
13.2. Defining your own glossary style[link]
The markup used in the glossary is described in §8.2. Commands that may be used by styles, but should not be redefined by styles, are described in §§13.2.1 & 13.2.2. The commands that should be redefined by the glossary style are described in §13.2.3.
\printglossary
are designed to produce content in
the PDF. If your intention is to design a style that doesn’t print
any content (for example, to simply capture information) then you
are likely to experience unwanted side-effects. If you just want to
capture indexing information (such as locations) then a much better
approach is to use bib2gls, which automatically stores this
information in dedicated fields when the entry is defined.
If you still really want to use a style to capture information
obtained from makeindex or xindy then simply \input
the indexing file instead of using \printglossary
.
If the predefined glossary styles don’t fit your requirements, you can define your own style using:
where is the name of the new glossary style (to be used in the style option or\setglossarystyle
).
An existing style can be redefined with:
In both cases, the second argument
needs to redefine all of the commands listed in §13.2.3.
A style may inherit from an existing style by starting
\setglossarystyle
and then just
redefine the commands that are different from the inherited style.
For example, the indexgroup style is basically the same as
the index style, except for the definition of
\glsgroupheading
, so the style is simply defined as:
\newglossarystyle
{indexgroup}{%\setglossarystyle
{index}% inherit index % alter the command that's different:\renewcommand
*{\glsgroupheading
}[1]{%\item
\glstreegroupheaderfmt
{\glsgetgrouptitle
{##
1}}%\indexspace
}% }
13.2.1. Commands For Use in Glossary Styles[link]
These commands are typically used in style definitions but should not be modified by the style. See §13.2.2 for hyperlinks to group headings.
In order to support the entrycounter=option, a style needs to use:
at the place where the associated number should appear if the option is set. If entrycounter=true,\glsentryitem
will do:
otherwise it will do\glsstepentry
{ }\glsentrycounterlabel
\glsresetsubentrycounter
(which ensures
the sub-entry counter is reset if it has been enabled with
subentrycounter).
For example, the list style defines \glossentry
as follows:
\renewcommand
*{\glossentry
}[2]{%\item
[\glsentryitem
{##
1}%\glstarget
{##
1}{\glossentryname
{##
1}}]\glossentrydesc
{##
1}\glspostdescription
\space
##
2}
In order to support the subentrycounter=option, a style needs to use:
at the place where the associated number should appear if the option is set. If subentrycounter=true, this will do:otherwise it does nothing. This will typically only be used with level 1 and omitted for deeper hierarchical levels.\glsstepsubentry
{ }\glssubentrycounterlabel
For example, the index style has:
The test for level 0 is redundant in this case as\renewcommand
{\subglossentry
}[3]{%\ifcase
##
1 % level 0\item
\or
% level 1\subitem
\glssubentryitem
{##
2}%\else
% all other levels\subsubitem
\fi
\glstreenamefmt
{\glstarget
{##
2}{\glossentryname
{##
2}}}%\ifglshassymbol
{##
2}{\space
(\glossentrysymbol
{##
2})}{}%\glstreechildpredesc
\glossentrydesc
{##
2}\glspostdescription
\space
##
3% }
\glossentry
will be used for top level (level 0) entries, but is provided for
completeness. Note that \glssubentryitem
is only used for
level 1.
The style will typically also create the target to enable hyperlinks
from an entry reference within the document (created with commands
like \gls
) to the entry line in the glossary.
The target is created with:
If hyperlinks aren’t enabled, this simply does the second argument , otherwise it will create a target with the name , where the prefix is obtained by expanding: The glossaries-extra package has options, such as prefix, that can be used to override this.This is used in glossary styles to display the name encapsulated with
\glsnamefont
. Unlike \glsentryname
, this
command will trigger a warning if the entry
hasn’t been defined. The sentence case version is:
Both commands internally use \glsnamefont
so
there’s no need to explicitly use that command in a style.
\glossentryname
, case-changing. If you just use
\glsentryname
, the style won’t be influenced by those
attributes.
This is used in glossary styles to display the description. Unlike
\glsentrydesc
, this command will trigger a warning if
the entry hasn’t been defined. The sentence case version is:
\glossentrydesc
, case-changing. If you just use
\glsentrydesc
, the style won’t be influenced by those
attributes.
This is used in glossary styles to display the symbol. Unlike
\glsentrysymbol
, this command will trigger a warning if
the entry hasn’t been defined. The sentence case version is:
\glsentrysymbol
, the style won’t be influenced by that
attribute.
glossary styles that support groups can obtain the group title with:
This gets the title associated with the group identified by and displays it. The title is determined as follows:- •if is a single character or either
glsnumbers
orglssymbols
and the command\
exists, then that command is used as the title. groupname - •otherwise the title is the same as the group label.
\glsgetgrouptitle
to
accommodate the enhanced features.
13.2.3. Glossary Style Commands[link]
The commands listed in this section should all be redefined by every
glossary style. However, a style may be based on another
style, in which case the style definitions should start with
\setglossarystyle
and then only redefine the commands that
should differ from the inherited style.
Note that \print
glossary sets \currentglossary
to the current glossary label, so it’s possible to create a glossary
style that varies according to the glossary type, but this will
generally limit its usefulness.
The actual content of the glossary is placed inside the theglossary environment. For example, the list style redefines this to start and end the description environment:
Immediately after\renewenvironment
{theglossary}% {\glslistinit
\begin{description}
}{\end{description}
}
\begin{theglossary}
comes the header:
For example, the longheader style has:
(Note that this is not the same as the preamble which occurs before the start of the theglossary environment and is not part of the style.)\renewcommand
*{\glossaryheader
}{%\bfseries
\entryname
&
\bfseries
\descriptionname
\tabularnewline
\endhead
}
The rest of the contents of the theglossary environment is divided into letter group blocks. Each block starts with the group heading:
Note that the argument is a label that identifies the group. Some glossary styles redefine this command to do nothing, which means there’s no group title displayed. Others, such as glossary styles, will obtain the group title from the and format the title to fit the style.
With Options 1, 2 and 3, groups only related to top level (level 0) entries.
\glssubgroupheading
to support sub-groups, which are
only available with Options 4 and 5. Glossary styles
should only include a redefinition of \glssubgroupheading
if
the style is specifically designed for use with
glossaries-extra as the command won’t be available with just
the base glossaries package. (A default definition will be
provided if this command isn’t set with glossaries-extra.)
After the group heading, each top level (level 0) entry line within the group is formatted with:
The first argument is the entry’s label. The second is the number list that was collated by the indexing application.
The \relax
, or may contain the
number list encapsulated with \glossaryentrynumbers
,
possibly prefixed with a pre-number list hook. If
is an unbraced \relax
, that typically indicates that
Options 2 or 3 were used and the entry was a parent that wasn’t
indexed but has been included because it has an indexed child entry.
An empty argument is more likely to be a result
of Options 1, 4 or 5, in which case nothing can be
inferred about whether or not the entry was actually indexed.
Each sub-entry line is formatted with:
where is the hierarchical level. The other arguments are the same as for\glossentry
. Some
glossary styles redefine this command to simply use
\glossentry
, in which case the glossary will have a flat
(no-hierarchy) appearance, but the indexing application will still take the
hierarchy into account when ordering the entries.
\glossentry
and
\subglossentry
to fit the style, but they should not
redefine the markup in . If the style doesn’t
support number lists, then the argument
should simply be ignored.
The glossary styles will typically redefine \glossentry
to use \glsentryitem
to support the entrycounter option,
\glstarget
to create the hyperlink target,
and will use \glossentryname
to format the name.
Similarly, \subglossentry
will typically start with
\glssubentryitem
to support the subentrycounter option.
Again \glstarget
is needed to create the hyperlink
target. The entry name may be displayed with \glossentryname
or
may be omitted to support homographs.
Between each letter group block (that is, before all instances
of \glsgroupheading
except for the first one) is the group skip:
\ifglsnogroupskip
conditional within this command to determine whether or
not to add the gap.
For example, the list style defines \glsgroupskip
as
follows:
This has the conditional inside the definition of\renewcommand
*{\glsgroupskip
}{\ifglsnogroupskip
\else
\indexspace
\fi
}
\glsgroupskip
which allows it to be changed after the style has been set. This
causes a problem for tabular-like styles, so those need to have the
conditional outside of the definition. For example, the
long-booktabs style has:
This requires the conditional to be set before the style definitions are performed.\ifglsnogroupskip
\renewcommand
*{\glsgroupskip
}{}%\else
\renewcommand
*{\glsgroupskip
}{\glspenaltygroupskip
}%\fi
If you want a completely new style, you will need to redefine all of the commands and the environment listed above in this section.
For example, suppose you want each entry to start with a bullet point.
This means that the glossary should be placed in the itemize
environment, so theglossary should start and end that
environment. Let’s also suppose that you don’t want anything between
the glossary groups (so \glsgroupheading
and \glsgroupskip
should do nothing) and suppose you don’t want anything to appear
immediately after
(so \begin{theglossary}
\glossaryheader
should do nothing). In addition, let’s suppose the symbol should
appear in brackets after the name, followed by the description and
last of all the number list should appear within square brackets
at the end. Then you can create this new glossary style, called, say,
mylist, as follows:
Note that this style creates a flat glossary, where sub-entries are displayed in exactly the same way as the top level entries. It also hasn’t used\newglossarystyle
{mylist}{% % put the glossary in the itemize environment:\renewenvironment
{theglossary}% {\begin{itemize}
}{\end{itemize}
}% % no header after\begin{theglossary}
\renewcommand
*{\glossaryheader
}{}% % no visual distinction between glossary groups:\renewcommand
*{\glsgroupheading
}[1]{}%\renewcommand
*{\glsgroupskip
}{}% % set how each entry should appear:\renewcommand
*{\glossentry
}[2]{%\item
% bullet point\glstarget
{##
1}{\glossentryname
{##
1}}% the entry name\space
(\glossentrysymbol
{##
1})% the symbol in brackets\space
\glossentrydesc
{##
1}% the description\space
[##
2]% the number list in square brackets }% % set how sub-entries appear:\renewcommand
*{\subglossentry
}[3]{%\glossentry
{##
2}{##
3}}% }
\glsentryitem
or \glssubentryitem
so
it won’t be affected by the entrycounter,
counterwithin or subentrycounter package options.
Variations:
- •You might want the entry name to start with a capital, in
which case use
\Glossentryname
instead of\glossentryname
. - •You might want to check if the symbol hasn’t been set and omit
the parentheses if the symbol is absent. In this case you can use
\ifglshassymbol
(see §15):\renewcommand
*{\glossentry
}[2]{%\item
% bullet point\glstarget
{##
1}{\glossentryname
{##
1}}% the entry name\ifglshassymbol
{##
1}% check if symbol exists {%\space
(\glossentrysymbol
{##
1})% the symbol in brackets }% {}% no symbol so do nothing\space
\glossentrydesc
{##
1}% the description\space
[##
2]% the number list in square brackets }%
If you want to define a new style that is a slightly modified
version of an existing style, you can use \setglossarystyle
within the second argument of \newglossarystyle
followed by
whatever alterations you require. For example, suppose you want
a style like the list style but you don’t want the extra
vertical space created by \indexspace
between groups, then you
can create a new glossary style called, say, mylist as
follows:
(In this case, you can actually achieve the same effect using the list style in combination with the package option nogroupskip.)\newglossarystyle
{mylist}{%\setglossarystyle
{list}% base this style on the list style % make nothing happen between groups:\renewcommand
{\glsgroupskip
}{}% }
Suppose each entry not only has an associated symbol, but also units (stored in user1) and dimension (stored in user2). Then you can define a glossary style that displays each entry in a longtable as follows:
\newglossarystyle
{long6col}{% % put the glossary in a longtable environment:\renewenvironment
{theglossary}% {\begin{longtable}
{lp{\glsdescwidth
}cccp{\glspagelistwidth
}}}% {\end{longtable}
}% % Set the table's header:\renewcommand
*{\glossaryheader
}{%\bfseries
Term&
\bfseries
Description&
\bfseries
Symbol&
\bfseries
Units&
\bfseries
Dimensions&
\bfseries
Page List\\
\endhead
}% % No heading between groups:\renewcommand
*{\glsgroupheading
}[1]{}% % top level (level 0) entries displayed in a row optionally numbered:\renewcommand
*{\glossentry
}[2]{%\glsentryitem
{##
1}% Entry number if required\glstarget
{##
1}{\glossentryname
{##
1}}% Name&
\glossentrydesc
{##
1}% Description&
\glossentrysymbol
{##
1}% Symbol&
\glsentryuseri
{##
1}% Units&
\glsentryuserii
{##
1}% Dimensions&
##
2% Page list\tabularnewline
% end of row }% % Similarly for sub-entries (no sub-entry numbers)\renewcommand
*{\subglossentry
}[3]{% % ignoring first argument (sub-level)\glstarget
{##
2}{\glossentryname
{##
2}}% Name&
\glossentrydesc
{##
2}% Description&
\glossentrysymbol
{##
2}% Symbol&
\glsentryuseri
{##
2}% Units&
\glsentryuserii
{##
2}% Dimensions&
##
3% Page list\tabularnewline
% end of row }% % Nothing between groups:\renewcommand
*{\glsgroupskip
}{}% }
14. Xindy (Option 3)[link]
If you want to use xindy to sort the glossary, you must use the package option xindy:
\usepackage
[xindy]{glossaries}
This ensures that the information is written
to the indexing files using xindy’s raw syntax.
§1.6 covers how to use the external indexing application, and §12.3 covers the issues involved in the location syntax. This section covers the commands provided by the glossaries package that allow you to adjust the xindy style file (xdy) and parameters.
To assist writing information to the xindy style file, the glossaries package provides the following commands:
which expands to (a literal open brace) and which expands to (a literal closing brace). This is needed because\{
and \}
don’t expand
to a simple brace character when written to a file.
Expands to (a literal percent).
Expands to
~
(a literal tilde).
For example, a newline character is specified in a xindy style
file using ~n
so you can use
to write this correctly (or you can do \glstildechar
n
).
\string
~
(literal)n
Expands to
\
(a literal tilde).
In addition, if you are using a package that makes
"
(double-quote) active you can use:
"
"
,
where "
is a literal character.
Alternatively, you can use \string
"
to write
the double-quote character.
This document assumes that the double quote character has not been
made active, so the examples just use "
for clarity.
If you want greater control over the xindy style file than is
available through the LaTeX commands provided by the
glossaries package, you will need to edit the xindy
style file. In which case, you must use \noist
to prevent the
style file from being overwritten by \makeglossaries
package. For additional information about xindy, read the
xindy documentation. I’m sorry I can’t provide any assistance
with writing xindy style files. If you need help, I recommend
you ask on the xindy
mailing list.
14.1. Required Styles[link]
The xdy file created by \makeglossaries
starts with
identifying the required styles.
By default, the tex style is automatically added, so the xdy
file should contain:
; required styles (require "tex.xdy")Any additional styles can be identified in the preamble (before
\makeglossaries
) with:
The styles are all stored as a comma-separated list, so you can list
multiple styles within the argument, but avoid spurious spaces.
You can reset the style list (for example, if a style needs to be identified before
tex.xdy) with:
The argument should be a comma-separated list where, again, you need to make
sure there are no spurious spaces.
14.2. Language and Encodings[link]
When you use xindy, you need to specify the language and encoding used (unless you have written your own custom xindy style file that defines the relevant alphabet and sort rules). If you use makeglossaries, this information is obtained from the document’s auxiliary (aux) file. The makeglossaries script attempts to find the xindy language name given your document settings, which may not match the babel or polyglossia name, using set of known mappings.
The default is to use \languagename
. The information is written to the
aux file at the start of \printglossary
, which means that
it should match the language in the document at that point.
In the event that makeglossaries gets the language name wrong or if xindy doesn’t support that language, then you can specify the required language using:
where is the name of the language. The optional argument can be used if you have multiple glossaries in different languages. If is omitted,\glsdefaulttype
is assumed. If a language hasn’t been set for a
particular glossary then the language will be as for the
default glossary.
The default codepage will be obtained from the value of
\inputencodingname
. If that command isn’t defined or is empty,
utf8
is assumed. As with \languagename
, the input
encoding name obtained with \inputencodingname
may not match
the xindy codepage name, which may include additional
information, such as ij-as-ij
(with Dutch) or
din5007
(with German).
Again, makeglossaries will try to adjust the codepage for known cases, but it may get it wrong. Neither makeglossaries-lite nor the automake option will make those adjustments.
If the default is incorrect, you can specify the correct codepage using:
where is the name of the codepage. Note there’s only one codepage for all glossaries as it’s rare to switch encoding mid-document. For example:This can also be implemented as a package option:\GlsSetXdyLanguage
{dutch}\GlsSetXdyCodePage
{ij-as-y-utf8}
\usepackage
[xindy=language=dutch,codepage=ij-as-y-utf8]{glossaries}
In the event that you want one glossary sorted with
ij-as-y
and another with ij-as-ij
you will need to
call xindy explicitly for each glossary.
If you write your own custom xindy style file that includes the language settings, you need to set the language to nothing:
\GlsSetXdyLanguage
{}
(and remember to use \noist
to prevent the style file from
being overwritten).
14.3. Locations and Number lists[link]
If you use xindy, the glossaries package needs to
know which counters you will be using in the number list
in order to correctly format the xindy style
file. Counters specified using the counter package option
or the option of \newglossary
are
automatically taken care of, but if you plan to use a different
counter in the counter key for the \gls
-like or
\glstext
-like commands,
then you need to identify these counters before
\makeglossaries
using:
Xindy attributes normally correspond to the encap when
using the standard \index
command where the locations are all
page numbers, but the glossaries package needs to
incorporate the location counter as well. For example, if the
hyperbf encap is used with the section counter,
then the xindy attribute will be sectionhyperbf
.
This is in contrast to using makeindex, where the counter is
incorporated in the encap with \setentrycounter
.
The most likely xindy attributes (such as pagehyperbf
) are
automatically added to the xdy style file, but if you want to
use another encap, you need to add it with:
Note that \GlsAddXdyAttribute
will define commands in the form:
\GlsAddXdyAttribute
).
This command is provided for each counter that has been identified either by the
counter package option, the option for
\newglossary
or in the argument of \GlsAddXdyCounters
.
Each command has a definition in the form:
This ensures that, if required, location hyperlinks can be supported.\setentrycounter
[ ]{ }\
{ }
\glsX
X commands may need redefining for
unusual locations where the default definition won’t work with hyperlinks
(see Example 41).
Take care if you have multiple instances of the same location with different formats. The duplicate locations will be discarded according to the order in which the attributes are listed. Consider defining semantic commands to use for primary references. For example:
Then in the document:\newcommand
*{\primary
}[1]{\hyperbf
{1}}\GlsAddXdyAttribute
{primary}
AThis will give the format=primary instance preference over the next use that doesn’t use the format key.\gls
[format=primary]{duck} is an aquatic bird. There are lots of different types of\gls
{duck}.
but with xindy, I also need to add this as an allowed attribute:\newcommand
*{\hyperbfit
}[1]{\textit
{\hyperbf
{1}}}
\GlsAddXdyAttribute
{hyperbfit}
Now I can use it in the optional argument of commands like
\gls
:
Here is a \gls
[formathyperbfit]{sample} entry.
(where “sample” is the label of the required entry).
\GlsAddXdyAttribute
has no effect if \noist
is
used or if \makeglossaries
is omitted.
\GlsAddXdyAttribute
must be used before \makeglossaries
.
Additionally, \GlsAddXdyCounters
must come before
\GlsAddXdyAttribute
.
If the locations include robust or protected formatting commands, then you need to add a location style using the appropriate xindy syntax using:
where is the name of the location style and is the xindy definition. The optional argument is needed if\theH
either isn’t defined or is
different from \the
.
Be sure to also read §12.3 for some issues
that you may encounter.
\GlsAddXdyLocation
has no effect if \noist
is
used or if \makeglossaries
is omitted.
\GlsAddXdyLocation
must be used before \makeglossaries
.
\thesection
as follows:
If I haven’t used the package option counter=section, then I need to specify that the section counter will be used as a location counter:\renewcommand
*{\thesection
}{[\thechapter
]\arabic
{section}}
\GlsAddXdyCounters
{section}
Next I need to add the location syntax:
\GlsAddXdyLocation
{section}{:sep "[" "arabic-numbers" :sep "]"
"arabic-numbers"
}
This assumes that \thechapter
is defined as
\arabic
{chapter}
.
Note that if I have further decided to use the hyperref
package and want to redefine \theHsection
as:
then I need to modify the\renewcommand
*{\theHsection
}{\thepart
.\thesection
}\renewcommand
*{\thepart
}{\Roman
{part}}
\GlsAddXdyLocation
code above to:
\GlsAddXdyLocation
["roman-numbers-uppercase"]{section}{:sep "["
"arabic-numbers" :sep "]" "arabic-numbers"
}
Since \Roman
will result in an empty string if the counter is
zero, it’s a good idea to add an extra location to catch this:
\GlsAddXdyLocation
{zero.section}{:sep "["
"arabic-numbers" :sep "]" "arabic-numbers"
}
This example is illustrated in the sample file
samplexdy2.tex.
\usepackage
[xindy,esclocations]{glossaries}\glswrallowprimitivemodstrue
Suppose I want a rather eccentric page numbering system that’s
represented by the number of dots on dice. The stix package
provides \dicei
, …,
\dicevi
that represent the six
sides of a die. I can define a command that takes a number as its
argument. If the number is less than seven, the appropriate
\dice
command is used otherwise it does \dicevi
the
required number of times with the leftover in a final
\dice
. For example, the number 16 is represented by
(6+6+4=16). I’ve called this command
\dicevi
\dicevi
\diceiv
\tallynum
to match the example given earlier in
§12.3:
Here’s the counter command:\newrobustcmd
{\tallynum
}[1]{%\ifnum
\number
1<7 $\csname
dice\romannumeral
1\endcsname
$%\else
$\dicevi
$%\expandafter
\tallynum
\expandafter
{\numexpr
1-6}%\fi
}
The page counter representation (\newcommand
{\tally
}[1]{\tallynum
{\arabic
{1}}}
\thepage
) needs to be
changed to use this command:
The\renewcommand
*{\thepage
}{\tally
{page}}
\tally
command expands to \tallynum {number}
so
this needs a location class that exactly matches this format:
The space between\GlsAddXdyLocation
{tally}{% :sep "\string
\tallynum
\space
\glsopenbrace
" "arabic-numbers" :sep "\glsclosebrace
" }
\tallynum
and {number} is
significant to xindy so \space
is required.
The sample file samplexdy.tex, which comes with the glossaries
package, uses the default page counter for locations, and it
uses the default \glsnumberformat
and a custom \hyperbfit
format. A new xindy location called “tallynum”, as
illustrated above, is defined to make the page numbers appear as
dice. In order for the location numbers to
hyperlink to the relevant pages, I need to redefine the necessary
\glsX
X commands:
Note that the second argument of\renewcommand
{\glsXpageXglsnumberformat
}[2]{%\linkpagenumber
2% }\renewcommand
{\glsXpageXhyperbfit
}[2]{%\textbf
{\em
\linkpagenumber
2}% }\newcommand
{\linkpagenumber
}[2]{\hyperlink
{page.2}{1{2}}}
\glsXpageXglsnumberformat
is
in the form \tallynum{ }
so the line
\linkpagenumber
2%
does
so\linkpagenumber
\tallynum
{ }
\tallynum
is the first argument of \linkpagenumber
and is the second argument.
\usepackage
[xindy,esclocations]{glossaries}\glswrallowprimitivemodstrue
Suppose I want the page numbers written as words
rather than digits and I use the fmtcount package to
do this. I can redefine \thepage
as follows:
This used to get expanded to\renewcommand
*{\thepage
}{\Numberstring
{page}}
where is the Arabic page number. This means that I needed to define a new location with the form:\protect
\Numberstringnum
{ }
and if I’d used the\GlsAddXdyLocation
{Numberstring}{:sep "\string
\protect
\space
\string
\Numberstringnum
\space
\glsopenbrace
" "arabic-numbers" :sep "\glsclosebrace
"}
\linkpagenumber
command from the previous
example, it would need three arguments (the first being
\protect
):
\newcommand
{\linkpagenumber
}[3]{\hyperlink
{page.3}{12{3}}}
The internal definition of \Numberstring
has since changed
so that it now expands to
\Numberstringnum
{ }
(no \protect
). This means that the location class definition
must be changed to:
and\GlsAddXdyLocation
{Numberstring}{% no\protect
now! :sep "\string
\Numberstringnum
\space
\glsopenbrace
" "arabic-numbers" :sep "\glsclosebrace
"}
\linkpagenumber
goes back to only two arguments:
The other change is that\newcommand
{\linkpagenumber
}[2]{\hyperlink
{page.2}{1{2}}}
\Numberstring
uses
instead of\the
\value
{ }
so it hides\expandafter
\the
\csname
c@\endcsname
\c@page
from the location escaping mechanism
(see §12.3). This means that the page
number may be incorrect if the indexing occurs during the output
routine.
A more recent change to fmtcount (v3.03) now puts three
instances of \expandafter
before \the\value
which
no longer hides \c@page
from the location escaping mechanism, so
the page numbers should once more be correct. Further changes
to the fmtcount package may cause a problem again.
Instead of directly using \Numberstring
in the definition of
\thepage
, I can provide a custom command in the same form
as the earlier \tally
command:
This ensures that the location will always be written to the indexing file in the form:\newcommand
{\customfmt
}[1]{\customfmtnum
{\arabic
{1}}}\newrobustcmd
{\customfmtnum
}[1]{\Numberstringnum
{1}}
:locref "So the location class can be defined as:\glsopenbrace
\glsclosebrace
\glsopenbrace
\string
\\
customfmtnum { }\glsclosebrace
"
\GlsAddXdyLocation
{customfmt}{ :sep "\string
\customfmtnum
\space
\glsopenbrace
" "arabic-numbers" :sep "\glsclosebrace
"}
The sample file samplexdy3.tex illustrates this.
In the number list, the locations are sorted according to the list of provided location classes. The default ordering is:
- 1.
roman-page-numbers
(i, ii, …); - 2.
arabic-page-numbers
(1, 2, …); - 3.
arabic-section-numbers
(for example, 1.1 if the compositor is a full stop or 1-1 if the compositor is a hyphen); - 4.
alpha-page-numbers
(a, b, …); - 5.
Roman-page-numbers
(I, II, …); - 6.
Alpha-page-numbers
(A, B, …); - 7.
Appendix-page-numbers
(for example, A.1 if the Alpha compositor, see\glsSetAlphaCompositor
, is a full stop or A-1 if the Alpha compositor is a hyphen); - 8.user defined location names (as specified by
\GlsAddXdyLocation
in the order in which they were defined); - 9.
see
(cross-referenced entries).
This ordering can be changed using:
where each location name is delimited by double quote marks and separated by white space. For example:\GlsSetXdyLocationClassOrder
{
"arabic-page-numbers"
"arabic-section-numbers"
"roman-page-numbers"
"Roman-page-numbers"
"alpha-page-numbers"
"Alpha-page-numbers"
"Appendix-page-numbers"
"see"
}
(Remember to add "seealso"
if you’re using glossaries-extra.)
\GlsSetXdyLocationClassOrder
has no effect if
\noist
is used or if \makeglossaries
is omitted.
\GlsSetXdyLocationClassOrder
must be used before
\makeglossaries
.
If a number list consists of a sequence of consecutive numbers, the range will be concatenated. The number of consecutive locations that causes a range formation defaults to 2, but can be changed using:
The may be the keyword none, to indicate no range formation, or a number. For example:\GlsSetXdyMinRangeLength
{3}
See the xindy manual for further details on range formations.
\GlsSetXdyMinRangeLength
has no effect if \noist
is used or if \makeglossaries
is omitted.
\GlsSetXdyMinRangeLength
must be used before
\makeglossaries
.
14.4. Glossary Groups[link]
The glossary is divided into groups according to the first letter of the sort key. The glossaries package also adds a number group by default, unless you suppress it in the xindy package option. For example:
\usepackage
[xindy=glsnumbers=false]{glossaries}
Any entry that doesn’t go in one of the letter groups or the
number group is placed in the default group. If you want xindy
to sort the number group numerically (rather than by a string sort)
then you need to use xindy’s numeric-sort module:
\GlsAddXdyStyle
{numeric-sort}
With the default glsnumbers=true, the number group will be placed
before the “A” letter group. This is done in the define-letter-group
block in the xdy file:
(define-letter-group "glsnumbers" :prefixes ("0" "1" "2" "3" "4" "5" "6" "7" "8" "9") :before "A")
If you are not using a Roman alphabet, you need to change this with:
{letter} where is the first letter of your alphabet. This will change:before "A"
to :before "
.
"A starred version of this command was added to v4.33 which sanitized xdy file to protect it from expansion with inputenc. This shouldn’t be necessary with recent LaTeX kernels.
before writing it to theAlternatively you can use:
This will change:before "A"
to .
Again, a starred version was provided to sanitize the argument, which
should no longer be necessary unless "
(double-quote) is active.
For example:
\GlsSetXdyNumberGroupOrder
{:after "Z"}
will put the number group after the “Z” letter group.
\noist
is used or if \makeglossaries
is omitted.
\GlsSetXdyFirstLetterAfterDigits
must be used before
\makeglossaries
.
15. Utilities[link]
This section describes the utility commands provided with the base glossaries package.
\glsxtrusefield
and \glsxtrfieldformatlist
.
See the glossaries-extra manual for further details.
15.1. hyperref[link]
The hyperref package needs to be loaded before glossaries to ensure that the commands provided by hyperref are only used if they have been defined.
This disables the creation of hyperlinks and targets by commands such as
\glshyperlink
, the \gls
-like and
\glstext
-like commands and \glstarget
. This setting is the
default if hyperref hasn’t been loaded.
The commands that normally create a hyperlink will use:
The internal command used by \glstarget
to create a target is just set to
\@secondoftwo
.
This enables the creation of hyperlinks and targets, and is the default if hyperref has been loaded.
The internal command used by \glstarget
to create a target is
set to:
The corresponding command that’s used to link to this target is:
This includes the debugging information, if applicable, and creates a link with\hyperlink
.
Both the above target and link commands have a corresponding hook that does nothing by default. These commands are not used if hyperlinks have been disabled (or if hyperref has not been loaded).
This hook occurs after the height of the has been measured and before the target is inserted.This hook occurs immediately before the link is created with
\hyperlink
.
This command is provided for use in
\glsdohypertargethook
and will simulate
a label corresponding to the target. It’s primarily intended for use with
\pageref
rather than \ref
as there is no corresponding counter
to provide a numeric value. It is an alternative to using the entrycounter
option. The label is given by
, where the
is obtained by expanding:
The target will be the title corresponding to the label (which
can be referenced with \nameref
). Since there is no numeric value,
the text obtained with \ref
will either be empty or the name of the most recent
entry in the glossary list where the hypertarget occurs.
For example:
Certain commands that may occur in the argument, such as\renewcommand
{\glsdohypertargethook
}[2]{\glslabelhypertarget
{#1}{#2}}
\glossentryname
, are locally redefined during the protected write
to the aux file. These redefinitions are performed by:
You can append any additional redefinitions of problematic commands to this
hook.
The “value” part of the label (that is, the text produced with \ref
) is
obtained by expanding:
if\glsentryname
\glscurrententrylabel
\glscurrententrylabel
is defined and not empty. Otherwise it expands to nothing.
If you’re not sure whether or not the hyperref package will be loaded, this command will use
\texorpdfstring
if
that command has been defined, otherwise it will simply expand to
.
15.2. Case-Changing[link]
These commands may be used to perform a case change.
An expandable command that converts uppercase (all caps).
This is used by commands such as \GLS
and \GLStext
and is affected by
\glsmfuexcl
.
An expandable command that converts lowercase.
This isn’t used by the glossaries package, but you may find it
useful with acronym or abbreviation font commands for
small caps styles. This command is affected by
\glsmfuexcl
.
This command is used by sentence case commands, such as
\Glsentrytext
, when expanding in a PDF bookmark.
This command is actually defined by mfirstuc v2.08+, but if an
old version of mfirstuc is installed, the glossaries
package will provide the same command. This command is affected by
\glsmfuexcl
.
Converts sentence case. This is used by
commands such as \Gls
and \Glstext
, and also by commands
like \Glsentrytext
in the document text.
The default definition is to use the robust \makefirstuc
provided by the mfirstuc package. If you need an expandable
command, use \MFUsentencecase
instead.
Note that \makefirstuc
internally uses \glsmakefirstuc
,
which is provided by mfirstuc. The default definition is:
The mfirstuc=expanded package option will redefine this command without\newcommand
*{\glsmakefirstuc
}[1]{\MFUsentencecase
{\unexpanded
{1}}}
\unexpanded
.
The reason for the use of \unexpanded
is mostly a
backward-compatibility feature, as without it there is now the
possibility for fragile commands to expand prematurely and cause an
error.
This is because the LaTeX3 kernel command used by
\MFUsentencecase
expands its argument before applying the
case change. With previous versions of mfirstuc,
\glsmakefirstuc
would simply apply the case change to the
first token.
Suppose a document created with mfirstuc v2.07 had something like:
and a glossary style is used that performs automated sentence-casing for the description (for example, with the topic style, provided by glossaries-extra), then this would essentially do:\newglossaryentry
{sample}{ name={sample}, description={an example with a\fragilecommand
} }
With old versions of mfirstuc, this would simply end up as:\makefirstuc
{an example with a\fragilecommand
}
so the fragile command is unaffected.\MakeTextUppercase
an example with a\fragilecommand
However, with mfirstuc v2.08 and mfirstuc=expanded this would end up as:
and the underlying\MFUsentencecase
an example with a\fragilecommand
\text_titlecase_first:n
will expand the
entire argument, which will break the fragile command.
The use of \unexpanded
prevents this from happening, but if you
don’t have fragile commands and you want the content to be expanded,
then use mfirstuc=expanded.
Converts title case. The default definition is
to use the robust \capitalisewords
provided by mfirstuc.
You may need to redefine this command to use \capitalisefmtwords
instead.
This uses \MFUexcl
with mfirstuc v2.08+, otherwise its defined in the
same way (so it won’t affect \makefirstuc
but will affect
commands like \glsuppercase
).
This uses \MFUblocker
with mfirstuc v2.08+, otherwise it simply uses
\glsmfuexcl
.
This uses \MFUaddmap
with mfirstuc v2.08+, otherwise it
simply does
\glsmfuexcl
{ }\glsmfublocker
{ }
This uses \MFUblocker
if defined, otherwise it simply uses
\glsmfuexcl
.
15.3. Loops[link]
\@for
command, make sure your list
doesn’t have any unwanted spaces in it as they don’t get stripped.
(Discussed in more detail in
§2.7.2 of “LaTeX for Administrative
Work”.)
This iterates through , a comma-separated list of glossary labels (as supplied when the glossary was defined). At each iteration the command is defined to the glossary label for the current iteration and is performed. If is omitted, the default is to iterate over all non-ignored glossaries.
This is like
\forallglossaries
but only iterates over the
lists of acronyms (that have previously been declared using
\DeclareAcronymList
or the acronymlists package
option). This command doesn’t have an optional argument. If you want
to explicitly say which lists to iterate over, just use the optional
argument of \forallglossaries
.
This iterates through all entries in the glossary given by . At each iteration the command is defined to the entry label for the current iteration and is performed. If is omitted,
\glsdefaulttype
is used.
This is just a nested loop that essentially does:
\forallglossaries
[ ]{ }{ }
If is omitted, the default is the list of all non-ignored glossaries.
(The current glossary label can be obtained using
\glsentrytype
{ }
within .)
\glsxtrforcsvfield
to iterate over any fields that contain comma-separated lists.
15.4. Conditionals[link]
This checks if the glossary given by exists (that is, if it has been defined). If it does exist is performed, otherwise .
The unstarred form will treat ignored glossaries as
non-existent. The starred form will consider them as existing.
So both forms will do if was
defined by \newglossary
, but only the starred form will do
if was defined with
\newignoredglossary
.
For example, given:
\newignoredglossary
{common}
then
will produce “false true”.\ifglossaryexists
{common}{true}{false}\ifglossaryexists
*{common}{true}{false}
This checks if the glossary entry given by exists. If it
does exist then is performed, otherwise this does .
Simply uses etoolbox’s \ifcsundef
so can expand.
Does if the entry given by exists. If it doesn’t exist, an undefined error is generated.
Does if the entry given by doesn’t exist. If it does exist, an already defined error is generated.
As
\glsdoifexists
but issues a warning rather than an error if
the entry doesn’t exist.
Does if the entry given by exists otherwise it generates an undefined error and does .
Tests the entry’s first use flag. If the entry has been used, will be done, otherwise (if the entry has been defined) will be done. If the entry isn’t defined, then an undefined error will occur and neither nor will be done (see §7).
This means that \ifglsused
is unreliable with bib2gls as
no entries are defined on the first LaTeX run, which means there’s no
way of determining if it has been used, so
glossaries-extra provides a similar command:
\ifglsused
for defined entries.
\ifglshas
commands use
\glsdoifexists
. In those cases, the or parts are only
performed if the entry exists. Neither are done if the entry doesn’t
exist.
This does entries in the same glossary
as had parent={.
This is inefficient and time-consuming if there are a large number
of entries defined. Uses }\glsdoifexists
.
\GlsXtrIfHasNonZeroChildCount
.
This does parent field is non-empty
for the entry identified by . Uses \glsdoifexists
.
A robust command that does symbol field is non-empty
and not \relax
for the entry identified by .
A robust command that does long field is non-empty
and not \relax
for the entry identified by .
A robust command that does short field is non-empty
and not \relax
for the entry identified by .
Expands to description is empty for the entry identified by , otherwise expands to . Compare with:
if the This expands to if description={\nopostdesc
}
for the entry identified by
otherwise expands to .
There are also commands available for arbitrary fields. Some may
allow the field to be identified by its corresponding key (such as
description) but some require the internal field label
(such as desc). See Table 4.1 for the
internal field labels that correspond to each key. If you
provide your own keys, for example with \glsaddkey
, then the
internal label will be the same as the key.
Expands to if the field identified by its internal field label is void for the entry identified by , otherwise it expands to . The void test is performed with etoolbox’s
\ifcsvoid
. This means that an undefined field or an undefined
entry will be considered void. An empty field value or a field set
to \relax
are also considered void.
This robust command tests the value of the field given by internal field label.
for the entry identified by . The argument may either be the key associated with the field or the
If the field value is empty or \relax
, then is
performed, otherwise is performed. If the field supplied
is unrecognised is performed and a warning is
issued. If the entry is undefined, an undefined error occurs.
Within
, you can access the field’s value with: This command is initially defined to empty but has no relevance outside of the argument. This saves re-accessing the field if the test is true. For example:will insert a comma, space and the field value if the user1 key has been set for the entry whose label is “sample”.\ifglshasfield
{useri}{sample}{,\glscurrentfieldvalue
}{}
This robust command does if the entry identified by has the field identified by its internal field label (not the key) defined and set to the given . The test is performed by etoolbox’s
\ifcsstring
. An error will occur if the field value is
undefined or if the entry hasn’t been defined.
The result may vary depending on whether or not expansion was on for the given field when the entry was defined (see §4.4). For example:
This will produce “TRUE” in both cases since expansion is on for the user1 key, so\documentclass
{article}\usepackage
{glossaries}\newcommand
*{\foo
}{FOO}\newglossaryentry
{sample1}{name={sample1},description={an example}, user1={FOO}}\newglossaryentry
{sample2}{name={sample2},description={an example}, user1={\foo
}}\begin{document}
\ifglsfieldeq
{sample1}{useri}{FOO}{TRUE}{FALSE}.\ifglsfieldeq
{sample2}{useri}{FOO}{TRUE}{FALSE}.\end{document}
\foo
was expanded to “FOO” when “sample2” was defined.
If the tests are changed to:
then this will produce “FALSE” in both cases. Now suppose expansion is switched off for the user1 key:\ifglsfieldeq
{sample1}{useri}{\foo
}{TRUE}{FALSE}.\ifglsfieldeq
{sample2}{useri}{\foo
}{TRUE}{FALSE}.
This now produces “TRUE” for the first case (comparing “FOO” with “FOO”) and “FALSE” for the second case (comparing “\documentclass
{article}\usepackage
{glossaries}\newcommand
*{\foo
}{FOO}\glssetnoexpandfield
{useri}\newglossaryentry
{sample1}{name={sample1},description={an example}, user1={FOO}}\newglossaryentry
{sample2}{name={sample2},description={an example}, user1={\foo
}}\begin{document}
\ifglsfieldeq
{sample1}{useri}{FOO}{TRUE}{FALSE}.\ifglsfieldeq
{sample2}{useri}{FOO}{TRUE}{FALSE}.\end{document}
\foo
” with “FOO”).
The reverse happens in the following:
This now produces “FALSE” for the first case (comparing “FOO” with “\documentclass
{article}\usepackage
{glossaries}\newcommand
*{\foo
}{FOO}\glssetnoexpandfield
{useri}\newglossaryentry
{sample1}{name={sample1},description={an example}, user1={FOO}}\newglossaryentry
{sample2}{name={sample2},description={an example}, user1={\foo
}}\begin{document}
\ifglsfieldeq
{sample1}{useri}{\foo
}{TRUE}{FALSE}.\ifglsfieldeq
{sample2}{useri}{\foo
}{TRUE}{FALSE}.\end{document}
\foo
”) and “TRUE” for the second case (comparing
“\foo
” with “\foo
”).
You can test if the value of a field is equal to the replacement text of a command using:
This robust command is essentially like\ifglsfieldeq
but
internally uses etoolbox’s \ifdefstrequal
command to
perform the comparison. The argument argument must be a macro.
For example:
Here, the first case produces “TRUE” since the value of the useri field (“FOO”) is the same as the replacement text (definition) of\documentclass
{article}\usepackage
{glossaries}\newcommand
*{\foo
}{FOO}\glssetnoexpandfield
{useri}\newglossaryentry
{sample1}{name={sample1},description={an example}, user1={FOO}}\newglossaryentry
{sample2}{name={sample2},description={an example}, user1={\foo
}}\begin{document}
\ifglsfielddefeq
{sample1}{useri}{\foo
}{TRUE}{FALSE}.\ifglsfielddefeq
{sample2}{useri}{\foo
}{TRUE}{FALSE}.\end{document}
\foo
(“FOO”). We have the result
“FOO
” is equal to “FOO
”.
The second case produces “FALSE” since the value of the
useri field (“\foo
”) is not the same as the replacement
text (definition) of \foo
(“FOO”). No expansion has been
performed on the value of the useri field. We have the
result “\foo
” is not equal to “FOO
”.
If we add:
we now get “TRUE” since the value of the useri field (“\newcommand
{\FOO
}{\foo
}\ifglsfielddefeq
{sample2}{useri}{\FOO
}{TRUE}{FALSE}.
\foo
”) is the same as the replacement
text (definition) of \FOO
(“\foo
”). We have the result
“\foo
” is equal to “\foo
”.
There is a similar command that requires the control sequence name (without the leading backslash) instead of the actual control sequence:
This robust command is like ifglsfielddefeq but internally uses etoolbox’s\ifcsstrequal
command
instead of \ifdefstrequal
.
15.5. Measuring[link]
Sometimes it’s necessary to measure the width or height of some
text. For example, \glsdohypertarget
measures the height of the
supplied text to position the target at the top of the line instead
of at the baseline (where it can cause the line to scroll up out of
view). Some styles measure the width of text to assist with
alignment.
Measuring can be performed using \settowidth
, \settoheight
and \settodepth
, but if the content being measured contains any
\gls
-like or \glstext
-like commands, or if it contains
commands like \glsentryitem
, it can cause duplication. (See
also §7 for the problems this can cause with
unsetting and resetting the first use flag.)
The following measuring commands locally disable indexing, the
unset/reset commands, and \label
, and adjust
\refstepcounter
to only locally update the counter value.
Measures the height of and stores the result in the supplied register.
Measures the depth of and stores the result in the supplied register.
Measures the width of and stores the result in the supplied register.
You can test if content is inside an area that’s being measured with:
This will do if it occurs inside either of the above commands and does otherwise. This will also take amsmath’s\ifmeasuring@
into account.
If tabularx is loaded, its \TX@trial
command can be
patched with:
\gls
-like commands
inside a tabularx environment, you will need to use
\glspatchtabularx
in the preamble to disable
unset/reset while the environment measures its content.
15.6. Fetching and Updating the Value of a Field[link]
In addition to the commands described in §5.2, the commands described in this section may also be used to fetch field information.
Expands to the value of the entry’s type field, which is the label of the glossary the entry has been assigned to. No existence check is performed.
Expands to the value of the entry’s parent field, which is the label identifying the entry’s parent. No existence check is performed.
Expands to the entry’s sort value. No existence check is performed. This is not intended for general use, but can be useful to display the value for debugging purposes. Note that there is also an internal field sortvalue which contains the escaped sort value, which may not necessarily be the same as the sort value.
{label}{field}{cs}
This robust command fetches the value of the field identified by its internal field label for the entry identified by and stores it in the given command . An error will occur if the entry doesn’t exist or if the field hasn’t been defined.
This command simply assigns the supplied command internal field label for the entry
identified by . This differs from
\glsfieldfetch
in that it doesn’t test for existence. If either
the field or the entry haven’t been defined, no error or warning
will be trigger but will be undefined. You can then use
etoolbox’s \ifdef
or \ifundef
on .
For example, to store
the description for the entry whose label is “apple” in the
control sequence \tmp
:
An alternative is to use\glsletentryfield
{\tmp
}{apple}{desc}\ifdef
{\tmp
}description:\tmp
{no description}
\ifglshasfield
or, with
glossaries-extra, \glsxtrifhasfield
.
This command is provided for use in expandable contexts where the field value is required but the contents should not be expanded. The argument must be the internal field label. Does nothing if the field or entry isn’t defined.
You can change the value of a given field using one of the following commands. Note that these commands only change the value of the given field. They have no affect on any related field. For example, if you change the value of the text field, it won’t modify the value given by the name, plural, first or any other related key.
In all the four related commands below, internal field label. The argument is the new value of the field. Both the entry and field must already be defined. If you want internal fields that don’t require a corresponding key to be defined, you will need the supplementary commands provided by glossaries-extra.
identifies the entry and is theThis robust command uses
\def
to change the value of the field (so it will be
localised by any grouping).
This robust command uses
\protected@csedef
to change the value of the
field (so it will be localised by any grouping).
\glsfieldgdef
This uses \gdef
to change the value of the field (so it will
have a global effect).
This robust command uses
\protected@csxdef
to change the value of the
field (so it will be localised by any grouping).
16. Prefixes or Determiners[link]
The glossaries-prefix package that comes with the glossaries package provides additional keys that can be used as prefixes. For example, if you want to specify determiners (such as “a”, “an” or “the”). The glossaries-prefix package automatically loads the glossaries package and has the same package options.
The extra keys for \newglossaryentry
are as follows:
The prefix associated with the text key. This defaults to nothing.
The prefix associated with the plural key. This defaults to nothing.
The prefix associated with the first key. If omitted, this defaults to the value of the prefix key.
The prefix associated with the firstplural key. If omitted, this defaults to the value of the prefixplural key.
Note that I’ve simply replaced glossaries from previous sample documents with glossaries-prefix. Now for a sample definition:\documentclass
{article}\usepackage
[colorlinks]{hyperref}\usepackage
[toc,acronym]{glossaries-prefix}
(Single letter words, such as “a” and “I” should typically not appear at the end of a line, hence the non-breakable space\newglossaryentry
{sample}{namesample, description={an example}, prefix={a~
}, prefixplural={the\space
} }
~
after “a” in the prefix field.)
Note that I’ve had to explicitly insert a space after the prefix since there’s no designated separator between the prefix and the term being referenced. This not only means that you can vary between a breaking space and non-breaking space, but also allows for the possibility of prefixes that shouldn’t have a space, such as:
\newglossaryentry
{oeil}{name={oeil}, plural={yeux}, description={eye}, prefix={l'}, prefixplural={les\space
}}
\space
, \
(backslash space) or
~
due to the automatic spacing trimming performed in
= options.
In the event that you always require a space between the prefix and
the term, then you can instead redefine \glsprefixsep
to do a space. For example:
\renewcommand
{\glsprefixsep
}{\space
}
The prefixes can also be used with acronyms. For example:
\newacronym
[ prefix={an\space
},prefixfirst={a~
} ]{svm}{SVM}{support vector machine}
The glossaries-prefix package provides convenient commands to
use these prefixes with commands such as \gls
. Note that the
prefix is not considered part of the link text, so it’s not
included in the hyperlink (where hyperlinks are enabled). The
options and any star or plus modifier are passed on to the
appropriate \gls
-like command. (See §5.1 for
further details.)
The separator used between the appropriate prefix and the corresponding
\gls
-like command.
Each of the following commands \p
essentially does
if the appropriate
prefix field has been set, otherwise it simply does ,
where is the corresponding \glsprefixsep
\gls
-like command.
The all caps commands \P
will convert the
prefix to all caps (using \glsuppercase
) and use the
all caps \gls
-like counterpart.
The sentence case commands \P
are slightly
more complicated. If the appropriate prefix field has been set, then
the prefix will have the case change applied and the non-case
\gls
-like command will be used (\gls
or \glspl
).
If the appropriate prefix field hasn’t been set, then the
sentence case \gls
-like command is used (\Gls
or
\Glspl
).
The usual \gls
-like optional argument and star (*
)
and plus (+
) modifiers can be used with these commands,
in which case they will be applied to the applicable \gls
-like
command.
Does
\glsprefixsep
\gls
if
is non-empty otherwise just uses \gls
.
The prefixfirst key on first use or the prefix key on subsequent use.
will be the value of theDoes
\glsprefixsep
\glspl
if
is non-empty otherwise just uses \glspl
.
The prefixfirstplural key on first use or the prefixplural key on subsequent use.
will be the value of theDoes
\glsprefixsep
\gls
if
is non-empty otherwise just uses \Gls
.
As \pgls
, the prefix fields are prefixfirst on
first use or the prefix on subsequent use, but
the will now be obtained from the sentence case
commands \Glsentryprefix
and \Glsentryprefixfirst
.
Does
\glsprefixsep
\glspl
if
is non-empty otherwise just uses \Glspl
.
As \pglspl
, the prefix fields are prefixfirstplural on
first use or the prefixplural on subsequent use, but
the will now be obtained from the sentence case
commands \Glsentryprefixplural
and
\Glsentryprefixfirstplural
.
Does:
if is non-empty otherwise just uses\glsuppercase
{\glsprefixsep
}\GLS
\GLS
.
The prefixfirst key on first use or the prefix key on subsequent use.
will be the value of theDoes:
if is non-empty otherwise just uses\glsuppercase
{\glsprefixsep
}\GLSpl
\GLSpl
.
The prefixfirstplural key on first use or the prefixplural key on subsequent use.
will be the value of the
\pglsxtrshort
, for use in section headings.
First use:which produces:\pgls
{svm}. Next use:\pgls
{svm}. Singular:\pgls
{sample},\pgls
{oeil}. Plural:\pglspl
{sample},\pglspl
{oeil}.
This package also provides the commands described below, none of which perform any check to determine the entry’s existence.
Expands to if the prefix field is non-empty, otherwise expands to .
Expands to if the prefixplural field is non-empty, otherwise expands to .
Expands to if the prefixfirst field is non-empty, otherwise expands to .
Expands to if the prefixfirstplural field is non-empty, otherwise expands to .
Expands to the value if the prefix field.
Expands to the value if the prefixplural field.
Expands to the value if the prefixfirst field.
Expands to the value if the prefixfirstplural field.
There are also variants that convert to sentence case. As with
command like \Glsentrytext
, these will use
\MFUsentencecase
to expand in PDF bookmarks, but will use
\glssentencecase
in the document.
As
\glsentryprefix
with sentence case applied.
As
\glsentryprefixplural
with sentence case applied.
As
\glsentryprefixfirst
with sentence case applied.
As
\glsentryprefixfirstplural
with sentence case applied.
If you want to change the prefix separator (\newglossarystyle
{plist}{%\setglossarystyle
{list}%\renewcommand
*{\glossentry
}[2]{%\item
[\glsentryitem
{1}%\glsentryprefix
{1}%\glstarget
{1}{\glossentryname
{1}}]\glossentrydesc
{1}\glspostdescription
\space
2}% }
\glsprefixsep
) then
the following is better:
The conditional is also useful if you want the style to use an uppercase letter at the start of the entry item:\newglossarystyle
{plist}{% %\renewcommand
*{\glossentry
}[2]{%\item
[\glsentryitem
{1}%\ifglshasprefix
{1}{\glsentryprefix
{1}\glsprefixsep
}{}%\glstarget
{1}{\glossentryname
{1}}]\glossentrydesc
{1}\glspostdescription
\space
2}% }
\newglossarystyle
{plist}{%\setglossarystyle
{list}%\renewcommand
*{\glossentry
}[2]{%\item
[\glsentryitem
{1}%\glstarget
{1}% {%\ifglshasprefix
{1}% {\Glsentryprefix
{1}\glsprefixsep
\glossentryname
{1}}% {\Glossentryname
{1}}% }]\glossentrydesc
{1}\glspostdescription
\space
2}% }
17. Accessibility Support[link]
Limited accessibility support is provided by the accompanying glossaries-accsupp package, but note that this package is experimental. This package automatically loads the glossaries package. Any options are passed to glossaries (if it hasn’t already been loaded). For example:
\usepackage
[acronym]{glossaries-accsupp}
This will load glossaries with the acronym package
option as well as loading glossaries-accsupp.
\usepackage[abbreviations,accsupp]{glossaries-extra}This will load glossaries-extra (with the abbreviations option), glossaries and glossaries-accsupp and make appropriate patches to integrate the accessibility support with the extension commands.
17.1. Accessibility Keys[link]
The glossaries-accsupp package defines additional keys that may be used when defining glossary entries. If a key isn’t set, then there will be not accessibility support for the corresponding field.
The value of this key is the replacement text corresponding to the name key.
The value of this key is the replacement text corresponding to the text key.
The value of this key is the replacement text corresponding to the first key.
The value of this key is the replacement text corresponding to the plural key.
The value of this key is the replacement text corresponding to the firstplural key.
The value of this key is the replacement text corresponding to the symbol key.
The value of this key is the replacement text corresponding to the symbolplural key.
The value of this key is the replacement text corresponding to the description key. The corresponding internal field label is descaccess.
The value of this key is the replacement text corresponding to the descriptionplural key. The corresponding internal field label is descpluralaccess.
The value of this key is the replacement text corresponding to the long key.
The value of this key is the replacement text corresponding to the longplural key.
The value of this key is the replacement text corresponding to the short key.
If you define acronyms with \newacronym
, the
shortaccess field will automatically be set to:
The value of this key is the replacement text corresponding to the shortplural key.
The value of this key is the replacement text corresponding to the user1 key. The corresponding internal field label is useriaccess.
The value of this key is the replacement text corresponding to the user2 key. The corresponding internal field label is useriiaccess.
The value of this key is the replacement text corresponding to the user3 key. The corresponding internal field label is useriiiaccess.
The value of this key is the replacement text corresponding to the user4 key. The corresponding internal field label is userivaccess.
The value of this key is the replacement text corresponding to the user5 key. The corresponding internal field label is uservaccess.
The value of this key is the replacement text corresponding to the user6 key. The corresponding internal field label is userviaccess.
For example:
Now the link text produced by\newglossaryentry
{tex}{name={\TeX
},description={Document preparation language},access={TeX}}
\gls
{tex}
will be:
which is produced via\BeginAccSupp
{ActualText={TeX}}\TeX
\EndAccSupp
\glsaccessibility
. If you want to use
another accessibility package, see §17.5.
The sample file sampleaccsupp.tex illustrates the glossaries-accsupp package.
17.2. Incorporating Accessibility Support[link]
The \gls
-like and \glstext
-like commands have their
link text adjusted to incorporate the accessibility support, if
provided.
A helper command is used to identify the replacement text that depends
on the field name:
There are two commands pre-defined:
which is defined as:\glsaccessibility
{E}{ }{ }
and
which is simply defined to use \glsshortaccsupp
.
These helper commands all internally use:
The default definition uses commands provided by the accsupp package. If you want to experiment with another accessibility package, see §17.5. The are passed to the underlying accessibility support command.The PDF element tag. The PDF specification identifies three different types of replacement text:
argument is the appropriate- Alt
- Description of some content that’s non-textual (for example, an image). A word break is assumed after the content.
- ActualText
- A character or sequence of characters that replaces textual content (for example, a dropped capital, a ligature or a symbol). No word break is assumed after the content.
- E
- Expansion of an abbreviation to avoid ambiguity (for example, “St” could be short for “saint” or “street”).
You can define your own custom helper commands for specific fields that require them. For example:
This definition requires the replacement text to be specified with the hexadecimal character code. For example:\newcommand
{\glssymbolaccsupp
}[2]{%\glsaccessibility
[method=hex,unicode]{ActualText}{1}{2}% }
\newglossaryentry
{int}{name={int},description={integral}, symbol={\ensuremath
{\int
}},symbolaccess={222B} }
17.3. Incorporating the Access Field Values[link]
These robust commands are all in the form
\gls
{ accessdisplay }{ }
They may be used to apply the supplied accessibility
information to . If the relevant access field hasn’t
been set, these simply do .
The glossaries-extra package provides convenient wrapper commands such as:
See the glossaries-extra manual for further details.\newcommand
*{\glsaccessname
}[1]{%\glsnameaccessdisplay
{\glsentryname
{1}}1% }
Applies the accessibility information from the access field to .
Applies the accessibility information from the textaccess field to .
Applies the accessibility information from the pluralaccess field to .
Applies the accessibility information from the firstpluralaccess field to .
Applies the accessibility information from the symbolaccess field to .
Applies the accessibility information from the symbolpluralaccess field to .
Applies the accessibility information from the descaccess field (which corresponds to the descriptionaccess key) to .
Applies the accessibility information from the descpluralaccess field (which corresponds to the descriptionpluralaccess key) to .
Applies the accessibility information from the shortaccess field to .
Applies the accessibility information from the shortpluralaccess field to .
Applies the accessibility information from the longaccess field to .
Applies the accessibility information from the longpluralaccess field to .
Applies the accessibility information from the useriaccess field (which corresponds to the user1access key) to .
Applies the accessibility information from the useriiaccess field (which corresponds to the user2access key) to .
Applies the accessibility information from the useriiiaccess field (which corresponds to the user3access key) to .
Applies the accessibility information from the userivaccess field (which corresponds to the user4access key) to .
Applies the accessibility information from the uservaccess field (which corresponds to the user5access key) to .
Applies the accessibility information from the userviaccess field (which corresponds to the user6access key) to .
17.4. Obtaining the Access Field Values[link]
There are commands analogous to \glsentrytext
if you need to
obtain the value of any of the accessibility fields. Since the
accessibility information isn’t intended to be typeset but should be
written as a PDF string, use the expandable
\MFUsentencecase
or \glsuppercase
if any case change
is required.
Expands to the value of the access field.
Expands to the value of the textaccess field.
Expands to the value of the firstaccess field.
Expands to the value of the pluralaccess field.
Expands to the value of the firstpluralaccess field.
Expands to the value of the symbolaccess field.
Expands to the value of the symbolpluralaccess field.
Expands to the value of the descaccess field, which corresponds to the descriptionaccess key.
Expands to the value of the descpluralaccess field, which corresponds to the descriptionpluralaccess key.
Expands to the value of the shortaccess field.
Expands to the value of the shortpluralaccess field.
Expands to the value of the longaccess field.
Expands to the value of the longpluralaccess field.
Expands to the value of the useriaccess field, which corresponds to the user1access key.
Expands to the value of the useriiaccess field, which corresponds to the user2access key.
Expands to the value of the useriiiaccess field, which corresponds to the user3access key.
Expands to the value of the userivaccess field, which corresponds to the user4access key.
Expands to the value of the uservaccess field, which corresponds to the user5access key.
Expands to the value of the userviaccess field, which corresponds to the user6access key.
17.5. Developer’s Note[link]
Currently there’s only support for accsupp. If you want to experiment with another package that provides accessibility support, define the following command before glossaries-accsupp is loaded:
If this command has its default definition ofaccsupp
when
glossaries-accsupp loads then the accsupp package will
automatically be loaded, otherwise it won’t and you’ll need to
redefine \gls@accessibility
to use the appropriate
accessibility commands.
This command is used internally by
\glsaccessibility
. The
default definition if \gls@accsupp@engine
is defined to
accsupp
does:
Otherwise it simply does .\BeginAccSupp
{ , ={ }}\EndAccSupp
{}
18. Sample Documents[link]
In addition to the examples within this manual, the glossaries package is provided with some sample documents that illustrate the various functions. These should be located in the samples subdirectory (folder) of the glossaries documentation directory. This location varies according to your operating system and TeX distribution. You can use texdoc to locate the main glossaries documentation. For example:
texdoc -l glossariesThis should display a list of all the files in the glossaries documentation directory with their full pathnames. (The GUI version of texdoc may also provide you with the information.)
If you can’t find the sample files on your computer, they are also available from your nearest CTAN mirror at http://mirror.ctan.org/macros/latex/contrib/glossaries/samples/. Each sample file listed below has a hyperlink to the file’s location on the CTAN mirror.
The glossaries-extra package and bib2gls provide some additional sample files. There are also examples in the Dickimaw Books Gallery.
If you prefer to use UTF-8 aware engines (xelatex or lualatex) remember that you’ll need to switch from fontenc & inputenc to fontspec where appropriate.
If you get any errors or unexpected results, check that you have
up-to-date versions of all the required packages. (Search the log
file for lines starting with “Package:
”.) Where
hyperref is loaded you will get warnings about non-existent
references that look something like:
pdfTeX warning (dest): name{glo:aca} has been referenced but does not exist, replaced by a fixed oneThese warnings may be ignored on the first LaTeX run. (The destinations won’t be defined until the glossary has been created.)
18.1. Basic[link]
This document is a minimal working example. You can test your installation using this file. To create the complete document you will need to do the following steps:
- 1.Run minimalgls.tex through LaTeX either by
typing
pdflatex minimalgls
in a terminal or by using the relevant button or menu item in your text editor or front-end. This will create the required associated files but you will not see the glossary in the document. - 2.If you have Perl installed, run makeglossaries on the document
(§1.6). This can
be done on a terminal by typing:
makeglossaries minimalgls
otherwise use makeglossaries-lite:makeglossaries-lite minimalgls
If for some reason you want to call makeindex explicitly, you can do this in a terminal by typing (all on one line):makeindex -s minimalgls.ist -t minimalgls.glg -o minimalgls.gls minimalgls.glo
See §1.6.4 for further details on using makeindex explicitly.Note that if the file name contains spaces, you will need to use the double-quote character to delimit the name.
- 3.Run minimalgls.tex through LaTeX again (as step 1)
The acronym package option creates a second glossary with
the label acronym
(which can be referenced with
\acronymtype
). If you decide to enable this option then there
will be a second set of indexing files that need to be processed by
makeindex. If you use makeglossaries or
makeglossaries-lite you don’t need to worry about it, as
those scripts automatically detect which files need to be processed
and will run makeindex (or xindy) the appropriate number
of times.
If for some reason you don’t want to use makeglossaries or makeglossaries-lite and you want the acronym package option then the complete build process is:
pdflatex minimalgls makeindex -s minimalgls.ist -t minimalgls.glg -o minimalgls.gls minimalgls.glo makeindex -s minimalgls.ist -t minimalgls.alg -o minimalgls.acr minimalgls.acn pdflatex minimalgls
There are three other files that can be used as minimal working examples: mwe-gls.tex, mwe-acr.tex and mwe-acr-desc.tex.
If you want to try out the glossaries-extra extension package, you need to replace the package loading line:
\usepackage
[acronym]{glossaries}
with:
\usepackage
[acronym,postdot,stylemods]{glossaries-extra}
Note the different default package options. (You may omit the
acronym package option in both cases if you only want a
single glossary.) The glossaries-extra package internally
loads the base glossaries package so you don’t need to
explicitly load both (in fact, it’s better to let
glossaries-extra load glossaries).
Next, replace:
\setacronymstyle
{long-short}
with:
\setabbreviationstyle
[acronym]{long-short}
The optional argument acronym identifies the category that
this style should be applied to. The \newacronym
command
provided by the base glossaries package is redefined by
glossaries-extra to use \newabbreviation
with the category
set to acronym.
If you prefer to replace \newacronym
with \newabbreviation
then the default category is abbreviation so the style should
instead be:
\setabbreviationstyle
[abbreviation]{long-short}
This is actually the default category if the optional argument is
omitted, so you can simply do:
\setabbreviationstyle
{long-short}
The long-short style is the default for the
abbreviation category so you can omit this line completely if
you replace \newacronym
. (The default style for the
acronym category is short-nolong, which only shows
the short form on first use.)
As mentioned earlier, the acronym package option creates a
new glossary with the label acronym
. This is independent of
the acronym category. You can use the acronym
package option with either \newacronym
or \newabbreviation
.
You may instead prefer to use the abbreviations package
option, which creates a new glossary with the label abbreviations
:
\usepackage
[abbreviations,postdot,stylemods]{glossaries-extra}
This can again be used with either \newacronym
or
\newabbreviation
, but the file extensions are different. This
isn’t a problem if you are using makeglossaries or
makeglossaries-lite. If you are explicitly calling
makeindex (or xindy) then you need to modify the file
extensions.
See the glossaries-extra user manual for further details.
If you use both the acronym and abbreviations
package options then \newacronym
will default to the
acronym
glossary and \newabbreviation
will default to
the abbreviations
glossary.
If you want to try bib2gls, you first need to convert the document to use glossaries-extra as described above. Then add the record package option. For example:
\usepackage
[record,postdot,stylemods]{glossaries-extra}
Next you need to convert the entry definitions into the
bib format required by bib2gls. This can easily be
done with convertgls2bib. For example:
convertgls2bib --preamble-only minimalgls.tex entries.bibThis will create a file called entries.bib. Next, replace:
\makeglossaries
with:
\GlsXtrLoadResources
[src={entries}]
Now remove all the entry definitions in the document preamble
(\longnewglossaryentry
, \newglossaryentry
and \newacronym
or \newabbreviation
).
The abbreviation style command
must go before \GlsXtrLoadResources
. For example (if you are
using \newacronym
):
Finally, replace:\setabbreviationstyle
[acronym]{long-short}\GlsXtrLoadResources
[src={entries}]
\printglossaries
with:
\printunsrtglossaries
The document build is now:
pdflatex minimalgls bib2gls minimalgls pdflatex minimalgls
sampleDB.tex
This document illustrates how
to load external files containing the glossary entry definitions. It also
illustrates how to define a new glossary type. This document has the
number list suppressed and uses \glsaddall
to add all
the entries to the glossaries without referencing each one
explicitly. (Note that it’s more efficient to use
glossaries-extra and bib2gls if you have a large number
of entries.) To create the document do:
pdflatex sampleDB makeglossaries sampleDB pdflatex sampleDBor
pdflatex sampleDB makeglossaries-lite sampleDB pdflatex sampleDBThe glossary definitions are stored in the accompanying files database1.tex and database2.tex. If for some reason you want to call makeindex explicitly you must have a separate call for each glossary:
- 1.Create the
main
glossary (all on one line):makeindex -s sampleDB.ist -t sampleDB.glg -o sampleDB.gls sampleDB.glo
- 2.Create the secondary glossary (all on one line):
makeindex -s sampleDB.ist -t sampleDB.nlg -o sampleDB.not sampleDB.ntn
Note that both makeglossaries and makeglossaries-lite do this all in one call, so they not only make it easier because you don’t need to supply all the switches and remember all the extensions but they also call makeindex the appropriate number of times.
If you want to switch to using bib2gls with glossaries-extra, you can convert database1.tex and database2.tex to bib files using convertgls2bib:
convertgls2bib database1.tex database1.bib convertgls2bib database2.tex database2.bibThe document code then needs to be:
Note that the nonumberlist package option has been omitted. It’s not needed because there are no locations in this amended document (whereas in the original sampleDB.tex locations are created with\documentclass
{article}\usepackage
[colorlinks,plainpages=false]{hyperref}\usepackage
[record,postdot]{glossaries-extra}\newglossary*
{punc}{Punctuation Characters}\GlsXtrLoadResources
[src={database1}, selection=all,sort=en]\GlsXtrLoadResources
[src={database2},type=punc, selection=all,sort=letter-case]\begin{document}
\printunsrtglossaries
\end{document}
\glsaddall
). The starred \newglossary*
is used
since the makeindex/xindy extensions are now irrelevant.
Instead of using makeglossaries you need to use bib2gls when you build the document:
pdflatex sampleDB bib2gls sampleDB pdflatex sampleDBNote that one bib2gls call processes all the indexing (rather than one call per glossary). Unlike makeindex and xindy, bib2gls processes each resource set in turn, but the resource sets aren’t linked to a specific glossary. Multiple glossaries may be processed in a single resource set or sub-blocks of a single glossary may be processed by multiple resource sets. In this example, there happens to be one resource set per glossary because each glossary requires a different sort method. (A locale-sensitive alphabetical sort for the first and a character code sort for the second.)
If you want letter groups, you need to use the --group switch:
bib2gls --group sampleDBand use an appropriate glossary style.
See also bib2gls gallery: sorting, glossaries-extra and bib2gls: An Introductory Guide and the bib2gls user manual.
18.2. Acronyms and First Use[link]
sampleAcr.tex This document has some sample acronyms. It also adds the glossary to the table of contents, so an extra run through LaTeX is required to ensure the document is up to date:
pdflatex sampleAcr makeglossaries sampleAcr pdflatex sampleAcr pdflatex sampleAcr(or use makeglossaries-lite).
Note that if the glossary is at the start of the document and spans across multiple pages, then this can cause the locations to be shifted. In that case, an extra makeglossaries and LaTeX call are required. In this particular example, the glossary is at the end of the document so it’s not a problem. It’s also not a problem for a glossary at the start of the document if the page numbering is reset at the end of the glossary. For example, if the glossary is at the end of the front matter in a book-style document.
This document uses \ifglsused
to determine whether to use
“a” or “an” in:
… isThis clumsy bit of code can be tidied up with the glossaries-prefix package. Since that package automatically loads glossaries and passes all its options to the base package it’s possible to do a simple replacement of:\ifglsused
{svm}{an}{a}\gls
{svm} …
\usepackage
[style=long,toc]{glossaries}
with:
\usepackage
[style=long,toc]{glossaries-prefix}
The definition of “svm” now needs an adjustment:
The clumsy text can now simply be changed to:\newacronym
[description={statistical pattern recognition technique~
\protect
\cite
{svm}}, prefixfirst={a~
},prefix={an\space
} ]{svm}{svm}{support vector machine}
… is \pgls
{svm} …
If you want to convert this sample document to use glossaries-extra, you may want the patched version of the styles provided in glossary-long, in which case you can also add stylemods:
\usepackage
[stylemods,style=long]{glossaries-extra}
If you want to suppress all the other glossary style packages with
nostyles, then you need to specify exactly which package
(or packages) that you do want:
\usepackage
[nostyles,stylemods=long,style=long]{glossaries-extra}
(Now that glossaries-extra is being used, there are more
available “long” styles in the glossary-longextra package,
which you may prefer.)
If you want to use glossaries-prefix, you can simply add the prefix package option.
Note that the toc package option has been dropped. This is the default with glossaries-extra, so it doesn’t need to be specified now. The document build is now shorter:
pdflatex sampleAcr makeglossaries sampleAcr pdflatex sampleAcrThe third LaTeX call is no longer required to make the table of contents up-to-date. This is because glossaries-extra provides boilerplate text on the first LaTeX call when the indexing files are missing. This means that the glossary header is added to the toc file on the first LaTeX call, whereas with just the base glossaries package, the header isn’t present until the second LaTeX call. (As with just the base glossaries package, if the glossary occurs at the start of the document without a page reset after it then part of the build process needs repeating to ensure all referenced page numbers are up-to-date. This problem isn’t specific to the glossaries package.)
The other different default setting is the post-description punctuation. The base package has nopostdot=false as the default. This means that a full stop (period) is automatically inserted after the description in the glossary. The extension package has nopostdottrue as the default. If you want the original behaviour then you can use nopostdot=false or the shorter synonym postdot.
The glossaries-extra package has different
abbreviation handling that’s far more flexible than that provided by
the base glossaries package. The style now needs to be set with
\setabbreviationstyle
instead of \setacronymstyle
:
(Note the different style name long-short-sc instead of long-sc-short and the optional argument acronym.) If you prefer to replace\setabbreviationstyle
[acronym]{long-short-sc}\newacronym
{svm}{svm}{support vector machine}
\newacronym
with \newabbreviation
then
omit the optional argument:
(The optional argument of\setabbreviationstyle
{long-short-sc}\newabbreviation
{svm}{svm}{support vector machine}
\setabbreviationstyle
is the
category to which the style should be applied. If it’s omitted,
abbreviation is assumed. You can therefore have different
styles for different categories.)
Finally, you need to replace \acrshort
, \acrlong
and
\acrfull
and their variants with \glsxtrshort
, \glsxtrlong
and
\glsxtrfull
etc.
This is similar to the previous example, except that the acronyms have an associated description. As with the previous example, the glossary is added to the table of contents, so an extra run through LaTeX is required:
pdflatex sampleAcrDesc makeglossaries sampleAcrDesc pdflatex sampleAcrDesc pdflatex sampleAcrDescThis document uses the acronym package option, which creates a new glossary used by
\newacronym
. This leaves the
default main
glossary available for general terms. However,
in this case there are no general terms so the main
glossary is redundant. The nomain package option will
prevent its creation. Obviously, if you decide to add some terms
with \newglossaryentry
you will need to remove the
nomain option as the main
glossary will now be
required.
As with the previous example, if you want to convert this document to use glossaries-extra you need to make a few modifications. The most obvious one is to replace glossaries with glossaries-extra in the
\usepackage
argument. Again you
can omit toc as this is the default for
glossaries-extra. As in the previous example, you may want to
use the patched styles. This document uses altlist which
is provided by glossary-list, so the style can be patched with
stylemods.
\usepackage
[acronym,nomain,style=altlist,stylemods]{glossaries-extra}
You may prefer to replace the acronym option with
abbreviations, but this will change the file extensions.
If you use makeglossaries or makeglossaries-lite you
don’t need to worry about it.
Again the style command needs to be changed:
\setabbreviationstyle
[acronym]{long-short-sc-desc}
(Note the change in style name long-short-sc-desc
instead of long-sc-short-desc and the optional argument acronym.)
As with the previous example, if
you prefer to use \newabbreviation
instead of \newacronym
then you need to omit the optional argument:
\setabbreviationstyle
{long-short-sc-desc}
The original document uses:
to ensure that the cross-references (from the see key) use the acronym font. The new abbreviation styles don’t use\renewcommand
*{\glsseeitemformat
}[1]{%\acronymfont
{\glsentrytext
{#1}}}
\acronymfont
so this isn’t appropriate with
glossaries-extra. If you’re using at least version 1.42 of
glossaries-extra, you don’t need to do anything as it
automatically redefines \glsseeitemformat
to take the style
formatting into account. If you have an earlier version you can
redefine this command as follows:
This will just show the short form in the cross-reference. If you prefer the name instead (which includes the short and long form) you can use:\renewcommand
*{\glsseeitemformat
}[1]{%\ifglshasshort
{#1}{\glsfmttext
{#1}}{\glsfmtname
{#1}}% }
\renewcommand
*{\glsseeitemformat
}[1]{\glsfmtname
{#1}}
The glossaries-extra package provides two additional
cross-referencing keys seealso and alias,
so see={[see also]{svm}}
can be replaced with a more appropriate key:
\newacronym
[description={Statistical pattern recognition
technique using the ``kernel trick''},
seealso={svm},
]{ksvm}{ksvm}{kernel support vector machine}
Finally, as with the previous example, you need to replace
\acrshort
, \acrlong
and \acrfull
etc with
\glsxtrshort
, \glsxtrlong
and \glsxtrfull
etc.
If you want to convert this document so that it uses bib2gls, you first need to convert it to use glossaries-extra, as above, but remember that you now need the record option:
\usepackage
[acronym,nomain,style=altlist,record,postdot,stylemods]
{glossaries-extra}
Now you need to convert the acronym definitions to the bib
format required by bib2gls. This can be done with:
convertgls2bib --preamble-only sampleAcrDesc.tex entries.bibIf you retained
\newacronym
from the original example file,
then the new entries.bib file will contain entries
defined with @acronym
. For example:
@acronym
{ksvm,
description={Statistical pattern recognition technique
using the ``kernel trick''},
seealso={svm},
short={ksvm},
long={kernel support vector machine}
}
If you switched to \newabbreviation
then the entries will
instead be defined with @abbreviation
.
Next replace \makeglossaries
with the resource command, but note
that the abbreviation style must be set first:
Another possibility is to make\setabbreviationstyle
[acronym]{long-short-sc-desc}\GlsXtrLoadResources
[src={entries},% terms defined in entries.bib abbreviation-sort-fallback=long]
@acronym
behave as though it
was actually @abbreviation
:
Note that the category is now abbreviation not acronym so the optional argument of\setabbreviationstyle
{long-short-sc-desc}\GlsXtrLoadResources
[src={entries},abbreviation-sort-fallback=long, entry-type-aliases={acronym=abbreviation}]
\setabbreviationstyle
needs to be removed.
If the sort field is missing (which should usually be the
case), then both @acronym
and @abbreviation
will
fallback on the short field (not the name field,
which is usually set by the style and therefore not visible to
bib2gls). For some styles, as in this example, it’s more
appropriate to sort by the long form so the fallback is changed.
(Remember that you will break this fallback mechanism if you
explicitly set the sort value.) See the bib2gls manual for
further details and other examples.
Remember to delete any \newacronym
or \newabbreviation
in
the tex file.
Finally replace \printglossary
with \printunsrtglossary
.
The document build is now:
pdflatex sampleAcrDesc bib2gls sampleAcrDesc pdflatex sampleAcrDesc
Note that it’s now much easier to revert back to the descriptionless style used in sampleAcr.tex:
With the other options it would be necessary to delete all the description fields from the abbreviation definitions in order to omit them, but with bib2gls you can simply instruct bib2gls to ignore the description. This makes it much easier to have a large database of abbreviations for use across multiple documents that may or may not require the description.\setabbreviationstyle
[acronym]{long-short-sc}\GlsXtrLoadResources
[src={entries},ignore-fields={description}]
This is similar to the previous example, except that it defines the acronyms as normal entries using
\newglossaryentry
instead of
\newacronym
. As with the previous example, the glossary is
added to the table of contents, so an extra run through LaTeX is
required:
pdflatex sampleDesc makeglossaries sampleDesc pdflatex sampleDesc pdflatex sampleDescThis sample file demonstrates the use of the first and text keys but in general it’s better to use
\newacronym
instead as it’s more flexible. For even greater
flexibility use \newabbreviation
provided by glossaries-extra.
For other variations, such as showing the symbol on first use,
you may prefer to make use of the post-link category hook. For
examples, see the section “Changing the Formatting” in glossaries-extra and bib2gls: An Introductory Guide.
This document has some sample acronyms that use the footnote-sc-desc acronym style. As with the previous example, the glossary is added to the table of contents, so an extra run through LaTeX is required:
pdflatex sampleFnAcrDesc makeglossaries sampleFnAcrDesc pdflatex sampleFnAcrDesc pdflatex sampleFnAcrDescIf you want to convert this sample document to use glossaries-extra, then you just need to follow the same steps as for sampleAcr.tex with a slight modification. This time the short-sc-footnote-desc abbreviation style is needed:
\setabbreviationstyle
[acronym]{short-sc-footnote-desc}
The command redefinitions (performed with \renewcommand
) should
now all be deleted as they are no longer applicable.
You may prefer to use the short-sc-postfootnote-desc style instead. There are subtle differences between the postfootnote and footnote set of styles. Try changing the abbreviation style to short-sc-footnote and compare the position of the footnote marker with the two styles.
This modified sample file now has a shorter build:
pdflatex sampleFnAcrDesc makeglossaries sampleFnAcrDesc pdflatex sampleFnAcrDescThis is because the glossaries-extra package produces boilerplate text when the indexing file is missing (on the first LaTeX run) which adds the glossary title to the table of contents (toc) file.
This document has some sample acronyms with a custom acronym style. It also adds the glossary to the table of contents, so an extra run through LaTeX is required:
pdflatex sampleCustomAcr makeglossaries sampleCustomAcr pdflatex sampleCustomAcr pdflatex sampleCustomAcrThis is a slight variation on the previous example where the name is in the form ( ) instead of ( ), and the sort key is set to the long form instead of the short form. On first use, the footnote text is in the form : (instead of just the long form). This requires defining a
\newacronym
style that inherits from the footnote-sc-desc style.
The conversion to glossaries-extra starts in much the same way as the previous examples:
\usepackage
[acronym,nomain,postdot,stylemods,style=altlist]
{glossaries-extra}
The abbreviation styles have associated helper commands that may be
redefined to make minor modifications. These redefinitions should be
done before the abbreviations are defined.
The short-sc-footnote-desc abbreviation style is the closest match
to the requirement, so replace the \setacronymstyle
command
with:
\setabbreviationstyle
[acronym]{short-sc-footnote-desc}
Again, you may prefer short-sc-postfootnote-desc. Both
styles use the same helper commands.
Next some adjustments need to be made to fit the new requirements. The name needs to be
( ):This command expands when the abbreviations are defined so take care to\renewcommand
*{\glsxtrfootnotedescname
}{%\protect
\glslongfont
{\the
\glslongtok
}%\protect
\glsxtrfullsep
{\the
\glslabeltok
}%\protect
\glsxtrparen
{\protect
\glsabbrvfont
{\the
\glsshorttok
}}% }
\protect
commands that shouldn’t be expanded at that point,
and make sure that the token registers that store the label, long
and short values are able to expand. Similarly the sort value needs
adjusting:
The footnote for all the footnote abbreviation styles is produced with:\renewcommand
*{\glsxtrfootnotedescsort
}{\the
\glslongtok
}
\glsxtrabbrvfootnote
{ }{ }
where is the singular or plural long form, depending on
what command was used to reference the abbreviation (\gls
,
\glspl
etc). This can simply be redefined as:
This will mimic the result from the original sample document. Note that newer versions of glossaries-extra may have additional helper commands associated with certain abbreviation styles.\renewcommand
*{\glsxtrabbrvfootnote
}[2]{\footnote
{% #2:\glsentrydesc
{#1}}}
You may prefer to replace #2
with a reference to a
specific field (or fields). For example:
As with the earlier sampleAcrDesc.tex, you need to remove or change the redefinition of\renewcommand
*{\glsxtrabbrvfootnote
}[2]{\footnote
{%\Glsfmtlong
{#1} (\glsfmtshort
{#1}):\glsentrydesc
{#1}.}}
\glsseeitemformat
since \acronymfont
is no longer appropriate.
In the original sampleCustomAcr.tex source code, I started the description with a capital:
\newacronym
[description={Statistical pattern recognition
technique using the ``kernel trick''},
see={[see also]{svm}},
]{ksvm}{ksvm}{kernel support vector machine}
This leads to a capital letter after the colon in the footnote,
which is undesirable, but I would like to have the description start
with a capital in the glossary. The solution to this problem
is easy with glossaries-extra. I start the description with a
lowercase letter and set the glossdesc
category attribute to firstuc to convert the
description to sentence case in the glossary:
\glssetcategoryattribute
{acronym}{glossdesc}{firstuc}
The abbreviation definitions are modified slightly:
\newacronym
[description={statistical pattern recognition
technique using the ``kernel trick''},
seealso={svm},
]{ksvm}{ksvm}{kernel support vector machine}
Note the use of the seealso key, which is only
available with glossaries-extra.
If you prefer to use \newabbreviation
instead of
\newacronym
, then the category needs to be
abbreviation rather than acronym:
\glssetcategoryattribute
{abbreviation}{glossdesc}{firstuc}
and the style command needs to be adjusted so that it omits the
optional argument. For example:
\setabbreviationstyle
{short-sc-postfootnote-desc}
This example defines a custom entry formatdisplay format that puts the description in a footnote on first use.
pdflatex sample-FnDesc makeglossaries sample-FnDesc pdflatex sample-FnDescIn order to prevent nested hyperlinks, this document uses the hyperfirst=false package option (otherwise the footnote marker hyperlink would be inside the hyperlink around the link text which would result in a nested hyperlink).
The glossaries-extra package has category post-link hooks that make it easier to adjust the formatting. The post-link hook is placed after the hyperlink around the link text, so a hyperlink created by
\footnote
in the post-link hook won’t cause a nested link. This means that the
hyperfirst=false option isn’t required:
\usepackage
[postdot,stylemods]{glossaries-extra}
\gls
or \glsdesc
in the
post-link hook as you can end up with infinite recursion. Use commands that
don’t themselves have a post-link hook, such as \glsentrydesc
or
\glossentrydesc
, instead.
In the original sample-FnDesc.tex file, the entry format was adjusted with:
This can be changed to:\renewcommand
*{\glsentryfmt
}{%\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\footnote
{\glsentrydesc
{\glslabel
}}}}
This sets the post-link hook for the general category (which is the default category for entries defined with\glsdefpostlink
{general}% category label {\glsxtrifwasfirstuse
{\footnote
{\glsentrydesc
{\glslabel
}}}{}}
\newglossaryentry
). If I
added some abbreviations (which have a different category) then this
change wouldn’t apply to them.
The first paragraph in the document is:
First use: \gls
{sample}.
So the PDF will have the word “sample” (the link text
created by \gls
{sample}
) as a hyperlink to the entry in the
glossary followed by the footnote marker, which is a
hyperlink to
the footnote. This is then followed by the sentence terminator.
“First use: sample¹.”
It would look tidier if the footnote marker could be shifted after the full stop. “First use: sample.¹” This can easily be achieved with a minor modification:
You may prefer to use\glsdefpostlink
{general}% category label {\glsxtrifwasfirstuse
{\glsxtrdopostpunc
{\footnote
{\glsentrydesc
{\glslabel
}}}}% {}% }
\glossentrydesc
instead of
\glsentrydesc
. This will obey the glossdesc
category attribute.
If you append \glspostdescription
, you can also pick up the
postdot package option. For example:
Alternatively, you could just use\glssetcategoryattribute
{general}{glossdesc}{firstuc}\glsdefpostlink
{general}% category label {\glsxtrifwasfirstuse
{\glsxtrdopostpunc
{\footnote
{%\glossentrydesc
{\glslabel
}\glspostdescription
}}}% {}% }
\Glsentrydesc
and explicitly
append the full stop.
This document illustrates how to define your own acronym style if the predefined styles don’t suit your requirements.
pdflatex sample-custom-acronym makeglossaries sample-custom-acronym pdflatex sample-custom-acronymIn this case, a style is defined to show the short form in the text with the long form and description in a footnote on first use. The long form is used for the sort value. The short form is displayed in small caps in the main part of the document but in uppercase in the list of acronyms. (So it’s a slight variation of some of the examples above.) The name is set to the long form (starting with an initial capital) followed by the all caps short form in parentheses. The final requirement is that the inline form should show the long form followed by the short form in parentheses.
As with sampleFnAcrDesc.tex, the short-sc-footnote-desc and short-sc-postfootnote-desc abbreviation styles produce almost the required effect so one of those can be used as a starting point. However the final requirement doesn’t fit. It’s now necessary to actually define a custom abbreviation style, but it can mostly inherit from the short-sc-footnote-desc or short-sc-postfootnote-desc style:
(See the glossaries-extra user manual for further details.)\newabbreviationstyle
{custom-fn}% {%\GlsXtrUseAbbrStyleSetup
{short-sc-footnote-desc}% }% {%\GlsXtrUseAbbrStyleFmts
{short-sc-footnote-desc}%\renewcommand
*{\glsxtrinlinefullformat
}[2]{%\glsfirstlongfootnotefont
{\glsaccesslong
{##
1}%\ifglsxtrinsertinside
##
2\fi
}%\ifglsxtrinsertinside
\else
##
2\fi
\glsxtrfullsep
{##
1}%\glsxtrparen
{\glsfirstabbrvscfont
{\glsaccessshort
{##
1}}}% }%\renewcommand
*{\glsxtrinlinefullplformat
}[2]{%\glsfirstlongfootnotefont
{\glsaccesslongpl
{##
1}%\ifglsxtrinsertinside
##
2\fi
}\ifglsxtrinsertinside
\else
##
2\fi
\glsxtrfullsep
{##
1}%\glsxtrparen
{\glsfirstabbrvscfont
{\glsaccessshortpl
{##
1}}}% }\renewcommand
*{\Glsxtrinlinefullformat
}[2]{%\glsfirstlongfootnotefont
{\Glsaccesslong
{##
1}%\ifglsxtrinsertinside
##
2\fi
}%\ifglsxtrinsertinside
\else
##
2\fi
\glsxtrfullsep
{##
1}%\glsxtrparen
{\glsfirstabbrvscfont
{\glsaccessshort
{##
1}}}% }%\renewcommand
*{\Glsxtrinlinefullplformat
}[2]{%\glsfirstlongfootnotefont
{\Glsaccesslongpl
{##
1}%\ifglsxtrinsertinside
##
2\fi
}%\ifglsxtrinsertinside
\else
##
2\fi
\glsxtrfullsep
{##
1}%\glsxtrparen
{\glsfirstabbrvscfont
{\glsaccessshortpl
{##
1}}}% }% }
This new custom style now needs to be set:
\setabbreviationstyle
[acronym]{custom-fn}
Remember that if you decide to use \newabbreviation
instead
of \newacronym
then the category will be abbreviation not acronym:
\setabbreviationstyle
{custom-fn}
This custom style simply adjusts the inline full form. There are other
adjustments to be made that apply to the inherited style. (The alternative is to
design a new style from scratch.) The footnote contains the long form followed by the
description. This is the same as the modification to an earlier
example:
As with sampleCustomAcr.tex, if you specifically want the singular long form then you can ignore the second argument. For example:\renewcommand
*{\glsxtrabbrvfootnote
}[2]{\footnote
{#2:\glsentrydesc
{#1}.}}
\renewcommand
*{\glsxtrabbrvfootnote
}[2]{\footnote
{\Glsfmtlong
{#1}:\glsentrydesc
{#1}.}}
The name now needs to be the long form followed by the short form in parentheses, but note the new requirement that the short form should now be in all caps not small caps and the long form should start with a capital letter.
The inherited abbreviation style uses the short form as the sort value by default. This needs to be changed to the long form:\renewcommand
*{\glsxtrfootnotedescname
}{%\protect
\glsfirstlongfootnotefont
{\makefirstuc
{\the
\glslongtok
}} (\protect
\glsuppercase
{\the
\glsshorttok
})% }
\renewcommand
*{\glsxtrfootnotedescsort
}{\the
\glslongtok
}
This document illustrates how to use the base post-link hook to adjust the space factor after acronyms.
pdflatex sample-dot-abbr makeglossaries sampledot-abbrf pdflatex sample-dot-abbrThis example creates a custom storage key that provides a similar function to glossaries-extra’s category key.
This example is much simpler with glossaries-extra. The custom storage key, which is defined using:
can now be removed.\glsaddstoragekey
{abbrtype}{word}{\abbrtype
}
The category key is set to “initials” for
the initialisms (which are defined with the custom \newacr
command). The abbreviation styles can be set with:
The discardperiod category attribute will discard any full stop (period) following commands like\setabbreviationstyle
[acronym]{long-short}\setabbreviationstyle
[initials]{long-short}
\gls
:
\glssetcategoryattribute
{initials}{discardperiod}{true}
(If you want to use the noshortplural attribute then you will
also need to set the pluraldiscardperiod attribute.)
The first use is governed by the retainfirstuseperiod
category attribute. If set, the period won’t be discarded if it follows the
first use of commands like \gls
. This is useful for styles
where the first use doesn’t end with the short form. In this
case, the first use of the long-short style ends
with a closing parenthesis, so the end of sentence might be clearer
if the period is retained:
\glssetcategoryattribute
{initials}{retainfirstuseperiod}{true}
The insertdots category attribute can automatically insert dots into the short form with a final space factor adjustment:
\glssetcategoryattribute
{initials}{insertdots}{true}
The custom helper command defined in the example needs to be slightly modified:
The definitions need to be slightly modified to work with the insertdots attribute:\newcommand
*{\newabbr
}[1][]{%\newabbreviation
[category=initials,#1]}
(This makes it much easier to change your mind if you decide at a later date to omit the dots, especially if you are storing all your definitions in a file that’s shared across multiple documents, but note the need to group “Sc”.)\newabbr
{eg}{eg}{eg}\newabbr
{ie}{ie}{ie}\newabbr
{bsc}{B{Sc}}{Bachelor of Science}\newabbr
{ba}{BA}{BA}\newabbr
{agm}{AGM}{AGM}
The “laser” definition remains unchanged:
\newacronym
{laser}{laser}{light amplification by stimulated
emission of radiation}
The remaining code in the document preamble must now be removed. (It will
interfere with glossaries-extra’s category post-link hooks.)
No change is required in the document body.
See the glossaries-extra user manual for further details about category attributes and post-link hooks.
This document illustrates how to have different fonts for acronyms within the style. The document build is:
pdflatex sample-font-abbr makeglossaries sample-font-abbr pdflatex sample-font-abbrThe acronym mechanism provided by the base glossaries package isn’t well suited to having a mixture of styles. This example provides a workaround that involves defining a new storage key with
\glsaddstoragekey
that’s used to hold the font
declaration (such as \em
).
A new custom acronym style is defined that fetches the font information from this new key so that it can be applied to the acronym. Some helper commands are also provided to define the different types of acronyms:\glsaddstoragekey
{font}{}{\entryfont
}
This makes the first use of\newcommand
*{\newitabbr
}[1][]{\newacronym
[font=\em
,#1]}\newcommand
*{\newupabbr
}{\newacronym
}\newitabbr
{eg}{e.g.}{exempli gratia}\newupabbr
{bsc}{BSc}{Bachelor of Science}
\gls
{eg}
appear as “exempli
gratia (e.g.)” whereas the first use of \gls
{bsc}
is “Bachelor of Science (BSc)”.
This example document is much simpler with glossaries-extra. First the
\usepackage
command needs adjusting:
\usepackage
[postdot,stylemods]{glossaries-extra}
The custom storage key can now be removed and also the custom
acronym style. Now replace the \setacronymstyle
line with:
\setabbreviationstyle
[acronym]{long-short-em}
and change the definition of the helper commands:
Note that the\newcommand
*{\newitabbr
}{\newacronym
}\newcommand
*{\newupabbr
}{\newabbreviation
}
font=\em,
part has been removed from the
definition of the first command and the second command uses
\newabbreviation
instead of \newacronym
. This means that
\newitabbr
will default to
category={acronym} and \newupabbr
will
default to category={abbreviation}. The
default style for the abbreviation category is
long-short, which is the required style for this
example. This just means that only the acronym category needs
to have the style set (with the above \setabbreviationstyle
command).
Finally, the \acrshort
, \acrlong
and \acrfull
commands
need to be replaced with \glsxtrshort
, \glsxtrlong
and
\glsxtrfull
.
You may notice that the spacing after “e.g.” and “i.e.” isn’t correct. This is similar to the sample-dot-abbr.tex example where the space factor needs adjusting. In this case I’ve inserted the dots manually (rather than relying on the insertdots attribute). You can either remove the dots and use insertdots with discardperiod:
Or you can manually insert the space factor adjustment with\glssetcategoryattribute
{acronym}{insertdots}{true}\glssetcategoryattribute
{acronym}{discardperiod}{true}\newitabbr
{eg}{eg}{exempli gratia}\newitabbr
{ie}{ie}{id est}
\@
and only use
the discardperiod attribute:
\glssetcategoryattribute
{acronym}{discardperiod}{true}\newitabbr
{eg}{e.g.\@
}{exempli gratia}\newitabbr
{ie}{i.e.\@
}{id est}
You don’t have to use the acronym category. You may prefer a different label that fits better semantically. For example:
\setabbreviationstyle
[latinabbr]{long-short-em}\newcommand
*{\newlatinabbr
}[1][]{\newabbreviation
[category={latinabbr},#1]}\glssetcategoryattribute
{latinabbr}{insertdots}{true}\glssetcategoryattribute
{latinabbr}{discardperiod}{true}\newlatinabbr
{eg}{e.g.\@
}{exempli gratia}\newlatinabbr
{ie}{i.e.\@
}{id est}
18.3. Non-Page Locations[link]
This document illustrates how to change the entry location to something other than the page number. In this case, the equation counter is used since all glossary entries appear inside an equation environment. To create the document do:
pdflatex sampleEq makeglossaries sampleEq pdflatex sampleEqThe glossaries package provides some location formats, such as hyperrm and hyperbf, that allow the locations in the number list to hyperlink to the appropriate place in the document (if hyperref has been used). Since it’s not possible to include the hyperlink name in the indexing information with makeindex and xindy, the glossaries package has to reform the name from a prefix and the location value.
Unfortunately it’s not always possible to split the link name into a
prefix and location. That happens with the equation
counter in certain classes, such as the report class (which
is used in this example). This means that it’s necessary to redefine
\theHequation
so that it has a format that fits the requirement:
If you don’t do this, the equation locations in the glossary won’t form valid hyperlinks.\renewcommand
*\theHequation
{\theHchapter
.\arabic
{equation}}
Each glossary entry represents a mathematical symbol. This means that with Options 1, 2 and 3 it’s necessary to use the sort key. For example:
\newglossaryentry
{Gamma}{name={\ensuremath
{\Gamma
(z)}}, description={Gamma function},sort={Gamma}}
If you want to switch to using bib2gls, the first change you need to make is to switch from explicitly loading glossaries to loading glossaries-extra with the record package option. If record=only (or record without a value) is used, then the above redefinition of
\theHequation
is still required. If
record=nameref is used instead then the redefinition of
\theHequation
isn’t required. You may also want to use the
stylemods and postdot options:
\usepackage
[record=nameref,stylemods,postdot,
ucmark,style=long3colheader,counter=equation]{glossaries-extra}
The entries now need to be converted into the bib format required
by bib2gls, which can be done with convertgls2bib:
convertgls2bib --preamble-only sampleEq.tex entries.bibThis will create a file called entries.bib that starts:
% Encoding: UTF-8You may prefer to change@entry
{Gamma, name={\ensuremath
{\Gamma
(z)}}, description={Gamma function} }
@entry
to @symbol
. (This
should be easy to do with your text editor’s search and replace
function.)
Note that the sort key has been omitted. This is because
it typically shouldn’t be used. The difference between using
@entry
and @symbol
is that with @entry
the sort value will be obtained from the name but with
@symbol
the sort value will be obtained from the label.
If you explicitly use the sort key then you will break
this behaviour. (If you try this example out, notice the difference
in the ordering if you switch between @entry
and
@symbol
. See also bib2gls gallery: sorting.)
Next replace \makeglossaries
with:
\GlsXtrLoadResources
[src={entries}]
If you have used record=nameref then you can remove the
redefinition of \theHequation
. Next remove all the lines
defining the glossary entries (since they’re now defined in the
bib file).
Finally, replace \printglossary
with \printunsrtglossary
:
\printunsrtglossary
[title={Index of Special Functions and Notations}]
The rest of the document remains unchanged (unless you want to use
\glsxtrfmt
as described in the following example).
This is similar to the previous example, but the number lists are a mixture of page numbers and equation numbers. This example adds the glossary to the table of contents, so an extra LaTeX run is required:
pdflatex sampleEqPg makeglossaries sampleEqPg pdflatex sampleEqPg pdflatex sampleEqPgAs with the previous example, entries are defined like this:
The counter=equation package option is used to set the default indexing counter to equation. This means that it has to be changed for indexing outside of any numbered equation. For example:\newglossaryentry
{Gamma}name={\ensuremath
{\Gamma
(z)}}, description={Gamma function},sort={Gamma}
\glslink
[format=hyperbf,counter=page]{Gamma}{gamma function}
I’ve set the format to hyperbf to indicate that
this is a primary reference. (Note that I’m using hyperbf not
textbf in order to include a hyperlink in the location.)
The link text here is almost identical to the
description. The only difference is that the description starts with
a capital (sentence case). If it started with a lowercase character instead, I could
simply use \glsdesc
instead of \glslink
. If I change the
entry descriptions so that they all start with a lowercase letter
then I would need to create a custom glossary style that used
\Glossentrydesc
instead of \glossentrydesc
.
If I switch to using glossaries-extra I wouldn’t need a new glossary style. Instead I could just use the glossdesc category attribute to perform the case change. Remember that the first change to make is to replace glossaries with glossaries-extra:
\usepackage
[style=long3colheader,postdot,stylemods,
counter=equation]{glossaries-extra}
The entries are now all defined so that the description starts with
a lowercase letter (except for the descriptions that start with a
proper noun). For example:
The glossdesc category attribute needs setting:\newglossaryentry
{Gamma}{name={\ensuremath
{\Gamma
(z)}}, description={gamma function},sort={Gamma}}
\glssetcategoryattribute
{general}{glossdesc}{firstuc}
This means that I can now use \glsdesc
instead of \glslink
.
It’s a bit cumbersome typing [format=hyperbf,counter=page]
for each primary reference, but glossaries-extra provides a
convenient way of having a third modifier for commands like \gls
and \glstext
. This needs to be a single punctuation character
(but not *
or +
which are already in use). For
example:
\GlsXtrSetAltModifier
{!}{format=hyperbf,counter=page}
Now \glsdesc
!{Gamma}
is equivalent to:
\glsdesc
[format=hyperbf,counter=page]{Gamma}
So the text at the start of the “Gamma Functions” chapter is now
just:
The \glsdesc
!{Gamma} is defined as
which is much more compact. Similar changes can be made for the
other instance of \glslink
where the link text is just
the description:
The \glsdesc
!{erf} is defined as
There are three other instances of \glslink
, such as:
If I just use\glslink
{Gamma}{\Gamma
(x+1)}
\gls
{Gamma}
then I would get Γ(z) as the
link text. For entries like this that represent functions with
variable parameters it would be more convenient (and help with
consistency) if a command was available to easily replace the
parameters.
With the base glossaries package, one simple solution that works for this example is to save just the function symbol in the symbol field, for example:
and then use:\newglossaryentry
{Gamma}{name={\ensuremath
{\Gamma
(z)}}, symbol={\ensuremath
{\Gamma
}}, description={gamma function},sort={Gamma}}
(which includes the function parameter inside the link text) or just:\glssymbol
{Gamma}[(\Gamma
(x+1))]
(which has the function parameter after the link text). This is a convenient approach where the extra material can simply follow the symbol, and it can also be used with glossaries-extra.\glssymbol
{Gamma}(\Gamma
(x+1))
The glossaries-extra package provides another possibility. It requires a command that takes a single argument, for example:
The control sequence name (the command name without the leading backslash) is stored in the field identified by the command\newcommand
{\Gammafunction
}[1]{\Gamma
(#1)}
\GlsXtrFmtField
(this should be the internal field name not the key name, see Table 4.1). The
default is useri which corresponds to the user1
key. This means that the “Gamma” entry would need to be
defined with user1={Gammafunction}. With this approach, each
function entry would need a separate associated command.
Another approach is to store the parameterless function in the
symbol key (as earlier) and have a more generic command that uses this
symbol. This requires the entry label, which can be obtained with
\glslabel
within the link text:
(Obviously, this command can’t be used outside of the link text or post-link hooks since it uses\newcommand
{\entryfunc
}[1]{\glsentrysymbol
{\glslabel
}(#1)}
\glslabel
.)
So the entry now needs the parameterless function in symbol and the control sequence name of this generic command in user1. For example:
(This doesn’t need to be done for the “C” and “G” entries since they’re constants not functions.)\newglossaryentry
{Gamma}{name={\ensuremath
{\Gamma
(z)}}, symbol={\ensuremath
{\Gamma
}},user1={entryfunc}, description={gamma function},sort={Gamma}}
You may want to consider providing helper commands to make the functions easier to define. For example:
The entries can now be defined using this custom\newcommand
{\func
}[2]{#1(#2)}\newcommand
{\entryfunc
}[1]{\func
{\glsentrysymbol
{\glslabel
}}{#1}}\newcommand
{\newfunc
}[5][]{%\newglossaryentry
{#2}{name={\ensuremath
{\func
{#3}{#4}}}, symbol={#3}, user1={entryfunc}, description={#5}, sort={#2},#1 }% }
\newfunc
command. For example:
\newfunc
{Gamma}{\Gamma
}{z}{gamma function}\newfunc
[sort={gamma1}]{gamma}{\gamma
}{\alpha
,x}{lower incomplete gamma function}\newfunc
[sort={Gamma2}]{iGamma}{\Gamma
}{\alpha
,x}{upper incomplete gamma function}
Note that in \newfunc
the symbol key doesn’t have its value
encapsulated with \ensuremath
so \glssymbol
will need to explicitly be
placed in math mode. If you switch to a glossary style that displays
the symbol, you will either need to adjust the definition of
\newfunc
to use \ensuremath
in the symbol field
or you can add the encapsulation with the glosssymbolfont
category attribute.
Now
can simply be replaced with
\glslink
{Znu}{Z_\nu}
(no parameter is required in
this case). For the other cases, where the parameter is different
from that given in the text field (which is obtained from
the name), you can use \glssymbol
{Znu}\glsxtrfmt
. For example,
can now be replaced with:
\glslink
{Gamma}{\Gamma(x+1)}
\glsxtrfmt
{Gamma}{x+1}
This effectively works like \glslink
but omits the post-link hook.
(See the glossaries-extra user manual for further details.)
\glsxtrfmt
within the argument of another \glsxtrfmt
command
(or inside any other link text).
Similarly
can now be replaced with:
\glslink
{Gamma}{\Gamma(\alpha)}
Note that it’s still possible to use:\glsxtrfmt
{Gamma}{\alpha
}
You may prefer to define a helper command that makes it easier to switch between your preferred method. For example:\glssymbol
{Gamma}[(\alpha
)]
or:\newcommand
*{\Fn
}[3][]{\glssymbol
[#1]{#2}[(#3)]}
\newcommand
*{\Fn
}[3][]{\glsxtrfmt
[#1]{#2}{#3}}
If you want to convert this example so that it works with bib2gls, first convert it to use glossaries-extra (as described above), and then follow the instructions from sampleEq.tex. The convertgls2bib application recognises
\newcommand
so it
will be able to parse the custom \newfunc
commands.
Note that bib2gls allows you to separate the locations in the number list into different groups according to the counter used for the location. This can be done with the loc-counters resource option. It’s also possible to identify primary formats (such as hyperbf used in this example) using the primary-location-formats option. The primary locations can then be given a more prominent position in the number list. See the bib2gls user manual for further details.
This document also illustrates how to change the location to something other than the page number. In this case, the section counter is used. This example adds the glossary to the table of contents, so an extra LaTeX run is required:
pdflatex sampleSec makeglossaries sampleSec pdflatex sampleSec pdflatex sampleSecNote that there are conflicting location formats, which trigger a warning from makeindex:
## Warning (input = sampleSec.glo, line = 6; output = sampleSec.gls, line = 9): -- Conflicting entries: multiple encaps for the same page under same key. ## Warning (input = sampleSec.glo, line = 2; output = sampleSec.gls, line = 10): -- Conflicting entries: multiple encaps for the same page under same key.This is the result of indexing an entry multiple times for the same location with different values of the format key (encaps). (makeindex assumes that the location is a page number)
In this case, it’s caused by three references to the “ident” entry in section 2.1:
\gls
[format=hyperit]{ident}\glspl
{ident} % default format=glsnumberformat\gls
*[format=hyperbf]{ident}
If you use the makeglossaries Perl script it will detect the warnings in the makeindex transcript file and attempt to fix the conflict by removing entries from the glo file:
Multiple encaps detected. Attempting to remedy. Reading sampleSec.glo... Writing sampleSec.glo... Retrying(Range formats have highest precedence. The default glsnumberformat has the lowest precedence.)
If you use makeglossaries-lite or call makeindex directly then the problem won’t be fixed and the glossary will end up with the rather odd number list for the identity matrix entry consisting of three references to section 2.1: the first in the default font, followed by bold (hyperbf) and then italic (hyperit), which results in 2.1, 2.1, 2.1. If you use makeglossaries then only the bold entry (2.1) will be present. However, if you don’t want the problem corrected, call makeglossaries with the -e switch.
If you switch to xindy:
\usepackage
[xindy,style=altlist,toc,counter=section]{glossaries}
then the conflict will be resolved using the number format attribute
list order of priority. In this case, glsnumberformat has
the highest priority. This means that only the upright medium weight entry
(2.1) will be present. The simplest way of altering this is to
provide your own custom format. For example:
and change\newcommand
*{\primary
}[1]{\hyperit
{#1}}\GlsAddXdyAttribute
{primary}
\gls
[format=hyperit]
to
\gls
[format=primary]
etc.
This will give format=primary the highest priority.
(It’s also better practice to provide this kind of semantic command.)
With bib2gls, you can supply rules to deal with location format conflicts, as illustrated below.
In order to switch to bib2gls, first replace glossaries with glossaries-extra, and add the record package option. Remember that glossaries-extra has a different set of defaults and you may also want to patch the predefined base styles. For example:
\usepackage
[style=altlist,postdot,stylemods,counter=section]
{glossaries-extra}
The entry definitions now need to be converted into bib2gls format and saved in a bib file (say, entries.bib). You can use convertgls2bib:
convertgls2bib --preamble-only sampleSec.tex entries.bib
Next replace \makeglossaries
with:
\GlsXtrLoadResources
[src={entries}]
and remove all the \newglossaryentry
commands.
Finally, replace \printglossaries
with \printunsrtglossaries
.
The document build is now:
pdflatex sampleSec bib2gls sampleSec pdflatex sampleSecAs with the original example, there’s still a location format conflict, which bib2gls warns about:
Warning: Entry location conflict for formats: hyperbf and hyperit Discarding: {ident}{}{section}{hyperbf}{2.1} Conflicts with: {ident}{}{section}{hyperit}{2.1}This means that it has discarded the bold location and kept the italic one. (As with makeglossaries, range formats have the highest priority and glsnumberformat has the lowest.)
It would be better if the conflict could be merged into a single location that was both bold and italic. To achieve this, it’s first necessary to define a command that produces this effect:
Now bib2gls needs to be invoked with the appropriate mapping with the --map-format or -m switch:\newcommand
*{\hyperbfit
}[1]{\textbf
{\hyperit
{#1}}}
bib2gls -m "hyperbf:hyperbfit,hyperit:hyperbfit" sampleSecIf you are using arara the directive should be:
% arara: bib2gls: { mapformats: [ [hyperbf, hyperbfit], % arara: --> [hyperit, hyperbfit] ] }
If you try out this example, notice the difference between record=only and record=nameref. If you use the latter, the locations will now be the section titles rather than the section numbers. If you use the record=nameref setting you can customize the location by defining the command:
\glsxtr
locfmt{ }{ }
In this case the counter is section, so the command should be
\glsxtrsectionlocfmt
. It takes two arguments: the first is the
location and the second is the title. For example:
(The only command of this type that is defined by default is the one for the equation counter,\newcommand
*{\glsxtrsectionlocfmt
}[2]{\S
#1 #2}
\glsxtrequationlocfmt
.) Make sure
that you have at least version 1.42 of glossaries-extra.
18.4. Multiple Glossaries[link]
See also sampleSort.tex in §18.5, which has three glossaries.
This document illustrates how to create an additional glossary type. This example adds the glossary to the table of contents, so an extra LaTeX run is required:
pdflatex sampleNtn makeglossaries sampleNtn pdflatex sampleNtn pdflatex sampleNtnNote that if you want to call makeindex explicitly instead of using the makeglossaries or makeglossaries-lite scripts then you need to call makeindex twice:
- 1.Create the
main
glossary (all on one line):makeindex -s sampleNtn.ist -t sampleNtn.glg -o sampleNtn.gls sampleNtn.glo
- 2.Create the secondary glossary (all on one line):
makeindex -s sampleNtn.ist -t sampleNtn.nlg -o sampleNtn.not sampleNtn.ntn
\newglossary
[nlg]{notation}{not}{ntn}{Notation}
This defines a glossary that can be identified with the label
“notation” with the default title “Notation”. The other
arguments are the file extensions required with Options 2 and 3. For those
two options, the glossaries package needs to know the input
and output files required by makeindex or xindy.
(The optional argument is the file extension of the indexing transcript file, which glossaries doesn’t need to know about (unless automake is used), but it writes the information to the aux file for the benefit of makeglossaries and makeglossaries-lite.)
If you switch to a different indexing option then these file extensions aren’t required, in which case it’s simpler to use the starred form:
\newglossary*
{notation}{Notation}
This example uses a label prefixing system to differentiate
between the different types of entries. (If you use
babel with a language that makes
:
(colon) active you will need to change the prefix.)
For example, the term
“set” is defined as:
\newglossaryentry
{gls:set}{name={set},
description={A collection of distinct objects}}
and the set notation is defined as:
Notice that the latter description contains\newglossaryentry
{not:set}{type={notation}, name={\ensuremath
{\mathcal
{S}}}, description={A\gls
{gls:set}},sort={S}}
\gls
. This means
you shouldn’t use \glsdesc
with this entry otherwise you will
end up with nested links.
The glossaries-extra package provides a command for use in within field values to prevent nested link text:
\glsxtrp
{ }{ }
There are convenient shortcuts for common fields:
\glsps
{ }
(for the short field) and
\glspt
{ }
(for the text
field). So the set notation definition can be modified:
This will stop the inner reference from causing interference if you use\newglossaryentry
{not:set}{type={notation}, name={\ensuremath
{\mathcal
{S}}}, description={A\glspt
{gls:set}},sort={S}}
\glsdesc
.
It will also suppress indexing within the glossary but will have a
hyperlink (if hyperref is used).
The glossaries-extra package provides a way of defining
commands like \gls
that automatically insert a prefix. For
example:
(there’s no point providing commands for plural or case-changing with symbols). Now\glsxtrnewgls
{not:}{\sym
}\glsxtrnewglslike
{gls:}{\term
}{\termpl
}{\Term
}{\Termpl
}
\gls
{not:set}
can be replaced
with \sym{set}
and \gls
{gls:set}
can be replaced with \term{set}
.
These two commands are primarily provided for the benefit of bib2gls as the information is written to the aux file. This allows bib2gls to recognise the custom commands if they have been used in the bib files. When combined with label-prefix and ext-prefixes (see below) this makes it much simpler to change the prefixes if necessary.
If you want to convert this document to use bib2gls, remember that you need the record or record=nameref option. For example:
\usepackage
[record,postdot,stylemods]{glossaries-extra}
As with earlier examples, convertgls2bib can be used to
convert the entry definitions into the required bib format.
You may prefer to split the entries into separate files according to
type. (Requires at least bib2gls v2.0.) This is useful
if you want to reuse a large database of
entries across multiple documents as it doesn’t lock you into using
a specific glossary. For example:
convertgls2bib --split-on-type --preamble-only sampleNtn.tex entries.bibThis will create a file called entries.bib that contains the entries that didn’t have a type assigned in the original file, such as:
@entry
{gls:set,
name={set},
description={A collection of distinct objects}
}
It will also create a file called notation.bib that
contains the entries that had the type set to
“notation” in the original file, such as:
Note that the type field has been removed. The above entry in the notation.bib file references a term in the entries.bib file. It’s possible to strip all the prefixes from the bib files and get bib2gls to automatically insert them. In which case, this cross-reference needs adjusting to indicate that it’s referring to an entry in another file. This can be done with one of the special ext prefixes: .@entry
{not:set, name={\ensuremath
{\mathcal
{S}}}, description={A\glspt
{gls:set}} }
The corresponding term in the entries.bib file is now:@entry
{set, name={\ensuremath
{\mathcal
{S}}}, description={A\glspt
{ext1.set}} }
@entry
{set,
name={set},
description={A collection of distinct objects}
}
Now you can replace \makeglossaries
with:
Remove all the\GlsXtrLoadResources
[src={entries},label-prefix={gls:}]\GlsXtrLoadResources
[src={notation},type=notation, label-prefix={not:},ext-prefixes={gls:}]
\newglossaryentry
definitions and replace
\printglossaries
with \printunsrtglossaries
.
Regardless of how many resource sets the document contains, only one bib2gls call is required:
pdflatex sampleNtn bib2gls sampleNtn pdflatex sampleNtn
You may notice that the ordering in the notations list has changed
from the original. This is because the sort field was
automatically removed by convertgls2bib, so the entries are
now sorted according to the name field (since they are
defined with @entry
). You can use your text editor’s search
and replace function to replace all instances of @entry
with @symbol
in the notations.bib file so that,
for example, the “set” definition becomes:
Now these@symbol
{set, name={\ensuremath
{\mathcal
{S}}}, description={A\glspt
{ext1.set}} }
@symbol
entries will be sorted according to their
label. (The original label in the bib file, not the
prefixed label.) This will put them in the same order as the original
document. (See the “Examples” chapter of
the bib2gls user manual for examples of varying the sorting
and also bib2gls gallery: sorting.)
This document illustrates how to define an entry that both appears in the list of acronyms and in the
main
glossary. To create the document do:
pdflatex sample-dual makeglossaries sample-dual pdflatex sample-dualThis defines a custom command
\newdualentry
that defines two entries
at once (a normal entry and an acronym). It uses \glsadd
to ensure
that if one is used then the other is automatically indexed:
A sample dual entry is defined with this command:\newcommand
*{\newdualentry
}[5][]{% % main entry:\newglossaryentry
{main-#2}{name={#4},% text={#3\glsadd
{#2}},% description={#5},% #1% additional options for main entry }% % acronym:\newacronym
{#2}{#3\glsadd
{main-#2}}{#4}% }
\newdualentry
{svm}% label
{SVM}% short form
{support vector machine}% long form
{Statistical pattern recognition technique}% description
This defines an acronym with the label “svm” that can be
referenced with \gls
{svm}
but it also defines an
entry with the label “main-svm”. This isn’t used in the document with
\gls
but it’s automatically added from the
\glsadd
{main-svm}
code in the short form of
“svm”.
For this trivial document, this kind of dual entry is redundant and
unnecessarily leads the reader down a trail, first to the list of
acronyms and from there the reader then has to go to the main
glossary to look up the description. It’s better to simply include
the description in the list of acronyms.
There are, however, uses for repeating entries across multiple lists.
For example, this user manual defines all described commands (such
as \gls
) as glossary entries. They appear in the
command summary (where the syntax is given
with a brief description and the principle location in the document
where the command is described) and they also appear in the
index (where just the name and location list
is shown).
If you want to switch over to bib2gls, first change to glossaries-extra:
\usepackage
[record,postdot,stylemods,acronym]{glossaries-extra}
Next, the definition needs to be converted to the bib
format required by bib2gls. If you do:
convertgls2bib --preamble-only sample-dual.tex entries.bibthen convertgls2bib will report the following:
Overriding default definition ofThis is because convertgls2bib has its own internal definition of\newdualentry
with custom definition. (Change\newcommand
to\providecommand
if you want\newdualentry
[options]{label}{short}{long}{description} converted to@dualabbreviationentry
.)
\newdualentry
, but if it encounters a new definition that
will override its default. If you want to retain
convertgls2bib’s definition (recommended) then just replace
\newcommand
with \providecommand
in the document source and
rerun convertgls2bib.
With \providecommand
, the new entries.bib file
created by convertgls2bib contains:
@dualabbreviationentry
{svm,
short={SVM},
description={Statistical pattern recognition technique},
long={support vector machine}
}
If \newcommand
is retained, it will instead contain:
In the first case, bib2gls creates two linked entries using its primary-dual mechanism. In the second case, bib2gls creates two entries that simply reference each other.@entry
{main-svm, name={support vector machine}, description={Statistical pattern recognition technique}, text={SVM\glsadd
{svm}} }@acronym
{svm, short={SVM\glsadd
{main-svm}}, long={support vector machine} }
Assuming that your entries.bib file just contains
@dualabbreviationentry
,
now replace \makeglossaries
with:
\GlsXtrLoadResources
[src={entries},% entries.bib type=acronym
,dual-type=main
,dual-prefix={main-}]
Then remove the definition of \newdualentry
and the entry
definition. Finally, replace \printglossaries
with
\printunsrtglossaries
.
The document build is:
pdflatex sample-dual bib2gls sample-dual pdflatex sample-dual
If, instead, your entries.bib file contains separate
@entry
and @acronym
, then you need:
If you need number lists, the document build is now\setabbreviationstyle
[acronym]{long-short}\GlsXtrLoadResources
[src={entries}]
pdflatex sample-dual bib2gls sample-dual pdflatex sample-dual bib2gls sample-dual pdflatex sample-dualand this time bib2gls complains about the use of
\glsadd
within the short and text fields as this can be
problematic. (The extra bib2gls and LaTeX calls are
to ensure the number list is up to date for the
“main-svm” entry, which can only be indexed with \glsadd
after “svm” has been defined.)
Dual entries make much more sense when one entry is for a glossary
with the description displayed but no number list (or just a
primary location), and the other is for the index without the
description but with a number list. This can be created by
replacing @dualabbreviationentry
with
@dualindexabbreviation
:
@dualindexabbreviation
{svm,
description={Statistical pattern recognition technique},
short={SVM},
long={support vector machine}
}
This can be mixed with @index
terms for example:
@index
{machlearn,
name={machine learning}
}
The document needs modifying:
See the bib2gls manual for further details.\documentclass
{article}\usepackage
[record,postdot, nostyles,stylemods=bookindex,list,% only want bookindex and list styles acronym]{glossaries-extra}\setabbreviationstyle
{long-short-desc}\GlsXtrLoadResources
[src={entries},% entries.bib dual-type=acronym
, label-prefix={idx.},dual-prefix={}, combine-dual-locations={primary}]\glsxtrnewglslike
{idx.}{\idx
}{\idxpl
}{\Idx
}{\Idxpl
}\begin{document}
\gls
{svm} and\idx
{machlearn}.\printunsrtglossary
[type=\acronymtype
,style=altlist]\printunsrtglossary
[style=bookindex,title={Index}]\end{document}
This document illustrates how to use the glossaries package to create English to French and French to English dictionaries. To create the document do:
pdflatex sample-langdict makeglossaries sample-langdict pdflatex sample-langdictThis example uses the nomain package option to prevent the creation of the
main
glossary. This means that the document
must provide its own glossaries:
This means that if you want to call makeindex explicitly you need to take these new extensions into account:\newglossary
[glg]{english}{gls}{glo}{English to French}\newglossary
[flg]{french}{flx}{flo}{French to English}
makeindex -s sample-langdict.ist -t sample-langdict.glg -o sample-langdict.gls sample-langdict.glo makeindex -s sample-langdict.ist -t sample-langdict.flg -o sample-langdict.flx sample-langdict.floAs with the previous example, this document provides a custom command that defines two related entries:
This has the syntax:\newcommand
*{\newword
}[4]{%\newglossaryentry
{en-#1}{type={english},name={#2},description={#3 #4}}%\newglossaryentry
{fr-#1}{type={french},name={#3 #4},text={#4},sort={#4}, description={#2}}% }
\newword
{ }{ }{ }{ }
(Note that this trivial example doesn’t take plurals into account.)
This custom command will define two terms with labels en-
(for
the English term) and fr-
(for the French term).
So
\newword
{cat}{cat}{le}{chat}
is equivalent to:
\newglossaryentry
{en-cat}{type={english},name={cat},description={le chat}}\newglossaryentry
{fr-cat}{type={french},name={le chat},sort={chat}, description={cat}}
Unlike the previous example (sample-dual.tex), there’s no link
between these two entries. If the document only uses
, then the “en-cat” entry will appear in the
english glossary but the “fr-cat” entry won’t
appear in the french one.
\gls
{en-cat}
If you want to switch to bib2gls then you first need to convert the document so that it uses glossaries-extra, but include the prefix option to ensure that glossaries-prefix is also loaded:
\usepackage
[record,prefix,postdot,stylemods,nomain]{glossaries-extra}
You don’t need to worry about file extensions now, so it’s simpler
to use the starred \newglossary*
:
Next the entries need to be converted to the bib format required by bib2gls:\newglossary
*{english}{English to French}\newglossary
*{french}{French to English}
convertgls2bib --preamble-only --ignore-type sample-langdict.tex entries.bibThis creates the file entries.bib that contains entries defined like:
(Note that the sort and type fields have been omitted.)@entry
{en-cat, name={cat}, description={le chat} }@entry
{fr-cat, name={le chat}, description={cat}, text={chat} }
This would be more flexible, and much briefer, if these entries were defined using bib2gls’s dual entry system combined with the glossaries-prefix package:
@dualentry
{cat,
name={chat},
description={cat},
prefix={le},
prefixplural={les}
}
Similarly for the “chair” entry:
@dualentry
{chair,
name={chaise},
description={chair},
prefix={la},
prefixplural={les}
}
With @dualentry
, the English and French terms are now
automatically linked from bib2gls’s point of view. If only one
is referenced in the document, the other will also be added by default.
Now that the determiner has been moved out of the description, it won’t show in the glossary. However, it’s possible to include it by providing a command to encapsulate the description (which can also apply the language change as well).
\GlsXtrLoadResources
[src={entries},% entries.bib append-prefix-field={space}, category={same as type},dual-category={same as type}, label-prefix={en-},dual-prefix={fr-}, type=english,dual-type=french, sort=en,dual-sort=fr]\newcommand
{\FrEncap
}[1]{%\foreignlanguage
{french}{\glsentryprefix
{\glscurrententrylabel
}#1}}\newcommand
{\EnEncap
}[1]{\foreignlanguage
{english}{#1}}\glssetcategoryattribute
{english}{glossnamefont}{EnEncap}\glssetcategoryattribute
{english}{glossdescfont}{FrEncap}\glssetcategoryattribute
{french}{glossnamefont}{FrEncap}\glssetcategoryattribute
{french}{glossdescfont}{EnEncap}
Remember to remove \makeglossaries
, the definition of \newword
and
the entry definitions from the document preamble, and
replace \printglossary
with:
\printunsrtglossary
Other refinements that you might like to make include using
\glsxtrnewglslike
so you don’t have to worry about the label
prefix (“en-” and “fr-”). See the glossaries-extra
manual for further details.
This document uses the glossaries package to create both a glossary and an index. This requires two makeglossaries (or makeglossaries-lite) calls to ensure the document is up to date:
pdflatex sample-index makeglossaries sample-index pdflatex sample-index makeglossaries sample-index pdflatex sample-index
18.5. Sorting[link]
This document illustrates how you can hook into the standard sort mechanism to adjust the way the sort key is set. This requires an additional run to ensure the table of contents is up-to-date:
pdflatex samplePeople makeglossaries samplePeople pdflatex samplePeople pdflatex samplePeopleThis provides two commands for typesetting a name:
where the first argument contains the forenames and the second is the surname. The first command is the one required for sorting the name and the second is the one required for displaying the name in the document. A synonym is then defined:\newcommand
{\sortname
}[2]{#2, #1}\newcommand
{\textname
}[2]{#1 #2}
This command defaults to the display name command (\let
\name
\textname
\textname
)
but is temporarily redefined to the sort name command (\sortname
)
within the sort field assignment hook:
The people are defined using the custom\renewcommand
{\glsprestandardsort
}[3]{%\let
\name
\sortname
\edef
#1{\expandafter
\expandonce
\expandafter
{#1}}%\let
\name
\textname
\glsdosanitizesort
}
\name
command:
Since\newglossaryentry
{joebloggs}{name={\name
{Joe}{Bloggs}}, description={\nopostdesc
}}
\name
is temporarily changed while the sort key
is being assigned, the sort value for this entry ends up as
“Bloggs, Joe”, but the name appears in the document as “Joe Bloggs”.
If you want to use bib2gls, you first need to convert the document to use glossaries-extra but make sure you include the record option:
\usepackage
[record,stylemods,style=listgroup]{glossaries-extra}
Next it’s necessary to convert the entry definitions to the
bib format required by bib2gls. You can simply do:
convertgls2bib --preamble-only samplePeople people.bibwhich will create a file called people.bib that contains definitions like:
However, you may prefer to use the --index-conversion (-i) switch:@entry
{joebloggs, name={\name
{Joe}{Bloggs}}, description={\nopostdesc
} }
convertgls2bib -i --preamble-only samplePeople people.bibThis will discard the description field and use
@index
instead of @entry
if the
description is either empty or simply set to \nopostdesc
or
\glsxtrnopostpunc
. The people.bib file now
contains definitions like:
Regardless of which approach you used to create the bib file, you now need to edit it to provide a definition of the custom@index
{joebloggs, name={\name
{Joe}{Bloggs}} }
\name
command for bib2gls’s use:
Note the use of@preamble
{"\providecommand
{\name
}[2]{#2, #1}"}
\providecommand
instead of \newcommand
.
In the document (samplePeople.tex) you now need to
delete \makeglossaries
, the definitions of \sortname
,
\textname
, \name
, \glsprestandardsort
, and all the entry
definitions. Then add the following to the document preamble:
Next, use your text editor’s search and replace function to substitute all instances of\newcommand
{\name
}[2]{#1 #2}\GlsXtrLoadResources
[src={people}]
\glsentrytext
in the chapter
headings with \glsfmttext
. For example:
Finally, replace\chapter
{\glsfmttext
{joebloggs}}
\printglossaries
with:
\printunsrtglossaries
The document build is now:
pdflatex samplePeople bib2gls samplePeople pdflatex samplePeople pdflatex samplePeopleThe third LaTeX call is required to ensure that the PDF bookmarks are up to date, as the entries aren’t defined until after the bib2gls run (which is why you have to use
\glsfmttext
instead of \glsentrytext
).
This again leads to a list sorted by surname. The reason this works
is because bib2gls only sees the definition of \name
provided in @preamble
, but the document uses the definition
of \name
provided before \GlsXtrLoadResources
. The use of
\providecommand
in @preamble
prevents \name
from
being redefined within the document.
See also the “Examples” chapter of the bib2gls user manual, which provides another “people” example and Aliases.
This is another document that illustrates how to hook into the standard sort mechanism. An additional run is required to ensure the table of contents is up-to-date:
pdflatex sampleSort makeglossaries sampleSort pdflatex sampleSort pdflatex sampleSortThis document has three glossaries (
main
, acronym
and a custom notation
), so if you want to use
makeindex explicitly you will need to have three
makeindex calls with the appropriate file extensions:
pdflatex sampleSort makeindex -s sampleSort.ist -t sampleSort.alg -o sampleSort.acr sampleSort.acn makeindex -s sampleSort.ist -t sampleSort.glg -o sampleSort.gls sampleSort.glo makeindex -s sampleSort.ist -t sampleSort.nlg -o sampleSort.not sampleSort.ntn pdflatex sampleSort pdflatex sampleSortIt’s much simpler to just use makeglossaries or makeglossaries-lite.
In this example, the sort hook is adjusted to ensure the list of notation is sorted according to the order of definition. A new counter is defined to keep track of the entry number:
\newcounter
{sortcount}
The sort hook is then redefined to increment this counter and assign
the sort key to that numerical value, but only for the
notation
glossary. The other two glossaries have their sort
keys assigned as normal:
This means that makeindex will sort the notation in numerical order.\renewcommand
{\glsprestandardsort
}[3]%\ifdefstring
{#2}{notation}% {%\stepcounter
{sortcount}%\edef
#1{\glssortnumberfmt
{\arabic
{sortcount}}}% }% {%\glsdosanitizesort
}%
If you want to convert this document to use glossaries-extra, a much simpler approach is available with its hybrid method. First change the package loading line to:
\usepackage
[postdot,stylemods,acronym]{glossaries-extra}
Either remove \setacronymstyle
and replace all instances of
\newacronym
with \newabbreviation
or replace:
\setacronymstyle
{long-short}
with:
\setabbreviationstyle
[acronym]{long-short}
The custom counter and redefinition of \glsprestandardsort
can now
be removed. The file extensions for the custom notation
glossary are no longer relevant so the glossary definition can be
changed to:
\newglossary*
{notation}{Notation}
The \makeglossaries
command now needs to be adjusted to
indicate which glossaries need to be processed by makeindex:
Finally,\makeglossaries
[main
,acronym
]
\printglossaries
needs to be replaced with:
Note that the notation glossary, which hasn’t been listed in the optional argument of\printglossary
\printacronyms
\printnoidxglossary
[type=notation,sort=def]
\makeglossaries
, must be displayed with \printnoidxglossary
.
This means that makeindex only needs to process the
main
and acronym
glossaries. No actual sorting is
performed for the notation
glossary because, when used with
sort=def, \printnoidxglossary
simply
iterates over the list of entries that have been indexed.
The document build doesn’t need the third LaTeX call now (since none of the glossaries extend beyond a page break):
pdflatex sampleSort makeglossaries sampleSort pdflatex sampleSortThis time makeglossaries will include the message:
only processing subset 'This means that although makeglossaries has noticed themain
,acronym
'
notation
glossary, it will be skipped.
If you are explicitly calling makeindex then you need to drop the call
for the notation
glossary:
pdflatex sampleSort makeindex -s sampleSort.ist -t sampleSort.alg -o sampleSort.acr sampleSort.acn makeindex -s sampleSort.ist -t sampleSort.glg -o sampleSort.gls sampleSort.glo pdflatex sampleSort
If you prefer to use bib2gls, the package loading line needs to be changed to:
\usepackage
[record,postdot,stylemods,acronym]{glossaries-extra}
Next the entry definitions need to be convert to the bib
format required by bib2gls.
For this example, it’s simpler to split the entries into different files according to the glossary type. This can be done with the --split-on-type or -t switch:
convertgls2bib -t --preamble-only sampleSort.tex entries.bibThis will create three files:
- entries.bib
-
This contains the entries that were
defined with
\newglossaryentry
. For example:@entry
{gls:set, name={set}, description={A collection of distinct objects} } - abbreviations.bib
-
This contains the entries that
were defined with
\newacronym
. For example:
If you changed@acronym
{zfc, short={ZFC}, long={Zermelo-Fraenkel set theory} }\newacronym
to\newabbreviation
then@abbreviation
will be used instead:@abbreviation
{zfc, short={ZFC}, long={Zermelo-Fraenkel set theory} } - notation.bib
-
This contains the entries that were
defined with type={notation}. For example:
You may prefer to replace@entry
{not:set, name={$\mathcal
{S}$}, description={A set}, text={\mathcal
{S}} }@entry
with@symbol
in this file.
notation
glossary
(\newglossary
), add:
% abbreviation style must be set first:Delete the remainder of the document preamble (\setabbreviationstyle
[acronym]{long-short}\GlsXtrLoadResources
[src={entries,abbreviations}]\GlsXtrLoadResources
[src={notation},% notation.bib type=notation,sort=unsrt]
\makeglossaries
and entry
definitions).
Finally, replace the lines that display the glossaries with:
\printunsrtglossaries
The build process is now:
pdflatex sampleSort bib2gls sampleSort pdflatex sampleSort
In this case, I have one resource command that processes two
glossaries (main
and acronym
) at the same time.
The entries in these glossaries are ordered alphabetically.
The second resource command processes the notation
glossary but
the entries in this glossary aren’t sorted (and so will appear in
the order of definition within the bib file).
See also sampleNtn.tex, bib2gls gallery: sorting and the bib2gls user manual for more examples.
18.6. Child Entries[link]
This document illustrates some of the basics, including how to create child entries that use the same name as the parent entry. This example adds the glossary to the table of contents and it also uses
\glsrefentry
, so an extra LaTeX
run is required:
pdflatex sample makeglossaries sample pdflatex sample pdflatex sampleYou can see the difference between word and letter ordering if you add the package option order=letter. (Note that this will only have an effect if you use makeglossaries or makeglossaries-lite. If you use makeindex explicitly, you will need to use the -l switch to indicate letter ordering.)
One of the entries has its name encapsulated with a semantic command:
This means that this entry needs to have the sort key set otherwise makeindex will assign it to the “symbol” group, since it starts with a backslash (which makeindex simply treats as punctuation).\newcommand
{\scriptlang
}[1]{\textsf
{#1}}\newglossaryentry
{Perl}{name={\scriptlang
{Perl}},sort={Perl}, description={A scripting language}}
The homograph entries “glossary” and “bravo” are defined as
sub-entries that inherit the name from the parent entry. The parent
entry doesn’t have a description, but with the default
nopostdot=false setting this will lead to a spurious dot.
This can be removed by adding \nopostdesc
to the description,
which suppresses the post-description hook for that entry.
Since the child entries have the same name as the parent, this means that the child entries will have duplicate sort values unless the default is changed with the sort key:
(Remember that the entries are sorted hierarchically.) This will place “glossarylist” before “glossarycol”, but both will come immediately after their parent “glossary” entry.\newglossaryentry
{glossary}{name={glossary}, description={\nopostdesc
},plural={glossaries}}\newglossaryentry
{glossarycol}{ description={collection of glosses}, sort={2}, parent={glossary}% parent label }\newglossaryentry
{glossarylist}{ description={list of technical words}, sort={1}, parent={glossary}% parent label }
If you switch to using glossaries-extra, remember that the default package options are different:
\usepackage
[postdot,stylemods,style=treenonamegroup,order=word,
subentrycounter]{glossaries-extra}
You may now want to consider replacing \nopostdesc
in the
descriptions with \glsxtrnopostpunc
(using your
text editor’s search and replace function). This suppresses the
post-description punctuation but not the category post-description
hook.
You may have noticed that some of the descriptions include the plural form, but it’s not done very consistently. For example:
which has the parenthetical material at the start of the description with emphasis,\newglossaryentry
{cow}{name={cow}, plural={cows},% not required as this is the default user1={kine}, description={(\emph
{pl.}\
cows,\emph
{archaic} kine) an adult female of any bovine animal} }
which has the parenthetical material at the end of the description without emphasis even though it’s a regular plural,\newglossaryentry
{bravocry}{ description={cry of approval (pl.\
bravos)}, sort={1}, parent={bravo} }
which has the parenthetical material at the end of the description without emphasis, and\newglossaryentry
{bravoruffian}{ description={hired ruffian or killer (pl.\
bravoes)}, sort={2}, plural={bravoes}, parent={bravo}}
which doesn’t show the plural in the description.\newglossaryentry
{glossary}{name={glossary}, description={\nopostdesc
}, plural={glossaries}}
With glossaries-extra, you can remove this parenthetical material and implement it using the category post-description hook instead. For example, the above definitions become:
The post-description hook for the general category can now be set:\newglossaryentry
{cow}{name={cow}, user1={kine}, description={an adult female of any bovine animal} }\newglossaryentry
{bravocry}{ description={cry of approval}, sort={1}, parent={bravo} }\newglossaryentry
{bravoruffian}{ description={hired ruffian or killer}, sort={2}, plural={bravoes}, parent={bravo}}\newglossaryentry
{glossary}{name={glossary}, description={\glsxtrnopostpunc
}, plural={glossaries}}
(If you try this example out, notice the difference for the “glossary” entry if you use\glsdefpostdesc
{general}{% % Has the user1 key been set?\glsxtrifhasfield
{useri}{\glscurrententrylabel
}% {\space
(\emph
{pl.}\
\glsentryplural
{\glscurrententrylabel
},\emph
{archaic}\glscurrentfieldvalue
)% }% {% % The user1 key hasn't been set. Is the plural the same as the % singular form with the plural suffix appended?\GlsXtrIfXpFieldEqXpStr
{plural}{\glscurrententrylabel
}% {\glsentrytext
{\glscurrententrylabel
}\glspluralsuffix
}% {% % Sibling check with bib2gls (see below) }% {% % The plural isn't the default. Does this entry have a parent?\ifglshasparent
{\glscurrententrylabel
} {% % This entry has a parent. % Are the plurals for the child and parent the same?\GlsXtrIfXpFieldEqXpStr
{plural}{\glscurrententrylabel
}% {\glsentryplural
{\glsentryparent
{\glscurrententrylabel
}}}% {}% child and parent plurals the same {%\space
(\emph
{pl.}\
\glsentryplural
{\glscurrententrylabel
})% }% } {\space
(\emph
{pl.}\
\glsentryplural
{\glscurrententrylabel
})}% }% }% }
\nopostdesc
and then
replace it with \glsxtrnopostpunc
.)
See the glossaries-extra user manual for further details and
also glossaries-extra and bib2gls: An Introductory Guide.
The “bravo” homographs are an oddity where the singular form is identical but the plural is different (“bravos” and “bravoes”). In the original, both descriptions included the plural term. The above modifications drop the display of the regular “bravos” plural (for the “bravocry” term) and only show the “bravoes” plural (for the “bravoruffian” term). In this particular case it might be useful to show the regular plural in order to highlight the difference.
While it’s straightforward to access an entry’s parent label (with
\glsentryparent
) it’s much harder to access entry’s children or
siblings. The \ifglshaschildren
command has to iterate over all
entries to determine if any have a parent that matches the given
label. This is obviously very time-consuming if you have a large
database of entries. It also doesn’t provide a way of determining
whether or not the child entries have been indexed.
With bib2gls, it’s possible to save this information with the save-child-count and save-sibling-count, which not only save the total but also save the child or sibling labels in an etoolbox internal list. This makes the information much faster to access and also only includes the labels of those entries that have actually been indexed.
In the above, the comment line:
% Sibling check with bib2gls (see below)indicates where to put the extra code. If you switch to bib2gls and make sure to use save-sibling-count then you can insert the following code in the block above where that comment is:
This uses a custom handler that’s defined as follows:\GlsXtrIfFieldNonZero
{siblingcount}{\glscurrententrylabel
}% {% siblingcount field value non-zero\glsxtrfieldforlistloop
% iterate over internal list {\glscurrententrylabel
} % entry label {siblinglist} % label of field containing list {\siblinghandler
} % loop handler }% {}% siblingcount field value 0 or empty or missing
The\newcommand
{\siblinghandler
}[1]{%\GlsXtrIfXpFieldEqXpStr
*{plural}{\glscurrententrylabel
}% {\glsentryplural
{#1}}% {}% current entry's plural same as sibling's plural {%\space
(\emph
{pl.}\
\glsentryplural
{\glscurrententrylabel
})%\listbreak
}% }
\listbreak
command is provided by etoolbox and is used
for prematurely exiting a loop. The handler tests if the sibling’s
plural field is identical to the current entry’s plural
field. If they are the same, it does nothing. If they are different,
it displays the current entry’s plural and breaks the loop.
Note that this assumes that the parent entry hasn’t had the plural form explicitly set to “bravoes” instead of the default “bravos”. In that case, the parent entry would show the plural but the “bravoruffian” child entry wouldn’t show the plural (since this case would led to the empty code block identified with the comment “child and parent plurals the same”). The “bravoes” plural form would instead be shown for the parent, which wouldn’t look right.
If you don’t use bib2gls or if you use it without the save-sibling-count resource option then the sibling information won’t be available.
In order to switch to using bib2gls, it’s first necessary to switch to using glossaries-extra (as above). Remember that the record option is required:
\usepackage
[record,postdot,stylemods,style=treenonamegroup,
subentrycounter]{glossaries-extra}
Next the entry definitions need to be converted to the
bib format required by bib2gls. This can be done
with convertgls2bib:
convertgls2bib --preamble-only sample.tex entries.The semantic command may be moved to the bib file’s preamble to ensure it’s defined:
@preamble
{"\providecommand
{\scriptlang
}[1]{\textsf
{#1}}"}
The sort field typically shouldn’t be set when using
bib2gls, so convertgls2bib strips it.
If the sort field is missing, bib2gls will obtain it
from the sort fallback for that entry type. In this case,
@entry
has the name field as the sort fallback.
If this is also missing then its value is obtained from the parent’s
name field (see bib2gls gallery: sorting for other examples).
Therefore the “Perl” entry is simply defined as:
This isn’t a problem for bib2gls. In this case, the command has been provided in the@entry
{Perl, name={\scriptlang
{Perl}}, description={A scripting language} }
@preamble
, but bib2gls
strips font information so the sort value becomes “Perl”.
If the definition isn’t placed in @preamble
then
bib2gls will simply ignore the command (as xindy does)
so the sort value will still end up as “Perl”.
The homograph entries have also had their sort fields omitted:
@entry
{glossarycol, parent={glossary}, description={collection of glosses} }@entry
{glossarylist, parent={glossary}, description={list of technical words} }
This means that the sort value for both these child entries is “glossary”. When bib2gls encounters identical sort values it acts according to its identical-sort-action setting. The default action is to sort by the label using a simple string comparison. In this case, it would put “glossarycol” before “glossarylist”. In the original document, the sort value was manually chosen to ensure that the entries are ordered according to first use. This ordering can easily be obtained by changing bib2gls’s identical sort action (requires at least bib2gls v2.0):
\GlsXtrLoadResources
[src={entries},identical-sort-action=use]
This command should replace \makeglossaries
. If you want the
sibling information (see earlier), then you need to remember to add
save-sibling-count to the list of options.
Note that this is a better solution than in the original example. If I edit the document so that “glossarycol” is used first, then the ordering will be updated accordingly, but with the original example, the sort keys would need to be manually changed.
The remainder of the document preamble (that is, the definition of
\scriptlang
and all the entry definitions) should now be
removed.
Finally, replace \printglossaries
with \printunsrtglossaries
.
The document build is now:
pdflatex sample bib2gls --group sample pdflatex sample pdflatex sampleNote use of the --group (or -g) switch, which is needed to support the treenonamegroup style. The third LaTeX call is needed because the document contains
\glsrefentry
.
Note that you can’t use the order=letter package option with bib2gls. Instead use the break-at=none resource option:
\GlsXtrLoadResources
[src={entries},identical-sort-action=use,
break-at=none
]
This document is like sample.tex, above, but uses the inline glossary style to put the glossary in a footnote. The document build is:
pdflatex sample-inline makeglossaries sample-inline pdflatex sample-inline pdflatex sample-inlineIf you want to convert this document to glossaries-extra, follow the same procedure as above. If you want to use bib2gls then you don’t need the --group switch since no letter groups are required.
This document illustrates a hierarchical glossary structure where child entries have different names to their corresponding parent entry. To create the document do:
pdflatex sampletree makeglossaries sampletree pdflatex sampletreeThe document uses the alttreehypergroup glossary style, which needs to know the widest name for each hierarchical level. This has been assigned manually in the document preamble with
\glssetwidest
:
(Level 0 is the top-most level. That is, entries that don’t have a parent.) It’s possible to get glossaries to compute the widest top-level entry with\glssetwidest
{Roman letters} % level 0 widest name\glssetwidest
[1]{Sigma} % level 1 widest name
\glsfindwidesttoplevelname
but this
will iterate over all top-level entries, regardless of whether or
not they appear in the glossary. If you have a large database of
entries, this will firstly take time and secondly the width may be
too large due to an unindexed entry with a big name.
This sample document doesn’t require any of the tabular styles so I’ve prevented those packages from being loaded with nolong and nosuper. The reduces the overall package loading and reduces the potential of package conflict.
\usepackage
[style=alttreehypergroup,nolong,nosuper]
{glossaries}
(This example glossary is actually better suited for one of the
topic styles provided with glossary-topic, see below.)
This is obviously a contrived example since it’s strange to have the symbol names (such as “Sigma”) in the glossary. The purpose is to demonstrate the alttreehypergroup with an entry that’s noticeably wider than the others in the same hierarchical level. A more sensible document would have the symbol in the name key.
If you want to switch to glossaries-extra, then you can instead use a combination of nostyles and stylemods:
\usepackage
[style=alttreehypergroup,postdot,nostyles,
stylemods=tree]{glossaries-extra}
The stylemods package not only patches the original styles
provided by the base glossaries package (such as
glossary-tree used in this example) but also provides extra
helper commands. In this case, it provides additional commands to
calculate the widest name. For example, instead of manually setting
the widest entry with \glssetwidest
, you could add the
following before the glossary:
This will only take into account the entries that have actually been used in the document, but it can still be time-consuming if you have a large number of entries.\glsFindWidestUsedTopLevelName
\glsFindWidestUsedLevelTwo
This example document is using top-level entries for topics without
descriptions. This means that the descriptions simply contain
\nopostdesc
to prevent the post-description punctuation from
being automatically inserted. For example:
With glossaries-extra, you can convert this to\newglossaryentry
{greekletter}{name={Greek letters}, text={Greek letter}, description={\nopostdesc
}}
\glsxtrnopostpunc
which will prevent the post-description
punctuation without interfering with the category post-description
hook.
In order to distinguish between the child entries, which are symbols, and the parent entries, which are topics, it’s useful to give these two different types of entries different categories. The topics can use the default general category, but the symbol entries can be assigned to a different category. The value of the category key must be a label. For example:
\newglossaryentry
{C}{name={C},
description={Euler's constant},
category={symbol},
parent={romanletter}}
There is some redundancy caused by a parenthetical note after the first use in some of the symbol entries. For example:
With glossaries-extra this can be dealt with through the category post-link hook:\newglossaryentry
{pi}{name={pi}, text={\ensuremath
{\pi
}}, first={\ensuremath
{\pi
} (lowercase pi)}, description={Transcendental number}, parent={greekletter}}
The parenthetical material is now stored in the user1 key. For example:\glsdefpostlink
{symbol}{%\glsxtrifwasfirstuse
{% first use\glsxtrifhasfield
{useri}{\glslabel
}% { (\glscurrentfieldvalue
)}{}% }% {}% not first use }
The category post-description link is also set to ensure that the symbol is displayed after the description in the glossary:\newglossaryentry
{sigma}{name={Sigma}, text={\ensuremath
\Sigma
}, user1={uppercase sigma}, description={Used to indicate summation}, parent={greekletter}}
These modifications only affect entries with the category set to symbol.\glsdefpostdesc
{symbol}{\space
($\glsentrytext
{\glscurrententrylabel
}$)}
With glossaries-extra, it’s now possible to use the topic styles provided with the glossary-topic package:
\usepackage
[style=topic,postdot,nostyles,stylemods={tree,topic}]
{glossaries-extra}
The topic style is designed for this kind of hierarchy
where all the top-level entries don’t have descriptions. This means
that the \nopostdesc
and \glsxtrnopostpunc
commands aren’t
required. The top-level entries can simply be defined as:
I’ve now loaded both the glossary-tree and glossary-topic packages (via stylemods={tree,topic}). The glossary-topic package can be used without glossary-tree, in which case it will behave more like the normal tree rather than alttree styles (but with different indentation and no description in the top-level). However, if you use\newglossaryentry
{greekletter}{name={Greek letters}, text={Greek letter}, description={}}\newglossaryentry
{romanletter}{name={Roman letters}, text={Roman letter}, description={}}
\glssetwidest
(provided by
glossary-tree) then the topic style will behave
more like alttree.
Since there’s no description for the top-level entries, the topic style ignores the widest name setting for the top-level, so I can just have the level 1 setting:
\glssetwidest
[1]Sigma
If you want to convert this document so that it uses bib2gls, you first need to convert it to using glossaries-extra, as described above, but remember that you now need the record option.
\usepackage
[record,style=topic,postdot,nostyles,stylemods={tree,topic}]
{glossaries-extra}
Next convert the entries to the bib format required by
bib2gls:
convertgls2bib --preamble-only sampletree.tex entries.bibNow replace
\makeglossaries
with:
\GlsXtrLoadResources
[src=entries,set-widest]
I’ve used the set-widest option here to get
bib2gls to compute the widest name. (Obviously, it can only do
this if it can correctly interpret any commands contained in the
name field.)
This means that the \glssetwidest
commands can now be removed
completely. All the \newglossaryentry
commands also need to be removed from
the document preamble. Finally, \printglossaries
needs to be
replaced with \printunsrtglossaries
. The document build is now:
pdflatex sampletree bib2gls sampletree pdflatex sampletree
This produces the same result as with just glossaries-extra and makeglossaries. However, there are some modifications that can be made to the bib file to make it neater.
The top-level entries are defined as:
This is a direct translation from the@entry
{greekletter, name={Greek letters}, description={}, text={Greek letter} }@entry
{romanletter, name={Roman letters}, description={}, text={Roman letter} }
\newglossaryentry
commands
(after switching to the topic style). There’s a more
appropriate entry type:
The@indexplural
{greekletter, text={Greek letter} }@indexplural
{romanletter, text={Roman letter} }
@indexplural
entry type doesn’t require the
description and will set the name field to the
same as the plural field. Since the plural field
hasn’t been set it’s obtained by appending “s” to the
text field.
Now let’s assume that the symbol entries are defined in a more rational manner, with the actual symbol in the name field. For example:
The category post-description hook (provided with@entry
{sigma, user1={uppercase sigma}, parent={greekletter}, description={Used to indicate summation}, name={\ensuremath
{\Sigma
}}, category={symbol} }@entry
{C, parent={romanletter}, name={\ensuremath
{C}}, description={Euler's constant}, category={symbol} }
\glsdefpostdesc
) should now be removed from the document.
If you make these changes and rebuild the document, you’ll find that
the order has changed. Now the “sigma” entry is before the
“pi” entry. This is because bib2gls is obtaining the
sort values from the name field, which is the sort
fallback for @entry
. This means that the sort values end up
as Σ and π (bib2gls recognises the commands
\Sigma
and \pi
and converts them to the Unicode characters
0x1D6F4 and 0x1D70B).
If you change @entry
to @symbol
then you will once
again get the order from the original example (“pi” before
“Sigma”). This is because the sort fallback for
@symbol
is the label not the name. (Remember that
the sort fallback is only used if the sort field isn’t
set. If you explicitly set the sort field then no fallback
is required. See bib2gls gallery: sorting.)
You can further tidy the bib file by removing the category fields. For example:
You can then assign the category in the resource set:@symbol
{sigma, user1={uppercase sigma}, parent={greekletter}, description={Used to indicate summation}, name={\ensuremath
{\Sigma
}} }
\GlsXtrLoadResources
[src=entries,set-widest,category={same as entry}]
This means that all the entries defined with @symbol
will
have the category set to symbol and all the
entries defined with @indexplural
will have the
category set to indexplural. (Only the
symbol category is significant in this example.)
You can make the bib files even more flexible by introducing field and entry aliases with field-aliases and entry-type-aliases. See the bib2gls manual for further details.
18.7. Cross-Referencing[link]
This document illustrates how to cross-reference entries in the glossary.
pdflatex sample-crossref makeglossaries sample-crossref pdflatex sample-crossrefThe document provides a command
\alsoname
to produce some fixed text, which can be
changed as appropriate (usually within a language hook):
I’ve used\providecommand
{\alsoname
}{see also}
\providecommand
as some packages define this command.
This is used to create a “see also” cross-reference with the
see key:
\newglossaryentry
{apple}{name={apple},description={firm, round fruit}, see={[\alsoname
]{pear}}}\newglossaryentry
{marrow}{name={marrow}, description={long vegetable with thin green skin and white flesh}, see={[\alsoname
]courgette}}
Note that “marrow” is included in the glossary even though it
hasn’t been referenced in the text. This is because the
see key automatically triggers \glssee
which indexes
the term. This behaviour is intended for documents where only the
terms that are actually required in the document are defined. It’s
not suitable for a large database of terms shared across multiple
documents that may or may not be used in a particular document. In
that case, you may want to consider using glossaries-extra
(see below).
This example is quite simple to convert to glossaries-extra. If you want the dot after the description, you need the nopostdot=false or postdot package option. You may also want to consider using the stylemods option.
In order to prevent the “marrow” entry from being automatically being added to the glossary as a result of the cross-reference, you can use autoseeindex=false to prevent the automatic indexing triggered by the see key (or the seealso key provided by glossaries-extra).
\usepackage
[autoseeindex=false,postdot,stylemods]{glossaries-extra}
The document build is the same, but now the “marrow” and
“zucchini” entries aren’t present in the document.
Note that the “fruit” entry is still included even though it
hasn’t been used in the document. This is because it was explicitly
indexed with \glssee
not via the see key.
The entries that contains see[\alsoname
]
can be converted to use the seealso key:
(The provided\newglossaryentry
{apple}{name={apple},description={firm, round fruit}, seealso={pear}}\newglossaryentry
{marrow}{name={marrow}, description={long vegetable with thin green skin and white flesh}, seealso={courgette}}
\alsoname
definition may be removed.)
The original example redefines the cross-referencing format to use small caps:
This will still produce the desired effect with glossaries-extra for this simple example but, as with sampleAcrDesc.tex, this redefinition isn’t necessary if you have at least glossaries-extra v1.42.\renewcommand
{\glsseeitemformat
}[1]{\textsc
{\glsentryname
{#1}}}
If you want to switch to bib2gls then you first need to switch to glossaries-extra, as described above, but you now need the record option but no longer need the autoseeindex=false option:
\usepackage
[record,postdot,stylemods]{glossaries-extra}
Next the entry definitions need to be converted to the
bib format required by bib2gls.
convertgls2bib sample-crossref.tex entries.bibIf you have at least v2.0 then convertgls2bib will absorb the cross-referencing information supplied by:
\glssee
{fruit}{pear,apple,banana}
into the “fruit” definition:
@entry
{fruit,
see={pear,apple,banana},
name={fruit},
description={sweet, fleshy product of plant containing seed}
}
Now remove \makeglossaries
and all the entry definition commands
(including \glssee
from the document preamble) and add:
\GlsXtrLoadResources
[src=entries]
Finally, replace \printglossaries
with
\printunsrtglossaries
. The document build is now:
pdflatex sample-crossref bib2gls sample-crossref pdflatex sample-crossrefThe glossary now contains: apple, banana, courgette and pear. Note that it doesn’t contain fruit, zucchini or marrow.
Now change the selection criteria:
\GlsXtrLoadResources
[src=entries,
selection={recorded and deps and see}]
The glossary now includes fruit, zucchini and marrow.
The fruit and zucchini use the see key which is a simple redirection for the reader. There’s no number list for either of these entries. Whereas marrow uses the seealso key, which is typically intended as a supplement to a number list but in this case there are no locations as marrow hasn’t been used in the text.
With at least v2.0, there’s an alternative:
\GlsXtrLoadResources
[src=entries,
selection={recorded and deps and see not also}]
In this case, the glossary includes fruit and zucchini but not marrow.
18.8. Custom Keys[link]
This document illustrates how add custom keys (using
\glsaddkey
). There are two custom keys ed, where
the default value is the text field with “ed” appended,
and ing, where the default value is the text
field with “ing” appended. Since the default value in both cases
references the text field, the starred version
\glsaddkey*
is required to ensure that the
default value is expanded on definition if no alternative has been provided.
The entries are then defined as follows:
\newglossaryentry
{jump}{name={jump},description={}}\newglossaryentry
{run}{name={run}, ed={ran}, ing={running}, description={}}\newglossaryentry
{waddle}{name=waddle, ed={waddled}, ing={waddling}, description={}}
Each custom key is provided a set of commands analogous to
\glsentrytext
, that allows the key value to be accessed, and
\glstext
that allows the key value to be access with indexing
and hyperlinking (where applicable).
If you find yourself wanting to create a lot of custom keys that
produce minor variations of existing keys (such as different tenses)
you may find it simpler to just use \glsdisp
. When editing the
document source, it’s usually simpler to read:
The dog \glsdisp
{jump}{jumped} over the duck.
than
The dog \glsed
{jump} over the duck.
If you want to convert this document to use bib2gls, you first need to switch to glossaries-extra, but remember that you need the record option:
\usepackage
[record]{glossaries-extra}
Next convert the entry definitions to the bib format
required by bib2gls:
convertgls2bib --index-conversion --preamble-only sample-newkeys.tex entries.bibThe --index-conversion switch requires at least v2.0 and will convert entries without a description (or where the description is simply
\nopostdesc
or \glsxtrnopostpunc
) to
@index
instead of @entry
. This means that the
new entries.bib file will contain:
Now replace@index
{jump, name={jump} }@index
{run, ing = {running}, name={run}, ed = {ran} }@index
{waddle, ing = {waddling}, name={waddle}, ed = {waddled} }
\makeglossaries
with
\GlsXtrLoadResources
[src=entries]
and delete the \newglossaryentry
commands. Finally replace
\printglossaries
with \printunsrtglossaries
.
The document build is now:
pdflatex sample-newkeys bib2gls sample-newkeys pdflatex sample-newkeysNote that there’s no need for the nonumberlist package option when you don’t use bib2gls’s --group switch. This document illustrates how add custom storage keys (using
\glsaddstoragekey
). The document build is:
pdflatex sample-storage-abbr makeglossaries sample-storage-abbr pdflatex sample-storage-abbr
The custom storage key is called abbrtype which defaults
to “word” if not explicitly set. Its value can be accessed
with the provided custom command \abbrtype
.
A custom acronym style is then defined that checks the value of this key and makes certain adjustments depending on whether or not its value is the default “word”.\glsaddstoragekey
{abbrtype}{word}{\abbrtype
}
This essentially forms a very similar function to the glossaries-extra package’s category key, which is also defined as a storage key:
\glsaddstoragekey
{category}{general}{\glscategory
}
This document is much simpler with the glossaries-extra package:
\documentclass
{article}\usepackage
[postdot]{glossaries-extra}\makeglossaries
\setabbreviationstyle
[acronym]{short-long}\newacronym
{radar}{radar}{radio detecting and ranging}\newacronym
{laser}{laser}{light amplification by stimulated emission of radiation}\newacronym
{scuba}{scuba}{self-contained underwater breathing apparatus}\newabbreviation
{dsp}{DSP}{digital signal processing}\newabbreviation
{atm}{ATM}{automated teller machine}\begin{document}
First use:\gls
{radar},\gls
{laser},\gls
{scuba},\gls
{dsp},\gls
{atm}. Next use:\gls
{radar},\gls
{laser},\gls
{scuba},\gls
{dsp},\gls
{atm}.\printglossaries
\end{document}
An extension of the previous example where the user needs to provide a description.
This document illustrates how to add a custom key using
\glsaddstoragekey
and hook into the \gls
-like
and \glstext
-like mechanism used to determine whether or not to
hyperlink an entry.
The document build is:
pdflatex sample-chap-hyperfirst makeglossaries sample-chap-hyperfirst pdflatex sample-chap-hyperfirstThis example creates a storage key called “chapter” used to store the chapter number.
It’s initialised to 0 and the\glsaddstoragekey
{chapter}{0}{\glschapnum
}
\glslinkpostsetkeys
hook is used
to check this value against the current chapter number. If the
values are the same then the hyperlink is switched off, otherwise
the key value is updated unless the hyperlink has been switched off
(through the optional argument of commands like \gls
and \glstext
).
Since this key isn’t intended for use when the entry is being defined, it would be more appropriate to simply use an internal field that doesn’t have an associated key or helper command, but\renewcommand
*{\glslinkpostsetkeys
}{%\edef
\currentchap
{\arabic
{chapter}}%\ifnum
\currentchap
=\glschapnum
{\glslabel
}\relax
\setkeys
{glslink}{hyper=false}%\else
\glsifhyperon
{\glsfieldxdef
{\glslabel
}{chapter}{\currentchap
}}{}%\fi
}
\glsfieldxdef
requires the existence of the field. The
glossaries-extra package provides utility commands designed to
work on internal fields that don’t have an associated key and may
not have had a value assigned.
If you want to switch to glossaries-extra you need to change the package loading line:
\usepackage
[postdot]{glossaries-extra}
The custom storage key (provided with \glsaddstoragekey
) can be
removed, and the \glslinkpostsetkeys
hook can be changed to:
The field name is still called “chapter” but there’s no longer an associated key or command.\renewcommand
*{\glslinkpostsetkeys
}{%\edef
\currentchap
{\arabic
{chapter}}%\GlsXtrIfFieldEqNum
*{chapter}{\glslabel
}{\currentchap
} {%\setkeys
{glslink}{hyper=false}% }% {%\glsifhyperon
{\xGlsXtrSetField
{\glslabel
}{chapter}{\currentchap
}}{}% }% }
18.9. Xindy (Option 3)[link]
Most of the earlier makeindex sample files can be adapted to
use xindy instead by adding the xindy package option.
Situations that you need to be careful about are when the sort value
(obtained from the name if the sort key is
omitted) contains commands (such as name={\pi
}) or is identical
to another value (or is identical after xindy has stripped all
commands and braces). This section describes sample documents that
use features which are unavailable with makeindex.
The document uses UTF-8 encoding (with the inputenc package). This is information that needs to be passed to xindy, so the encoding is picked up by makeglossaries from the aux file.
This document has an exotic numbering system which requires the package option esclocations=true. Before glossaries v4.50, this was the default setting, but the default is now esclocations=false, so this package option now needs to be set explicitly.
By default, this document will create a xindy style file called samplexdy.xdy, but if you uncomment the lines
it will set the style file to samplexdy-mc.xdy instead. This provides an additional letter group for entries starting with “Mc” or “Mac”. If you use makeglossaries or makeglossaries-lite, you don’t need to supply any additional information. If you don’t use makeglossaries, you will need to specify the required information. Note that if you set the style file to samplexdy-mc.xdy you must also specify\setStyleFile
{samplexdy-mc}\noist
\GlsSetXdyLanguage
{}
\noist
,
otherwise the glossaries package will overwrite
samplexdy-mc.xdy and you will lose the “Mc”
letter group.
To create the document do:
pdflatex samplexdy makeglossaries samplexdy pdflatex samplexdyIf you don’t have Perl installed then you can’t use makeglossaries, but you also can’t use xindy! However, if for some reason you want to call xindy explicitly instead of using makeglossaries (or makeglossaries-lite):
- •if you are using the default style file samplexdy.xdy, then
do (no line breaks):
xindy -L english -C utf8 -I xindy -M samplexdy -t samplexdy.glg -o samplexdy.gls samplexdy.glo
- •if you are using samplexdy-mc.xdy, then do
(no line breaks):
xindy -I xindy -M samplexdy-mc -t samplexdy.glg -o samplexdy.gls samplexdy.glo
This document creates a new command to use with the
format key in the optional argument of commands
like \gls
to format the location in the number list.
The usual type of definition when a hyperlinked location is required
should use one of the \hyper
commands listed in
Table 12.1:
Unfortunately, this definition doesn’t work for this particular document and some adjustments are needed (see below). As a result of the adjustments, this command doesn’t actually get used by TeX, even though\newcommand
*{\hyperbfit
}[1]{\textit
{\hyperbf
{#1}}}
hyperbfit
is used in the
format key. It does, however, need to be
identified as an attribute so that xindy can recognise it:
\GlsAddXdyAttribute
{hyperbfit}
This will add information to the xdy file when it’s
created by \makeglossaries
. If you prevent the creation of this
file with \noist
then you will need to add the attribute to
your custom xdy file (see the provided
samplexdy-mc.xdy file).
In order to illustrate unusual location formats, this sample
document provides a command called \tallynum
{ } that represents its
numerical argument with a die or dice where the dots add up to :
This command needs to be robust to prevent it from being expanded when it’s written to any of the auxiliary files. The\newrobustcmd
*{\tallynum
}[1]{%\ifnum
\number
#1<7 $\csname
dice\romannumeral
#1\endcsname
$%\else
$\dicevi
$%\expandafter
\tallynum
\expandafter
{\numexpr
#1-6}%\fi
}
\dicei
,
…, \dicevi
commands are provided by the stix
package, so that needs to be loaded.
An associated command \tally
{ } is defined that
formats the value of the named according to
\tallynum
:
(This shouldn’t be robust as it needs the counter value to expand.) The page numbers are altered to use this format (by redefining\newcommand
*{\tally
}[1]{\tallynum
{\arabic
{#1}}}
\thepage
).
This custom location format also needs to be identified in the xdy file so that xindy can recognise it and determine how to form ranges if required.
Again this information is written to the xdy file by\GlsAddXdyLocation
{tally}{% tally location format :sep "\string
\tallynum
\space
\glsopenbrace
" "arabic-numbers" :sep "\glsclosebrace
" }
\makeglossaries
so if you use \noist
then you need to
manually add it to your custom xdy file.
When xindy creates the associated indexing files, the locations will be written using:
\glsX
X{ }{ }
In this case:
or\glsXpageXglsnumberformat
{}{\tallynum
{ }}
This means that although\glsXpageXhyperbfit
{}{\tallynum
{ }}
\hyperbf
is designed to create
hyperlinked locations, the presence of \tallynum
interferes with
it.
In order to make the hyperlinks work correctly, the definitions of
\glsXpageXhyperbfit
need to be redefined in order to grab the
number part in order to work out the location’s numeric value. If
the value of \tally
is changed so that it expands differently
then these modifications won’t work.
Remember that in both cases, the second argument #2 is in the
form
:
\tally
{ }
These need a command that can grab the actual number and correctly encapsulate it:\renewcommand
{\glsXpageXglsnumberformat
}[2]{%\linkpagenumber
#2% }\renewcommand
{\glsXpageXhyperbfit
}[2]{%\textbf
{\em
\linkpagenumber
#2}% }
\newcommand
{\linkpagenumber
}[2]{\hyperlink
{page.#2}{#1{#2}}}
If you want to try out the samplexdy-mc.xdy file, the
entries starting with “Mac” or “Mc” will be placed in their
own “Mc” letter group. Ideally it should be possible to do
this simply with \GlsAddLetterGroup
(and not require a custom
xdy file) but unfortunately the “M” letter group will
have already been defined and take precedence over “Mc”, which is
why a custom file is required and the normal language module must be
suppressed:
\setStyleFile
{samplexdy-mc}\noist
\GlsSetXdyLanguage
{}
This “Mc” group is suitable for names like “Maclaurin” but not for “Mach”. To prevent this, the sort key for that value is set to lower case:
\newglossaryentry
{mach}{name={Mach, Ernst},
first={Ernst Mach},text={Mach},
sort={mach, Ernst},
description={Czech/Austrian physicist and philosopher}}
If you want to convert this document so that it uses bib2gls, you first need to switch to glossaries-extra and use the record package option:
\usepackage
[record,postdot]{glossaries-extra}
The xindy-only commands can now all be removed
(attribute \GlsAddXdyAttribute
, location \GlsAddXdyLocation
,
language \GlsSetXdyLanguage
, location encaps
\glsX
X and the custom helper \linkpagenumber
).
Also \noist
and \setStyleFile
aren’t relevant with
bib2gls and so should be removed.
The definitions of \hyperbfit
should be retained (as well as
\tallynum
, \tally
and the redefinition of \thepage
).
The entries all need to be converted to the bib format required by bib2gls.
convertgls2bib --preamble-only samplexdy.tex entries.bibNext replace
\makeglossaries
with:
\GlsXtrLoadResources
[src=entries]
and remove all the entry definitions from the document preamble. Use the
search and replace function on your text editor to replace all
instances of \glsentryfirst
with \glsfmtfirst
, and all
instances of \glsentryname
with \glsfmtname
.
Finally, replace \printglossaries
with \printunsrtglossaries
.
The document build is now:
pdflatex samplexdy bib2gls --group samplexdy pdflatex samplexdy
This results in a slightly different ordering from the original
document (without the “Mc” letter group). In the original
example, “Mach number” was listed before “Mach, Ernest”. The
modified document now has “Mach, Ernest” before “Mach number”.
This difference is due to bib2gls’s default
break-at=word setting, which marks word boundaries
with the |
(pipe) character, so the sort values for
bib2gls are Mach|Earnest|
and Mach|number|
.
See the bib2gls manual for further details of this option, and
also see the examples chapter of that manual for alternative
approaches when creating entries that contain people’s names.
If you want the “Mc” letter group, it can be obtained by providing a custom sort rule:
Unfortunately, as with xindy, this puts “Mach” into the “Mc” letter group. (See the glossaries-extra manual for details about the sort rule commands.)\GlsXtrLoadResources
[src=entries, sort=custom, sort-rule={}\glsxtrGeneralInitRules
<\glsxtrGeneralLatinAtoGrules
<h,H<i,I<j,J<k,K<l,L<Mc=Mac<m,M <\glsxtrGeneralLatinNtoZrules
]
One way to get around this problem is to define a custom command to help identify genuine “Mc”/“Mac” prefixes with names that happen to start with “Mac”. For example:
but not for “Mach”:@entry
{mcadam, name={\Mac
{Mc}Adam, John Loudon}, description={Scottish engineer}, text={McAdam}, first={John Loudon McAdam} }@entry
{maclaurin, name={\Mac
{Mac}laurin, Colin}, description={Scottish mathematician best known for the\gls
{maclaurinseries}}, text={Maclaurin}, first={Colin Maclaurin} }
@entry
{mach,
name={Mach, Ernst},
description={Czech/Austrian physicist and philosopher},
text={Mach},
first={Ernst Mach}
}
With LaTeX, this command should simply do its argument:
However, when bib2gls works out the sort value, it needs to be defined with something unique that won’t happen to occur at the start of another term. For example:\newcommand
{\Mac
}[1]{#1}
(Remember that break-at=word will strip spaces and punctuation so don’t include them unless you switch to break-at=none.)\providecommand
{\Mac
}[1]{MC}
So add the first definition of \Mac
to the tex file and modify
entries.bib so that it includes the second definition:
Then modify the “Mc”/“Mac” entries as appropriate (see the above “McAdam” and “Maclaurin” examples).@preamble
{"\providecommand
{\Mac
}[1]{MC}"}
The custom sort rule needs to be modified:
This will create a “Mc” letter group that only includes the names that start with the custom\GlsXtrLoadResources
[src=entries, write-preamble=false, sort=custom, sort-rule=\glsxtrGeneralInitRules
<\glsxtrGeneralLatinAtoGrules
<h,H<i,I<j,J<k,K<l,L<MC<m,M <\glsxtrGeneralLatinNtoZrules
]
\Mac
command.
Other alternatives include moving @preamble
into a separate
bib file, so that you can choose whether or not to
include it. See the “Examples” chapter of the bib2gls user
manual for further examples.
This document illustrates how to use the glossaries package where the location numbers don’t follow a standard syntax. This example won’t work with makeindex, which only accepts a limited set of location syntax. To create the document do:
pdflatex samplexdy2 makeglossaries samplexdy2 pdflatex samplexdy2The explicit xindy call is:
xindy -L english -C utf8 -I xindy -M samplexdy2 -t samplexdy2.glg -o samplexdy2.gls samplexdy2.gloThis example uses the section counter with xindy:
\usepackage
[xindy,counter=section]{glossaries}
The document employs an eccentric section numbering system for
illustrative purposes. The section numbers are prefixed by the
chapter number in square brackets:
Parts use Roman numerals:\renewcommand
*{\thesection
}{[\thechapter
]\arabic
{section}}
The section hyperlink name includes the part:\renewcommand
*{\thepart
}{\Roman
{part}}
This custom numbering scheme needs to be identified in the xdy file:\renewcommand
*{\theHsection
}{\thepart
.\thesection
}
\GlsAddXdyLocation
["roman-numbers-uppercase"]{section}{:sep "["
"arabic-numbers" :sep "]" "arabic-numbers"
}
If the part is 0 then \thepart
will be empty
(there isn’t a zero Roman numeral). An extra case is needed to catch this:
\GlsAddXdyLocation
{zero.section}{:sep "["
"arabic-numbers" :sep "]" "arabic-numbers"
}
Note that this will stop xindy giving a warning, but the location hyperlinks will be invalid if no \part
is used.
If you want to switch to bib2gls, you first need to switch to glossaries-extra but remember to use record instead of xindy:
\usepackage
[record,counter=section]{glossaries-extra}
Next remove the \GlsAddXdyLocation
commands and convert the
entry definitions to the bib format required by
bib2gls:
convertgls2bib --preamble-only samplexdy2.tex entries.bibNow replace
\makeglossaries
with:
\GlsXtrLoadResources
[src=entries]
and remove the \newglossaryentry
commands.
Finally, replace \printglossaries
with \printunsrtglossaries
.
The document build is:
pdflatex samplexdy2 bib2gls samplexdy2 pdflatex samplexdy2
With unusual numbering systems, it’s sometimes better to use record=nameref:
\usepackage
[record=nameref,counter=section]{glossaries-extra}
In this case, the locations will be the actual section headings,
rather than the section number. In order to make the number appear
instead you need to define:
(Make sure you have at least v1.42 of glossaries-extra.) See also the earlier sampleSec.tex.\newcommand
*{\glsxtrsectionlocfmt
}[2]{#1}
This document is very similar to samplexdy.tex but uses the command
\Numberstring
from the
fmtcount package to format the page numbers instead of the
\tally
command from the earlier example.
This is another example that uses xindy. Unlike makeindex, xindy recognises non-Latin characters (provided the correct encoding is passed to xindy via the -C switch). This document uses UTF-8 encoding. To create the document do:
pdflatex sampleutf8 makeglossaries sampleutf8 pdflatex sampleutf8The explicit xindy call is (no line breaks):
xindy -L english -C utf8 -I xindy -M sampleutf8 -t sampleutf8.glg -o sampleutf8.gls sampleutf8.glo
If you remove the xindy option from sampleutf8.tex and do:
pdflatex sampleutf8 makeglossaries sampleutf8 pdflatex sampleutf8or
pdflatex sampleutf8 makeglossaries-lite sampleutf8 pdflatex sampleutf8you will see that the entries that start with an extended Latin character now appear in the symbols group, and the word “manœuvre” is now after “manor” instead of before it. If you want to explicitly call makeindex (no line breaks):
makeindex -s sampleutf8.ist -t sampleutf8.glg -o sampleutf8.gls sampleutf8.glo
If you want to switch to bib2gls, you first need to switch to glossaries-extra but replace xindy with record:
\usepackage
[record,postdot,stylemods,style=listgroup]{glossaries-extra}
Note that you don’t need the nonumberlist option with
bib2gls. You can instruct bib2gls to simply not save the
number lists, but in this case there won’t be any locations as
there’s no actual indexing.
The entries need to be converted to the bib format required by bib2gls:
convertgls2bib --preamble-only --texenc UTF-8 --bibenc UTF-8 sampleutf8.tex entries.bibNote the first line of the entries.bib file:
% Encoding: UTF-8This is the encoding of the bib file. It doesn’t have to match the encoding of the tex file, but it’s generally better to be consistent. When bib2gls parses this file, it will look for this encoding line. (If the --texenc and --bibenc switches aren’t used, convertgls2bib will assume your Java default encoding. See the bib2gls manual for further details.)
Next replace \makeglossaries
with:
\GlsXtrLoadResources
[src=entries,selection=all]
and remove all the \newglossaryentry
commands.
Iterative commands like \glsaddall
don’t work with
bib2gls. Instead, you can select all entries using the
selection=all option.
This is actually better than \glsaddall
, which enforces
the selection of all entries by indexing each entry. As a result,
with makeindex and xindy (and Option 1), every entry will
have the same location (which is the location of the \glsaddall
command, in this case page 1). With selection=all,
bib2gls will automatically selection all entries even if they
don’t have any records (indexing information) so in this case there
are no number lists.
Finally, replace \printglossaries
with
\printunsrtglossaries
. The build process is now:
pdflatex sampleutf8 bib2gls --group sampleutf8 pdflatex sampleutf8bib2gls picks up the encoding of the tex file from the aux file:
\glsxtr@texencoding
{utf8}
If you experience any encoding issues, check the aux file for
this command and check the bib file for the encoding
comment line. Also check bib2gls’s glg transcript file
for encoding messages, which should look like:
TeX character encoding: UTF-8
The document language, if it has been set, is also added to the aux file when the record option is used. In this case, no language package has been used, so bib2gls will fallback on the system’s default locale. If no sort method is set, the entries will be sorted according to the document language, if set, or the default locale. You can specify a specific locale using the sort key with a locale tag identifier. For example:
\GlsXtrLoadResources
[src=entries,selection=all,sort=de-CH-1996]
(Swiss German new orthography) or:
\GlsXtrLoadResources
[src=entries,selection=all,sort=is]
(Icelandic).
18.10. No Indexing Application (Option 1)[link]
This document illustrates how to use the glossaries package without an external indexing application (Option 1). To create the complete document, you need to do:
pdflatex sample-noidxapp pdflatex sample-noidxappWith old LaTeX kernels and old versions of mfirstuc, it was necessary to group the accent command that occurs at the start of the name:
This used to be necessary to allow the term to work with\newglossaryentry
{elite}{% name={{\'
e}lite},% mfirstuc v2.07 description={select group of people} }
\Gls
. With a new
kernel and latest versions of glossaries and mfirstuc, this should
no longer be necessary.
\newglossaryentry
{elite}{% name={\'
elite},% mfirstuc v2.08 description={select group of people} }
Notice also how the number lists can’t be compacted into ranges. For example, the list “1, 2, 3” would be converted to “1–3” with a proper indexing application (Options 2 or 3 or, with glossaries-extra, Option 4).
The larger the list of entries, the longer the document build time. This method is very inefficient for large glossaries. See Gallery: glossaries performance for a comparison.
As the previous example, except that it uses the inputenc package. In this case, the sort key is used for the entries with UTF-8 characters in the names. To create the complete document, you need to do:
pdflatex sample-noidxapp-utf8 pdflatex sample-noidxapp-utf8This method is unsuitable for sorting languages with extended Latin alphabets or non-Latin alphabets. Use Options 3 or 4 instead.
18.11. Other[link]
This document illustrates a four column glossary where the entries have a symbol in addition to the name and description. To create the complete document, you need to do:
pdflatex sample4col makeglossaries sample4col pdflatex sample4color
pdflatex sample4col makeglossaries-lite sample4col pdflatex sample4colThe vertical gap between entries is the gap created at the start of each letter group. This can be suppressed using the nogroupskip package option. (If you switch to bib2gls, simply omit the --group command line option.)
This example uses the long4colheaderborder. This style doesn’t allow multi-line descriptions. You may prefer to use altlong4colheaderborder with long descriptions. However, in either case a style that uses booktabs is preferable. For example, long4col-booktabs or altlongragged4col-booktabs. Note that this requires glossary-longbooktabs, which needs to be explicitly loaded. The style can only be set once this package has been loaded:
\usepackage
{glossaries}\usepackage
{glossary-longbooktabs}\setglossarystyle
{altlongragged4col-booktabs}
The glossaries-extra package provides a more compact way of doing this with the stylemods option:
\usepackage
[style=altlongragged4col-booktabs,stylemods=longbooktabs]
{glossaries-extra}
The glossaries-extra package provides additional styles,
including more “long” styles with the glossary-longextra
package. For example, the long-name-desc-sym-loc
style:
\usepackage
[style=long-name-desc-sym-loc,stylemods=longextra]
{glossaries-extra}
If you use the stylemods option with an argument, you may
prefer to use it with nostyles to prevent unwanted styles
from being automatically loaded. For example:
\usepackage
[style=long-name-desc-sym-loc,nostyles,stylemods=longextra]
{glossaries-extra}
See also the
gallery of predefined styles.
This document illustrates how to reference the number list in the document text. This requires an additional LaTeX run:
pdflatex sample-numberlist makeglossaries sample-numberlist pdflatex sample-numberlist pdflatex sample-numberlistThis uses the savenumberlist package option, which enables
\glsentrynumberlist
and \glsdisplaynumberlist
(with limitations). The location counter is set to
chapter, so the number list refers to the chapter
numbers.
\usepackage
[savenumberlist,counter=chapter]{glossaries}
The number list can’t be obtained until makeindex (or
xindy) has created the indexing file. The number list is
picked up when this file is input by \printglossary
and is then
saved in the aux file so that it’s available on the next
LaTeX run.
This document contains both commands:
This is aWithout hyperref, the first list shows as “1–3, 5 & 6” and the second list shows as “1–3, 5, 6”.\gls
{sample} document.\Glspl
{sample} are discussed in chapters\glsdisplaynumberlist
{sample} (or\glsentrynumberlist
{sample}).
Note that you can’t use \glsdisplaynumberlist
with
hyperref and Options 2 or 3. If you do, you will get the warning:
Package glossaries Warning:Now both lists show as “1–3, 5, 6”.\glsdisplaynumberlist
doesn't work with hyperref. Using\glsentrynumberlist
instead
If you switch to Option 1 (replace \makeglossaries
with
\makenoidxglossaries
and replace \printglossaries
with
\printnoidxglossaries
), then the document build is simply:
pdflatex sample-numberlist pdflatex sample-numberlistNow
\glsdisplaynumberlist
works with hyperref,
however there are no ranges, so the first list shows as “1,
2, 3, 5, & 6” and the second list shows as “1, 2, 3, 4, 5, 6”.
If you want to switch to bib2gls, you first need to switch to glossaries-extra (at least v1.42) but remember to include the record option:
\usepackage
[record,counter=chapter]{glossaries-extra}
Note that the savenumberlist option is no longer required.
Next convert the entry to the bib format required by
bib2gls:
convertgls2bib sample-numberlist.tex entries.bibReplace
\makeglossaries
with:
\GlsXtrLoadResources
[src=entries]
and remove the \newglossaryentry
command from the
document preamble. Finally, replace \printglossaries
with
\printunsrtglossaries
. The build process is now:
pdflatex sample-numberlist bib2gls sample-numberlist pdflatex sample-numberlistNow both ranges and hyperlinks work. The first list shows “1–3, 5, & 6” and the second list shows “1–3, 5, 6”. You can also use:
\glsxtrfieldformatlist
{sample}{loclist}
which will show the complete list without ranges “1, 2, 3, 5 &
6”.
This method works much better than using the savenumberlist option because bib2gls saves the formatted number list in the location field (which is provided by glossaries-extra for the benefit of bib2gls) and the unformatted number list in the loclist internal field (which is also used by Option 1).
With Options 2 and 3, both makeindex and xindy simply create a
file containing the commands to typeset the glossary, which is input
by \printglossary
. This means that it’s quite hard to gather
information obtained by the indexing application.
bib2gls, on the other hand, doesn’t write a file containing
the glossary. It writes a file containing the entry definitions and
uses internal fields to save the indexing information. The glossary is
then displayed with \printunsrtglossary
, which simply iterates
over all defined entries and fetches the required information from
those internal fields.
The \glsdisplaynumberlist
and \glsentrynumberlist
commands
are redefined by glossaries-extra-bib2gls to simply access the
location field.
However, if you want a complete list without ranges you can use:
\glsxtrfieldformatlist
{sample}{loclist}
In this example, this produces “1, 2, 3, 5 & 6”.
Note the difference if you use the record=nameref package option instead of just record.
This document illustrates how to selectively enable and disable entry hyperlinks in
\glsentryfmt
. The
document build is:
pdflatex sample-nomathhyper makeglossaries sample-nomathhyper pdflatex sample-nomathhyperThis disables the hyperlinks for the
main
glossary with:
and then redefines\GlsDeclareNoHyperList
{main
}
\glsentryfmt
so that it adds a hyperlink if
not in maths mode and the hyperlinks haven’t been forced off (with
the hyper=false key).
If you want to switch to glossaries-extra, then you can instead use the hook that comes before the keys are set. The preamble is much simpler:
\usepackage
{glossaries-extra}\makeglossaries
\renewcommand
{\glslinkpresetkeys
}{%\ifmmode
\setkeys
{glslink}{hyper=false}\fi
} % entry definition
This document illustrates how to change the way an entry is displayed in the text. (This is just a test document. For a real document, I recommend you use the siunitx package to typeset units.) The document build is:
pdflatex sample-entryfmt makeglossaries sample-entryfmt pdflatex sample-entryfmtThis redefines
\glsentryfmt
to add the symbol on
first use:
Note the use of\renewcommand
*{\glsentryfmt
}{%\glsgenentryfmt
\ifglsused
{\glslabel
}{}{\space
(\glsentrysymbol
{\glslabel
})}% }
\glsentrysymbol
not \glssymbol
(which
would result in nested link text).
If you want to switch to the glossaries-extra package, you can make use of the category post-link hook instead:
Note that in this case the symbol is now outside of the hyperlink.\usepackage
[stylemods,style=tree]{glossaries-extra}\makeglossaries
\glsdefpostlink
{unit}{\glsxtrpostlinkAddSymbolOnFirstUse
}\newglossaryentry
{distance}{ category={unit}, name={distance}, description={The length between two points}, symbol={km}}
This document illustrates the use of the glossaries-prefix package. An additional run is required to ensure the table of contents is up-to-date:
pdflatex sample-prefix makeglossaries sample-prefix pdflatex sample-prefix pdflatex sample-prefixRemember that the default separator between the prefix and
\gls
(or one of its variants) is empty, so if a space is required it must
be inserted at the end of the prefix. However, the xkeyval
package (which is used to parse the = lists) trims leading
and trailing space from the values, so an
ordinary space character will be lost.
\newglossaryentry
{sample}{name={sample}, description={an example}, prefix={a~
}, prefixplural={the\space
}}\newglossaryentry
{oeil}{name={oeil}, plural={yeux}, description={eye}, prefix={l'}, prefixplural={les\space
}}
If you want to convert this example to use glossaries-extra, then (as from v1.42) you can use the prefix option:
\usepackage
[prefix,postdot,acronym]{glossaries-extra}
(Alternatively load glossaries-prefix after
glossaries-extra.) The rest of the document is the same as for
the base glossaries package, unless you want to switch to
using bib2gls.
If you want to switch to bib2gls, first switch to glossaries-extra (as above) but make sure you include the record package option:
\usepackage
[record,prefix,postdot,acronym]{glossaries-extra}
Next convert the entries into the bib format required by
bib2gls:
convertgls2bib --preamble-only sample-prefix.tex entries.bibReplace
\makeglossaries
with
remove the entry definitions from the document preamble, and replace\setabbreviationstyle
[acronym]{long-short}\GlsXtrLoadResources
[src=entries]
with\printglossary
[style=plist]\printacronyms
The document build is now:\printunsrtglossary
[style=plist]\printunsrtacronyms
pdflatex sample-prefix bib2gls sample-prefix pdflatex sample-prefix
With bib2gls v2.0+, you don’t need to manually insert the spaces at
the end of the prefixes. Instead you can instruct bib2gls to
insert them. To try this out, remove the trailing \space
and
non-breaking space (~
) from the entries.bib file:
Now add the append-prefix-field={space or nbsp} resource option:@entry
{sample, prefix={a}, name={sample}, description={an example}, prefixplural={the} }@entry
{oeil, plural={yeux}, prefix={l'}, name={oeil}, description={eye}, prefixplural={les} }@acronym
{svm, prefixfirst={a}, prefix={an}, short={SVM}, long={support vector machine} }
\GlsXtrLoadResources
[src=entries,append-prefix-field={space or nbsp}]
See the bib2gls manual for further details.
This document uses the glossaries-accsupp package (see §17). That package automatically loads glossaries and passes all options to the base package. So you can load both packages at once with just:
\usepackage
[acronym]{glossaries-accsupp}
This provides additional keys that aren’t available with just the
base package, which may be used to provide replacement text. The
replacement text is inserted using accsupp’s
\BeginAccSupp
and \EndAccSupp
commands. See the
accsupp package for further details of those commands.
Note that this example document is provided to demonstrate glossaries-accsupp as succinctly as possible. The resulting document isn’t fully accessible as it’s not tagged. See the accessibility and tagpdf packages for further information about tagging documents.
It’s not essential to use glossaries-accsupp. You can simply insert the replacement text directly into the field values. For example:
However, this can cause interference (especially with case-changing). With glossaries-accsupp it’s possible to obtain the field values without the accessibility information if required. (If in the future\newglossaryentry
{Drive}{ name={\BeginAccSupp
{Actual=Drive}Dr.\EndAccSupp
{}}, description={Drive} }\newglossaryentry
{image}{name={sample image}, description={an example image}, user1={\protect
\BeginAccSupp
{Alt={a boilerplate image used in examples}}\protect
\includegraphics
[height=20pt]{example-image}\protect
\EndAccSupp
{}} }
\includegraphics
is given extra
options to provide replacement text then the image example here
won’t be necessary. However, the example can be adapted for images
created with TeX code.)
The acronym style is set using:
\setacronymstyle
{long-short}
The first acronym is straightforward:
\newacronym
{eg}{e.g.}{for example}
The shortaccess replacement text is automatically set to
the long form. The next acronym is awkward as the long form contains
formatting commands which can’t be included in the replacement text.
This means that the shortaccess key must be supplied:
In the above two cases, the short form obtained in\newacronym
[shortaccess={TiKZ ist kein Zeichenprogramm}] {tikz}{Ti\emph
{k}Z}{Ti\emph
{k}Z ist\emph
{kein} Zeichenprogramm}
\gls
will use
the “E” PDF element.
By way of comparison, there are some entries that are technically
abbreviations but are defined using \newglossaryentry
instead
of \newacronym
. The replacement text is provided in the
access key:
These will use the “ActualText” PDF element (not “E”).\newglossaryentry
{Doctor}{name={Dr},description={Doctor},access={Doctor}}\newglossaryentry
{Drive}{name={Dr.},plural={Drvs},description={Drive}, access={Drive}}
The next entry is a symbol (the integration symbol ∫). This could be defined simply as:
and then referenced in the text like this:\newglossaryentry
{int}{name={int},description={integral}, symbol={\ensuremath
{\int
}}}
Symbol:This results in the text “Symbol: integral (∫).” However if you copy and paste this from the PDF you will find the resulting text is “Symbol: int (R).” This is what’s actually read out by the text-to-speech system.\gls
{int} (\glssymbol
{int}).
It would be better if the actual text was the Unicode character
0x222B. This would not only assist the text-to-speech system but
also make it easier to copy and paste the text. The simplest method
is to identify the character by its hexadecimal code, but in order
to do this the \BeginAccSupp
command needs to have the options adjusted.
In order to determine whether to use “E”, “ActualText” or “Alt” for a
particular field, glossaries-accsupp will check if the command
\gls
accsupp exists (where is the
internal field label, see Table 4.1). Only two of these
commands are predefined: \glsshortaccsupp
and \glsshortplaccsupp
,
which is why the shortaccess field uses “E”. If the given command
doesn’t exist then the generic \glsaccsupp
command is used instead.
This means that in order to simply set symbolaccess to the
hexadecimal character code, I need to provide a command called
\glssymbolaccsupp
:
Now I can adjust the definition of the “int” entry:\newcommand
{\glssymbolaccsupp
}[2]{%\glsaccessibility
[method=hex,unicode]{ActualText}{#1}{#2}% }
\newglossaryentry
{int}{name={int},description={integral}, symbol={\ensuremath
{\int
}},symbolaccess={222B} }
The final entry has an image stored in the user1 key. (The
image file is provided with the mwe package.) This should use
“Alt” instead of “ActualText” so I need to define
\glsuseriaccsupp
:
The image description is provided in the user1access key:\newcommand
{\glsuseriaccsupp
}[2]{%\glsaccessibility
{Alt}{#1}{#2}% }
(Note the need to protect the fragile\newglossaryentry
{sampleimage}{name={sample image}, description={an example image}, user1={\protect
\includegraphics
[height=20pt]{example-image}}, user1access={a boilerplate image used in examples} }
\includegraphics
. The alternative is
to use \glsnoexpandfields
before defining the command. See
§4.4.)
The PDF can be inspected either by uncompressing the file and viewing it in a text editor or you can use a tool such as the PDFDebugger provided with PDFBox. If you do this you will find content like:
/Span << /ActualText (Doctor) >> BDC BT /F8 9.9626 Tf 73.102 697.123 Td [ (Dr) ] TJ ET EMCThis shows that “ActualText” was used for
\gls
{Doctor}
.
The integral symbol (∫) created with \glssymbol
{int}
is:
/Span << /ActualText (\376\377"+) >> BDC BT /F1 9.9626 Tf 97.732 650.382 Td [ (R) ] TJ ET EMCAgain, “ActualText” has been used, but the character code has been supplied. The image created with
\glsuseri
{sampleimage}
is:
/Span << /Alt (a boilerplate image used in examples) >> BDC 1 0 0 1 106.588 618.391 cm q 0.08301 0 0 0.08301 0 0 cm q 1 0 0 1 0 0 cm /Im1 Do Q Q EMCThis shows that “Alt” has been used.
The first use of
produces the long form (not
reproduced here) followed by the short form:
\gls
{eg}
/Span << /E (for example) >> BDC BT /F8 9.9626 Tf 161.687 563.624 Td [ (e.g.) ] TJ ET EMCThe subsequent use also has the “E” element:
/Span << /E (for example) >> BDC BT /F8 9.9626 Tf 118.543 551.669 Td [ (e.g.) ] TJ ET EMCSimilarly for
\acrshort
{eg}
. You can also use the
debug=showaccsupp package option. This will show the
replacement text in the document, but note that this is the content before
it’s processed by \BeginAccSupp
.
If the \setacronymstyle
command is removed (or commented out)
then the result would be different. The first use of \gls
uses “E” for
the short form but the subsequent use has “ActualText” instead.
This is because without \setacronymstyle
the original acronym
mechanism is used, which is less sophisticated than the newer
acronym mechanism that’s triggered with \setacronymstyle
.
If you want to convert this example so that it uses glossaries-extra, you need to replace the explicit loading of glossaries-accsupp with an implicit load through the accsupp package option:
\usepackage
[abbreviations,accsupp]{glossaries-extra}
I’m switching from \newacronym
to \newabbreviation
, which
means that the default category is abbreviation and also the
file extensions are different. If you are using makeglossaries
or makeglossaries-lite you don’t need to worry about it.
However, if you’re not using those helper scripts then you will need
to adjust the file extensions in your document build process.
The style command
needs
to be replaced with:
\setacronymstyle
{long-short}
\setabbreviationstyle
{long-short}
This is actually the default so you can simply delete the
\setacronymstyle
line. Substitute the two instances of
\newacronym
with \newabbreviation
. For example:
\newabbreviation
{eg}{e.g.}{for example}
Note that for the “tikz” entry you can now remove the explicit assignment of
shortaccess with glossaries-extra v1.42 as it will
strip formatting commands like \emph
:
It’s also necessary to replace\newabbreviation
{tikz}{Ti\emph
{k}Z}{Ti\emph
{k}Z ist\emph
{kein} Zeichenprogramm}
\acrshort
, \acrlong
and \acrfull
with
\glsxtrshort
, \glsxtrlong
and \glsxtrfull
.
You may notice a slight difference from the original example if you use a
version of glossaries-extra between 1.42 and 1.48. The
shortaccess field shows ( ) instead of just
. This is because glossaries-extra v1.42 redefined
\glsdefaultshortaccess
to include the short form. The original definition
was restored in glossaries v1.49.
Now that the extension package is being used, there are some other modifications that would tidy up the code and fix a few issues.
The “Doctor” and “Drive” entries should really be defined as abbreviations but they shouldn’t be expanded on first use. The short-nolong style can achieve this and it happens to be the default style for the acronym category. This means that you can simply replace the “Doctor” definition with:
\newacronym
{Doctor}{Dr}{Doctor}
The first use of \gls
{Doctor}
is just “Dr”. This
means that the “E” PDF element will be used instead of “ActualText”.
Now I don’t need to supply the accessibility text as its obtained
from the long form.
The “Drive” entry can be similarly defined but it has the awkward terminating full stop. This means that I had to omit the end of sentence terminator in:
This looks odd when reading the document source and it’s easy to forgot. This is very similar to the situation in the sample-dot-abbr.tex example. I can again use the discardperiod category attribute, but I need to assign a different category so that it doesn’t interfere with the “Doctor” entry.\gls
{Doctor} Smith lives at 2, Blueberry\gls
{Drive}
The category is simply a label that’s used in the construction of some internal command names. This means that it must be fully expandable, but I can choose whatever label I like (general, abbreviation, acronym, index, symbol and number are used by various commands provided by glossaries-extra).
In this case, I’ve decided to have a category called shortdotted to indicate an abbreviation that ends with a dot but only the short form is shown on first use:
In the sample-dot-abbr.tex example, I also used the insertdots attribute to automatically insert the dots and add the space factor (which is adjusted if discardperiod discards a period). In this case I’m inserting the dot manually so I’ve also added the space factor with\setabbreviationstyle
[shortdotted]{short-nolong-noreg}\glssetcategoryattribute
{shortdotted}{discardperiod}{true}\newabbreviation
[category={shortdotted}]{Drive}{Dr.\@
}{Drive}
\@
in case the abbreviation is used
mid-sentence. For example:
(The spacing is more noticeable if you first switch to a monospaced font with\gls
{Doctor} Smith lives at 2, Blueberry\gls
{Drive}. Next sentence.\gls
{Doctor} Smith lives at 2, Blueberry\gls
{Drive} end of sentence.
\ttfamily
.)
The “e.g.” abbreviation similarly ends with a dot. It’s not usual to write “for example (e.g.)” in a document, so it really ought to have the same shortdotted category, but it has a long-short form for illustrative purposes in this test document. In this case I need to choose another category so that I can apply a different style. For example:
\setabbreviationstyle
[longshortdotted]{long-short}\glssetcategoryattribute
{longshortdotted}{discardperiod}{true}\newabbreviation
[category={longshortdotted}]{e.g.}{e.g.\@
}{for example}
To further illustrate categories, let’s suppose the symbol and image should be
in the name field instead of the symbol and user1
fields. Now the \glssymbolaccsupp
and \glsuseriaccsupp
commands won’t be used. I can’t deal with both cases if I just provide
\glsnameaccsupp
.
I could provide category+field versions, such as
\glsxtrsymbolnameaccsupp
, but remember that this only covers
accessing the name field, which is typically only done in
the glossary. I would also need similar commands for the
first, firstplural, text and
plural keys. This is quite complicated, but since I don’t
need to worry about any of the other fields it’s simpler to just
provide the \glsxtr
accsupp version:
If it’s necessary to provide support for additional fields, then the category+field command\newcommand
{\glsxtrsymbolaccsupp
}[2]{%\glsaccessibility
[method=hex,unicode]{ActualText}{#1}{#2}% }\newcommand
{\glsxtrimageaccsupp
}[2]{%\glsaccessibility
{Alt}{#1}{#2}% }\newglossaryentry
{int}{category={symbol}, name={\ensuremath
{\int
}},access={222B}, description={integral} }\newglossaryentry
{sampleimage}{category={image}, description={an example image}, name={\protect
\includegraphics
[height=20pt]{example-image}}, access={a boilerplate image used in examples} }
\glsxtr
accsupp could be used to
override the more general category command \glsxtr
accsupp.
This document defines an ignored glossary for common terms that don’t need a definition. The document build is:
pdflatex sample-ignored makeglossaries sample-ignored pdflatex sample-ignoredA new ignored glossary is defined with:
\newignoredglossary
{common}
There are no associated files with an ignored glossary. An entry is defined with
this as its glossary type:
\newglossaryentry
{commonex}{type={common},name={common term}}
Note that the description key isn’t required. This term
may be referenced with \gls
(which is useful for consistent
formatting) but it won’t be indexed.
This document uses
\glsenableentrycount
and \cgls
(described in §7.1)
so that acronyms only used once don’t appear in the list of
acronyms. The document build is:
pdflatex sample-entrycount pdflatex sample-entrycount makeglossaries sample-entrycount pdflatex sample-entrycountNote the need to call LaTeX twice before makeglossaries, and then a final LaTeX call is required at the end.
19. Troubleshooting[link]
In addition to the sample files listed in §18, the glossaries package comes with some minimal example files, minimalgls.tex, mwe-gls.tex, mwe-acr.tex and mwe-acr-desc.tex, which can be used for testing. These should be located in the samples subdirectory (folder) of the glossaries documentation directory. The location varies according to your operating system and TeX installation. For example, on Linux it may be in /usr/local/texlive/2022/texmf-dist/doc/latex/glossaries/. The makeglossariesgui application can also be used to test for various problems. Further information on debugging LaTeX code is available at http://www.dickimaw-books.com/latex/minexample/.
If you have any problems, please first consult the glossaries FAQ. If that doesn’t help, try posting your query to somewhere like the comp.text.tex newsgroup, the LaTeX Community Forum or TeX on StackExchange. Bug reports can be submitted via my package bug report form.
Symbols[link]
- №
- A counter is being described.
- 📌
- The syntax and usage of a command, environment or option etc.
- 🗑
- A command, environment or option that is now deprecated.
- ℹ
- An important message.
- 🛈
- Prominent information.
- 🖹
- LaTeX code to insert into your document.
- 🔖
- The definition of an option value.
- 🖺
- How the example code should appear in the PDF.
- 🎚
- An option that takes a value.
- 〉_
- A command-line application invocation that needs to be entered into a terminal or command prompt. See also “Incorporating makeglossaries or makeglossaries-lite or bib2gls into the document build”.
- 🔘︎
- A boolean option that is initially false.
- 🔘
- A boolean option that is initially true.
- 🔎
- Text in a transcript or log file or written to STDOUT or STDERR.
- 𝍢
- An option that doesn’t take a value.
- ⚠
- A warning.
Terms[link]
- American Standard Code for Information Interchange (ASCII)
- A single-byte character encoding. Related blog article: Binary Files, Text Files and File Encodings.
- Case change
- There are four types of case-changing commands provided by the glossaries package:
- all caps
- For example,
\GLS
and\GLStext
. All letters in the given text are converted to uppercase (capitals). The actual case-conversion is performed by\glsuppercase
. - sentence case
- For example,
\Gls
and\Glstext
. Only the first letter is converted to uppercase. The case-conversion for the\gls
-like and\glstext
-like commands is performed via\glssentencecase
, which is simply defined to use the robust\makefirstuc
. Commands such as\Glsentrytext
also use\glssentencecase
in the document but use the expandable\MFUsentencecase
in PDF bookmarks. - title case
- For example,
\glsentrytitlecase
. The first letter of each word is converted to uppercase. The case-conversion is performed using\glscapitalisewords
in the document text, but commands designed for use in section headings, use the expandable\MFUsentencecase
in PDF bookmarks. - lowercase
- The command
\glslowercase
is provided to allow for the conversion of the short form of acronyms or abbreviations to lowercase for small caps styles. Note that\glslowercase
isn’t actually in the default definition any of the commands provided by glossaries but is provided in the event that any of those commands need redefining with an expandable definition. Alternatives are to use the robust\MakeLowercase
or switch to LaTeX3 syntax.
- Common Locale Data Repository (CLDR)
- A project of the Unicode Consortium that provides locale-specific information which an operating system will typically provide to applications.
- Command-line interface (CLI)
- An application that doesn’t have a graphical user interface. That is, an application that doesn’t have any windows, buttons or menus and can be run in a command prompt or terminal.
- Entry line
- The line in the glossary where the entry is shown. This may be a single row in a tabular-style or the start of a paragraph for list or index styles or mid-paragraph for the inline style. The exact formatting depends on the glossary style, but usually includes the name and description. If hyperlinks are enabled, the
\gls
-like and\glstext
-like commands will create a hyperlink to this line. - Entry location
- The location of the entry in the document (obtained from the location counter or from the thevalue option). This defaults to the page number on which the entry has been referenced with any of the
\gls
-like,\glstext
-like or\glsadd
commands. An entry may have multiple locations that form a list. See also §12.3. - Extended Latin alphabet
- An alphabet consisting of Latin characters and extended Latin characters.
- Extended Latin character
- A character that’s created by combining Latin characters to form ligatures (e.g. æ) or by applying diacritical marks to a Latin character or characters (e.g. á).
- Field
- Entry data is stored in fields. These may have a corresponding key used to set the value, such as name or description.
- First use
- The first time an entry is used by a command that unsets the first use flag (or the first time since the flag was reset).
- First use flag
- A conditional that keeps track of whether or not an entry has been referenced by any of the
\gls
-like commands (which can adjust their behaviour according to whether or not this flag is true). The conditional is true if the entry hasn’t been used by one of these commands (or if the flag has been reset) and false if it has been used (or if the flag has been unset). - First use text
- The link text that is displayed on first use of the
\gls
-like commands. - Group (letters, numbers, symbols)
- A logical division within a glossary that is typically a by-product of the indexing application’s sorting algorithm. Glossary styles may or may not start each group with a title (such as “Symbols” or “A”) or a vertical space. See also Gallery: Logical Glossary Divisions (type vs group vs parent).
- Graphical user interface (GUI)
- An application that has windows, buttons or menus.
- Glossary
- Technically a glossary is an alphabetical list of words relating to a particular topic. For the purposes of describing the glossaries and glossaries-extra packages, a glossary is either the list produced by commands like
\printglossary
or\printunsrtglossary
(which may or may not be ordered alphabetically) or a glossary is a set of entry labels where the set is identified by the glossary label or type. \gls
-like- Commands like
\gls
and\glsdisp
that change the first use flag. These commands index the entry (if indexing is enabled), create a hyperlink to the entry’s glossary listing (if enabled) and unset the first use flag. These commands end with the post-link hook. \glstext
-like- Commands like
\glstext
and\glslink
that don’t change the first use flag. These commands index the entry (if indexing is enabled) and create a hyperlink to the entry’s glossary listing (if enabled). These commands end with the post-link hook. - Hierarchical level
- A number that indicates how many ancestors an entry has. An entry with no parent has hierarchical level 0. If an entry has a parent then the hierarchical level for the entry is one more than the hierarchical level of the parent. Most styles will format an entry according to its hierarchical level, giving prominence to level 0 entries, although some may have a maximum supported limit. The level is stored in the level internal field. It can be accessed using commands like
\glsfieldfetch
or\glsxtrusefield
, but neither the level nor the parent values should be altered as it will cause inconsistencies in the sorting and glossary formatting. See also §4.5. - Homograph
- Each of a set of words that have the same spelling but have different meanings and origins. They may or may not have different pronunciations.
- Ignored glossary
- A glossary that has been defined using a command like
\newignoredglossary
. These glossaries are omitted by iterative commands, such as\printglossaries
and\printunsrtglossaries
. An ignored glossary can only be displayed with\printunsrtglossary
. - Ignored location (or record)
- A location that uses glsignore as the encap. With bib2gls, this indicates that the entry needs to be selected but the location isn’t added to the location list. With other methods, this will simply create an invisible location, which can result in unwanted commas if the location list has other items. With bib2gls v3.0+, empty locations will be converted to ignored locations.
- Indexing application
- An application (piece of software) separate from TeX/LaTeX that collates and sorts information that has an associated page reference. Generally the information is an index entry but in this case the information is a glossary entry.
The original indexing application used with TeX is makeindex (which can be also be used with other non-TeX text formatters). This was then followed by xindy, which provided more flexible support for different languages and encodings. The original release of glossaries only supported makeindex, since it was readily available in all TeX distributions, and a later release added support for xindy. There is now also a newer indexing application called xindex, which isn’t supported by glossaries or glossaries-extra (unless a way can be found of converting makeindex’s ist file to an equivalent xindex configuration file).
General purpose indexing applications that are developed independently are harder to fully integrate with the glossaries package, which has more complex requirements than a simple index. The glossaries-extra package additionally supports bib2gls, which is designed specifically for, and developed alongside, the glossaries-extra package. These are all CLI applications.
- Indexing file
- A file that’s input (read) by an indexing application, such as the style file (ist or xdy) or the files containing the indexing data (the sort value, hierarchical information, location encap and entry location). These files are output files from the point of view of the glossaries package as it’s TeX that creates and writes to those files. An indexing file may also refer to the files that are created by the indexing application. These are output files from the indexing application’s point of view, but they are input files from TeX’s point of view as they are input by commands used in the document.
- Indexing (or recording)
- The process of saving the entry location and any associated information that is required in the glossary. In the case of makeindex and xindy, the entry location, encap, entry item and sort value are written to a supplementary file associated with the glossary that is subsequently read by makeindex/xindy. In the case of bib2gls and the “noidx” method, the entry location, encap and label is written to the aux file.
- Internal field
- An internal field may refer to a key that shouldn’t be used in the bib file, such as the group field, or an internal field may refer to the label used to internally represent the field (which may or may not match the key used to set the field or may not have an associated key), such as useri which corresponds to the user1 key, or it may refer to a field that is only ever used internally that should not be explicitly modified, such as the field used to store the entry’s hierarchical level .
- Internal field (bib2gls)
- A field that is used or assigned by bib2gls that should typically not be used in the bib file.
- Internal field label
- The field label that forms part of the internal control sequence used to store the field value. This may or may not match the key used to assign the value when defining the entry. See Table 4.1.
- Latin alphabet
- The alphabet consisting of Latin characters.
- Latin character
- One of the letters “a”, …, “z”, “A”, …, “Z”.
- Link text
- The text produced by
\gls
-like and\glstext
-like commands that have the potential to be a hyperlink. - Location counter
- The counter used to obtain the entry location.
- Location encap (format)
- A command used to encapsulate an entry location. The control sequence name (without the leading backslash) is identified by the format key. The default encap is
\glsnumberformat
. See §12.1 for further details. - Location list
- A list of entry locations (also called a number list). May be suppressed for all glossaries with the package option nonumberlist or for individual glossaries with nonumberlist. With bib2gls, the list may also be suppressed with save-locations=false.
- Non-Latin alphabet
- An alphabet consisting of non-Latin characters.
- Non-Latin character
- An extended Latin character or a character that isn’t a Latin character.
- Post-description hook
- A hook (
\glspostdescription
) included in some glossary styles that is used after the description is displayed. The glossaries-extra package modifies this command to provide additional hooks. - Post-link hook
- A hook (command) that is used after link text to allow code to be automatically added. The base glossaries package provides a general purpose hook
\glspostlinkhook
. The glossaries-extra package modifies this command to provide additional hooks. - Print “unsrt” glossary commands
- The set of commands used for displaying a glossary or partial glossary that have “unsrt” in the name, such as
\printunsrtglossary
. See the glossaries-extra manual for further details. - Resource file
- The glstex file created by bib2gls and loaded by
\GlsXtrLoadResources
. - Resource set
- All the settings (resource options) and entries associated with a particular instance of
\GlsXtrLoadResources
. - Sanitize
- Converts command names into character sequences. That is, a command called, say,
\foo
, is converted into the sequence of characters:\
,f
,o
,o
. Depending on the font, the backslash character may appear as a dash when used in the main document text, so\foo
will appear as: —foo.Earlier versions of glossaries used this technique to write information to the files used by the indexing applications to prevent problems caused by fragile commands. Now, this is only used for the sort key.
- Shell escape
- Most LaTeX formats have the ability to run CLI applications while it’s typesetting a document. Whilst this is a convenient way of using tools to help build the document, it’s a security risk. To help protect users from arbitrary—and potentially dangerous—code from being executed, TeX has a restricted mode, where only trusted applications are allowed to run. This is usually the default mode, but your TeX installation may be set up so that the shell escape is disabled by default. The unrestricted mode allows you to run any application from the shell escape. Take care about enabling this option. If you receive a document or package from an untrusted source, first run LaTeX with the shell escape disabled or in restricted mode and search the log file for “runsystem” before using the unrestricted mode.
- Small capitals (small caps)
- The LaTeX kernel provides
to produce small capitals. This uses a font where lowercase letters have a small capital design. Uppercase letters have the standard height and there’s no noticeable difference with uppercase characters in corresponding non-small caps fonts. This means that for a small caps appearance, you need to use lowercase letters in the argument. The relsize package provides\textsc
{ }
which simulates small caps by reducing the size of the font, so in this case the contents of should be uppercase (otherwise the effect is simply smaller lowercase letters). Some fonts don’t support small caps combined with bold or slanted properties. In this case, there will be a font substitution warning and one of the properties (such as small caps or slanted) will be dropped.\textsmaller
{ } - Standard LaTeX extended Latin character
- An extended Latin character that can be created by a core LaTeX command, such as
\o
(ø) or
(é). That is, the character can be produced without the need to load a particular package.\'
e - Subsequent use
- Using an entry that unsets the first use flag when it has already been unset.
- Unicode Transformation Format (8-bit) (UTF-8)
- A variable-width encoding that uses 8-bit code units. This means that some characters are represented by more that one byte. XeLaTeX and LuaLaTeX treat the multi-byte sequence as a single token, but the older LaTeX formats have single-byte tokens, which can cause complications, although these have mostly been addressed with the newer kernels introduced over the past few years. Related blog article: Binary Files, Text Files and File Encodings.
- Whatsit
- A command whose execution is delayed or an OS-specific special command. This includes writing to external files (which is what indexing does).
Glossary Entry Keys Summary[link]
These are options that can be passed to commands that define entries, such as\newglossaryentry
or \newacronym
.
Accessibility text corresponding to the name field. §17.1; 384
Behaves in a similar manner to see={[\seealsoname
] } but also sets up aliasing which makes the link text hyperlink to instead. §4; 143
The entry’s category (must be a simple label). §4; 143
If set, the value indicates the location counter to use by default when indexing this entry (overrides the counter associated with the glossary or the counter package option). §4; 143
The entry’s description, as displayed in the glossary. If required in the text, use \glsdesc
(if indexing and hyperlinks are required) or \glsentrydesc
. Glossary styles should use \glossentrydesc
and \glspostdescription
to incorporate the post-description hook. §4; 136
Accessibility text corresponding to the description field. §17.1; 385
The plural form of the entry’s description, if applicable. If omitted, this is set to the same value as the description, since descriptions tend not to be a singular entity. §4; 137
Accessibility text corresponding to the descriptionplural field. §17.1; 385
The entry’s text, as displayed on first use of \gls
-like commands. Note that using an acronym style or post-link hooks is a more flexible approach. If omitted, this value is assumed to be the same as the text key. §4; 137
Accessibility text corresponding to the first field. §17.1; 385
The entry’s plural form, as displayed on first use of plural \gls
-like commands, such as \glspl
. If this key is omitted, then the value will either be the same as the plural field, if the first key wasn’t used, or the value will be taken from the first key with \glspluralsuffix
appended. §4; 138
Accessibility text corresponding to the firstplural field. §17.1; 385
The group label that identifies which letter group the entry belongs to. This key is only available with the record=only and record=nameref options, and is set by bib2gls, if invoked with --group or -g. Although this has a key, this is considered an internal key assigned by bib2gls as a by-product of sorting. Explicit use without reference to the order of entries can result in fragmented groups. The corresponding title can be set with \glsxtrsetgrouptitle
, although this is more commonly done implicitly within the glstex file. See also Gallery: Logical Glossary Divisions (type vs group vs parent).
The formatted location list used by the “unsrt” family of commands. This key is only available with the record option and is set by bib2gls unless save-locationsfalse is set. Although it has an associated key, it’s usually considered an internal field.
A field that is set by \newacronym
(and \newabbreviation
) to the entry’s long (unabbreviated) form. It typically shouldn’t be used explicitly with \newglossaryentry
as \newacronym
(and \newabbreviation
) makes other modifications to ensure that when the entry is referenced with the \gls
-like commands, it will obey the appropriate acronym style (or abbreviation style). If you are using bib2gls then this field should be used in the bib file when defining abbreviations. §4; 143
Accessibility text corresponding to the long field. §17.1; 385
As long but the plural form. §4; 143
Accessibility text corresponding to the longplural field. §17.1; 386
The entry’s name, as displayed in the glossary. This typically isn’t used outside of the glossary (the text and plural keys are used instead). However, if there is a need to specifically display the entry name, use \glsname
(if indexing and hyperlinks are required) or \glsentryname
. Glossary styles should use \glossentryname
rather than explicitly using \glsentryname
. §4; 136
If set, suppress the location list for this entry. This is done by adding \glsnonextpages
or \glsnextpages
to the indexing information for Options 2 and 3 or to the prenumberlist field for Option 1. §4; 140
The label of the entry’s parent (from which the entry’s hierarchical level is obtained). §4; 136
The entry’s plural form, as displayed on subsequent use of plural \gls
-like commands, such as \glspl
. This should be the appropriate plural form of the value provided by the text key. If omitted, this value is assumed to be the value of the text key with \glspluralsuffix
appended. §4; 137
Accessibility text corresponding to the plural field. §17.1; 385
The subsequent use singular prefix. §16; 376
The first use singular prefix. §16; 376
The first use plural prefix. §16; 376
The subsequent use plural prefix. §16; 376
With the base glossaries package this simply triggers an automatic cross-reference with \glssee
. The glossaries-extra package additionally saves the value. Use autoseeindex=false to prevent the automatic cross-reference. The defaults to \seename
and should be a comma-separated list of entries that have already been defined. §4; 141
Behaves in a similar manner to see={[\seealsoname
] }. §4; 142
A field that is set by \newacronym
to the entry’s short (abbreviated) form. It typically shouldn’t be used explicitly with \newglossaryentry
as \newacronym
(and \newabbreviation
) makes other modifications to ensure that when the entry is referenced with the \gls
-like commands, it will obey the appropriate acronym style (or abbreviation style). If you are using bib2gls then this field should be used in the bib file when defining abbreviations. §4; 143
Accessibility text corresponding to the short field. §17.1; 386
As short but the plural form. The default is obtained by appending the acronym or abbreviation plural suffix. §4; 143
Accessibility text corresponding to the shortplural field. §17.1; 386
Specifies the value to use for sorting (overrides the default). This key is usually required for xindy if the name key only contains commands (for example, the entry is a symbol), but explicitly using this key in other contexts can break certain sort methods. Don’t use the sort field with bib2gls. §4; 138
The entry’s associated symbol (optional), which can be displayed with \glssymbol
(if indexing and hyperlinks are required) or with \glsentrysymbol
. §4; 138
Accessibility text corresponding to the symbol field. §17.1; 385
The plural form of the symbol, if applicable, which can be displayed with \glssymbolplural
(if indexing and hyperlinks are required) or with \glsentrysymbolplural
. If omitted, this value is set to the same as the symbol key (since symbols usually don’t have a plural form). §4; 138
Accessibility text corresponding to the symbolplural field. §17.1; 385
The entry’s text, as displayed on subsequent use of \gls
-like commands. If omitted, this value is assumed to be the same as the name key. §4; 137
Accessibility text corresponding to the text field. §17.1; 385
Assigns the entry to the glossary identified by . §4; 140
A generic field, which can be displayed with \glsuseri
(if indexing and hyperlinks are required) or with \glsentryuseri
. §4; 140
Accessibility text corresponding to the user1 field. §17.1; 386
A generic field, which can be displayed with \glsuserii
(if indexing and hyperlinks are required) or with \glsentryuserii
. §4; 140
Accessibility text corresponding to the user2 field. §17.1; 386
A generic field, which can be displayed with \glsuseriii
(if indexing and hyperlinks are required) or with \glsentryuseriii
. §4; 140
Accessibility text corresponding to the user3 field. §17.1; 386
A generic field, which can be displayed with \glsuseriv
(if indexing and hyperlinks are required) or with \glsentryuseriv
. §4; 140
Accessibility text corresponding to the user4 field. §17.1; 386
A generic field, which can be displayed with \glsuserv
(if indexing and hyperlinks are required) or with \glsentryuserv
. §4; 140
Accessibility text corresponding to the user5 field. §17.1; 387
A generic field, which can be displayed with \glsuservi
(if indexing and hyperlinks are required) or with \glsentryuservi
. §4; 140
Accessibility text corresponding to the user6 field. §17.1; 387
\gls
-Like and \glstext
-Like Options Summary[link]
Most (but not all) of these options can be used in the optional argument of all the \gls
-like, \glstext
-like and \glsadd
commands.
The location counter. §5.1.1; 170
The encap or control sequence name (without the leading backslash) that should be used to encapsulate the entry location. §5.1.1; 169
Determines whether or not the link text should have a hyperlink (provided hyperlinks are supported). §5.1.1; 169
Determines whether the hyperlink should be inside or outside of \glstextformat
. §5.1.1; 170
If true use \glslocalunset
to unset the first use flag, otherwise use \glsunset
(only applies to \gls
-like commands). §5.1.1; 170
If true this option will suppress indexing. If you are using bib2gls, you may want to consider using format=glsignore to prevent a location but ensure that the entry is selected. §5.1.1; 170
Determines whether or not to unset the first use flag after the link text. The value may be one of: global
, local
or none
(only applies to \gls
-like commands). §5.1.1; 171
The prefix to use for the entry’s hyperlink target. §5.1.1; 171
Determines whether or not to reset the entry before the link text. Allowed values: none (no reset), local (localise the reset) and global. §5.1.1; 171
Determines whether or not to unset the entry before the link text. Allowed values: none (no unset), local (localise the unset) and global. §5.1.1; 171
The name of the control sequence to use instead of \glstextformat
to encapsulate the link text. §5.1.1; 170
Set the hyper location to this value instead of obtaining it from \theH
. §5.1.1; 171
Set the location to this value instead of obtaining it from the location counter. §5.1.1; 171
Only available with \glsaddall
, the value is the list of glossaries to iterate over. §10; 262
Determines whether to do the indexing before or after the link text. Allowed values: before and after. §5.1.1; 170
\print
Options Summary glossary[link]
Most (but not all) of these options can be used in the optional argument of all the \print
glossary commands.
If true, enable the entry counter. §8.1; 248
If true, treats all entries as though they have the same hierarchical level (the value of leveloffset). This option is only available for the “unsrt” commands. §8.1; 251
Enables letter group formation. This option is only available for the “unsrt” commands. Note that no groups will be formed when invoking bib2gls with the default --no-group, regardless of this setting. §8.1; 251
Adds
to the start of the glossary (after the title). §8.1; 250
\label
{ }
Set or increment the hierarchical level offset. If starts with ++
then the current offset is incremented by the given amount otherwise the current offset is set to . For example, an entry with a normal hierarchical level of 1 will be treated as though it has hierarchical level \(1+ \). This option is only available for the “unsrt” commands. §8.1; 251
If true, suppress the gap implemented by some glossary styles between groups. §8.1; 248
Suppress the location list. Note that nonumberlist=true will have no effect with the save-locationsfalse resource option as there won’t be any location lists to display. Likewise if \printunsrtglossary
is used without bib2gls. §8.1; 248
If true, suppress the post-description punctuation. §8.1; 248
Indicates whether or not glossary section headers will be numbered and also if they should automatically be labelled. The numberedsection package option will change the default setting to match. §8.1; 248
Redefines \glolinkprefix
to . §8.1; 250
Only available with \printnoidxglossary
, this indicates how the glossary should be ordered. §8.1; 249
Case-sensitive sort. 250
Order of definition. 249
Letter order. 250
Case-insensitive sort. 249
Word or letter order according to the order package option. 250
Order of use. 249
Word order. 250
Use the glossary style. §8.1; 248
If true, enable the sub-entry counter. §8.1; 248
If true, each entry in the glossary should have a hypertarget created, if supported by the glossary style and if hyperlinks are enabled. §8.1; 250
at the start of the hypertarget names.
Sets the glossary title (overriding the default). §8.1; 247
Sets the glossary toc title (overriding the default). §8.1; 247
Identifies the glossary to display. §8.1; 247
Acronym Style Summary[link]
The style should be set with\setacronymstyle
before the first instance of \newacronym
.
Both the first use and subsequent use only show the long form and the description must be supplied. §6.2.1.5; 215
Both the first use and subsequent use only show the long form. §6.2.1.5; 215
followed by the long form in a footnote and the description must be supplied.
in smallcaps followed by the long form in a footnote and the description must be supplied.
in smallcaps followed by the long form in a footnote.
in a smaller font followed by the long form in a footnote and the description must be supplied.
in a smaller font followed by the long form in a footnote.
followed by the long form in a footnote.
( ) with the short form in smallcaps and the description must be supplied.
( ) with the short form in smallcaps.
( ) where the description must be supplied.
( ).
( ) with the short form in a smaller font and the description must be supplied.
( ) with the short form in a smaller font.
( ) where the space may be converted to a non-breaking space and the description must be supplied.
( ) where the space may be converted to a non-breaking space.
( ) with the short form in smallcaps and a description must be supplied.
( ) with short form in smallcaps.
( ) and a description must be supplied.
( ).
( ) with the short form in a smaller font and a description must be supplied.
( ) with short form in a smaller font.
Glossary Styles Summary[link]
The default style may be set with\setglossarystyle
or with the style package option. The default style can be overridden for individual glossaries with the style option. For a summary of all available styles, see Gallery: Predefined Styles.
A list style using the description environment with the entry’s description starting on a new line. §13.1.1; 306
A list style using the description environment with the entry’s description starting on a new line with letter group headings. §13.1.1; 306
A list style using the description environment with the entry’s description starting on a new line with letter group headings and a navigation line. §13.1.1; 306
A tabular style using longtable with 4 columns allowing for multi-lined descriptions, a header row and rules. §13.1.4; 315
A tabular style using longtable with 4 columns allowing a multiline description. §13.1.2; 310
A tabular style using longtable with 4 columns allowing a multiline description with border lines. §13.1.2; 310
A tabular style using longtable with 4 columns allowing a multiline description with a header row. §13.1.2; 310
A tabular style using longtable with 4 columns allowing a multiline description with a header row and border lines. §13.1.2; 310
A tabular style using longtable with 4 columns, a header row and rules, and ragged right formatting for the description. §13.1.4; 315
A tabular style using longtable with 4 columns and ragged right formatting for the description. §13.1.3; 312
A tabular style using longtable with 4 columns and ragged right formatting for the description and border lines. §13.1.3; 313
A tabular style using longtable with 4 columns and ragged right formatting for the description, and a header row. §13.1.3; 313
A tabular style using longtable with 4 columns and ragged right formatting for the description, border lines and a header row. §13.1.3; 313
A tabular style using supertabular with 4 columns allowing multiline descriptions. §13.1.5; 318
A tabular style using supertabular with 4 columns and a header row allowing multiline descriptions. §13.1.5; 318
A tabular style using supertabular with 4 columns, a header row and border lines allowing multiline descriptions. §13.1.5; 318
A tabular style using supertabular with 4 columns and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 4 columns and border lines, and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 4 columns and a header row, and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 4 columns, a header row and border lines, and ragged right formatting for the description. §13.1.6; 320
A hierarchical style that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.7; 324
A hierarchical style with letter group headings that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.7; 325
A hierarchical style with letter group headings and navigation line that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.7; 325
Designed for indexes, the description isn’t shown.
A style similar to standard indexes but also shows the description and, if set, the symbol. §13.1.7; 322
A style similar to standard indexes with letter group headings but also shows the description and, if set, the symbol. §13.1.7; 323
A style similar to standard indexes with letter group headings and a navigation line but also shows the description and, if set, the symbol. §13.1.7; 323
An inline homograph style. §13.1.9; 328
A list style using the description environment. §13.1.1; 305
A list style with a dotted leader between the name and description. §13.1.1; 306
A list style using the description environment with letter group headings. §13.1.1; 306
A list style using the description environment with letter group headings and a navigation line. §13.1.1; 306
A tabular style using longtable with 2 columns a header row and rules. §13.1.4; 315
Tabular style with 4 columns.
Tabular style with 2 columns.
A tabular style using longtable with 2 columns. §13.1.2; 308
A tabular style using longtable with 3 columns a header row and rules. §13.1.4; 315
A tabular style using longtable with 3 columns. §13.1.2; 309
A tabular style using longtable with 3 columns and border lines. §13.1.2; 309
A tabular style using longtable with 3 columns and a header row. §13.1.2; 309
A tabular style using longtable with 3 columns, a header row and border lines. §13.1.2; 309
A tabular style using longtable with 4 columns a header row and rules. §13.1.4; 315
A tabular style using longtable with 4 columns. §13.1.2; 309
A tabular style using longtable with 4 columns and border lines. §13.1.2; 309
A tabular style using longtable with 4 columns and a header row. §13.1.2; 309
A tabular style using longtable with 4 columns, a header row and border lines. §13.1.2; 310
A tabular style using longtable with 2 columns and border lines. §13.1.2; 308
A tabular style using longtable with 2 columns and a header row. §13.1.2; 308
A tabular style using longtable with 2 columns, a header row and border lines. §13.1.2; 308
A tabular style using longtable with 2 columns, a header row and rules, and ragged right formatting for the description. §13.1.4; 315
A tabular style using longtable with 2 columns and ragged right formatting for the description. §13.1.3; 311
A tabular style using longtable with 3 columns, a header row and rules, and ragged right formatting for the description. §13.1.4; 315
A tabular style using longtable with 3 columns and ragged right formatting for the description. §13.1.3; 312
A tabular style using longtable with 3 columns and ragged right formatting for the description and border lines. §13.1.3; 312
A tabular style using longtable with 3 columns and ragged right formatting for the description, and a header row. §13.1.3; 312
A tabular style using longtable with 3 columns and ragged right formatting for the description, border lines and a header row. §13.1.3; 312
A tabular style using longtable with 2 columns and ragged right formatting for the description and border lines. §13.1.3; 311
A tabular style using longtable with 2 columns and ragged right formatting for the description, and a header row. §13.1.3; 312
A tabular style using longtable with 2 columns and ragged right formatting for the description, border lines and a header row. §13.1.3; 312
A multicolumn hierarchical style that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.8; Table 13.2
A multicolumn hierarchical style with letter group headings that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.8; Table 13.2
A hierarchical style with letter group headings and navigation line at the start of the first column that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.8; Table 13.2
A hierarchical style with letter group headings and navigation line spanning all columns that shows the name, description and, if set, the symbol. The name is set in a box whose width is given by the widest name that has to be identified with \glssetwidest
. §13.1.8; Table 13.2
A multicolumn style similar to standard indexes but also shows the description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn style similar to standard indexes with letter group headings but also shows the description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn style similar to standard indexes with letter group headings and a navigation line at the start of the first column but also shows the description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn style similar to standard indexes with letter group headings and a navigation line spanning all columns but also shows the description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn hierarchical style that shows the name, description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn hierarchical style with letter group headings that shows the name, description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn hierarchical style with letter group headings and navigation line at the start of the first column that shows the name, description and, if set, the symbol. §13.1.8; Table 13.2
A multicolumn homograph style that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.8; Table 13.2
A multicolumn homograph style with letter group headings that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.8; Table 13.2
A multicolumn homograph style with letter group headings and navigation line at the start of the first column that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.8; Table 13.2
A multicolumn homograph style with letter group headings and navigation line spanning all columns that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.8; Table 13.2
A multicolumn hierarchical style with letter group headings and navigation line spanning all columns that shows the name, description and, if set, the symbol. §13.1.8; Table 13.2
A list style with just the name for top-level entries and a dotted leader between the name and description for sub-entries. §13.1.1; 307
A tabular style using supertabular with 2 columns. §13.1.5; 316
A tabular style using supertabular with 3 columns. §13.1.5; 317
A tabular style using supertabular with 3 columns and border lines. §13.1.5; 317
A tabular style using supertabular with 3 columns and a header row. §13.1.5; 317
A tabular style using supertabular with 3 columns, a header row and border lines. §13.1.5; 317
A tabular style using supertabular with 4 columns. §13.1.5; 317
A tabular style using supertabular with 4 columns and border lines. §13.1.5; 317
A tabular style using supertabular with 4 columns and a header row. §13.1.5; 317
A tabular style using supertabular with 4 columns, a header row and border lines. §13.1.5; 317
A tabular style using supertabular with 2 columns and border lines. §13.1.5; 316
A tabular style using supertabular with 2 columns and a header row. §13.1.5; 316
A tabular style using supertabular with 2 columns, a header row and border lines. §13.1.5; 316
A tabular style using supertabular with 2 columns and ragged right formatting for the description. §13.1.6; 319
A tabular style using supertabular with 3 columns and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 3 columns and border lines, and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 3 columns and a header row, and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 3 columns, a header row and border lines, and ragged right formatting for the description. §13.1.6; 320
A tabular style using supertabular with 2 columns and border lines, and ragged right formatting for the description. §13.1.6; 319
A tabular style using supertabular with 2 columns and a header row, and ragged right formatting for the description. §13.1.6; 319
A tabular style using supertabular with 2 columns, a header row and border lines, and ragged right formatting for the description. §13.1.6; 319
Designed for paragraph length top-level descriptions.
Designed for paragraph length top-level descriptions with sub-entries in multiple columns.
A hierarchical style that shows the name, description and, if set, the symbol. §13.1.7; 323
A hierarchical style with letter group headings that shows the name, description and, if set, the symbol. §13.1.7; 323
A hierarchical style with letter group headings and navigation line that shows the name, description and, if set, the symbol. §13.1.7; 323
A homograph style that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.7; 323
A homograph style with letter group headings that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.7; 323
A homograph style with letter group headings and navigation line that shows the top-level name, description and, if set, the symbol, but omits the name for sub-entries. §13.1.7; 324
Command Summary[link]
@[link]
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. The indicates the xindy codepage. §1.7.1; 76
This command is written to the aux file to provide the information for \printnoidxglossary
. §1.7.1; 77
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. The should be either letter
or word
. §1.7.1; 76
This command is written to the aux file to provide the \GlsXtrSetAltModifier
information for bib2gls. §1.7.3; 78
This command is written to the aux file to provide the \glsxtrnewglslike
information for bib2gls. §1.7.3; 78
This command is written to the aux file to provide the \dgls
information for bib2gls. §1.7.3; 78
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. The is the name of the style file. §1.7.1; 76
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. The arguments indicate the file extensions associated with the given glossary. §1.7.1; 75
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. The is the language to pass to xindy for the given glossary. §1.7.1; 76
A[link]
Expands to the title of the abbreviations
glossary. The default is “Abbreviations” or \acronymname
if babel has been detected.
A synonym for \Gls
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \gls
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Acrfull
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrfull
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Acrfullpl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrfullpl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Acrlong
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrlong
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Acrlongpl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrlongpl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Glspl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \glspl
defined by the shortcuts package option. §6.1; Table 6.1
As \acrfull
but all caps. §6.1; 204
As \acrfull
but sentence case. §6.1; 204
References the acronym identified by . The text produced shows the full form, formatted according to the acronym style. With glossaries-extra, use \glsxtrfull
instead. For the first optional argument, see \glslink
options. §6.1; 204
Used by \ACRfull
to format the full form. This command is redefined by acronym styles.
Used by \Acrfull
to format the full form. This command is redefined by acronym styles.
Used by \acrfull
to format the full form. This command is redefined by acronym styles.
Deprecated with the introduction of \setacronymstyle
but used in the initial definition of commands like \glsentryfmt
before they are redefined by the acronym style. This may be removed in a future release.
As \acrfullpl
but all caps. §6.1; 204
As \acrfullpl
but sentence case. §6.1; 204
As \acrfull
but shows the full plural form of an acronym. With glossaries-extra, use \glsxtrfullpl
instead. For the first optional argument, see \glslink
options. §6.1; 204
Used by \ACRfullpl
to format the full form. This command is redefined by acronym styles.
Used by \Acrfullpl
to format the full form. This command is redefined by acronym styles.
Used by \acrfullpl
to format the full form. This command is redefined by acronym styles.
Deprecated with the introduction of \setacronymstyle
but used in the initial definition of commands like \acrfullfmt
before they are redefined by the acronym style. This may be removed in a future release.
As \acrlong
but converts the link text to all caps. §6.1; 203
As \acrlong
but converts the link text to sentence case. §6.1; 203
References the acronym identified by . The text produced is obtained from the long value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. With glossaries-extra, use \glsxtrlong
instead. For the first optional argument, see \glslink
options. §6.1; 203
As \acrlongpl
but converts the link text to all caps. §6.1; 204
As \acrlongpl
but converts the link text to sentence case. §6.1; 203
References the acronym identified by . The text produced is obtained from the longplural value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. With glossaries-extra, use \glsxtrlongpl
instead. For the first optional argument, see \glslink
options. §6.1; 203
Used by acronym styles that require an additional description to determine what information is displayed in the name.
Used by acronym styles to format the acronym name. §6.2; 208
Used to encapsulate the acronym short form on subsequent use. §6.2.1; 209
Provided by glossaries if it hasn’t already been defined. Used as the default title for the glossary created by the acronyms option. §1.5.1; Table 1.2
Used by acronym styles in the acronym sort key. §6.2; 209
Expands to the label of the default acronym glossary. The acronym or acronyms package option will redefine this to acronym
. The glossaries-extra package’s abbreviations option will redefine this to \glsxtrabbrvtype
if acronyms/acronym isn’t used. §9; 260
Suffix used in the default shortplural value by \newacronym
. §6.2.1; 210
As \acrshort
but converts the link text to all caps. §6.1; 203
As \acrshort
but converts the link text to sentence case. §6.1; 202
References the acronym identified by . The text produced is obtained from the short value, formatted according to the acronym style. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. With glossaries-extra, use \glsxtrshort
instead. For the first optional argument, see \glslink
options. §6.1; 202
As \acrshortpl
but converts the link text to all caps. §6.1; 203
As \acrshortpl
but converts the link text to sentence case. §6.1; 203
References the acronym identified by . The text produced is obtained from the shortplural value, formatted according to the acronym style. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. With glossaries-extra, use \glsxtrshortpl
instead. For the first optional argument, see \glslink
options. §6.1; 203
A synonym for \Acrshort
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrshort
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \Acrshortpl
defined by the shortcuts package option. §6.1; Table 6.1
A synonym for \acrshortpl
defined by the shortcuts package option. §6.1; Table 6.1
Adds the redefinition of \glossaryname
to \captions
if translator has been loaded (does nothing if translator hasn’t been loaded).
A shortcut that supplies file extensions based on the
argument:\newglossary
[ -glg]{ }{ -gls}{ }{ }[ ]
§9; 259
Provided by glossaries if it hasn’t already been defined.
Locally appends preamble for the glossary identified by . If is omitted, \glsdefaulttype
is assumed. §8.2; 255
B[link]
Delimiter used between locations in the location list, except for the last pair.
Delimiter used between the last pair of locations in the location list.
C[link]
Converts title case, where may contain text-block commands. The starred form only permits a text-block command at the start of the argument. Limitations apply, see the mfirstuc documentation for further details, either:
totexdoc mfirstucor visit ctan.org/pkg/mfirstuc.
Converts title case. Limitations apply, see the mfirstuc documentation for further details, either:
totexdoc mfirstucor visit ctan.org/pkg/mfirstuc.
Like \Gls
but hooks into the entry counting mechanism. §7.1; 241
Like \gls
but hooks into the entry counting mechanism. §7.1; 240
Format used by \cGls
if the entry was only used once on the previous run. §7.1; 242
Format used by \cgls
if the entry was only used once on the previous run. §7.1; 241
Like \Glspl
but hooks into the entry counting mechanism. §7.1; 241
Like \glspl
but hooks into the entry counting mechanism. §7.1; 240
Format used by \cGlspl
if the entry was only used once on the previous run. §7.1; 242
Format used by \cglspl
if the entry was only used once on the previous run. §7.1; 241
Defined by the \print
glossary commands to the current glossary label. §8; 247
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \newacronymstyle
and \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \newacronymstyle
and \setacronymstyle
.
D[link]
Identifies the list of glossaries as lists of acronyms. §2.7; 122
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
This was originally used to define a format the way the link text was displayed on first use by the \gls
-like commands. Deprecated in v3.11a and removed in v4.50. Use rollback if backward-compatibility required, but it’s better to switch to \defglsentryfmt
.
This was originally used to define a format the way the link text was displayed on first use by the \gls
-like commands. Deprecated in v3.11a and removed in v4.50. Use rollback if backward-compatibility required, but it’s better to switch to \defglsentryfmt
.
Defines the display format used by the \gls
-like commands for entries assigned to the glossary identified by (\glsdefaulttype
if omitted). §5.1.4; 181
Provides the shortcut commands for acronyms. §2.7; 123
Used as a separator between locations. §12; 272
Used between the start and end of a location range. §12.2; 278
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Provided by glossaries if it hasn’t already been defined. Used as a column header for some of the tabular-like glossary styles. §1.5.1; Table 1.2
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Does
for the first prefix in the prefix list that matches a defined entry.
\gls
[ ]{ {entry-label}}[ ]
Formats the comma-separated list datatool documentation for further details, either:
. One-level expansion is performed on . See thetexdoc datatoolor visit ctan.org/pkg/datatool.
Does datatool documentation for further details, either:
if is contained in the comma-separated list , otherwise does . One-level expansion is performed on , but not on . See thetexdoc datatoolor visit ctan.org/pkg/datatool.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
E[link]
Provided by glossaries if it hasn’t already been defined. Used as a column header for some of the tabular-like glossary styles. §1.5.1; Table 1.2
F[link]
Used to encapsulate the acronym short form on first use. §6.2.1; 209
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Iterates overall all lists of abbreviations, defines the command
to the current label and does .
Iterates overall all glossaries that have been declared lists of acronyms, defines the command to the current label and does . §15.3; 364
Iterates overall all the glossary labels given in the argument, defines the command to the current label and does . If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §15.3; 364
Does \forglsentries
for each glossary. The optional argument is a comma-separated list of glossary labels. If omitted, all non-ignored glossaries is assumed. §15.3; 364
Iterates over all entries in the given glossary and, at each iteration, defines the command to the current entry label and does . The optional argument is the glossary label and defaults to \glsdefaulttype
if omitted. This command can’t be used with bib2gls since there are no defined entries until bib2gls has selected them and added them to the glstex file. §15.3; 364
G[link]
As \genacrfullformat
but sentence case. §5.1.4; 185
Used by \glsgenacfmt
to display the acronym singular full form on first use. Redefined by acronym styles. §5.1.4; 184
Expands to the additional keys that need to be provided to \newglossaryentry
when called by \newacronym
. For example, the description key. §6.2.2; 217
As \genplacrfullformat
but sentence case. §5.1.4; 185
Used by \glsgenacfmt
to display the acronym plural full form on first use. Redefined by acronym styles. §5.1.4; 184
Glo[link]
Expands to the prefix used for entry targets. §13.2.1; 333
Change allowed options that are defined or modified by the glossaries-extra package. Note that some options can only be passed as package options.
This isn’t actually defined as a command but is used as a keyword for makeindex. §12.5; 286
Encapsulations the number list in the glossary and is also used to save the number list with the savenumberlist option. This command is redefined by options such as nonumberlist or commands like \glsnonextpages
. §8.2; 256
Does the header code after
. §13.2.3; 337
\begin{theglossary}
Only provided if it hasn’t already been defined for backward-compatibility. Use \glsglossarymark
instead. §8.2; 252
Provided by glossaries if it hasn’t already been defined. Used as the default title for glossaries without a specified title. May already be defined by a language package. §1.5.1; Table 1.2
Used at the end of the glossary. §8.2; 255
Used at the start of the glossary. This will be locally redefined to the preamble associated with the current glossary, if one has been set. §8.2; 254
Used to display the glossary heading. §8.2; 252
Sets the default glossary style to . Deprecated in v3.08a and removed in v4.50. Now only available with rollback. Use \setglossarystyle
instead.
Defined by \print
glossary to the current glossary’s title. §8.2; 253
Defined by \print
glossary to the current glossary’s title for the table of contents (if toctrue). §8.2; 253
Redefined by the glossary styles to display top level (level 0) entries. §13.2.3; 338
As \glossentrydesc
but sentence case. §13.2.1; 334
Used within glossary styles to display the description. §13.2.1; 334
As \glossentryname
but sentence case. §13.2.1; 334
Used within glossary styles to display the name encapsulated with \glsnamefont
. §13.2.1; 333
Behaves like \glossentryname
but uses the given field (identified by its internal label) instead of name.
As \glossentrysymbol
but sentence case. §13.2.1; 334
Used within glossary styles to display the symbol. §13.2.1; 334
Gls[link]
As \gls
but converts the link text to all caps. §5.1.2; 173
As \gls
but converts the link text to sentence case. §5.1.2; 173
References the entry identified by first use. The argument may be inserted at the end of the link text or may be inserted at a different point (for example, after the long form on first use for some acronym or abbreviation styles. For the first optional argument, see \glslink
options. §5.1.2; 172
Used by \glsaccessibility
to provide the accessibility support. §17.5; 394
Expands to the accessibility support engine. This command may be defined before glossaries-accsupp is loaded. §17.5; 394
Font formatting command for the short form, initialised by the abbreviation style.
Applies accessibility attribute for the given . This internally uses the accessibility support provided by accsupp. §17.2; 388
as the
The sentence case version of \glsaccesslong
.
If accessibility support was enabled when glossaries-extra was loaded (accsupp) this will display the value of the long key with the accessibility support enabled for that key (longaccess). If there is no accessibility support, this just uses \glsentrylong
.
The sentence case version of \glsaccesslongpl
.
If accessibility support was enabled when glossaries-extra was loaded (accsupp) this will display the value of the longplural key with the accessibility support enabled for that key (longpluralaccess). If there is no accessibility support, this just uses \glsentrylongpl
.
If accessibility support was enabled when glossaries-extra was loaded (accsupp) this will display the value of the name key with the accessibility support enabled for that key (access). If there is no accessibility support, this just uses \glsentryname
.
If accessibility support was enabled when glossaries-extra was loaded (accsupp) this will display the value of the short key with the accessibility support enabled for that key (shortaccess). If there is no accessibility support, this just uses \glsentryshort
.
If accessibility support was enabled when glossaries-extra was loaded (accsupp) this will display the value of the shortplural key with the accessibility support enabled for that key (shortpluralaccess). If there is no accessibility support, this just uses \glsentryshortpl
.
Applies \glsaccessibility
. §17.2; 387
Short plural suffix, this command is changed by acronym styles. §6; 199
Uses a non-breakable space if the short form is less than 3em. This command is redefined by glossaries-extra to use \glsacspacemax
instead of the hard-coded 3em. §6.2.1.1; 212
Expands to the maximum width used by \glsacspace
. This is a macro not a register. The default is 3em
.
Indexes the entry identified by §10; 261
.
Iterates over all non-ignored glossaries (or all those listed in the types option) and indexes each entry in the glossary. The optional argument are passed to \glsadd
. This command can’t be used with bib2gls. Use the selection=all resource option instead. §10; 262
Iterates over all glossaries listed in (all all non-ignored glossaries if omitted) and indexes each entry (with format=glsignore) that hasn’t been used. This command can’t be used with bib2gls. Use the selection=all resource option instead. §10; 262
Does
for each label in the supplied comma-separated list.
\glsadd
[ ]{ }
Defines a new glossary entry key with the given default value and commands that are analogous to \glsentrytext
( ), \Glsentrytext
( ), \glstext
( ), \Glstext
( ), \GLStext
( ). The starred version switches on field expansion for the given key. §4.3.1; 147
Adds a new xindy letter group, identified by and defined by . This information is written to the xdy file that’s created by \makeglossaries
.
Provides a new glossary entry key with a default value and a command for simply accessing the value (without indexing or hyperlinks). The starred version switches on field expansion for the given key. §4.3.2; 149
Adds the xindy attributes associated with to the xdy style file. §14.3; 348
Identifies all the location counters required in the document. §14.3; 348
Adds the given location syntax to the xdy style file. §14.3; 349
Adds a required xindy file to the xdy style file. §14.1; 345
Expands to the prefix for the label used by numberedsection=autolabel and numberedsection=nameref. §2.2; 90
Expands to \
(a literal backslash). §14; 344
Just does \capitalisewords
but may be redefined to use \capitalisefmtwords
, if required. §15.2; 363
Defined by the \gls
-like commands to expand to if the calling command wasn’t a case-changing
command (\gls
or \glspl
), to for sentence case commands (\Gls
or \Glspl
) or to for all caps commands (\GLS
or \GLSpl
). §5.1.4; 182
Expands to the entry’s category.
Used to clear the page at the start of a glossary. §8.2; 253
Expands to (a literal closing brace). §14; 344
The default counter as specified by the counter option. §2.3; 98
Assigned at the start of each entry item within the glossary. This command may be used by glossary hooks, such as \glspostdescription
, to reference the current entry.
Conditional commands such as \ifglshasfield
set this to the field’s value for use within the code. §15.4; 369
Placeholder command that expands to the text provided in \glsdisp
. §5.1.4; 182
Identifies the list of glossaries that should have hyperlinks suppressed. §2.6; 117
The default value for the shortaccess key when defining acronyms with \newacronym
. §17.1; 386
Expands to the label of the default glossary, which is normally main
but if nomain is used, it will be the label of the first glossary to be defined.
Defines post-description hook associated with the category identified by the label .
Defines post-link hook associated with the category identified by the label .
This command is written to the glsdefs file to define the given entry using the definition provided in the document environment on the previous LaTeX run.
As \glsdesc
but converts the link text to all caps. §5.1.3; 178
As \glsdesc
but converts the link text to sentence case. Use \Glossentrydesc
within custom glossary styles instead of this command. §5.1.3; 178
References the entry identified by description value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. Use \glossentrydesc
within custom glossary styles instead of this command. §5.1.3; 178
As \glsdescplural
but converts the link text to all caps.
As \glsdescplural
but converts the link text to sentence case.
As \glsdesc
but for the descriptionplural field.
Does descriptionaccess replacement text (if set). §17.3; 390
with the
Does descriptionpluralaccess replacement text (if set). §17.3; 390
with the
A length register used to set the width of the description column for tabular-like styles. §13.1; 301
Disables hyperlinks (may be scoped to localise the effect). §15.1; 359
As \glsdisp
but converts to sentence case. §5.1.2; 174
References the entry identified by link text. This command unsets the first use flag (use \glslink
instead, if the first use flag should not be altered). This command is considered a \gls
-like command. For the first optional argument, see \glslink
options. §5.1.2; 174
This was originally used to format the way the link text was displayed on first use by the \gls
-like commands. Deprecated in v3.11a and removed in v4.50. Use rollback if backward-compatibility required, but it’s better to switch to \glsentryfmt
.
This was originally used to format the way the link text was displayed on first use by the \gls
-like commands. Deprecated in v3.11a and removed in v4.50. Use rollback if backward-compatibility required, but it’s better to switch to \glsentryfmt
.
Formats the location list for the given entry. Redefined by glossaries-extra-bib2gls to obtain the location list from the location field. §5.2; 195
Creates a hyperlink to the given target using \hyperlink
, and includes the debugging information if debug=showtargets. §15.1; 360
Hook used by \glsdohyperlink
. Does nothing by default. §15.1; 360
Creates a hypertarget, and includes the debugging information if debug=showtargets. This uses \hypertarget
but measures the height of so that the target can be placed at the top of instead of along the baseline. §15.1; 359
Hook used by \glsdohypertarget
. Does nothing by default. §15.1; 360
Does entry given by exists. If the entry doesn’t exist, this will generate an error. §15.4; 366
if the
Similar to \ifglsentryexists
, this does if the entry given by exists. If the entry doesn’t it exist, this does and generates an error. §15.4; 366
Like \glsdoifexists
, but always warns (no error) if the entry doesn’t exist. §15.4; 366
Does entry given by does not exist. If the entry does exist, this will generate an error. §15.4; 366
if the
Used instead of \glsdohyperlink
when hyperlinks are disabled. This simply expands to . §15.1; 359
Sanitizes the sort value if sanitizesort=true. §2.5; 107
Enables entry counting. §7.1; 239
Enables hyperlinks (may be scoped to localise the effect). §15.1; 359
As \glsstartrange
but with the end range marker )
.
Expands to the value of the access field. §17.4; 392
Defined by \setentrycounter
to its argument. §12.1; 276
Sets \ifglsentrycounter
to false. §2.3; 93
Displays the formatted value of the glossaryentry counter or does nothing if entrycounter=false. §2.3; 93
Expands to the prefix used by \glsrefentry
. §2.3; 92
Sets \ifglsentrycounter
to true. §2.3; 93
Expands to the current entry count running total or 0 if not available (needs to be enabled with \glsenableentrycount
). §7.1; 239
Partially robust command that displays the value of the description field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 193
Simply expands to the value of the description field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the description field doesn’t contain any fragile commands. §5.2; 192
Expands to the value of the descaccess field. §17.4; 392
Partially robust command that displays the value of the descriptionplural field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 193
Simply expands to the value of the descriptionplural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the descriptionplural field doesn’t contain any fragile commands. §5.2; 193
Expands to the value of the descpluralaccess field. §17.4; 393
Partially robust command that displays the value of the first field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 192
Simply expands to the value of the first field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the first field doesn’t contain any fragile commands. §5.2; 192
Expands to the value of the firstaccess field. §17.4; 392
Partially robust command that displays the value of the firstplural field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 192
Simply expands to the value of the firstplural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the firstplural field doesn’t contain any fragile commands. §5.2; 192
Expands to the value of the firstpluralaccess field. §17.4; 392
The default display format used by the \gls
-like commands. This command is redefined by the glossaries-extra package. §5.1.4; 181
As \glsentryfull
but all caps.
As \glsentryfull
but sentence case. §6.1; 206
Displays the singular full form of the acronym identified by , without hyperlinks or indexing. This command is redefined by acronym styles to match the style format. §6.1; 206
As \glsentryfullpl
but all caps.
As \glsentryfullpl
but sentence case. §6.1; 206
Displays the plural full form of the acronym identified by , without hyperlinks or indexing. This command is redefined by acronym styles to match the style format. §6.1; 206
Used for top level (level 0) entries in glossary styles to increment and display the entry counter if entrycounter=true. §13.2.1; 332
Displays the value of the long field with sentence case applied. Does nothing if the entry hasn’t been defined. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §6.1; 205
Simply expands to the value of the long field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the long field doesn’t contain any fragile commands. §6.1; 204
Expands to the value of the longaccess field. §17.4; 393
Displays the value of the longplural field with sentence case applied. Does nothing if the entry hasn’t been defined. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §6.1; 205
Simply expands to the value of the longplural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the longplural field doesn’t contain any fragile commands. §6.1; 205
Expands to the value of the longpluralaccess field. §17.4; 393
Partially robust command that displays the value of the name field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 191
Simply expands to the value of the name key. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the name key doesn’t contain any fragile commands. §5.2; 191
Displays the location list for the given entry. Redefined by glossaries-extra-bib2gls to obtain the location list from the location field. §5.2; 195
Expands to the value of the parent field. Expands to nothing if the parent field hasn’t been set and expands to \relax
if the entry hasn’t been defined. §15.6; 374
Partially robust command that displays the value of the plural field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 192
Simply expands to the value of the plural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the plural field doesn’t contain any fragile commands. §5.2; 192
Expands to the value of the pluralaccess field. §17.4; 392
As \glsentryprefix
but sentence case. §16; 381
Expands to the value of the prefix field. §16; 380
As \glsentryprefixfirst
but sentence case. §16; 381
Expands to the value of the prefixfirst field. §16; 381
As \glsentryprefixfirstplural
but sentence case. §16; 381
Expands to the value of the prefixfirstplural field. §16; 381
As \glsentryprefixplural
but sentence case. §16; 381
Expands to the value of the prefixplural field. §16; 381
Expands to the final entry count total from the previous LaTeX run or if 0 if not available (needs to be enabled with \glsenableentrycount
). §7.1; 239
Displays the value of the short field with sentence case applied. Does nothing if the entry hasn’t been defined. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §6.1; 206
Simply expands to the value of the short field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the short field doesn’t contain any fragile commands. §6.1; 205
Expands to the value of the shortaccess field. §17.4; 393
Displays the value of the shortplural field with sentence case applied. Does nothing if the entry hasn’t been defined. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command.
Simply expands to the value of the shortplural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the shortplural field doesn’t contain any fragile commands.
Expands to the value of the shortpluralaccess field. §17.4; 393
Simply expands to the value of the sort key. Does nothing if the entry hasn’t been defined. §15.6; 374
Partially robust command that displays the value of the symbol field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 193
Simply expands to the value of the symbol field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the symbol field doesn’t contain any fragile commands. §5.2; 193
Expands to the value of the symbolaccess field. §17.4; 392
Partially robust command that displays the value of the symbolplural field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 193
Simply expands to the value of the symbolplural field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the symbolplural field doesn’t contain any fragile commands. §5.2; 193
Expands to the value of the symbolpluralaccess field. §17.4; 392
Partially robust command that displays the value of the text field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 192
Simply expands to the value of the text field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the text field doesn’t contain any fragile commands. §5.2; 192
Expands to the value of the textaccess field. §17.4; 392
Applies title case to the given field using \glscapitalisewords
or sentence case in PDF bookmarks. §5.2; 190
Simply expands to the value of the type key. Does nothing if the entry hasn’t been defined. §15.6; 373
Partially robust command that displays the value of the user1 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 193
Simply expands to the value of the user1 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user1 field doesn’t contain any fragile commands. §5.2; 193
Expands to the value of the user1access field. §17.4; 393
Partially robust command that displays the value of the user2 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 194
Simply expands to the value of the user2 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user2 field doesn’t contain any fragile commands. §5.2; 194
Expands to the value of the user2access field. §17.4; 393
Partially robust command that displays the value of the user3 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 194
Simply expands to the value of the user3 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user3 field doesn’t contain any fragile commands. §5.2; 194
Expands to the value of the user3access field. §17.4; 393
Partially robust command that displays the value of the user4 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 194
Simply expands to the value of the user4 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user4 field doesn’t contain any fragile commands. §5.2; 194
Expands to the value of the user4access field. §17.4; 394
Partially robust command that displays the value of the user5 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 194
Simply expands to the value of the user5 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user5 field doesn’t contain any fragile commands. §5.2; 194
Expands to the value of the user5access field. §17.4; 394
Partially robust command that displays the value of the user6 field with sentence case applied. As from glossaries v4.50, this command can expand in PDF bookmarks. Outside of PDF bookmarks it will expand to a robust internal command. §5.2; 194
Simply expands to the value of the user6 field. Does nothing if the entry hasn’t been defined. May be used in expandable contexts provided that the user6 field doesn’t contain any fragile commands. §5.2; 194
Expands to the value of the user6access field. §17.4; 394
Expand values when assigning fields during entry definition (except for specific fields that are overridden by \glssetnoexpandfield
). §4.4; 156
If defined, used by \glsfieldaccsupp
for the accessibility support for the internal field label given by . §17.2; 387
If glossaries-extra has been loaded, this command will first check for the existence of the command \glsxtr
accsupp. If that command doesn’t exist or if glossaries-extra hasn’t been loaded, it then checks for the existence of \gls
(for example, accsupp\glsshortaccsupp
). Failing that it will use \glsaccsupp
. Whichever command is found first, is performed. { }{ }§17.2; 387
Locally assigns the internal field label ) for the entry identified by . Produces an error (or warning with undefaction=warn) if the entry or field doesn’t exist. Note that this doesn’t update any associated fields. §15.6; 375
to the given field (identified by the
Locally assigns the full expansion of internal field label ) for the entry identified by . Produces an error (or warning with undefaction=warn) if the entry or field doesn’t exist. Note that this doesn’t update any associated fields. §15.6; 375
to the given field (identified by the
Fetches the value of the given field for the given entry and stores it in the command internal field label) hasn’t been defined. Uses \glsdoifexists
. §15.6; 374
As \glsfielddef
but does a global assignment.
As \glsfieldedef
but does a global assignment. §15.6; 375
Finds and sets the widest name for all top-level entries in the given glossaries. If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §13.1.7; 324
Finds and sets the widest name for all entries that have been marked as used with hierarchical level less than or equal to 2 in the given glossaries.
Finds and sets the widest name for all top-level entries that have been marked as used in the given glossaries.
As \glsfirst
but converts the link text to all caps. §5.1.3; 176
As \glsfirst
but converts link text to sentence case. §5.1.3; 176
References the entry identified by first value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. If you have defined the entry with \newacronym
consider using \acrfull
(or \glsxtrfull
with glossaries-extra) for the full form or \acrlong
(or \glsxtrlong
with glossaries-extra) for the long form instead. §5.1.3; 176
Short form font used by the small caps “sc” abbreviation styles on first use.
Does firstaccess replacement text (if set).
with the
Formatting command for the first use long form used by the footnote abbreviation styles.
As \glsfirstplural
but converts the link text to all caps. §5.1.3; 177
As \glsfirstplural
but converts the link text to sentence case. §5.1.3; 177
References the entry identified by firstplural value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. If you have defined the entry with \newacronym
consider using \acrfullpl
(or \glsxtrfullpl
with glossaries-extra) for the full form or \acrlongpl
(or \glsxtrlongpl
with glossaries-extra) for the long form instead. For the first optional argument, see \glslink
options. §5.1.3; 177
Does firstpluralaccess replacement text (if set). §17.3; 390
with the
For use within captions or section titles to display the formatted first.
For use within captions or section titles to display the formatted sentence case long form.
For use within captions or section titles to display the formatted name.
For use within captions or section titles to display the formatted short form.
For use within captions or section titles to display the formatted text.
The generic acronym display format used by the \gls
-like commands. §5.1.4; 184
The generic display format used by the \gls
-like commands. §5.1.4; 184
Robust command that determines the title associated with §13.2.1; 335
and displays it.
Redefined by glossary styles to show, if applicable, the title associated with the letter group identified by . §13.2.3; 338
Redefined by glossary styles to produce a vertical gap between letter groups, if applicable. §13.2.3; 339
Sets the header mark for the glossary. §8.2; 252
Sets \ifglshyperfirst
to false.
Sets \ifglshyperfirst
to true.
Creates a hyperlink to the given entry with the hyperlink text provided in the optional argument. If omitted, the default is
. §5.2; 191
\glsentrytext
{ }
Used as a separator by \glsnavigation
. §13.2.2; 336
This will encapsulate each location with a hyperlink, if supported. This may be used as a location encap. The argument may be a single location or locations delimited by \delimR
or \delimN
. This command should not be used outside of location lists as it requires additional information in order to correctly form the hyperlinks. §12.1; 276
This was originally used in \glsgenentryfmt
to test if the hyper option was set. Deprecated in v4.08 and removed in v4.50. Use \glsifhyperon
instead.
Defined by the \gls
-like commands to expand to if the hyperlink setting is on for the current reference. Otherwise it expands to . §5.1.4; 183
, if the has been identified as a list of acronyms.
it it occurs inside a measuring content otherwise does .
Defined by the \gls
-like commands to expand to if the calling command was a plural form (for example, \glspl
) and to for the other commands. §5.1.4; 182
Does translate=true and the glossaries-dictionary-.dict file has been loaded, otherwise does .
if
Does nothing. When used as a location encap, this signifies to bib2gls that the entry is required but the location shouldn’t be added to the location list. With other indexing methods, this simply creates an invisible location. §12.1; 273
Indicates what indexing option has been chosen. §1.3; 9
Sets \ifglsindexonlyfirst
to false. §2.4; 102
Sets \ifglsindexonlyfirst
to true. §2.4; 101
Formats the description, symbol and location list for top-level entries. §13.1.9; 330
Hook at the start of \glossentry
that finishes off the previous child entry, if the current top level (level 0) entry follows a child entry. This command is redefined within \glossentry
to use \glsinlinepostchild
after a top level (level 0) entry if that entry has any children. §13.1.9; 328
Used to format the symbol and location list when the description is suppressed. §13.1.9; 330
Used to test if the entry has any children. §13.1.9; 329
Creates the target for top level (level 0) entries and may be used to adjust the format of the name. §13.1.9; 329
Separator used between a top level (level 0) parent and its first child entry. §13.1.9; 328
Hook used between a top level (level 0) entry and its first sub-entry. §13.1.9; 330
Separator used between top level (level 0) entries. §13.1.9; 328
Formats the description, symbol and location list for child entries. §13.1.9; 330
Creates the target for sub entries and may be used to adjust the format of the name. §13.1.9; 330
Separator used between sub-entries. §13.1.9; 328
Placeholder command that expands to the \gls
-like commands. §5.1.4; 182
A token register used by \newacronym
(and \newabbreviation
) to store the supplied in the optional argument. §6.2.2; 217
Placeholder command that expands to the entry label. §5.1.4; 182
May be used in the definition of \glsdohypertargethook
to simulate a label corresponding to the target where the label is given by
. §15.1; 360
\glslabelhypertargetprefix
Hook used by \glslabelhypertarget
to locally redefine problematic commands. §15.1; 361
Expands to the prefix used for the label created by \glslabelhypertarget
. §15.1; 360
Expands to the value part of the label created by \glslabelhypertarget
. §15.1; 361
A token register used by \newacronym
(and \newabbreviation
) to store the entry label. §6.2.2; 217
Fetches the value of the given field (identified by its internal label ) for the entry given by and stores it in the command . §15.6; 374
As \glslink
but converts to sentence case. §5.1.3; 175
References the entry identified by link text. This command does not alter or depend on the first use flag (use \glsdisp
instead, if the first use flag needs to be unset). This command is considered a \glstext
-like command. For the first optional argument, see \glslink
options. §5.1.3; 175
Hook used when checking whether or not to switch off hyperlinks on first use. §2.1; 85
Hook implemented after setting the options passed to the \gls
-like and \glstext
-like commands. §5.1.5; 186
Hook implemented before setting the options passed to the \gls
-like and \glstext
-like commands.
Defined by the \gls
-like commands test if the unmodified, starred (*
) or plus (+
) command was used. §5.1.4; 183
A length register used by listdotted. §13.1.1; 307
Used by \glslistinit
to provide better integration with gettitlestring. §13.1.1; 305
Used to encapsulate the group title. §13.1.1; 305
Used to disable problematic commands at the start the list styles to provide better integration with gettitlestring. §13.1.1; 304
Used in styles like listhypergroup to display the navigation line. §13.1.1; 305
Locally resets the first use flag. §7; 234
Locally resets the first use flag for all entries in whose labels are listed in the comma-separated list. If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §7; 234
Locally unsets the first use flag. §7; 234
Locally unsets the first use flag for all entries in whose labels are listed in the comma-separated list. If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §7; 235
Used by makeglossaries when repairing problematic locations with makeindex. §12.5; 289
Does longaccess replacement text (if set). §17.3; 391
with the
Font formatting command for the long form, initialised by the abbreviation style.
Does longpluralaccess replacement text (if set). §17.3; 391
with the
A token register used by \newacronym
(and \newabbreviation
) to store the supplied long form. §6.2.2; 217
Converts lowercase using the modern LaTeX3 case-changing command, which is expandable. §15.2; 361
to
Penalty check used by \glspatchLToutput
. §13.1.4; 314
Used by \makefirstuc
to perform the actual case-change. As from mfirstuc v2.08+ this just uses \MFUsentencecase
. Despite the “gls” prefix in the command name, this command is provided by mfirstuc, but dates back to when mfirstuc was part of the glossaries package.
Expands to the number of columns for the “mcol” styles. §13.1.8; 326
Measures the depth of \settodepth
but temporarily switches off indexing, unset/reset and labelling. §15.5; 373
Measures the height of \settoheight
but temporarily switches off indexing, unset/reset and labelling. §15.5; 372
Measures the width of \settowidth
but temporarily switches off indexing, unset/reset and labelling. §15.5; 373
If mfirstuc v2.08+ is installed, this will use \MFUaddmap
, otherwise it will use \glsmfuexcl
instead. See §15.2 for further details. §15.2; 363
If mfirstuc v2.08+ is installed, this will use \MFUblocker
, otherwise it will use \glsmfuexcl
instead. See §15.2 for further details. §15.2; 363
If mfirstuc v2.08+ is installed, this will use \MFUexcl
, otherwise it will implement something similar. §15.2; 363
Moves the entry identified by glossary identified by . §4.7; 163
to the
As \glsname
but converts the link text to all caps. §5.1.3; 177
As \glsname
but converts the link text to sentence case. Use \Glossentryname
within custom glossary styles instead of this command. §5.1.3; 177
References the entry identified by name value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. Use \glossentryname
within custom glossary styles instead of this command. §5.1.3; 177
Does access replacement text (if set). §17.3; 390
with the
Used by \glossentryname
to apply a font change to the name. §13; 299
Used by \glsnavhypertarget
to create the hypertarget for the given group. §13.2.2; 336
Creates a hyperlink to the given group, where the target name is obtained from \glsnavhyperlinkname
. §13.2.2; 336
Expands to the anchor for the given group. §13.2.2; 336
Used to create a hyper target for a group in order to support styles that have navigation links to glossary groups. Note that if you only want to change the way that the target is created, redefine \glsnavhypergroupdotarget
instead. §13.2.2; 335
Displays a simple glossary group navigation line with the items separated by \glshypernavsep
. §13.2.2; 336
Used by \glsnavigation
to create the hyperlink for the given group (with the title corresponding to the group label). §13.2.2; 336
Does nothing outside of \print
glossary. Within the glossary, this redefines \glossaryentrynumbers
to do its argument and then reset itself. §8.2; 257
Don’t expand values when assigning fields during entry definition (except for specific fields that are overridden by \glssetexpandfield
). §4.4; 156
Used to display an individual location within the number list when \printnoidxglossary
formats the number list. §12.6; 297
Handler macro used by \glsdisplaynumberlist
with Option 1. §5.2; 196
Displays the location list by iterating over the loclist field with the \glsnoidxloclisthandler
handler. §12.6; 296
Handler macro used by \glsnoidxloclist
. §12.6; 296
List loop handler used by \glsnumberlistloop
. §12.6; 298
Used before the number list for Option 1. By default it expands to the value of the prenumberlist internal field, if set. §8.2; 256
Does nothing outside of \print
glossary. Within the glossary, this redefines \glossaryentrynumbers
to ignore its argument and then reset itself. §8.2; 256
The default format for entry locations. If hyperlinks are defined, this will use \glshypernumber
otherwise it will simply display its argument, which may be a single location, or locations delimited by \delimR
or \delimN
. §12.1; 275
Iterates over the loclist internal field. §12.6; 296
Provided by glossaries if it hasn’t already been defined. The title associated with the glsnumbers
letter group. Also used as the title for the glossary created with the numbers package option. §1.5.1; Table 1.2
Separator used by \glsdisplaynumberlist
between the last two locations. §5.2; 195
Separator used by \glsdisplaynumberlist
between all but the last two locations. §5.2; 195
Expands to (a literal open brace). §14; 344
A length register used to set the width of the location list column for tabular-like styles. §13.1; 301
Paragraph break (for instances where \par
can’t be used directly). §4; 136
Applies a patch to longtable to check for instances of the group skip occurring at a page break.
Patches tabularx (if it has been loaded) to prevent the first use flag from being unset while tabularx is calculating the column widths. §15.5; 373
The definition of \glsgroupskip
with nogroupskip=false for the glossary-longbooktabs styles. §13.1.4; 314
Expands to (a literal percent character). §14; 344
As \glspl
but converts the link text to all caps. §5.1.2; 173
As \glspl
but converts the link text to sentence case. §5.1.2; 173
As \gls
but uses the relevant plural form. §5.1.2; 173
As \glsplural
but converts the link text to all caps. §5.1.3; 177
As \glsplural
but converts the link text to sentence case. §5.1.3; 176
References the entry identified by plural value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. If you have defined the entry with \newacronym
consider using \acrshortpl
(or \glsxtrshortpl
with glossaries-extra) instead. §5.1.3; 176
Does pluralaccess replacement text (if set). §17.3; 390
with the
Suffix used to obtain default plurals. §4.1; 145
A hook that is usually placed after the description in glossary styles. Some of the styles provided with the glossaries package don’t use this hook. The glossaries-extra-stylemods redefines those styles to include the hook. The default definition of this command tests for the nopostdot option, but the postpunc option redefines the command to implement the chosen punctuation. §13.1; 303
Used at the end of the theglossary environment. §13.1.9; 329
Formats the top-level entry’s description, symbol and location list.
Formats the child entry’s description, symbol and location list.
A post-link hook used after all the \gls
-like and \glstext
-like commands. This is redefined by glossaries-extra to use \glsxtrpostlinkhook
. §5.1.5; 187
Separator between the prefix and the term. §16; 378
Hook used with sort=standard to adjust the default sort value (with \makeglossaries
or \makenoidxglossaries
only). §2.5; 107
Shortcut for
.
\glsxtrp
{short}{ }
Shortcut for
.
\glsxtrp
{text}{ }
Expands to "
"
, where the "
is a literal character. §14; 345
For use with entrycounter and subentrycounter, this references the value of the glossaryentry or glossarysubentry counter associated with the glossary entry identified by . If entrycounter=false and subentrycounter=false, this simply uses \gls
otherwise it uses \ref
. §2.3; 92
Globally resets the first use flag. §7; 234
Globally resets the first use flag for all entries in whose labels are listed in the comma-separated list. If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §7; 234
Sets the \ifglsresetcurrcount
conditional to \iffalse
. §7.1; 239
Sets the \ifglsresetcurrcount
conditional to \iftrue
. §7.1; 239
Resets glossaryentry back to zero if entrycounter=true. §2.3; 92
Resets \glossaryentrynumbers
. §8.2; 256
Resets glossarysubentry back to zero if entrycounter=true. §2.3; 94
Reverses the effect of \glspatchLToutput
. §13.1.4; 314
Indexes the entry identified by as a general cross-reference to the entries identified in the comma-separated list . The optional argument is the textual tag that’s inserted before the cross-reference list and defaults to \seename
. §11; 266
Used to format the see cross-reference in the location list. This requires a location argument for makeindex even though it isn’t required. The default definition is
. §11.1; 269
\emph
{ } \glsseelist
{ }
Used by \glsseelist
to format each entry item. This adds a hyperlink, if enabled, to the appropriate entry line in the glossary with the text obtained with \glsseeitemformat
. §11.1; 270
Used by \glsseeitem
to produce the hyperlink text. §11.1; 270
Used by \glsseelist
as a separator between the final pair. §11.1; 270
Iterates over a comma-separated list of entry labels \glsseeitem
. The separators are \glsseelastsep
(between the penultimate and last items) and \glsseesep
(between all the other items). §11.1; 270
Used by \glsseelist
as a separator between each entry except the last pair. §11.1; 270
Used by sentence case commands, such as \Gls
, to perform the case change. This is simply defined to use \makefirstuc
. §15.2; 362
Sets the compositor for locations that start with an uppercase alphabetical character. §3.2; 133
Locally sets the given attribute to for the given category.
Sets the location compositor for the indexing style file created by \makeglossaries
. §3.2; 132
Indicates that the given field should always have its value expanded when the entry is defined. This overrides \glsnoexpandfields
. §4.4; 156
Indicates that the given field should always have its value expanded when the entry is defined. This overrides \glsexpandfields
. §4.4; 156
Set makeindex’s quote character (used for escaping special characters) to . §1.5; 52
The suffix for two consecutive locations. §12.2; 279
The suffix for three or more consecutive locations. §12.2; 279
Used by \print
glossary to set the table of contents title for the given glossary if a title hasn’t been supplied with toctitle or title. §8.2; 254
Indicates that hierarchical level. §13.1.7; 324
is the widest name for the given
Adds indexing style file. §3.2; 131
to the
Sets the xindy codepage. This information is written to the aux file for makeglossaries to pick up. It has no effect if xindy is called explicitly. §14.2; 347
Identifies the first letter group to occur after the number group. §14.4; 357
Sets the xindy language for the given glossary. This information is written to the aux file for makeglossaries to pick up. It has no effect if xindy is called explicitly. §14.2; 346
May be used to change the ordering of location class names. §14.3; 356
Sets the minimum number of consecutive locations to form an implicit range. The value may be “none” to indicate no range formation. §14.3; 356
Sets the relative location of the number group. §14.4; 358
Resets the list of required xindy files. §14.1; 345
Does shortaccess replacement text (if set). §17.3; 390
with the
Applies attribute for using \glsaccessibility
for the short field. §17.2; 388
Applies attribute for using \glsaccessibility
for the shortplural field. §17.2; 388
Does shortpluralaccess replacement text (if set). §17.3; 391
with the
A token register used by \newacronym
(and \newabbreviation
) to store the supplied short form. §6.2.2; 217
Used by \glsshowtarget
in outer mode. §2.1; 81
Used with debug=showtargets to show the target. §2.1; 80
Used by \glsshowtargetfonttext
and \glsshowtargetouter
to set the font. §2.1; 81
Used by \glsshowtargetinner
to set the font. §2.1; 81
Used by \glsshowtarget
in math mode and inner mode. §2.1; 80
Used by \glsshowtarget
in outer mode. §2.1; 81
Used by \glsshowtargetouter
to mark the target. §2.1; 81
Expands to the given §2.5; 106
zero-padded to six digits.
Essentially does
where can either be provided by the format key in .
\glsaddeach
[ ,format=(
]{ }
Increments glossaryentry with \refstepcounter
if entrycounter=true. §2.3; 92
Increments glossarysubentry with \refstepcounter
if subentrycounter=true. §2.3; 95
Sets \ifglssubentrycounter
to false. §2.3; 95
Displays the formatted value of the glossarysubentry counter or does nothing if subentrycounter=false. §2.3; 95
Sets \ifglssubentrycounter
to true. §2.3; 95
Used for level 1 entries in glossary styles to increment and display the sub-entry counter if subentrycounter=true. §13.2.1; 332
Used to format sub-group headings.
As \glssymbol
but converts the link text to all caps. §5.1.3; 178
As \glssymbol
but converts the link text to sentence case. Use \Glossentrysymbol
within custom glossary styles instead of this command. §5.1.3; 178
References the entry identified by symbol value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. Use \glossentrysymbol
within custom glossary styles instead of this command. §5.1.3; 178
Does symbolaccess replacement text (if set). §17.3; 390
with the
Produces a simple navigation set of links for just the symbols and number groups separated by \glshypernavsep
. §13.2.2; 337
As \glssymbolplural
but converts the link text to all caps.
As \glssymbolplural
but converts the link text to sentence case.
As \glssymbol
but for the symbolplural field.
Does symbolpluralaccess replacement text (if set). §17.3; 390
with the
Provided by glossaries if it hasn’t already been defined. The title associated with the glssymbols
letter group. Also used as the title for the glossary created with the symbols package option. §1.5.1; Table 1.2
Used by glossary styles to create a hypertarget (if enabled) for the entry (identified by ). The is usually \glossentryname
{ }, but it can be something else. §13.2.1; 333
If hyperref has been loaded, this uses \texorpdfstring
otherwise it just expands to . §15.1; 361
As \glstext
but converts the link text to all caps. §5.1.3; 176
As \glstext
but converts the first character of the link text to sentence case. §5.1.3; 175
References the entry identified by text value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. If you have defined the entry with \newacronym
consider using \acrshort
for the short form (or \glsxtrshort
with glossaries-extra). For the first optional argument, see \glslink
options. §5.1.3; 175
Does textaccess replacement text (if set). §17.3; 390
with the
Used by the \gls
-like and \glstext
-like commands to format the link text. §5.1; 168
If \textulc
is defined, this will use that command, otherwise it will use \textup
to cancel the effect of the small caps font command \textsc
. §6.2.1; 211
Expands to ~
(a literal tilde character). §14; 344
Sets \ifglstoc
to false. §2.2; 88
Sets \ifglstoc
to true. §2.2; 87
Space inserted before child descriptions. §13.1.7; 321
Used to format the group title for the treegroup and indexgroup styles. §13.1.7; 321
Length register used by the tree style. §13.1.7; 323
Used to indent the top-level entries for the index styles. §13.1.7; 322
Creates the box for the name with styles like alttree. §13.1.7; 325
Used to format the name for the tree and index styles. §13.1.7; 321
Used to format the navigation element for styles like treehypergroup. §13.1.7; 321
Space inserted before top-level descriptions. §13.1.7; 321
Used to indent the level 1 entries for the index styles. §13.1.7; 322
Used to indent the level 2 entries for the index styles. §13.1.7; 322
Placeholder command that expands to the entry’s glossary type. §5.1.4; 182
Sets \ifglsucmark
to false.
Sets \ifglsucmark
to true.
For use in expandable contexts where the field value is required but the contents should not be expanded. The field should be identified by its internal field label. Expands to nothing with no error or warning if the entry or field aren’t defined. §15.6; 374
Globally unsets the first use flag. §7; 234
Globally unsets the first use flag for all entries in whose labels are listed in the comma-separated list. If the optional argument is omitted, the list of all non-ignored glossaries is assumed. §7; 234
Suffix used to obtain the default shortplural value with the base small caps acronym styles. §6.2.1; 210
Converts uppercase using the modern LaTeX3 case-changing command, which is expandable. §15.2; 361
to
Implements the entry format part of the given acronym style (the code supplied in the argument of \newacronymstyle
). §6.2.2; 217
Implements the style definitions part of the given acronym style (the code supplied in the argument of \newacronymstyle
). §6.2.2; 218
As \glsuseri
but converts the link text to all caps. §5.1.3; 179
As \glsuseri
but converts the link text to sentence case. §5.1.3; 179
References the entry identified by user1 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 179
Does user1access replacement text (if set). §17.3; 391
with the
As \glsuserii
but converts the link text to all caps. §5.1.3; 179
As \glsuserii
but converts the link text to sentence case. §5.1.3; 179
References the entry identified by user2 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 179
Does user2access replacement text (if set). §17.3; 391
with the
As \glsuseriii
but converts the link text to all caps. §5.1.3; 179
As \glsuseriii
but converts the link text to sentence case. §5.1.3; 179
References the entry identified by user3 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 179
Does user3access replacement text (if set). §17.3; 391
with the
As \glsuseriv
but converts the link text to all caps. §5.1.3; 180
As \glsuseriv
but converts the link text to sentence case. §5.1.3; 180
References the entry identified by user4 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 180
Does user4access replacement text (if set). §17.3; 391
with the
As \glsuserv
but converts the link text to all caps. §5.1.3; 180
As \glsuserv
but converts the link text to sentence case. §5.1.3; 180
References the entry identified by user5 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 180
Does user5access replacement text (if set). §17.3; 391
with the
As \glsuservi
but converts the link text to all caps. §5.1.3; 180
As \glsuservi
but converts the link text to sentence case. §5.1.3; 180
References the entry identified by user6 value. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options. §5.1.3; 180
Does user6access replacement text (if set). §17.3; 391
with the
Sets \ifglswrallowprimitivemods
to false. §2.4; 101
Sets \ifglswrallowprimitivemods
to true. §2.4; 101
Hook used to locally disable problematic commands whilst constructing the anchor for \glshypernumber
. §12.1; 277
Hook used to locally disable problematic commands whilst writing the location to the indexing file with Options 2 and 3. §12.3; 282
Must be expandable. May be used to alter the location suffix whilst constructing the anchor for \glshypernumber
. §12.1; 277
Used to encapsulate the location in the hyperlink text for \glshypernumber
. §12.1; 276
The write register used to create the indexing style file. §3.2; 131
Hook used when writing entries to the glsdefs file after all the = information has been written and before the end brace that closes the final argument of \glsdefs@newdocentry
.
Does indexonlyfirst=true and the entry identified by has been marked as used. §2.4; 102
unless
Used with xindy for location formats. §14.3; 348
Glsxtr[link]
This command is written to the aux file for the benefit of makeglossaries and makeglossaries-lite. §1.7.1; 76
This command is written to the aux file to provide the indexing information for bib2gls. §1.7.3; 77
This command is written to the aux file to provide the indexing information for bib2gls when the record=nameref option is used. §1.7.3; 78
This command is written to the aux file to provide the \glssee
information for bib2gls. §1.7.3; 78
This command is written to the aux file to provide the resource options for bib2gls. §1.7.3; 77
This command is written to the aux file to provide the file encoding information for bib2gls.
Command that produces the footnote for the footnote abbreviation styles, such as footnote and postfootnote.
Expands to the label of the default abbreviation glossary. The abbreviations package option will redefine this to abbreviations
.
Used by the bookindex style to display a top-level entry’s name.
If defined, used by \glsfieldaccsupp
for the accessibility support for the category identified by .
If defined, used by \glsfieldaccsupp
for the accessibility support for the category identified by and the internal field label given by .
Copies the entry to the internal glossary list for the given glossary. The starred version performs a global change. The unstarred version can be localised. Only for use with the “unsrt” family of commands.
If defined, used with record=name to format locations associated with .
If
is a recognised punctuation character this does the punctuation character and then , otherwise if does followed by .
Iterates over the given field’s value using etoolbox’s \forlistcsloop
.
Formats the value of the given field, which should be an etoolbox internal list, using the same list handler macro as datatool’s \DTLformatlist
.
Behaves like
where the control sequence name is obtained from a designated field.
\glslink
[ ]{ }{\{ } }
Expands to the name of the used by \glsxtrfmt
.
Expands to the name value for styles like short-footnote-desc.
Expands to the sort value for footnote styles like short-footnote-desc.
Iterates over the comma-separated list stored in the given field (identified by its internal label) for the entry identified by and performs for each element of the list.
{ }
As \glsxtrfull
but converts the link text to all caps.
As \glsxtrfull
but converts the link text to sentence case.
References the abbreviation identified by . The text produced is obtained from the short and long values, formatted according to the abbreviation style associated with the entry’s category. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. The format produced by this command may not match the format produced by the first use of
, depending on the abbreviation style.
\gls
{ }
As \glsxtrfullpl
but converts the link text to all caps.
As \glsxtrfullpl
but converts the link text to sentence case.
As \glsxtrfull
but for the plural form.
Separator used by the parenthetical inline full and also for some display full forms.
A shortcut that expands to the ignorable rules, combining diacritic rules, hyphen rules, general punctuation rules, digit rules, and fraction rules.
Expands to the A–G subset of General Latin I sort rules.
Expands to the N–Z subset of General Latin I sort rules.
Obtains the title corresponding to the group identified by and stores the result in the control sequence .
As \glsxtrglossentry
but applies sentence case.
Used for standalone entries to display the name with \glossentryname
, with appropriate hooks.
Displays the entry’s hierarchical name.
Compares the numeric value stored in the given field with
.
Tests if the entry given by field identified by its internal label set to .
has the
Tests if the numeric value stored in the given field is non-zero.
Expandable command that tests if the given field (identified by its internal label) is undefined for the entry given by . Internally uses etoolbox’s \ifcsundef
command.
Tests if the field identified by its internal label for the entry given by is defined and is not empty. This is like \ifglshasfield
but doesn’t produce a warning if the entry or field doesn’t exist. This sets \glscurrentfieldvalue
to the field value and does if its defined and not empty, otherwise it does . The unstarred version adds implicit grouping to make nesting easier. The starred version doesn’t (to make assignments easier).
Tests if the value in the childcount field is non-zero (using \GlsXtrIfFieldNonZero
). This requires the save-child-count resource option.
Does used, otherwise does . Note that this command will generate an error or warning (according to undefaction) if the entry hasn’t been defined, but will still do . §15.4; 367
if the entry hasn’t been defined or hasn’t been marked as
Initialised by the \gls
-like and \glstext
-like commands, this expands to if the calling command was considered the first use, otherwise it expands to . This command may be used within the post-link hook (where it’s too late to test the first use flag with \ifglsused
).
Like \GlsXtrIfFieldEqStr
but first (protected) expands both the field value and the supplied .
A shortcut that expands to the control rules, space rules and non-printable rules.
Used by \Glsxtrfull
to display the sentence case inline full form (defined by the abbreviation style).
Used by \glsxtrfull
to display the inline full form (defined by the abbreviation style).
Used by \Glsxtrfullpl
to display the plural sentence case inline full form (defined by the abbreviation style).
Used by \glsxtrfullpl
to display the plural inline full form (defined by the abbreviation style).
For use with bib2gls, this both sets up the resource options (which bib2gls can detect from the aux file) and inputs the glstex file created by bib2gls.
Locally assigns the given title group identified by .
to the
As \glsxtrlong
but converts the link text to all caps.
As \glsxtrlong
but converts the link text to sentence case.
References the abbreviation identified by . The text produced is obtained from the long value, formatted according to the abbreviation style associated with the entry’s category. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag.
As \glsxtrlongpl
but converts the link text to all caps.
As \glsxtrlongpl
but converts the link text to sentence case.
As \glsxtrlong
but the text produced is obtained from the longplural value.
Defines the command
.
\gls
[ , ]{ }
Like \glsxtrnewgls
but provides plural and sentence case commands as well.
Defines a new glossary entry with the given label, type set to numbers
, the category set to number
, the name set to and the sort set to . The optional argument is a comma-separated list of glossary entry keys, which can be used to override the defaults.
Defines a new glossary entry with the given label, type set to symbols
, the category set to symbol
, the name set to and the sort set to . The optional argument is a comma-separated list of glossary entry keys, which can be used to override the defaults.
When placed at the end of the description, this switches off the post-description punctuation (inserted automatically via options such as postdot) but doesn’t suppress the post-description hook. Does nothing outside of the glossary.
For use in headings and captions (instead of the \gls
-like or \glstext
-like commands). This command is designed to expand to the field value if used in a PDF bookmark and can also expand to a more appropriate command if it ends up in the page header. Note that there’s no option argument.
Used to encapsulate
in parentheses.
May be used within a post-link hook to display the symbol in parentheses on first use.
An additional post-link hook that supports categories.
If local unset for repeat entries has been enabled with \GlsXtrUnsetBufferEnableRepeatLocal
, this will locally reset all entries that are in the buffer that hadn’t been marked as used before the function was enabled.
Sets \gls
-like and \glstext
-like commands that will automatically implement the given options.
Assigns internal label for the entry identified by . An error (or warning with undefaction=warn) occurs if the entry hasn’t been defined.
to the field identified by its
Globally assigns the given title group identified by .
to the
Overrides the options that should be implemented by the plus (+
) modifier for \gls
-like and \glstext
-like commands.
Overrides the options that should be implemented by the star (*
) modifier for \gls
-like and \glstext
-like commands.
As \glsxtrshort
but converts the link text to all caps.
As \glsxtrshort
but converts the link text to sentence case.
References the abbreviation identified by . The text produced is obtained from the short value, formatted according to the abbreviation style associated with the entry’s category. The argument will be inserted at the end of the link text. This command does not alter or depend on the first use flag. For the first optional argument, see \glslink
options.
As \glsxtrshortpl
but converts the link text to sentence case.
As \glsxtrshort
but the text produced is obtained from the shortplural value.
Enables unset buffering. The starred version doesn’t check for duplicates.
Stops buffering. The starred version performs a global unset.
Allows repeat entries within the buffering code to be locally unset before the link text.
Implements the
code for the given abbreviation style.
Implements the
code for the given abbreviation style.
Expands to the value of the given field (identified by its internal label ) for the entry given by . Expands to \relax
if the entry or field are undefined.
H[link]
If hyperlinks are supported this does \textbf{
otherwise it just does \glshypernumber
{ }}\textbf{ }
. Table 12.1
If hyperlinks are supported this does \emph{
otherwise it just does \glshypernumber
{ }}\emph{ }
. Table 12.1
If hyperlinks are supported this does \textit{
otherwise it just does \glshypernumber
{ }}\textit{ }
. Table 12.1
If hyperlinks are supported this does \textmd{
otherwise it just does \glshypernumber
{ }}\textmd{ }
. Table 12.1
If hyperlinks are supported this does \textrm{
otherwise it just does \glshypernumber
{ }}\textrm{ }
. Table 12.1
If hyperlinks are supported this does \textsc{
otherwise it just does \glshypernumber
{ }}\textsc{ }
. Table 12.1
If hyperlinks are supported this does \textsf{
otherwise it just does \glshypernumber
{ }}\textsf{ }
. Table 12.1
If hyperlinks are supported this does \textsl{
otherwise it just does \glshypernumber
{ }}\textsl{ }
. Table 12.1
If hyperlinks are supported this does \texttt{
otherwise it just does \glshypernumber
{ }}\texttt{ }
. Table 12.1
If hyperlinks are supported this does \textup{
otherwise it just does \glshypernumber
{ }}\textup{ }
. Table 12.1
I[link]
If the glossary given by exists, this does , otherwise it does . The unstarred form treats ignored glossaries as non-existent. The starred form (v4.46+) will do if matches an ignored glossary. §15.4; 365
Does description field is just \nopostdesc
otherwise does . §15.4; 368
Conditional corresponding to the entrycounter option. §2.3; 93
if the entry given by exists, otherwise does .
Tests if the value of the given field is equal to the replacement text of the command given by the control sequence name etoolbox’s \ifcsstrequal
. Triggers an error if the given field (identified by its internal field label) hasn’t been defined. Uses \glsdoifexists
. §15.4; 372
Tests if the value of the given field is equal to the replacement text of the given command etoolbox’s \ifdefstrequal
. Triggers an error if the given field (identified by its internal field label) hasn’t been defined. Uses \glsdoifexists
. §15.4; 371
Tests if the value of the given field is equal to the given string using etoolbox’s \ifcsstring
. Triggers an error if the given field (identified by its internal field label) hasn’t been defined. Uses \glsdoifexists
. §15.4; 369
An expandable test to determine if the entry is undefined or the field is undefined or empty. The internal label. Internally uses etoolbox’s \ifcsvoid
command. §15.4; 368
Does glossary to find one that has the entry identified in its parent field. A more efficient approach can be achieved with bib2gls and the save-child-count resource option. §15.4; 367
if the given entry has child entries otherwise does . Note that this has to iterate over the set of defined entries for the entry’s
Does description field is set otherwise does . §15.4; 368
if the entry’s
If the field identified by either its key or its internal field label for the entry identified by is set and non-empty, this sets \glscurrentfieldvalue
to the field value and does otherwise it does . §15.4; 368
Does long field is set otherwise does . §15.4; 367
if the entry’s
Does parent field is set otherwise does . §15.4; 367
if the entry’s
Expands to prefix field is non-empty. §16; 380
if the
Expands to prefixfirst field is non-empty. §16; 380
if the
Expands to prefixfirstplural field is non-empty. §16; 380
if the
Expands to prefixplural field is non-empty. §16; 380
if the
Does short field is set otherwise does . §15.4; 368
if the entry’s
Does symbol field is set otherwise does . §15.4; 367
if the entry’s
Conditional corresponding to the hyperfirst option.
Conditional corresponding to the indexonlyfirst option. §2.4; 101
Conditional set by the nogroupskip option. §2.3; 99
Conditional that determines whether or not the reset commands should reset the entry count stored in currcount to zero. §7.1; 239
Conditional corresponding to the subentrycounter option. §2.3; 95
Conditional corresponding to the toc option. §2.2; 88
Conditional corresponding to the ucmark option. §2.2; 89
Does entry has been marked as used, does if the entry is marked as unused, and does neither if the entry hasn’t been defined (but will generate an error). §15.4; 366
if the
If esclocations=true and this conditional is true, then some primitives will be locally redefined while indexing occurs in order to escape special characters in the location without prematurely expanding \thepage
. §2.4; 101
Conditional that, if true, indicates that xindy should be used. §2.5; 111
A conditional used by the predefined abbreviation styles to determine whether the
part should go inside or outside of the style’s font formatting commands.
Does glossary identified by has been defined as an ignored glossary, otherwise does . §9; 259
if the
Provided by various packages, including glossary-list and glossary-tree, this creates a vertical space. §13.1.1; 305
L[link]
Locally assigns \glsdefaulttype
to and inputs . If the optional argument is omitted, the default glossary is assumed. Note that if any entries with have the type key set (including implicitly in commands like \newabbreviation
), then this will override the type given in the optional argument. §4.6; 160
Defines a new glossary entry with the given label. The second argument is a comma-separated list of glossary entry keys. The third argument is the description, which may include paragraph breaks. §4; 135
As \longnewglossaryentry
but does nothing if the entry is already defined. §4; 135
M[link]
Robust command that converts the first character of uppercase (sentence case) unless starts with a command, in which case it will attempt to apply the case change to the first character of the first argument following the command, if the command is followed by a group. As from mfirstuc v2.08, this command internally uses \MFUsentencecase
to perform the actual case change. See the mfirstuc documentation for further details, either:
texdoc mfirstucor visit ctan.org/pkg/mfirstuc.
Opens the associated indexing files that need to be processed by makeindex or xindy. This command has an optional argument with glossaries-extra. §3.2; 130
Sets up all non-ignored glossaries so that they can be displayed with \printnoidxglossary
. §3.1; 130
This command was used by \makefirstuc
to convert its argument to all caps and was redefined by glossaries to use \MakeTextUppercase
, but with mfirstuc v2.08+ and glossaries v4.50+ this command is instead defined to use the LaTeX3 all caps command, which is expandable. This command is no longer used by \makefirstuc
(which instead uses \MFUsentencecase
). The glossaries (v4.50+) and glossaries-extra (v1.49+) packages now use \glsuppercase
for the all caps commands, such as \Gls
.
Identifies a mapping from the command \makefirstuc
and also identifies as a blocker. Mappings and blockers aren’t supported by \MFUsentencecase
, so both and are identified as exclusions for \MFUsentencecase
.
Locally identifies \makefirstuc
and an exclusion for \MFUsentencecase
(which doesn’t support blockers).
Locally identifies \makefirstuc
and \MFUsentencecase
.
Fully expands uppercase. Unlike \makefirstuc
, this command is expandable, but only recognises commands identified as exclusions. See the mfirstuc documentation for further details. This command is provided by glossaries-extra v1.49+ if an old version of mfirstuc is detected. §15.2; 362
N[link]
Defines a new entry that represents an abbreviation. This internally uses \newglossaryentry
and any provided options (glossary entry keys) given in will be appended. The category is set to abbreviation by default, but may be overridden in . The appropriate style should be set before the abbreviation is defined with \setabbreviationstyle
.
Defines an abbreviation style, which can be set with \setabbreviationstyle
.
This command is provided by the base glossaries package to define a new acronym but it’s redefined by glossaries-extra to use \newabbreviation
with the category key set to acronym. With just the base glossaries package, use \setacronymstyle
to set the style. With glossaries-extra, use
to set the style that governs \setabbreviationstyle
[acronym]{ }\newacronym
. §6; 198
Hook used by \newacronym
just before the entry is defined by \newglossaryentry
.
Defines an acronym style for use with the base glossaries package’s acronym mechanism. These styles are not compatible with glossaries-extra. The part is the code used as the entry format definition within \defglsentryfmt
. The is the code that redefines the acronym formatting commands, such as \genacrfullformat
, and the additional fields command \GenericAcronymFields
. §6.2.2; 216
Defines a glossary identified by (which can be referenced by the type key when defining an entry). The will be used when displaying the glossary (using commands like \printglossary
), but this title can be overridden by the title option. The optional indicates which counter should be used by default for the location when indexing any entries that have been assigned to this glossary. (This can be overridden by the counter option.) The other arguments are file extensions for use with makeindex or xindy. These arguments aren’t relevant for other indexing options (in which case, you may prefer to use \newglossary*
). §9; 258
A shortcut that supplies file extensions based on the glossary label:
\newglossary
[ -glg]{ }{ -gls}{ }{ }[ ]
§9; 258
Defines a new glossary entry with the given label. The second argument is a comma-separated list of glossary entry keys. §4; 134
Defines a new glossary style called . §13.2; 331
Defines a glossary that should be ignored by iterative commands, such as \printglossaries
. This glossary has no associated indexing files and has hyperlinks disabled. You can use an ignored glossary for common terms or acronyms or abbreviations that don’t need to be included in any listing (but you may want these terms defined as entries to allow automated formatting with the \gls
-like commands). An ignored glossary can’t be displayed with \printglossary
but may be displayed with the “unsrt” family of commands, such as \printunsrtglossary
. The glossaries-extra package provides a starred form of this command.
Defines a new glossary entry with the given label, type set to index
, the name set to and the description set to \nopostdesc
. The optional argument is a comma-separated list of glossary entry keys, which can be used to override the defaults. §2.6; 119
Prevents \makeglossaries
from creating the default indexing application style file. §3.2; 132
When placed at the end of the description, this switches off the post-description hook (including the post-description punctuation). Does nothing outside of the glossary. §4; 136
O[link]
Defines an acronym using the syntax of the old glossary package. §6.4; 232
P[link]
Provided by glossaries if it hasn’t already been defined. Used as the page list column header for some of the tabular-like glossary styles. §1.5.1; Table 1.2
As \pgls
but all caps. §16; 379
As \pgls
but sentence case. §16; 379
Similar to \gls
but inserts the appropriate prefix, if provided. §16; 378
As \pgls
but all caps. §16; 379
As \pgls
but sentence case. §16; 379
Similar to \glspl
but inserts the appropriate prefix, if provided. §16; 378
As \glsxtrshort
but inserts the prefix field and separator in front if set.
Locally prepends preamble for the glossary identified by . If is omitted, \glsdefaulttype
is assumed. §8.2; 255
Shortcut for
.
\printglossary
[type=\glsxtrabbrvtype
]
Shortcut for
. §2.7; 121
\printglossary
[type=\acronymtype
]
Iterates over all non-ignored glossaries and does
for each glossary. §8; 246
\printglossary
[type=]
Displays the glossary by inputting a file created by makeindex or xindy. Must be used with \makeglossaries
and either makeindex or xindy. §8; 245
Shortcut provided by the index package option that simply does
. §2.6; 120
\printglossary
[type=index]
Iterates over all non-ignored glossaries and does
for each glossary. §8; 245
\printnoidxglossary
[type=]
Displays the glossary by obtaining the indexing information from the aux file and using TeX to sort and collate. Must be used with \makenoidxglossaries
or with the glossaries not identified in the optional argument of \makeglossaries
when using the hybrid method. This method can be very slow and has limitations. §8; 245
Shortcut for
. §2.6; 119
\printglossary
[type=numbers]
Shortcut for
. §2.6; 118
\printglossary
[type=symbols
]
Shortcut for
.
\printunsrtglossary
[type=\acronymtype
]
Iterates over all non-ignored glossaries and does
for each glossary. §8; 246
\printunsrtglossary
[type=]
Displays the glossary by iterating over all entries associated with the given glossary (in the order in which they were added to the glossary). Group headers will only be inserted if the group key has been defined and has been set (typically with the record option and bib2gls). Location lists will only be shown if the location or loclist fields have been set (typically by bib2gls). §8; 246
Similar to \printunsrtglossary
but doesn’t contain the code that starts and ends the glossary (such as beginning and ending the theglossary environment). See the glossaries-extra manual for further details. §8; 247
As \newglossaryentry
but does nothing if the entry is already defined. §4; 135
As \newignoredglossary
but does nothing if the glossary has already been defined.
Used at the start of a glossaries language definition file (ldf) to declare the file and version details.
R[link]
As \newacronymstyle
but redefines an existing acronym style.
Redefines the glossary style called . §13.2; 331
Indicates that the language definition file (ldf) corresponding to the given language should be loaded, if it hasn’t already been loaded.
S[link]
Used as a cross-reference tag. The default value is \alsoname
, if that command has been defined, or “see also”.
Provided by glossaries if it hasn’t already been defined. May already be defined by a language package.
Sets the current abbreviation style to for the category identified by . If the optional argument is omitted, abbreviation is assumed.
Sets the list of acronym lists (overriding any that have previously been identified). §2.7; 123
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Sets the acronym style. Don’t use with glossaries-extra. §6.2; 207
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \newacronymstyle
and \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use
.
\setacronymstyle
{long-short}
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \newacronymstyle
and \setacronymstyle
.
Sets up the hypertarget prefix and location counter for use with \glshypernumber
. §12.1; 276
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Globally sets the preamble for the glossary identified by to . If is omitted, \glsdefaulttype
is assumed. §8.2; 254
Equivalent to the package option section=. §2.2; 89
Sets the default glossary style to . §2.3; 96
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Sets the file name of the makeindex or xindy style file that’s created by \makeglossaries
. §3.2; 131
Change allowed options that are defined by the base glossaries package. Note that some options can only be passed as package options. To change options defined or modified by the glossaries-extra package, use \glossariesextrasetup
. §2.10; 129
Deprecated with the introduction of \setacronymstyle
. Removed in v4.50. Use rollback if backward-compatibility required or use \setacronymstyle
.
Redefined by the glossary styles to display child entries. §13.2.3; 338
Provided by glossaries if it hasn’t already been defined. Used as a column header for some of the tabular-like glossary styles. §1.5.1; Table 1.2
T[link]
Displays the value of the glossaryentry counter. §2.3; 93
Displays the value of the glossarysubentry counter. §2.3; 95
W[link]
Writes the makeindex/xindy style file. This command is used by \makeglossaries
and then disabled. §3.2; 131
X[link]
Passes the argument to \capitalisefmtwords
but with the first token in expanded. The starred version uses the starred version of \capitalisefmtwords
.
As \GlsXtrSetField
but expands the value and uses a global assignment.
Environment Summary[link]
Redefined by the glossary styles to format the glossary according to the style specifications. The entire glossary content (not including the section header, preamble and postamble) is contained within this environment. §13.2.3; 337
Package Option Summary[link]
Extension package that loads glossaries, provides additional commands, and modifies some of the base glossaries commands to integrate them with the new commands or to make them more flexible.
Provides a new glossary with the label abbreviations
and title given by \abbreviationsname
, redefines \glsxtrabbrvtype
to abbreviations
, redefines \acronymtype
to \glsxtrabbrvtype
(unless the acronym or acronyms option has been used), and provides \printabbreviations
. §2.7; 122
Loads glossaries-accsupp. §2.9; 127
Indicates whether or not to enable automatic indexing of see and seealso fields. §2.4; 103
Determines whether or not \newglossaryentry
is permitted in the document environment. §2.1; 87
As restricted but creates the glsdefs file for atom’s autocomplete support. 87
Don’t allow \newglossaryentry
in the document environment. 87
Allow \newglossaryentry
in the document environment, but only before any glossaries. 87
Allow \newglossaryentry
in the document environment if the base glossaries package would allow it. 87
Automatically switch the location counter to equation when inside a numbered equation environment. §2.4; 104
Automatically switch the location counter to the corresponding counter when inside a floating environment. §2.4; 104
Defines the index counter wrglossary and implements counter=wrglossary. §2.4; 104
If true, automatically indexes cross references at the end of the document. §2.4; 103
Determines whether or not to display warning text if the external indexing file hasn’t been generated due to an incomplete build. §2.9; 127
A shortcut for nopostdot=false.
An alternative to postdot, this can be used to insert a different punctuation character after the description.
Loads glossaries-prefix. §2.9; 127
Indicates whether or not bib2gls is being used (in which case entry indexing is performed by adding bib2gls records in the aux file). §2.4; 103
Performs a mixture of bib2gls records in the aux file (to select entries from a bib file) and makeindex/xindy indexing in their associated files. This option is best avoided. 104
Entry indexing is performed by adding bib2gls nameref records in the aux file. Glossaries should be displayed with the “unsrt” family of commands. 104
Entry indexing is performed as per the base glossaries package, using either \makeglossaries
or \makenoidxglossaries
. 103
Entry indexing is performed by adding bib2gls records in the aux file. Glossaries should be displayed with the “unsrt” family of commands. 103
Loads glossaries-extra-stylemods with the given options. If stylemods=default then no options are passed to glossaries-extra-stylemods. §2.3; 99
Indicates whether to trigger an error or warning if an unknown entry label is referenced. §2.1; 86
Trigger an error if an unknown entry label is referenced. 86
Trigger a warning if an unknown entry label is referenced. 87
Base package. This package will be implicitly loaded by glossaries-prefix, glossaries-accsupp and glossaries-extra. §1; 2
If true, provides a new glossary with the label acronym
and title given by \acronymname
, redefines \acronymtype
to acronym
, and provides \printacronyms
. §2.7; 121
Identifies the glossaries that contain acronyms (defined with the base glossaries packages acronym mechanism). §2.7; 122
Provides a new glossary with the label acronym
, redefines \acronymtype
to acronym
, and provides \printacronyms
. §2.7; 122
Indicates whether or not to attempt to use TeX’s shell escape to run an indexing application. §2.5; 112
Use the shell escape to run makeindex or xindy at the end of the document. 114, 114
Don’t use the shell escape. 114
Use the shell escape to run makeindex or xindy before \makeglossaries
opens the associated indexing files. 115
Use the shell escape to run makeglossaries-lite before \makeglossaries
opens the associated indexing files. §2.5; 115, 115
Use the shell escape to run makeglossaries before \makeglossaries
opens the associated indexing files. §2.5; 115, 115
Deprecated synonym for automake=delayed. 114
Synonym for automake=makegloss. §2.5; 115
Synonym for automake=lite. §2.5; 115
Option removed in version 4.50. Now only available with rollback. §2.9; 127
Option removed in version 4.50. Now only available with rollback. §2.9; 127
Sets the default location counter. §2.3; 98
Sets the parent counter for glossaryentry. §2.3; 93
Adds markers to the document for debugging purposes. §2.1; 80
Disable debugging actions. 80
Implements debug=true and also shows accessibility information in the document. 81
Implements debug=true and also shows target markers in the document. 80
Writes wrglossary(
to the )( )log file if there is an attempt to index an entry before the associated indexing file has been opened (makeindex and xindy only). With glossaries-extra, this setting will also display the label of any undefined entries that are referenced in the document. 80
Deprecated in version 4.02 (2013-12-05) and removed in version 4.50. Now only available with rollback. §2.8; 124
Disables \makeglossaries
. §2.5; 115
Deprecated in version 4.02 (2013-12-05) and removed in version 4.50. Now only available with rollback. §2.8; 126
Enables the entry counter for top-level entries. §2.3; 92
If true, escapes locations before indexing. §2.4; 100
Deprecated in version 4.02 (2013-12-05) and removed in version 4.50. Now only available with rollback. §2.8; 126
If false, this option will suppress hyperlinks on first use for the \gls
-like commands. §2.1; 85
Provides a new glossary with the label index
and the title \indexname
, and provides \printindex
and \newterm
. §2.6; 119
Indicates whether or not to only index the first use. §2.4; 101
Indicates whether or not to redefined the kernel glossary commands \glossary
and \makeglossary
. §2.9; 128
Don’t redefine \glossary
and \makeglossary
. 128
Redefine \glossary
and \makeglossary
without any warnings. 128
Redefine \glossary
and \makeglossary
but their use will trigger a warning. 128
Implements translate=babel and adds the supplied languages to tracklang’s list of tracked languages. §2.1, §2.1; 84, 84
Synonym of languages. §2.1; 84
Indicates that the indexing should be performed by makeindex (default). §2.5; 110
The value may be either expanded or unexpanded and performs the same function as mfirstuc’s expanded and unexpanded package options. Note that there’s no value corresponding to mfirstuc’s other package option. §2.9; 127
If true, suppress the gap between letter groups in the glossaries by default. §2.3; 99
Counteracts the index option. §2.6; 120
Identifies the list of glossaries that should have hyperlinks suppressed. §2.6; 116
Suppresses the warning if no language support is found. §2.1; 79
Don’t load glossary-list, which is normally loaded automatically. Note that if glossaries is loaded before glossaries-extra, then this option should be passed directly to glossaries not glossaries-extra otherwise it will be too late to implement. §2.3; 97
Don’t load glossary-long, which is normally loaded automatically. Note that if glossaries is loaded before glossaries-extra, then this option should be passed directly to glossaries not glossaries-extra otherwise it will be too late to implement. §2.3; 96
Prevents the definition of the main
glossary. You will need to define another glossary to use instead. For example, with the acronyms package option. §2.6; 117
Set no location lists as the default for all glossaries. May be overridden for individual glossaries with nonumberlist=true. §2.3; 98
If true, suppresses the automatic insertion of a full stop after each entry’s description in the glossary (for styles that support this). The default is nopostdot=true for glossaries-extra and nopostdot=false for just glossaries. §2.3; 99
Suppresses a warning if theglossary or \printglossary
have already been defined (which indicates that the document class or another package also provides a mechanism for creating a glossary that could potentially conflict with glossaries). This option is automatically implemented with glossaries-extra. §2.1; 79
Don’t load the default set of predefined styles. Note that if glossaries is loaded before glossaries-extra, then this option should be passed directly to glossaries not glossaries-extra otherwise it will be too late to implement. §2.3; 97
Don’t load glossary-super, which is normally loaded automatically. Note that if glossaries is loaded before glossaries-extra, then this option should be passed directly to glossaries not glossaries-extra otherwise it will be too late to implement. §2.3; 96
Equivalent to translate=false. §2.1; 84
Don’t load glossary-tree, which is normally loaded automatically. Note that if glossaries is loaded before glossaries-extra, then this option should be passed directly to glossaries not glossaries-extra otherwise it will be too late to implement. §2.3; 97
Indicates whether or not glossary section headers will be numbered and also if they should automatically be labelled. §2.2; 89
Use numbered sectional units for glossaries and automatically add a label based on the glossary label. 90
Use unnumbered sectional units for glossaries. 89
Use unnumbered sectional units for glossaries and automatically add a label based on the glossary label. 91
Use numbered sectional units for glossaries but no label. 89
If true (and toc=true), includes \numberline
when adding a glossary to the table of contents. §2.2; 88
Provides a new glossary with the label numbers
and the title \glsnumbersgroupname
, and provides \printnumbers
. With glossaries-extra, this additionally defines \glsxtrnewnumber
. §2.6; 119
Indicates whether word or letter order should be used. With Options 2 and 3, this information is written to the aux file, where it can be picked up by makeglossaries. This option will have no effect if you call makeindex or xindy explicitly. §2.5; 109
Letter order (“seal” before “sea lion”). 109
Word order (“sea lion” before “seal”). 109
Cancels the effect of disablemakegloss. §2.5; 116
Indicates whether the default sort value should be sanitized (only applicable with sort=standard). §2.5; 105
If true, save number lists. Only applicable with Options 2 and 3 as Options 1 and 4 have the number list stored in the loclist field and Option 4 also has the formatted number list in the location field. §2.3; 91
If true, indexing information is stored until the end of the document to reduce the number of write registers. §2.1; 83
Indicates which section heading command to use for the glossary. The value may be one of the standard sectioning command’s control sequence name (without the leading backslash), such as chapter
or section
. §2.2; 88
Automatically adds nonumberlist={false} to any entries with the see key set. §2.3; 98
Indicates what to do if the see key is used before the associated indexing files have been opened by \makeglossaries
. §2.4; 100
Triggers an error if the see key is used before \makeglossaries
. 100
Does nothing if the see key is used before \makeglossaries
. 100
Triggers a warning if the see key is used before \makeglossaries
. 100
Defines various shortcut commands. Has additional values with glossaries-extra. §2.7; 123
Deprecated in version 4.02 (2013-12-05) and removed in version 4.50. Now only available with rollback. §2.8; 125
Deprecated in version 4.02 (2013-12-05) and removed in version 4.50. Now only available with rollback. §2.8; 125
Indicates how the sort key should automatically be assigned if not explicitly provided (for \makeglossaries
and \makenoidxglossaries
only). §2.5; 105
Sets the sort key to an empty value. Use this option if no indexing is required for a slightly faster build. 106
Use the (zero-padded) order of definition as the default for the sort key. 106
Don’t process the sort key. Use this option if no indexing is required for a slightly faster build. 105
Use the value of the name key as the default for the sort key and implement the \glsprestandardsort
hook. 106
Use the (zero-padded) order of use as the default for the sort key. 106
Sets the default glossary style to . §2.3; 96
Enables the entry counter for level 1 entries. §2.3; 94
Provides a new glossary with the label symbols
and the title \glssymbolsgroupname
, and provides \printsymbols
. With glossaries-extra, this additionally defines \glsxtrnewsymbol
. §2.6; 118
If true, each glossary will be automatically added to the table of contents. The default is toc=false with glossaries and toc=true with glossaries-extra. §2.2; 87
Indicates how multilingual support should be provided, if applicable. §2.1; 83
Uses babel’s language hooks to implement multilingual support (default for glossaries-extra if babel has been detected). 84
Don’t implement multilingual support (default if no language package has been detected). 84
Uses translator’s language hooks to implement multilingual support (default for glossaries if a language package has been detected). 84
Indicates whether or not to use all caps in the glossary header. §2.2; 89
Creates a file called
that contains all defined entry labels and names (for the benefit of auto-completion tools). §2.1; 86
\jobname
.glslabels
Creates a file called
that contains all defined entry labels (for the benefit of auto-completion tools). §2.1; 86
\jobname
.glslabels
Indicates that the indexing should be performed by xindy. §2.5; 110
Sets the xindy codepage. Defaults to utf8
if \inputencodingname
isn’t defined. Only applicable if you use makeglossaries or automake. §2.5; 111
Indicates whether or not to add the glsnumbers
letter group. §2.5; 112
Sets the xindy language module. Only applicable if you use makeglossaries or automake. §2.5; 111
Equivalent to xindy with no value. §2.5; 112
Equivalent to xindy={glsnumbers=false}. §2.5; 112
Index[link]
Symbols[link]
\$
@[link]
\@gobble
A[link]
\acrfull
§6.1; Table 6.1; 178, 204, 208–215 passim, 220, 226, 236, 404, 406, 419, 500, 548, 549, 550, 589B[link]
C[link]
D[link]
E[link]
F[link]
G[link]
Glo[link]
Gls[link]
\glsdefaulttype
121, 140, 160, 162, 181, 199, 245–247, 254, 260, 346, 364, 520, 528, 552–560 passim, 570, 626, 644, 650, 656Glsxtr[link]
H[link]
I[link]
J[link]
L[link]
M[link]
\makeglossaries
§3.2; 5, 9, 15–21 passim, 29, 50, 52, 64, 76–82 passim, 100, 105, 111, 115, 116, 130–132, 142, 163, 166, 245, 260, 266, 280, 286, 295, 345–350 passim, 356–358, 407, 422, 429, 434, 438, 443–451 passim, 458, 463, 468, 471, 475–478 passim, 482, 484, 489, 493, 568, 607, 610, 645, 648, 651, 657–668 passim\MakeUppercase
\mark-both
N[link]
\newabbreviation
5, 41, 121, 143, 157, 160, 172, 173, 397–399, 404–411 passim, 415, 419, 448, 450, 499, 501, 516, 518, 595–599 passim, 613, 644, 646, 647\newacronym
§6; 41, 59, 121–126 passim, 134–143 passim, 152, 157, 160, 164, 166, 172, 173, 197–217 passim, 226–229 passim, 238, 268, 386, 397–399, 404–411 passim, 415, 419, 448, 450, 496, 499, 514–518 passim, 529, 552, 561, 570, 589, 590, 595–599 passim, 606, 613, 617, 647\newglossary
§9; 9, 67–75 passim, 98, 117, 143, 170, 245, 247, 253, 254, 258, 280, 347, 348, 365, 451, 647\newglossaryentry
§4; Table 1.1; 31, 47, 82, 87, 98, 105–107, 134, 142, 147, 152, 153, 160–166 passim, 172, 173, 197, 198, 208, 216, 217, 238, 280, 376, 377, 399, 404, 408, 413, 430, 435, 450, 463, 464, 471, 482, 484, 489–496 passim, 514–518 passim, 561, 646, 647, 648, 652, 660\NoCaseChange
\nopostdesc
§4; 135, 136, 158, 159, 304, 368, 445, 452–455 passim, 461, 462, 470, 639, 648, \glsxtrnopostpunc
O[link]
P[link]
\printglossaries
§8; 17, 55, 164, 231, 246, 259, 430, 435, 438, 446, 449, 459, 463, 468, 471, 478, 482, 484, 489, 509, 648, 650\printglossary
§8; a, 15–20 passim, 55, 87, 127, 128, 165, 195, 245, 246, 251, 259, 260, 287, 331, 346, 407, 422, 443, 488, 490, 509, 647–650 passim, 651, 666\printnoidxglossary
§8; 7, 14, 105–110 passim, 195, 245–249 passim, 257, 259, 296, 297, 449, 526, 546, 602, 645, 651\printunsrtglossaries
§8; 26–30 passim, 246, 430, 435, 438, 459, 463, 468, 471, 478, 482, 484, 489, 509, 652\printunsrtglossary
§8; 23–30 passim, 34, 105, 106, 134, 246–251 passim, 259, 296, 329, 407, 422, 439, 490, 509, 512, 526, 648, 651, 652R[link]
S[link]
\setacronymstyle
§6.2; 122–124, 172, 173, 197, 207–211 passim, 216, 404, 409, 419, 448, 499, 529, 550, 556–560, 647, 654, 655–657\setmainlanguage
\setotherlanguage
T[link]
U[link]
W[link]
X[link]
1This style was supplied by Axel Menzel.