% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

\documentclass[a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage[record,% use bib2gls
 nostyles,% don't load default styles
 stylemods={tree},% load glossary-tree and patch styles
 style=alttreegroup]{glossaries-extra}

\GlsXtrLoadResources[
 src={chemicalformula},% definitions in chemicalformula.bib
 entry-type-aliases={chemical=symbol},
 field-aliases={formula=name,chemicalname=description},
 symbol-sort-fallback=name,% use name field as fallback for sort
 sort=letternumber-case,% case-sensitive letter-number sort
 set-widest,% needed for alttree styles
 save-locations=false% don't create location lists
]

\renewcommand*{\glstreenamefmt}[1]{#1}
\renewcommand*{\glstreegroupheaderfmt}[1]{\textbf{#1}}

\begin{document}
\section{Sample}

Reference Entries: \gls{Al2SO43}, \gls{H2O}, \gls{C6H12O6},
\gls{CH3CH2OH}, \gls{CH2O}, \gls{OF2}, \gls{O2F2}, \gls{SO42-},
\gls{H3O+}, \gls{OH-}, \gls{O2}, \gls{AlF3}, \gls{O}, 
\gls{Al2CoO4}, \gls{As4S4}, \gls{C10H10O4}, \gls{C5H4NCOOH}, 
\gls{C8H10N4O2}, \gls{SO2}, \gls{S2O72-}, \gls{SbBr3}, 
\gls{Sc2O3}, \gls{Zr3PO44}, \gls{ZnF2}.

\printunsrtglossary
\end{document}
