[Tex/LaTex] Glossaries with more hierarchical categories

glossaries

I use a lot of classic glossaries in my work: main, acronyms, abbreviations… I also use more complex glossaries for linguistic studies, with hierarchical categories. I know how to build glossaries with subentries but not with sub-subentries. I want to learn to build that: entry=subsection, subentry=subsubsection, subsubentry=glossary entry and description.

Here my code:

% !TEX encoding = UTF-8 Unicode 
% !TEX TS-program = arara
\documentclass{scrbook} 
\usepackage[xindy={language=french, codepage=utf8},section]{glossaries}

\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossarystyle{subgroup}{%
\renewenvironment{theglossary}{\tablehead{}\begin{description}}{\end{description}\tabletail{}}%
\renewcommand{\glossaryheader}{}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand*{\glossentry}[2]{\subsection*{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}%
\renewcommand{\subglossentry}[3]{\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3}}

% \newglossarystyle{subsubgroup}{% yours ideas, thanks}

\newglossaryentry{niveau1}{type=est,name=niveau1,description={\nopostdesc}}
\newglossaryentry{niveau2}{type=est,name=niveau2,parent=niveau1,description={\nopostdesc}}
\newglossaryentry{glossaire}{type=est,name=glossaire,parent=niveau2,description={C'est un glossaire et un bon}}

\newglossaryentry{level1}{type=his,name=level1,description={\nopostdesc}}
\newglossaryentry{glossary}{type=his,name=glossary,parent=level1,description={This is a glossary \&  a good one}}

\begin{document}
\gls{glossary} \gls{glossaire}
\printglossary[type=est,style=subgroup]% to test with the style=subsubgroup
\printglossary[type=his,style=subgroup]
\tableofcontents
\end{document}
% arara: xelatex
% arara: makeglossaries
% arara: xelatex

Thanks!

Best Answer

Table 15.1 in the glossaries user manual shows which of the predefined styles support hierarchical entries. You need to find one which has at least 2 or — (unlimited) in the maximum level column.

The glossaries gallery of predefined styles shows samples of all the available styles. Those provided by the glossary-tree and glossary-mcols packages are the best suited to hierarchical entries. I recommend either the tree or mcoltree styles, depending one whether you want to use the multicol package.

If you want to define your own custom style, the first argument of \subglossentry is a number that indicates the sub-level. Many of the predefined styles ignore this value, resulting in either a flat glossary or a maximum of one sub-level. The tree styles use this argument to determine the indent.

Example:

\documentclass{scrbook}
\usepackage[xindy={language=french, codepage=utf8},section]{glossaries}

\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossaryentry{niveau1}{type=est,name=niveau1,description={\nopostdesc}}
\newglossaryentry{niveau2}{type=est,name=niveau2,parent=niveau1,description={\nopostdesc}}
\newglossaryentry{glossaire}{type=est,name=glossaire,parent=niveau2,description={C'est un glossaire et un bon}}

\newglossaryentry{level1}{type=his,name=level1,description={\nopostdesc}}
\newglossaryentry{glossary}{type=his,name=glossary,parent=level1,description={This is a glossary \&  a good one}}

\begin{document}
\gls{glossary} \gls{glossaire}
\printglossary[type=est,style=tree]% to test with the style=subsubgroup
\printglossary[type=his,style=tree]
\tableofcontents
\end{document}

Produces:

image of document

Related Question