[Tex/LaTex] Glossaries: make \newglossaryentry behave as \newacronym

acronymsglossaries

I'm hoping this is a simple question, but I've been searching for the best part of the day for a solution to no avail. I basically want to make the \newglossaryentry command behave like the \newacronym command, so that when I first use \gls{uv} it prints "ultraviolet (UV)" rather than just "UV".

The reason I'm not using \newacronym is because I am using the alttree style for my glossary to break it up into three sections: acronyms, Roman symbols, and Greek symbols. Because of the requirement to set the parent flag for this style, I understand that I can't use \newacronym command.

A minimal working example is below.

\documentclass[12pt,twoside]{report}
\usepackage[utf8]{inputenc}

\usepackage[version=3]{mhchem}
\usepackage{dsfont}
\usepackage[nonumberlist,toc,nopostdot,style=alttree,xindy]{glossaries}

\makeglossaries
\glssetwidest{SNSPD}
\setacronymstyle{long-short}

\newglossaryentry{definition}{name={Acronyms}, description={\glspar}}
\newglossaryentry{roman}{name={Roman symbols}, description={\glspar}}
\newglossaryentry{greek}{name={Greek symbols}, description={\glspar}}

\newglossaryentry{snspd}{name=SNSPD, description={superconducting nanowire single photon detector}, parent=definition}
\newglossaryentry{uv}{name=UV, description={ultraviolet}, parent=definition}
\newglossaryentry{ir}{name=IR, description={infra-red}, parent=definition}


\newglossaryentry{sym:lambda}{name=\ensuremath{\lambda}, sort={lambda}, description={wavelength}, parent=greek}
\newglossaryentry{sym:hbar}{name=\ensuremath{\hbar}, sort={hbar}, description={reduced Planck constant}, parent=roman}

\begin{document}

\glsaddall
\printglossary[title={Definitions \& Abbreviations},toctitle={Definitions \& Abbreviations}]

\section{Section 1}
\Gls{uv} and \gls{ir}

\section{Section 2}
\Gls{uv} and \glspl{snspd}

\end{document}

which produces an output of the form:

[glossary]
UV and IR
UV and SNSPDs

I would like the output to be:

[glossary]
Ultraviolet (UV) and infra-red (IR)
UV and superconducting nanowire single photon detectors (SNSPDs)

I found the type=\acronymtype command and thought I might be able to use that, but my TeX knowledge wasn't sufficient to achieve the result I wanted.

Thanks for reading!

Best Answer

\newacronym has an optional argument that allows you to provide additional keys, which are internally passed to \newglossaryentry, so you can just do:

\newacronym[parent=definition]{uv}{UV}{Ultraviolet}