Debian Codegraph @

texmf-dist/doc/support/bib2gls/examples/sample-citations.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 % bib2gls must be run with the --cite-as-record switch
6
7 \documentclass[12pt,a4paper]{article}
8
9 \usepackage[record,% using bib2gls
10 nomain,% don't define main glossary
11 postdot,% full stop after descriptions
12 nostyles,% don't load default styles
13 % load glossary-tree and glossary-list and patch styles:
14 stylemods={tree,list}
15 ]{glossaries-extra}
16
17 \newglossary*{contributors}{Authors}
18 \newglossary*{titles}{Titles}
19
20 \newcommand{\bibglsnewbibtexentry}[4]{%
21 \longnewglossaryentry*{#1}{name={#3},#2,type={titles}}{#4}%
22 }
23
24 \GlsXtrLoadResources[
25 src={citations},% data in citations.bib
26 entry-type-aliases={\GlsXtrBibTeXEntryAliases},
27 field-aliases={
28 title=name
29 },
30 type={contributors},
31 category={same as original entry},
32 sort-field={category},
33 sort-suffix={name}
34 ]
35
36 \glsxtrsetgrouptitle{article}{Articles}
37 \glsxtrsetgrouptitle{book}{Books}
38
39 \newcommand{\contributorhandler}[1]{\par\glsentryname{#1} \cite{#1}}
40
41 \newcommand{\glsxtrpostdesccontributor}{%
42 \glsxtrifhasfield{bibtexentry}{\glscurrententrylabel}%
43 {%
44 \glsxtrfieldforlistloop
45 {\glscurrententrylabel}{bibtexentry}%
46 {\contributorhandler}%
47 }%
48 {\par No titles.}%
49 }
50
51 \newcommand{\glsxtrpostdescarticle}{\cite{\glscurrententrylabel}}
52 \newcommand{\glsxtrpostdescbook}{\cite{\glscurrententrylabel}}
53
54 \begin{document}
55 This is a sample document with some citations~\cite{macaw,parrot}
56 and some more citations~\cite{duck2018,duck2016} and don't
57 forget~\cite{ing,parrot2012} and lastly~\cite{quackalot}.
58
59 \printunsrtglossary[type=contributors,style=altlist]
60 \printunsrtglossary*[type=titles,style=indexgroup]
61 {%
62 \renewcommand{\glsxtrgroupfield}{category}%
63 \renewcommand{\glstreenamefmt}[1]{\emph{#1}}%
64 \renewcommand{\glstreegroupheaderfmt}[1]{\textbf{#1}}%
65 }
66
67 \bibliographystyle{unsrt}
68 \bibliography{citations}
69
70 \end{document}