summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/glossaries-extra/sample-abbr-styles.tex
blob: 7825a22dcb22cc7ab5be282861e70daf45d35c9d (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: pdflatex

\documentclass{report}

\usepackage[T1]{fontenc}
\usepackage{relsize}
\usepackage{etoolbox}
\usepackage[colorlinks,linkcolor=magenta]{hyperref}
\usepackage{glossaries-extra}

% If you get any undefined control sequences or undefined
% style errors, make sure you have the latest versions of
% glossaries-extra.sty and glossaries.sty

\makeglossaries

% This command is used for short forms for styles
% that don't have a designated command:
\renewcommand{\glsabbrvdefaultfont}[1]{\textsf{#1}}

% This command is used on first use for short forms
% for styles that don't have a designated command:
%\renewcommand{\glsfirstabbrvdefaultfont}[1]{\textsf{#1}}

% This command is used for long forms for styles
% that don't have a designated command:
\renewcommand{\glslongdefaultfont}[1]{\textsf{#1}}

% This command is used on first use for long forms
% for styles that don't have a designated command:
%\renewcommand{\glsfirstlongdefaultfont}[1]{\textsf{#1}}

% These commands are used by the '-hyphen' styles.
% For example, to switch to small-caps for the short form:
%\renewcommand{\glsabbrvhyphenfont}{\glsabbrvscfont}
%\renewcommand{\glsxtrhyphensuffix}{\glsxtrscsuffix}
% and emphasize the long form
%\renewcommand{\glslonghyphenfont}{\emph}

\renewcommand{\glsxtrabbrvfootnote}[2]{%
  \footnote{\glshyperlink[\glsfmtshort{#1}]{#1}: #2}%
}

\glssetcategoryattribute{long-hyphen-short-hyphen}{markwords}{true}
\glssetcategoryattribute{long-hyphen-postshort-hyphen}{markwords}{true}
\glssetcategoryattribute{long-hyphen-short-hyphen-desc}{markwords}{true}
\glssetcategoryattribute{long-hyphen-postshort-hyphen-desc}{markwords}{true}
\glssetcategoryattribute{short-hyphen-long-hyphen}{markwords}{true}
\glssetcategoryattribute{short-hyphen-postlong-hyphen}{markwords}{true}
\glssetcategoryattribute{short-hyphen-long-hyphen-desc}{markwords}{true}
\glssetcategoryattribute{short-hyphen-postlong-hyphen-desc}{markwords}{true}
\glssetcategoryattribute{long-hyphen-noshort-desc-noreg}{markwords}{true}
\glssetcategoryattribute{long-hyphen-noshort-noreg}{markwords}{true}

\newcommand{\stylelist}{}

\newcommand{\teststyle}[1]{%
 \listadd{\stylelist}{#1}%
 \setabbreviationstyle[#1]{#1}%
 \newabbreviation[category=#1,%
  %sort={#1},% order by style name
  user1={user text}%
 ]{sample-#1}{short}{long form}%
 \csdef{glsxtrpostdesc#1}{ [style: #1]}%
}

\newcommand{\testdescstyle}[1]{%
 \listadd{\stylelist}{#1}%
 \setabbreviationstyle[#1]{#1}%
 \newabbreviation[category=#1,%
  %sort={#1},% order by style name
  user1={user text},%
  description={sample description}]{sample-#1}{short}{long form}%
 \csdef{glsxtrpostdesc#1}{ [style: #1]}%
}

\teststyle{long-short}
\teststyle{short-long}
%\teststyle{footnote}% synonym: short-footnote
\teststyle{short-footnote}
%\teststyle{postfootnote}% synonym: short-postfootnote
\teststyle{short-postfootnote}
%\teststyle{short}% synonym: short-nolong
\teststyle{short-nolong}
\teststyle{short-nolong-noreg}
%\teststyle{long}% synonym: long-noshort
\teststyle{long-noshort}
\teststyle{long-noshort-noreg}
\teststyle{long-only-short-only}
\teststyle{long-short-sc}
\teststyle{short-sc-long}
%\teststyle{short-sc}% synonym: short-sc-nolong
\teststyle{short-sc-nolong}
\teststyle{long-noshort-sc}
%\teststyle{long-sc}% deprecated synonym of long-noshort-sc
\teststyle{short-sc-footnote}
%\teststyle{footnote-sc}% deprecated synonym of short-sc-footnote
\teststyle{short-sc-postfootnote}
%\teststyle{postfootnote-sc}% deprecated synonym of short-sc-postfootnote
\teststyle{long-short-sm}
\teststyle{short-sm-long}
%\teststyle{short-sm}% synonym: short-sm-nolong
\teststyle{short-sm-nolong}
%\teststyle{long-sm}% deprecated synonym of long-noshort-sm
\teststyle{long-noshort-sm}
\teststyle{short-sm-footnote}
%\teststyle{footnote-sm}% deprecated synonym of short-sm-footnote
\teststyle{short-sm-postfootnote}
%\teststyle{postfootnote-sm}% deprecated synonym of short-sm-postfootnote
\teststyle{long-short-em}
\teststyle{long-em-short-em}
\teststyle{short-em-long}
\teststyle{short-em-long-em}
\teststyle{short-em-nolong}
%\teststyle{short-em}% synonym: short-em-nolong
\teststyle{long-noshort-em}
%\teststyle{long-em}% deprecated synonym of long-noshort-em
\teststyle{long-em-noshort-em}
\teststyle{long-em-noshort-em-noreg}
\teststyle{short-em-footnote}
%\teststyle{footnote-em}% deprecated synonym of short-em-footnote
\teststyle{short-em-postfootnote}
%\teststyle{postfootnote-em}% deprecated synonym of short-em-postfootnote
\teststyle{long-short-user}
\teststyle{long-postshort-user}
\teststyle{short-long-user}
\teststyle{short-postlong-user}
\teststyle{long-hyphen-short-hyphen}
\teststyle{long-hyphen-postshort-hyphen}
\teststyle{short-hyphen-long-hyphen}
\teststyle{short-hyphen-postlong-hyphen}
\teststyle{long-hyphen-noshort-noreg}

\testdescstyle{long-short-desc}
\testdescstyle{short-long-desc}
%\testdescstyle{short-desc}% synonym: short-nolong-desc
\testdescstyle{short-nolong-desc}
\testdescstyle{short-nolong-desc-noreg}
%\testdescstyle{long-desc}% synonym: long-noshort-desc
\testdescstyle{long-noshort-desc}
\testdescstyle{long-noshort-desc-noreg}
\testdescstyle{long-only-short-only-desc}
\testdescstyle{long-short-sc-desc}
\testdescstyle{short-sc-long-desc}
%\testdescstyle{short-sc-desc}% synonym: short-sc-nolong-desc
\testdescstyle{short-sc-nolong-desc}
\testdescstyle{long-noshort-sc-desc}
%\testdescstyle{long-desc-sc}% deprecated synonym of long-noshort-sc-desc
\testdescstyle{long-short-sm-desc}
\testdescstyle{short-sm-long-desc}
%\testdescstyle{short-sm-desc}% synonym: short-sm-nolong-desc
\testdescstyle{short-sm-nolong-desc}
\testdescstyle{long-noshort-sm-desc}
%\testdescstyle{long-desc-sm}% deprecated synonym of long-noshort-sm-desc
\testdescstyle{long-short-em-desc}
\testdescstyle{long-em-short-em-desc}
\testdescstyle{short-em-long-desc}
\testdescstyle{short-em-long-em-desc}
%\testdescstyle{short-em-desc}% synonym: short-em-nolong-desc
\testdescstyle{short-em-nolong-desc}
\testdescstyle{long-noshort-em-desc}
%\testdescstyle{long-desc-em}% deprecated synonym of long-noshort-em-desc
\testdescstyle{long-em-noshort-em-desc}
\testdescstyle{long-em-noshort-em-desc-noreg}
\testdescstyle{long-short-user-desc}
\testdescstyle{long-postshort-user-desc}
\testdescstyle{short-long-user-desc}
\testdescstyle{short-postlong-user-desc}
\testdescstyle{long-hyphen-short-hyphen-desc}
\testdescstyle{long-hyphen-postshort-hyphen-desc}
\testdescstyle{short-hyphen-long-hyphen-desc}
\testdescstyle{short-hyphen-postlong-hyphen-desc}
\testdescstyle{long-hyphen-noshort-desc-noreg}

\newcommand{\marg}[1]{\{\textnormal{\emph{#1}}\}}
\pagestyle{headings}

\makeatletter
\renewcommand{\l@section}{\@dottedtocline {1}{1.5em}{3.3em}}
\makeatother

\begin{document}
\pagenumbering{roman}
This is a test document demonstrating abbreviation styles
provided by the \textsf{glossaries-extra} package. Hyperlinks
are shown in 
\makeatletter
\textcolor{\@linkcolor}{\@linkcolor}.
\makeatother

Some of the styles just use the default formatting commands (which don't
change the font). To make the default setting clearer, this document has done:
\begin{verbatim}
\renewcommand{\glslongdefaultfont}[1]{\textsf{#1}}
\renewcommand{\glsabbrvdefaultfont}[1]{\textsf{#1}}
\end{verbatim}
So any text in this document that's rendered in sans-serif would normally not have any font
change implemented.

Each test entry is defined using 
\begin{verbatim}
 \newabbreviation[category=#1,user1={user text}]%
  {sample-#1}{short}{long form}%
\end{verbatim}
for the non\texttt{-desc} styles or
\begin{verbatim}
 \newabbreviation[category=#1,user1={user text},%
  description={sample description}]%
 {sample-#1}{short}{long form}%
\end{verbatim}
for the \texttt{-desc} styles (where \verb|#1| is the style label).
Note that many of the entries will have duplicate sort values, so
don't build this with \texttt{xindy}. You can change the ordering
in the glossary to that it's sorted according to the style name
by changing the above definitions to:
\begin{verbatim}
 \newabbreviation[category=#1,user1={user text},sort={#1}]%
  {sample-#1}{short}{long form}%
 \newabbreviation[category=#1,user1={user text},sort={#1},%
  description={sample description}]%
 {sample-#1}{short}{long form}%
\end{verbatim}

To assist with distinguishing between the various styles, 
the post-description hook (used after displaying the description in
the glossary) is set to \verb*| [style: #1]| for all categories,
and the footnote command \verb|\glsxtrabbrvfootnote| has been
redefined to include the short form hyperlinked to the glossary.

The test entries that use the \texttt{-hyphen} styles have had the
\texttt{markwords} attribute set. This is designed to trigger
compound word hyphenation if the inserted text (through the final
optional argument of \verb|\gls|) starts with a hyphen.

\tableofcontents

\pagenumbering{arabic}
\chapter{First Use}
First use of \verb|\gls|.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\gls{\thislabel}.\glspar}

\chapter{Next Use}
Next use of \verb|\gls|.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\gls{\thislabel}.\glspar}

\chapter{First Use With Insert}
First use of \texttt{\string\gls\marg{label}[-insert]}. The conditional
\verb|\ifglsxtrinsertinside| is used by some styles to 
determine whether or not to include the inserted material
inside the font changing command used by the style.
The default is: \ifglsxtrinsertinside true\else false\fi.

In this test chapter, each entry is reset, then displayed with
\begin{verbatim}
\glsxtrinsertinsidefalse
\end{verbatim}
then reset and displayed with 
\begin{verbatim}
\glsxtrinsertinsidetrue
\end{verbatim}
(following the semi-colon). Some styles may only obey this
conditional for particular commands. (For example, the inline
commands like \verb|\glsxtrfull| may behave differently to 
commands like \verb|\gls|.)

Some of the styles just use the default font commands (which don't
change the font) so there's no noticeable difference. To make the
differences more noticeable this document has done:
\begin{verbatim}
\renewcommand{\glslongdefaultfont}[1]{\textsf{#1}}
\renewcommand{\glsabbrvdefaultfont}[1]{\textsf{#1}}
\end{verbatim}

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsreset{\thislabel}\glsxtrinsertinsidefalse
\gls{\thislabel}[-insert];
\glsreset{\thislabel}\glsxtrinsertinsidetrue
\gls{\thislabel}[-insert].\glspar}

\chapter{Next Use With Insert}
Next use of \texttt{\string\gls\marg{label}[-insert]}.

In this test chapter, each entry is displayed
with \verb|\glsxtrinsertinsidefalse| and then displayed with
\verb|\glsxtrinsertinsidetrue| 
(following the semi-colon). Some styles don't check this
conditional.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrinsertinsidefalse
\gls{\thislabel}[-insert];
\glsxtrinsertinsidetrue
\gls{\thislabel}[-insert].\glspar}

\chapter{Full Form}
Full form using \verb|\glsxtrfull| (inline full style).
This may differ from the display form used by \verb|\gls|
on first use, depending on the style.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrfull{\thislabel}.\glspar}

\chapter{Short Form}
Short form using \verb|\glsxtrshort|.
This may differ from the display form used by \verb|\gls|
on subsequent use, depending on the style.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrshort{\thislabel}.\glspar
}

\chapter{Long Form}
Long form using \verb|\glsxtrlong|.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrlong{\thislabel}.\glspar}

\chapter{Full Form With Insert}
Full form using \texttt{\string\glsxtrfull\marg{label}[-insert]} (inline full style).
In this test chapter, each entry is displayed
with \verb|\glsxtrinsertinsidefalse| and then displayed with
\verb|\glsxtrinsertinsidetrue| 
(following the semi-colon).

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrinsertinsidefalse
\glsxtrfull{\thislabel}[-insert];
\glsxtrinsertinsidetrue
\glsxtrfull{\thislabel}[-insert].\glspar}

\chapter{Short Form With Insert}
Short form using \texttt{\string\glsxtrshort\marg{label}[-insert]}.

In this test chapter, each entry is displayed
with \verb|\glsxtrinsertinsidefalse| and then displayed with
\verb|\glsxtrinsertinsidetrue| 
(following the semi-colon).

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrinsertinsidefalse
\glsxtrshort{\thislabel}[-insert];
\glsxtrinsertinsidetrue
\glsxtrshort{\thislabel}[-insert].\glspar}

\chapter{Long Form With Insert}
Long form using \texttt{\string\glsxtrlong\marg{label}[-insert]}.
Note that the \texttt{hyphen} styles with the \texttt{markwords}
attribute don't adjust in this case.

In this test chapter, each entry is displayed
with \verb|\glsxtrinsertinsidefalse| and then displayed with
\verb|\glsxtrinsertinsidetrue| 
(following the semi-colon).

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsxtrinsertinsidefalse
\glsxtrlong{\thislabel}[-insert];
\glsxtrinsertinsidetrue
\glsxtrlong{\thislabel}[-insert].\glspar}

\chapter{First Form}
First form using \verb|\glsfirst|. This may be different
from the first use of \verb|\gls| depending on the style.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsfirst{\thislabel}.\glspar}

\chapter{Text Form}
Text form using \verb|\glstext|. This may be different
from the subsequent use of \verb|\gls| depending on the style.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glstext{\thislabel}.\glspar}

\chapter{First Form With Insert}
First form using \texttt{\string\glsfirst\marg{label}[-insert]}.
This is different from the first use of \verb|\gls|
as can be seen by the location of the inserted material.
(There's no check for the conditional 
\verb|\ifglsxtrinsertinside|.) In general it's best not
to use \verb|\glsfirst| with abbreviations. Use either
\verb|\gls| (possibly with a reset) or \verb|\glsxtrfull|.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glsfirst{\thislabel}[-insert].\glspar}

\chapter{Text Form With Insert}
Text form using \texttt{\string\glstext\marg{label}[-insert]}.
This doesn't check for the conditional 
\verb|\ifglsxtrinsertinside|.

\forglsentries{\thislabel}{\glscategory{\thislabel}:
\glstext{\thislabel}[-insert].\glspar}

\chapter{Summary}

\renewcommand{\do}[1]{\section{#1}
First use \texttt{\string\gls\marg{label}}:
\glsreset{sample-#1}\gls{sample-#1}.\par\noindent
Next use \texttt{\string\gls\marg{label}}: \gls{sample-#1}.\par\noindent
First use \texttt{\string\gls\marg{label}[-insert]}: 
\glsreset{sample-#1}\gls{sample-#1}[-insert].\par\noindent
Next use \texttt{\string\gls\marg{label}[-insert]}: 
\gls{sample-#1}[-insert].\par\noindent
\texttt{\string\glsxtrfull\marg{label}[-insert]}: 
\glsxtrfull{sample-#1}[-insert].\par\noindent
\texttt{\string\glsxtrshort\marg{label}[-insert]}: 
\glsxtrshort{sample-#1}[-insert].\par\noindent
\texttt{\string\glsxtrlong\marg{label}[-insert]}: 
\glsxtrlong{sample-#1}[-insert].\par\noindent
Name: \glsentryname{sample-#1}.\par\noindent
Sort: \texttt{\glsentrysort{sample-#1}}.\par\noindent
Description: \glsentrydesc{sample-#1}.\par
}

\dolistloop{\stylelist}
\printglossaries
\end{document}