I'm attempting to generate two distinct glossaries—one for symbols and another for acronyms. However, I'm encountering an issue where the description for symbols doesn't appear on the first use in the text when using '\glsxtrnewsymbol{}'. e.g. $\gls{x}$ only shows x and not position x
I've been stuck on this problem for a couple of hours now, so any help would be greatly appreciated.
My code is based on the excellent answer from Nicola Talbots in this post: Ordered symbols list with units
\documentclass[a4paper,twoside,11pt]{memoir}
\usepackage{siunitx}
\usepackage{xcolor}
\usepackage[colorlinks]{hyperref}
\usepackage[symbols,acronyms,nonumberlist,nogroupskip]{glossaries-extra}
% new keys must be defined before use
\glsaddstoragekey{unit}{}{\glsentryunit}
\glsnoexpandfields
%
\setabbreviationstyle[acronym]{long-short}
%
\glsxtrnewsymbol[description={position},unit={\si{m}}]{x}{\ensuremath{x}}
\glsxtrnewsymbol[description={velocity},unit={\si{\metre\per\second}}]{v}{\ensuremath{v}}
\newacronym{ulm}{ULM}{ultrasound localisation microscopy}
\newacronym{sr}{SR}{super-resolution}
%
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long3col}% base this style on the list style
\renewenvironment{theglossary}{% Change the table type --> 3 columns
\begin{longtable}{lp{\glsdescwidth}>{\centering\arraybackslash}p{2cm}}}%
{\end{longtable}}%
%
\renewcommand*{\glossaryheader}{% Change the table header
\bfseries Symbol & \bfseries Description & \bfseries Unit\\\hline
\endhead}%
\renewcommand*{\glossentry}[2]{% Change the displayed items
\glstarget{##1}{\glossentryname{##1}} %
& \glossentrydesc{##1}% Description
& \glsentryunit{##1} \tabularnewline
}%
}
%
\makenoidxglossaries
%
% Hyperref setup
\hypersetup{
colorlinks,
linkcolor={black!50!black},
citecolor={black!50!black},
urlcolor={blue!80!black}
}
%
\begin{document}
\glsaddall
\printunsrtglossary[type=symbols,style=symbunitlong, title=List of Symbols, toctitle=List of Symbols]
\printnoidxglossary[type=acronym, title=List of Acronyms, toctitle=List of Acronyms]
\tableofcontents
%
\chapter{Glossary Test}
First: $\gls{x}$, $\gls{v}$, \gls{ulm}, \gls{sr}\newline
Second: $\gls{x}$, $\gls{v}$, \gls{ulm}, \gls{sr}
\end{document}
Output:

glossarystyleis not relevant here, the symbols are not acronyms and so don't default to a special first style. This can be manually set through thefirstkey which can be given in the optional argument to\glsxtrnewsymbol. See this answer. – Dai Bowen Nov 13 '23 at 14:51The problem only exists when using the '{glossaries-extra}' package with '\glsxtrnewsymbol'. The '{glossaries}' package in combination with '\newsymbol' works as expected.
– Kflo Nov 13 '23 at 15:09\newsymbolis not defined inglossariesorglossaries-extra.\glsxtrnewsymbolis just a wrapper around\newglossaryentry,\newglossaryentrydefaults thefirstkey to be thetextkey which defaults to thenamekey, only thenamekey is specified by\glsxtrnewsymbol, acronyms are handled exceptionally in this sense. You can define your own wrapper around\newglossaryentrywhich parses the symbol and description and passes that to thefirstkey of\newglossaryentry, as the linked answer does with defining a\newsymbol. – Dai Bowen Nov 13 '23 at 16:44