Actually, this question has been already asked here:
How to effectively use List of Symbols for a thesis?
And there is a very good answer with 4 methods.
However…
Thank you very much for the post, very interesting! I am trying to implement the method 4 on Overleaf.com, but I meet some problems… Would be someone so kind to help me?
I have followed the example here above creating a file 'greek-symbols.bib' exactly as described above. Then I have a created a "symbols.tex" file:
\usepackage[symbols,nogroupskip,
record % using 'bib2gls'
]{glossaries-extra}
\GlsXtrLoadResources[
src={greek-symbols},% entries in 'greek-symbols.bib'
type=symbols,% put these entries in the 'symbols' glossary
save-locations=false% don't save locations
]
In the main.tex, I call this file, the settings, and build the document (for example):
\input{head/settings.tex} % place your packages, etc... in this file!
\input{symbols.tex}
\begin{document}
\tableofcontents
\listoftables
% Symbols
\printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\chapter{Mathematics}
Some symbols
Reference symbols: $\gls{x}$, $\gls{v}$, $\gls{a}$, $\gls{t}$, $\gls{F}$.
\end{document}
But the problem is that I obtain the following error:
Package gloassaries-extra Warning: No file 'output.glstex' on input
line 13.
If I look at line 13, it corresponds to the end of command
\GlsXtrLoadResources[
src={greek-symbols},% entries in 'greek-symbols.bib'
type=symbols,% put these entries in the 'symbols' glossary
save-locations=false% don't save locations
]
What is going on? Why following strictly the example, it does not work?
I would be very thankful if someone can help me.
Best regards, Elfo
Best Answer
I will demonstrate using some of the example
.bib
files provided withbib2gls
.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. Theglossaries-extra-bib2gls
package (automatically loaded with\usepackage[record]{glossaries-extra}
) now provides these missing commands. Themathgreek.bib
example file allows for an older version that doesn't provide them and uses@preamble
to provide the definition of\omicron
:The entries are defined using
@symbol
. Theidentifier
field is a custom field thatbib2gls
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:The other entries follow the same format.
mathsobjects.bib
is rather more complicated. It first provides some semantic commands to format the notation:So, for example,
\setfmt
formats its argument in a calligraphic font to denote a set. The first three entries are defined as:The other entries are defined in a similar way. Again the custom
identifier
field is used, whichbib2gls
will ignore by default. There's also another custom field calledformat
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
), sobib2gls
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:or if
@unit
should be treated as@entry
:The first few entries are defined as:
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:The
.bib
file also defines a bib variable for convenience:This variable is just for use in the
.bib
file. String concatenation is performed with#
in a.bib
file. For example:is equivalent to:
The first few entries are:
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
andinterpret-preamble2.bib
. For now, I'm just going to useno-interpret-preamble.bib
which contains:The first example document just has a single list to get started. The
mathsobjects.bib
file includes commands that are provided byamssymb
, and thebaseunits.bib
file includes commands that are provided bysiunitx
, so those packages will need to be loaded:If the file is called
test.tex
then the document build is:(Replace
pdflatex
withxelatex
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 thename
field, if an entry is defined with@abbreviation
then the sort value is obtained from theshort
field, and if an entry is defined with@symbol
then the sort value is obtained from the label. So β is actually sorted by its labelbeta
.You can change the field used to obtain the default sort value for the
@symbol
entries using thesymbol-sort-fallback
option. For example, to use thename
field instead:(For abbreviations, you can use
abbreviation-sort-fallback
.) Below is a modified version of the above MWE that sorts symbols according to thename
field: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 thenomain
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:Here's the updated MWE:
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 (usingmakeindex
orxindy
), this method only has two associated glossary files: the.glstex
which is input by\GlsXtrLoadResources
and the.glg
transcript file (which contains messages frombib2gls
). Withmakeindex
/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:In this case, I've used the
abbreviations
andsymbols
package option to create the glossaries labelledabbreviations
andsymbols
. Package options that are provided by the baseglossaries
package are processed before options that are only provided byglossaries-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: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 thetype
option, so the default type is used. This is the defaultmain
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 theabbreviations
glossary, since theabbreviations
package option has been used.A glossary list can be sub-sorted in blocks by splitting the entries across multiple resource commands. For example:
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:Now
bib2gls
needs to be run with the--group
(or-g
) switch:If the above change is made to the MWE, this will result in errors like:
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 thegroup
option. The value must be a label. A title can be assigned using\glsxtrsetgrouptitle{
label}{
title}
. For example:The symbols list now starts:
The custom
identifier
fields all have values that can be used as labels. It's possible to convertidentifier
intogroup
using the option:The titles need to be supplied:
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:Entries within the same group then need to be sorted according to the
name
field. There are two ways to do this.identical-sort-action={name}
which will perform a character code comparison on thename
field when the compared sort values (obtained from the field identified bysort-field
) are identical.sort-suffix={name}
which will append the value of thename
field to the sort value.I've used the first option below with
sort=en-GB
, which means that the sort value (obtained from thegroup
) field will be sorted according to theen-GB
collation rules and thename
fields will be sorted according to character code (which makes more sense for symbols).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 optionsacronyms
oracronym
create a new glossaryacronym
. 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 setscategory=acronym
(which overrides the defaultcategory=abbreviation
set by\newabbreviation
). It is possible to switch\newacronym
back to using the baseglossaries
package's abbreviation handling, although I don't recommend this.The
glossaries-extra
package also permits theacronyms
oracronym
package option, which can be used as well as or instead of theabbreviations
package option. If you use bothacronyms
/acronym
andabbreviations
then (if notype
is explicitly set)\newacronym
will put the entry in theacronym
(\acronymtype
) glossary and\newabbreviation
will put the entry in theabbreviations
(\glsxtrabbrvtype
) glossary. If you only use theabbreviations
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
setscategory=acronym
by default, you need to use the optional argument of\setabbreviationstyle
to set the abbreviation style. For example: