2

I am experimenting with the pre-defined glossary style in the glossaries package. The tree style looks great and seems flexible, but I would like the left edge of all the glossary entries to line up vertically down the page. As far as I can tell, that is what the alttree style is for.

But when I use alttree, the glossary entry name and description overlap. Is that expected behavior? I suspect that \glstreeindent is not indenting properly. If it is expected behavior, what am I doing wrong?

MWE:

\documentclass[11pt]{article}%

\usepackage[style=alttree]{glossaries}
\makeglossaries

\newglossaryentry{gls1}{name={gls1},description={description for gls1}}
\newglossaryentry{gls2}{name={gls2},description={description for gls2}}
\newglossaryentry{gls3}{name={gls3longname},description={description for gls3}}

\glsaddall
\begin{document}
\printglossaries
\end{document}

I have tried modifying the alttree style to add \hangindent\glstreeindent after the line \ifnum\@gls@prevlevel=0 (as per mfap's answer to this Two column glossary question) but there is no change in output.

(Tried to tag with [alttree] and [tree] but I don't have permissions yet.)

1 Answer 1

2

To set width manually: use \glssetwidest{} in the preamble. This command takes one argument and sets the name box width to the width of that argument.

To semi-automatically determine width: use \glsfindwidesttoplevelname in the preamble. This iterates over all glossaries (using \forallglossaries) and finds the widest parentless glossary entry name.

It can take an optional argument which is a list of glossary names to iterate over. For instance, \glsfindwidesttoplevelname[main,acronym] will find the widest parentless glossary entry name in the acronym and main glossaries only.

3
  • You can iterate through the gls entries with \forglsentries in order to determine the widest entry (see the glossaries documentation about \forglsentries
    – user31729
    Commented Apr 12, 2017 at 16:03
  • Thanks, @ChristianHupfer. I had trouble using \forglsentries in this fashion, but it looks like \glsfindwidesttoplevelname basically does this anyway. Just what I needed. Do you want to make your suggestion and/or \glsfindwidesttoplovelname an answer? It is exactly what I was looking for with my question. Commented Apr 17, 2017 at 18:17
  • No, keep your answer or add your findings to it.
    – user31729
    Commented Apr 17, 2017 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .