[Tex/LaTex] Custom glossary style, \makenoidxglossaries and \glsgroupskip

glossaries

The code below creates a glossary table containing acronyms, their representation in math expressions and their description. A custom glossary style my is created using \newglossarystyle. It is a table with a \tabularnewline between every entry group, as set by redefining \glsgroupskip. However, the code produces a new line between every entry, not just the groups. By default, groups are based on the first letter of an entry, e.g. ‘bar’ and ‘baz’ should be in a group and ‘foo’ and ‘qux’ are separately grouped.

The default style (i.e. disable the line \setglossarystyle{my}) does create groups with extra separation between them. Why/where does my style fail?

Note that I use ‘Option 1’ as defined in the glossaries package manual, i.e. \makenoidxglossaries.

\documentclass{article}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{tabu}
\usepackage[shortcuts]{glossaries}
\makenoidxglossaries

\glsaddkey{math}{}{\acem}{\Acem}{\acm}{\Acm}{\ACm}

\newacronym[math=\mathfrak{foo}]{foo}{foo}{Foo}
\newacronym[math=\mathfrak{bar}]{bar}{bar}{Bar}
\newacronym[math=\mathfrak{baz}]{baz}{baz}{Baz}
\newacronym[math=\mathfrak{qux}]{qux}{qux}{Qux}

\newglossarystyle{my}{%
    % redefine theglossary environment
    \renewenvironment{theglossary}%
    % begin
    {\begin{longtabu} spread 0pt {@{}X[1Lm]X[1Lm]X[3Jm]@{}}}%
    % end
    {\bottomrule
    \end{longtabu}}%
    \renewcommand*{\glossaryheader}{%
        \toprule%
        Abbreviation & Symbol in Mathematical Expressions & Description \\ \midrule%
    }%
    \renewcommand*{\glsgroupskip}{%
        \tabularnewline%
    }%
    \renewcommand*{\glossentry}[2]{%
        \glstarget{##1}{\glossentryname{##1}}%
        &%
        $\acem{##1}$%
        &%
        \glossentrydesc{##1}%
        \\%
    }%
}

\setglossarystyle{my}

\begin{document}
\glsaddallunused
\printnoidxglossaries
\end{document}

Best Answer

It seems that grouping does not work properly with tabular styles with glossary-creation 'Option 1'. If you use \makeglossaries with the makeglossaries script, it works fine. Or, if you use a list style, it works fine. I am not sure if this is a bug or a recognised limitation.

Here is an example with the makeglossaries script:

\documentclass{article}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage[shortcuts]{glossaries}
\makeglossaries

\glsaddkey{math}{}{\acem}{\Acem}{\acm}{\Acm}{\ACm}

\newacronym[math=\mathfrak{foo}]{foo}{foo}{Foo}
\newacronym[math=\mathfrak{bar}]{bar}{bar}{Bar}
\newacronym[math=\mathfrak{baz}]{baz}{baz}{Baz}
\newacronym[math=\mathfrak{qux}]{qux}{qux}{Qux}

\newglossarystyle{my}{%
  \setglossarystyle{long3colheader}%
  \renewcommand*{\glossaryheader}{%
    \toprule
    Abbreviation & Symbol in Mathematical Expressions & Description \tabularnewline\midrule\endhead
    \bottomrule\endfoot
  }%
  \renewcommand*{\glsgroupskip}{%
     & &\tabularnewline}%
  \setlength\glsdescwidth{.275\textwidth}%
  \setlength\glspagelistwidth{.45\textwidth}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} & $\acem{##1}$ & \glossentrydesc{##1}\tabularnewline
  }%
}

\setglossarystyle{my}

\begin{document}
  \glsaddallunused
  \printglossaries
\end{document}

grouped entries in tabular

This was compiled with

pdflatex <filename>
makeglossaries <filename>
pdflatex <filename>

The problem with using \makenoidxglossaries etc. is not that the group skip is ignored. It is that glossaries erroneously believes that every entry starts a new group.

Here's an example using a standard style which demonstrates that it is not your particular definition of my which causes the problem:

\documentclass{article}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage[shortcuts]{glossaries}
\makenoidxglossaries

\glsaddkey{math}{}{\acem}{\Acem}{\acm}{\Acm}{\ACm}

\newacronym[math=\mathfrak{foo}]{foo}{foo}{Foo}
\newacronym[math=\mathfrak{bar}]{bar}{bar}{Bar}
\newacronym[math=\mathfrak{baz}]{baz}{baz}{Baz}
\newacronym[math=\mathfrak{qux}]{qux}{qux}{Qux}

\setglossarystyle{long3colheader}
\renewcommand*\glsgroupskip{%
  X & X & X\tabularnewline}

\begin{document}
  \glsaddallunused
  \printnoidxglossaries
\end{document}

too many glossary groups

If \makeglossaries and \printglossaries are used instead, the grouping is correct:

correct grouping

Alternatively, if \makenoidxglossaries and \printnoidxglossaries are used with the default (list) style and

\renewcommand*\glsgroupskip{%
  \item XXX}

then the grouping is also correct:

correct grouping with list

Related Question