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
|
% This file is public domain
% If you want to use arara, you need the following directives:
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{article}
\usepackage{glossaries}
\makeglossaries
\glsaddstoragekey
{abbrtype}% key/field name
{acronym}% default value if not explicitly set
{\abbrtype}% custom command to access the value if required
\newacronymstyle
{mystyle}% style name
{% Use the generic display
\ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}
{% User needs to explicitly set the description
\renewcommand*{\GenericAcronymFields}{}%
% For the full format, test the value of the "abbrtype" key.
% If it's set to "acronym" put the short form first with
% the long form in brackets.
\renewcommand*{\genacrfullformat}[2]{%
\ifglsfieldeq{##1}{abbrtype}{acronym}
{% is a proper acronym
\protect\firstacronymfont{\glsentryshort{##1}}##2\space
(\glsentrylong{##1})%
}
{% is another form of abbreviation
\glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}})%
}%
}%
% first letter upper case version:
\renewcommand*{\Genacrfullformat}[2]{%
\ifglsfieldeq{##1}{abbrtype}{acronym}
{% is a proper acronym
\protect\firstacronymfont{\Glsentryshort{##1}}##2\space
(\glsentrylong{##1})%
}
{% is another form of abbreviation
\Glsentrylong{##1}##2\space
(\protect\firstacronymfont{\glsentryshort{##1}})%
}%
}%
% plural
\renewcommand*{\genplacrfullformat}[2]{%
\ifglsfieldeq{##1}{abbrtype}{acronym}
{% is a proper acronym
\protect\firstacronymfont{\glsentryshortpl{##1}}##2\space
(\glsentrylong{##1})%
}
{% is another form of abbreviation
\glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}})%
}%
}%
% plural and first letter upper case
\renewcommand*{\Genplacrfullformat}[2]{%
\ifglsfieldeq{##1}{abbrtype}{acronym}
{% is a proper acronym
\protect\firstacronymfont{\Glsentryshortpl{##1}}##2\space
(\glsentrylong{##1})%
}
{% is another form of abbreviation
\Glsentrylongpl{##1}##2\space
(\protect\firstacronymfont{\glsentryshortpl{##1}})%
}%
}%
% Just use the short form as the name part in the glossary:
\renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}%
% Sort by the short form:
\renewcommand*{\acronymsort}[2]{##1}%
% Just use the surrounding font for the short form:
\renewcommand*{\acronymfont}[1]{##1}%
% Same for first use:
\renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
% Default plural suffix if the plural isn't explicitly set
\renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
\setacronymstyle{mystyle}
% The default for "abbrtype" is "acronym" so we don't need
% this new key for acronyms:
\newacronym[description={system for detecting the position and
speed of aircraft, ships, etc}]{radar}{radar}{radio detecting
and ranging}
\newacronym[description={device that creates a narrow beam
of intense light}]{laser}{laser}{light amplification by
stimulated emission of radiation}
\newacronym[description={portable breathing device for
divers}]{scuba}{scuba}{self-contained underwater breathing
apparatus}
\newcommand*{\newinitialism}[4][]{%
\newacronym[abbrtype=initialism,#1]{#2}{#3}{#4}%
}
\newinitialism[description={mathematical manipulation of an
information signal}]{dsp}{DSP}{digital signal processing}
\newinitialism[description={device that allows customers of
financial institutions to perform transactions, such as
cash withdrawal, without the need for a teller}]{atm}{ATM}
{automated teller machine}
\newcommand*{\newcontraction}[4][]{%
\newacronym[abbrtype=contraction,#1]{#2}{#3}{#4}%
}
\newcontraction[description={front part of a ship below the
deck}]{focsle}{fo'c's'le}{forecastle}
\newglossaryentry{apple}{name={apple},description={a fruit}}
\newglossarystyle
{mystyle}% style name
{% base it on the "list" style
\setglossarystyle{list}%
\renewcommand*{\glossentry}[2]{%
\item[\glsentryitem{##1}%
\glstarget{##1}{\glossentryname{##1}}]
\ifglshaslong{##1}%
{ (\abbrtype{##1}: \glsentrylong{##1})\space}{}%
\glossentrydesc{##1}\glspostdescription\space ##2}%
}
\setglossarystyle{mystyle}
\begin{document}
First use: \gls{radar}, \gls{laser}, \gls{scuba}, \gls{dsp},
\gls{atm}, \gls{focsle}.
Next use: \gls{radar}, \gls{laser}, \gls{scuba}, \gls{dsp},
\gls{atm}, \gls{focsle}.
Regular term: \gls{apple}.
\printglossaries
\end{document}
|