Debian Codegraph @

texmf-dist/doc/support/bib2gls/examples/sample-nested.tex

raw
1 % This file is public domain. See the "Examples" chapter
2 % in the bib2gls user manual for a more detailed description
3 % of this file.
4
5 \documentclass[12pt,a4paper]{article}
6
7 \usepackage[T1]{fontenc}
8 \usepackage[colorlinks]{hyperref}
9
10 \usepackage[record,% use bib2gls
11 nostyles,% don't load default styles
12 postdot,% add a full stop after the description
13 % load glossary-tree.sty and patch styles:
14 stylemods={tree},
15 style=treegroup]{glossaries-extra}
16
17 \GlsXtrLoadResources[src={terms},sort={en-reverse}]
18
19 \GlsXtrLoadResources[
20 src={animals,minerals,vegetables},
21 field-aliases={identifier=type},
22 dependency-fields=type,
23 sort={en}
24 ]
25
26 \newcommand{\nestedhandler}[1]{%
27 \glsxtrunsrtdo{#1}%
28 % Is there a glossary whose label (type) matches this entry's label?
29 \ifglossaryexists*{#1}%
30 {%
31 \printunsrtinnerglossary[type={#1},leveloffset=++1,groups=false]{}{}%
32 }%
33 {}%
34 }
35
36 \begin{document}
37 Some sample terms: \gls{duck}, \gls{sealion}, \gls{armadillo},
38 \gls{seal}, \gls{aardvark}, \gls{amethyst}, \gls{aquamarine},
39 \gls{diamond}, \gls{dolomite}, \gls{chalcedony}, \gls{citrine},
40 \gls{quetzalcoatlite}, \gls{cabbage}, \gls{cauliflower},
41 \gls{artichoke}, \gls{courgette}.
42
43 \GlsXtrSetDefaultNumberFormat{glsignore}% ignore records in the glossary
44
45 \printunsrtglossary*{%
46 \let\printunsrtglossaryhandler\nestedhandler
47 }
48
49 \end{document}