3

I use some glossaries, one in the main matter of my text, other in the back matter of my document. I applied to the first a homemade style with hierarchical entries & subentries (cf. MWE). I would trait differently both glossaries, but I'm exposed to the following difficulties:

When I decided to set a configuration in the announcement of the package, I don't know how to change. I want \usepackage[numberedsection=autolabel]{glossaries} for the first glossary, \usepackage[section,numberedsection=nameref]{glossaries} for the other.

Secondly, I want to number my hierarchical sub-entries like sections, subsections or subsubsections, and appear in toc and headings. But, if I try my own glossary style with an unstarred sectioning, compilation doesn't work.

% !TEX encoding = UTF-8 Unicode 
% !TEX TS-program = arara
\documentclass{scrbook} 
\usepackage[xindy={language=french, codepage=utf8}]{glossaries}
\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossarystyle{arbre}{%
\renewenvironment{theglossary}{\tablehead{}\begin{description}}{\end{description}\tabletail{}}%
\renewcommand{\glossaryheader}{}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand*{\glossentry}[2]{\section*{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}% I want unscarred this \section
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}}

\newglossaryentry{section}{type=est,name=section,description={\nopostdesc}}
\newglossaryentry{subsection}{type=est,name=subsection,parent=section,description={\nopostdesc}}
\newglossaryentry{subsubsection}{type=est,name=subsubsection,parent=subsection,description={\nopostdesc}}
\newglossaryentry{glouglou}{type=est,name=glouglou,parent=subsubsection,description={dindon}}
\newglossaryentry{coincoin}{type=his,name=coincoin,description={canard}}

\newcommand\est[5]{
\newglossaryentry{#1}{type=est,name=#1,description={\nopostdesc}}% 
\newglossaryentry{#2}{type=est,name=#2,parent=#1,description={\nopostdesc}}%
\newglossaryentry{#3}{type=est,name=#3,parent=#2,description={\nopostdesc}}% 
\newglossaryentry{#4}{type=est,name=#4,parent=#3,description={#5}}%
\gls{#4}, #5}%

\begin{document}
\est{section}{subsection}{subsubsection}{coco}{ara}, \gls{coincoin}, \gls{glouglou}.
\printglossary[type=est,style=arbre] 
% and now usepackage[section,numberedsection=nameref]{glossaries}
\printglossary[type=his]
\end{document}
% arara: xelatex
% arara: makeglossaries
% arara: xelatex

Thanks for your help. (This question is the continuation of Glossaries with more hierarchical categories)

2

You can use \setupglossaries to modify some (but not all) of the settings that can be used in the package options. Fortunately the settings you want adjusted may be changed in the document. First with

\setupglossaries{numberedsection=autolabel}

and then with

\setupglossaries{section,numberedsection=nameref}

Modified MWE:

\documentclass{scrbook} 
\usepackage[xindy={language=french, codepage=utf8}]{glossaries}
\newglossary*{his}{History}
\newglossary*{est}{Esthetic}
\makeglossaries

\newglossarystyle{arbre}{%
\renewenvironment{theglossary}{\tablehead{}\begin{description}}{\end{description}\tabletail{}}%
\renewcommand{\glossaryheader}{}%
\renewcommand*{\glsgroupskip}{}%
\renewcommand*{\glossentry}[2]{\section*{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}% I want unscarred this \section
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection*{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}}

\newglossaryentry{section}{type=est,name=section,description={\nopostdesc}}
\newglossaryentry{subsection}{type=est,name=subsection,parent=section,description={\nopostdesc}}
\newglossaryentry{subsubsection}{type=est,name=subsubsection,parent=subsection,description={\nopostdesc}}
\newglossaryentry{glouglou}{type=est,name=glouglou,parent=subsubsection,description={dindon}}
\newglossaryentry{coincoin}{type=his,name=coincoin,description={canard}}

\newcommand\est[5]{
\newglossaryentry{#1}{type=est,name=#1,description={\nopostdesc}}% 
\newglossaryentry{#2}{type=est,name=#2,parent=#1,description={\nopostdesc}}%
\newglossaryentry{#3}{type=est,name=#3,parent=#2,description={\nopostdesc}}% 
\newglossaryentry{#4}{type=est,name=#4,parent=#3,description={#5}}%
\gls{#4}, #5}%

\begin{document}
\setupglossaries{numberedsection=autolabel}
\est{section}{subsection}{subsubsection}{coco}{ara}, \gls{coincoin}, \gls{glouglou}.
\printglossary[type=est,style=arbre] 
\setupglossaries{section,numberedsection=nameref}
\printglossary[type=his]
\end{document}

Edit: for numbered sections in the glossary style, you'll need to use the optional argument of \section to overcome expansion problems and other unwanted stuff getting into the .toc file:

\renewcommand*{\glossentry}[2]{\section[\glsentryname{##1}]{\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}}}
\renewcommand{\subglossentry}[3]{%
\ifnum##1=1\relax\subsection[\glsentryname{##2}]{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=2\relax\subsubsection[\glsentryname{##2}]{\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}}\fi% idem
\ifnum##1=3\relax\item[\glssubentryitem{##2}\glstarget{##2}{\glossentryname{##2}}] \space\glossentrydesc{##2}\glspostdescription\space ##3\fi}
  • You are always my hero. I can't help but put two or three questions per article… sorry. What about the second question? Should I open another page & republish it (for ease)? Because this title matches more with my second question :s – Zouib Jul 1 '16 at 18:23
  • @Zouib sorry, I missed that. I've edited my answer. – Nicola Talbot Jul 1 '16 at 18:37
  • Great ! It run for \section, not for \subsection or \subsubsection. I still try tomorrow. – Zouib Jul 1 '16 at 23:58
  • @Zouib Sorry, I forgot to add the edits to \subglossentry. I've updated my answer. – Nicola Talbot Jul 2 '16 at 8:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.