[Tex/LaTex] Glossaries: list of abbreviations (alphabetically ordered) and list of symbols (ordered by usage)

glossaries

For my thesis, I would like to generate a list of abbreviations that is ordered alphabetically as well as list of symbols that is ordered by the first appearance of each symbol in the thesis. Having done some research, it seems to me that the
glossaries package is the best package for this.

I can generate a list of abbreviations ordered alphabetically like this:

\documentclass[a4paper,twoside]{book}
\usepackage[acronym]{glossaries}

\newacronym{ny1}{NY}{New York}
\newacronym{la1}{LA}{Los Angeles}
\newacronym{un1}{UN}{United Nations}
\makeglossaries

\begin{document}
\printglossary[type=\acronymtype,title=Abbreviations]

\gls{ny1} \gls{la1} and \gls{un1} are abbreviations that should 
appear alphabetically in the list of abbreviations.

\end{document}

enter image description here

I can also generate a list of symbols ordered by their first appearance in the document like this:

\documentclass[a4paper,twoside]{book}
\usepackage[symbols,nogroupskip,nonumberlist,sort=use]{glossaries-extra}

\glsxtrnewsymbol[description={position}]{x}{\ensuremath{x}}
\glsxtrnewsymbol[description={velocity}]{v}{\ensuremath{v}}
\glsxtrnewsymbol[description={acceleration}]{a}{\ensuremath{a}}
\glsxtrnewsymbol[description={time}]{t}{\ensuremath{t}}
\glsxtrnewsymbol[description={force}]{F}{\ensuremath{F}}
\makenoidxglossaries

\begin{document}
\printnoidxglossary[type=symbols,style=long,title={List of Symbols}]

Reference symbols: $\gls{F}$, $\gls{t}$, $\gls{x}$, $\gls{v}$, $\gls{a}$.

\end{document}

enter image description here

However, merging both lists into one document is not straightforward for me as there is a clash between \usepackage[acronym]{glossaries} and \usepackage[symbols,nogroupskip,nonumberlist,sort=use]{glossaries-extra} when I try to load both packages. What is the best way to merge both lists into one document (abbreviations, alphabetically ordered and symbols, ordered by first appearance)?

Thank you

Best Answer

The glossaries-extra package internally loads glossaries so you don't need to load both. The "noidx" method is quick for order of use/definition but slow and inefficient for alphabetic sorting, so glossaries-extra provides a hybrid method where you can use makeindex/xindy for the glossaries that need alphabetical ordering and \printnoidxglossary for order of use/definition. With glossaries-extra, there's an optional argument to \makeglossaries that's a comma-separated list of glossary labels indicating which glossaries need processing by makeindex/xindy. These ones are displayed with \printglossary and the others are displayed with \printnoidxglossary. (Note that there's no \makenoidxglossary.)

\documentclass[a4paper,twoside]{book}
\usepackage[abbreviations,symbols,nogroupskip,nonumberlist]{glossaries-extra}

\makeglossaries[abbreviations]

\glsxtrnewsymbol[description={position}]{x}{\ensuremath{x}}
\glsxtrnewsymbol[description={velocity}]{v}{\ensuremath{v}}
\glsxtrnewsymbol[description={acceleration}]{a}{\ensuremath{a}}
\glsxtrnewsymbol[description={time}]{t}{\ensuremath{t}}
\glsxtrnewsymbol[description={force}]{F}{\ensuremath{F}}

\newabbreviation{ny1}{NY}{New York}
\newabbreviation{la1}{LA}{Los Angeles}
\newabbreviation{un1}{UN}{United Nations}

\begin{document}
\printnoidxglossary[type=symbols,sort=use,style=long,title={List of Symbols}]
\printglossary[type=abbreviations]

Reference symbols: $\gls{F}$, $\gls{t}$, $\gls{x}$, $\gls{v}$, $\gls{a}$.

\gls{ny1} \gls{la1} and \gls{un1} are abbreviations that should
appear alphabetically in the list of abbreviations.

\end{document}

The build process still uses the makeglossaries script, which picks up from the .aux file which glossaries need processing, so in this case it will skip the list of symbols.

The list of symbols is in the order of use:

list of symbols in order of use

The list of abbreviations is in alphabetical order:

list of abbreviations in alphabetical order

If you prefer to use \newacronym instead of \newabbreviation you need to replace the abbreviations package option with acronyms (or acronym) and set the abbreviation style:

\documentclass[a4paper,twoside]{book}
\usepackage[acronym,symbols,nogroupskip,nonumberlist]{glossaries-extra}

\makeglossaries[\acronymtype]

\glsxtrnewsymbol[description={position}]{x}{\ensuremath{x}}
\glsxtrnewsymbol[description={velocity}]{v}{\ensuremath{v}}
\glsxtrnewsymbol[description={acceleration}]{a}{\ensuremath{a}}
\glsxtrnewsymbol[description={time}]{t}{\ensuremath{t}}
\glsxtrnewsymbol[description={force}]{F}{\ensuremath{F}}

\setabbreviationstyle[acronym]{long-short}

\newacronym{ny1}{NY}{New York}
\newacronym{la1}{LA}{Los Angeles}
\newacronym{un1}{UN}{United Nations}

\begin{document}
\printnoidxglossary[type=symbols,sort=use,style=long,title={List of Symbols}]
\printglossary[type=\acronymtype]

Reference symbols: $\gls{F}$, $\gls{t}$, $\gls{x}$, $\gls{v}$, $\gls{a}$.

\gls{ny1} \gls{la1} and \gls{un1} are abbreviations that should
appear alphabetically in the list of abbreviations.

\end{document}

Here's a completely different approach where the terms are defined in .bib files.

abbreviations.bib:

% Encoding: UTF-8

@abbreviation{ny1,
  short = {NY},
  long = {New York}
}

@abbreviation{la1,
  short = {LA},
  long = {Los Angeles}
}

@abbreviation{un1,
  short = {UN},
  long = {United Nations}
}

If you already have an existing file containing \newabbreviation (or \newacronym) you can convert it to a .bib with convertgls2bib, which is supplied with bib2gls.

symbols.bib:

% Encoding: UTF-8

@symbol{x,
  name = {\ensuremath{x}},
  description = {position}
}

@symbol{v,
  name = {\ensuremath{v}},
  description = {velocity}
}

@symbol{a,
  name = {\ensuremath{a}},
  description = {acceleration}
}

@symbol{t,
  name = {\ensuremath{t}},
  description = {time}
}

@symbol{F,
  name = {\ensuremath{F}},
  description = {force}
}

Again, if you already have an existing file containing \glsxtrnewsymbol you can convert it to a .bib file with convertgls2bib.

Document (test.tex):

\documentclass[a4paper,twoside]{book}
\usepackage[record,% using bib2gls
 abbreviations,symbols]{glossaries-extra}

\GlsXtrLoadResources[
  src={abbreviations},% data in abbreviations.bib
  sort={en}, % sort by this language tag (en = English)
  type=abbreviations, % put the entries in this glossary
  save-locations=false % no number list required
]

\GlsXtrLoadResources[
  src={symbols}, % data in symbols.bib
  sort={use}, % sort by order of use
  type=symbols, % put the entries in this glossary
  save-locations=false % no number list required
]


\begin{document}
\printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\printunsrtglossary[type=abbreviations]

Reference symbols: $\gls{F}$, $\gls{t}$, $\gls{x}$, $\gls{v}$, $\gls{a}$.

\gls{ny1} \gls{la1} and \gls{un1} are abbreviations that should
appear alphabetically in the list of abbreviations.

\end{document}

The document build is:

pdflatex test
bib2gls test
pdflatex test

By default bib2gls doesn't form letter groups, so there's no need for the nogroupskip option now. If you decide that you do actually want letter groups you need to add the --group or -g switch:

bib2gls -g test

The list of symbols is as before:

list of symbols in order of use

and the list of abbreviations is again in alphabetical order:

list of abbreviations in alphabetical order

This provides a more flexible way of applying different ordering to different glossaries.

If your TeX distribution is too old to support either the hybrid method or the bib2gls method, you can use the \makenoidxglossaries method with just the base glossaries package as in the other answer, but with glossaries-extra you can still use \glsxtrnewsymbol if you have the symbols package option as that command has been available since the first release of glossaries-extra:

\documentclass[a4paper,twoside]{book}
\usepackage[abbreviations,symbols,nogroupskip,nonumberlist]{glossaries-extra}

\makenoidxglossaries

\glsxtrnewsymbol[description={position}]{x}{\ensuremath{x}}
\glsxtrnewsymbol[description={velocity}]{v}{\ensuremath{v}}
\glsxtrnewsymbol[description={acceleration}]{a}{\ensuremath{a}}
\glsxtrnewsymbol[description={time}]{t}{\ensuremath{t}}
\glsxtrnewsymbol[description={force}]{F}{\ensuremath{F}}

\newabbreviation{ny1}{NY}{New York}
\newabbreviation{la1}{LA}{Los Angeles}
\newabbreviation{un1}{UN}{United Nations}

\begin{document}
\printnoidxglossary[type=symbols,sort=use,style=long,title={List of Symbols}]
\printnoidxglossary[type=abbreviations]

Reference symbols: $\gls{F}$, $\gls{t}$, $\gls{x}$, $\gls{v}$, $\gls{a}$.

\gls{ny1} \gls{la1} and \gls{un1} are abbreviations that should
appear alphabetically in the list of abbreviations.

\end{document}

The advantage is that the code is a bit more compact.