summaryrefslogtreecommitdiff
path: root/support/bib2gls/examples/sample-constants.tex
blob: 7758b419d3599d01d24370a31c8432fb90b196a8 (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
50
51
52
53
54
55
56
57
% 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{upgreek}

\usepackage[record,% use bib2gls
 nostyles,% don't load default styles
 postdot,% add dot after descriptions
% load glossary-tree.sty and patch styles:
 stylemods={tree},
 style=alttree]{glossaries-extra}

\GlsXtrLoadResources[
  src={constants},% data in constants.bib
  % make @constant behave like @number
  entry-type-aliases={constant=number},
  field-aliases={
    identifier=category,
    constantsymbol=name,
    constantname=description,
    value=user1,
    definition=user2,
    alternative=user3
  },
  type=main,
  set-widest,
  sort-field=user1,
  missing-sort-fallback=name,
  sort=double,
  selection=all
]

\newcommand{\glsxtrpostdescconstant}{%
  \glsxtrifhasfield{useriii}{\glscurrententrylabel}%
  { (also denoted \glscurrentfieldvalue
      \glsxtrifhasfield{useri}{\glscurrententrylabel}%
      {, approximately \glscurrentfieldvalue}%
      {}%
   )%
  }%
  {%
    \glsxtrifhasfield{useri}{\glscurrententrylabel}%
    { (approximately \glscurrentfieldvalue)}%
    {}%
  }%
  \glsxtrifhasfield{userii}{\glscurrententrylabel}%
  {: \glscurrentfieldvalue}%
  {}%
}

\begin{document}
\printunsrtglossary[title={Constants}]
\end{document}