summaryrefslogtreecommitdiff
path: root/support/bib2gls/examples/sample-nested.tex
blob: fc6b540706c3e1f8f08a565517b350fd2d0a09d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

\documentclass[12pt,a4paper]{article}

\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}

\usepackage[record,% use bib2gls
 nostyles,% don't load default styles
 postdot,% add a full stop after the description
% load glossary-tree.sty and patch styles:
 stylemods={tree},
 style=treegroup]{glossaries-extra}

\GlsXtrLoadResources[src={terms},sort={en-reverse}]

\GlsXtrLoadResources[
  src={animals,minerals,vegetables},
  field-aliases={identifier=type},
  dependency-fields=type,
  sort={en}
]

\newcommand{\nestedhandler}[1]{%
  \glsxtrunsrtdo{#1}%
% Is there a glossary whose label (type) matches this entry's label?
  \ifglossaryexists*{#1}%
  {%
    \printunsrtinnerglossary[type={#1},leveloffset=++1,groups=false]{}{}%
  }%
  {}%
}

\begin{document}
Some sample terms: \gls{duck}, \gls{sealion}, \gls{armadillo},
\gls{seal}, \gls{aardvark}, \gls{amethyst}, \gls{aquamarine},
\gls{diamond}, \gls{dolomite}, \gls{chalcedony}, \gls{citrine},
\gls{quetzalcoatlite}, \gls{cabbage}, \gls{cauliflower},
\gls{artichoke}, \gls{courgette}.

\GlsXtrSetDefaultNumberFormat{glsignore}% ignore records in the glossary

\printunsrtglossary*{%
  \let\printunsrtglossaryhandler\nestedhandler
}

\end{document}