LaTeX forum ⇒ MakeIndex, Nomenclature, Glossaries and AcronymsHow to keep the group heading in glossaries with the first entry in the group?

Information and discussion about MakeIndex - the tool to generate subject indices for LaTeX documents.
eezacque
Posts: 7
Joined: Mon Jan 06, 2020 5:47 pm

How to keep the group heading in glossaries with the first entry in the group?

Postby eezacque » Sat Feb 01, 2020 12:22 pm

In a document with glossaries set in multicols, it often happens that the heading of a group, say 'A', ends up on the bottom of a column, while the first member of the group, say 'Albert', sits at the top of the next column. Is there any remedy?

An example:
\documentclass{article}

\usepackage[a4paper, textheight=5in]{geometry}
\usepackage{multicol}
\usepackage[automake,xindy]{glossaries}

\newglossary[wrg]{glos}{wrd}{wrn}{Glossary}

\newglossaryentry{A}{name=A,description=A}
\newglossaryentry{B}{name=B,description=B}
\newglossaryentry{C}{name=C,description=C}
\newglossaryentry{D}{name=D,description=D}
\newglossaryentry{E}{name=E,description=E}
\newglossaryentry{F}{name=F,description=F}
\newglossaryentry{G}{name=G,description=G}
\newglossaryentry{H}{name=H,description=H}
\newglossaryentry{I}{name=I,description=I}
\newglossaryentry{J}{name=J,description=J}
\newglossaryentry{K}{name=K,description=K}
\newglossaryentry{L}{name=L,description=L}
\newglossaryentry{M}{name=M,description=M}
\newglossaryentry{N}{name=N,description=N}
\newglossaryentry{O}{name=O,description=O}
\newglossaryentry{P}{name=P,description=P}
\newglossaryentry{Q}{name=Q,description=Q}
\newglossaryentry{R}{name=R,description=R}
\newglossaryentry{S}{name=S,description=S}
\newglossaryentry{T}{name=T,description=T}
\newglossaryentry{U}{name=U,description=U}
\newglossaryentry{V}{name=V,description=V}
\newglossaryentry{W}{name=W,description=W}
\newglossaryentry{X}{name=X,description=X}
\newglossaryentry{Y}{name=Y,description=Y}
\newglossaryentry{Z}{name=Z,description=Z}



\makeglossaries

\begin{document}

\glsaddall


\begin{multicols}{2}

\printglossary[style=indexgroup]

\end{multicols}

\end{document}

Recommended reading 2021:

LaTeXguide.org • LaTeX-Cookbook.net
LaTeX Beginner's Guide LaTeX Cookbook
eezacque
Posts: 7
Joined: Mon Jan 06, 2020 5:47 pm

How to keep the group heading in glossaries with the first entry in the group?

Postby eezacque » Thu Feb 06, 2020 10:43 pm

Ulrike Fischer sorted this out at usenet group comp.text.tex:

\makeatletter \newcommand\indexheaderspace{\par\nopagebreak\vskip 10\p@
\@plus 5\p@ \@minus 3\p@ \relax\@afterheading}
\makeatother \renewglossarystyle{indexgroup}{%
  \setglossarystyle{index}% 
  \renewcommand*{\glsgroupheading}[1]{%
    \item \glstreegroupheaderfmt{\glsgetgrouptitle{##1}}%
    \indexheaderspace
  }%
}


Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”

Who is online

Users browsing this forum: No registered users and 2 guests