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
|
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\usepackage[nopostdot=false]{glossaries-extra}
\makeglossaries
% regular terms:
% (Version 1.04+) The following will make regular terms appear
% in sans-serif when used with \gls etc but won't affect the
% abbreviations:
%\renewcommand*{\glsxtrregularfont}[1]{\textsf{#1}}
% or limit to just the "general" category:
%\renewcommand*{\glsxtrregularfont}[1]{%
% \glsifcategory{\glslabel}{general}{\textsf{#1}}{#1}}
% or limit to a particular attribute:
%\glssetcategoryattribute{general}{font}{sf}
%\glssetcategoryattribute{acronym}{font}{sf}
%\renewcommand*{\glsxtrregularfont}[1]{%
% \glsifattribute{\glslabel}{font}{sf}{\textsf{#1}}{#1}}
% or use the attribute to store the font control sequence name:
%\glssetcategoryattribute{general}{font}{textsf}
%\glssetcategoryattribute{acronym}{font}{emph}
%
%\renewcommand*{\glsxtrregularfont}[1]{%
% \glshasattribute{\glslabel}{font}%
% {\csuse{\glsgetattribute{\glslabel}{font}}{#1}}%
% {#1}%
%}
% The following will make the first letter of the name upper case
% in the glossary for the general entries:
\glssetcategoryattribute{general}{glossname}{firstuc}
% The following will make the first letter of the description upper case
% in the glossary for the general entries:
\glssetcategoryattribute{general}{glossdesc}{firstuc}
% (version 1.04+) The following will make the description
% appear in italic in the glossary for general entries:
%\glssetcategoryattribute{general}{glossdescfont}{emph}
% (version 1.04+) The following will make the name
% appear in italic in the glossary for general entries:
%\glssetcategoryattribute{general}{glossnamefont}{emph}
\newglossaryentry{duck}{name=duck,%
description={a waterbird with webbed feet}}
\newglossaryentry{parrot}{name=parrot,%
description={mainly tropical bird with bright plumage}}
% acronyms:
% The following redefinition will add the provided text to the end of the
% description in the glossary.
\renewcommand*{\glsxtrpostdescacronym}{%
\space(\textsc{acronym:} \glsentrylong{\glscurrententrylabel})%
}
% The following will make the first letter of the name upper case
% in the glossary for the acronym entries:
\glssetcategoryattribute{acronym}{glossname}{firstuc}
% The following will make the first letter of the description upper case
% in the glossary for the acronym entries:
\glssetcategoryattribute{acronym}{glossdesc}{firstuc}
% Enable tagging of initials. The second argument is the name of
% the command you want to use to tag initial letters. The
% command will be defined robustly and will only be activated
% in the glossary for the categories listed in the first
% argument.
% If the specified tagging command (\itag here) is used
% anywhere else it will just do its argument.
\GlsXtrEnableInitialTagging{acronym,abbreviation}{\itag}
\newacronym[description={a device that emits a narrow intense
beam of light}]{laser}{laser}
{\itag{l}ight \itag{a}mplification by \itag{s}timulated
\itag{e}mission of \itag{r}adiation}
\newacronym[description={a form of \gls{laser} generating a beam of
microwaves}]{maser}{maser}
{\itag{m}icrowave \itag{a}mplification by \itag{s}timulated
\itag{e}mission of \itag{r}adiation}
\newacronym[description={a system for detecting the location and
speed of ships, aircraft, etc, through the use of radio waves}]{radar}{radar}
{\itag{ra}dio \itag{d}etection \itag{a}nd \itag{r}anging}
\newacronym[description={portable breathing apparatus for divers}]{scuba}{scuba}
{\itag{s}elf-\itag{c}ontained \itag{u}nderwater
\itag{b}reathing \itag{a}pparatus}
% The following redefinition will add the provided text to the end of the
% description in the glossary.
\renewcommand*{\glsxtrpostdescabbreviation}{%
\space (abbreviation)%
}
% The following will set the description in title case
% in the glossary for the abbreviations:
\glssetcategoryattribute{abbreviation}{glossdesc}{title}
% The following will convert the abbreviations to all capitals
% in the glossary:
\glssetcategoryattribute{abbreviation}{glossname}{uc}
% Use \textsc in the abbreviations:
\setabbreviationstyle{long-short-sc}
% Some other attributes you might want to try:
% Use 's (apostrophe s) for the plural suffix
% (only affects the short plural not the long plural)
%\glssetcategoryattribute{abbreviation}{aposplural}{true}
% Suppress the default suffix for the short plural.
% (Don't use with the above for the same category.)
%\glssetcategoryattribute{abbreviation}{noshortplural}{true}
% abbreviations:
\newabbreviation
{html}% identifying label
{html}% short form
{\itag{h}yper\itag{t}ext \itag{m}arkup \itag{l}anguage}% long form
\newabbreviation
{xml}% identifying label
{xml}% short form
{e\itag{x}tensible \itag{m}arkup \itag{l}anguage}% long form
\newabbreviation
{svg}% identifying label
{svg}% short form
{\itag{s}calable \itag{v}ector \itag{g}raphics}% long form
\newabbreviation
{svm}% identifying label
{svm}% short form
{\itag{s}upport \itag{v}ector \itag{m}achine}% long form
\title{Sample Document Illustrating the glossaries-extra Package}
\author{Nicola Talbot}
\begin{document}
\pagenumbering{alph}
\maketitle
\pagenumbering{roman}
\tableofcontents
\pagenumbering{arabic}
\chapter{Categories}
The \texttt{glossaries-extra} package provides an extra key called
\texttt{category}, which is used to assign a category to each entry.
For example, the category for the ``duck'' entry is:
\glscategory{duck}.
The category value is just a label, which needs to be expandable, so
make sure you avoid problematic characters in it. You can test the
category with \verb|\glsifcategory|.
The entry ``duck'' \glsifcategory{duck}{general}{is}{isn't} a
general entry.
The entry ``laser'' \glsifcategory{laser}{general}{is}{isn't} a
general entry.
A category can have attributes set. For example, both the
``general'' category and the ``acronym'' category have the attribute
``regular'' set to ``true''.
You can obtain the value of an attribute for a given category with
\begin{verbatim}
\glsgetcategoryattribute{category}{attribute}
\end{verbatim}
This does nothing if the category
or attribute aren't defined.
Category ``general'' has the attribute ``regular'' set to
``\glsgetcategoryattribute{general}{regular}''.
Category ``acronym'' has the attribute ``regular'' set to
``\glsgetcategoryattribute{acronym}{regular}''.
Category ``abbreviation'' has the attribute ``regular'' set to
``\glsgetcategoryattribute{abbreviation}{regular}''.
You can test if a category has an attribute set to a given value
with
\begin{verbatim}
\glsifcategoryattribute{category}{attribute}{value}{true code}{false
code}
\end{verbatim}
Category ``general''
\glsifcategoryattribute{general}{regular}{true}{has}{doesn't have}
the ``regular'' attribute set to ``true''.
Category ``acronym''
\glsifcategoryattribute{acronym}{regular}{true}{has}{doesn't have}
the ``regular'' attribute set to ``true''.
Category ``abbreviation''
\glsifcategoryattribute{abbreviation}{regular}{true}{has}{doesn't have}
the ``regular'' attribute set to ``true''.
\chapter{Regular Terms}
By default glossary entries have the category ``general''.
For
example\glsforeachincategory{general}{\thistype}{\thislabel}{,
\gls{\thislabel}} have the category field set to ``general''.
Commands like \verb|\newabbreviation| and \verb|\newacronym|
override this.
Regular terms are those entries whose category has the ``regular''
attribute set to ``true''. There's a convenient shortcut to
determine if an entry has a category with the ``regular'' attribute
set:
\begin{verbatim}
\glsifregular{entry-label}{true code}{false code}
\end{verbatim}
For example: \gls{duck} \glsifregular{duck}{is}{isn't} a regular
term;
\gls{laser} \glsifregular{laser}{is}{isn't} a regular
term.
The regular attribute determines what \verb|\gls| (and plural and
case-changing variants) should do. A regular entry (even if
it's been defined using \verb|\newacronym| or
\verb|\newabbreviation|) uses the \texttt{first} (or
\texttt{firstplural}) key on first use and the \texttt{text}
(or \texttt{plural}) key on subsequent use.
An abbreviation whose category doesn't have the regular attribute
set to ``true'' will use the abbreviation style assigned
to that category for first and subsequent use, which will use
the values of the \texttt{long} (or \texttt{longplural})
and \texttt{short} (or \texttt{shortplural}) keys.
The first use of \verb|\gls| may or may not match \verb|\glsfirst|
for non-regular entries, depending on the abbreviation style.
\chapter{Abbreviations}
Abbreviations include acronyms, initialisms and contractions.
Some abbreviation styles may set category attributes.
For example, the ``short'' style sets the ``regular'' attribute for
the category used by the abbreviations with that style applied.
Whereas the ``long-short'' style will switch off the ``regular'' attribute
if it has previously been switched on.
Styles must be set before defining abbreviations, but you may set
different styles for different categories.
For example, by default the ``short'' style is set for abbreviations
with the ``acronym'' category using:
\begin{verbatim}
\setabbreviationstyle[acronym]{short}
\end{verbatim}
whereas the ``short-long'' style is set for abbreviations with the
``abbreviation'' category:
\begin{verbatim}
\setabbreviationstyle{long-short}
\end{verbatim}
(The optional argument defaults to ``abbreviation''.)
If no style has been set for a particular category, the style for the
``abbreviation'' category is used instead.
\section{Acronyms}
An acronym is a word formed from the initial letters of other words.
Since it's a word, an acronym is pronounced as a word rather than as
a series of letters. Examples of acronyms: \gls{laser}, \gls{maser},
\gls{radar} and \gls{scuba}.
Since acronyms are treated as words, the ``acronym'' category
has the ``regular'' attribute set to ``true''. The default
abbreviation style for acronyms is ``short'', which doesn't expand
the entry on first use.
The description defaults to the long
form with the ``short'' style. This example document overrides
the default description by using the \texttt{description}
key in the optional argument of \verb|\newacronym|. This
document also sets the post description hook
(\verb|\glsxtrpostdescacronym|) to insert the long form in
parentheses after the description when it's displayed in the glossary.
\section{Initialism}
Initialisms are formed from initial letters of words where the
letters are sounded out. Examples of initialisms:
\gls{svm}, \gls{html}, \gls{svg} and \gls{xml}.
The \texttt{glossaries-extra} package sets the default abbreviation
style to \texttt{long-short}. This document has changed it to
\texttt{long-short-sc} (use small caps). Next use:
\gls{svm}, \gls{html}, \gls{svg} and \gls{xml}.
Note that the acronyms (like \gls{laser}) don't use small caps.
This is because the acronyms and initialisms have separate styles
applied since they are in separate categories.
\section{Plurals}
The default plural for the short form is obtained by appending
the abbreviation plural suffix to the singular form. You can
override this on a per-entry basis using the \texttt{shortplural}
key in the optional argument of \verb|\newabbreviation|
(or \verb|\newacronym|) or you can prevent the suffix from
being added to all entries in a particular category (or categories)
by setting the \texttt{noshortplural} attribute to ``true'' for
the relevant category (before defining the entries).
Alternatively you can automatically insert an apostrophe before
the plural suffix by setting the \texttt{aposplural} attribute to
``true''. The \texttt{aposplural} attribute overrides the
\texttt{noshortplural} attribute.
Plurals: \glspl{svm}, \glspl{laser}.
\printglossaries
\end{document}
|