\documentclass{nlctdoc}

\usepackage[utf8]{inputenc}
\ifpdf
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{fourier}
\usepackage{mathpazo}
\usepackage[scaled=.88]{helvet}
\usepackage{courier}
\fi
\usepackage{cmap}

\usepackage[colorlinks,
            bookmarks,
            hyperindex=false,
            pdfauthor={Nicola L.C. Talbot},
            pdftitle={Upgrading from the glossary package to 
            the glossaries package}]{hyperref}
\usepackage{xr-hyper}

\newcommand*{\igloskey}[2][newglossaryentry]{\icsopt{#1}{#2}}
\newcommand*{\gloskey}[2][newglossaryentry]{\csopt{#1}{#2}}

\ifpdf
\newcommand{\glsentrytext}[1]{\texttt{#1}}
\externaldocument{glossaries-user}
\fi

\IndexPrologue{\section*{Index}}
\setcounter{IndexColumns}{2}

\title{Upgrading from the glossary package to the glossaries
package}
\author{Nicola L.C. Talbot}
\date{2014-09-01}

\newenvironment{oldway}{%
  \begin{labelledbox}{\styfmt{glossary}}\ttfamily\obeylines
}{%
  \end{labelledbox}%
}

\newenvironment{newway}{%
  \begin{labelledbox}{\styfmt{glossaries}}\ttfamily\obeylines
}{%
  \end{labelledbox}%
}

\begin{document}
\maketitle

\begin{abstract}
The purpose of this document is to provide advice if you want to
convert a \LaTeX\ document from using the obsolete \styfmt{glossary}
package to the replacement \styfmt{glossaries} package.
\end{abstract}

\tableofcontents

\section{Why the Need for a New Package?}
\label{whyglossaries}

The \styfmt{glossary} package started out as an example in a tutorial,
but I decided that I may as well package it up and upload it to CTAN.
Unfortunately it was fairly rigid and unable to adapt well to the
wide variation in glossary styles. Users began making requests for
enhancements, but with each enhancement the code became more
complicated and bugs crept in. Each fix in one place seemed to cause
another problem elsewhere. In the end, it was taking up too much
of my time to maintain, so I decided to replace it with a much
better designed package. With the new \styfmt{glossaries} package:

\begin{itemize}
\item you can define irregular plurals;

\item glossary terms can have an associated symbol in addition
to the name and description;

\item new glossary styles are much easier to design;

\item you can add dictionaries to supply translations for the
fixed names used in headings and by some of the glossary styles;

\item you can choose\footnote{as from v1.17. Previous versions
were designed to be used with \app{makeindex} only} between using
\app{makeindex} or \app{xindy} to sort the glossary. Using
\app{xindy} means that:

  \begin{itemize}
  \item there is much better support for terms containing accented 
  or non-Latin characters;

  \item there is support for non-standard location numbers;
  \end{itemize}

\item you don't need to remember to escape \app{makeindex}'s
special characters as this is done internally;

\item hierarchical entries and homographs are supported;\footnote{as
from v1.17}

\item there is better support for cross-referencing glossary entries;

\item acronyms are just another glossary term which helps to
maintain consistency;

\item different acronym styles are supported.

\end{itemize}

\section{Package Options}

When converting a document that currently uses the obsolete
\styfmt{glossary} package to the replacement \styfmt{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 \styfmt{glossary} 
to the \styfmt{glossaries} package options.

\begin{table}[htbp]
\caption[Mappings]{Mappings from \styfmt{glossary} to \styfmt{glossaries} 
package options}
\label{tab:pkgopt}
\begin{center}
\begin{tabular}{ll}
\bfseries \styfmt{glossary} option & \bfseries \styfmt{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}
\ics{newglossarytype}\oarg{log-ext}\marg{type}\marg{out-ext}\marg{in-ext}\oarg{old style list}\newline
\cs{newcommand}\verb|{\|\meta{type}name\verb|}|\marg{title}
\end{oldway}%
with
\begin{newway}
\ics{newglossary}\oarg{log-ext}\marg{type}\marg{out-ext}\marg{in-ext}\marg{title}
\end{newway}%
in the preamble, and, if the new glossary requires a different style
to the main (default) glossary, you will also need to put
\begin{newway}
\ics{glossarystyle}\marg{new style}
\end{newway}%
immediately before the glossary is displayed, or you can specify
the style when you display the glossary using \ics{printglossary}
(see below). 

The \meta{old 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. Alternatively, you
can specify the style using the \csopt{printglossary}{style} key in
the optional argument of \ics{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 \ics{glossaryname}
and \ics{acronymname}) but is instead specified in the \meta{title}
argument of \ics{newglossary}. The short title which is specified in
the \styfmt{glossary} package by the command
\cs{short}\meta{glossary-name}\texttt{name} is now specified using
the \csopt{printglossary}{toctitle} key in the optional argument to
\ics{printglossary}.

\section{\texorpdfstring{\cs{make}\meta{glossary
name}}{\textbackslash make...}}

All instances of \cs{make}\meta{glossary name} (e.g.\ 
\ics{makeglossary} and \ics{makeacronym}) should be replaced
by the single command \ics{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 \styfmt{glossary} package you could optionally store
glossary information for later use, or you could simply use
\ics{glossary} whenever you wanted to add information to the glossary.
With the new \styfmt{glossaries} package, the latter option is no longer
available.\footnote{mainly because having a key value list in
\ics{glossary} caused problems, but it also helps consistency.}  If
you have stored all the glossary information using
\ics{storeglosentry}, then you will need to convert these commands
into the equivalent \ics{newglossaryentry}. If you have only
used \ics{glossary}, then see \sectionref{sec:csglossary}.

Substitute all instances of
\begin{oldway}
\ics{storeglosentry}\marg{label}\marg{gls-entry}
\end{oldway}%
with
\begin{newway}
\ics{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 \ics{storeglosentry}
(i.e.\ you have multiple glossaries) then you will need to
substitute
\begin{oldway}
\ics{storeglosentry}\oarg{gls-type}\marg{label}\marg{gls-entry}
\end{oldway}%
with
\begin{newway}
\ics{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 \app{makeindex}'s 
special characters (i.e.\ \texttt{@} \texttt{!} \verb|"| or
\verb"|") then they should no longer be escaped with \verb'"'
since the \styfmt{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 \csopt{storeglosentry}{format} and
\csopt{storeglosentry}{number} keys available in \ics{storeglosentry}
are not available with \ics{newglossaryentry}.

\section{Adding an entry to the glossary}

The \styfmt{glossary} package provided two basic means to add
information to the glossary: firstly, the term was defined
using \ics{storeglosentry} and the entries for that term were
added using \ics{useglosentry}, \ics{useGlosentry} and \ics{gls}.
Secondly, the term was added to the glossary using \ics{glossary}.
This second approach is unavailable with the \styfmt{glossaries}
package.

\subsection{\texorpdfstring{\cs{useglosentry}}{\textbackslash
useglosentry}}
\label{sec:useglosentry}

The \styfmt{glossary} package allows you to add information to the
glossary for a predefined term without producing any text in the
document using
\begin{oldway}
\ics{useglosentry}\oarg{old options}\marg{label}
\end{oldway}%
Any occurrences of this command will need to be replaced with
\begin{newway}
\ics{glsadd}\oarg{new options}\marg{label}
\end{newway}%
The \csopt{useglosentry}{format} key in \meta{old options} remains
the same in \meta{new options}. However the
\csopt{useglosentry}{number}\texttt{=}\meta{counter name} key in
\meta{old options} should be replaced with
\csopt{glsadd}{counter}\texttt{=}\meta{counter name} in \meta{new
options}.

\subsection{\texorpdfstring{\cs{useGlosentry}}{\textbackslash
useGlosentry}}

The \styfmt{glossary} package allows you to add information to the
glossary for a predefined term with the given text using
\begin{oldway}
\ics{useGlosentry}\oarg{old options}\marg{label}\marg{text}
\end{oldway}%
Any occurrences of this command will need to be replaced with
\begin{newway}
\ics{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 \sectionref{sec:useglosentry}.

\subsection{\texorpdfstring{\cs{gls}}{\textbackslash gls}}

Both the \styfmt{glossary} and the \styfmt{glossaries} packages define
the command \ics{gls}. In this case, the only thing you need to
change is the \csopt{gls}{number} key in the optional argument
to \csopt{gls}{counter}. Note that the new form of \ics{gls} also takes
a final optional argument which can be used to insert text into the
automatically generated text.

\subsection{\texorpdfstring{\cs{glossary}}{\textbackslash glossary}}
\label{sec:csglossary}

When using the \styfmt{glossaries} package, you should not use
\ics{glossary} directly.\footnote{This is because \ics{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 \app{makeindex}'s or \app{xindy}'s special
characters. What's more, the format has changed as from v1.17 to
allow the new package to be used with either \app{makeindex} or
\app{xindy}.}  If, with the old package, you have opted to
explicitly use \ics{glossary} instead of storing the glossary
information with \ics{storeglosentry}, then converting from
\styfmt{glossary} to \styfmt{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 \ics{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 \app{makeindex} to treat the two entries as different
terms, even though they look the same in the document.}  If you have
used \ics{glossary} with the old glossary package, you will instead
need to define the relevant glossary terms using
\ics{newglossaryentry} and reference the terms using
\ics{glsadd}, \ics{glslink}, \ics{gls} etc.

If you don't like the idea of continually scrolling back to the
preamble to type all your \ics{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 \styfmt{glossary} package, acronyms were treated differently
to glossary entries. This resulted in inconsistencies and sprawling
unmaintainable code. The new \styfmt{glossaries} package treats
acronyms in exactly the same way as normal glossary terms. In fact,
in the \styfmt{glossaries} package, the default definition of:
\begin{newway}
\ics{newacronym}\oarg{options}\marg{label}\marg{abbrv}\marg{long}
\end{newway}
is a shortcut for:
\begin{newway}
\ics{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 \styfmt{glossary} package which set the
\csopt{newglossaryentry}{name} key to \meta{long} (\meta{abbrv}) and
allowed you to set a description using the
\csopt{newglossaryentry}{description} key. If you still want to do
this, you can use the \pkgopt{description} package option, and use
the \csopt{newglossaryentry}{description} key in the optional
argument of \ics{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 \styfmt{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 can then reference the acronym using any of the new referencing
commands, such as \ics{gls} or \ics{glsadd}.

With the old \styfmt{glossary} package, when you defined an
acronym, it also defined a command \cs{}\meta{acr-name} which
could be used to display the acronym in the text. So the
above SVM example would create the command \cs{SVM} with the old
package. In the new \styfmt{glossaries} package, the acronyms are just
another type of glossary entry, so they are displayed using
\ics{gls}\marg{label}.  Therefore, in the above example, you will
also need to replace all occurrences of \cs{SVM} with
\verb|\gls{svm}|.

If you have used \ics{useacronym} instead of \cs{}\meta{acr-name},
then you will need to replace all occurrences of
\begin{oldway}
\ics{useacronym}\oarg{insert}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\ics{gls}\marg{label}\oarg{insert}
\end{newway}%
Note that the starred versions of \ics{useacronym} and
\cs{}\meta{acr-name} (which make the first letter uppercase) should
be replaced with \ics{Gls}\marg{label}.  

Alternatively (as from v1.18 of the \styfmt{glossaries} package),
you can use \ics{oldacronym} which uses the same syntax as
the old \styfmt{glossary} package's \ics{newacronym} and also 
defines \cs{}\meta{acr-name}.
For example, if your document originally had the following:
\begin{oldway}
\begin{verbatim}
\newacronym{SVM}{Support Vector Machine}{description=Statistical
pattern recognition technique}
\end{verbatim}
\end{oldway}
then you can change this to:
\begin{newway}
\begin{verbatim}
\oldacronym{SVM}{Support Vector Machine}{description=Statistical
pattern recognition technique}
\end{verbatim}
\end{newway}
You can then continue to use \cs{SVM}\@. However, remember that
\LaTeX\ generally ignores spaces after command names that consist of
alphabetical characters. You will therefore need to force a space
after \cs{}\meta{acr-name}, unless you also load the \styfmt{xspace}
package. (See 
\xrsectionref{sec:acronyms}{glossaries-user}{Acronyms}
of the \styfmt{glossaries} documentation for further
details.) Note that \ics{oldacronym} uses its first argument to
define the acronym's label (as used by commands like \ics{gls}), so
in the above example, with the new \styfmt{glossaries} package,
\cs{SVM} becomes a shortcut for \verb|\gls{SVM}| and \cs{SVM*}
becomes a shortcut for \verb|\Gls{SVM}|.

\subsection{\texorpdfstring{\cs{acrln} and
\cs{acrsh}}{\textbackslash acrln and \textbackslash acrsh}}

In the \styfmt{glossary} package, it is possible to produce the
long and short forms of an acronym without adding an entry to
the glossary using \ics{acrln} and \ics{acrsh}. With the 
\styfmt{glossaries} package (provided you defined the acronym using
\ics{newacronym} or \ics{oldacronym} and provided you haven't
redefined \ics{newacronym}) 
you can replace
\begin{oldway}
\ics{acrsh}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\ics{acrshort}\marg{label}
\end{newway}%
and you can replace
\begin{oldway}
\ics{acrln}\marg{acr-name}
\end{oldway}%
with
\begin{newway}
\ics{acrlong}\marg{label}
\end{newway}%
The \styfmt{glossaries} package also provides the related commands
\ics{acrshortpl} (plural short form) and \ics{acrlongpl} (plural long
form) as well as upper case variations. If you use the 
\styfmt{glossaries} \qt{shortcuts} package option, you can use
\ics{acs} in place of \ics{acrshort} and \ics{acl} in place of
\ics{acrlong}.

See 
\xrsectionref{sec:acronyms}{glossaries-user}{Acronyms}
of the \styfmt{glossaries} manual for further details of
how to use these commands.

\subsection{\texorpdfstring{\cs{ifacronymfirstuse}}{\textbackslash
ifacronymfirstuse}}

The \styfmt{glossary} package command
\begin{oldway}
\ics{ifacronymfirstuse}\marg{acr-name}\marg{text1}\marg{text2}
\end{oldway}%
can be replaced by the \styfmt{glossaries} command:
\begin{newway}
\ics{ifglsused}\marg{label}\marg{text2}\marg{text1}
\end{newway}%
Note that \ics{ifglsused} evaluates the opposite condition to
that of \ics{ifacronymfirstuse} which is why the last two arguments
have been reversed.

\subsection{\texorpdfstring{\cs{resetacronym} and
\cs{unsetacronym}}{\textbackslash resetacronym and \textbackslash
unsetacronym}}

The \styfmt{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 \styfmt{glossaries} package also
provides a means to do this on either a local or a global level.
To reset an acronym, you will need to replace:
\begin{oldway}
\ics{resetacronym}\marg{acr-name}
\end{oldway}%
with either
\begin{newway}
\ics{glsreset}\marg{label}
\end{newway}%
or
\begin{newway}
\ics{glslocalreset}\marg{label}
\end{newway}

To unset an acronym, you will need to replace:
\begin{oldway}
\ics{unsetacronym}\marg{acr-name}
\end{oldway}%
with either
\begin{newway}
\ics{glsunset}\marg{label}
\end{newway}%
or
\begin{newway}
\ics{glslocalunset}\marg{label}
\end{newway}

To reset all acronyms, you will need to replace:
\begin{oldway}
\ics{resetallacronyms}
\end{oldway}
with
\begin{newway}
\ics{glsresetall}[\ics{acronymtype}]
\end{newway}
or
\begin{newway}
\ics{glslocalresetall}[\ics{acronymtype}]
\end{newway}
To unset all acronyms, you will need to replace:
\begin{oldway}
\ics{unsetallacronyms}
\end{oldway}
with
\begin{newway}
\ics{glsunsetall}[\ics{acronymtype}]
\end{newway}
or
\begin{newway}
\ics{glslocalunsetall}[\ics{acronymtype}]
\end{newway}

\section{Displaying the glossary}

The \styfmt{glossary} package provides the command \ics{printglossary}
(or \cs{print}\meta{type} for other glossary types) which
can be used to print individual glossaries. The \styfmt{glossaries}
package provides the command \ics{printglossaries} which 
will print all the glossaries which have been defined, or
\ics{printglossary}\oarg{options} to print individual glossaries.
So if you just have \ics{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 replace this with either
\begin{verbatim}
\printglossaries
\end{verbatim}
or 
\begin{verbatim}
\printglossary
\printglossary[type=\acronymtype]
\end{verbatim}

The \styfmt{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
\styfmt{glossaries} package doesn't do this, but instead provides
the \csopt{printglossary}{toctitle} key which can be used in the
optional argument to \ics{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 \csopt{printglossary}{toctitle} key:
\begin{verbatim}
\printglossary[type=notation,toctitle=Notation]
\end{verbatim}
The \styfmt{glossaries} package will ignore \ics{shortnotationname},
so unless you have used it elsewhere in the document, you may as
well remove the definition.

\section{Processing Your Document}

If you convert your document from using the \styfmt{glossary} package
to the \styfmt{glossaries} package, you will need to delete any of
the additional files, such as the \filetype{.glo} file, that were
created by the \styfmt{glossary} package, as the \styfmt{glossaries}
package uses a different format. 
Remember also, that if you used the \app{makeglos} Perl script,
you will need to use the \app{makeglossaries} Perl script 
instead. As from v1.17, the \styfmt{glossaries} package can be
used with either \app{makeindex} or \app{xindy}. Since
\app{xindy} was designed to be multilingual, the 
new \styfmt{glossaries} package is a much better option for 
non-English documents.

For further information on using \app{makeglossaries},
\app{makeindex} or \app{xindy} to create your glossaries, see
\xrsectionref{sec:makeglossaries}{glossaries-user}{Generating the
Associated Glossary Files}
of the \styfmt{glossaries} documentation.

\section{Troubleshooting}

Please check the \urlfootref{http://www.dickimaw-books.com/faqs/glossariesfaq.html}{FAQ} 
for the \styfmt{glossaries} package if you have any
problems.

\PrintIndex

\end{document}
