# Centralise group titles of glossary

I have been using glossaries-extra to generate a list of symbols in my thesis but I have been struggling on the formatting side of things. More specifically, the problem is that my chapter titles are centred, but the glossary group titles are not.

I have had a look at the gallery for Custom Group Blocks and also the different formatting styles, but I have not managed to find a solution. Ideally the list should look something like style=long (see Fig. below) but with group titles present, that are centred.

Is there a simple way to centre the group titles of a glossary?

MWE:

\documentclass[parskip,12pt,oneside,a4paper]{scrbook}
\usepackage[record,symbols,nomain,stylemods={tree},shortcuts=other]{glossaries-extra}

\renewcommand*{\raggedchapter}{\centering}% Make chapters centred

\glsxtrsetgrouptitle{bte}{Neutron transport}
\glsxtrsetgrouptitle{angdisc}{Angular discretisations}

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{r}{
name={\ensuremath{\mathbf{r}}},
description={Position},
group={bte},
type={symbols}
}
\newentry{S2}{
name={\ensuremath{\mathit{S_2}}},
description={Angular domain: the unit sphere},
group={bte},
type={symbols}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{SN}{
name={\ensuremath{S_N}},
description={Discrete Ordinates discretisation of \gls{S2}},
group={angdisc},
type={symbols}
}
\newentry{PN}{
name={\ensuremath{P_N}},
description={Spherical Harmonics discretisation of \gls{S2}},
group={angdisc},
type={symbols}
}

% \printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\printunsrtglossary[type=symbols,style=indexgroup,title={List of Symbols}]
\clearpage

\end{document}

• The link you have posted is about customization with bib2gls, however, you are not using it. Have you tryed it with bib2gls? Sep 14 '20 at 7:46
• @TomášKruliš I was under the impression that the majority of the settings for glossaries-extra were roughly the same regardless if you used bib2gls or pure LaTex, hence the link. To answer you question however, yes I did try it. The output looked identical to the MWE above, hence for the sake of simplicity I will refrain from using bib2gls in this question. Sep 14 '20 at 11:50

To answer the question you could simply renew the format by using

\renewcommand\glstreegroupheaderfmt[1]{\begin{center}\textbf{#1}\end{center}\vspace{-\parskip}}


and switching to the alttreegroup style. Therefore you must also use

\glsfindwidesttoplevelname


before the call of \printunsrtglossary. In the end it should look like this:

• thanks for the suggestion, however, alttreegroup increases the spacing between the entries to what looks like double spacing and also places them at the leftmost border of the page. Do you know how to adjust the entry spacing and text justification to resemble more style=long but with groups? Oct 3 '20 at 14:34
• Adding to my previous comment the entry spacing can be adjusted with something like this \renewcommand{\glossarypreamble}{\glsfindwidesttoplevelname[\acronymtype] \setlength{\parskip}{0pt}} credit to this post Oct 3 '20 at 14:49

Having tested a few alternatives, including the answer posted by @Venez, I think the easiest solution to this question is to define a new glossary style based on long. The long style is effectively a longtable which means simple column manipulations can result to the style requested, i.e. centred group titles and glossary entries being placed toward the centre of the page.

Solution:

\documentclass[parskip,12pt,oneside,a4paper]{scrbook}
\usepackage[record,symbols,nomain,stylemods={tree},shortcuts=other]{glossaries-extra}% list of symbols

\renewcommand*{\raggedchapter}{\centering}% Make chapters centred

\glsxtrsetgrouptitle{bte}{Neutron transport}
\glsxtrsetgrouptitle{angdisc}{Angular discretisations}

% Define a custom long style for groups; style=long uses longtables
\newglossarystyle{longgroup}{%
\setglossarystyle{long}%
&%  Add empty column in longtable
\multicolumn{1}{c}{% Change the alignment just for the group title to centre
\glsxtrgetgrouptitle{##1}{\glsxtrgrptitle}%
}%
\cr% newline in table
%\glsgroupskip% Uncomment for additional spacing below group title
}%
}%

\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{r}{
name={\ensuremath{\mathbf{r}}},
description={Position},
group={bte},
type={symbols}
}
\newentry{S2}{
name={\ensuremath{\mathit{S_2}}},
description={Angular domain: the unit sphere},
group={bte},
type={symbols}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newentry{SN}{
name={\ensuremath{S_N}},
description={Discrete Ordinates discretisation of \gls{S2}},
group={angdisc},
type={symbols}
}
\newentry{PN}{
name={\ensuremath{P_N}},
description={Spherical Harmonics discretisation of \gls{S2}},
group={angdisc},
type={symbols}
}

% \printunsrtglossary[type=symbols,style=long,title={List of Symbols}]
\printunsrtglossary[type=symbols,style=longgroup,title={List of Symbols}]
\clearpage

\end{document}