3

In glossaries, using the option listhypergroup, there is a problem when the list of letters is too long and the page too narrow: as it does not fold, it goes over the page width to give

Is there a fix for this issue ?

\documentclass{article}
\usepackage[left = 8cm, right = 8cm, showframe]{geometry}
\usepackage{hyperref}
\usepackage[nogroupskip]{glossaries}

\newglossaryentry{Almond}{ name=Almond,  description={A fruit},
  sort={Almond}  }
\newglossaryentry{Berry}{ name=Berry,  description={Another fruit},
  sort={Berry}  }
\newglossaryentry{Cherry}{ name={Cherry},  description={Yet another fruit},
  sort={Cherry}  }
\newglossaryentry{Date}{ name={Date},  description={Yet another fruit},
  sort={Date}  }
\newglossaryentry{Elderberry}{ name={Elderberry},  description={Yet another fruit},
sort={Elderberry}  }
  \newglossaryentry{Flour}{ name={Flour},  description={Not a fruit but useful for cakes}, sort={Flour}}
\newglossaryentry{Grenade}{ name={Grenade},  description={Only the one that does not blow up is a fruit},  sort={Grenade}  }
\newglossaryentry{Hammer}{ name={Hammer},  description={Definitely not a fruit},  sort={Hammer}  }


\newglossaryentry{Tomato}{ name={Tomato},  description={Again another fruit},
  sort={Tomato}  }
\newglossaryentry{Strawberry}{ name={Strawberry},  description={Not a fruit},
  sort={Strawberry}  }
\newglossaryentry{Walnut}{ name={Walnut},  description={Shell fruit},
  sort={Walnut}  }


\makenoidxglossaries

\begin{document}
\gls{Almond}, \gls{Berry}, \gls{Cherry}, \gls{Elderberry}, \gls{Grenade}, \gls{Walnut} and \gls{Tomato} are fruits, unlike \gls{Strawberry}, \gls{Hammer} and \gls{Flour}.

%\renewcommand{\glssymbolsgroupname}{Non-fruits}
\printnoidxglossary[sort=standard,style=listhypergroup]
\end{document}
HcN
  • 1,274
  • 9
  • 25

1 Answers1

3

The reason the navigation line is not breaking is that (for some reason) it is typeset within a description environment and the code is:

\item[<navigation line>]

I don't know why that is, but it turns out it can be easily fixed as the navigation line is set through the \glossaryheader command. The only trick here is that since we are in a description environment, we want to avoid having the indentation that is associated with this environment, hence why I surround the navigation line in a \parbox in the solution below.

\documentclass{article}
\usepackage[
  hmargin=8cm,
  showframe
]{geometry}
\usepackage{hyperref}
\usepackage[
  style=listhypergroup,
]{glossaries}
\renewcommand{\glossaryheader}{\item \parbox{0.9\textwidth}{\glsnavigation}}

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

\makeglossaries

\begin{document}
\glsaddall
\printglossary
\end{document}

output

Lastly, if you want to replace the | separator with something else, you have to redefine \glshypernavsep:

\renewcommand*{\glshypernavsep}{\space}
JP-Ellis
  • 8,929
  • 2
  • 33
  • 49
  • Thanks a lot. Unfortunalty, while this work in the MWE, it does not in my large document for a reason I failed to identify. In this document, I define other glossaries using \altnewglossary{symbolsroman}{cnt}{Symbols (latin)}, still using the listhypergroup style. Is it the same \glossaryheader function in this case ? If it is, I think I will stick to the listgroup style until I find out the reason for this. – HcN Feb 27 '16 at 15:36
  • @HcN This would be because \glossaryheader gets redefined whenever you change style. Perhaps try redefining \glossaryheader just before your \printglossary command? – JP-Ellis Feb 27 '16 at 15:38
  • I get cryptic error messages (such as Illegal parameter number in definition of \GetTitleStringResult.) if I remove the style=listhypergroup option from \printglossary, even if I define it globally when loading the package. I do not understand what is going on, so I am obliged to keep it this way, and is certainly the reason why It does not work in my case. – HcN Feb 27 '16 at 15:49
  • 1
    Without being able to reproduce the error, it'll be hard for me to tell you what's going on. Perhaps post another question with this new problem? Curiously, are you also implementing my answer for your other question? Because it is possible that it only works this listhypergroup and not others (though I have not tested this). – JP-Ellis Feb 27 '16 at 15:58