Debian Codegraph @

texmf-dist/doc/latex/glossaries-extra/samples/sample-unitentrycount.tex

raw
1 % arara: pdflatex
2 % arara: pdflatex
3 % arara: makeglossaries
4 % arara: pdflatex
5 \documentclass{report}
6
7 \usepackage[colorlinks]{hyperref}
8 \usepackage{glossaries-extra}
9
10 \GlsXtrEnableEntryUnitCounting{abbreviation}{2}{chapter}
11
12 \makeglossaries
13
14 \newabbreviation{html}{HTML}{hypertext markup language}
15 \newabbreviation{xml}{XML}{extensible markup language}
16 \newabbreviation{css}{CSS}{cascading style sheet}
17
18 \newglossaryentry{sample}{name={sample},description={sample}}
19
20 \newcommand*{\lastruncount}[1]{%
21 Overall number of times the \texttt{#1} entry is used in
22 this chapter: \glsentryprevcount{#1}. (Information obtained
23 from previous run.)%
24 }
25
26 \newcommand*{\currentruncount}[1]{%
27 Number of times the \texttt{#1} entry has been used this
28 chapter so far: \glsentrycurrcount{#1}.%
29 }
30
31 \newcommand*{\triggertest}[1]{%
32 Normal usage of \texttt{\char`\\gls} \glsxtrifcounttrigger{#1}{has}{hasn't} been
33 suppressed for the \texttt{#1} entry in this chapter.%
34 }
35
36 \begin{document}
37
38 This is a sample document that uses entry counting per unit. The unit entry counting
39 has been enabled on the \texttt{abbreviation} category.
40 The unit has been set to
41 ``\glsgetcategoryattribute{abbreviation}{unitcount}''.
42 This means that abbreviations will only be added to the glossary if
43 they are used more than $n$ times per
44 \glsgetcategoryattribute{abbreviation}{unitcount},
45 where in this document $n$ has been set to
46 \glsgetcategoryattribute{abbreviation}{entrycount}.
47 Entries in other categories behave as normal.
48
49 \chapter{Sample}
50
51 \lastruncount{xml}
52
53 Used once: \gls{html}.
54
55 Used twice: \gls{xml} and \gls{xml}.
56
57 Used three times: \gls{css} and \gls{css} and \gls{css}.
58
59 Used once but this entry is in the ``general'' category
60 which doesn't have the entry unit counting set:
61 \gls{sample}.
62
63 \currentruncount{xml}
64
65 \triggertest{xml}
66
67 \currentruncount{css}
68
69 \triggertest{css}
70
71 \chapter{Another Sample}
72
73 Used once in this chapter: \gls{xml}.
74
75 Used twice in this chapter: \gls{css} and \gls{css}.
76
77 \currentruncount{css}
78
79 \triggertest{css}
80
81 Total number of times the \texttt{css} entry was used
82 throughout the document on the previous run:
83 \glsentryprevtotalcount{css}.
84
85 Total number of times the \texttt{xml} entry was used
86 throughout the document on the previous run:
87 \glsentryprevtotalcount{xml}.
88
89 \printglossaries
90
91 \end{document}