I am using the glossaries package to make a list of acronyms and a list of symbols (separately). Following this approach, I tried to make a list of symbols that has that layout, but with a separated greek and roman symbols section.
I tried to do this using the link's \newglossarystyle
command:
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long4col-booktabs}%
\renewenvironment{theglossary}%
{%
\renewcommand{\arraystretch}{1.5}%
\begin{longtable}{cp{\glsdescwidth}c>{\centering}p{\glspagelistwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\bfseries Symbol & \bfseries \descriptionname & \bfseries Unit & \bfseries First appearance \tabularnewline
\midrule\endhead}%
\renewcommand{\glossentry}[2]{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & \glossentrydesc{##1} & \glossentrydesc{##1} & \glsentryunit{##1}
\tabularnewline
}%
}
This gives me a push in the right direction in that the separation of roman and greek letters is correct. However, the units column and symbols column, except for the Roman letters and Greek letters indicators, are left entirely empty.
Taken from this question, I have defined the unit
key using this command, before calling \makeglossaries
:
\glsaddkey
{unit} % new key
{\relax} % default value if "unit" isn't used in \newglossaryentry
{\glsentryunit} % analogous to \glsentrytext
{\Glsentryunit} % analogous to \Glsentrytext
{\glsunit} % analogous to \glstext
{\Glsunit} % analogous to \Glstext
{\GLSunit} % analogous to \GLStext
I have made the distinction between Roman and Greek symbols by assigning a parent
to each glossary entry, following this approach:
% Define the parent romand and greek symbols
\newglossaryentry{romanletter}{name={\textbf{Roman letters}}, description={\nopostdesc}, sort={1}, type=symbols}
\newglossaryentry{greekletter}{name={\textbf{Greek letters}}, description={\nopostdesc}, sort={2}, type=symbols}
% Don't expand the unit field
\glssetnoexpandfield{unit}
% Some sample symbol glossary entries
\newglossaryentry{drag}{name={\ensuremath{D}},
sort={drag},
description={drag},
parent={romanletter},
type={symbols},
unit={\si{\newton}}}
\newglossaryentry{h}{name={\ensuremath{h}},
sort={h},
description={altitude},
parent={romanletter},
type={symbols},
unit={\si{\metre}}}
\newglossaryentry{lift}{name={\ensuremath{L}},
sort={lift},
description={lift},
parent={romanletter},
type={symbols},
unit={\si{\newton}}}
\newglossaryentry{mach}{name={\ensuremath{M}},
sort={Mach number},
description={Mach number},
parent={romanletter},
type={symbols},
unit={[-]}}
\newglossaryentry{mass}{name={\ensuremath{m}},
sort={mass},
description={mass},
parent={romanletter},
type={symbols},
unit={\si{\kilogram}}}
\newglossaryentry{pitchrate}{name={\ensuremath{q}},
sort={q},
description={pitch rate},
parent={romanletter},
type={symbols},
unit={\si{\radian\per\second}}}
% Some greek letter
\newglossaryentry{eta}{name={\ensuremath{\eta}},
sort={7},
description={(propulsive) efficiency},
parent={greekletter},
type={symbols},
unit={[-]}}
I am probably going wrong somewhere in the \newglossarystyle
command, but I've been trying to work it out reading the docs and inspecting previously posted questions, but I can't seem to work it out. I find the syntax \renewcommand{\glossentry}[2]{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & \glossentrydesc{##1} & \glossentrydesc{##1} & \glsentryunit{##1}
quite confusing and am not able to work out all those commands from the glossaries docs.
Summarising all the above in a MWE:
\documentclass{report}
\usepackage{siunitx} \sisetup{detect-all}
\usepackage{hyperref}
\usepackage[nopostdot, toc, nogroupskip, nomain, indexonlyfirst, acronym, symbols, style=long4col, stylemods={longbooktabs}]{glossaries-extra}
\GlsXtrEnablePreLocationTag{page~}{pages~}
\glsaddkey
{unit} % new key
{\relax} % default value if "unit" isn't used in \newglossaryentry
{\glsentryunit} % analogous to \glsentrytext
{\Glsentryunit} % analogous to \Glsentrytext
{\glsunit} % analogous to \glstext
{\Glsunit} % analogous to \Glstext
{\GLSunit} % analogous to \GLStext
\makeglossaries
% Define the parent romand and greek symbols
\newglossaryentry{romanletter}{name={\textbf{Roman letters}}, description={\nopostdesc}, sort={1}, type=symbols}
\newglossaryentry{greekletter}{name={\textbf{Greek letters}}, description={\nopostdesc}, sort={2}, type=symbols}
% Don't expand the unit field
\glssetnoexpandfield{unit}
% Some sample symbol glossary entries
\newglossaryentry{drag}{name={\ensuremath{D}},
sort={drag},
description={drag},
parent={romanletter},
type={symbols},
unit={\si{\newton}}}
\newglossaryentry{h}{name={\ensuremath{h}},
sort={h},
description={altitude},
parent={romanletter},
type={symbols},
unit={\si{\metre}}}
\newglossaryentry{lift}{name={\ensuremath{L}},
sort={lift},
description={lift},
parent={romanletter},
type={symbols},
unit={\si{\newton}}}
\newglossaryentry{mach}{name={\ensuremath{M}},
sort={Mach number},
description={Mach number},
parent={romanletter},
type={symbols},
unit={[-]}}
\newglossaryentry{mass}{name={\ensuremath{m}},
sort={mass},
description={mass},
parent={romanletter},
type={symbols},
unit={\si{\kilogram}}}
\newglossaryentry{pitchrate}{name={\ensuremath{q}},
sort={q},
description={pitch rate},
parent={romanletter},
type={symbols},
unit={\si{\radian\per\second}}}
% Some greek letter
\newglossaryentry{eta}{name={\ensuremath{\eta}},
sort={7},
description={(propulsive) efficiency},
parent={greekletter},
type={symbols},
unit={[-]}}
% Set the new glossary style
\newglossarystyle{symbunitlong}{%
\setglossarystyle{long4col-booktabs}%
\renewenvironment{theglossary}%
{%
\renewcommand{\arraystretch}{1.5}%
\begin{longtable}{cp{\glsdescwidth}c>{\centering}p{\glspagelistwidth}}}%
{\end{longtable}}%
\renewcommand*{\glossaryheader}{%
\bfseries Symbol & \bfseries \descriptionname & \bfseries Unit & \bfseries First appearance \tabularnewline
\midrule\endhead}%
\renewcommand{\glossentry}[2]{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & \glossentrydesc{##1} & \glossentrydesc{##1} & \glsentryunit{##1}
\tabularnewline
}%
}
\begin{document}
\glsaddall
\printglossary[type=symbols, style=symbunitlong]
\end{document}
Thanks in advance!
P.S. I would also like each column's width to be adapted to the widest entry in that column. For example, the last column should be made wider to display First appearance in one line. Moreover, the entries should be left-aligned instead of centered. This is of secondary importance, though.