summaryrefslogtreecommitdiff
path: root/support/bib2gls/examples/sample-citations.tex
blob: 3cf9fd14a0f1d2dbe56dce4eede99b195edb2c8b (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
% This file is public domain. See the "Examples" chapter
% in the bib2gls user manual for a more detailed description
% of this file.

% bib2gls must be run with the --cite-as-record switch

\documentclass[12pt,a4paper]{article}

\usepackage[record,% using bib2gls
nomain,% don't define main glossary
postdot,% full stop after descriptions
nostyles,% don't load default styles
% load glossary-tree and glossary-list and patch styles:
stylemods={tree,list}
]{glossaries-extra}

\newglossary*{contributors}{Authors}
\newglossary*{titles}{Titles}

\newcommand{\bibglsnewbibtexentry}[4]{%
 \longnewglossaryentry*{#1}{name={#3},#2,type={titles}}{#4}%
}

\GlsXtrLoadResources[
  src={citations},% data in citations.bib
  entry-type-aliases={\GlsXtrBibTeXEntryAliases},
  field-aliases={
    title=name
  },
  type={contributors},
  category={same as original entry},
  sort-field={category},
  sort-suffix={name}
]

\glsxtrsetgrouptitle{article}{Articles}
\glsxtrsetgrouptitle{book}{Books}

\newcommand{\contributorhandler}[1]{\par\glsentryname{#1} \cite{#1}}

\newcommand{\glsxtrpostdesccontributor}{%
  \glsxtrifhasfield{bibtexentry}{\glscurrententrylabel}%
  {%
    \glsxtrfieldforlistloop
    {\glscurrententrylabel}{bibtexentry}%
    {\contributorhandler}%
  }%
  {\par No titles.}%
}

\newcommand{\glsxtrpostdescarticle}{\cite{\glscurrententrylabel}}
\newcommand{\glsxtrpostdescbook}{\cite{\glscurrententrylabel}}

\begin{document}
This is a sample document with some citations~\cite{macaw,parrot}
and some more citations~\cite{duck2018,duck2016} and don't
forget~\cite{ing,parrot2012} and lastly~\cite{quackalot}.

\printunsrtglossary[type=contributors,style=altlist]
\printunsrtglossary*[type=titles,style=indexgroup]
{%
 \renewcommand{\glsxtrgroupfield}{category}%
 \renewcommand{\glstreenamefmt}[1]{\emph{#1}}%
 \renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}%
}

\bibliographystyle{unsrt}
\bibliography{citations}

\end{document}