2

I'm trying to redefine the style of my glossaries list, and base it on the altlist. When executing the new style however, I notice that there is an empty line when two glossary items are grouped, even though I have specified \nopostdesc. In the normal altlist this empty line does not exist.

Another issue I have is that I'd like to capitalize the first letter of the description in the glossaries list. According to the manual I should be able to use \Glossentrydesc, but as soon as I'm using it, I'm getting 9 errors, the first being 'undefined control sequence' related to \nopostdesc. What am I doing wrong?

This is the result I get: Result of MWE

with the following MWE:

\documentclass{article}

\usepackage{glossaries}

%make a new glossaries style
\newglossarystyle{altlistnumbers}{%
    \setglossarystyle{altlist}%
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\Glossentryname{##1}}]
                    \mbox{}\par\nobreak
       \glossentrydesc{##1}\glspostdescription\hfill ##2}%
}

\setglossarystyle{altlistnumbers}
\makeglossaries

\newglossaryentry{abb} {
    name = {abb},
    description = {\nopostdesc},
}

\newglossaryentry{abbone} {
    description = {this is the first description of an ABB},
    sort = {1},
    parent = abb,
    text = {abb},
    long = {abbreviation-one},
    first = {\glsentrylong{abbone} (\glsentrytext{abbone})}
}

\newglossaryentry{abbtwo} {
    description = {there is a second different description of ABB, too},
    sort = {2},
    parent = abb,
    text = {abb},
    long = {abbreviation-two},
    first = {\glsentrylong{abbtwo} (\glsentrytext{abbtwo})}
}
\begin{document}

\printglossaries

\noindent
There is \gls{abbone}, but also \gls{abbtwo}.\\

\end{document}

1 Answer 1

2

Your style only adjusts the behaviour of the top-level (level 0) entries. You also need to adjust the formatting of the sub-entries. The top-level entries are governed by \glossentry, which in your MWE is defined as:

  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\Glossentryname{##1}}]
                    \mbox{}\par\nobreak
       \glossentrydesc{##1}\glspostdescription\hfill ##2}%

This is inserting a paragraph break before the description, but you don't have a description for your top-level entry abb, so you get a paragraph break followed by an empty description followed by another paragraph break, which is causing the extra vertical space.

Sub-entries are formatted according to \subglossentry. Since you haven't redefined this, it's using the definition set by the altlist style, which is:

  \renewcommand{\subglossentry}[3]{%
    \par
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription\space ##3}%

Since this is using \glossentrydesc, no case-change is applied to the description.

The following adjustment to your MWE fixes these problems:

\documentclass{article}

\usepackage{glossaries}

%make a new glossaries style
\newglossarystyle{altlistnumbers}{%
    \setglossarystyle{altlist}%
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\Glossentryname{##1}}]
                    \mbox{}\par\nobreak}%
  \renewcommand{\subglossentry}[3]{%
    \par
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}\Glossentrydesc{##2}\glspostdescription\space
##3}%
}

\setglossarystyle{altlistnumbers}
\makeglossaries

\newglossaryentry{abb} {
    name = {abb},
    description = {\nopostdesc},
}

\newglossaryentry{abbone} {
    description = {this is the first description of an ABB},
    sort = {1},
    parent = abb,
    text = {abb},
    long = {abbreviation-one},
    first = {\glsentrylong{abbone} (\glsentrytext{abbone})}
}

\newglossaryentry{abbtwo} {
    description = {there is a second different description of ABB, too},
    sort = {2},
    parent = abb,
    text = {abb},
    long = {abbreviation-two},
    first = {\glsentrylong{abbtwo} (\glsentrytext{abbtwo})}
}
\begin{document}

\printglossaries

\noindent
There is \gls{abbone}, but also \gls{abbtwo}.

\end{document}

This produces:

Image of glossary

Note that this has removed the description and location lists for all top-level entries. If you want the location list to appear, just add ##2 back into the definition of \glossentry.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.