blob: 4e74e2e059cb9c972fc1df257fb0a8266aa03084 (
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
|
% This file is public domain
% If you want to use arara, you need the following directives:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{report}
\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}
\makeglossaries
\glsaddstoragekey{chapter}{0}{\glschapnum}
\loadglsentries{example-glossaries-brief}
\renewcommand*{\glslinkpostsetkeys}{%
\edef\currentchap{\arabic{chapter}}%
\ifnum\currentchap=\glschapnum{\glslabel}\relax
% Already used this entry in the current chapter, so switch
% off the hyperlink.
\setkeys{glslink}{hyper=false}%
\else
% Hasn't been used in the current chapter. Update the value
% of the "chapter" field unless the hyperlink has been switched
% off.
\glsifhyperon
{%
\glsfieldxdef{\glslabel}{chapter}{\currentchap}%
}%
{}%
\fi
}
\begin{document}
\chapter{Sample}
Use all entries: \forglsentries{\thislabel}{\gls{\thislabel}. }
Use them again: \forglsentries{\thislabel}{\gls{\thislabel}. }
\chapter{Another}
Use all entries: \forglsentries{\thislabel}{\gls{\thislabel}. }
Use them again: \forglsentries{\thislabel}{\gls{\thislabel}. }
\chapter{Start with a Star}
Use all entries but suppress hyperlink:
\forglsentries{\thislabel}{\gls*{\thislabel}. }
Use all entries: \forglsentries{\thislabel}{\gls{\thislabel}. }
Use them again: \forglsentries{\thislabel}{\gls{\thislabel}. }
\printglossaries
\end{document}
|