glossaries glossaries-extra – How to Reproduce altlist-style in Glossaries with Index-style for Multi-line Names

glossariesglossaries-extra

I really liked the altlist-style in glossaries, but I didn't find a way how it could handle multiple-line names, so I looked for an alternative and I came up with the index-style, which would allow the multiple-line names, but looks ugly to me. Basically, I want the names not indended, but the descriptions, and some space between name and description (like in altlist-style).

This should probably be rather easy to achieve by working around with "\glstreepredesc", but I couldn't do it. If someone could help that would be perfect. (Or perhaps, as an alternative, is there a solution to have multiple-line names in altlist-style?)

Here is a MWE

% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex

\documentclass[fontsize=10pt]{scrbook}
\usepackage{geometry}
\geometry{
    paperheight=213mm,
    paperwidth=140mm,
    left=16mm,
    right=16mm,
    top=21mm,
    bottom=16mm,
    heightrounded,
}

\usepackage[
nopostdot]{glossaries}

\makeglossaries

\newglossaryentry{long-long-long-argument}
{
    name={The Name for the Very Long and the Most Important Argument in the Text},
    text={The Name for the Very Long and the Most Important Argument in the Text},
    description={The Very Long Description of the Very Long and the Most Important Argument in the Text. The Very Long Description of the Very Long and the Most Important Argument in the Text.}
}
\newglossaryentry{short-argument}
{
    name={Very Short argument.},
        text={Very Short argument.},
    description={Description of a very short argument. Description of a very short argument.},
}


\renewcommand{\glstreepredesc}{%
    \glstreeitem\parindent\hangindent}

\begin{document}

\gls{long-long-long-argument} \gls{short-argument}

\printglossary[style=index,nonumberlist]

\end{document}

Altlist-Style

Index-Style

Best Answer

list (and thus altlist) just uses a description list to typeset the glossary, so we can use enumitem to adjust its behavior. After loading this package and using altlist, we can get the names to break by just saying

\setlist[description]{style=unboxed}

In order to make all lines of the name left-aligned (I'm not sure this is a good idea), we can define a custom alignment.

\SetLabelAlign{horstfuchs}{\parbox[b]{\textwidth}{#1}}
\setlist[description]{style=unboxed, align=horstfuchs, labelsep=0pt}

In order for the definitions not to change all description lists in your document, you should create an appropriate glossary style instead of just changing the settings globally.

\SetLabelAlign{horstfuchs}{\parbox[b]{\textwidth}{#1}}%
\newglossarystyle{horstfuchs}{%
  \setglossarystyle{altlist}%
  \renewenvironment{theglossary}%
    {\glslistinit\begin{description}[style=unboxed, align=horstfuchs, labelsep=0pt]}%
    {\end{description}}%
}