Debian Codegraph @

texmf-dist/doc/support/bib2gls/examples/sample-units3.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]{report}
6
7 \usepackage{siunitx}
8 \usepackage[record,% use bib2gls
9 nostyles,% don't load default styles
10 % load glossary-tree.sty and glossary-longbooktabs.sty and patch:
11 stylemods={tree,longbooktabs},
12 style=alttree]{glossaries-extra}
13
14 \newglossary*{units}{Units of Measurement (by SI unit)}
15
16 \GlsXtrLoadResources[
17 % data in baseunits.bib and derivedunits.bib:
18 src={baseunits,derivedunits},
19 field-aliases={
20 unitname=name,
21 unitsymbol=symbol,
22 measurement=description
23 },
24 symbol-sort-fallback={name},
25 selection=all,% select all entries
26 % make @measurement and @unit act like @dualsymbol:
27 entry-type-aliases={
28 measurement=dualsymbol,
29 unit=dualsymbol,
30 },
31 set-widest,% needed for alttree style
32 dual-sort={letternumber-upperlower},
33 type=main,% put primary entries in 'main' glossary
34 dual-type={units}% put dual entries in 'units' glossary
35 ]
36
37 \setlength{\glsdescwidth}{.4\hsize}
38
39 % define custom glossary style
40 \newglossarystyle{units}% style name
41 {% base it on long3col-booktabs
42 \setglossarystyle{long3col-booktabs}%
43 \renewcommand*{\glossaryheader}{%
44 \toprule
45 \bfseries Name &
46 \bfseries Measurement &
47 \bfseries Symbol
48 \tabularnewline\midrule\endhead
49 \bottomrule\endfoot}%
50 % main entries:
51 \renewcommand{\glossentry}[2]{%
52 \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
53 \glossentrydesc{##1}\glspostdescription &
54 \glossentrysymbol{##1}\tabularnewline
55 }%
56 }
57
58 \begin{document}
59
60 \printunsrtglossary[title={SI Units of Measurement},
61 style={units}]
62
63 \printunsrtglossary[type=units]
64
65 \end{document}