I will demonstrate using some of the example .bib files provided with bib2gls.
mathgreek.bib defines some sample symbols that are all mathematical Greek characters. The LaTeX kernel doesn't provide commands for Greek characters that look the same as Latin character. This stems back to the days of limited resources and, for example, omicron could simply be produced with $o$. Unfortunately, from a sorting point of view this would result in omicron being placed between N and P instead of between Xi and Pi.
The interpreter used by bib2gls recognises the missing commands \omicron etc and so can correctly order them with the other math-Greek commands. However, it's necessary for LaTeX to also recognise them as well. The glossaries-extra-bib2gls package (automatically loaded with \usepackage[record]{glossaries-extra}) now provides these missing commands. The mathgreek.bib example file allows for an older version that doesn't provide them and uses @preamble to provide the definition of \omicron:
@preamble{"\providecommand{\omicron}{o}"}
The entries are defined using @symbol. The identifier field is a custom field that bib2gls won't recognise by default, but it's possible to provide or alias the field on a per-document basis. This just makes the .bib file more widely useful across multiple documents. The first couple of entries are:
@symbol{alpha,
name={\ensuremath{\alpha}},
description={alpha},
identifier={mathgreek}
}
@symbol{beta,
name={\ensuremath{\beta}},
description={beta},
identifier={mathgreek}
}
The other entries follow the same format.
mathsobjects.bib is rather more complicated. It first provides some semantic commands to format the notation:
@preamble{"\providecommand{\setfmt}[1]{\mathcal{#1}}
\providecommand{\setcontentsfmt}[1]{\{#1\}}
\providecommand{\setmembershipfmt}[2]{\setcontentsfmt{#1: #2}}
\providecommand{\setmembershiponeargfmt}[1]{\setmembershipfmt#1}
\providecommand{\setcardfmt}[1]{\lvert#1\rvert}
\providecommand{\numspacefmt}[1]{\mathbb{#1}}
\providecommand{\transposefmt}[1]{#1^T}
\providecommand{\invfmt}[1]{#1^{-1}}
\providecommand{\vecfmt}[1]{\boldsymbol{#1}}
\providecommand{\mtxfmt}[1]{\boldsymbol{#1}}"}
So, for example, \setfmt formats its argument in a calligraphic font to denote a set. The first three entries are defined as:
@symbol{set,
name={\ensuremath{\setfmt{S}}},
description={\sortart{a}{set}},
format={setfmt},
identifier={set}
}
@symbol{setcontents,
name={\ensuremath{\setcontentsfmt{\ldots}}},
description={set contents},
format={setcontentsfmt},
identifier={set}
}
@symbol{setmembership,
name={\ensuremath{\setmembershipfmt{\vecfmt{x}}{\ldots}}},
description={set membership},
format={setmembershiponeargfmt},
identifier={set}
}
The other entries are defined in a similar way. Again the custom identifier field is used, which bib2gls will ignore by default. There's also another custom field called format that's used to store the name of a control sequence that takes a single argument that applies the appropriate format. This will also be ignored by default.
baseunits.bib uses a custom entry type (@unit), so bib2gls will ignore all entries in this file unless an alias is set up. This means that different documents using the same .bib file can use whatever's the most appropriate entry type. For example, if a document needs @unit to be treated as @symbol, then the document needs to set up the alias:
entry-type-aliases={unit=symbol}
or if @unit should be treated as @entry:
entry-type-aliases={unit=entry}
The first few entries are defined as:
@unit{ampere,
unitname={ampere},
unitsymbol={\si{\ampere}},
measurement={electric current},
identifier={baseunit}
}
@unit{kilogram,
unitname={kilogram},
unitsymbol={\si{\kilogram}},
measurement={mass},
identifier={baseunit}
}
@unit{metre,
unitname={metre},
unitsymbol={\si{\metre}},
measurement={length},
identifier={baseunit}
}
The other entries all follow the same format. In this case all the fields are custom fields that bib2gls will ignore by default, so they will need to be aliased. This again allows greater flexibility across multiple documents that use the same .bib file.
makruplanguages.bib has a mixture of normal entries (@entry) and abbreviations (@abbreviation). This provides a custom command used to tag the abbreviation initials. This just does its argument by default:
@preamble{"\providecommand{\abbrvtag}[1]{#1}"}
The .bib file also defines a bib variable for convenience:
@string{markuplang="\abbrvtag{m}arkup \abbrvtag{l}anguage"}
This variable is just for use in the .bib file. String concatenation is performed with # in a .bib file. For example:
long = {e\abbrvtag{x}tensible } # markuplang
is equivalent to:
long = {e\abbrvtag{x}tensible \abbrvtag{m}arkup \abbrvtag{l}anguage}
The first few entries are:
@entry{TeX,
name={{}\TeX},
description={a format for describing complex type and page layout
often used for mathematics, technical, and academic publications},
identifier={markuplanguage}
}
@entry{LaTeX,
name={{}\LaTeX},
description={a format of \glstext{TeX} designed to separate
content from style},
identifier={markuplanguage}
}
@entry{markdown,
name={markdown},
description={a lightweight markup language with plain text
formatting syntax},
identifier={markuplanguage}
}
@abbreviation{xml,
short={XML},
long={e\abbrvtag{x}tensible }#markuplang,
description={a markup language that defines a set of rules for
encoding documents},
identifier={markuplanguage}
}
@abbreviation{html,
short={HTML},
long={\abbrvtag{h}yper\abbrvtag{t}ext }#markuplang,
description={the standard markup language for creating web pages},
identifier={markuplanguage}
}
The empty group {} in front of \TeX and \LaTeX is in case any automated first letter upper-casing command is applied, as it's not appropriate for these commands.
Some of the sample .bib files use custom commands such as \sortart. There are three different .bib files that provide these commands: no-interpret-preamble.bib, interpret-preamble.bib and interpret-preamble2.bib. For now, I'm just going to use no-interpret-preamble.bib which contains:
@preamble{"\providecommand{\sortname}[2]{#1 #2}
\providecommand{\sortvonname}[3]{#1 #2 #3}
\providecommand{\sortart}[2]{#1 #2}
\providecommand{\sortmediacreator}[2]{#1 #2}"}
The first example document just has a single list to get started. The mathsobjects.bib file includes commands that are provided by amssymb, and the baseunits.bib file includes commands that are provided by siunitx, so those packages will need to be loaded:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
\GlsXtrLoadResources[
src={no-interpret-preamble,mathgreek,mathsobjects,baseunits,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
If the file is called test.tex then the document build is:
pdflatex test
bib2gls test
pdflatex test
(Replace pdflatex with xelatex etc, as appropriate.)
This creates a single glossary that starts as follows:

This places beta (β) between "ampere" and "candela". The sort values are determined by the entry type. For example, if an entry is defined with @entry then the sort value is obtained from the name field, if an entry is defined with @abbreviation then the sort value is obtained from the short field, and if an entry is defined with @symbol then the sort value is obtained from the label. So β is actually sorted by its label beta.
You can change the field used to obtain the default sort value for the @symbol entries using the symbol-sort-fallback option. For example, to use the name field instead:
symbol-sort-fallback=name
(For abbreviations, you can use abbreviation-sort-fallback.) Below is a modified version of the above MWE that sorts symbols according to the name field:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
\GlsXtrLoadResources[
src={no-interpret-preamble,mathgreek,mathsobjects,baseunits,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
The start of the glossary now looks like:

The Greek letters now come after Z:

There are a number of ways of splitting the data up into separate glossaries. This first method prevents the creation of the default main glossary (using the nomain package option) and defines three glossaries with labels that correspond to the entry type (without the initial @). This means that the type can easily be assigned using:
type={same as entry}
Here's the updated MWE:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record,nomain]{glossaries-extra}
\newglossary*{entry}{Glossary}
\newglossary*{abbreviation}{Abbreviations}
\newglossary*{symbol}{Symbols}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
\GlsXtrLoadResources[
src={no-interpret-preamble,mathgreek,mathsobjects,baseunits,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
type={same as entry},
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
The document now has three lists. The first is the entry glossary:

The second is the abbreviation glossary:

The third is the symbol glossary, which starts:

The Greek characters again come after Z.
Unlike the \makeglossaries approach (using makeindex or xindy), this method only has two associated glossary files: the .glstex which is input by \GlsXtrLoadResources and the .glg transcript file (which contains messages from bib2gls). With makeindex/xindy a document that has three glossary lists would have 10 corresponding glossary files (3 per glossary plus the style file).
With bib2gls, it's not the number of glossaries but the number of \GlsXtrLoadResources commands that determines the number of associated glossary files. Here's an alternative to the above that uses two resource commands:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record,abbreviations,symbols]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
\GlsXtrLoadResources[
src={no-interpret-preamble,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathgreek,mathsobjects,baseunits},% bib files
sort={letter-case},% sort according Unicode value
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
type=symbols,
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
In this case, I've used the abbreviations and symbols package option to create the glossaries labelled abbreviations and symbols. Package options that are provided by the base glossaries package are processed before options that are only provided by glossaries-extra, so \printunsrtglossaries will now list the glossaries in the order: main (default), symbols, abbreviations. You can change the order by using \printunsrtglossary for each individual glossary. For example:
\printunsrtglossary[type=abbreviations]
\printunsrtglossary % default main glossary
\printunsrtglossary[type=symbols]
This method has the advantage that a different sort method can be used for the symbols list (sort=letter-case). The first resource command doesn't set the glossary with the type option, so the default type is used. This is the default main for normal entries, but the entries defined with @abbreviation in the .bib file are defined using \newabbreviation in the .glstex file, so they will end up in the abbreviations glossary, since the abbreviations package option has been used.
A glossary list can be sub-sorted in blocks by splitting the entries across multiple resource commands. For example:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record,abbreviations,symbols]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
\GlsXtrLoadResources[
src={no-interpret-preamble,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={baseunits},% bib file
sort={letter-case},% sort according Unicode value
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
type=symbols,
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathsobjects},% bib file
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathgreek},% bib file
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
The symbols list now starts with the units:

In this case I've used sort=letter-case for all the sub-blocks, but it's possible to use different sort methods for each block.
Let's suppose I now want to switch to a glossary style that displays letter group headings, for example the treegroup style:
\usepackage[record,abbreviations,symbols,stylemods={tree},style=treegroup]{glossaries-extra}
Now bib2gls needs to be run with the --group (or -g) switch:
bib2gls --group test
If the above change is made to the MWE, this will result in errors like:
! Package inputenc Error: Unicode character (U+1D6FC)
(inputenc) not set up for use with LaTeX.
This is because bib2gls tries to put the alpha entry into the "" letter group, but that Unicode character isn't supported by the document. However, in this case it isn't appropriate for each Greek letter to be in its own letter group. Instead the entire block can be assigned to its own group using the group option. The value must be a label. A title can be assigned using \glsxtrsetgrouptitle{label}{title}. For example:
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record,abbreviations,symbols,stylemods={tree},style=treegroup]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
% Assign group titles:
\glsxtrsetgrouptitle{units}{SI Units}
\glsxtrsetgrouptitle{latin}{Latin Symbols}
\glsxtrsetgrouptitle{greek}{Greek Symbols}
\GlsXtrLoadResources[
src={no-interpret-preamble,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={baseunits},% bib file
sort={letter-case},% sort according Unicode value
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
type=symbols,
group=units,
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathsobjects},% bib file
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
group=latin,
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathgreek},% bib file
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
group=greek,
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
The symbols list now starts:

The custom identifier fields all have values that can be used as labels. It's possible to convert identifier into group using the option:
field-aliases={identifier=group}
The titles need to be supplied:
\glsxtrsetgrouptitle{set}{Sets}
\glsxtrsetgrouptitle{numberspace}{Number Spaces}
\glsxtrsetgrouptitle{matrix}{Matrices and Vectors}
It's now necessary to sort according to the group field in order to keep the members of each group together. This can be done with the option:
sort-field={group}
Entries within the same group then need to be sorted according to the name field. There are two ways to do this.
- Set
identical-sort-action={name} which will perform a character code comparison on the name field when the compared sort values (obtained from the field identified by sort-field) are identical.
- Use
sort-suffix={name} which will append the value of the name field to the sort value.
I've used the first option below with sort=en-GB, which means that the sort value (obtained from the group) field will be sorted according to the en-GB collation rules and the name fields will be sorted according to character code (which makes more sense for symbols).
\documentclass{report}
\usepackage{amssymb}
\usepackage{siunitx}
\usepackage[record,abbreviations,symbols,stylemods={tree},style=treegroup]{glossaries-extra}
% always set the abbreviation style before \GlsXtrLoadResources
\setabbreviationstyle{long-short-desc}
% Assign group titles:
\glsxtrsetgrouptitle{units}{SI Units}
\glsxtrsetgrouptitle{set}{Sets}
\glsxtrsetgrouptitle{numberspace}{Number Spaces}
\glsxtrsetgrouptitle{matrix}{Matrices and Vectors}
\glsxtrsetgrouptitle{greek}{Greek Symbols}
\GlsXtrLoadResources[
src={no-interpret-preamble,markuplanguages},% bib files
sort={en-GB},% sort according to this locale
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={baseunits},% bib file
sort={letter-case},% sort according Unicode value
entry-type-aliases={unit=entry},% make @unit behave like @entry
field-aliases={
unitname=name,
unitsymbol=symbol,
measurement=description
},
symbol-sort-fallback=name,
type=symbols,
group=units,
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathsobjects},% bib file
sort={en-GB},% sort according to this locale
sort-field={group},% sort according to this field
identical-sort-action={name},% sort using letter case comparison by this field when sort-field values are identical
symbol-sort-fallback=name,
type=symbols,
field-aliases={identifier=group},
selection=all% select all entries in the .bib files
]
\GlsXtrLoadResources[
src={mathgreek},% bib file
sort={letter-case},% sort according Unicode value
symbol-sort-fallback=name,
type=symbols,
group=greek,
selection=all% select all entries in the .bib files
]
\begin{document}
\printunsrtglossaries
\end{document}
The start of the symbols list now looks like:

There are many predefined styles to choose from.
Acronyms vs Abbreviations
The base glossaries package provides the command \newacronym which may be used to define acronyms or other forms of abbreviations. The package options acronyms or acronym create a new glossary acronym. You can reference it explicitly with that label or use \acronymtype.
The glossaries-extra extension package provides a completely new abbreviation handling system that's more flexible than the one used by the base package. The \newabbreviation command is provided to define all forms of abbreviations (including acronyms) using this new mechanism.
To assist with migrating from just using the base package to using the glossaries-extra package, \newacronym is redefined in terms of \newabbreviation, but it also sets category=acronym (which overrides the default category=abbreviation set by \newabbreviation). It is possible to switch \newacronym back to using the base glossaries package's abbreviation handling, although I don't recommend this.
The glossaries-extra package also permits the acronyms or acronym package option, which can be used as well as or instead of the abbreviations package option. If you use both acronyms/acronym and abbreviations then (if no type is explicitly set) \newacronym will put the entry in the acronym (\acronymtype) glossary and \newabbreviation will put the entry in the abbreviations (\glsxtrabbrvtype) glossary. If you only use the abbreviations package option then \acronymtype is redefined to \glsxtrabbrvtype.
Within the .bib files, you may use either @abbreviation (which will define the entry using \newabbreviation) or @acronym (which will define the entry using \newacronym). Since \newacronym sets category=acronym by default, you need to use the optional argument of \setabbreviationstyle to set the abbreviation style. For example:
\setabbreviationstyle[acronym]{long-short}
bib2glssee Problem with the Glossary+bib2gls on Overleaf. – Nicola Talbot Jan 08 '19 at 18:56bib2gls. Perhaps if enough people ask they may add it. – Nicola Talbot Jan 08 '19 at 21:25bib2glsin theexamplessubdirectory. They're described in the "Examples" chapter of the manual. I'll see if I can provide an answer with an example. – Nicola Talbot Jan 09 '19 at 14:22