Debian Codegraph @

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

raw
1 % arara: pdflatex
2 % arara: makeglossaries
3 % arara: pdflatex
4 \documentclass[12pt]{article}
5
6 \usepackage[colorlinks]{hyperref}
7 \usepackage[style=tree]{glossaries-extra}
8
9 \makeglossaries
10
11 \newcommand{\latinname}[1]{\emph{#1}}
12 \glssetcategoriesattributes{genus,species}{textformat,glossnamefont}{latinname}
13
14 \setabbreviationstyle[genus]{long-only-short-only-desc}
15 \newabbreviation[category=genus,description={}]{clostridium}{C.}{Clostridium}
16
17 \newglossaryentry{botulinum}{name=botulinum,category=species,
18 description={},parent=clostridium}
19 \newglossaryentry{perfringens}{name=perfringens,category=species,
20 description={},parent=clostridium}
21 \newglossaryentry{tetani}{name=tetani,category=species,
22 description={},parent=clostridium}
23
24 \multiglossaryentrysetup{indexothers=false,hyper=mainonly}
25
26 \multiglossaryentry
27 [firstsuffix=botulism]% suffix on first use of multi-entry set
28 {cbot}{clostridium,botulinum}
29 \multiglossaryentry
30 [firstsuffix={gas gangrene}]
31 {cperf}{clostridium,perfringens}
32 \multiglossaryentry
33 [% default options for this multi-entry set
34 firstsuffix=tetanus,% suffix on first use of multi-entry set
35 textformat=textbf% default formatting in \mgls-like commands
36 ]
37 {ctet}{clostridium,tetani}
38
39 % custom separator that checks the pre-separator element's category
40 \renewcommand*{\glscombinedsep}[2]{%
41 \glsifcategory{#1}{genus}%
42 {\ifglshasshort{#1}{\ifglshasshort{#2}{\space}{~}}{\space}}%
43 {\space}%
44 }
45
46 \begin{document}
47 \section{Regular Use}
48 First use: \mgls{cbot}.
49
50 Next use: \mgls{cbot}.
51
52 First use: \mgls{ctet}.
53
54 \section{Unset/Reset}
55
56 Unset all elements (not multi-entry) initially: \mgls[unsetall]{cperf}.
57
58 Reset all elements (not multi-entry) initially: \mgls[resetall]{cperf}.
59
60 Next use: \mgls{cperf}.
61
62 Reset multi-entry (not individual elements): \mglsreset{cperf}\mgls{cperf}.
63
64 \section{Formatting}
65 Change default text format to \texttt{underline}.
66
67 \subsection{One hyperlink over all}
68
69 Reset multi-entry and override entire textformat:
70 \mglsreset{ctet}\mgls[setup={hyper=allmain,textformat=underline}]{ctet}.
71
72 Override entire textformat: \mgls[setup={hyper=allmain,textformat=underline}]{ctet}.
73
74 Override main textformat: \mgls[setup={hyper=allmain},main={textformat=underline}]{ctet}.
75
76 Override other textformat: \mgls[setup={hyper=allmain},others={textformat=underline}]{ctet}.
77
78 \subsection{Individual hyperlinks}
79
80 Override entire textformat: \mgls[setup={hyper=individual,textformat=underline}]{ctet}.
81
82 Override main textformat: \mgls[setup={hyper=individual},main={textformat=underline}]{ctet}.
83
84 Override other textformat: \mgls[setup={hyper=individual},others={textformat=underline}]{ctet}.
85
86 \subsection{Only hyperlink main}
87
88 Override entire textformat: \mgls[setup={hyper=mainonly,textformat=underline}]{ctet}.
89
90 Override main textformat: \mgls[setup={hyper=mainonly},main={textformat=underline}]{ctet}.
91
92 Override other textformat: \mgls[setup={hyper=mainonly},others={textformat=underline}]{ctet}.
93
94 \printglossaries
95 \end{document}