glossaries package FAQ
Page break occurs after a group title 🔗
The base glossaries package provides fairly simple glossary styles. With these it is possible for page breaks to occur after group headings.
If you are using the glossaries-extra extension then make sure you use the glossaries-extra-stylemods package identifying the style package (or packages) that needs patching. The simplest way of doing this is to use the stylemods
package option.
The following test document uses the testidx package to generate a dummy document:
\documentclass{article} \usepackage[a4paper,margin=1in]{geometry} \usepackage[T1]{fontenc} \usepackage{glossaries} \usepackage{glossary-mcols}% provides the 'mcol' styles \usepackage[notestencaps,ascii]{testidx-glossaries} \tstidxmakegloss % uses \makeglossaries and loads definition files \begin{document} \tstidxprintglossary[style=mcolindexgroup] \testidx \end{document}This demonstrates the problem with the
mcolindexgroup
style when just using the base glossaries package. There's a page break between the title for the “G“ group and the first item in that group. Similarly for the “L” and “V” letter groups.
Switching to the glossaries-extra package and using the glossaries-extra-stylemods package to patch the styles provided by the base package solves the problem:
\documentclass{article} \usepackage[a4paper,margin=1in]{geometry} \usepackage[T1]{fontenc} \usepackage[stylemods=mcols]{glossaries-extra} \usepackage[notestencaps,ascii]{testidx-glossaries} \tstidxmakegloss \begin{document} \tstidxprintglossary[style=mcolindexgroup] \testidx \end{document}Note that the style package must be either loaded through the glossaries-extra-stylemods package or loaded before glossaries-extra-stylemods. For example, any of the following will work: Loading implicitly through the
stylemods
option:
\usepackage[stylemods=mcols]{glossaries-extra}Loading the glossaries-extra-stylemods package explicitly and identifying any supplementary style packages that need to be loaded:
\usepackage{glossaries-extra} \usepackage[mcols]{glossaries-extra-stylemods}Loading the required style package before loading glossaries-extra-stylemods:
\usepackage{glossaries-extra} \usepackage{glossary-mcols} \usepackage{glossaries-extra-stylemods}The base glossaries package automatically loads the long, super, list and tree style packages. If these are the only styles you require then you can simply do:
\usepackage[stylemods]{glossaries-extra}If you want to prevent any unnecessary style packages from being loaded and only load required ones, then use
nostyles
in combination with stylemods
. For example:
\usepackage[nostyles,stylemods={mcols,longextra}]{glossaries-extra}Any styles loaded after glossaries-extra-stylemods won't be patched. If you don't want to switch to the extension package but prefer to stick with just the base package, then you can provide your own patch. For example, to patch the
treegroup
style (which will affect any style that uses it, such as mcoltreegroup
):
\renewglossarystyle{treegroup}{% \setglossarystyle{tree}% \renewcommand{\glsgroupheading}[1]{\par \noindent\glstreegroupheaderfmt{\glsgetgrouptitle{##1}}\par \nopagebreak\indexspace\nobreak\@afterheader}% }If you patch a style remember to remove the patch if you switch over to glossaries-extra and glossaries-extra-stylemods otherwise you'll lose the benefit of the style modifications provided by the extension package.
2020-02-07 14:36:29
Permalink: https://www.dickimaw-books.com/faq.php?id=234
Alternative link: https://www.dickimaw-books.com/faq.php?itemlabel=glsnogroupbreak
Category: glossaries package
Topic:
Unexpected Output in the Glossaries