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
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
|
\documentclass[a4paper]{article}
\usepackage[colorlinks,pdfauthor={Nicola L.C. Talbot},
pdftitle={Upgrading from the glossary package to
the glossaries package}]{hyperref}
\usepackage{html}
\usepackage{xr}
\externaldocument{glossaries}
\title{Upgrading from the glossary package to the glossaries
package}
\author{Nicola L.C. Talbot}
\date{17th June 2008}
\newcommand*{\meta}[1]{\textnormal{\textless\emph{#1}\textgreater}}
\newcommand*{\marg}[1]{\texttt{\char`\{\meta{#1}\char`\}}}
\newcommand*{\oarg}[1]{\texttt{[\meta{#1}]}}
\newcommand*{\cs}[1]{\texttt{\char`\\#1}}
%\begin{latexonly}
\newcommand*{\sty}[1]{\textsf{#1}}
\newcommand*{\key}[1]{\textsf{#1}}
\newcommand*{\pkgopt}[1]{\textsf{#1}}
\newcommand*{\dq}[1]{``#1''}
\newsavebox\waybox
\newenvironment{oldway}{\begin{lrbox}{\waybox}
\begin{minipage}{0.98\linewidth}\ttfamily
}{\end{minipage}\end{lrbox}\vskip\baselineskip\par\noindent
\begin{tabular}{r}
\fbox{\usebox\waybox}\\[4pt]\footnotesize\mbox{\sty{glossary}}
\end{tabular}%
\vskip\baselineskip\par\noindent\ignorespaces}
\newenvironment{newway}{\begin{lrbox}{\waybox}
\begin{minipage}{0.98\linewidth}\ttfamily
}{\end{minipage}\end{lrbox}\vskip\baselineskip\par\noindent
\begin{tabular}{r}
\fbox{\usebox\waybox}\\[4pt]\footnotesize\mbox{\sty{glossaries}}
\end{tabular}%
\vskip\baselineskip\par\noindent\ignorespaces}
%\end{latexonly}
\begin{htmlonly}
\newenvironment{oldway}{\par\begin{ttfamily}}{\end{ttfamily}\par}
\newenvironment{newway}{\par\begin{ttfamily}}{\end{ttfamily}\par}
\newcommand{\sty}[1]{\texttt{#1}}
\renewcommand{\LaTeX}{LaTeX}
\newcommand*{\key}[1]{\texttt{#1}}
\newcommand*{\pkgopt}[1]{\texttt{#1}}
\newcommand*{\dq}[1]{"#1"}
\end{htmlonly}
\begin{document}
\maketitle
\tableofcontents
\begin{abstract}
The purpose of this document is to provide advice if you want
to convert a \LaTeX\ document from using the obsolete
\sty{glossary} package to the replacement \sty{glossaries} package.
\end{abstract}
\section{Package Options}
When converting a document that currently uses the obsolete
\sty{glossary} package to the replacement \sty{glossaries} package,
it should be fairly obvious that the first thing you need to do is
replace \verb|\usepackage{glossary}| with
\verb|\usepackage{glossaries}|, however some of the package options
are different, so you may need to change those as well.
Table~\ref{tab:pkgopt} shows the mappings from the \sty{glossary}
to the \sty{glossaries} package options.
\begin{table}[htbp]
\caption[Mappings]{Mappings from \sty{glossary} to \sty{glossaries}
package options}
\label{tab:pkgopt}
\begin{center}
\begin{tabular}{ll}
\bfseries \sty{glossary} option & \bfseries \sty{glossaries} option\\
style=list & style=list\\
style=altlist & style=altlist\\
style=long,header=none,border=none,cols=2 & style=long\\
style=long,header=plain,border=none,cols=2 & style=longheader\\
style=long,header=none,border=plain,cols=2 & style=longborder\\
style=long,header=plain,border=plain,cols=2 & style=longheaderborder\\
style=long,header=none,border=none,cols=3 & style=long3col\\
style=long,header=plain,border=none,cols=3 & style=long3colheader\\
style=long,header=none,border=plain,cols=3 & style=long3colborder\\
style=long,header=plain,border=plain,cols=3 & style=long3colheaderborder\\
style=super,header=none,border=none,cols=2 & style=super\\
style=super,header=plain,border=none,cols=2 & style=superheader\\
style=super,header=none,border=plain,cols=2 & style=superborder\\
style=super,header=plain,border=plain,cols=2 & style=superheaderborder\\
style=super,header=none,border=none,cols=3 & style=super3col\\
style=super,header=plain,border=none,cols=3 & style=super3colheader\\
style=super,header=none,border=plain,cols=3 & style=super3colborder\\
style=super,header=plain,border=plain,cols=3 & style=super3colheaderborder\\
number=none & nonumberlist\\
number=\meta{counter name} & counter=\meta{counter name}\\
toc & toc\\
hypertoc & toc\\
hyper & \emph{no corresponding option}\\
section=true & section\\
section=false & \emph{no corresponding option}\\
acronym & acronym\\
global & \emph{no corresponding option}
\end{tabular}
\end{center}
\end{table}
\section{Defining new glossary types}
If you have created new glossary types, you will need to
replace all instances of
\begin{oldway}
\cs{newglossarytype}\oarg{log-ext}\marg{type}\marg{out-ext}\marg{in-ext}\oarg{style list}\newline
\cs{newcommand}\verb|{\|\meta{type}name\verb|}|\marg{title}
\end{oldway}%
with
\begin{newway}
\cs{newglossary}\oarg{log-ext}\marg{type}\marg{out-ext}\marg{in-ext}\marg{title}
\end{newway}%
in the preamble, and
\begin{newway}
\cs{glossarystyle}\marg{new style}
\end{newway}%
immediately before \verb|\printglossary[type=|\meta{type}\verb|]|,
if the new glossary requires a different style to the main (default)
glossary.
The \meta{style list} optional argument can be converted to
\meta{new style} using the same mapping given in
Table~\ref{tab:pkgopt}.
For example, if your document contains the following:
\begin{verbatim}
\newglossarytype[nlg]{notation}{not}{ntn}[style=long,header]
\newcommand{\notationname}{Index of Notation}
\end{verbatim}
You will need to replace the above two lines with:
\begin{verbatim}
\newglossary[nlg]{notation}{not}{ntn}{Index of Notation}
\end{verbatim}
in the preamble, and
\begin{verbatim}
\glossarystyle{longheader}
\end{verbatim}
immediately prior to displaying this glossary new type.
Alternatively, you can specify the style using the \key{style}
key in the optional argument of \cs{printglossary}. For example:
\begin{verbatim}
\printglossary[type=notation,style=longheader]
\end{verbatim}
Note that the glossary title is no longer specified using
\cs{}\meta{glossary-type}\texttt{name} (except for \cs{glossaryname}
and \cs{acronymname}) but is instead specified in the \meta{title}
argument of \cs{newglossary}. The short title which is specified
in the \sty{glossary} package by the command
\cs{short}\meta{glossary-name}\texttt{name} is now specified
using the \key{toctitle} key in the optional argument to
\cs{printglossary}.
\section{\cs{make}\meta{glossary name}}
All instances of \cs{make}\meta{glossary name} (e.g.\
\cs{makeglossary} and \cs{makeacronym}) should be replaced
by the single command \cs{makeglossaries}. For example, if
your document contained the following:
\begin{verbatim}
\makeglossary
\makeacronym
\end{verbatim}
then you should replace both lines with the single line:
\begin{verbatim}
\makeglossaries
\end{verbatim}
\section{Storing glossary information}
With the old \sty{glossary} package you could optionally store
glossary information for later use, or you could simply use
\cs{glossary} whenever you wanted to add information to the glossary.
With the new \sty{glossaries} package, the latter option is no longer
available.\footnote{mainly because having a key value list in
\cs{glossary} caused problems, but it also helps consistency.} If
you have stored all the glossary information using
\cs{storeglosentry}, then you will need to convert these commands
into the equivalent \cs{newglossaryentry}. If you haven't used
\cs{storeglosentry}, then you'll have a bit more work to do!
The former approach requires substituting all instances of
\begin{oldway}
\cs{storeglosentry}\marg{label}\marg{gls-entry}
\end{oldway}%
with
\begin{newway}
\cs{newglossaryentry}\marg{label}\marg{gls-entry}
\end{newway}%
This should be fairly easy to do using the search and replace
facility in your editor (but see notes below).
If you have used the optional argument of \cs{storeglosentry}
(i.e.\ you have multiple glossaries) then you will need to
substitute
\begin{oldway}
\cs{storeglosentry}\oarg{gls-type}\marg{label}\marg{gls-entry}
\end{oldway}%
with
\begin{newway}
\cs{newglossaryentry}\marg{label}\verb|{|\meta{gls-entry},type=\meta{gls-type}\verb|}|
\end{newway}
The glossary entry information \meta{gls-entry} may also need
changing. If \meta{gls-entry} contains any of \texttt{makeindex}'s
special characters (i.e.\ \texttt{@} \texttt{!} \verb|"| or
\verb"|") then they should no longer be escaped with \verb'"'
since the \sty{glossaries} package deals with these characters
internally. For example, if your document contains the following:
\begin{verbatim}
\storeglosentry{card}{name={$"|\mathcal{S}"|$},
description={The cardinality of the set $\mathcal{S}$}}
\end{verbatim}
then you will need to replace it with:
\begin{verbatim}
\newglossaryentry{card}{name={$|\mathcal{S}|$},
description={The cardinality of the set $\mathcal{S}$}}
\end{verbatim}
The \key{format} and \key{number} keys available in
\cs{storeglosentry} are not available with \cs{newglossaryentry}.
\section{Adding an entry to the glossary}
The \sty{glossary} package provided two basic means to add
information to the glossary: firstly, the term was defined
using \cs{storeglosentry} and the entries for that term were
added using \cs{useglosentry}, \cs{useGlosentry} and \cs{gls}.
Secondly, the term was added to the glossary using \cs{glossary}.
This second approach is unavailable with the \sty{glossaries}
package.
\subsection{\cs{useglosentry}}
\label{sec:useglosentry}
The \sty{glossary} package allows you to add information to the
glossary for a predefined term without producing any text
in the document using
\begin{oldway}
\cs{useglosentry}\oarg{old options}\marg{label}
\end{oldway}%
Any occurrences of this command will need to be replaced with
\begin{newway}
\cs{glsadd}\oarg{new options}\marg{label}
\end{newway}%
The \key{format} key in \meta{old options} remains the same
in \meta{new options}, the \texttt{number=}\meta{counter name}
key in \meta{old options} should be replaced with\linebreak
\texttt{counter=}\meta{counter name} in \meta{new options}.
\subsection{\cs{useGlosentry}}
The \sty{glossary} package allows you to add information to the
glossary for a predefined term with the given text using
\begin{oldway}
\cs{useGlosentry}\oarg{old options}\marg{label}\marg{text}
\end{oldway}%
Any occurrences if this command will need to be replaced with
\begin{newway}
\cs{glslink}\oarg{new options}\marg{label}\marg{text}
\end{newway}%
The mapping from \meta{old options} to \meta{new options} is
the same as that given \latexhtml{section~\ref{sec:useglosentry}
above}{\htmlref{above}{sec:useglosentry}}.
\subsection{\cs{gls}}
Both the \sty{glossary} and the \sty{glossaries} packages define
the command \cs{gls}. In this case, the only thing you need to
change is the \key{number} key in the optional argument
to \key{counter}. Note that the new form of \cs{gls} also takes
a final optional argument which can be used to insert text into the
automatically generated text.
\subsection{\cs{glossary}}
When using the \sty{glossaries} package, you should not use
\cs{glossary} directly.\footnote{This is because \cs{glossary} requires
the argument to be in a specific format and doesn't use the
\meta{key}=\meta{value} format that the old glossary package used. The
new package's internal commands set this format, as well as escaping
any of \texttt{makeindex}'s special characters, so although it is
still possible to use \cs{glossary} with the new package, it's not
recommended. If you persist in using \cs{glossary} with the new
package, don't complain if things go wrong!} If, with the old
package, you have opted to explicitly use \cs{glossary} instead of
storing the glossary information with \cs{storeglosentry}, then
converting from \sty{glossary} to \sty{glossaries} will be more
time-consuming, although in the end, I hope you will see the
benefits!\footnote{From the user's point of view, using \cs{glossary}
throughout the document is time consuming, and if you use it more than
once for the same term, there's a chance extra spaces may creep in
which will cause \texttt{makeindex} to treat the two entries as
different terms, even though they look the same in the document.} If
you have used \cs{glossary} with the old glossary package, you will
instead need to define the relevant glossary terms using
\cs{newglossaryentry} and reference the terms using \cs{glslink},
\cs{gls} (or \cs{glspl} etc).
If you don't like the idea of continually scrolling back to the
preamble to type all your \cs{newglossaryentry} commands, you may
prefer to create a new file, in which to store all these commands,
and then input that file in your document's preamble. Most text
editors and front-ends allow you to have multiple files open, and
you can tab back and forth between them.
\section{Acronyms}
In the \sty{glossary} package, acronyms were treated differently
to glossary entries. This resulted in inconsistencies and sprawling
unmaintainable code. The new \sty{glossaries} package treats
acronyms in exactly the same way as normal glossary terms. In fact,
in the \sty{glossaries} package, the default definition of:
\begin{newway}
\cs{newacronym}\oarg{options}\marg{label}\marg{abbrv}\marg{long}
\end{newway}
is a shortcut for:
\begin{newway}
\cs{newglossaryentry}\marg{label}\{type=\cs{acronymtype},
name=\marg{abbrv},
description=\marg{long},
text=\marg{abbrv},
first=\{\meta{long} (\meta{abbrv})\},
plural=\{\meta{abbrv}s\},
firstplural=\{\meta{long}s (\meta{abbrv}s)\},
\meta{options}\}
\end{newway}
This is different to the \sty{glossary} package which set the
\key{name} key to \meta{long} (\meta{abbrv}) and allowed you
to set a description using the \key{description} key. If you
still want to do this, you can use the \pkgopt{description} package
option, and use the \key{description} key in the
optional argument of \cs{newacronym}.
For example, if your document originally had the following:
\begin{verbatim}
\newacronym{SVM}{Support Vector Machine}{description=Statistical
pattern recognition technique}
\end{verbatim}
Then you would need to load the \sty{glossaries} package using the
\pkgopt{description} package option, for example:
\begin{verbatim}
\usepackage[description]{glossaries}
\end{verbatim}
and change the acronym definition to:
\begin{verbatim}
\newacronym[description=Statistical pattern recognition
technique]{svm}{SVM}{Support Vector Machine}
\end{verbatim}
You will also need to replace all occurrences of \cs{SVM} with
\verb|\gls{svm}|. Alternatively, you can define \cs{SVM}:
\begin{verbatim}
\newcommand{\SVM}{\gls{svm}}
\end{verbatim}
Remember that generally \LaTeX\ ignores all spaces following command
names that consist of a backslash followed by letters! For example,
using the above definition of \cs{SVM}, the following will ignore
the space after \cs{SVM}:
\begin{verbatim}
The \SVM is a statistical pattern recognition technique.
\end{verbatim}
Instead, you need to explicitly insert a space:
\begin{verbatim}
The \SVM\ is a statistical pattern recognition technique.
\end{verbatim}
However, \verb|\SVM['s]| is equivalent to \verb|\gls{svm}['s]|,
so you can do, for example:
\begin{verbatim}
The \SVM['s] parameters are obtained via optimisation techniques.
\end{verbatim}
The \sty{xspace} package provides the command \cs{xspace} which can
be used to insert a space after the command name if required. Some
people prefer to use this at the end of the command definition so
that they don't need to remember to insert an explicit space.
For example, if we use the \sty{xspace} package, we could define
\cs{SVM} as follows:
\begin{verbatim}
\newcommand{\SVM}{\gls{svm}\xspace}
\end{verbatim}
so now the following will have a space before the word \dq{is}:
\begin{verbatim}
The \SVM is a statistical pattern recognition technique.
\end{verbatim}
However, you can no longer do \verb|\SVM['s]|, as the \cs{xspace} is
now in the way.
If you have used \cs{useacronym} instead of \cs{}\meta{acr-name},
then you will need to replace all occurrences of
\begin{oldway}
\cs{useacronym}\oarg{insert}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\cs{gls}\marg{label}\oarg{insert}
\end{newway}%
Note that the starred versions of \cs{useacronym} and
\cs{}\meta{acr-name} (which make the first letter uppercase) should
be replaced with \cs{Gls}\marg{label}.
\subsection{\cs{acrln} and \cs{acrsh}}
In the \sty{glossary} package, it is possible to produce the
long and short forms of an acronym without adding an entry to
the glossary using \cs{acrln} and \cs{acrsh}. With the
\sty{glossaries} package (provided you defined the acronym using
\cs{newacronym} and provided you haven't redefined \cs{newacronym})
you can replace
\begin{oldway}
\cs{acrsh}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\cs{acrshort}\marg{label}
\end{newway}%
and you can replace
\begin{oldway}
\cs{acrln}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\cs{acrlong}\marg{label}
\end{newway}%
The \sty{glossaries} package also provides the related commands
\cs{acrshortpl} (plural short form) and \cs{acrlongpl} (plural long
form) as well as upper case variations.
See
\latexhtml{section~\ref*{sec:code:glslink} (}{the section }\dq{Using
glossary entries in the text}\latex{)} of the \sty{glossaries}
manual for further details of how to use these commands.
\subsection{\cs{ifacronymfirstuse}}
The \sty{glossary} package command
\begin{oldway}
\cs{ifacronymfirstuse}\marg{acr-name}\marg{text1}\marg{text2}
\end{oldway}%
can be replaced by the \sty{glossaries} command:
\begin{newway}
\cs{ifglsused}\marg{label}\marg{text2}\marg{text1}
\end{newway}%
Note that \cs{ifglsused} evaluates the opposite condition to
that of \cs{ifacronymfirstuse} which is why the last two arguments
have been reversed.
\subsection{\cs{resetacronym} and \cs{unsetacronym}}
The \sty{glossary} package allows you to reset and unset the
acronym flag which is used to determine whether the acronym has
been used in the document. The \sty{glossaries} package also
provides a means to do this on either a local or global level.
To reset an acronym, you will need to replace:
\begin{oldway}
\cs{resetacronym}\marg{acr-name}
\end{oldway}%
with either
\begin{newway}
\cs{glsreset}\marg{label}
\end{newway}%
or
\begin{newway}
\cs{glslocalreset}\marg{label}
\end{newway}
To unset an acronym, you will need to replace:
\begin{oldway}
\cs{unsetacronym}\marg{acr-name}
\end{oldway}%
with either
\begin{newway}
\cs{glsunset}\marg{label}
\end{newway}%
or
\begin{newway}
\cs{glslocalunset}\marg{label}
\end{newway}
\section{Displaying the glossary}
The \sty{glossary} package provides the command \cs{printglossary}
(or \cs{print}\meta{type} for other glossary types) which
can be used to print individual glossaries. The \sty{glossaries}
package provides the command \cs{printglossaries} which
will print all the glossaries which have been defined, or
\cs{printglossary}\oarg{options} to print individual glossaries.
So if you just have \cs{printglossary}, then you can leave it as
it is, but if you have, say:
\begin{verbatim}
\printglossary
\printglossary[acronym]
\end{verbatim}
or
\begin{verbatim}
\printglossary
\printacronym
\end{verbatim}
then you will need to either replace this with either
\begin{verbatim}
\printglossaries
\end{verbatim}
or
\begin{verbatim}
\printglossary
\printglossary[type=\acronymtype]
\end{verbatim}
The \sty{glossary} package allows you to specify a short title
(for the table of contents and page header) by defining a command
of the form \cs{short}\meta{glossary-type}\texttt{name}. The
\sty{glossaries} package doesn't do this, but instead provides
the \key{toctitle} key which can be used in the optional
argument to \cs{printglossary}. For example, if you have created
a new glossary type called \texttt{notation}, and you had
defined
\begin{verbatim}
\newcommand{\shortnotationname}{Notation}
\end{verbatim}
then you would need to use the \key{toctitle} key:
\begin{verbatim}
\printglossary[type=notation,toctitle=Notation]
\end{verbatim}
The \sty{glossaries} package will ignore \cs{shortnotationname},
so unless you have used it elsewhere in the document, you may
as well remove the definition.
\section{Using makeindex}
If you convert your document from using the \sty{glossary} package
to the \sty{glossaries} package, you will need to delete any of
the additional files, such as the \texttt{.glo} file, that were
created by the \sty{glossary} package, as the \sty{glossaries}
package uses a different \texttt{makeindex} style file.
Remember also, that if you used the \texttt{makeglos} Perl script,
you will need to use the \texttt{makeglossaries} Perl script
instead.
\section{Troubleshooting}
Please check the \htmladdnormallinkfoot{FAQ}{http://theoval.cmp.uea.ac.uk/~nlct/latex/packages/faq/glossariesfaq.html}
for the \sty{glossaries} package if you have any
problems.
\end{document}
|