summaryrefslogtreecommitdiff
path: root/support/bib2gls/examples/sample-people.tex
blob: 289e7a2d203b3bcc18ea07d9cc782065270316bc (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
% 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]{report}

\usepackage[colorlinks]{hyperref}
\usepackage[record,% using bib2gls
 index,% create index glossary
 postdot,% dot after descriptions
% load glossary-list.sty and glossary-bookindex.sty and patch:
 stylemods={list,bookindex},
 style=altlistgroup]{glossaries-extra}

\newglossary*{bybirth}{People (Ordered by Birth)}

\newcommand{\bibglsdategroup}[7]{#1#4#7}
\newcommand{\bibglsdategrouptitle}[7]{\number#1\ #4}

\newcommand*{\swaptwo}[2]{#2, #1}
\newcommand*{\swapthree}[3]{#2 #3, #1}

\GlsXtrLoadResources[
  src=no-interpret-preamble,
  interpret-preamble=false
]

\GlsXtrLoadResources[
  src={interpret-preamble,people},
  match={entrytype=entry},
  category={people},
  replicate-fields={name={first}},
  field-aliases={born=user1,died=user2,othername=user3},
  secondary={date:user1:bybirth},
  secondary-date-sort-format={d MMM YYYY G}
]

\GlsXtrLoadResources[
  src={people},
  type=index,
  category=people,
  action={define or copy},
  copy-action-group-field={indexgroup},
  selection={recorded and deps and see}
]

\newcommand*{\glsxtrpostlinkpeople}{%
 \glsxtrifwasfirstuse
 {%
   \ifglshasfield{user3}{\glslabel}%
   {\space(\glscurrentfieldvalue)}%
   {}%
 }%
 {}%
}

\newcommand*{\glsxtrpostnamepeople}{%
 \ifglshasfield{user3}{\glscurrententrylabel}%
 {\space(\glscurrentfieldvalue)}%
 {}%
}

\newcommand*{\glsxtrpostdescpeople}{%
 \ifglshasfield{user1}{\glscurrententrylabel}
 {% born
   \space(\glscurrentfieldvalue\,--\,%
     \ifglshasfield{user2}{\glscurrententrylabel}
     {% died
        \glscurrentfieldvalue
     }%
     {}%
   )%
 }%
 {}%
}

\begin{document}
\chapter{Sample}
\section{First Use}

\gls{caesar}, \gls{wellesley}, \gls{bonaparte}, 
\gls{vonrichthofen} and \gls{alexander}.

\section{Next Use}

\gls{caesar}, \gls{wellesley}, \gls{bonaparte}, 
\gls{vonrichthofen} and \gls{alexander}.

\printunsrtglossary[title={People (Alphabetical)},nonumberlist]

\printunsrtglossary[type=bybirth,target=false,nonumberlist]

\printunsrtglossary*
 [type=index,style=bookindex]
 {%
   \let\sortname\swaptwo
   \let\sortart\swaptwo
   \let\sortvonname\swapthree
   \renewcommand{\glsxtrgroupfield}{indexgroup}%
   \renewcommand*{\glolinkprefix}{idx:}%
 }
\end{document}