%\iffalse
% glossaries.dtx generated using makedtx version 0.94b (c) Nicola Talbot
% Command line args:
%   -macrocode ".*\.perl"
%   -macrocode ".*\.tex"
%   -macrocode ".*\.xdy"
%   -setambles ".*\.perl=>\nopreamble\nopostamble"
%   -setambles ".*\.tex=>\nopreamble\nopostamble"
%   -setambles ".*\.xdy=>\nopreamble\nopostamble"
%   -comment ".*\.perl"
%   -comment ".*\.tex"
%   -comment ".*\.xdy"
%   -src "glossaries.sty\Z=>glossaries.sty"
%   -src "mfirstuc.sty\Z=>mfirstuc.sty"
%   -src "(glossary-.+)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-compatible-207)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-accsupp)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-babel)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-polyglossia)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-dictionary-.+)\.(dict)\Z=>\1.\2"
%   -src "(minimalgls\.tex)\Z=>\1"
%   -src "(sample.*\.tex)\Z=>\1"
%   -src "(samplexdy-mc.*\.xdy)\Z=>\1"
%   -src "(database.*\.tex)\Z=>\1"
%   -src "(.*\.perl)\Z=>\1"
%   -doc "glossaries-manual.tex"
%   -author "Nicola Talbot"
%   -codetitle "Main Package Code"
%   glossaries
% Created on 2012/11/18 20:04
%\fi
%\iffalse
%<*package>
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%</package>
%\fi
% \iffalse
% Doc-Source file to use with LaTeX2e
% Copyright (C) 2012 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
\documentclass{nlctdoc}

\iffalse
glossaries-manual.tex is a stub file used by makedtx to create
glossaries.dtx
\fi

\RecordChanges

\usepackage{alltt}
\usepackage{pifont}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[colorlinks,
            bookmarks,
            hyperindex=false,
            pdfauthor={Nicola L.C. Talbot},
            pdftitle={glossaries.sty: LaTeX2e Package to Assist Generating Glossaries},
            pdfkeywords={LaTeX,package,glossary,acronyms}]{hyperref}
\usepackage[toc]{glossaries}

\makeglossaries

\renewcommand*{\main}[1]{\hyperpage{#1}}
\newcommand*{\htextbf}[1]{\textbf{\hyperpage{#1}}}
\newcommand*{\itermdef}[1]{\index{#1|htextbf}}

\newglossaryentry{xindy}{
  name={\appfmt{xindy}\index{xindy|htextbf}},
  sort={xindy},
  text={\protect\app{xindy}},
  description={An flexible indexing application with multilingual
  support written in Perl}
}

\newglossaryentry{makeindex}{%
  name={\appfmt{makeindex}\index{makeindex|htextbf}},%
  sort={makeindex},%
  text={\protect\app{makeindex}},%
  description={An indexing application},
}

\let\glsd\glsuseri
\let\glsation\glsuserii

\newglossaryentry{firstuse}{%
  name={First use\ifirstuse},
  sort={first use},%
  text={first use},%
  user1={first used},
  description={The first time a glossary entry is used (from the start
  of the document or after a reset) with one of the
  following commands: \ics{gls}, \ics{Gls}, \ics{GLS}, \ics{glspl},
  \ics{Glspl}, \ics{GLSpl} or \ics{glsdisp}.
  \glsseeformat{firstuseflag,firstusetext}{}\nopostdesc}%
}

\newglossaryentry{firstuseflag}{%
name={First use flag\ifirstuseflag},
sort={first use flag},%
text={first use flag},%
description={A conditional that determines whether or not the entry
has been used according to the rules of \gls{firstuse}}%
}

\newglossaryentry{firstusetext}{%
name={First use text\ifirstusetext},
sort={first use text},%
text={first use text},%
description={The text that is displayed on \gls{firstuse}, which is
governed by the \gloskey{first} and \gloskey{firstplural} keys of
\ics{newglossaryentry}. (May be overridden by
\ics{glsdisp}.)\nopostdesc}%
}

\doxitem{Option}{option}{package options}
\doxitem{GlsKey}{key}{glossary keys}
\doxitem{Style}{style}{glossary styles}
\doxitem{Counter}{counter}{glossary counters}

\setcounter{IndexColumns}{2}

\CheckSum{13982}

\newcommand*{\ifirstuse}{\iterm{first use}}
\newcommand*{\firstuse}{\gls{firstuse}}
\newcommand*{\firstuseflag}{\gls{firstuseflag}}
\newcommand*{\firstusetext}{\gls{firstusetext}}

\newcommand*{\ifirstuseflag}{\iterm{first use>flag}}
\newcommand*{\ifirstusetext}{\iterm{first use>text}}

\newcommand*{\istkey}[1]{\appfmt{#1}\index{makeindex=\appfmt{makeindex}>#1=\texttt{#1}|hyperpage}}
\newcommand*{\locfmt}[1]{\texttt{#1}\SpecialMainIndex{#1}}
\newcommand*{\mkidxspch}{\index{makeindex=\appfmt{makeindex}>special characters|hyperpage}}

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

\newcommand*{\glostyle}[1]{\textsf{#1}\index{glossary styles:>#1={\protect\ttfamily#1}|main}}


\begin{document}
\DocInput{glossaries.dtx}
\end{document}
%</driver>
%\fi
%\MakeShortVerb{"}
%\DeleteShortVerb{\|}
%
% \title{Documented Code For glossaries v3.04}
% \author{Nicola L.C. Talbot\\[10pt]
%Dickimaw Books\\
%\url{http://www.dickimaw-books.com/}}
%
% \date{2012-11-18}
% \maketitle
%
%This is the documented code for the \styfmt{glossaries} package.
%This bundle comes with the following documentation:
%\begin{description}
%\item[\url{glossariesbegin.pdf}] 
%If you are a complete beginner, start with \qt{The glossaries
%package: a guide for beginners}.
%
%\item[\url{glossary2glossaries.pdf}] 
%If you are moving over from the obsolete \sty{glossary} package, 
%read \qt{Upgrading from the glossary package to the
%glossaries package}.
%
%\item[\url{glossaries-user.pdf}]
%For the main user guide, read \qt{glossaries.sty v3.04:
%\LaTeX2e\ Package to Assist Generating Glossaries}.
%
%\item[\url{mfirstuc-manual.pdf}]
%The commands provided by the \sty{mfirstuc} package are briefly
%described in \qt{mfirstuc.sty: uppercasing first letter}.
%
%\item[glossaries.pdf]
%This document is for advanced users wishing to know more about the
%inner workings of the \styfmt{glossaries} package.
%
%\item[INSTALL] Installation instructions.
%
%\item[CHANGES] Change log.
%
%\item[README] Package summary.
%
%\end{description}
%
%\clearpage
%\tableofcontents
%
%\StopEventually{%
%  \printglossaries
%  \phantomsection
%  \addcontentsline{toc}{section}{Change History}%
%  \PrintChanges
%  \clearpage\phantomsection
%  \addcontentsline{toc}{section}{Index}\PrintIndex
%}
%
%
%
%\section{Main Package Code}
%\iffalse
%    \begin{macrocode}
%<*glossaries.sty>
%    \end{macrocode}
%\fi
%\label{sec:code}
% \subsection{Package Definition}
% This package requires \LaTeXe.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries}[2012/11/18 v3.04 (NLCT)]
%    \end{macrocode}
% Required packages:
%    \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{xkeyval}[2006/11/18]
\RequirePackage{mfirstuc}
\RequirePackage{xfor}
%    \end{macrocode}
%\changes{3.04}{2012-11-18}{added datatool-base as a required
%package}
%    \begin{macrocode}
\RequirePackage{datatool-base}
%    \end{macrocode}
%\changes{1.1}{2008 Feb 22}{amsgen now loaded (\cs{new@ifnextchar} needed)}
% Need to use \cs{new@ifnextchar} instead of \cs{@ifnextchar} in 
% commands that have a final optional argument (such as \ics{gls})
% so require \isty{amsgen}.
% Thanks to Morten~H\o gholm for suggesting this. (This has
% replaced using the \sty{xspace} package.)
%    \begin{macrocode}
\RequirePackage{amsgen}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{etoolbox now loaded}
% As from v3.0, now loading \sty{etoolbox}:
%    \begin{macrocode}
\RequirePackage{etoolbox}
%    \end{macrocode}
%\changes{3.04}{2012-11-18}{Added check for doc package}
% Check if \sty{doc} has been loaded.
%\begin{macro}{\if@gls@docloaded}
%    \begin{macrocode}
\newif\if@gls@docloaded
\@ifpackageloaded{doc}%
{%
  \@gls@docloadedtrue
}%
{%
  \@ifclassloaded{nlctdoc}{\@gls@docloadedtrue}{\@gls@docloadedfalse}%
}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
\if@gls@docloaded
%    \end{macrocode}
% It has been loaded, so some modifications need to be made to
% ensure both packages can work together.
%\begin{macro}{\glsorg@glossary}
%\changes{3.04}{2012-11-18}{new}
% First, save the original behaviour of \cs{glossary}
%    \begin{macrocode}
  \newcommand{\glsorg@glossary}{%
    \@bsphack
      \begingroup
        \@sanitize \glsorg@wrglossary
  }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsorg@wrglossary}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
  \newcommand{\glsorg@wrglossary}[1]{%
        \protected@write\@glossaryfile{}{%
          \string \glossaryentry{#1}{\thepage}}%
      \endgroup
    \@esphack
  }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\changes}
%\changes{3.04}{2012-11-18}{new}
% Now we need to redefine \cs{changes} so that it uses the original
% definition of \cs{glossary}.
%    \begin{macrocode}
  \let\glsorg@changes\changes
  \renewcommand{\changes}[3]{%
    \begingroup
      \let\glossary\glsorg@glossary
      \glsorg@changes{#1}{#2}{#3}%
    \endgroup
  }
%    \end{macrocode}
%\end{macro}
%\cs{PrintChanges} needs to use \sty{doc}'s version of
%\env{theglossary}, so save that.
%\begin{macro}{\glsorg@theglossary}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
  \let\glsorg@theglossary\theglossary
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsorg@endtheglossary}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
  \let\glsorg@endtheglossary\endtheglossary
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\PrintChanges}
% Now redefine \cs{PrintChanges} so that it uses the original
% \env{theglossary} environment.
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
  \let\glsorg@PrintChanges\PrintChanges
  \renewcommand{\PrintChanges}{%
    \begingroup
      \let\theglossary\glsorg@theglossary
      \let\endtheglossary\glsorg@endtheglossary
      \glsorg@PrintChanges
    \endgroup
  }
%    \end{macrocode}
%\end{macro}
% End of doc stuff.
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
% \subsection{Package Options}\label{sec:pkgopt}
%\begin{option}{toc}
% The \pkgopt{toc} package option will add the glossaries 
% to the table of contents. This is a boolean key, if the
% value is omitted it is taken to be true.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{toc}[true]{}
%    \end{macrocode}
%\end{option}
%\begin{option}{numberline}
%\changes{1.1}{2008 Feb 22}{numberline option added}
% The \pkgopt{numberline} package option adds \cs{numberline} to
% \cs{addcontentsline}. Note that this option only has an effect
% if used in with \pkgopt[true]{toc}.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{numberline}[true]{}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@@glossarysec}
% The sectional unit used to start the glossary is stored in
% \cs{@@glossarysec}. If chapters are defined, this
% is initialised to \texttt{chapter}, otherwise it is
% initialised to \texttt{section}.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{chapter}%
  {\newcommand*{\@@glossarysec}{section}}%
  {\newcommand*{\@@glossarysec}{chapter}}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{section}
% The \pkgopt{section} key can be used to set the sectional unit.
% If no unit is specified, use \texttt{section} as the default.
% The starred form of the named sectional unit will be used.
% If you want some other way to start the glossary section (e.g.\ 
% a numbered section) you will have to redefined 
% \ics{glossarysection}.
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{section}{part,chapter,section,%
subsection,subsubsection,paragraph,subparagraph}[section]{%
  \renewcommand*{\@@glossarysec}{#1}}
%    \end{macrocode}
%\end{option}
%
% Determine whether or not to use numbered sections.
%\begin{macro}{\@@glossarysecstar}
%    \begin{macrocode}
\newcommand*{\@@glossarysecstar}{*}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@@glossaryseclabel}
%    \begin{macrocode}
\newcommand*{\@@glossaryseclabel}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsautoprefix}
% Prefix to add before label if automatically generated:
%\changes{1.14}{2008 June 17}{new}
%    \begin{macrocode}
\newcommand*{\glsautoprefix}{}
%    \end{macrocode}
%\end{macro}
%\begin{option}{numberedsection}
%\changes{1.1}{2008 Feb 22}{numberedsection package option added}
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{numberedsection}[\val\nr]{%
false,nolabel,autolabel}[nolabel]{%
  \ifcase\nr\relax
    \renewcommand*{\@@glossarysecstar}{*}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{%
      \label{\glsautoprefix\@glo@type}}%
  \fi
}
%    \end{macrocode}
%\end{option}
%
% The default glossary style is stored in 
% \cs{@glossary@default@style}. This is initialised to
% \texttt{list}. (The \glostyle{list} style is
% defined in the accompanying \isty{glossary-list} package
% described in \autoref{sec:code:styles}.)
%\begin{macro}{\@glossary@default@style}
%    \begin{macrocode}
\newcommand*{\@glossary@default@style}{list}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{style}
% The default glossary style can be changed using the \pkgopt{style}
% package option. The value can be the name of any
% defined glossary style. The glossary style is set at the beginning
% of the document, so you can still use the \pkgopt{style} key to
% set a style that is defined in another package. This package comes
% with some predefined styles that are defined in 
% \autoref{sec:code:styles}.
%    \begin{macrocode}
\define@key{glossaries.sty}{style}{%
\renewcommand*{\@glossary@default@style}{#1}}
%    \end{macrocode}
%\end{option}
%
% Each entry within a given glossary will have an associated
% number list. By default, this refers to the page numbers on
% which that entry has been used, but it can also refer to any counter
% used in the document (such as the section or equation counters).
% The default number list format displays the number list ``as is'':
%\begin{macro}{\glossaryentrynumbers}
%    \begin{macrocode}
\newcommand*{\glossaryentrynumbers}[1]{#1\gls@save@numberlist{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{option}{nonumberlist}
% Note that the entire number list for a given entry will be
% passed to \cs{glossaryentrynumbers} so any font changes
% will also be applied to the delimiters.
% The \pkgopt{nonumberlist} package option suppresses the 
% number lists (this simply redefines 
% \cs{glossaryentrynumbers} to ignores its argument).
%    \begin{macrocode}
\DeclareOptionX{nonumberlist}{%
  \renewcommand*{\glossaryentrynumbers}[1]{\gls@save@numberlist{#1}}%
}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{savenumberlist}
%\changes{3.02}{2012/05/21}{new}
% Provide means to store the number list for entries.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{savenumberlist}[true]{}
\glssavenumberlistfalse
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@glo@seeautonumberlist}
%    \begin{macrocode}
\newcommand*\@glo@seeautonumberlist{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{seeautonumberlist}
% Automatically activates number list for entries containing the
% \gloskey{see} key.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\DeclareOptionX{seeautonumberlist}{%
   \renewcommand*{\@glo@seeautonumberlist}{%
      \def\@glo@prefix{\glsnextpages}%
   }%
}
%    \end{macrocode}
%\end{option}
%\begin{macro}{\@gls@loadlong}
%\changes{1.18}{2009 January 14}{new}
%    \begin{macrocode}
\newcommand*{\@gls@loadlong}{\RequirePackage{glossary-long}}
%    \end{macrocode}
%\end{macro}
%\begin{option}{nolong}
%\changes{1.18}{2009 January 14}{new}
% This option prevents \isty{glossary-long} from being loaded.
% This means that the glossary styles that use the 
% \env{longtable} environment will not be available. This option
% is provided to reduce overhead caused by loading unrequired
% packages.
%    \begin{macrocode}
\DeclareOptionX{nolong}{\renewcommand*{\@gls@loadlong}{}}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@loadsuper}
%\changes{1.18}{2009 January 14}{new}
% The \isty{glossary-super} package isn't loaded if
% \isty{supertabular} isn't installed.
%    \begin{macrocode}
\IfFileExists{supertabular.sty}{%
  \newcommand*{\@gls@loadsuper}{\RequirePackage{glossary-super}}}{%
  \newcommand*{\@gls@loadsuper}{}}
%    \end{macrocode}
%\end{macro}
%\begin{option}{nosuper}
%\changes{1.18}{2009 January 14}{new}
% This option prevents \isty{glossary-super} from being loaded.
% This means that the glossary styles that use the 
% \env{supertabular} environment will not be available. This option
% is provided to reduce overhead caused by loading unrequired
% packages.
%    \begin{macrocode}
\DeclareOptionX{nosuper}{\renewcommand*{\@gls@loadsuper}{}}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@loadlist}
%\changes{1.18}{2009 January 14}{new}
%    \begin{macrocode}
\newcommand*{\@gls@loadlist}{\RequirePackage{glossary-list}}
%    \end{macrocode}
%\end{macro}
%\begin{option}{nolist}
%\changes{1.18}{2009 January 14}{new}
% This option prevents \isty{glossary-list} from being loaded
% (to reduce overheads if required). Naturally, the styles defined
% in \isty{glossary-list} will not be available if this option
% is used.
%    \begin{macrocode}
\DeclareOptionX{nolist}{\renewcommand*{\@gls@loadlist}{}}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@loadtree}
%\changes{1.18}{2009 January 14}{new}
%    \begin{macrocode}
\newcommand*{\@gls@loadtree}{\RequirePackage{glossary-tree}}
%    \end{macrocode}
%\end{macro}
%\begin{option}{notree}
%\changes{1.18}{2009 January 14}{new}
% This option prevents \isty{glossary-tree} from being loaded
% (to reduce overheads if required). Naturally, the styles defined
% in \isty{glossary-tree} will not be available if this option
% is used.
%    \begin{macrocode}
\DeclareOptionX{notree}{\renewcommand*{\@gls@loadtree}{}}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{nostyles}
%\changes{1.18}{2009 January 14}{new}
% Provide an option to suppress all the predefined styles (in the
% event that the user has custom styles that are not dependent
% on the predefined styles).
%    \begin{macrocode}
\DeclareOptionX{nostyles}{%
  \renewcommand*{\@gls@loadlong}{}%
  \renewcommand*{\@gls@loadsuper}{}%
  \renewcommand*{\@gls@loadlist}{}%
  \renewcommand*{\@gls@loadtree}{}%
  \let\@glossary@default@style\relax
}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\glspostdescription}
% The description terminator is given by \cs{glspostdescription}
% (except for the 3 and 4 column styles). This is a full stop
% by default:
%    \begin{macrocode}
\newcommand*{\glspostdescription}{\ifglsnopostdot\else.\fi}
%    \end{macrocode}
%\end{macro}
%\begin{option}{nopostdot}
% Boolean option to suppress post description dot
%\changes{3.03}{2012/09/21}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{nopostdot}[true]{}
\glsnopostdotfalse
%    \end{macrocode}
%\end{option}
%\begin{option}{nogroupskip}
% Boolean option to suppress vertical space between groups in the
% pre-defined styles.
%\changes{3.03}{2012/09/21}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{nogroupskip}[true]{}
\glsnogroupskipfalse
%    \end{macrocode}
%\end{option}
%
%\begin{option}{ucmark}
% Boolean option to determine whether or not to use
% \ics{MakeUppercase} in definition of \ics{glossarymark}
%\changes{3.02}{2012/05/21}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{ucmark}[true]{}
\glsucmarkfalse
%    \end{macrocode}
%\end{option}
%
%\begin{option}{entrycounter}
% Defines a counter that can be used in the standard glossary styles
% to number each (main) entry. If true, this will define a counter called
% \ctr{glossaryentry}.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{entrycounter}[true]{}
\glsentrycounterfalse
%    \end{macrocode}
%\end{option}
%
%\begin{option}{entrycounterwithin}
% This option can be used to set a parent counter for
% \ctr{glossaryentry}. This option automatically sets
% \pkgopt[true]{entrycounter}.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\define@key{glossaries.sty}{counterwithin}{%
  \renewcommand*{\@gls@counterwithin}{#1}%
  \glsentrycountertrue
}
%    \end{macrocode}
%\end{option}
%\begin{macro}{\@gls@counterwithin}
%\changes{3.0}{2011/04/02}{new}
% The default value is no parent counter:
%    \begin{macrocode}
\newcommand*{\@gls@counterwithin}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{subentrycounter}
% Define a counter that can be used in the standard glossary styles
% to number each level~1 entry. If true, this will define a counter called
% \ctr{glossarysubentry}.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{subentrycounter}[true]{}
\glssubentrycounterfalse
%    \end{macrocode}
%\end{option}
%
%\begin{option}{sort}
%\changes{3.0}{2011/04/02}{new}
% Define the sort method: \pkgopt[standard]{sort} (default),
% \pkgopt[def]{sort} (order of definition) or
% \pkgopt[use]{sort} (order of use).
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{sort}{standard,def,use}{%
  \csname @gls@setupsort@#1\endcsname
}
%    \end{macrocode}
%\end{option}
%\begin{macro}{\@gls@setupsort@standard}
%\changes{3.0}{2011/04/02}{new}
% Set up the macros for default sorting.
%    \begin{macrocode}
\newcommand*{\@gls@setupsort@standard}{%
%    \end{macrocode}
% Store entry information when it's defined.
%    \begin{macrocode}
  \def\do@glo@storeentry{\@glo@storeentry}%
%    \end{macrocode}
% No count register required for standard sort.
%    \begin{macrocode}
  \def\@gls@defsortcount##1{}%
%    \end{macrocode}
% Sort according to sort key (\cs{@glo@sort}) if provided otherwise 
% sort according to the entry's name (\cs{@glo@name}).
%    \begin{macrocode}
  \def\@gls@defsort##1##2{%
    \ifx\@glo@sort\@glsdefaultsort
      \let\@glo@sort\@glo@name
    \fi
%    \end{macrocode}
%\changes{3.03}{2012/09/21}{used \cs{@gls@sanitizesort}}
%    \begin{macrocode}
    \@gls@sanitizesort
    \expandafter\protected@xdef\csname glo@##2@sort\endcsname{\@glo@sort}%
  }%
%    \end{macrocode}
% Don't need to do anything when the entry is used.
%    \begin{macrocode}
  \def\@gls@setsort##1{}%
}
%    \end{macrocode}
% Set standard sort as the default:
%    \begin{macrocode}
\@gls@setupsort@standard
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssortnumberfmt}
%\changes{3.0}{2011/04/02}{new}
% Format the number used as the sort key by \pkgopt[def]{sort} and
% \pkgopt[use]{sort}. Defaults to six digit numbering.
%    \begin{macrocode}
\newcommand*\glssortnumberfmt[1]{%
  \ifnum#1<100000 0\fi
  \ifnum#1<10000 0\fi
  \ifnum#1<1000 0\fi
  \ifnum#1<100 0\fi
  \ifnum#1<10 0\fi
  \number#1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@setupsort@def}
%\changes{3.0}{2011/04/02}{new}
% Set up the macros for order of definition sorting.
%    \begin{macrocode}
\newcommand*{\@gls@setupsort@def}{%
%    \end{macrocode}
% Store entry information when it's defined.
%    \begin{macrocode}
  \def\do@glo@storeentry{\@glo@storeentry}%
%    \end{macrocode}
% Defined count register associated with the glossary.
%    \begin{macrocode}
  \def\@gls@defsortcount##1{%
    \expandafter\global
    \expandafter\newcount\csname glossary@##1@sortcount\endcsname
  }%
%    \end{macrocode}
% Increment count register associated with the glossary and use as
% the sort key.
%    \begin{macrocode}
  \def\@gls@defsort##1##2{%
    \expandafter\global\expandafter
    \advance\csname glossary@##1@sortcount\endcsname by 1\relax
    \expandafter\protected@xdef\csname glo@##2@sort\endcsname{%
       \expandafter\glssortnumberfmt
         {\csname glossary@##1@sortcount\endcsname}}%
  }%
%    \end{macrocode}
% Don't need to do anything when the entry is used.
%    \begin{macrocode}
  \def\@gls@setsort##1{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@setupsort@use}
%\changes{3.0}{2011/04/02}{new}
% Set up the macros for order of use sorting.
%    \begin{macrocode}
\newcommand*{\@gls@setupsort@use}{%
%    \end{macrocode}
% Don't store entry information when it's defined.
%    \begin{macrocode}
  \let\do@glo@storeentry\@gobble
%    \end{macrocode}
% Defined count register associated with the glossary.
%    \begin{macrocode}
  \def\@gls@defsortcount##1{%
    \expandafter\global
    \expandafter\newcount\csname glossary@##1@sortcount\endcsname
  }%
%    \end{macrocode}
% Initialise the sort key to empty.
%    \begin{macrocode}
  \def\@gls@defsort##1##2{%
    \expandafter\gdef\csname glo@##2@sort\endcsname{}%
  }%
%    \end{macrocode}
% If the sort key hasn't been set, increment the counter associated
% with the glossary and set the sort key.
%    \begin{macrocode}
  \def\@gls@setsort##1{%
%    \end{macrocode}
% Get the parent, if one exists
%    \begin{macrocode}
    \edef\@glo@parent{\csname glo@##1@parent\endcsname}%
%    \end{macrocode}
% Set the information for the parent entry if not already done.
%    \begin{macrocode}
    \ifx\@glo@parent\@empty
    \else
      \expandafter\@gls@setsort\expandafter{\@glo@parent}%
    \fi
%    \end{macrocode}
% Set index information for this entry
%    \begin{macrocode}
    \edef\@glo@type{\csname glo@##1@type\endcsname}%
    \edef\@gls@tmp{\csname glo@##1@sort\endcsname}%
    \ifx\@gls@tmp\@empty
      \expandafter\global\expandafter
      \advance\csname glossary@\@glo@type @sortcount\endcsname by 1\relax
      \expandafter\protected@xdef\csname glo@##1@sort\endcsname{%
         \expandafter\glssortnumberfmt
           {\csname glossary@\@glo@type @sortcount\endcsname}}%
      \@glo@storeentry{##1}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdefmain}
%\changes{2.01}{2009 May 30}{new}
%\changes{3.04}{2012-11-18}{added check for doc package}
% Define the main glossary. This will be the first glossary to
% be displayed when using \ics{printglossaries}. The default
% extensions conflict if used with \sty{doc}, so provide different
% extensions if \sty{doc} loaded. (If these extensions are
% inappropriate, use \pkgopt{nomain} and manually define the main
% glossary with the desired extensions.)
%    \begin{macrocode}
\newcommand*{\glsdefmain}{%
  \if@gls@docloaded
    \newglossary[glg2]{main}{gls2}{glo2}{\glossaryname}%
  \else
    \newglossary{main}{gls}{glo}{\glossaryname}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
% Keep track of the default glossary. This is initialised to
% the main glossary, but can be changed if for some reason
% you want to make a secondary glossary the main glossary. This
% affects any commands that can optionally take a glossary name
% as an argument (or as the value of the 
% \gloskey{type}\igloskey[printglossary]{type} key in 
%a key-value list). This was mainly done so that 
% \ics{loadglsentries} can temporarily change 
% \cs{glsdefaulttype} while it loads a file containing
% new glossary entries (see \autoref{sec:load}).
%\begin{macro}{\glsdefaulttype}
%    \begin{macrocode}
\newcommand*{\glsdefaulttype}{main}
%    \end{macrocode}
%\end{macro}
% Keep track of which glossary the acronyms are in. This is 
% initialised to \cs{glsdefaulttype}, but is changed by
% the \pkgopt{acronym} package option.
%\begin{macro}{\acronymtype}
%    \begin{macrocode}
\newcommand*{\acronymtype}{\glsdefaulttype}
%    \end{macrocode}
%\end{macro}
%
%\changes{2.01}{2009 May 30}{added nomain package option}
% The \pkgopt{nomain} option suppress the creation of the main 
% glossary.
%    \begin{macrocode}
\DeclareOptionX{nomain}{%
   \let\glsdefaulttype\relax
   \renewcommand*{\glsdefmain}{}%
}
%    \end{macrocode}
%
%\begin{option}{acronym}
% The \pkgopt{acronym} option sets an associated conditional 
% which is used in \autoref{sec:acronym} to determine whether
% or not to define a separate glossary for acronyms.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{acronym}[true]{%
  \DeclareAcronymList{acronym}%
}
%    \end{macrocode}
%\end{option}
%\begin{macro}{\@glsacronymlists}
%\changes{2.04}{2009 November 10}{new}
% Comma-separated list of glossary labels indicating which 
% glossaries contain acronyms. Note that \ics{SetAcronymStyle}
% must be used after adding labels to this macro.
%    \begin{macrocode}
\newcommand*{\@glsacronymlists}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@addtoacronynlists}
%    \begin{macrocode}
\newcommand*{\@addtoacronymlists}[1]{%
  \ifx\@glsacronymlists\@empty
    \protected@xdef\@glsacronymlists{#1}%
  \else
    \protected@xdef\@glsacronymlists{\@glsacronymlists,#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DeclareAcronymList}
%\changes{2.04}{2009 November 10}{new}%
% Identifies the named glossary as a list of acronyms and adds
% to the list. (Doesn't check if the glossary exists, but checks
% if label already in list. Use \ics{SetAcronymStyle} after
% identifying all the acronym lists.)
%    \begin{macrocode}
\newcommand*{\DeclareAcronymList}[1]{%
  \glsIfListOfAcronyms{#1}{}{\@addtoacronymlists{#1}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsIfListOfAcronyms}
%\cs{glsIfListOfAcronyms}\marg{label}\marg{true part}\marg{false part}\\[10pt]
% Determines if the glossary with the given label has been identified
% as being a list of acronyms.
%    \begin{macrocode}
\newcommand{\glsIfListOfAcronyms}[1]{%
  \edef\@do@gls@islistofacronyms{%
    \noexpand\@gls@islistofacronyms{#1}{\@glsacronymlists}}%
  \@do@gls@islistofacronyms
}
%    \end{macrocode}
% Internal command requires label and list to be expanded:
%    \begin{macrocode}
\newcommand{\@gls@islistofacronyms}[4]{%
  \def\gls@islistofacronyms##1,#1,##2\end@gls@islistofacronyms{%
     \def\@before{##1}\def\@after{##2}}%
  \gls@islistofacronyms,#2,#1,\@nil\end@gls@islistofacronyms
  \ifx\@after\@nnil
%    \end{macrocode}
% Not found
%    \begin{macrocode}
    #4%
  \else
%    \end{macrocode}
% Found
%    \begin{macrocode}
    #3%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\if@glsisacronymlist}
% Convenient boolean.
%    \begin{macrocode}
\newif\if@glsisacronymlist
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@checkisacronymlist}
% Sets the above boolean if argument is a label representing 
% a list of acronyms.
%    \begin{macrocode}
\newcommand*{\gls@checkisacronymlist}[1]{%
   \glsIfListOfAcronyms{#1}%
     {\@glsisacronymlisttrue}{\@glsisacronymlistfalse}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetAcronymLists}
%\changes{2.04}{2009 November 10}{new}%
% Sets the ``list of acronyms'' list. Argument must be a
% comma-separated list of glossary labels. (Doesn't check at this
% point if the glossaries exists.)
%    \begin{macrocode}
\newcommand*{\SetAcronymLists}[1]{%
  \renewcommand*{\@glsacronymlists}{#1}%
}
%    \end{macrocode}
%\end{macro}
%\begin{option}{acronymlists}
%\changes{2.04}{2009 November 10}{new}%
%    \begin{macrocode}
\define@key{glossaries.sty}{acronymlists}{%
  \@addtoacronymlists{#1}%
}
%    \end{macrocode}
%\end{option}
%
% The default counter associated with the numbers in the glossary
% is stored in \cs{glscounter}. This is initialised to the 
% page counter. This is used as the default counter when a
% new glossary is defined, unless a different counter is specified
% in the optional argument to \ics{newglossary} (see
% \autoref{sec:newglos}).
%\begin{macro}{\glscounter}
%    \begin{macrocode}
\newcommand{\glscounter}{page}
%    \end{macrocode}
%\end{macro}
%\begin{option}{counter}
% The \pkgopt{counter} option changes the default counter. (This
% just redefines \cs{glscounter}.)
%    \begin{macrocode}
\define@key{glossaries.sty}{counter}{%
  \renewcommand*{\glscounter}{#1}%
}
%    \end{macrocode}
%\end{option}
%
% The glossary keys whose values are written to another file (i.e.\
% \gloskey{sort}, \gloskey{name}, \gloskey{description} and
% \gloskey{symbol}) need to be sanitized, otherwise fragile
% commands would not be able to be used in 
% \ics{newglossaryentry}. However, strange results will occur
% if you then use those fields in the document. As these fields
% are not normally used in the document, but are by default only
% used in the glossary, the default is to sanitize them. If however
% you want to use these values in the document (either by redefining
% commands like \ics{glsdisplay} or by using commands like
% \ics{glsentrydesc}) you will have to switch off the 
% sanitization using the \pkgopt{sanitize} package option, but
% you will then have to use \ics{protect} to protect fragile 
% commands when defining new glossary entries. 
% The \pkgopt{sanitize} option
% takes a key-value list as its value, which can be used to 
% switch individual values on and off. For example:
%\begin{verbatim}
%\usepackage[sanitize={description,name,symbol=false}]{glossaries}
%\end{verbatim}
%will switch off the sanitization for the \gloskey{symbol} key, but
% switch it on for the \gloskey{description} and \gloskey{name} keys.
% This would mean that you can use fragile commands in the
%description and name when defining a new glossary entry, but not
% for the symbol.
%
% The default values are defined as:
%\begin{macro}{\@gls@sanitizedesc}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizedesc}{\@onelevel@sanitize\@glo@desc}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizename}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizename}{\@onelevel@sanitize\@glo@name}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizesymbol}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizesymbol}{\@onelevel@sanitize\@glo@symbol}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizesort}
%\changes{3.03}{2012/09/21}{new}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizesort}{\@onelevel@sanitize\@glo@sort}
%    \end{macrocode}
%\end{macro}
%
% Before defining the \pkgopt{sanitize} package option, The 
% key-value list for the \pkgopt{sanitize} value needs to be defined.
% These are all boolean keys. If they are not given a value, assume
% \texttt{true}.
%
% Firstly the \gloskey{description}. If set, it will redefine
% \cs{@gls@sanitizedesc} to use \cs{@onelevel@sanitize},
% otherwise \cs{@gls@sanitizedesc} will do nothing.
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{description}[true]{%
\ifgls@sanitize@description
  \renewcommand*{\@gls@sanitizedesc}{\@onelevel@sanitize\@glo@desc}%
\else
  \renewcommand*{\@gls@sanitizedesc}{}%
\fi
}
%    \end{macrocode}
% Similarly for the \gloskey{name} key:
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{name}[true]{%
\ifgls@sanitize@name
  \renewcommand*{\@gls@sanitizename}{\@onelevel@sanitize\@glo@name}%
\else
  \renewcommand*{\@gls@sanitizename}{}%
\fi}
%    \end{macrocode}
% and for the \gloskey{symbol} key:
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{symbol}[true]{%
\ifgls@sanitize@symbol
  \renewcommand*{\@gls@sanitizesymbol}{%
\@onelevel@sanitize\@glo@symbol}%
\else
  \renewcommand*{\@gls@sanitizesymbol}{}%
\fi}
%    \end{macrocode}
% and for the \gloskey{sort} key:
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{sort}[true]{%
\ifgls@sanitize@sort
  \renewcommand*{\@gls@sanitizesort}{%
\@onelevel@sanitize\@glo@sort}%
\else
  \renewcommand*{\@gls@sanitizesort}{}%
\fi}
%    \end{macrocode}
%
%
%\begin{option}{sanitize}
% Now define the \pkgopt{sanitize} option. It can either take
% a key-val list as its value, or it can take the keyword
% \texttt{none}, which is equivalent to \texttt{description=false,
% symbol=false, name=false}:
%    \begin{macrocode}
\define@key{glossaries.sty}{sanitize}[description=true,symbol=true,
name=true]{%
\ifthenelse{\equal{#1}{none}}%
{%
  \renewcommand*{\@gls@sanitizedesc}{}%
  \renewcommand*{\@gls@sanitizename}{}%
  \renewcommand*{\@gls@sanitizesymbol}{}%
}%
{%
  \setkeys[gls]{sanitize}{#1}}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{translate}
%\changes{1.1}{2008 Feb 22}{translate option added}
% Define \pkgopt{translate} option. If false don't set up
% multi-lingual support.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{translate}[true]{}
%    \end{macrocode}
%\end{option}
% Set the default value:
%    \begin{macrocode}
\glstranslatefalse
  \@ifpackageloaded{translator}%
    {\glstranslatetrue}%
    {%
       \@ifpackageloaded{polyglossia}%
          {\glstranslatetrue}%
          {%
             \@ifpackageloaded{babel}{\glstranslatetrue}{}%
          }%
}
%    \end{macrocode}
%
%\begin{option}{indexonlyfirst}
%\changes{3.02}{2012/05/21}{new}
% Set whether to only index on first use.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{indexonlyfirst}[true]{}
\glsindexonlyfirstfalse
%    \end{macrocode}
%\end{option}
%
%\begin{option}{hyperfirst}
%\changes{2.03}{2009 Sep 23}{new}
% Set whether or not terms should have a hyperlink on first use.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{hyperfirst}[true]{}
\glshyperfirsttrue
%    \end{macrocode}
%\end{option}
%
%\begin{option}{footnote}
% Set the long form of the acronym in footnote on first use.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{footnote}[true]{%
\ifthenelse{\boolean{glsacrdescription}}{}%
{\renewcommand*{\@gls@sanitizedesc}{}}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{description}
% Allow acronyms to have a description (needs to be set using
% the \gloskey{description} key in the optional argument of
% \ics{newacronym}).
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{description}[true]{%
  \renewcommand*{\@gls@sanitizesymbol}{}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{smallcaps}
% Define \ics{newacronym} to set the short form in small capitals.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{smallcaps}[true]{%
  \renewcommand*{\@gls@sanitizesymbol}{}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{smaller}
% Define \ics{newacronym} to set the short form using \cs{smaller}
% which obviously needs to be defined by loading the appropriate
% package.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{smaller}[true]{%
  \renewcommand*{\@gls@sanitizesymbol}{}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{dua}
% Define \ics{newacronym} to always use the long forms 
% (i.e.\ don't use acronyms)
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{dua}[true]{%
  \renewcommand*{\@gls@sanitizesymbol}{}%
}
%    \end{macrocode}
%\end{option}
%\begin{option}{shotcuts}
% Define acronym shortcuts.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{shortcuts}[true]{}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\glsorder}
% Stores the glossary ordering. This may either be \qt{word}
% or \qt{letter}. This passes the relevant information to
% \app{makeglossaries}. The default is word ordering.
%    \begin{macrocode}
\newcommand*{\glsorder}{word}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsorder}
% The ordering information is written to the auxiliary file
% for \app{makeglossaries}, so ignore the auxiliary 
% information.
%    \begin{macrocode}
\newcommand*{\@glsorder}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{order}
%\changes{1.17}{2008 December 26}{order package option added}
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{order}{word,letter}{%
  \def\glsorder{#1}}
%    \end{macrocode}
%\end{option}
%
%\changes{1.17}{2008 December 26}{added xindy support}
%\begin{macro}{\ifglsxindy}
%\changes{1.17}{2008 December 26}{new}
% Provide boolean to determine whether \gls{xindy} or
% \gls{makeindex} will be used to sort the glossaries.
%    \begin{macrocode}
\newif\ifglsxindy
%    \end{macrocode}
%\end{macro}
% The default is \app{makeindex}:
%    \begin{macrocode}
\glsxindyfalse
%    \end{macrocode}
%
% Define package option to specify that \app{makeindex} will 
% be used to sort the glossaries:
%    \begin{macrocode}
\DeclareOptionX{makeindex}{\glsxindyfalse}
%    \end{macrocode}
%
% The \pkgopt{xindy} package option may have a value which in
% turn can be a key=value list. First define the keys for this
% sub-list. The boolean "glsnumbers" determines whether to
% automatically add the \texttt{glsnumbers} letter group.
%    \begin{macrocode}
\define@boolkey[gls]{xindy}{glsnumbers}[true]{}
\gls@xindy@glsnumberstrue
%    \end{macrocode}
%
%\begin{macro}{\@xdy@main@language}
% Define what language to use for each glossary type (if a
% language is not defined for a particular glossary type
% the language specified for the main glossary is used.)
%    \begin{macrocode}
\def\@xdy@main@language{\rootlanguagename}%
%    \end{macrocode}
%\end{macro}
% Define key to set the language
%    \begin{macrocode}
\define@key[gls]{xindy}{language}{\def\@xdy@main@language{#1}}
%    \end{macrocode}
%
%\begin{macro}{\gls@codepage}
% Define the code page. If \ics{inputencodingname} is defined
% use that, otherwise have initialise with no codepage.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{inputencodingname}{%
  \def\gls@codepage{}}{%
  \def\gls@codepage{\inputencodingname}
}
%    \end{macrocode}
% Define a key to set the code page.
%    \begin{macrocode}
\define@key[gls]{xindy}{codepage}{\def\gls@codepage{#1}}
%    \end{macrocode}
%\end{macro}
%
% Define package option to specify that \app{xindy} will be 
% used to sort the glossaries:
%    \begin{macrocode}
\define@key{glossaries.sty}{xindy}[]{%
  \glsxindytrue
  \setkeys[gls]{xindy}{#1}%
}
%    \end{macrocode}
%
%\begin{option}{savewrites}
%\changes{3.0}{2011/04/02}{new}
% The \pkgopt{savewrites} package option is provided to save on 
% the number of write registers.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{savewrites}[true]{}
%    \end{macrocode}
%\end{option}
% Set default:
%    \begin{macrocode}
\glssavewritesfalse
%    \end{macrocode}
%
%\begin{macro}{\GlossariesWarning}
% Prints a warning message.
%    \begin{macrocode}
\newcommand*{\GlossariesWarning}[1]{%
  \PackageWarning{glossaries}{#1}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlossariesWarningNoLine}
% Prints a warning message without the line number.
%    \begin{macrocode}
\newcommand*{\GlossariesWarningNoLine}[1]{%
  \PackageWarningNoLine{glossaries}{#1}%
}
%    \end{macrocode}
%\end{macro}
% Define package option to suppress warnings
%    \begin{macrocode}
\DeclareOptionX{nowarn}{%
  \renewcommand*{\GlossariesWarning}[1]{}%
  \renewcommand*{\GlossariesWarningNoLine}[1]{}%
}
%    \end{macrocode}
%\begin{option}{compatible-2.07}
%\changes{3.0}{2011/04/02}{compatible-2.07 option added}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{compatible-2.07}[true]{}
\csname glscompatible-2.07false\endcsname
%    \end{macrocode}
%\end{option}
%
%
% Process package options:
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
% If \isty{babel} package is loaded, check to see if 
% \isty{translator} is installed, but only if translation is
% required.
%\changes{2.02}{2009 July 13}{translate=false will prevent 
% automatic loading of translator package}
%    \begin{macrocode}
\ifglstranslate
  \@ifpackageloaded{polyglossia}%
  {%
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{added check for polyglossia}%
% \sty{polyglossia} fakes \sty{babel} so need to check for
% \sty{polyglossia} first.
%    \begin{macrocode}
  }%
  {%
     \@ifpackageloaded{babel}%
     {%
         \IfFileExists{translator.sty}%
         {%
            \RequirePackage{translator}%
         }%
         {}%
     }%
     {}
  }
\fi
%    \end{macrocode}
%
% If chapters are defined and the user has requested the
% section counter as a package option, \cs{@chapter} will
% be modified so 
% that it adds a \texttt{section.}\meta{n}\texttt{.0} target, 
% otherwise entries placed before the first section of a chapter
% will have undefined links.
%
% The same problem will also occur if a lower sectional unit is
% used, but this is less likely to happen. If it does, or if
% you change \cs{glscounter} to "section" later, you
% will have to specify a different counter for the entries
% that give rise to a \texttt{name}"{"\meta{section-level}"."\meta{n}".0}"
% non-existent warning (e.g. "\gls[counter=chapter]{label}").
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifthenelse{\equal{\glscounter}{section}}%
{%
  \ifcsundef{chapter}{}%
  {%
    \let\@gls@old@chapter\@chapter
    \def\@chapter[#1]#2{\@gls@old@chapter[{#1}]{#2}%
    \ifcsundef{hyperdef}{}{\hyperdef{section}{\thesection}{}}}%
  }%
}%
{}
%    \end{macrocode}
%
%\begin{macro}{\@gls@onlypremakeg}
% Some commands only have an effect when used before 
% \ics{makeglossaries}. So define a list of commands that
% should be disabled after \ics{makeglossaries}
%    \begin{macrocode}
\newcommand*{\@gls@onlypremakeg}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@onlypremakeg}
% Adds the specified control sequence to the list of commands that
% must be disabled after \ics{makeglossaries}.
%    \begin{macrocode}
\newcommand*{\@onlypremakeg}[1]{%
\ifx\@gls@onlypremakeg\@empty
   \def\@gls@onlypremakeg{#1}%
\else
   \expandafter\toks@\expandafter{\@gls@onlypremakeg}%
   \edef\@gls@onlypremakeg{\the\toks@,\noexpand#1}%
\fi}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@disable@onlypremakeg}
% Disable all commands listed in \cs{@gls@onlypremakeg}
%    \begin{macrocode}
\newcommand*{\@disable@onlypremakeg}{%
\@for\@thiscs:=\@gls@onlypremakeg\do{%
   \expandafter\@disable@premakecs\@thiscs%
}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@disable@premakecs}
% Disables the given command.
%    \begin{macrocode}
\newcommand*{\@disable@premakecs}[1]{%
  \def#1{\PackageError{glossaries}{\string#1\space may only be
  used before \string\makeglossaries}{You can't use
  \string#1\space after \string\makeglossaries}}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Default values}\label{sec:predefinednames}
% This section sets up default values that are used by this
% package. Some of the names may already be defined (e.g.\ by
% \isty{babel}) so \cs{providecommand} is used.
%
% Main glossary title:
%\begin{macro}{\glossaryname}
%    \begin{macrocode}
\providecommand*{\glossaryname}{Glossary}
%    \end{macrocode}
%\end{macro}
% The title for the "acronym" glossary type (which is defined if 
% \pkgopt{acronym} package option is used) is given by
% \cs{acronymname}. If the \pkgopt{acronym}
% package option is not used, \cs{acronymname} won't be used.
%\begin{macro}{\acronymname}
%    \begin{macrocode}
\providecommand*{\acronymname}{Acronyms}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssettoctitle}
% Sets the TOC title for the given glossary.
%\changes{1.15}{2008 August 15}{new}
%    \begin{macrocode}
\newcommand*{\glssettoctitle}[1]{%
\def\glossarytoctitle{\csname @glotype@#1@title\endcsname}}
%    \end{macrocode}
%\end{macro}
%
% The following commands provide text for the headers used by 
% some of the tabular-like glossary 
% styles. Whether or not they get used in the glossary depends on
% the glossary style.
%\begin{macro}{\entryname}
%    \begin{macrocode}
\providecommand*{\entryname}{Notation}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\descriptionname}
%    \begin{macrocode}
\providecommand*{\descriptionname}{Description}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\symbolname}
%    \begin{macrocode}
\providecommand*{\symbolname}{Symbol}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\pagelistname}
%    \begin{macrocode}
\providecommand*{\pagelistname}{Page List}
%    \end{macrocode}
%\end{macro}
% Labels for \app{makeindex}'s symbol and number groups:
%\begin{macro}{\glssymbolsgroupname}
%    \begin{macrocode}
\providecommand*{\glssymbolsgroupname}{Symbols}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsnumbersgroupname}
%    \begin{macrocode}
\providecommand*{\glsnumbersgroupname}{Numbers}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glspluralsuffix}
% The default plural is formed by appending \cs{glspluralsuffix} to
% the singular form.
%    \begin{macrocode}
\newcommand*{\glspluralsuffix}{s}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\seename}
%    \begin{macrocode}
\providecommand*{\seename}{see}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\andname}
%    \begin{macrocode}
\providecommand*{\andname}{\&}
%    \end{macrocode}
%\end{macro}
% Add multi-lingual support\changes{1.08}{2007 Oct 13}{Added 
% babel support}. Thanks to everyone who contributed to the
% translations from both comp.text.tex and via email.
%\begin{macro}{\addglossarytocaptions}
% If using \isty{translator}, \ics{glossaryname} should be defined
% in terms of \ics{translate}, but if babel is also loaded, it will
% redefine \cs{glossaryname} whenever the language is set, so 
% override it. (Don't use \ics{addto} as \isty{polyglossia} doesn't
% define it.)
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand*{\addglossarytocaptions}[1]{%
  \ifcsundef{captions#1}{}%
  {%
    \expandafter\let\expandafter\@gls@tmp\csname captions#1\endcsname
    \expandafter\toks@\expandafter{\@gls@tmp
      \renewcommand*{\glossaryname}{\translate{Glossary}}%
    }%
    \expandafter\edef\csname captions#1\endcsname{\the\toks@}%
  }%
}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
\ifglstranslate
%    \end{macrocode}
% If \isty{translator} is not install, used standard 
% \isty{babel} captions, otherwise load \isty{translator}
% dictionary.
%\changes{1.1}{2008 Feb 22}{Added support for translator package}
%\changes{1.15}{2008 August 15}{Added 'glssettoctitle}
%    \begin{macrocode}
  \@ifpackageloaded{translator}{%
    \usedictionary{glossaries-dictionary}%
    \addglossarytocaptions{portuges}%
    \addglossarytocaptions{portuguese}%
    \addglossarytocaptions{brazil}%
    \addglossarytocaptions{brazilian}%
    \addglossarytocaptions{danish}%
    \addglossarytocaptions{dutch}%
    \addglossarytocaptions{afrikaans}%
    \addglossarytocaptions{english}%
    \addglossarytocaptions{UKenglish}%
    \addglossarytocaptions{USenglish}%
    \addglossarytocaptions{american}%
    \addglossarytocaptions{australian}%
    \addglossarytocaptions{british}%
    \addglossarytocaptions{canadian}%
    \addglossarytocaptions{newzealand}%
    \addglossarytocaptions{french}%
    \addglossarytocaptions{frenchb}%
    \addglossarytocaptions{francais}%
    \addglossarytocaptions{acadian}%
    \addglossarytocaptions{canadien}%
    \addglossarytocaptions{german}%
    \addglossarytocaptions{germanb}%
    \addglossarytocaptions{austrian}%
    \addglossarytocaptions{naustrian}%
    \addglossarytocaptions{ngerman}%
    \addglossarytocaptions{irish}%
    \addglossarytocaptions{italian}%
    \addglossarytocaptions{magyar}%
    \addglossarytocaptions{hungarian}%
    \addglossarytocaptions{polish}%
    \addglossarytocaptions{spanish}%
    \renewcommand*{\glssettoctitle}[1]{%
    \ifthenelse{\equal{#1}{main}}{%
      \translatelet{\glossarytoctitle}{Glossary}}{%
      \ifthenelse{\equal{#1}{acronym}}{%
        \translatelet{\glossarytoctitle}{Acronyms}}{%
        \def\glossarytoctitle{\csname @glotype@#1@title\endcsname}}}}%
    \renewcommand*{\glossaryname}{\translate{Glossary}}%
    \renewcommand*{\acronymname}{\translate{Acronyms}}%
    \renewcommand*{\entryname}{\translate{Notation (glossaries)}}%
    \renewcommand*{\descriptionname}{%
      \translate{Description (glossaries)}}%
    \renewcommand*{\symbolname}{\translate{Symbol (glossaries)}}%
    \renewcommand*{\pagelistname}{%
      \translate{Page List (glossaries)}}%
    \renewcommand*{\glssymbolsgroupname}{%
      \translate{Symbols (glossaries)}}%
    \renewcommand*{\glsnumbersgroupname}{%
      \translate{Numbers (glossaries)}}%
  }{%
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{reversed order of package check}
%    \begin{macrocode}
    \@ifpackageloaded{polyglossia}%
    {\RequirePackage{glossaries-polyglossia}}%
    {%
      \@ifpackageloaded{babel}{%
        \RequirePackage{glossaries-babel}}{}%
    }}
\fi
%    \end{macrocode}
%\begin{macro}{\nopostdesc}
% Provide a means to suppress description terminator for a given
% entry. (Useful for entries with no description.) Has no
% effect outside the glossaries.
%\changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\newcommand*{\nopostdesc}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@nopostdesc}
% Suppress next description terminator.
%    \begin{macrocode}
\newcommand*{\@nopostdesc}{%
  \let\org@glspostdescription\glspostdescription
  \def\glspostdescription{%
    \let\glspostdescription\org@glspostdescription}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glspar}
% Provide means of having a paragraph break in glossary entries
%    \begin{macrocode}
\newcommand{\glspar}{\par}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\setStyleFile}
% Sets the style file. The relevent extension is appended.
%    \begin{macrocode}
\ifglsxindy
  \newcommand{\setStyleFile}[1]{%
    \renewcommand{\istfilename}{#1.xdy}}
\else
  \newcommand{\setStyleFile}[1]{%
    \renewcommand{\istfilename}{#1.ist}}
\fi
%    \end{macrocode}
% This command only has an effect prior to using
% \ics{makeglossaries}.
%    \begin{macrocode}
\@onlypremakeg\setStyleFile
%    \end{macrocode}
%\end{macro}
%
% The name of the \app{makeindex} or \app{xindy} style file
% is given by \cs{istfilename}. This file is 
% created by \ics{writeist} (which is used by 
% \ics{makeglossaries}) so
% redefining this command will only have an effect if it is 
% done \emph{before} \cs{makeglossaries}. As from v1.17, use
% \ics{setStyleFile} instead of directly redefining \cs{istfilename}.
%\begin{macro}{\istfilename}
%\changes{1.17}{2008 December 26}{added xindy support}
%    \begin{macrocode}
\ifglsxindy
  \def\istfilename{\jobname.xdy}
\else
  \def\istfilename{\jobname.ist}
\fi
%    \end{macrocode}
%\end{macro}
% The \app{makeglossaries} Perl script picks up this name
% from the auxiliary file. If the name ends with \filetype{.xdy}
% it calls \app{xindy} otherwise it calls \app{makeindex}.
% Since its not required by
% \LaTeX, \cs{@istfilename} ignores its argument.
%\begin{macro}{\@istfilename}
%    \begin{macrocode}
\newcommand*{\@istfilename}[1]{}
%    \end{macrocode}
%\end{macro}
%
% This command is the value of the \istkey{page\_compositor}
% \app{makeindex} key. Again, any redefinition of this command 
% must take place \emph{before} \cs{writeist} otherwise it 
% will have no effect. As from 1.17, use \ics{glsSetCompositor}
% instead of directly redefining \cs{glscompositor}.
%\begin{macro}{\glscompositor}
%    \begin{macrocode}
\newcommand*{\glscompositor}{.}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsSetCompositor}
% Sets the compositor.
%    \begin{macrocode}
\newcommand*{\glsSetCompositor}[1]{%
  \renewcommand*{\glscompositor}{#1}}
%    \end{macrocode}
% Only use before \ics{makeglossaries}
%    \begin{macrocode}
\@onlypremakeg\glsSetCompositor
%    \end{macrocode}
%\end{macro}
%
% (The page compositor is usually defined as a dash when using
% \app{makeindex}, but most of the standard counters used
% by \LaTeX\ use a full stop as the compositor, which is why I
% have used it as the default.) If \app{xindy} is used 
% \cs{glscompositor} only affects the \texttt{arabic-page-numbers}
% location class.
%\begin{macro}{\@glsAlphacompositor}
% This is only used by \app{xindy}. It specifies the
% compositor to use when location numbers are in the form
% \meta{letter}\meta{compositor}\meta{number}. For example,
% if \cs{@glsAlphacompositor} is set to ``.'' then it allows
% locations such as A.1 whereas if \cs{@glsAlphacompositor} is
% set to ``-'' then it allows locations such as A-1.
%    \begin{macrocode}
\newcommand*{\@glsAlphacompositor}{\glscompositor}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsSetAlphaCompositor}
% Sets the alpha compositor.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\glsSetAlphaCompositor[1]{%
     \renewcommand*\@glsAlphacompositor{#1}}
\else
  \newcommand*\glsSetAlphaCompositor[1]{%
    \glsnoxindywarning\glsSetAlphaCompositor}
\fi
%    \end{macrocode}
% Can only be used before \ics{makeglossaries}
%    \begin{macrocode}
\@onlypremakeg\glsSetAlphaCompositor
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@suffixF}
%\changes{1.17}{2008 December 26}{new}
% Suffix to use for a two page list. This overrides the separator
% and the closing page number if set to something other than
% an empty macro.
%    \begin{macrocode}
\newcommand*{\gls@suffixF}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsSetSuffixF}
%\changes{1.17}{2008 December 26}{new}
% Sets the suffix to use for a two page list.
%    \begin{macrocode}
\newcommand*{\glsSetSuffixF}[1]{%
  \renewcommand*{\gls@suffixF}{#1}}
%    \end{macrocode}
% Only has an effect when used before \ics{makeglossaries}
%    \begin{macrocode}
\@onlypremakeg\glsSetSuffixF
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@suffixFF}
%\changes{1.17}{2008 December 26}{new}
% Suffix to use for a three page list. This overrides the separator
% and the closing page number if set to something other than
% an empty macro.
%    \begin{macrocode}
\newcommand*{\gls@suffixFF}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsSetSuffixFF}
%\changes{1.17}{2008 December 26}{new}
% Sets the suffix to use for a three page list.
%    \begin{macrocode}
\newcommand*{\glsSetSuffixFF}[1]{%
  \renewcommand*{\gls@suffixFF}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnumberformat}
% The command \cs{glsnumberformat} indicates the default
% format for the page numbers in the glossary. (Note that this
% is not the same as \ics{glossaryentrynumbers}, but applies
% to individual numbers or groups of numbers within an entry's
% associated number list.) If hyperlinks are defined, it will use
% \ics{glshypernumber}, otherwise it will simply display its 
% argument ``as is''.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{hyperlink}%
{%
  \newcommand*{\glsnumberformat}[1]{#1}%
}%
{%
  \newcommand*{\glsnumberformat}[1]{\glshypernumber{#1}}%
}
%    \end{macrocode}
%\end{macro}
%
% Individual numbers in an entry's associated number list are
% delimited using \cs{delimN} (which corresponds to the 
% \istkey{delim\_n} \app{makeindex} keyword). The default value
% is a comma followed by a space.
%\begin{macro}{\delimN}
%    \begin{macrocode}
\newcommand{\delimN}{, }
%    \end{macrocode}
%\end{macro}
% A range of numbers within an entry's associated number list is
% delimited using \cs{delimR} (which corresponds to the
% \istkey{delim\_r} \app{makeindex} keyword). The default is
% an en-dash.
%\begin{macro}{\delimR}
%    \begin{macrocode}
\newcommand{\delimR}{--}
%    \end{macrocode}
%\end{macro}
%
% The glossary preamble is given by \cs{glossarypreamble}. This
% will appear after the glossary sectioning command, and before the
% \env{theglossary} environment. It is designed to allow the
% user to add information pertaining to the glossary (e.g.\ ``page
% numbers in italic indicate the primary definition'') therefore 
% \cs{glossarypremable} shouldn't be affected by the glossary
% style. (So if you define your own glossary style, don't have it 
% change \cs{glossarypreamble}.) The preamble is empty by
% default. If you have multiple glossaries, and you want a 
% different preamble for each glossary, you will need to use
% \ics{printglossary} for each glossary type, instead of 
% \ics{printglossaries}, and redefine \cs{glossarypreamble}
% before each \ics{printglossary}.
%\begin{macro}{\glossarypreamble}
%    \begin{macrocode}
\newcommand*{\glossarypreamble}{}
%    \end{macrocode}
%\end{macro}
%
% The glossary postamble is given by \cs{glossarypostamble}.
% This is provided to allow the user to
% add something after the end of the \env{theglossary}
% environment (again, this shouldn't be affected by the
% glossary style). It is, of course, possible to simply add the
% text after \ics{printglossary}, but if you only want the
% postamble to appear after the first glossary, but not after 
% subsequent glossaries, you can do something like:
%\begin{verbatim}
%\renewcommand{\glossarypostamble}{For a complete list of terms
%see \cite{blah}\gdef\glossarypreamble{}}
%\end{verbatim}
%\begin{macro}{\glossarypostamble}
%    \begin{macrocode}
\newcommand*{\glossarypostamble}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossarysection}
% The sectioning command that starts a glossary is given by
% \cs{glossarysection}. (This does not form part of the
% glossary style, and so should not be changed by a glossary
% style.) If \ics{phantomsection}
% is defined, it uses \cs{\@p@glossarysection}, otherwise it
% uses \cs{@glossarysection}.
%\changes{1.05}{2007 Aug 10}{added '@mkboth to 'glossarysection}
%\changes{2.02}{2009 July 13}{changed '@mkboth to 'glossarymark}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand*{\glossarysection}[2][\@gls@title]{%
  \def\@gls@title{#2}%
  \ifcsundef{phantomsection}%
  {%
    \@glossarysection{#1}{#2}%
  }%
  {%
    \@p@glossarysection{#1}{#2}%
  }%
  \glossarymark{\glossarytoctitle}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glossarymark}
%\changes{2.02}{2009 July 13}{New}
%\changes{2.03}{2009 Sep 23}{Added check to see if it's already 
%defined}
% Sets the header mark for the glossary. Takes the glossary short
% (TOC) title as the argument.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{glossarymark}%
{%
  \ifglsucmark
    \newcommand{\glossarymark}[1]{%
       \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
    }
  \else
    \newcommand{\glossarymark}[1]{\@mkboth{#1}{#1}}
  \fi
}%
{%
  \GlossariesWarning{overriding \string\glossarymark}%
  \@ifclassloaded{memoir}%
  {
    \ifglsucmark
      \renewcommand{\glossarymark}[1]{%
         \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
      }
    \else
      \renewcommand{\glossarymark}[1]{%
        \markboth{\memUChead{#1}}{\memUChead{#1}}%
      }
    \fi
  }
  {
    \ifglsucmark
      \renewcommand{\glossarymark}[1]{%
         \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
      }
    \else
      \renewcommand{\glossarymark}[1]{\@mkboth{#1}{#1}}
    \fi
  }
}
%    \end{macrocode}
%\end{macro}
%
% The required sectional unit is given by \cs{@@glossarysec}
% which was defined by the \pkgopt{section} package option. The
% starred form of the command is chosen. If you don't want any sectional
% command, you will need to redefine \cs{glossarysection}.
% The sectional unit can be changed, if different sectional units
% are required.
%\begin{macro}{\setglossarysection}
%\changes{1.1}{2008 Feb 22}{new}
%    \begin{macrocode}
\newcommand*{\setglossarysection}[1]{%
\setkeys{glossaries.sty}{section=#1}}
%    \end{macrocode}
%\end{macro}
%
%The command \cs{@glossarysection} indicates how to start
% the glossary section if \ics{phantomsection} is not defined.
%\begin{macro}{\@glossarysection}
%\changes{1.1}{2008 Feb 22}{numbered sections and auto label added}
%    \begin{macrocode}
\newcommand*{\@glossarysection}[2]{%
\ifx\@@glossarysecstar\@empty
  \csname\@@glossarysec\endcsname{#2}%
\else
  \csname\@@glossarysec\endcsname*{#2}%
  \@gls@toc{#1}{\@@glossarysec}%
\fi
\@@glossaryseclabel}
%    \end{macrocode}
%\end{macro}
%
% As \cs{@glossarysection}, but put in 
% \ics{phantomsection}, and swap where \cs{@gls@toc} goes. 
% If using chapters do a \cs{clearpage}. This ensures that
% the hyper link from the table of contents leads to the line above
% the heading, rather than the line below it.
%\begin{macro}{\@p@glossarysection}
%\changes{1.1}{2008 Feb 22}{numbered sections and auto label added}
%    \begin{macrocode}
\newcommand*{\@p@glossarysection}[2]{%
\glsclearpage
\phantomsection
\ifx\@@glossarysecstar\@empty
  \csname\@@glossarysec\endcsname{#2}%
\else
  \@gls@toc{#1}{\@@glossarysec}%
  \csname\@@glossarysec\endcsname*{#2}%
\fi
\@@glossaryseclabel}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@doclearpage}
%The \cs{gls@doclearpage} command is used to issue a
% \cs{clearpage} (or \cs{cleardoublepage}) depending
% on whether the glossary sectional unit is a chapter. If the
% sectional unit is something else, do nothing.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand*{\gls@doclearpage}{%
  \ifthenelse{\equal{\@@glossarysec}{chapter}}%
  {%
    \ifcsundef{cleardoublepage}{\clearpage}{\cleardoublepage}%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsclearpage}
% This just calls \cs{gls@doclearpage}, but it makes it easier to
% have a user command so that the user can override it.
%\changes{1.19}{2009 Mar 2}{new}
%    \begin{macrocode}
\newcommand*{\glsclearpage}{\gls@doclearpage}
%    \end{macrocode}
%\end{macro}
%
% The glossary is added to the table of contents if glstoc flag set.
% If it is set, \cs{@gls@toc} will add a line to the 
% \filetype{.toc} file, otherwise it will do nothing.
% (The first argument to \cs{@gls@toc} is the title for the
% table of contents, the second argument is the sectioning type.) 
%\begin{macro}{\@gls@toc}
%\changes{1.1}{2008 Feb 22}{numberline added}
%    \begin{macrocode}
\newcommand*{\@gls@toc}[2]{%
\ifglstoc
  \ifglsnumberline
    \addcontentsline{toc}{#2}{\numberline{}#1}%
  \else
    \addcontentsline{toc}{#2}{#1}%
  \fi
\fi}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Xindy}
% This section defines commands that only have an effect if
% \app{xindy} is used to sort the glossaries.
%\begin{macro}{\glsnoxindywarning}
% Issues a warning if \app{xindy} hasn't been specified.
% These warnings can be suppressed by redefining 
% \cs{glsnoxindywarning} to ignore its argument
%    \begin{macrocode}
\newcommand*{\glsnoxindywarning}[1]{%
  \GlossariesWarning{Not in xindy mode --- ignoring \string#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdyattributes}
% Define list of attributes (\cs{string} is used in case
% the double quote character has been made active)
%    \begin{macrocode}
\ifglsxindy
  \edef\@xdyattributes{\string"default\string"}%
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@xdyattributelist}
% Comma-separated list of attributes.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\ifglsxindy
  \edef\@xdyattributelist{}%
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@xdylocref}
% Define list of markup location references.
%    \begin{macrocode}
\ifglsxindy
  \def\@xdylocref{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@ifinlist}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\@gls@ifinlist}[4]{%
  \def\@do@ifinlist##1,#1,##2\end@doifinlist{%
    \def\@gls@listsuffix{##2}%
    \ifx\@gls@listsuffix\@empty
       #4%
    \else
       #3%
    \fi
  }%
  \@do@ifinlist,#2,#1,\end@doifinlist
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsAddXdyCounters}
%\changes{3.0}{2011/04/02}{new}
% Need to know all the counters that will be used in location
% numbers for Xindy. Argument may be a single counter name or a
% comma-separated list of counter names.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@xdycounters}{\glscounter}
  \newcommand*\GlsAddXdyCounters[1]{%
    \@for\@gls@ctr:=#1\do{%
%    \end{macrocode}
% Check if already in list before adding.
%    \begin{macrocode}
       \edef\@do@addcounter{%
          \noexpand\@gls@ifinlist{\@gls@ctr}{\@xdycounters}{}%
          {%
             \noexpand\edef\noexpand\@xdycounters{\@xdycounters,%
               \noexpand\@gls@ctr}%
          }%
       }%
       \@do@addcounter
    }
  }
%    \end{macrocode}
% Only has an effect before \ics{writeist}:
%    \begin{macrocode}
  \@onlypremakeg\GlsAddXdyCounters
\else
  \newcommand*\GlsAddXdyCounters[1]{%
    \glsnoxindywarning\GlsAddXdyAttribute
  }
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@disabled@glsaddxdycounters}
% Counters must all be identified before adding attributes.
%    \begin{macrocode}
\newcommand*\@disabled@glsaddxdycounters{%
   \PackageError{glossaries}{\string\GlsAddXdyCounters\space
   can't be used after \string\GlsAddXdyAttribute}{Move all
   occurrences of \string\GlsAddXdyCounters\space before the first
   instance of \string\GlsAddXdyAttribute}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsAddXdyAttribute}
% Adds an attribute.
%    \begin{macrocode}
\ifglsxindy
%    \end{macrocode}
% First define internal command that adds an attribute for a given
% counter (2nd argument is the counter):
%    \begin{macrocode}
  \newcommand*\@glsaddxdyattribute[2]{%
%    \end{macrocode}
% Add to xindy attribute list
%    \begin{macrocode}
    \edef\@xdyattributes{\@xdyattributes ^^J \string"#1\string" ^^J
      \string"#2#1\string"}%
%    \end{macrocode}
% Add to xindy markup location.
%    \begin{macrocode}
    \expandafter\toks@\expandafter{\@xdylocref}%
    \edef\@xdylocref{\the\toks@ ^^J%
      (markup-locref
      :open \string"\string~n%
        \expandafter\string\csname glsX#2X#1\endcsname
        \string" ^^J
      :close \string"\string" ^^J
      :attr \string"#2#1\string")}%
%    \end{macrocode}
% Define associated attribute command
% \cs{glsX}\meta{counter}"X"\meta{attribute}\marg{Hprefix}\marg{n}
%    \begin{macrocode}
    \expandafter\gdef\csname glsX#2X#1\endcsname##1##2{%
       \setentrycounter[##1]{#2}\csname #1\endcsname{##2}%
    }%
  }
%    \end{macrocode}
% High-level command:
%    \begin{macrocode}
  \newcommand*\GlsAddXdyAttribute[1]{%
%    \end{macrocode}
% Add to comma-separated attribute list
%    \begin{macrocode}
    \ifx\@xdyattributelist\@empty
      \edef\@xdyattributelist{#1}%
    \else
      \edef\@xdyattributelist{\@xdyattributelist,#1}%
    \fi
%    \end{macrocode}
% Iterate through all specified counters and add counter-dependent
% attributes:
%    \begin{macrocode}
    \@for\@this@counter:=\@xdycounters\do{%
      \protected@edef\gls@do@addxdyattribute{%
        \noexpand\@glsaddxdyattribute{#1}{\@this@counter}%
      }
      \gls@do@addxdyattribute
    }%
%    \end{macrocode}
% All occurrences of \cs{GlsAddXdyCounters} must be used before this
% command
%    \begin{macrocode}
    \let\GlsAddXdyCounters\@disabled@glsaddxdycounters
  }
%    \end{macrocode}
% Only has an effect before \ics{writeist}:
%    \begin{macrocode}
  \@onlypremakeg\GlsAddXdyAttribute
\else
  \newcommand*\GlsAddXdyAttribute[1]{%
    \glsnoxindywarning\GlsAddXdyAttribute}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@addpredefinedattributes}
% Add known attributes for all defined counters
%    \begin{macrocode}
\ifglsxindy
\newcommand*{\@gls@addpredefinedattributes}{%
  \GlsAddXdyAttribute{glsnumberformat}
  \GlsAddXdyAttribute{textrm}
  \GlsAddXdyAttribute{textsf}
  \GlsAddXdyAttribute{texttt}
  \GlsAddXdyAttribute{textbf}
  \GlsAddXdyAttribute{textmd}
  \GlsAddXdyAttribute{textit}
  \GlsAddXdyAttribute{textup}
  \GlsAddXdyAttribute{textsl}
  \GlsAddXdyAttribute{textsc}
  \GlsAddXdyAttribute{emph}
  \GlsAddXdyAttribute{glshypernumber}
  \GlsAddXdyAttribute{hyperrm}
  \GlsAddXdyAttribute{hypersf}
  \GlsAddXdyAttribute{hypertt}
  \GlsAddXdyAttribute{hyperbf}
  \GlsAddXdyAttribute{hypermd}
  \GlsAddXdyAttribute{hyperit}
  \GlsAddXdyAttribute{hyperup}
  \GlsAddXdyAttribute{hypersl}
  \GlsAddXdyAttribute{hypersc}
  \GlsAddXdyAttribute{hyperemph}
}
\else
  \let\@gls@addpredefinedattributes\relax
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdyuseralphabets}
% List of additional alphabets
%    \begin{macrocode}
\def\@xdyuseralphabets{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsAddXdyAlphabet}
% \cs{GlsAddXdyAlphabet}\marg{name}\marg{definition}
% adds a new alphabet called \meta{name}. The definition
% must use \app{xindy} syntax.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\GlsAddXdyAlphabet}[2]{%
  \edef\@xdyuseralphabets{%
    \@xdyuseralphabets ^^J
    (define-alphabet "#1" (#2))}}
\else
  \newcommand*{\GlsAddXdyAlphabet}[2]{%
     \glsnoxindywarning\GlsAddXdyAlphabet}
\fi
%    \end{macrocode}
%\end{macro}
%
% This code is only required for xindy:
%    \begin{macrocode}
\ifglsxindy
%    \end{macrocode}
%
%\begin{macro}{\@gls@xdy@locationlist}
%\changes{3.0}{2011/04/02}{new}
% List of predefined location names.
%    \begin{macrocode}
  \newcommand*{\@gls@xdy@locationlist}{%
     roman-page-numbers,%
     Roman-page-numbers,%
     arabic-page-numbers,%
     alpha-page-numbers,%
     Alpha-page-numbers,%
     Appendix-page-numbers,%
     arabic-section-numbers%
  }
%    \end{macrocode}
%\end{macro}
% Each location class \meta{name} has the format stored in 
% \cs{@gls@xdy@Lclass@}\meta{name}. Set up predefined
% formats.
%
%\begin{macro}{\@gls@xdy@Lclass@roman-page-numbers}
% Lower case Roman numerals (i, ii, \ldots). In the event that
% \ics{roman} has been redefined to produce a fancy form of
% roman numerals, attempt to work out how it will be written
% to the output file.
%    \begin{macrocode}
  \protected@edef\@gls@roman{\@roman{0\string" 
      \string"roman-numbers-lowercase\string" :sep \string"}}%
  \@onelevel@sanitize\@gls@roman
  \edef\@tmp{\string" \string"roman-numbers-lowercase\string"
       :sep \string"}%
  \@onelevel@sanitize\@tmp
  \ifx\@tmp\@gls@roman
    \expandafter
      \edef\csname @gls@xdy@Lclass@roman-page-numbers\endcsname{%
        \string"roman-numbers-lowercase\string"%
      }%
  \else
     \expandafter
      \edef\csname @gls@xdy@Lclass@roman-page-numbers\endcsname{
        :sep \string"\@gls@roman\string"%
      }%
  \fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@Roman-page-numbers}
% Upper case Roman numerals (I, II, \ldots).
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@Roman-page-numbers\endcsname{%
    \string"roman-numbers-uppercase\string"%
  }%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@arabic-page-numbers}
% Arabic numbers (1, 2, \ldots).
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@arabic-page-numbers\endcsname{%
    \string"arabic-numbers\string"%
  }%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@alpha-page-numbers}
% Lower case alphabetical (a, b, \ldots).
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@alpha-page-numbers\endcsname{%
    \string"alpha\string"%
  }%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@Alpha-page-numbers}
% Upper case alphabetical (A, B, \ldots).
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@Alpha-page-numbers\endcsname{%
    \string"ALPHA\string"%
  }%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@Appendix-page-numbers}
% Appendix style locations (e.g.\ A-1, A-2, \ldots, B-1, B-2,
% \ldots). The separator is given by \ics{@glsAlphacompositor}.
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@Appendix-page-numbers\endcsname{%
    \string"ALPHA\string"
    :sep \string"\@glsAlphacompositor\string"
    \string"arabic-numbers\string"%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdy@Lclass@arabic-section-numbers}
% Section number style locations (e.g.\ 1.1, 1.2, \ldots). The
% compositor is given by \ics{glscompositor}.
%    \begin{macrocode}
  \expandafter\def\csname @gls@xdy@Lclass@arabic-section-numbers\endcsname{%
    \string"arabic-numbers\string"
     :sep \string"\glscompositor\string"
    \string"arabic-numbers\string"%
  }%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdyuserlocationdefs}
% List of additional location definitions
% (separated by "^^J")
%    \begin{macrocode}
  \def\@xdyuserlocationdefs{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@xdyuserlocationnames}
% List of additional user location names
%    \begin{macrocode}
  \def\@xdyuserlocationnames{}
%    \end{macrocode}
%\end{macro}
%
% End of xindy-only block:
%    \begin{macrocode}
\fi
%    \end{macrocode}
%
%\begin{macro}{\GlsAddXdyLocation}
% \cs{GlsAddXdyLocation}\oarg{prefix-loc}\marg{name}\marg{definition}
% Define a new location called \meta{name}. The definition
% must use \app{xindy} syntax. (Note that this doesn't
% check to see if the location is already defined. That is left
% to \app{xindy} to complain about.)
%    \begin{macrocode}
\ifglsxindy
   \newcommand*{\GlsAddXdyLocation}[3][]{%
     \def\@gls@tmp{#1}%
     \ifx\@gls@tmp\@empty
       \edef\@xdyuserlocationdefs{%
          \@xdyuserlocationdefs ^^J%
          (define-location-class \string"#2\string"^^J\space\space
          \space(:sep \string"{}\glsopenbrace\string" #3 
                 :sep \string"\glsclosebrace\string"))
       }%
     \else
       \edef\@xdyuserlocationdefs{%
          \@xdyuserlocationdefs ^^J%
          (define-location-class \string"#2\string"^^J\space\space
          \space(:sep "\glsopenbrace"
                 #1
                 :sep "\glsclosebrace\glsopenbrace" #3
                 :sep "\glsclosebrace"))
       }%
     \fi
     \edef\@xdyuserlocationnames{%
        \@xdyuserlocationnames^^J\space\space\space
        \string"#1\string"}%
   }
%    \end{macrocode}
% Only has an effect before \ics{writeist}:
%    \begin{macrocode}
  \@onlypremakeg\GlsAddXdyLocation
\else
   \newcommand*{\GlsAddXdyLocation}[2]{%
     \glsnoxindywarning\GlsAddXdyLocation}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdylocationclassorder}
% Define location class order
%    \begin{macrocode}
\ifglsxindy
  \edef\@xdylocationclassorder{^^J\space\space\space
    \string"roman-page-numbers\string"^^J\space\space\space
    \string"arabic-page-numbers\string"^^J\space\space\space
    \string"arabic-section-numbers\string"^^J\space\space\space
    \string"alpha-page-numbers\string"^^J\space\space\space 
    \string"Roman-page-numbers\string"^^J\space\space\space
    \string"Alpha-page-numbers\string"^^J\space\space\space
    \string"Appendix-page-numbers\string"
    \@xdyuserlocationnames^^J\space\space\space
    \string"see\string"
   }
\fi
%    \end{macrocode}
%\end{macro}
% Change the location order.
%\begin{macro}{\GlsSetXdyLocationClassOrder}
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\GlsSetXdyLocationClassOrder[1]{%
    \def\@xdylocationclassorder{#1}}
\else
  \newcommand*\GlsSetXdyLocationClassOrder[1]{%
    \glsnoxindywarning\GlsSetXdyLocationClassOrder}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdysortrules}
% Define sort rules
%    \begin{macrocode}
\ifglsxindy
  \def\@xdysortrules{}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsAddSortRule}
% Add a sort rule
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\GlsAddSortRule[2]{%
    \expandafter\toks@\expandafter{\@xdysortrules}%
    \protected@edef\@xdysortrules{\the\toks@ ^^J
     (sort-rule \string"#1\string" \string"#2\string")}%
  }
\else
  \newcommand*\GlsAddSortRule[2]{%
    \glsnoxindywarning\GlsAddSortRule}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdyrequiredstyles}
% Define list of required styles (this should be a comma-separated
% list of \app{xindy} styles)
%    \begin{macrocode}
\ifglsxindy
  \def\@xdyrequiredstyles{tex}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsAddXdyStyle}
% Add a \app{xindy} style to the list of required styles
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\GlsAddXdyStyle[1]{%
    \edef\@xdyrequiredstyles{\@xdyrequiredstyles,#1}}%
\else
  \newcommand*\GlsAddXdyStyle[1]{%
    \glsnoxindywarning\GlsAddXdyStyle}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsSetXdyStyles}
% Reset the list of required styles
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\GlsSetXdyStyles[1]{%
    \edef\@xdyrequiredstyles{#1}}
\else
  \newcommand*\GlsSetXdyStyles[1]{%
    \glsnoxindywarning\GlsSetXdyStyles}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\findrootlanguage}
% The root language name is required by \app{xindy}. This
% information is for \app{makeglossaries} to pass to
% \app{xindy}. Since \ics{languagename} only stores the
% regional dialect rather than the root language name, some
% trickery is required to determine the root language.
%    \begin{macrocode}
\ifglsxindy
  \@ifpackageloaded{babel}{%
%    \end{macrocode}
% Need to parse \texttt{babel.sty} to determine the root language.
% This code was provided by Enrico~Gregorio.
%    \begin{macrocode}
  \def\findrootlanguage{\begingroup
    \escapechar=-1\relax
%    \end{macrocode}
% normalize \cs{languagename} to category 12 chars
%    \begin{macrocode}
    \edef\languagename{%
      \expandafter\string\csname\languagename\endcsname}%
%    \end{macrocode}
% disable \texttt{babel.sty} useless commands
%    \begin{macrocode}
    \def\NeedsTeXFormat##1[##2]{}%
    \def\ProvidesPackage##1[##2]{}%
    \let\LdfInit\relax
    \def\languageattribute##1##2{}%
%    \end{macrocode}
% change the meaning of \cs{DeclareOption}
%    \begin{macrocode}
    \def\DeclareOption##1##2{%
%    \end{macrocode}
% at \cs{DeclareOption*} we end
%    \begin{macrocode}
      \ifx##1*\expandafter\endinput\else
%    \end{macrocode}
% else we build a string with the first argument
%    \begin{macrocode}
      \edef\testlanguage{\expandafter\string\csname##1\endcsname}%
%    \end{macrocode}
% if \cs{testlanguage} and \cs{languagename} are the same
% we execute the second argument
%    \begin{macrocode}
      \ifx\testlanguage\languagename##2\fi
    \fi}
%    \end{macrocode}
% almost all options of babel are \cs{input}"{"\meta{name}".ldf}"
%    \begin{macrocode}
  \def\input##1{\stripldf##1}%
%    \end{macrocode}
% we put the root language name in \ics{rootlanguagename}
%    \begin{macrocode}
  \def\stripldf##1.ldf{\gdef\rootlanguagename{##1}}%
%    \end{macrocode}
% now input babel.sty, using the primitive \cs{input}
%    \begin{macrocode}
  \@@input babel.sty
  \endgroup}%
  }{%
%    \end{macrocode}
% \isty{babel} hasn't been loaded, so check if \isty{ngerman} has
% been loaded
%    \begin{macrocode}
    \@ifpackageloaded{ngerman}{%
       \def\findrootlanguage{%
         \def\rootlanguagename{german}}%
    }{%
%    \end{macrocode}
% Neither \sty{babel} nor \sty{ngerman} have been loaded, so
% assume the root language is English
%    \begin{macrocode}
       \def\findrootlanguage{%
         \def\rootlanguagename{english}}%
    }%
  }%
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\rootlanguagename}
% Set default root language to English.
%    \begin{macrocode}
\def\rootlanguagename{english}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdylanguage}
% The \app{xindy} language setting is required by 
% \app{makeglossaries}, so provide a command for 
% \app{makeglossaries} to pick up the information
% from the auxiliary file.  This command is not needed by the 
% \sty{glossaries} package, so define it to ignore its arguments.
%    \begin{macrocode}
\def\@xdylanguage#1#2{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsSetXdyLanguage}
% Define a command that allows the user to set the language
% for a given glossary type. The first argument indicates the
% glossary type. If omitted the main glossary is assumed.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*\GlsSetXdyLanguage[2][\glsdefaulttype]{%
  \ifglossaryexists{#1}{%
    \expandafter\def\csname @xdy@#1@language\endcsname{#2}%
  }{%
    \PackageError{glossaries}{Can't set language type for
    glossary type `#1' --- no such glossary}{%
    You have specified a glossary type that doesn't exist}}}
\else
  \newcommand*\GlsSetXdyLanguage[2][]{%
    \glsnoxindywarning\GlsSetXdyLanguage}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@codepage}
% The \app{xindy} codepage setting is required by 
% \app{makeglossaries}, so provide a command for 
% \app{makeglossaries} to pick up the information
% from the auxiliary file.  This command is not needed by the 
% \sty{glossaries} package, so define it to ignore its arguments.
%    \begin{macrocode}
\def\@gls@codepage#1#2{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsSetXdyCodePage}
% Define command to set the code page.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\GlsSetXdyCodePage}[1]{%
    \renewcommand*{\gls@codepage}{#1}%
  }
\else
  \newcommand*{\GlsSetXdyCodePage}[1]{%
    \glsnoxindywarning\GlsSetXdyCodePage}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@xdylettergroups}
% Store letter group definitions.
%    \begin{macrocode}
\ifglsxindy
  \ifgls@xindy@glsnumbers
    \def\@xdylettergroups{(define-letter-group
       \string"glsnumbers\string"^^J\space\space\space
       :prefixes (\string"0\string" \string"1\string"
       \string"2\string" \string"3\string" \string"4\string"
       \string"5\string" \string"6\string" \string"7\string"
       \string"8\string" \string"9\string")^^J\space\space\space
       :before \string"\@glsfirstletter\string")}
  \else
    \def\@xdylettergroups{}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsAddLetterGroup}
% Add a new letter group. The first argument is the name
% of the letter group. The second argument is the \app{xindy}
% code specifying prefixes and ordering.
%    \begin{macrocode}
  \newcommand*\GlsAddLetterGroup[2]{%
    \expandafter\toks@\expandafter{\@xdylettergroups}%
    \protected@edef\@xdylettergroups{\the\toks@^^J%
    (define-letter-group \string"#1\string"^^J\space\space\space#2)}%
  }%
%    \end{macrocode}
%\end{macro}
%
%\subsection{Loops and conditionals}
%\begin{macro}{\forallglossaries}
% To iterate through all glossaries (or comma-separated list of
% glossary names given in optional argument) use:\\[10pt]
% \cs{forallglossaries}\oarg{glossary list}\marg{cmd}\marg{code}\\[10pt]
% where \meta{cmd} is
% a control sequence which will be set to the name of the
% glossary in the current iteration.
%\changes{2.01}{2009 May 30}{replaced \cs{ifthenelse} with \cs{ifx}}
%    \begin{macrocode}
\newcommand*{\forallglossaries}[3][\@glo@types]{%
  \@for#2:=#1\do{\ifx#2\@empty\else#3\fi}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\forglsentries}
% To iterate through all entries in a given glossary use:\\[10pt]
%\cs{forglsentries}\oarg{type}\marg{cmd}\marg{code}\\[10pt]
%where \meta{type} is the glossary label and \meta{cmd} is a
% control sequence which will be set to the entry label in the
% current iteration.
%\changes{2.01}{2009 May 30}{replaced \cs{ifthenelse} with \cs{ifx}}
%    \begin{macrocode}
\newcommand*{\forglsentries}[3][\glsdefaulttype]{%
  \edef\@@glo@list{\csname glolist@#1\endcsname}%
  \@for#2:=\@@glo@list\do{\ifx#2\@empty\else#3\fi}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\forallglsentries}
% To iterate through all glossary entries over all glossaries listed
% in the optional argument (the default is all glossaries) use:\\[10pt] 
% \cs{forallglsentries}\oarg{glossary list}\marg{cmd}\marg{code}\\[10pt]
% Within \cs{forallglsentries}, the current glossary type
% is given by \cs{@@this@glo@}.
%    \begin{macrocode}
\newcommand*{\forallglsentries}[3][\@glo@types]{%
\expandafter\forallglossaries\expandafter[#1]{\@@this@glo@}{%
\forglsentries[\@@this@glo@]{#2}{#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglossaryexists}
% To check to see if a glossary exists use:\\[10pt]
%\cs{ifglossaryexists}\marg{type}\marg{true-text}\marg{false-text}\\[10pt]
%where \meta{type} is the glossary's label.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand{\ifglossaryexists}[3]{%
  \ifcsundef{@glotype@#1@out}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglsentryexists}
% To check to see if a glossary entry has been defined use:\\[10pt]
% \cs{ifglsentryexists}\marg{label}\marg{true text}\marg{false text}\\[10pt]
%where \meta{label} is the entry's label.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand{\ifglsentryexists}[3]{%
  \ifcsundef{glo@#1@name}{#3}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglsused}
% To determine if given glossary entry has been 
% used in the document text yet use:\\[10pt]
% \cs{ifglsused}\marg{label}\marg{true text}\marg{false text}\\[10pt]
% where \meta{label} is the entry's label.
% If true it will do \meta{true text}
% otherwise it will do \meta{false text}.
%    \begin{macrocode}
\newcommand*{\ifglsused}[3]{\ifthenelse{\boolean{glo@#1@flag}}{#2}{#3}}
%    \end{macrocode}
%\end{macro}
%The following two commands will cause an error if the given
% condition fails:
%
%\begin{macro}{\glsdoifexists}
%\cs{glsdoifexists}\marg{label}\marg{code}\par
% Generate an error if entry specified by \meta{label} doesn't 
% exists, otherwise do \meta{code}.
%    \begin{macrocode}
\newcommand{\glsdoifexists}[2]{%
  \ifglsentryexists{#1}{#2}{%
    \PackageError{glossaries}{Glossary entry `#1' has not been
    defined}{You need to define a glossary entry before you
    can use it.}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdoifnoexists}
%\cs{glsdoifnoexists}\marg{label}\marg{code}\par
% The opposite: only do second argument if the entry doesn't
% exists. Generate an error message if it exists.
%    \begin{macrocode}
\newcommand{\glsdoifnoexists}[2]{%
  \ifglsentryexists{#1}{%
    \PackageError{glossaries}{Glossary entry `#1' has already
    been defined}{}}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshaschildren}
% \cs{ifglshaschildren}\marg{label}\marg{true part}\marg{false part}
%\changes{3.02}{2012/05/21}{new}
%    \begin{macrocode}
\newcommand{\ifglshaschildren}[3]{%
  \glsdoifexists{#1}%
  {%
     \def\do@glshaschildren{#3}%
     \expandafter\forglsentries\expandafter[\csname glo@#1@type\endcsname]
     {\glo@label}%
     {%
       \letcs\glo@parent{glo@\glo@label @parent}%
       \ifthenelse{\equal{#1}{\glo@parent}}%
       {%
         \def\do@glshaschildren{#2}%
         \@endfortrue
       }%
       {}%
     }%
     \do@glshaschildren
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshasparent}
% \cs{ifglshaschildren}\marg{label}\marg{true part}\marg{false part}
%\changes{3.02}{2012/05/21}{new}
%    \begin{macrocode}
\newcommand{\ifglshasparent}[3]{%
  \glsdoifexists{#1}%
  {%
    \ifcsempty{glo@#1@parent}{#3}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Defining new glossaries}\label{sec:newglos}
% A comma-separated list of glossary names is stored
% in \cs{@glo@types}. When a new glossary type
% is created, its identifying name is added to this list.
% This is used by commands that iterate through all glossaries
% (such as \ics{makeglossaries} and \ics{printglossaries}).
%\begin{macro}{\@glo@types}
%    \begin{macrocode}
\newcommand*{\@glo@types}{,}
%    \end{macrocode}
%\end{macro}
%
% A new glossary type is defined using \cs{newglossary}.
% Syntax:\\[10pt]\cs{newglossary}\oarg{log-ext}\marg{name}\marg{in-ext}\marg{out-ext}%
%\marg{title}\oarg{counter}\\[10pt]%
% where \meta{log-ext} is the extension of the \app{makeindex}
% transcript file, \meta{in-ext} is the extension of the glossary 
% input file (read in by \ics{printglossary} and created by
% \app{makeindex}), \meta{out-ext} is the extension of the
% glossary output file which is read in by \app{makeindex} 
% (lines are written to this file by the \ics{glossary} command),
% \meta{title} is the title of the glossary that is used in
% \ics{glossarysection} and
% \meta{counter} is the default counter to be used by entries
% belonging to this glossary. The \app{makeglossaries} Perl
% script reads in the relevant extensions from the auxiliary file,
% and passes the appropriate file names and switches to 
% \app{makeindex}.
%\begin{macro}{\newglossary}
%    \begin{macrocode}
\newcommand*{\newglossary}[5][glg]{%
\ifglossaryexists{#2}{%
  \PackageError{glossaries}{Glossary type `#2' already exists}{%
  You can't define a new glossary called `#2' because it already
  exists}%
}{%
%    \end{macrocode}
% Check if default has been set
%    \begin{macrocode}
  \ifx\glsdefaulttype\relax
    \gdef\glsdefaulttype{#2}%
  \fi
%    \end{macrocode}
% Add this to the list of glossary types:
%    \begin{macrocode}
  \toks@{#2}\edef\@glo@types{\@glo@types\the\toks@,}%
%    \end{macrocode}
% Define a comma-separated list of labels for this glossary type, 
% so that all the entries for this glossary can be reset with a 
% single command. When a new entry is created, its label is added
% to this list.
%    \begin{macrocode}
  \expandafter\gdef\csname glolist@#2\endcsname{,}%
%    \end{macrocode}
% Store details of this new glossary type:
%    \begin{macrocode}
  \expandafter\def\csname @glotype@#2@in\endcsname{#3}%
  \expandafter\def\csname @glotype@#2@out\endcsname{#4}%
  \expandafter\def\csname @glotype@#2@title\endcsname{#5}%
  \protected@write\@auxout{}{\string\@newglossary{#2}{#1}{#3}{#4}}%
%    \end{macrocode}
% How to display this entry in the document text (uses
% \cs{glsdisplay} and \cs{glsdisplayfirst} by
% default). These can be redefined by the user later if required
% (see \ics{defglsdisplay} and \ics{defglsdisplayfirst}). These
% may already have been defined if this has been specified as 
% a list of acronyms.
%\changes{2.04}{2009 November 10}{added check to determine if 
% \cs{gls@\meta{type}@display} and \cs{gls@\meta{type}@displayfirst}
% have been defined.}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
  \ifcsundef{gls@#2@display}%
  {%
    \expandafter\gdef\csname gls@#2@display\endcsname{\glsdisplay}%
  }%
  {}%
  \ifcsundef{gls@#2@displayfirst}%
  {%
    \expandafter\gdef\csname gls@#2@displayfirst\endcsname{%
      \glsdisplayfirst
    }%
  }%
  {}%
%    \end{macrocode}
% Define sort counter if required:
%\changes{3.0}{2011/04/02}{added \cs{@gls@defsortcount}}
%    \begin{macrocode}
  \@gls@defsortcount{#2}%
%    \end{macrocode}
% Find out if the final optional argument has been specified, and
% use it to set the counter associated with this glossary. (Uses
% \ics{glscounter} if no optional argument is present.)
%    \begin{macrocode}
  \@ifnextchar[{\@gls@setcounter{#2}}%
    {\@gls@setcounter{#2}[\glscounter]}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\altnewglossary}
%\changes{2.06}{2010 June 14}{new}
%    \begin{macrocode}
\newcommand*{\altnewglossary}[3]{%
  \newglossary[#2-glg]{#1}{#2-gls}{#2-glo}{#3}%
}
%    \end{macrocode}
%\end{macro}
% Only define new glossaries in the preamble:
%    \begin{macrocode}
\@onlypreamble{\newglossary}
%    \end{macrocode}
% Only define new glossaries before \ics{makeglossaries}
%    \begin{macrocode}
\@onlypremakeg\newglossary
%    \end{macrocode}
%\cs{@newglossary} is used to specify the file extensions
% for the \app{makeindex} input, output and transcript files.
% It is written to the auxiliary file by \ics{newglossary}.
% Since it is not used by \LaTeX, \cs{@newglossary} simply
% ignores its arguments.
%\begin{macro}{\@newglossary}
%    \begin{macrocode}
\newcommand*{\@newglossary}[4]{}
%    \end{macrocode}
%\end{macro}
% Store counter to be used for given glossary type (the first
% argument is the glossary label, the second argument is the name 
% of the counter):
%\begin{macro}{\@gls@setcounter}
%    \begin{macrocode}
\def\@gls@setcounter#1[#2]{%
  \expandafter\def\csname @glotype@#1@counter\endcsname{#2}%
%    \end{macrocode}
% Add counter to xindy list, if not already added:
%    \begin{macrocode}
  \ifglsxindy
    \GlsAddXdyCounters{#2}%
  \fi
}
%    \end{macrocode}
%\end{macro}
% Get counter associated with given glossary (the argument is
% the glossary label):
%\begin{macro}{\@gls@getcounter}
%    \begin{macrocode}
\newcommand*{\@gls@getcounter}[1]{%
\csname @glotype@#1@counter\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Define the main glossary. This will be the first glossary to
% be displayed when using \ics{printglossaries}.
%    \begin{macrocode}
\glsdefmain
%    \end{macrocode}
%
%\subsection{Defining new entries}\label{sec:newentry}
% New glossary entries are defined using \cs{newglossaryentry}.
% This command requires a label and a key-value list that defines
% the relevant information for that entry. The definition for these
% keys follows. Note that the \gloskey{name},
% \gloskey{description} and \gloskey{symbol} keys will be
% sanitized later, depending on the value of the package option
% \pkgopt{sanitize} (this means that if some of the keys haven't
% been defined, they can be constructed from the \gloskey{name}
% and \gloskey{description} key before they are sanitized).
%
%
%\begin{key}{name}
%The \gloskey{name} key indicates the name
% of the term being defined. This is how the term will appear in
% the glossary. The \gloskey{name} key is required when defining
% a new glossary entry.
%    \begin{macrocode}
\define@key{glossentry}{name}{%
\def\@glo@name{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{description}
% The \gloskey{description} key is usually only used in
% the glossary, but can be made to appear in the text by redefining
% \ics{glsdisplay} and \ics{glsdisplayfirst} (or
% using \ics{defglsdisplay} and \ics{defglsdisplayfirst}), however,
% you will have to disable the sanitize option (using the 
% \pkgopt{sanitize} package option, 
% "sanitize={description=false}", and protect fragile
% commands). The \gloskey{description} key is required when
% defining a new glossary entry. (Be careful not to make the
% description too long, because \app{makeindex} has a limited
% buffer. \cs{@glo@desc} is defined to be a short command 
% to discourage lengthy descriptions
% for this reason. If you do have a very long description, or if
% you require paragraph breaks, define a separate command that 
% contains the description, and use it as the value to the 
% \gloskey{description} key.)
%    \begin{macrocode}
\define@key{glossentry}{description}{%
\def\@glo@desc{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{descriptionplural}
% \changes{1.12}{2008 Mar 8}{new}
%    \begin{macrocode}
\define@key{glossentry}{descriptionplural}{%
\def\@glo@descplural{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{sort}
% The \gloskey{sort} key needs to be sanitized here 
% (the sort key is provided for \app{makeindex}'s benefit, 
% not for use in the document). The \gloskey{sort} key is optional
% when defining a new glossary entry. If omitted, the value 
% is given by \meta{name} \meta{description}.
%\changes{1.18}{2009 January 14}{moved sanitization to 'newglossaryentry}
%    \begin{macrocode}
\define@key{glossentry}{sort}{%
\def\@glo@sort{#1}}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{text}
% The \gloskey{text} key determines how the term should appear when
% used in the document (i.e.\ outside of the glossary). If omitted, 
% the value of the \gloskey{name} key is used instead.
%    \begin{macrocode}
\define@key{glossentry}{text}{%
\def\@glo@text{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{plural}
% The \gloskey{plural} key determines how the plural form of the term
% should be displayed in the document. If omitted, the plural is
% constructed by appending \ics{glspluralsuffix} to the value of the 
% \gloskey{text} key.
%    \begin{macrocode}
\define@key{glossentry}{plural}{%
\def\@glo@plural{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{first}
% The \gloskey{first} key determines how the entry should be displayed
% in the document when it is first used. If omitted, it is taken
% to be the same as the value of the \gloskey{text} key.
%    \begin{macrocode}
\define@key{glossentry}{first}{%
\def\@glo@first{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{firstplural}
% The \gloskey{firstplural} key is used to set the plural form for
% first use, in the event that the plural is required the first 
% time the term is used. If omitted, it is constructed by 
% appending \ics{glspluralsuffix} to the value of the \gloskey{first} key.
%    \begin{macrocode}
\define@key{glossentry}{firstplural}{%
\def\@glo@firstplural{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{symbol}
% The \gloskey{symbol} key is ignored by most of the predefined
% glossary styles, and defaults to \cs{relax} if omitted. 
% It is provided for glossary styles that require an associated 
% symbol, as well as a name and description. To make this value 
% appear in the glossary, you need to redefine 
% \ics{glossaryentryfield} so that it uses its fourth parameter.
% If you want this value to appear in the text when the term is used 
% by commands like \ics{gls}, you will need to change
% \ics{glsdisplay} and \ics{glsdisplayfirst} (either 
% explicitly for all glossaries or via \ics{defglsdisplay}
% and \ics{defglsdisplayfirst} for individual glossaries).
%    \begin{macrocode}
\define@key{glossentry}{symbol}{%
\def\@glo@symbol{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{symbolplural}
% \changes{1.12}{2008 Mar 8}{new}
%    \begin{macrocode}
\define@key{glossentry}{symbolplural}{%
\def\@glo@symbolplural{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{type}
% The \gloskey{type} key specifies to which glossary this
% entry belongs. If omitted, the default glossary is used.
%    \begin{macrocode}
\define@key{glossentry}{type}{%
\def\@glo@type{#1}}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{counter}
% The \gloskey{counter} key specifies the name of the counter 
% associated with this glossary entry:
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\define@key{glossentry}{counter}{%
  \ifcsundef{c@#1}%
  {%
    \PackageError{glossaries}%
    {There is no counter called `#1'}%
    {%
      The counter key should have the name of a valid counter 
      as its value%
    }%
  }%
  {%
    \def\@glo@counter{#1}%
  }%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{see}
% The \gloskey{see} key specifies a list of cross-references
% \changes{1.17}{2008 December 26}{new}
% \changes{3.0}{2011/04/02}{added \cs{@glo@seeautonumberlist}}
%    \begin{macrocode}
\define@key{glossentry}{see}{%
  \def\@glo@see{#1}%
  \@glo@seeautonumberlist
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{parent}
% The \gloskey{parent} key specifies the parent entry, if
% required.
% \changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\define@key{glossentry}{parent}{%
\def\@glo@parent{#1}}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{nonumberlist}
% The \gloskey{nonumberlist} key suppresses or activates the number list
% for the given entry.
% \changes{1.17}{2008 December 26}{new}
%\changes{3.0}{2011/04/02}{now boolean}
%    \begin{macrocode}
\define@choicekey{glossentry}{nonumberlist}[\val\nr]{true,false}[true]{%
  \ifcase\nr\relax
    \def\@glo@prefix{\glsnonextpages}%
  \else
    \def\@glo@prefix{\glsnextpages}%
  \fi
}
%    \end{macrocode}
%\end{key}
%
% Define some generic user keys. (6 ought to be enough!)
%\begin{key}{user1}
%    \begin{macrocode}
\define@key{glossentry}{user1}{%
  \def\@glo@useri{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{user2}
%    \begin{macrocode}
\define@key{glossentry}{user2}{%
  \def\@glo@userii{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{user3}
%    \begin{macrocode}
\define@key{glossentry}{user3}{%
  \def\@glo@useriii{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{user4}
%    \begin{macrocode}
\define@key{glossentry}{user4}{%
  \def\@glo@useriv{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{user5}
%    \begin{macrocode}
\define@key{glossentry}{user5}{%
  \def\@glo@userv{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{user6}
%    \begin{macrocode}
\define@key{glossentry}{user6}{%
  \def\@glo@uservi{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{short}
%\changes{3.0}{2011/04/02}{new}
% This key is provided for use by \ics{newacronym}. It's not
% designed for general purpose use, so isn't described in the user
% manual.
%    \begin{macrocode}
\define@key{glossentry}{short}{%
  \def\@glo@short{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{shortplural}
%\changes{3.0}{2011/04/02}{new}
% This key is provided for use by \ics{newacronym}.
%    \begin{macrocode}
\define@key{glossentry}{shortplural}{%
  \def\@glo@shortpl{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{long}
%\changes{3.0}{2011/04/02}{new}
% This key is provided for use by \ics{newacronym}.
%    \begin{macrocode}
\define@key{glossentry}{long}{%
  \def\@glo@long{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{key}{longplural}
%\changes{3.0}{2011/04/02}{new}
% This key is provided for use by \ics{newacronym}.
%    \begin{macrocode}
\define@key{glossentry}{longplural}{%
  \def\@glo@longpl{#1}%
}
%    \end{macrocode}
%\end{key}
%
%\begin{macro}{\@glsnoname}
% \changes{1.17}{2008 December 26}{new}
% Define command to generate error if \gloskey{name} key is missing.
%    \begin{macrocode}
\newcommand*{\@glsnoname}{%
  \PackageError{glossaries}{name key required in 
  \string\newglossaryentry\space for entry `\@glo@label'}{You 
  haven't specified the entry name}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsdefaultplural}
% Define command to set default plural.
% \changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\newcommand*{\@glsdefaultplural}{\@glo@text\glspluralsuffix}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@missingnumberlist}
%\changes{3.02}{2012/05/21}{new}
% Define a command to generate warning when numberlist not set.
%    \begin{macrocode}
\newcommand*{\@gls@missingnumberlist}[1]{%
  ??%
  \ifglssavenumberlist
    \GlossariesWarning{Missing number list for entry `#1'. 
     Maybe makeglossaries + rerun required.}%
  \else
    \PackageError{glossaries}%
    {Package option `savenumberlist=true' required.}%
    {%
      You must use the `savenumberlist' package option
      to reference location lists.%
    }%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdefaultsort}
% Define command to set default sort.
% \changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\newcommand*{\@glsdefaultsort}{\@glo@name}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@level}
% Register to increment entry levels.
%    \begin{macrocode}
\newcount\gls@level
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newglossaryentry}
% Define \cs{newglossaryentry}%
% \marg{label} \marg{key-val list}. 
% There are two required fields in \meta{key-val list}: 
% \gloskey{name} (or \gloskey{parent}) and 
% \gloskey{description}. (See above.)
%\changes{3.0}{2011/04/02}{replaced \cs{DeclareRobustCommand} with
%\cs{newrobustcmd}}
%    \begin{macrocode}
\newrobustcmd{\newglossaryentry}[2]{%
%    \end{macrocode}
% Check to see if this glossary entry has already been defined:
%    \begin{macrocode}
  \glsdoifnoexists{#1}%
  {%
%    \end{macrocode}
% Store label
%    \begin{macrocode}
    \def\@glo@label{#1}%
%    \end{macrocode}
% Set up defaults. If the \gloskey{name} or \gloskey{description}
% keys are omitted, an error will be generated.
%    \begin{macrocode}
    \let\@glo@name\@glsnoname
%    \end{macrocode}
%\changes{1.08}{2007 Oct 13}{Fixed error message to say ``description
%key'' rather than ``desc key''}
%    \begin{macrocode}
    \def\@glo@desc{%
      \PackageError{glossaries}
      {%
        description key required in \string\newglossaryentry\space
        for entry `\@glo@label'%
      }%
      {%
        You haven't specified the entry description%
      }%
    }%
%    \end{macrocode}
% \changes{1.12}{2008 Mar 8}{descriptionplural support added}
%    \begin{macrocode}
    \def\@glo@descplural{\@glo@desc}%
%    \end{macrocode}
%    \begin{macrocode}
    \def\@glo@type{\glsdefaulttype}%
    \def\@glo@symbol{\relax}%
%    \end{macrocode}
% \changes{1.12}{2008 Mar 8}{symbolplural support added}
%    \begin{macrocode}
    \def\@glo@symbolplural{\@glo@symbol}%
%    \end{macrocode}
%    \begin{macrocode}
    \def\@glo@text{\@glo@name}%
%    \end{macrocode}
%    \begin{macrocode}
    \let\@glo@plural\@glsdefaultplural
%    \end{macrocode}
% \changes{1.13}{2008 May 10}{Changed default first value}
% Using \cs{let} instead of \cs{def} to make later comparison
% avoid expansion issues. (Thanks to Ulrich~Diez for suggesting
% this.)
% \changes{1.16}{2008 August 27}{Changed def to let}
%    \begin{macrocode}
    \let\@glo@first\relax
%    \end{macrocode}
% \changes{1.12}{2008 Mar 8}{Changed default first plural to be first
% key with s appended (was text key with s appended)}
% \changes{1.13}{2008 May 10}{Changed default firstplural value}
%    \begin{macrocode}
    \let\@glo@firstplural\relax
%    \end{macrocode}
% Set the default sort:
%\changes{1.05}{2007 Aug 10}{Changed the default value of the sort
% key to just the value of the name key}%
%\changes{1.18}{2009 January 14}{Changed default value of sort
% to '@glsdefaultsort}
%    \begin{macrocode}
    \let\@glo@sort\@glsdefaultsort
%    \end{macrocode}
% Set the default counter:
%    \begin{macrocode}
    \def\@glo@counter{\@gls@getcounter{\@glo@type}}%
%    \end{macrocode}
%\changes{1.17}{2008 December 26}{added see key}
%    \begin{macrocode}
    \def\@glo@see{}%
%    \end{macrocode}
%\changes{1.17}{2008 December 26}{added parent key}
%    \begin{macrocode}
    \def\@glo@parent{}%
%    \end{macrocode}
%\changes{1.17}{2008 December 26}{added nonumberlist key}
%    \begin{macrocode}
    \def\@glo@prefix{}%
%    \end{macrocode}
%\changes{2.04}{2009 November 10}{added user1-6 keys}
%    \begin{macrocode}
    \def\@glo@useri{}%
    \def\@glo@userii{}%
    \def\@glo@useriii{}%
    \def\@glo@useriv{}%
    \def\@glo@userv{}%
    \def\@glo@uservi{}%
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added short and long keys}
%    \begin{macrocode}
    \def\@glo@short{}%
    \def\@glo@shortpl{}%
    \def\@glo@long{}%
    \def\@glo@longpl{}%
%    \end{macrocode}
% Add start hook in case another package wants to add extra keys.
%    \begin{macrocode}
    \@newglossaryentryprehook
%    \end{macrocode}
% Extract key-val information from third parameter:
%    \begin{macrocode}
    \setkeys{glossentry}{#2}%
%    \end{macrocode}
% Check to see if this glossary type has been defined, if it has,
% add this label to the relevant list, otherwise generate an error.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
    \ifcsundef{glolist@\@glo@type}%
    {%
      \PackageError{glossaries}%
      {Glossary type '\@glo@type' has not been defined}%
      {You need to define a new glossary type, before making entries
       in it}%
    }%
    {%
      \protected@edef\@glolist@{\csname glolist@\@glo@type\endcsname}%
      \expandafter\xdef\csname glolist@\@glo@type\endcsname{\@glolist@{#1},}%
    }%
%    \end{macrocode}
% Initialise level to 0.
%    \begin{macrocode}
    \gls@level=0\relax
%    \end{macrocode}
% Has this entry been assigned a parent?
%    \begin{macrocode}
    \ifx\@glo@parent\@empty
%    \end{macrocode}
% Doesn't have a parent. Set \cs{glo@}\meta{label}"@parent" to
% empty.
%    \begin{macrocode}
      \expandafter\gdef\csname glo@#1@parent\endcsname{}%
    \else
%    \end{macrocode}
% Has a parent. Check to ensure this entry isn't its own parent.
%    \begin{macrocode}
      \ifthenelse{\equal{#1}{\@glo@parent}}%
      {%
        \PackageError{glossaries}{Entry `#1' can't be its own parent}{}%
        \def\@glo@parent{}%
        \expandafter\gdef\csname glo@#1@parent\endcsname{}%
      }%
      {%
%    \end{macrocode}
% Check the parent exists:
%    \begin{macrocode}
        \ifglsentryexists{\@glo@parent}%
        {%
%    \end{macrocode}
% Parent exists. Set \cs{glo@}\meta{label}"@parent".
%    \begin{macrocode}
          \expandafter\xdef\csname glo@#1@parent\endcsname{\@glo@parent}%
%    \end{macrocode}
% Determine level.
%    \begin{macrocode}
          \gls@level=\csname glo@\@glo@parent @level\endcsname\relax
          \advance\gls@level by 1\relax
%    \end{macrocode}
% If name hasn't been specified, use same as the parent name
%    \begin{macrocode}
          \ifx\@glo@name\@glsnoname
            \expandafter\let\expandafter\@glo@name
               \csname glo@\@glo@parent @name\endcsname
%    \end{macrocode}
% If name and plural haven't been specified, use same as the parent
%    \begin{macrocode}
            \ifx\@glo@plural\@glsdefaultplural
              \expandafter\let\expandafter\@glo@plural
                 \csname glo@\@glo@parent @plural\endcsname
            \fi
          \fi
        }%
        {%
%    \end{macrocode}
% Parent doesn't exist, so issue an error message and change this
% entry to have no parent
%    \begin{macrocode}
          \PackageError{glossaries}%
          {%
            Invalid parent `\@glo@parent'
            for entry `#1' - parent doesn't exist%
          }%
          {%
            Parent entries must be defined before their children%
          }%
          \def\@glo@parent{}%
          \expandafter\gdef\csname glo@#1@parent\endcsname{}%
        }%
      }%
    \fi
%    \end{macrocode}
% Set the level for this entry
%    \begin{macrocode}
    \expandafter\xdef\csname glo@#1@level\endcsname{\number\gls@level}%
%    \end{macrocode}
% Check if \gloskey{first} and \gloskey{firstplural} have been use.
% If \gloskey{firstplural} hasn't been specified, but \gloskey{first}
% has been specified, then form \gloskey{firstplural} by appending
% \cs{glspluralsuffix} to value of \gloskey{first} key, otherwise
% obtain the value from the \gloskey{plural} key.
% \changes{1.16}{2008 August 27}{Changed if to ifx}
% This now uses \cs{ifx} instead of \cs{if} to avoid expansion
% issues. (Thanks to Ulrich~Diez for suggesting this.)
%    \begin{macrocode}
    \ifx\relax\@glo@firstplural
       \ifx\relax\@glo@first
          \def\@glo@firstplural{\@glo@plural}%
          \def\@glo@first{\@glo@text}%
       \else
          \def\@glo@firstplural{\@glo@first\glspluralsuffix}%
       \fi
    \else
       \ifx\relax\@glo@first
          \def\@glo@first{\@glo@text}%
       \fi
    \fi
%    \end{macrocode}
% Define commands associated with this entry:
%    \begin{macrocode}
    \expandafter
      \protected@xdef\csname glo@#1@text\endcsname{\@glo@text}%
    \expandafter
      \protected@xdef\csname glo@#1@plural\endcsname{\@glo@plural}%
    \expandafter
      \protected@xdef\csname glo@#1@first\endcsname{\@glo@first}%
    \expandafter
      \protected@xdef\csname glo@#1@firstpl\endcsname{\@glo@firstplural}%
    \expandafter
      \protected@xdef\csname glo@#1@type\endcsname{\@glo@type}%
    \expandafter
      \protected@xdef\csname glo@#1@counter\endcsname{\@glo@counter}%
    \expandafter
      \protected@xdef\csname glo@#1@useri\endcsname{\@glo@useri}%
    \expandafter
      \protected@xdef\csname glo@#1@userii\endcsname{\@glo@userii}%
    \expandafter
      \protected@xdef\csname glo@#1@useriii\endcsname{\@glo@useriii}%
    \expandafter
      \protected@xdef\csname glo@#1@useriv\endcsname{\@glo@useriv}%
    \expandafter
      \protected@xdef\csname glo@#1@userv\endcsname{\@glo@userv}%
    \expandafter
      \protected@xdef\csname glo@#1@uservi\endcsname{\@glo@uservi}%
    \expandafter
      \protected@xdef\csname glo@#1@short\endcsname{\@glo@short}%
    \expandafter
      \protected@xdef\csname glo@#1@shortpl\endcsname{\@glo@shortpl}%
    \expandafter
      \protected@xdef\csname glo@#1@long\endcsname{\@glo@long}%
    \expandafter
      \protected@xdef\csname glo@#1@longpl\endcsname{\@glo@longpl}%
    \@gls@sanitizename
    \expandafter\protected@xdef\csname glo@#1@name\endcsname{\@glo@name}%
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{added numberlist element}
% Set default numberlist if not defined:
%    \begin{macrocode}
    \ifcsundef{glo@#1@numberlist}%
    {%
      \csxdef{glo@#1@numberlist}{\noexpand\@gls@missingnumberlist{\@glo@label}}%
    }%
    {}%
%    \end{macrocode}
% The smaller and smallcaps options set the description to 
% \cs{@glo@first}. Need to check for this, otherwise it won't get
% expanded if the description gets sanitized.
%\changes{1.15}{2008 August 15}{check for '@glo@first in description}%
%    \begin{macrocode}
    \def\@glo@@desc{\@glo@first}%
    \ifx\@glo@desc\@glo@@desc
      \let\@glo@desc\@glo@first
    \fi
    \@gls@sanitizedesc
    \expandafter\protected@xdef\csname glo@#1@desc\endcsname{\@glo@desc}%
    \expandafter\protected@xdef\csname glo@#1@descplural\endcsname{\@glo@descplural}%
%    \end{macrocode}
%\changes{1.18}{2009 January 14}{moved sort sanitization to
% 'newglossaryentry}
%\changes{3.0}{2011/04/02}{added \cs{@gls@defsort}}
% Set the sort key for this entry:
%    \begin{macrocode}
    \@gls@defsort{\@glo@type}{#1}%
%    \end{macrocode}
%\changes{1.15}{2008 August 15}{check for '@glo@text in symbol}%
%    \begin{macrocode}
    \def\@glo@@symbol{\@glo@text}%
    \ifx\@glo@symbol\@glo@@symbol
      \let\@glo@symbol\@glo@text
    \fi
    \@gls@sanitizesymbol
    \expandafter\protected@xdef\csname glo@#1@symbol\endcsname{\@glo@symbol}%
    \expandafter\protected@xdef\csname glo@#1@symbolplural\endcsname{\@glo@symbolplural}%
%    \end{macrocode}
% Define an associated boolean variable to determine whether this
% entry has been used yet (needs to be defined globally):
%    \begin{macrocode}
    \expandafter\gdef\csname glo@#1@flagfalse\endcsname{%
      \expandafter\global\expandafter
        \let\csname ifglo@#1@flag\endcsname\iffalse
    }%
    \expandafter\gdef\csname glo@#1@flagtrue\endcsname{%
      \expandafter\global\expandafter
      \let\csname ifglo@#1@flag\endcsname\iftrue
    }%
    \csname glo@#1@flagfalse\endcsname
%    \end{macrocode}
% Sort out any cross-referencing if required.
%    \begin{macrocode}
    \ifx\@glo@see\@empty
    \else
      \protected@edef\@do@glssee{%
        \noexpand\@gls@fixbraces\noexpand\@glo@list\@glo@see
          \noexpand\@nil
        \noexpand\expandafter\noexpand\@glssee\noexpand\@glo@list{#1}}%
      \@do@glssee
    \fi
  }%
%    \end{macrocode}
% Determine and store main part of the entry's index format.
%\changes{1.17}{2008 December 26}{Stored main part of entry 
% format when entry
% is defined}%
%    \begin{macrocode}
  \do@glo@storeentry{#1}%
%    \end{macrocode}
% Add end hook in case another package wants to add extra keys.
%    \begin{macrocode}
  \@newglossaryentryposthook
}
%    \end{macrocode}
%\changes{1.13}{2008 May 10}{Removed restriction on only using
% 'newglossaryentry in the preamble}
%\end{macro}
%\begin{macro}{\@newglossaryentryprehook}
% Allow extra information to be added to glossary entries:
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\@newglossaryentryprehook}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@newglossaryentryposthook}
% Allow extra information to be added to glossary entries:
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\@newglossaryentryposthook}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsmoveentry}
%\changes{3.02}{2012/05/21}{new}
% Moves entry whose label is given by first argument to the glossary
% named in the second argument.
%    \begin{macrocode}
\newcommand*{\glsmoveentry}[2]{%
  \edef\glo@type{\csname glo@#1@type\endcsname}%
  \def\glo@list{,}%
  \forglsentries[\glo@type]{\glo@label}%
   {%
     \ifthenelse{\equal{\glo@label}{#1}}{}{\eappto\glo@list{\glo@label,}}%
   }%
  \cslet{glolist@\glo@type}{\glo@list}%
  \csdef{glo@#1@type}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glossaryentryfield}
% Indicate what command should be used to display each entry in
% the glossary. (This enables the \sty{glossaries-accsupp} package
% to use \cs{accsuppglossaryentryfield} instead.)
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@glossaryentryfield}{\string\\glossaryentryfield}
\else
  \newcommand*{\@glossaryentryfield}{\string\glossaryentryfield}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glossarysubentryfield}
% Indicate what command should be used to display each subentry in
% the glossary. (This enables the \sty{glossaries-accsupp} package
% to use \cs{accsuppglossarysubentryfield} instead.)
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@glossarysubentryfield}{%
    \string\\glossarysubentryfield}
\else
  \newcommand*{\@glossarysubentryfield}{%
    \string\glossarysubentryfield}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@storeentry}
%\changes{1.17}{2008 December 26}{new}
% Determine the format to write the entry in the glossary 
% output (\filetype{.glo}) file.
% The argument is the entry's label.
% The result is stored in \cs{glo@}\meta{label}"@entry", where
% \meta{label} is the entry's label. (This doesn't include
% any formatting or location information.)
%    \begin{macrocode}
\newcommand{\@glo@storeentry}[1]{%
%    \end{macrocode}
% Get the sort string and escape any special characters
%    \begin{macrocode}
\protected@edef\@glo@sort{\csname glo@#1@sort\endcsname}%
\@gls@checkmkidxchars\@glo@sort
%    \end{macrocode}
% Same again for the name string.
%    \begin{macrocode}
\protected@edef\@@glo@name{\csname glo@#1@name\endcsname}%
\@gls@checkmkidxchars\@@glo@name
%    \end{macrocode}
% Add the font command. (The backslash needs to be escaped for
% \app{xindy}.)
%    \begin{macrocode}
\ifglsxindy
  \protected@edef\@glo@name{\string\\glsnamefont{\@@glo@name}}%
\else
  \protected@edef\@glo@name{\string\glsnamefont{\@@glo@name}}%
\fi
%    \end{macrocode}
% Get the description string and escape any special characters
%    \begin{macrocode}
\protected@edef\@glo@desc{\csname glo@#1@desc\endcsname}%
\@gls@checkmkidxchars\@glo@desc
%    \end{macrocode}
% Same again for the symbol
%    \begin{macrocode}
\protected@edef\@glo@symbol{\csname glo@#1@symbol\endcsname}%
\@gls@checkmkidxchars\@glo@symbol
%    \end{macrocode}
% Escape any special characters in the prefix
%    \begin{macrocode}
\@gls@checkmkidxchars\@glo@prefix
%    \end{macrocode}
% Get the parent, if one exists
%    \begin{macrocode}
\edef\@glo@parent{\csname glo@#1@parent\endcsname}%
%    \end{macrocode}
% Write the information to the glossary file.
%    \begin{macrocode}
\ifglsxindy
%    \end{macrocode}
% Store using \app{xindy} syntax.
%    \begin{macrocode}
  \ifx\@glo@parent\@empty
%    \end{macrocode}
% Entry doesn't have a parent
%    \begin{macrocode}
    \expandafter\protected@xdef\csname glo@#1@index\endcsname{%
     (\string"\@glo@sort\string" %
     \string"\@glo@prefix\@glossaryentryfield{#1}{\@glo@name
     }{\@glo@desc}{\@glo@symbol}\string") %
    }%
  \else
%    \end{macrocode}
% Entry has a parent
%    \begin{macrocode}
    \expandafter\protected@xdef\csname glo@#1@index\endcsname{%
      \csname glo@\@glo@parent @index\endcsname
      (\string"\@glo@sort\string" %
      \string"\@glo@prefix\@glossarysubentryfield%
         {\csname glo@#1@level\endcsname}{#1}{\@glo@name
      }{\@glo@desc}{\@glo@symbol}\string") %
   }%
  \fi
\else
%    \end{macrocode}
% Store using \app{makeindex} syntax.
%    \begin{macrocode}
  \ifx\@glo@parent\@empty
%    \end{macrocode}
% Sanitize \cs{@glo@prefix}
%    \begin{macrocode}
    \@onelevel@sanitize\@glo@prefix
%    \end{macrocode}
% Entry doesn't have a parent
%    \begin{macrocode}
    \expandafter\protected@xdef\csname glo@#1@index\endcsname{%
      \@glo@sort\@gls@actualchar\@glo@prefix
      \@glossaryentryfield{#1}{\@glo@name}{\@glo@desc
      }{\@glo@symbol}%
    }%
  \else
%    \end{macrocode}
% Entry has a parent
%    \begin{macrocode}
    \expandafter\protected@xdef\csname glo@#1@index\endcsname{%
      \csname glo@\@glo@parent @index\endcsname\@gls@levelchar
      \@glo@sort\@gls@actualchar\@glo@prefix
      \@glossarysubentryfield
        {\csname glo@#1@level\endcsname}{#1}{\@glo@name}{\@glo@desc
      }{\@glo@symbol}%
    }%
  \fi
\fi
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Resetting and unsetting entry flags}
% Each glossary entry is assigned a conditional of the form
%\cs{ifglo@}\meta{label}\texttt{@flag} which determines
% whether or not the entry has been used (see also 
% \ics{ifglsused} defined below). These flags can
% be set and unset using the following macros:
%
% The command \cs{glsreset}\marg{label} can be used
% to set the entry flag to indicate that it hasn't been used yet. The
% required argument is the entry label.
%\begin{macro}{\glsreset}
%    \begin{macrocode}
\newcommand*{\glsreset}[1]{%
\glsdoifexists{#1}{%
\expandafter\global\csname glo@#1@flagfalse\endcsname}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalreset}
%    \begin{macrocode}
\newcommand*{\glslocalreset}[1]{%
\glsdoifexists{#1}{%
\expandafter\let\csname ifglo@#1@flag\endcsname\iffalse}}
%    \end{macrocode}
%\end{macro}
% The command \cs{glsunset}\marg{label} can be used to
% set the entry flag to indicate that it has been used. The required
% argument is the entry label.
%\begin{macro}{\glsunset}
%    \begin{macrocode}
\newcommand*{\glsunset}[1]{%
\glsdoifexists{#1}{%
\expandafter\global\csname glo@#1@flagtrue\endcsname}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalunset}
%    \begin{macrocode}
\newcommand*{\glslocalunset}[1]{%
\glsdoifexists{#1}{%
\expandafter\let\csname ifglo@#1@flag\endcsname\iftrue}}
%    \end{macrocode}
%\end{macro}
% Reset all entries for the named glossaries (supplied in a 
% comma-separated list). 
% Syntax: \cs{glsresetall}\oarg{glossary-list}
%\begin{macro}{\glsresetall}
%    \begin{macrocode}
\newcommand*{\glsresetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glsreset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalresetall}
%    \begin{macrocode}
\newcommand*{\glslocalresetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glslocalreset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% Unset all entries for the named glossaries (supplied in a 
% comma-separated list). 
% Syntax: \cs{glsunsetall}\oarg{glossary-list}
%\begin{macro}{\glsunsetall}
%    \begin{macrocode}
\newcommand*{\glsunsetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glsunset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
% As above, but with only a local effect:
%\begin{macro}{\glslocalunsetall}
%    \begin{macrocode}
\newcommand*{\glslocalunsetall}[1][\@glo@types]{%
\forallglsentries[#1]{\@glsentry}{%
\glslocalunset{\@glsentry}}}
%    \end{macrocode}
%\end{macro}
%
% \subsection{Loading files containing glossary entries}
%\label{sec:load}
% Glossary entries can be defined in an external file.
% These external files can contain \ics{newglossaryentry}
% and \ics{newacronym} commands.\footnote{and any other valid 
%\LaTeX\ code that can be used in the preamble.}\\[10pt]
% \cs{loadglsentries}\oarg{type}\marg{filename}\\[10pt]
% This command will input the file using \cs{input}.
% The optional argument specifies to which glossary the
% entries should be assigned if they haven't used the \gloskey{type}
% key. If the optional argument is not specified, the default
% glossary is used. Only those entries used in the document (via
% \ics{glslink}, \ics{gls}, \ics{glspl} and uppercase
% variants or \ics{glsadd} and \ics{glsaddall} 
% will appear in the glossary). The mandatory argument is 
% the filename (with or without .tex extension).
%\begin{macro}{\loadglsentries}
%    \begin{macrocode}
\newcommand*{\loadglsentries}[2][\@gls@default]{%
\let\@gls@default\glsdefaulttype
\def\glsdefaulttype{#1}\input{#2}%
\let\glsdefaulttype\@gls@default}
%    \end{macrocode}
%\end{macro}
% \cs{loadglsentries} can only be used in the preamble:
%    \begin{macrocode}
\@onlypreamble{\loadglsentries}
%    \end{macrocode}
%
%\subsection{Using glossary entries in the text}
%\label{sec:code:glslink}
%
% Any term that has been defined using \ics{newglossaryentry}
% (or \ics{newacronym}) can be displayed in the text 
% (i.e.\ outside of the glossary) using
% one of the commands defined in this section. Unless you use
% \ics{glslink}, the way the term appears in the text is
% determined by \ics{glsdisplayfirst} (if it is the first
% time the term has been used) or \ics{glsdisplay} (for
% subsequent use). Any formatting commands (such as \cs{textbf}
% is governed by \ics{glstextformat}. By default this just 
% displays the \term{link text} ``as is''.
%\changes{1.04}{2007 Aug 3}{Added 'glstextformat}%
%\begin{macro}{\glstextformat}
%    \begin{macrocode}
\newcommand*{\glstextformat}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% The first time an entry is used, the way in which it is
% displayed is governed by \cs{glsdisplayfirst}. This
% takes four parameters: \verb|#1| will be the value
% of the entry's \gloskey{first} or \gloskey{firstplural} key, 
% \verb|#2| will be the value of the entry's \gloskey{description}
% key, \verb|#3| will be the value of the entry's \gloskey{symbol}
% key and \verb|#4| is additional text supplied by the final optional
% argument to commands like \ics{gls} and \ics{glspl}.
% The default is to display the first parameter followed by the
% additional text.
%\begin{macro}{\glsdisplayfirst}
%    \begin{macrocode}
\newcommand*{\glsdisplayfirst}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
% After the first use, the entry is displayed according to
% the format of \cs{glsdisplay}. Again, it takes four
% parameters: \verb|#1| will be the value of the
% entry's \gloskey{text} or \gloskey{plural} key, 
% \verb|#2| will be the value of the entry's \gloskey{description} 
% key, \verb|#3| will be the value of the entry's \gloskey{symbol}
% key and \verb|#4| is additional text supplied by the final optional
% argument to commands like \ics{gls} and \ics{glspl}.
%\begin{macro}{\glsdisplay}
%    \begin{macrocode}
\newcommand*{\glsdisplay}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
% When a new glossary is created it uses \cs{glsdisplayfirst}
% and \cs{glsdisplay} as the default way of displaying its
% entry in the text. This can be changed for the entries belonging 
% to an individual glossary using 
% \ics{defglsdisplay} and \ics{defglsdisplayfirst}.
%\\[10pt]
% \cs{defglsdisplay}\oarg{type}\marg{definition}\\[10pt]%
% The glossary type is given by \meta{type} (the default glossary
% if omitted) and
% \meta{definition} should have at most \verb|#1|, \verb|#2|,
% \verb|#3| and \verb|#4|. These represent the same arguments
% as those described for \ics{glsdisplay}.
%\begin{macro}{\defglsdisplay}
%    \begin{macrocode}
\newcommand*{\defglsdisplay}[2][\glsdefaulttype]{%
\expandafter\def\csname gls@#1@display\endcsname##1##2##3##4{#2}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{defglsdisplayfirst}\oarg{type}\marg{definition}\\[10pt]%
% The glossary type is given by \meta{type} (the default glossary
% if omitted) and
% \meta{definition} should have at most \verb|#1|, \verb|#2|,
% \verb|#3| and \verb|#4|. These represent the same arguments
% as those described for \ics{glsdisplayfirst}.
%\begin{macro}{\defglsdisplayfirst}
%    \begin{macrocode}
\newcommand*{\defglsdisplayfirst}[2][\glsdefaulttype]{%
\expandafter\def\csname gls@#1@displayfirst\endcsname##1##2##3##4{#2}}
%    \end{macrocode}
%\end{macro}
%
%\subsubsection{Links to glossary entries}
% The links to glossary entries all have a first optional 
% argument that can be used to change the format and counter
% of the associated entry number. Except for \cs{glslink},
% the commands like \cs{gls} have a final optional
% argument that can be used to insert additional text in the
% link (this will usually be appended, but can be redefined using
% \ics{defglsdisplay} and \ics{defglsdisplayfirst}). 
% It goes against the \LaTeX\ norm to have an optional
% argument after the mandatory arguments, but it makes more
% sense to write, say, \verb|\gls{label}['s]| rather than, say,
% \verb|\gls[append='s]{label}|. Since these control sequences
% are defined to include the final square bracket, spaces
% will be ignored after them. This is likely to lead to
% confusion as most users would not expect, say, "\gls{"\meta{label}"}"
% to ignore following spaces, so \cs{new@ifnextchar} from the 
% \isty{amsgen} package is required.
%
% The following keys can be used in the first optional 
% argument. The \gloskey[glslink]{counter} key checks that the 
% value is the name of a valid counter.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\define@key{glslink}{counter}{%
  \ifcsundef{c@#1}%
  {%
    \PackageError{glossaries}%
    {There is no counter called `#1'}%
    {%
       The counter key should have the name of a valid counter 
       as its value%
    }%
  }%
  {%
    \def\@gls@counter{#1}%
  }%
}
%    \end{macrocode}
% The value of the \gloskey[glslink]{format} key should be the name of a 
% command (without the initial backslash) that has a single mandatory 
% argument which can be used to format the associated entry
% number.
%    \begin{macrocode}
\define@key{glslink}{format}{%
\def\@glsnumberformat{#1}}
%    \end{macrocode}
% The \gloskey[glslink]{hyper} key is a boolean key, it can either have the 
% value true or false, and indicates whether or not to make a 
% hyperlink to the relevant glossary entry. If hyper is false, an 
% entry will still be made in the glossary, but the given text 
% won't be a hyperlink.
%    \begin{macrocode}
\define@boolkey{glslink}{hyper}[true]{}
%    \end{macrocode}
%\changes{3.04}{2012-11-18}{added local key}
% The \gloskey[glslink]{local} key is a boolean key. If true this
% indicates that commands such as \ics{gls} should only do a local
% reset rather than a global one.
%    \begin{macrocode}
\define@boolkey{glslink}{local}[true]{}
%    \end{macrocode}
%
%Syntax:\\[10pt]
% \cs{glslink}\oarg{options}\marg{label}\marg{text}
%\\[10pt]
% Display \meta{text} in the document, and add the entry information
% for \meta{label} into the relevant glossary. The optional
% argument should be a key value list using the \texttt{glslink}
% keys defined above.
%
% There is also a starred version:\\[10pt]
% \cs{glslink*}\oarg{options}\marg{label}\marg{text}\\[10pt]
% which is equivalent to 
% \cs{glslink}"[hyper=false,"\meta{options}"]"\marg{label}\marg{text}
%
% First determine whether or not we are using the starred version:
%\begin{macro}{\glslink}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glslink}{%
\@ifstar\@sgls@link\@gls@@link}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@sgls@link}
% The starred version of \cs{glslink} calls the unstarred version
% with hyperlinks disabled.
%    \begin{macrocode}
\newcommand*{\@sgls@link}[1][]{\@gls@@link[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@@link}
%\changes{2.03}{2009 Sep 23}{new}
% The unstarred version of \cs{glslink} checks for the existance
% of the term. The main part of the business is in \cs{@gls@link}
% which shouldn't check if the term is defined as it's called by
% \cs{gls} etc which also perform that check.
%    \begin{macrocode}
\newcommand*{\@gls@@link}[3][]{%
  \ifglsentryexists{#2}%
  {%
    \@gls@link[#1]{#2}{#3}%
  }{%
    \PackageError{glossaries}{Glossary entry `#2' has not been
    defined}{You need to define a glossary entry before you
    can use it.}%
%    \end{macrocode}
% Display the specified text. (The entry doesn't exist so
% there's nothing to link it to.)
%    \begin{macrocode}
    \glstextformat{#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@link}
%\changes{1.07}{2007 Sep 13}{fixed bug caused by \cs{theglsentrycounter} setting the page number too soon}
%\changes{1.15}{2008 August 15}{added 'glslabel}
%    \begin{macrocode}
\def\@gls@link[#1]#2#3{%
%    \end{macrocode}
%\changes{2.03}{2009 Sep 23}{Moved entry existence check to 
% avoid }
%\changes{2.03}{2009 Sep 23}{added \cs{leavevmode}}
% Inserting \cs{leavevmode} suggested by Donald~Arseneau (avoids
% problem with tabularx).
%    \begin{macrocode}
    \leavevmode
    \def\glslabel{#2}%
    \def\@glsnumberformat{glsnumberformat}%
    \edef\@gls@counter{\csname glo@#2@counter\endcsname}%
    \KV@glslink@hypertrue
    \setkeys{glslink}{#1}%
%    \end{macrocode}
% Store the entry's counter in \cs{theglsentrycounter}
%\changes{3.0}{2011/04/02}{added \cs{@gls@saveentrycounter}}
%    \begin{macrocode}
    \@gls@saveentrycounter
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added \cs{@gls@setsort}}
% Define sort key if necessary:
%    \begin{macrocode}
    \@gls@setsort{#2}%
%    \end{macrocode}
%\changes{2.01}{2009 May 30}{moved \cs{@do@wrglossary} before term is displayed
% to prevent unwanted whatsit}
%    \begin{macrocode}
    \@do@wrglossary{#2}%
    \ifKV@glslink@hyper
      \@glslink{\glolinkprefix#2}{\glstextformat{#3}}%
    \else
      \glstextformat{#3}\relax
    \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glolinkprefix}
%    \begin{macrocode}
\newcommand*{\glolinkprefix}{glo:}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentrycounter}
% Set default value of entry counter
%\changes{3.02}{2012/05/21}{set default value}
%    \begin{macrocode}
\def\glsentrycounter{\glscounter}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@saveentrycounter}
%\changes{3.0}{2011/04/02}{new}
% Need to check if using \ctr{equation} counter in \env{align}
% environment:
%    \begin{macrocode}
\newcommand*{\@gls@saveentrycounter}{%
  \def\@gls@Hcounter{}%
%    \end{macrocode}
% Are we using \ctr{equation} counter?
%    \begin{macrocode}
  \ifthenelse{\equal{\@gls@counter}{equation}}%
  {
%    \end{macrocode}
% If we in \env{align} environment, \cs{xatlevel@} will be defined.
% (Can't test for \cs{@currenvir} as may be inside an inner
% environment.)
%    \begin{macrocode}
    \ifcsundef{xatlevel@}%
    {%
      \edef\theglsentrycounter{\expandafter\noexpand
        \csname the\@gls@counter\endcsname}%
    }%
    {%
      \ifx\xatlevel@\@empty
        \edef\theglsentrycounter{\expandafter\noexpand
          \csname the\@gls@counter\endcsname}%
      \else
        \savecounters@
        \advance\c@equation by 1\relax
          \edef\theglsentrycounter{\csname the\@gls@counter\endcsname}%
%    \end{macrocode}
% Check if hyperref version of this counter
%    \begin{macrocode}
        \ifcsundef{theH\@gls@counter}%
        {%
           \def\@gls@Hcounter{\theglsentrycounter}%
        }%
        {%
          \def\@gls@Hcounter{\csname theH\@gls@counter\endcsname}%
        }%
        \protected@edef\theHglsentrycounter{\@gls@Hcounter}%
        \restorecounters@
      \fi
    }%
  }%
  {%
%    \end{macrocode}
% Not using \ctr{equation} counter so no special measures:
%    \begin{macrocode}
    \edef\theglsentrycounter{\expandafter\noexpand
      \csname the\@gls@counter\endcsname}%
  }%
%    \end{macrocode}
% Check if hyperref version of this counter
%    \begin{macrocode}
  \ifx\@gls@Hcounter\@empty
    \ifcsundef{theH\@gls@counter}%
    {%
       \def\theHglsentrycounter{\theglsentrycounter}%
    }%
    {%
      \protected@edef\theHglsentrycounter{\expandafter\noexpand
        \csname theH\@gls@counter\endcsname}%
    }%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\changes{1.01}{2007 May 17}{Added range facility in format key}%
%\begin{macro}{\@set@glo@numformat}
% Set the formatting information in the format required by 
% \app{makeindex}. The first argument is the format specified
% by the user (via the format key), the second argument is the
% name of the counter used to indicate the location, the third
% argument is a control sequence which stores the required format
% and the fourth argument (new to v3.0) is the hyper-prefix.
%\changes{3.0}{2010/03/31}{added 4th argument}
%    \begin{macrocode}
\def\@set@glo@numformat#1#2#3#4{%
  \expandafter\@glo@check@mkidxrangechar#3\@nil
  \protected@edef#1{%
    \@glo@prefix setentrycounter[#4]{#2}%
    \expandafter\string\csname\@glo@suffix\endcsname
  }%
  \@gls@checkmkidxchars#1%
}
%    \end{macrocode}
%\end{macro}
% Check to see if the given string starts with a ( or ). If it
% does set \cs{@glo@prefix} to the starting character,
% and \cs{@glo@suffix} to the rest (or "glsnumberformat"
% if there is nothing else),
% otherwise set \cs{@glo@prefix} to nothing and
% \cs{@glo@suffix} to all of it.
%    \begin{macrocode}
\def\@glo@check@mkidxrangechar#1#2\@nil{%
\if#1(\relax
  \def\@glo@prefix{(}%
  \if\relax#2\relax
    \def\@glo@suffix{glsnumberformat}%
  \else
    \def\@glo@suffix{#2}%
  \fi
\else
  \if#1)\relax
    \def\@glo@prefix{)}%
    \if\relax#2\relax
      \def\@glo@suffix{glsnumberformat}%
    \else
      \def\@glo@suffix{#2}%
  \fi
  \else
    \def\@glo@prefix{}\def\@glo@suffix{#1#2}%
  \fi
\fi}
%    \end{macrocode}
%
%\begin{macro}{\@gls@escbsdq}
% Escape backslashes and double quote marks. The argument must be
% a control sequence.
%    \begin{macrocode}
\newcommand*{\@gls@escbsdq}[1]{%
  \def\@gls@checkedmkidx{}%
  \let\gls@xdystring=#1\relax
  \@onelevel@sanitize\gls@xdystring
  \edef\do@gls@xdycheckbackslash{%
    \noexpand\@gls@xdycheckbackslash\gls@xdystring\noexpand\@nil
    \@backslashchar\@backslashchar\noexpand\null}%
  \do@gls@xdycheckbackslash
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{\gls@xdystring}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@xdycheckquote\gls@xdystring\@nil""\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{\gls@xdystring}%
%    \end{macrocode}
%\changes{3.04}{2012-11-18}{unsanitize \cs{gls@numberpage},
%\cs{gls@alphpage}, \cs{gls@Alphpage} and \cs{gls@romanpage}}
% Unsanitize \cs{gls@numberpage}, \cs{gls@alphpage},
% \cs{gls@Alphpage} and \cs{glsromanpage} (thanks to David~Carlise
% for the suggestion.)
%    \begin{macrocode}
  \@for\@gls@tmp:=\gls@protected@pagefmts\do
  {%
    \edef\@gls@sanitized@tmp{\expandafter\@gobble\string\\\expandonce\@gls@tmp}%
    \@onelevel@sanitize\@gls@sanitized@tmp
    \edef\gls@dosubst{%
      \noexpand\DTLsubstituteall\noexpand\gls@xdystring
      {\@gls@sanitized@tmp}{\expandonce\@gls@tmp}%
    }%
    \gls@dosubst
  }%
%    \end{macrocode}
% Assign to required control sequence
%    \begin{macrocode}
  \let#1=\gls@xdystring
}
%    \end{macrocode}
%\end{macro}
% Catch special characters\mkidxspch (argument must be a
% control sequence):
%\begin{macro}{\@gls@checkmkidxchars}
%    \begin{macrocode}
\newcommand{\@gls@checkmkidxchars}[1]{%
\ifglsxindy
  \@gls@escbsdq{#1}%
\else
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkquote#1\@nil""\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkescquote#1\@nil\"\"\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkescactual#1\@nil\?\?\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkactual#1\@nil??\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkbar#1\@nil||\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checkescbar#1\@nil\|\|\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
  \def\@gls@checkedmkidx{}%
  \expandafter\@gls@checklevel#1\@nil!!\null
  \expandafter\@gls@updatechecked\@gls@checkedmkidx{#1}%
\fi
}
%    \end{macrocode}
%\end{macro}
% Update the control sequence and strip trailing \cs{@nil}:
%\begin{macro}{\@gls@updatechecked}
%    \begin{macrocode}
\def\@gls@updatechecked#1\@nil#2{\def#2{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@tmpb}
%\changes{1.1}{2008 Feb 22}{changed \cs{toksdef} to \cs{newtoks}}
% Define temporary token
%    \begin{macrocode}
\newtoks\@gls@tmpb
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkquote}
% Replace \verb|"| with \verb|""| since \verb|"| is a makeindex
% special character\mkidxspch.
%    \begin{macrocode}
\def\@gls@checkquote#1"#2"#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkquote{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@quotechar\@gls@quotechar\@gls@quotechar}%
  \def\@@gls@checkquote{\@gls@checkquote#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@quotechar}%
 \ifx\null#3\null
   \def\@@gls@checkquote{\@gls@checkquote#2""\null}%
 \else
   \def\@@gls@checkquote{\@gls@checkquote#2"#3\null}%
 \fi
\fi
\@@gls@checkquote}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkescquote}
% Do the same for \verb|\"|:
%    \begin{macrocode}
\def\@gls@checkescquote#1\"#2\"#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescquote{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@quotechar
    \@gls@quotechar\string\"\@gls@quotechar}%
  \def\@@gls@checkescquote{\@gls@checkescquote#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@quotechar}%
 \ifx\null#3\null
   \def\@@gls@checkescquote{\@gls@checkescquote#2\"\"\null}%
 \else
   \def\@@gls@checkescquote{\@gls@checkescquote#2\"#3\null}%
 \fi
\fi
\@@gls@checkescquote}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkescactual}
% Similarly for \verb|\?| (which is replaces @ as 
% \app{makeindex}'s special character):
%    \begin{macrocode}
\def\@gls@checkescactual#1\?#2\?#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescactual{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@actualchar
    \@gls@quotechar\string\"\@gls@actualchar}%
  \def\@@gls@checkescactual{\@gls@checkescactual#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@actualchar}%
 \ifx\null#3\null
  \def\@@gls@checkescactual{\@gls@checkescactual#2\?\?\null}%
 \else
  \def\@@gls@checkescactual{\@gls@checkescactual#2\?#3\null}%
 \fi
\fi
\@@gls@checkescactual}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkescbar}
% Similarly for \verb"\|":
%    \begin{macrocode}
\def\@gls@checkescbar#1\|#2\|#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkescbar{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@encapchar
    \@gls@quotechar\string\"\@gls@encapchar}%
  \def\@@gls@checkescbar{\@gls@checkescbar#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@encapchar}%
 \ifx\null#3\null
  \def\@@gls@checkescbar{\@gls@checkescbar#2\|\|\null}%
 \else
  \def\@@gls@checkescbar{\@gls@checkescbar#2\|#3\null}%
 \fi
\fi
\@@gls@checkescbar}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkesclevel}
% Similarly for \verb"\!":
%    \begin{macrocode}
\def\@gls@checkesclevel#1\!#2\!#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkesclevel{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\string\"\@gls@levelchar
    \@gls@quotechar\string\"\@gls@levelchar}%
  \def\@@gls@checkesclevel{\@gls@checkesclevel#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\string\"\@gls@levelchar}%
 \ifx\null#3\null
  \def\@@gls@checkesclevel{\@gls@checkesclevel#2\!\!\null}%
 \else
  \def\@@gls@checkesclevel{\@gls@checkesclevel#2\!#3\null}%
 \fi
\fi
\@@gls@checkesclevel}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkbar}
% and for \verb"|":
%    \begin{macrocode}
\def\@gls@checkbar#1|#2|#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkbar{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@encapchar\@gls@quotechar\@gls@encapchar}%
  \def\@@gls@checkbar{\@gls@checkbar#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@encapchar}%
 \ifx\null#3\null
   \def\@@gls@checkbar{\@gls@checkbar#2||\null}%
 \else
   \def\@@gls@checkbar{\@gls@checkbar#2|#3\null}%
 \fi
\fi
\@@gls@checkbar}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checklevel}
% and for \verb"!":
%    \begin{macrocode}
\def\@gls@checklevel#1!#2!#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checklevel{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@levelchar\@gls@quotechar\@gls@levelchar}%
  \def\@@gls@checklevel{\@gls@checklevel#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@levelchar}%
 \ifx\null#3\null
   \def\@@gls@checklevel{\@gls@checklevel#2!!\null}%
 \else
   \def\@@gls@checklevel{\@gls@checklevel#2!#3\null}%
 \fi
\fi
\@@gls@checklevel}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@checkactual}
% and for \verb"?":
%    \begin{macrocode}
\def\@gls@checkactual#1?#2?#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@checkactual{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \@gls@quotechar\@gls@actualchar\@gls@quotechar\@gls@actualchar}%
  \def\@@gls@checkactual{\@gls@checkactual#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \@gls@quotechar\@gls@actualchar}%
 \ifx\null#3\null
   \def\@@gls@checkactual{\@gls@checkactual#2??\null}%
 \else
   \def\@@gls@checkactual{\@gls@checkactual#2?#3\null}%
 \fi
\fi
\@@gls@checkactual}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdycheckquote}
% As before but for use with \app{xindy}
%    \begin{macrocode}
\def\@gls@xdycheckquote#1"#2"#3\null{%
\@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
\toks@={#1}%
\ifx\null#2\null
 \ifx\null#3\null
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
  \def\@@gls@xdycheckquote{\relax}%
 \else
  \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
    \string\"\string\"}%
  \def\@@gls@xdycheckquote{\@gls@xdycheckquote#3\null}%
 \fi
\else
 \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
   \string\"}%
 \ifx\null#3\null
   \def\@@gls@xdycheckquote{\@gls@xdycheckquote#2""\null}%
 \else
   \def\@@gls@xdycheckquote{\@gls@xdycheckquote#2"#3\null}%
 \fi
\fi
\@@gls@xdycheckquote
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@xdycheckbackslash}
% Need to escape all backslashes for \app{xindy}.
% Define command that will define \cs{@gls@xdycheckbackslash}
%    \begin{macrocode}
\edef\def@gls@xdycheckbackslash{%
 \noexpand\def\noexpand\@gls@xdycheckbackslash##1\@backslashchar
   ##2\@backslashchar##3\noexpand\null{%
  \noexpand\@gls@tmpb=\noexpand\expandafter
    {\noexpand\@gls@checkedmkidx}%
  \noexpand\toks@={##1}%
  \noexpand\ifx\noexpand\null##2\noexpand\null
   \noexpand\ifx\noexpand\null##3\noexpand\null
    \noexpand\edef\noexpand\@gls@checkedmkidx{%
       \noexpand\the\noexpand\@gls@tmpb\noexpand\the\noexpand\toks@}%
    \noexpand\def\noexpand\@@gls@xdycheckbackslash{\relax}%
   \noexpand\else
    \noexpand\edef\noexpand\@gls@checkedmkidx{%
      \noexpand\the\noexpand\@gls@tmpb\noexpand\the\noexpand\toks@
    \@backslashchar\@backslashchar\@backslashchar\@backslashchar}%
  \noexpand\def\noexpand\@@gls@xdycheckbackslash{%
     \noexpand\@gls@xdycheckbackslash##3\noexpand\null}%
   \noexpand\fi
  \noexpand\else
   \noexpand\edef\noexpand\@gls@checkedmkidx{%
     \noexpand\the\noexpand\@gls@tmpb\noexpand\the\noexpand\toks@
   \@backslashchar\@backslashchar}%
 \noexpand\ifx\noexpand\null##3\noexpand\null
   \noexpand\def\noexpand\@@gls@xdycheckbackslash{%
      \noexpand\@gls@xdycheckbackslash##2\@backslashchar
      \@backslashchar\noexpand\null}%
   \noexpand\else
     \noexpand\def\noexpand\@@gls@xdycheckbackslash{%
        \noexpand\@gls@xdycheckbackslash##2\@backslashchar
           ##3\noexpand\null}%
   \noexpand\fi
  \noexpand\fi
  \noexpand\@@gls@xdycheckbackslash
 }%
}
%    \end{macrocode}
% Now go ahead and define \cs{@gls@xdycheckbackslash}
%    \begin{macrocode}
\def@gls@xdycheckbackslash
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glslink}
% If \ics{hyperlink} is not defined \cs{@glslink} 
% ignores its first argument and just does the second argument,
% otherwise it is equivalent to \ics{hyperlink}.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{hyperlink}%
{%
  \gdef\@glslink#1#2{#2}%
}%
{%
  \gdef\@glslink#1#2{\hyperlink{#1}{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\changes{1.12}{2008 Mar 8}{added check for 'hypertarget separate
% to 'hyperlink (memoir defines 'hyperlink but not 'hypertarget)}
%\begin{macro}{\@glstarget}
% If \ics{hypertarget} is not defined, \cs{@glstarget}
% ignores its first argument and just does the second argument,
% otherwise it is equivalent to \ics{hypertarget}.
%\changes{1.16}{2008 August 27}{raised the hypertarget so the target text doesn't
% scroll off the top of the page}
%    \begin{macrocode}
\newlength\gls@tmplen
\ifcsundef{hypertarget}%
{%
  \gdef\@glstarget#1#2{#2}%
}%
{%
  \gdef\@glstarget#1#2{%
    \settoheight{\gls@tmplen}{#2}%
    \raisebox{\gls@tmplen}{\hypertarget{#1}{}}#2%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Glossary hyperlinks can be disabled using \cs{glsdisablehyper}
% (effect can be localised):
%\begin{macro}{\glsdisablehyper}
%    \begin{macrocode}
\newcommand{\glsdisablehyper}{%
\renewcommand*\@glslink[2]{##2}%
\renewcommand*\@glstarget[2]{##2}}
%    \end{macrocode}
%\end{macro}
% Glossary hyperlinks can be enabled using \cs{glsenablehyper}
% (effect can be localised):
%\begin{macro}{\glsenablehyper}
%    \begin{macrocode}
\newcommand{\glsenablehyper}{%
\renewcommand*\@glslink[2]{\hyperlink{##1}{##2}}%
\renewcommand*\@glstarget[2]{%
  \settoheight{\gls@tmplen}{##2}%
  \raisebox{\gls@tmplen}{\hypertarget{##1}{}}##2}}
%    \end{macrocode}
%\end{macro}
%
%Syntax:\\[10pt]
% \cs{gls}\oarg{options}\marg{label}\oarg{insert text}\\[10pt]
% Link to glossary entry using singular form. The link text
% is taken from the value of the \gloskey{text} or \gloskey{first}
% keys used when the entry was defined.
%
%  The first optional argument is a key-value list, the same as
% \ics{glslink}\igloskey[glslink]{hyper}\igloskey[glslink]{format}\igloskey[glslink]{counter}, 
% the mandatory argument is the entry label. 
% After the mandatory argument, there is another optional argument 
% to insert extra text in the link text (the location of the inserted
% text is governed by \ics{glsdisplay} and 
% \ics{glsdisplayfirst}). As with \cs{glslink}
% there is a starred version which is the same as the unstarred 
% version but with the \gloskey[glslink]{hyper} key set to \texttt{false}.
% (Additional options can also be specified 
% in the first optional argument.)
%
% First determine if we are using the starred form:
%\begin{macro}{\gls}
%    \begin{macrocode}
\newrobustcmd*{\gls}{\@ifstar\@sgls\@gls}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%\begin{macro}{\@sgls}
%    \begin{macrocode}
\newcommand*{\@sgls}[1][]{\@gls[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%\begin{macro}{\@gls}
%    \begin{macrocode}
\newcommand*{\@gls}[2][]{%
  \new@ifnextchar[{\@gls@{#1}{#2}}{\@gls@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@gls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
          {\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
    }%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
          {\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {\(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
       \OR \NOT\boolean{glshyperfirst}
      }%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{Gls} behaves like \cs{gls}, but the first letter
% of the link text is converted to uppercase (note that if the
% first letter has an accent, the accented letter will need to
% be grouped when you define the entry). It is mainly intended
% for terms that start a sentence:
%\begin{macro}{\Gls}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Gls}{\@ifstar\@sGls\@Gls}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGls}[1][]{\@Gls[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Gls}[2][]{%
  \new@ifnextchar[{\@Gls@{#1}{#2}}{\@Gls@{#1}{#2}[]}%
}
%    \end{macrocode}
%\begin{macro}{\@Gls@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Gls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
    \def\glslabel{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \protected@edef\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
          {\glsentrytext{#2}}{\glsentrydesc{#2}}%
          {\glsentrysymbol{#2}}{#3}}%
    }%
    {%
      \protected@edef\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
          {\glsentryfirst{#2}}{\glsentrydesc{#2}}%
          {\glsentrysymbol{#2}}{#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{%
      \expandafter\makefirstuc\expandafter{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {%
        \(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
        \OR \NOT\boolean{glshyperfirst}%
      }%
      {%
        \@gls@link[#1,hyper=false]{#2}{%
          \expandafter\makefirstuc\expandafter{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{%
          \expandafter\makefirstuc\expandafter{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{GLS} behaves like \ics{gls}, but the link
% text is converted to uppercase:
%\changes{3.01}{2011/04/12}{made robust}
%\begin{macro}{\GLS}
%    \begin{macrocode}
\newrobustcmd*{\GLS}{\@ifstar\@sGLS\@GLS}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLS}[1][]{\@GLS[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLS}[2][]{%
  \new@ifnextchar[{\@GLS@{#1}{#2}}{\@GLS@{#1}{#2}[]}%
}
%    \end{macrocode}
%\begin{macro}{\@GLS@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLS@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}).
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
        {\glsentrytext{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
      }%
    }%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
        {\glsentryfirst{#2}}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{#3}%
      }%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {%
        \(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
        \OR \NOT\boolean{glshyperfirst}}{%
        \@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{glspl} behaves in the same way as \ics{gls} except
% it uses the plural form.
%\begin{macro}{\glspl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glspl}{\@ifstar\@sglspl\@glspl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglspl}[1][]{\@glspl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glspl}[2][]{%
  \new@ifnextchar[{\@glspl@{#1}{#2}}{\@glspl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\begin{macro}{\@glspl@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{1.12}{2008 Mar 8}{now uses 'glsentrydescplural and
% 'glsentrysymbolplural instead of 'glsentrydesc and 'glsentrysymbol}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
          {\glsentryplural{#2}}{\glsentrydescplural{#2}}%
          {\glsentrysymbolplural{#2}}{#3}}%
    }%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
          {\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
          {\glsentrysymbolplural{#2}}{#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {%
        \(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
         \OR \NOT\boolean{glshyperfirst}%
      }%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{Glspl} behaves in the same way as \ics{glspl}, except
% that the first letter of the link text is converted to uppercase
% (as with \ics{Gls}, if the first letter has an accent, it
% will need to be grouped).
%\begin{macro}{\Glspl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glspl}{\@ifstar\@sGlspl\@Glspl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlspl}[1][]{\@Glspl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glspl}[2][]{%
  \new@ifnextchar[{\@Glspl@{#1}{#2}}{\@Glspl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\begin{macro}{\@Glspl@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
    \def\glslabel{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}). This needs to be expanded so that the
% \cs{@glo@text} can be passed to \cs{xmakefirstuc}.
%\changes{1.12}{2008 Mar 8}{now uses 'glsentrydescplural and
% 'glsentrysymbolplural instead of 'glsentrydesc and 'glsentrysymbol}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \protected@edef\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
          {\glsentryplural{#2}}{\glsentrydescplural{#2}}%
          {\glsentrysymbolplural{#2}}{#3}}%
    }%
    {%
      \protected@edef\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
          {\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
          {\glsentrysymbolplural{#2}}{#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{%
        \expandafter\makefirstuc\expandafter{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {%
        \(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
        \OR \NOT\boolean{glshyperfirst}%
      }%
      {%
        \@gls@link[#1,hyper=false]{#2}{%
          \expandafter\makefirstuc\expandafter{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{%
          \expandafter\makefirstuc\expandafter{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{GLSpl} behaves like \ics{glspl} except that all the
% link text is converted to uppercase.
%\begin{macro}{\GLSpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSpl}{\@ifstar\@sGLSpl\@GLSpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSpl}[1][]{\@GLSpl[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSpl}[2][]{%
  \new@ifnextchar[{\@GLSpl@{#1}{#2}}{\@GLSpl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\begin{macro}{\@GLSpl}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSpl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{1.12}{2008 Mar 8}{now uses 'glsentrydescplural and
% 'glsentrysymbolplural instead of 'glsentrydesc and 'glsentrysymbol}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
        {\glsentryplural{#2}}{\glsentrydescplural{#2}}%
        {\glsentrysymbolplural{#2}}{#3}%
      }%
    }%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
        {\glsentryfirstplural{#2}}{\glsentrydescplural{#2}}%
        {\glsentrysymbolplural{#2}}{#3}%
      }%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse
      {%
        \(\boolean{@glsisacronymlist}\AND \boolean{glsacrfootnote}\)
        \OR \NOT\boolean{glshyperfirst}%
      }%
      {%
        \@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdisp}
%\changes{1.19}{2009 Mar 2}{new}
%\cs{glsdisp}\oarg{options}\marg{label}\marg{text}
% This is like \cs{gls} except that the link text is provided.
% This differs from \cs{glslink} in that it uses 
% \cs{glsdisplay} or \cs{glsdisplayfirst} and unsets the first use
% flag.
%
% First determine if we are using the starred form:
%    \begin{macrocode}
\newrobustcmd*{\glsdisp}{\@ifstar\@sglsdisp\@glsdisp}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%\begin{macro}{\@sgls}
%    \begin{macrocode}
\newcommand*{\@sglsdisp}[1][]{\@glsdisp[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
% Defined the un-starred form.
%\begin{macro}{\@glsdisp}
%    \begin{macrocode}
\newcommand*{\@glsdisp}[3][]{%
  \glsdoifexists{#2}{%
%    \end{macrocode}
%\changes{2.05}{2010 Feb 6}{Added closing brace. Patch provided by Sergiu Dotenco}
%    \begin{macrocode}
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @display\endcsname
        {#3}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{}}%
    }%
    {%
      \def\@glo@text{%
        \csname gls@\@glo@type @displayfirst\endcsname
        {#3}{\glsentrydesc{#2}}{\glsentrysymbol{#2}}{}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used and the glossary
% type is \cs{acronymtype}, suppress 
% hyperlink for first use. Likewise if the \pkgopt[false]{hyperfirst}
% package option is used.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%\changes{2.03}{2009 Sep 23}{Added check for hyperfirst}
%\changes{2.04}{2009 November 10}{Changed test to check if glossary type
%has been identified as a list of acronyms}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse{\(\boolean{@glsisacronymlist}\AND
        \boolean{glsacrfootnote}\) \OR \NOT\boolean{glshyperfirst}}%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%\changes{2.05}{2010 Feb 6}{Removed spurious brace. Patch provided by Sergiu Dotenco}
%    \begin{macrocode}
    \ifKV@glslink@local
      \glslocalunset{#2}%
    \else
      \glsunset{#2}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{glstext} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{text} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glstext}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glstext}{\@ifstar\@sglstext\@glstext}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglstext}[1][]{\@glstext[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glstext}[2][]{%
\new@ifnextchar[{\@glstext@{#1}{#2}}{\@glstext@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glstext@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glstext shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrytext{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLStext} behaves like \cs{glstext} except the text is converted
% to uppercase.
%\begin{macro}{\GLStext}
%    \begin{macrocode}
\newrobustcmd*{\GLStext}{\@ifstar\@sGLStext\@GLStext}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLStext}[1][]{\@GLStext[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLStext}[2][]{%
\new@ifnextchar[{\@GLStext@{#1}{#2}}{\@GLStext@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLStext@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLStext shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrytext{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{Glstext} behaves like \cs{glstext} except that the first letter
% of the text is converted to uppercase.
%\begin{macro}{\Glstext}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glstext}{\@ifstar\@sGlstext\@Glstext}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlstext}[1][]{\@Glstext[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glstext}[2][]{%
\new@ifnextchar[{\@Glstext@{#1}{#2}}{\@Glstext@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glstext@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glstext shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrytext{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
   \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{glsfirst} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{first} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glsfirst}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsfirst}{\@ifstar\@sglsfirst\@glsfirst}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsfirst}[1][]{\@glsfirst[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsfirst}[2][]{%
\new@ifnextchar[{\@glsfirst@{#1}{#2}}{\@glsfirst@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsfirst@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsfirst shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirst{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsfirst} behaves like \ics{glsfirst} except it displays the 
% first letter in uppercase.
%\begin{macro}{\Glsfirst}
%    \begin{macrocode}
\newrobustcmd*{\Glsfirst}{\@ifstar\@sGlsfirst\@Glsfirst}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsfirst}[1][]{\@Glsfirst[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsfirst}[2][]{%
\new@ifnextchar[{\@Glsfirst@{#1}{#2}}{\@Glsfirst@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsfirst@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glsfirst shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirst{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
   \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSfirst} behaves like \ics{Glsfirst} except it displays the 
% text in uppercase.
%\begin{macro}{\GLSfirst}
%    \begin{macrocode}
\newrobustcmd*{\GLSfirst}{\@ifstar\@sGLSfirst\@GLSfirst}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSfirst}[1][]{\@GLSfirst[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSfirst}[2][]{%
\new@ifnextchar[{\@GLSfirst@{#1}{#2}}{\@GLSfirst@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSfirst@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSfirst shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirst{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsplural} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{plural} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glsplural}
%    \begin{macrocode}
\newrobustcmd*{\glsplural}{\@ifstar\@sglsplural\@glsplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsplural}[1][]{\@glsplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsplural}[2][]{%
\new@ifnextchar[{\@glsplural@{#1}{#2}}{\@glsplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsplural} behaves like \ics{glsplural} except that the first
% letter is converted to uppercase.
%\begin{macro}{\Glsplural}
%    \begin{macrocode}
\newrobustcmd*{\Glsplural}{\@ifstar\@sGlsplural\@Glsplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsplural}[1][]{\@Glsplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsplural}[2][]{%
\new@ifnextchar[{\@Glsplural@{#1}{#2}}{\@Glsplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glsplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
   \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSplural} behaves like \ics{glsplural} except that the 
% text is converted to uppercase.
%\begin{macro}{\GLSplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSplural}{\@ifstar\@sGLSplural\@GLSplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSplural}[1][]{\@GLSplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSplural}[2][]{%
\new@ifnextchar[{\@GLSplural@{#1}{#2}}{\@GLSplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsfirstplural} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{firstplural} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glsfirstplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsfirstplural}{\@ifstar\@sglsfirstplural\@glsfirstplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsfirstplural}[1][]{\@glsfirstplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsfirstplural}[2][]{%
\new@ifnextchar[{\@glsfirstplural@{#1}{#2}}{\@glsfirstplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsfirstplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsfirstplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirstplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsfirstplural} behaves like \ics{glsfirstplural} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsfirstplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsfirstplural}{\@ifstar\@sGlsfirstplural\@Glsfirstplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsfirstplural}[1][]{\@Glsfirstplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsfirstplural}[2][]{%
\new@ifnextchar[{\@Glsfirstplural@{#1}{#2}}{\@Glsfirstplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsfirstplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glsfirstplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirstplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSfirstplural} behaves like \ics{glsfirstplural} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSfirstplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSfirstplural}{\@ifstar\@sGLSfirstplural\@GLSfirstplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSfirstplural}[1][]{\@GLSfirstplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSfirstplural}[2][]{%
\new@ifnextchar[{\@GLSfirstplural@{#1}{#2}}{\@GLSfirstplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSfirstplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSfirstplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryfirstplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsname} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{name} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glsname}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsname}{\@ifstar\@sglsname\@glsname}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsname}[1][]{\@glsname[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsname}[2][]{%
\new@ifnextchar[{\@glsname@{#1}{#2}}{\@glsname@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsname@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsname shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryname{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsname} behaves like \ics{glsname} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsname}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsname}{\@ifstar\@sGlsname\@Glsname}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsname}[1][]{\@Glsname[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsname}[2][]{%
\new@ifnextchar[{\@Glsname@{#1}{#2}}{\@Glsname@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsname@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsname shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryname{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSname} behaves like \ics{glsname} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSname}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSname}{\@ifstar\@sGLSname\@GLSname}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSname}[1][]{\@GLSname[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSname}[2][]{%
\new@ifnextchar[{\@GLSname@{#1}{#2}}{\@GLSname@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSname@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSname shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryname{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsdesc} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{description} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsdesc}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsdesc}{\@ifstar\@sglsdesc\@glsdesc}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsdesc}[1][]{\@glsdesc[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsdesc}[2][]{%
\new@ifnextchar[{\@glsdesc@{#1}{#2}}{\@glsdesc@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsdesc@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glsdesc shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydesc{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsdesc} behaves like \ics{glsdesc} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsdesc}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsdesc}{\@ifstar\@sGlsdesc\@Glsdesc}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsdesc}[1][]{\@Glsdesc[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsdesc}[2][]{%
\new@ifnextchar[{\@Glsdesc@{#1}{#2}}{\@Glsdesc@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsdesc@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glsdesc shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydesc{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSdesc} behaves like \ics{glsdesc} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSdesc}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSdesc}{\@ifstar\@sGLSdesc\@GLSdesc}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSdesc}[1][]{\@GLSdesc[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSdesc}[2][]{%
\new@ifnextchar[{\@GLSdesc@{#1}{#2}}{\@GLSdesc@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSdesc@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSdesc shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydesc{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsdescplural} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{descriptionplural} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsdescplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsdescplural}{\@ifstar\@sglsdescplural\@glsdescplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsdescplural}[1][]{\@glsdescplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsdescplural}[2][]{%
\new@ifnextchar[{\@glsdescplural@{#1}{#2}}{\@glsdescplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsdescplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydescplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsdescplural} behaves like \ics{glsdescplural} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsdescplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsdescplural}{\@ifstar\@sGlsdescplural\@Glsdescplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsdescplural}[1][]{\@Glsdescplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsdescplural}[2][]{%
\new@ifnextchar[{\@Glsdescplural@{#1}{#2}}{\@Glsdescplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsdescplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydescplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSdescplural} behaves like \ics{glsdescplural} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSdescplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSdescplural}{\@ifstar\@sGLSdescplural\@GLSdescplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSdescplural}[1][]{\@GLSdescplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSdescplural}[2][]{%
\new@ifnextchar[{\@GLSdescplural@{#1}{#2}}{\@GLSdescplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSdescplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrydescplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glssymbol} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{symbol} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glssymbol}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glssymbol}{\@ifstar\@sglssymbol\@glssymbol}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglssymbol}[1][]{\@glssymbol[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glssymbol}[2][]{%
\new@ifnextchar[{\@glssymbol@{#1}{#2}}{\@glssymbol@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glssymbol@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glssymbol shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbol{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glssymbol} behaves like \ics{glssymbol} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glssymbol}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glssymbol}{\@ifstar\@sGlssymbol\@Glssymbol}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlssymbol}[1][]{\@Glssymbol[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glssymbol}[2][]{%
\new@ifnextchar[{\@Glssymbol@{#1}{#2}}{\@Glssymbol@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glssymbol@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('Glssymbol shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbol{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
   \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSsymbol} behaves like \ics{glssymbol} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSsymbol}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSsymbol}{\@ifstar\@sGLSsymbol\@GLSsymbol}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSsymbol}[1][]{\@GLSsymbol[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSsymbol}[2][]{%
\new@ifnextchar[{\@GLSsymbol@{#1}{#2}}{\@GLSsymbol@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSsymbol@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('GLSsymbol shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbol{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glssymbolplural} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{symbolplural} key and it doesn't mark the entry as
% used.
%\begin{macro}{\glssymbolplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glssymbolplural}{\@ifstar\@sglssymbolplural\@glssymbolplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglssymbolplural}[1][]{\@glssymbolplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glssymbolplural}[2][]{%
\new@ifnextchar[{\@glssymbolplural@{#1}{#2}}{\@glssymbolplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glssymbolplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
% \changes{1.12}{2008 Mar 8}{fixed bug ('glssymbolplural shouldn't use
% 'gls@\meta{type}@display)}
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbolplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glssymbolplural} behaves like \ics{glssymbolplural} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glssymbolplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glssymbolplural}{\@ifstar\@sGlssymbolplural\@Glssymbolplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlssymbolplural}[1][]{\@Glssymbolplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glssymbolplural}[2][]{%
\new@ifnextchar[{\@Glssymbolplural@{#1}{#2}}{\@Glssymbolplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glssymbolplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbolplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
   \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSsymbolplural} behaves like \ics{glssymbolplural} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSsymbolplural}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSsymbolplural}{\@ifstar\@sGLSsymbolplural\@GLSsymbolplural}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSsymbolplural}[1][]{\@GLSsymbolplural[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSsymbolplural}[2][]{%
\new@ifnextchar[{\@GLSsymbolplural@{#1}{#2}}{\@GLSsymbolplural@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSsymbolplural@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentrysymbolplural{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
% \changes{1.13}{2008 May 10}{fixed bug that ignores 3rd parameter}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuseri} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user1} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuseri}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuseri}{\@ifstar\@sglsuseri\@glsuseri}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuseri}[1][]{\@glsuseri[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuseri}[2][]{%
\new@ifnextchar[{\@glsuseri@{#1}{#2}}{\@glsuseri@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuseri@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseri{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuseri} behaves like \ics{glsuseri} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuseri}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseri}{\@ifstar\@sGlsuseri\@Glsuseri}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuseri}[1][]{\@Glsuseri[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuseri}[2][]{%
\new@ifnextchar[{\@Glsuseri@{#1}{#2}}{\@Glsuseri@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuseri@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseri{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuseri} behaves like \ics{glsuseri} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuseri}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseri}{\@ifstar\@sGLSuseri\@GLSuseri}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuseri}[1][]{\@GLSuseri[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuseri}[2][]{%
\new@ifnextchar[{\@GLSuseri@{#1}{#2}}{\@GLSuseri@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuseri@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseri{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuserii} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user2} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuserii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuserii}{\@ifstar\@sglsuserii\@glsuserii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuserii}[1][]{\@glsuserii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuserii}[2][]{%
\new@ifnextchar[{\@glsuserii@{#1}{#2}}{\@glsuserii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuserii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuserii} behaves like \ics{glsuserii} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuserii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuserii}{\@ifstar\@sGlsuserii\@Glsuserii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuserii}[1][]{\@Glsuserii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuserii}[2][]{%
\new@ifnextchar[{\@Glsuserii@{#1}{#2}}{\@Glsuserii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuserii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuserii} behaves like \ics{glsuserii} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuserii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuserii}{\@ifstar\@sGLSuserii\@GLSuserii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuserii}[1][]{\@GLSuserii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuserii}[2][]{%
\new@ifnextchar[{\@GLSuserii@{#1}{#2}}{\@GLSuserii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuserii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuseriii} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user3} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuseriii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuseriii}{\@ifstar\@sglsuseriii\@glsuseriii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuseriii}[1][]{\@glsuseriii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuseriii}[2][]{%
\new@ifnextchar[{\@glsuseriii@{#1}{#2}}{\@glsuseriii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuseriii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuseriii} behaves like \ics{glsuseriii} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuseriii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseriii}{\@ifstar\@sGlsuseriii\@Glsuseriii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuseriii}[1][]{\@Glsuseriii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuseriii}[2][]{%
\new@ifnextchar[{\@Glsuseriii@{#1}{#2}}{\@Glsuseriii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuseriii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuseriii} behaves like \ics{glsuseriii} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuseriii}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseriii}{\@ifstar\@sGLSuseriii\@GLSuseriii}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuseriii}[1][]{\@GLSuseriii[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuseriii}[2][]{%
\new@ifnextchar[{\@GLSuseriii@{#1}{#2}}{\@GLSuseriii@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuseriii@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriii{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuseriv} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user4} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuseriv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuseriv}{\@ifstar\@sglsuseriv\@glsuseriv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuseriv}[1][]{\@glsuseriv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuseriv}[2][]{%
\new@ifnextchar[{\@glsuseriv@{#1}{#2}}{\@glsuseriv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuseriv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuseriv} behaves like \ics{glsuseriv} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuseriv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseriv}{\@ifstar\@sGlsuseriv\@Glsuseriv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuseriv}[1][]{\@Glsuseriv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuseriv}[2][]{%
\new@ifnextchar[{\@Glsuseriv@{#1}{#2}}{\@Glsuseriv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuseriv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuseriv} behaves like \ics{glsuseriv} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuseriv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseriv}{\@ifstar\@sGLSuseriv\@GLSuseriv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuseriv}[1][]{\@GLSuseriv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuseriv}[2][]{%
\new@ifnextchar[{\@GLSuseriv@{#1}{#2}}{\@GLSuseriv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuseriv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuseriv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuserv} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user5} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuserv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuserv}{\@ifstar\@sglsuserv\@glsuserv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuserv}[1][]{\@glsuserv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuserv}[2][]{%
\new@ifnextchar[{\@glsuserv@{#1}{#2}}{\@glsuserv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuserv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuserv} behaves like \ics{glsuserv} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuserv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuserv}{\@ifstar\@sGlsuserv\@Glsuserv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuserv}[1][]{\@Glsuserv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuserv}[2][]{%
\new@ifnextchar[{\@Glsuserv@{#1}{#2}}{\@Glsuserv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuserv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuserv} behaves like \ics{glsuserv} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuserv}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuserv}{\@ifstar\@sGLSuserv\@GLSuserv}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuserv}[1][]{\@GLSuserv[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuserv}[2][]{%
\new@ifnextchar[{\@GLSuserv@{#1}{#2}}{\@GLSuserv@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuserv@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuserv{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% \cs{glsuservi} behaves like \ics{gls} except it always uses the value 
% given by the \gloskey{user6} key and it doesn't mark the entry
% as used.
%\begin{macro}{\glsuservi}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsuservi}{\@ifstar\@sglsuservi\@glsuservi}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sglsuservi}[1][]{\@glsuservi[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@glsuservi}[2][]{%
\new@ifnextchar[{\@glsuservi@{#1}{#2}}{\@glsuservi@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsuservi@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuservi{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\@glo@text#3}%
}%
}
%    \end{macrocode}
%
% \cs{Glsuservi} behaves like \ics{glsuservi} except that the
% first letter is converted to uppercase.
%\begin{macro}{\Glsuservi}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsuservi}{\@ifstar\@sGlsuservi\@Glsuservi}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGlsuservi}[1][]{\@Glsuservi[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@Glsuservi}[2][]{%
\new@ifnextchar[{\@Glsuservi@{#1}{#2}}{\@Glsuservi@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsuservi@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuservi{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{%
  \expandafter\makefirstuc\expandafter{\@glo@text}#3}%
}%
}
%    \end{macrocode}
%
% \cs{GLSuservi} behaves like \ics{glsuservi} except that the
% link text is converted to uppercase.
%\begin{macro}{\GLSuservi}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\GLSuservi}{\@ifstar\@sGLSuservi\@GLSuservi}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\@sGLSuservi}[1][]{\@GLSuservi[hyper=false,#1]}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@GLSuservi}[2][]{%
\new@ifnextchar[{\@GLSuservi@{#1}{#2}}{\@GLSuservi@{#1}{#2}[]}}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSuservi@#1#2[#3]{%
\glsdoifexists{#2}{\edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
\protected@edef\@glo@text{\glsentryuservi{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
\@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
}%
}
%    \end{macrocode}
%
% Now deal with acronym related keys. First the short form:
%\begin{macro}{\acrshort}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrshort}{\@ifstar\s@acrshort\ns@acrshort}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@acrshort}[2][]{%
  \new@ifnextchar[{\@acrshort{hyper=false,#1}{#2}}%
                  {\@acrshort{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@acrshort}[2][]{%
  \new@ifnextchar[{\@acrshort{#1}{#2}}{\@acrshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshort{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\@glo@text}#3}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrshort}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrshort}{\@ifstar\s@Acrshort\ns@Acrshort}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@Acrshort}[2][]{%
  \new@ifnextchar[{\@Acrshort{hyper=false,#1}{#2}}%
                  {\@Acrshort{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Acrshort}[2][]{%
  \new@ifnextchar[{\@Acrshort{#1}{#2}}{\@Acrshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshort{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}%
    {%
      \acronymfont{\expandafter\makefirstuc\expandafter{\@glo@text}}#3%
    }%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRshort}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRshort}{\@ifstar\s@ACRshort\ns@ACRshort}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@ACRshort}[2][]{%
  \new@ifnextchar[{\@ACRshort{hyper=false,#1}{#2}}%
                  {\@ACRshort{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@ACRshort}[2][]{%
  \new@ifnextchar[{\@ACRshort{#1}{#2}}{\@ACRshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@ACRshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshort{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\MakeUppercase{\@glo@text#3}}}%
  }%
}
%    \end{macrocode}
%
% Short plural:
%\begin{macro}{\acrshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrshortpl}{\@ifstar\s@acrshortpl\ns@acrshortpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@acrshortpl}[2][]{%
  \new@ifnextchar[{\@acrshortpl{hyper=false,#1}{#2}}%
                  {\@acrshortpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@acrshortpl}[2][]{%
  \new@ifnextchar[{\@acrshortpl{#1}{#2}}{\@acrshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@acrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshortpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\@glo@text}#3}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrshortpl}{\@ifstar\s@Acrshortpl\ns@Acrshortpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@Acrshortpl}[2][]{%
  \new@ifnextchar[{\@Acrshortpl{hyper=false,#1}{#2}}%
                  {\@Acrshortpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Acrshortpl}[2][]{%
  \new@ifnextchar[{\@Acrshortpl{#1}{#2}}{\@Acrshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Acrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshortpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}%
    {%
      \acronymfont{\expandafter\makefirstuc\expandafter{\@glo@text}}#3%
    }%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRshortpl}{\@ifstar\s@ACRshortpl\ns@ACRshortpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@ACRshortpl}[2][]{%
  \new@ifnextchar[{\@ACRshortpl{hyper=false,#1}{#2}}%
                  {\@ACRshortpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@ACRshortpl}[2][]{%
  \new@ifnextchar[{\@ACRshortpl{#1}{#2}}{\@ACRshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@ACRshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentryshortpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\MakeUppercase{\@glo@text#3}}}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\acrlong}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrlong}{\@ifstar\s@acrlong\ns@acrlong}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@acrlong}[2][]{%
  \new@ifnextchar[{\@acrlong{hyper=false,#1}{#2}}%
                  {\@acrlong{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@acrlong}[2][]{%
  \new@ifnextchar[{\@acrlong{#1}{#2}}{\@acrlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylong{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\@glo@text#3}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrlong}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrlong}{\@ifstar\s@Acrlong\ns@Acrlong}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@Acrlong}[2][]{%
  \new@ifnextchar[{\@Acrlong{hyper=false,#1}{#2}}%
                  {\@Acrlong{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Acrlong}[2][]{%
  \new@ifnextchar[{\@Acrlong{#1}{#2}}{\@Acrlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylong{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}%
    {%
      \expandafter\makefirstuc\expandafter{\@glo@text}#3%
    }%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRlong}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRlong}{\@ifstar\s@ACRlong\ns@ACRlong}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@ACRlong}[2][]{%
  \new@ifnextchar[{\@ACRlong{hyper=false,#1}{#2}}%
                  {\@ACRlong{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@ACRlong}[2][]{%
  \new@ifnextchar[{\@ACRlong{#1}{#2}}{\@ACRlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@ACRlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylong{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
  }%
}
%    \end{macrocode}
%
% Short plural:
%\begin{macro}{\acrlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrlongpl}{\@ifstar\s@acrlongpl\ns@acrlongpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@acrlongpl}[2][]{%
  \new@ifnextchar[{\@acrlongpl{hyper=false,#1}{#2}}%
                  {\@acrlongpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@acrlongpl}[2][]{%
  \new@ifnextchar[{\@acrlongpl{#1}{#2}}{\@acrlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@acrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylongpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\@glo@text#3}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrlongpl}{\@ifstar\s@Acrlongpl\ns@Acrlongpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@Acrlongpl}[2][]{%
  \new@ifnextchar[{\@Acrlongpl{hyper=false#1}{#2}}%
                  {\@Acrlongpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Acrlongpl}[2][]{%
  \new@ifnextchar[{\@Acrlongpl{#1}{#2}}{\@Acrlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Acrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylongpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}%
    {%
      \expandafter\makefirstuc\expandafter{\@glo@text}#3%
    }%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRlongpl}{\@ifstar\s@ACRlongpl\ns@ACRlongpl}
%    \end{macrocode}
%\end{macro}
% Define the starred form:
%    \begin{macrocode}
\newcommand*{\s@ACRlongpl}[2][]{%
  \new@ifnextchar[{\@ACRlongpl{hyper=false,#1}{#2}}%
                  {\@ACRlongpl{hyper=false,#1}{#2}[]}%
}
%    \end{macrocode}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@ACRlongpl}[2][]{%
  \new@ifnextchar[{\@ACRlongpl{#1}{#2}}{\@ACRlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@ACRlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \protected@edef\@glo@text{\glsentrylongpl{#2}}%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text#3}}%
  }%
}
%    \end{macrocode}
%
% \subsubsection{Displaying entry details without adding
% information to the glossary}
%\label{sec:code:glsnolink}
% 
% These commands merely display entry information without adding
% entries in the associated file or having hyperlinks.
%
% Get the entry name (as specified by the \gloskey{name} key
% when the entry was defined). The argument
% is the label associated with the entry. Note that unless you
% used \texttt{name=false} in the \pkgopt{sanitize} package option 
% you may get unexpected results if the \gloskey{name} key contains 
% any commands.
%\begin{macro}{\glsentryname}
%    \begin{macrocode}
\newcommand*{\glsentryname}[1]{\csname glo@#1@name\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryname}
%    \begin{macrocode}
\newcommand*{\Glsentryname}[1]{%
\protected@edef\@glo@text{\csname glo@#1@name\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the entry description (as specified by the 
% \gloskey{description} when the entry was defined). The argument
% is the label associated with the entry. Note that unless you
% used \texttt{description=false} in the \pkgopt{sanitize} package 
% option you may get unexpected results if the \gloskey{description} 
% key contained any commands.
%\begin{macro}{\glsentrydesc}
%    \begin{macrocode}
\newcommand*{\glsentrydesc}[1]{\csname glo@#1@desc\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrydesc}
%    \begin{macrocode}
\newcommand*{\Glsentrydesc}[1]{%
\protected@edef\@glo@text{\csname glo@#1@desc\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
% Plural form:
%\begin{macro}{\glsentrydescplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\glsentrydescplural}[1]{%
\csname glo@#1@descplural\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrydescplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\Glsentrydescplural}[1]{%
\protected@edef\@glo@text{\csname glo@#1@descplural\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the entry text, as specified by the \gloskey{text} key when
% the entry was defined. The argument
% is the label associated with the entry:
%\begin{macro}{\glsentrytext}
%    \begin{macrocode}
\newcommand*{\glsentrytext}[1]{\csname glo@#1@text\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrytext}
%    \begin{macrocode}
\newcommand*{\Glsentrytext}[1]{%
\protected@edef\@glo@text{\csname glo@#1@text\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form:
%\begin{macro}{\glsentryplural}
%    \begin{macrocode}
\newcommand*{\glsentryplural}[1]{\csname glo@#1@plural\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryplural}
%    \begin{macrocode}
\newcommand*{\Glsentryplural}[1]{%
\protected@edef\@glo@text{\csname glo@#1@plural\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the symbol associated with this entry. The argument
% is the label associated with the entry. Note that unless you
% used \texttt{symbol=false} in the \pkgopt{sanitize} package 
% option you may get unexpected results if the \gloskey{symbol} 
% key contained any commands.
%\begin{macro}{\glsentrysymbol}
%    \begin{macrocode}
\newcommand*{\glsentrysymbol}[1]{\csname glo@#1@symbol\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrysymbol}
%    \begin{macrocode}
\newcommand*{\Glsentrysymbol}[1]{%
\protected@edef\@glo@text{\csname glo@#1@symbol\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
% Plural form:
%\begin{macro}{\glsentrysymbolplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\glsentrysymbolplural}[1]{%
\csname glo@#1@symbolplural\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrysymbolplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\Glsentrysymbolplural}[1]{%
\protected@edef\@glo@text{\csname glo@#1@symbolplural\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the entry text to be used when the entry is first used in
% the document (as specified by the \gloskey{first} key when
% the entry was defined).
%\begin{macro}{\glsentryfirst}
%    \begin{macrocode}
\newcommand*{\glsentryfirst}[1]{\csname glo@#1@first\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirst}
%    \begin{macrocode}
\newcommand*{\Glsentryfirst}[1]{%
\protected@edef\@glo@text{\csname glo@#1@first\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form (as specified by the \gloskey{firstplural}
% key when the entry was defined).
%\begin{macro}{\glsentryfirstplural}
%    \begin{macrocode}
\newcommand*{\glsentryfirstplural}[1]{%
\csname glo@#1@firstpl\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirstplural}
%    \begin{macrocode}
\newcommand*{\Glsentryfirstplural}[1]{%
\protected@edef\@glo@text{\csname glo@#1@firstpl\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Display the glossary type with which this entry is associated
% (as specified by the \gloskey{type} key used when the entry was 
% defined)
%\begin{macro}{\glsentrytype}
%    \begin{macrocode}
\newcommand*{\glsentrytype}[1]{\csname glo@#1@type\endcsname}
%    \end{macrocode}
%\end{macro}
%
% Display the sort text used for this entry. Note that the 
% \gloskey{sort} key is sanitize, so unexpected results may 
% occur if the \gloskey{sort} key contained commands.
%\begin{macro}{\glsentrysort}
%    \begin{macrocode}
\newcommand*{\glsentrysort}[1]{\csname glo@#1@sort\endcsname}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuseri}
% Get the first user key (as specified by the 
% \gloskey{user1} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuseri}[1]{\csname glo@#1@useri\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseri}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuseri}[1]{%
\protected@edef\@glo@text{\csname glo@#1@useri\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuserii}
% Get the second user key (as specified by the 
% \gloskey{user2} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuserii}[1]{\csname glo@#1@userii\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuserii}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuserii}[1]{%
\protected@edef\@glo@text{\csname glo@#1@userii\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuseriii}
% Get the third user key (as specified by the 
% \gloskey{user3} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuseriii}[1]{\csname glo@#1@useriii\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseriii}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuseriii}[1]{%
\protected@edef\@glo@text{\csname glo@#1@useriii\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuseriv}
% Get the fourth user key (as specified by the 
% \gloskey{user4} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuseriv}[1]{\csname glo@#1@useriv\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseriv}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuseriv}[1]{%
\protected@edef\@glo@text{\csname glo@#1@useriv\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuserv}
% Get the fifth user key (as specified by the 
% \gloskey{user5} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuserv}[1]{\csname glo@#1@userv\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuserv}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuserv}[1]{%
\protected@edef\@glo@text{\csname glo@#1@userv\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryuservi}
% Get the sixth user key (as specified by the 
% \gloskey{user6} when the entry was defined). The argument
% is the label associated with the entry.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\glsentryuservi}[1]{\csname glo@#1@uservi\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuservi}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryuservi}[1]{%
\protected@edef\@glo@text{\csname glo@#1@uservi\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryshort}
% Get the short key (as specified by the 
% \gloskey{short} the entry was defined). The argument
% is the label associated with the entry.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\glsentryshort}[1]{\csname glo@#1@short\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryshort}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryshort}[1]{%
\protected@edef\@glo@text{\csname glo@#1@short\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryshortpl}
% Get the short plural key (as specified by the 
% \gloskey{shortplural} the entry was defined). The argument
% is the label associated with the entry.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\glsentryshortpl}[1]{\csname glo@#1@shortpl\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryshortpl}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\Glsentryshortpl}[1]{%
\protected@edef\@glo@text{\csname glo@#1@shortpl\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentrylong}
% Get the long key (as specified by the 
% \gloskey{long} the entry was defined). The argument
% is the label associated with the entry.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\glsentrylong}[1]{\csname glo@#1@long\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrylong}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\Glsentrylong}[1]{%
\protected@edef\@glo@text{\csname glo@#1@long\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentrylongpl}
% Get the long plural key (as specified by the 
% \gloskey{longplural} the entry was defined). The argument
% is the label associated with the entry.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\glsentrylongpl}[1]{\csname glo@#1@longpl\endcsname}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrylongpl}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\Glsentrylongpl}[1]{%
\protected@edef\@glo@text{\csname glo@#1@longpl\endcsname}%
\expandafter\makefirstuc\expandafter{\@glo@text}}
%    \end{macrocode}
%\end{macro}
%
% Short cut macros to access full form:
%\begin{macro}{\glsentryfull}
%    \begin{macrocode}
\newcommand*{\glsentryfull}[1]{%
  \glsentrylong{#1}\space(\glsentryshort{#1})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfull}
%\changes{3.02}{2012/05/21}{fixed bug (replaced \cs{glsentryshortpl}
%with \cs{glsentryshort})}
%    \begin{macrocode}
\newcommand*{\Glsentryfull}[1]{%
  \Glsentrylong{#1}\space(\glsentryshort{#1})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryfullpl}
%\changes{3.02}{2012/05/21}{fixed bug (replaced \cs{glsentryshort}
%with \cs{glsentryshortpl})}
%    \begin{macrocode}
\newcommand*{\glsentryfullpl}[1]{%
  \glsentrylongpl{#1}\space(\glsentryshortpl{#1})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfullpl}
%    \begin{macrocode}
\newcommand*{\Glsentryfullpl}[1]{%
  \Glsentrylongpl{#1}\space(\glsentryshortpl{#1})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentrynumberlist}
%\changes{3.02}{2012/05/21}{new}
%Displays the number list as is.
%    \begin{macrocode}
\newcommand*{\glsentrynumberlist}[1]{%
  \glsdoifexists{#1}%
  {%
    \csname glo@#1@numberlist\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdisplaynumberlist}
%\changes{3.02}{2012/05/21}{new}
% Formats the number list for the given entry label.
% Doesn't work with hyperref.
%    \begin{macrocode}
\@ifpackageloaded{hyperref}
{%
  \newcommand*{\glsdisplaynumberlist}[1]{%
    \GlossariesWarning
    {%
      \string\glsdisplaynumberlist\space
      doesn't work with hyperref.^^JUsing
      \string\glsentrynumberlist\space instead%
    }%
    \glsentrynumberlist{#1}%
  }%
}%
{%
  \newcommand*{\glsdisplaynumberlist}[1]{%
    \glsdoifexists{#1}%
    {%
      \bgroup
         \def\@glo@label{#1}%
         \let\@org@glsnumberformat\glsnumberformat
         \def\glsnumberformat##1{##1}%
         \protected@edef\the@numberlist{\csname glo@\@glo@label @numberlist\endcsname}%
         \def\@gls@numlist@sep{}%
         \def\@gls@numlist@nextsep{}%
         \def\@gls@numlist@lastsep{}%
         \def\@gls@thislist{}%
         \def\@gls@donext@def{}%
         \renewcommand\do[1]{%
           \protected@edef\@gls@thislist{%
             \@gls@thislist
             \noexpand\@gls@numlist@sep 
             ##1%
           }%
           \let\@gls@numlist@sep\@gls@numlist@nextsep
           \def\@gls@numlist@nextsep{\glsnumlistsep}%
           \@gls@donext@def
           \def\@gls@donext@def{%
             \def\@gls@numlist@lastsep{\glsnumlistlastsep}%
           }%
         }%
         \expandafter \glsnumlistparser \expandafter{\the@numberlist}%
         \let\@gls@numlist@sep\@gls@numlist@lastsep
         \@gls@thislist
      \egroup
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnumlistsep}
%\changes{3.02}{21012/05/19}{new}
%    \begin{macrocode}
\newcommand*{\glsnumlistsep}{, }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsnumlistlastsep}
%\changes{3.02}{21012/05/19}{new}
%    \begin{macrocode}
\newcommand*{\glsnumlistlastsep}{ \& }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glshyperlink}
% Provide a hyperlink to a glossary entry without adding information
% to the glossary file. The entry needs to be added using a 
% command like \ics{glslink} or \ics{glsadd} to ensure that
% the target is defined. The first (optional) argument specifies
% the link text. The entry name is used by default. The second
% argument is the entry label.
%\changes{1.17}{2008 December 26}{new}
%\changes{3.0}{2011/04/02}{changed default from \cs{glsentryname}
%to \cs{glsentrytext}}
%    \begin{macrocode}
\newcommand*{\glshyperlink}[2][\glsentrytext{\@glo@label}]{%
\def\@glo@label{#2}%
\@glslink{\glolinkprefix#2}{#1}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Adding an entry to the glossary without generating
% text}
% The following keys are provided for \cs{glsadd} and 
% \cs{glsaddall}:
%    \begin{macrocode}
\define@key{glossadd}{counter}{\def\@gls@counter{#1}}
%    \end{macrocode}
%\changes{2.07}{2010 Jul 10}{glssadd format key stored in \cs{@glsnumberformat}
%(was mistakenly stored in \cs{@glo@format})}
%    \begin{macrocode}
\define@key{glossadd}{format}{\def\@glsnumberformat{#1}}
%    \end{macrocode}
% This key is only used by \cs{glsaddall}:
%    \begin{macrocode}
\define@key{glossadd}{types}{\def\@glo@type{#1}}
%    \end{macrocode}
%\vskip5pt
%\cs{glsadd}\oarg{options}\marg{label}\\[10pt]
% Add a term to the glossary without generating any link text. 
% The optional argument indicates which counter to use, 
% and how to format it (using a key-value list)
% the second argument is the entry label. Note that \meta{options}
% only has two keys: \gloskey[glsadd]{counter} and \gloskey[glsadd]{format} (the \gloskey[glsaddall]{types} key will be ignored).
%\begin{macro}{\glsadd}
%\changes{1.07}{2007 Sep 13}{fixed bug caused by \cs{theglsentrycounter} setting the page number too soon}
%\changes{2.04}{2009 November 10}{fixed bug that ignored counter}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsadd}[2][]{%
  \glsdoifexists{#2}%
  {%
    \def\@glsnumberformat{glsnumberformat}%
    \edef\@gls@counter{\csname glo@#2@counter\endcsname}%
    \setkeys{glossadd}{#1}%
%    \end{macrocode}
% Store the entry's counter in \cs{theglsentrycounter}
%\changes{3.0}{2011/04/02}{added \cs{@gls@saveentrycounter}}
%    \begin{macrocode}
    \@gls@saveentrycounter
    \@do@wrglossary{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
%\cs{glsaddall}\oarg{option list}\\[10pt]
% Add all terms defined for the listed glossaries (without displaying
% any text). If \gloskey[glsaddall]{types} key is omitted, apply to all
% glossary types.
%\begin{macro}{\glsaddall}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\glsaddall}[1][]{%
\edef\@glo@type{\@glo@types}%
\setkeys{glossadd}{#1}%
\forallglsentries[\@glo@type]{\@glo@entry}{%
\glsadd[#1]{\@glo@entry}}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Creating associated files}
% The \cs{writeist} command creates the associated 
% customized \filetype{.ist} \app{makeindex} style file.
% While defining this command, some characters have their 
% catcodes temporarily changed to ensure they get written to 
% the \filetype{.ist} file correctly. The \app{makeindex} 
% actual character (usually "@") is redefined to be a "?", to allow 
% internal commands to be written to the glossary file output file.
%
% The special characters\mkidxspch\ are stored in \cs{@gls@actualchar},
% \cs{@gls@encapchar}, \cs{@glsl@levelchar} and
% \cs{@gls@quotechar} to make them easier to use later,
% but don't change these values, because the characters are
% encoded in the command definitions that are used to escape
% the special characters (which means that the user no longer
% needs to worry about \app{makeindex} special characters).
%
% The symbols and numbers label for group headings are hardwired into
% the \filetype{.ist} file as \texttt{glssymbols} and 
% \texttt{glsnumbers}, the group titles can be translated 
% (so that \ics{glssymbolsgroupname} replaces \texttt{glssymbols}
% and \ics{glsnumbersgroupname} replaces \texttt{glsnumbers})
% using the command \ics{glsgetgrouptitle} which is
% defined in \isty{glossary-hypernav}. This is done to prevent
% any problem characters in \ics{glssymbolsgroupname}
% and \ics{glsnumbersgroupname} from breaking hyperlinks.
%
%\begin{macro}{\glsopenbrace}
% Define \cs{glsopenbrace} to make it easier to write an opening 
% brace to a file.
%    \begin{macrocode}
\edef\glsopenbrace{\expandafter\@gobble\string\{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsclosebrace}
% Define \cs{glsclosebrace} to make it easier to write an opening 
% brace to a file.
%    \begin{macrocode}
\edef\glsclosebrace{\expandafter\@gobble\string\}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsquote}
% Define command that makes it easier to write quote marks to
% a file in the event that the double quote character has been
% made active.
%    \begin{macrocode}
\edef\glsquote#1{\string"#1\string"}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsfirstletter}
% Define the first letter to come after the digits 0,\ldots,9.
% Only required for \app{xindy}.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@glsfirstletter}{A}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsSetXdyFirstLetterAfterDigits}
% Sets the first letter to come after the digits 0,\ldots,9.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\GlsSetXdyFirstLetterAfterDigits}[1]{%
    \renewcommand*{\@glsfirstletter}{#1}}
\else
  \newcommand*{\GlsSetXdyFirstLetterAfterDigits}[1]{%
    \glsnoxindywarning\GlsSetXdyFirstLetterAfterDigits}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsminrange}
% Define the minimum number of successive location references
% to merge into a range.
%    \begin{macrocode}
\newcommand*{\@glsminrange}{2}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsSetXdyMinRangeLength}
% Set the minimum range length. The value must either be "none"
% or a positive integer. The \sty{glossaries} package doesn't
% check if the argument is valid, that is left to \app{xindy}.
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\GlsSetXdyMinRangeLength}[1]{%
    \renewcommand*{\@glsminrange}{#1}}
\else
  \newcommand*{\GlsSetXdyMinRangeLength}[1]{%
    \glsnoxindywarning\GlsSetXdyMinRangeLength}
\fi
%    \end{macrocode}
%\end{macro}

%\begin{macro}{\writeist}
%\changes{1.17}{2008 December 26}{added xindy support}
%\changes{1.01}{2007 May 17}{Added spaces after 'delimN and 'delimR in ist file}%
%\changes{3.0}{2011/04/02}{modified to support new format}
%    \begin{macrocode}
\ifglsxindy
%    \end{macrocode}
% Code to use if \app{xindy} is required.
%    \begin{macrocode}
  \def\writeist{%
%    \end{macrocode}
% Update attributes list
%    \begin{macrocode}
    \@gls@addpredefinedattributes
%    \end{macrocode}
% Open the file.
%    \begin{macrocode}
    \openout\glswrite=\istfilename
%    \end{macrocode}
% Write header comment at the start of the file
%    \begin{macrocode}
    \write\glswrite{;; xindy style file created by the glossaries
        package}%
    \write\glswrite{;; for document '\jobname' on 
       \the\year-\the\month-\the\day}%
%    \end{macrocode}
% Specify the required styles
%    \begin{macrocode}
    \write\glswrite{^^J; required styles^^J}
    \@for\@xdystyle:=\@xdyrequiredstyles\do{%
         \ifx\@xdystyle\@empty
         \else
           \protected@write\glswrite{}{(require 
             \string"\@xdystyle.xdy\string")}%
         \fi
    }%
%    \end{macrocode}
% List the allowed attributes (possible values used by the
% \gloskey{format} key)
%    \begin{macrocode}
    \write\glswrite{^^J%
       ; list of allowed attributes (number formats)^^J}%
    \write\glswrite{(define-attributes ((\@xdyattributes)))}%
%    \end{macrocode}
% Define any additional alphabets
%    \begin{macrocode}
    \write\glswrite{^^J; user defined alphabets^^J}%
    \write\glswrite{\@xdyuseralphabets}%
%    \end{macrocode}
% Define location classes.
%    \begin{macrocode}
    \write\glswrite{^^J; location class definitions^^J}%
%    \end{macrocode}
% As from version 3.0, locations are now specified as
% \marg{Hprefix}\marg{number}, so need to add all possible
% combinations of location types.
%    \begin{macrocode}
    \@for\@gls@classI:=\@gls@xdy@locationlist\do{%
%    \end{macrocode}
% Case were \meta{Hprefix} is empty:
%    \begin{macrocode}
      \protected@write\glswrite{}{(define-location-class
        \string"\@gls@classI\string"^^J\space\space\space
        (
          :sep "{}{"
          \csname @gls@xdy@Lclass@\@gls@classI\endcsname\space
          :sep "}"
        )
        ^^J\space\space\space
        :min-range-length \@glsminrange^^J%
        )
      }%
%    \end{macrocode}
% Nested iteration over all classes:
%    \begin{macrocode}
      {%
        \@for\@gls@classII:=\@gls@xdy@locationlist\do{%
          \protected@write\glswrite{}{(define-location-class
            \string"\@gls@classII-\@gls@classI\string"
              ^^J\space\space\space
            (
              :sep "{"
              \csname @gls@xdy@Lclass@\@gls@classII\endcsname\space
              :sep "}{"
              \csname @gls@xdy@Lclass@\@gls@classI\endcsname\space
              :sep "}"
            )
            ^^J\space\space\space
            :min-range-length \@glsminrange^^J%
            )
          }%
        }%
      }%
    }%
%    \end{macrocode}
% User defined location classes (needs checking for new location format).
%    \begin{macrocode}
    \write\glswrite{^^J; user defined location classes}%
    \write\glswrite{\@xdyuserlocationdefs}%
%    \end{macrocode}
% Cross-reference class. (The unverified option is used as the
% cross-references are supplied using the list of labels along with
% the optional argument for \ics{glsseeformat} which
% \app{xindy} won't recognise.)
%    \begin{macrocode}
    \write\glswrite{^^J; define cross-reference class^^J}%
    \write\glswrite{(define-crossref-class \string"see\string"
        :unverified )}%
%    \end{macrocode}
% Define how cross-references should be displayed. This adds an
% empty set of braces after the cross-referencing information 
% allowing for the final argument of \cs{glsseeformat} which
% gets ignored. (When using \app{makeindex} this final argument
% contains the location information which is not required.)
%    \begin{macrocode}
    \write\glswrite{(markup-crossref-list
         :class \string"see\string"^^J\space\space\space
         :open \string"\string\glsseeformat\string"
         :close \string"{}\string")}%
%    \end{macrocode}
% List the order to sort the classes.
%    \begin{macrocode}
    \write\glswrite{^^J; define the order of the location classes}%
    \write\glswrite{(define-location-class-order
         (\@xdylocationclassorder))}%
%    \end{macrocode}
% Specify what to write to the start and end of the glossary file.
%    \begin{macrocode}
    \write\glswrite{^^J; define the glossary markup^^J}%
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added xindy-only macro definitions to
%glossary open tag}
%    \begin{macrocode}
    \write\glswrite{(markup-index^^J\space\space\space
        :open \string"\string
        \glossarysection[\string\glossarytoctitle]{\string
        \glossarytitle}\string\glossarypreamble}%
%    \end{macrocode}
% Add all the xindy-only macro definitions (needed to prevent errors
% in the event that the user changes from \pkgopt{xindy} to
% \pkgopt{makeindex})
%    \begin{macrocode}
    \@for\@this@ctr:=\@xdycounters\do{%
      {%
        \@for\@this@attr:=\@xdyattributelist\do{%
           \protected@write\glswrite{}{\string\providecommand*%
             \expandafter\string
             \csname glsX\@this@ctr X\@this@attr\endcsname[2]%
             {%
                \string\setentrycounter
                  [\expandafter\@gobble\string\#1]{\@this@ctr}%
                \expandafter\string
                \csname\@this@attr\endcsname
                  {\expandafter\@gobble\string\#2}%
             }%
           }%
        }%
      }%
    }%
%    \end{macrocode}
% Add the end part of the open tag and the rest of the markup-index
% information:
%    \begin{macrocode}
    \write\glswrite{%
        \string\begin
        {theglossary}\string\glossaryheader\string~n\string" ^^J\space
        \space\space:close \string"\expandafter\@gobble
          \string\%\string~n\string
          \end{theglossary}\string\glossarypostamble
          \string~n\string" ^^J\space\space\space
        :tree)}%
%    \end{macrocode}
% Specify what to put between letter groups
%    \begin{macrocode}
    \write\glswrite{(markup-letter-group-list
        :sep \string"\string\glsgroupskip\string~n\string")}%
%    \end{macrocode}
% Specify what to put between entries
%    \begin{macrocode}
    \write\glswrite{(markup-indexentry
        :open \string"\string\relax \string\glsresetentrylist
           \string~n\string")}%
%    \end{macrocode}
% Specify how to format entries
%    \begin{macrocode}
    \write\glswrite{(markup-locclass-list :open 
       \string"\glsopenbrace\string\glossaryentrynumbers
         \glsopenbrace\string\relax\space \string"^^J\space\space\space
       :sep \string", \string"
       :close \string"\glsclosebrace\glsclosebrace\string")}%
%    \end{macrocode}
% Specify how to separate location numbers
%    \begin{macrocode}
    \write\glswrite{(markup-locref-list
       :sep \string"\string\delimN\space\string")}%
%    \end{macrocode}
% Specify how to indicate location ranges
%    \begin{macrocode}
    \write\glswrite{(markup-range
       :sep \string"\string\delimR\space\string")}%
%    \end{macrocode}
% Specify 2-page and 3-page suffixes, if defined.
% First, the values must be sanitized to write them explicity.
%    \begin{macrocode}
    \@onelevel@sanitize\gls@suffixF
    \@onelevel@sanitize\gls@suffixFF
%    \end{macrocode}
%    \begin{macrocode}
    \ifx\gls@suffixF\@empty
    \else
      \write\glswrite{(markup-range
        :close "\gls@suffixF" :length 1 :ignore-end)}%
    \fi
    \ifx\gls@suffixFF\@empty
    \else
      \write\glswrite{(markup-range
        :close "\gls@suffixFF" :length 2 :ignore-end)}%
    \fi
%    \end{macrocode}
% Specify how to format locations.
%    \begin{macrocode}
    \write\glswrite{^^J; define format to use for locations^^J}%
    \write\glswrite{\@xdylocref}%
%    \end{macrocode}
% Specify how to separate letter groups.
%    \begin{macrocode}
    \write\glswrite{^^J; define letter group list format^^J}%
    \write\glswrite{(markup-letter-group-list
       :sep \string"\string\glsgroupskip\string~n\string")}%
%    \end{macrocode}
% Define letter group headings.
%    \begin{macrocode}
    \write\glswrite{^^J; letter group headings^^J}%
    \write\glswrite{(markup-letter-group 
        :open-head \string"\string\glsgroupheading
        \glsopenbrace\string"^^J\space\space\space
        :close-head \string"\glsclosebrace\string")}%
%    \end{macrocode}
% Define additional letter groups.
%    \begin{macrocode}
    \write\glswrite{^^J; additional letter groups^^J}%
    \write\glswrite{\@xdylettergroups}%
%    \end{macrocode}
% Define additional sort rules
%    \begin{macrocode}
    \write\glswrite{^^J; additional sort rules^^J}
    \write\glswrite{\@xdysortrules}%
%    \end{macrocode}
% Close the style file
%    \begin{macrocode}
    \closeout\glswrite
%    \end{macrocode}
% Suppress any further calls.
%    \begin{macrocode}
    \let\writeist\relax
  }
\else
%    \end{macrocode}
% Code to use if \app{makeindex} is required.
%\changes{2.01}{2009 May 30}{removed item\_02 - no such makeindex key}
%    \begin{macrocode}
  \edef\@gls@actualchar{\string?}
  \edef\@gls@encapchar{\string|}
  \edef\@gls@levelchar{\string!}
  \edef\@gls@quotechar{\string"}
  \def\writeist{\relax
   \openout\glswrite=\istfilename
    \write\glswrite{\expandafter\@gobble\string\% makeindex style file
      created by the glossaries package}
    \write\glswrite{\expandafter\@gobble\string\% for document
      '\jobname' on \the\year-\the\month-\the\day}
    \write\glswrite{actual '\@gls@actualchar'}
    \write\glswrite{encap '\@gls@encapchar'}
    \write\glswrite{level '\@gls@levelchar'}
    \write\glswrite{quote '\@gls@quotechar'}
    \write\glswrite{keyword \string"\string\\glossaryentry\string"}
    \write\glswrite{preamble \string"\string\\glossarysection[\string
      \\glossarytoctitle]{\string\\glossarytitle}\string
      \\glossarypreamble\string\n\string\\begin{theglossary}\string
      \\glossaryheader\string\n\string"}
    \write\glswrite{postamble \string"\string\%\string\n\string
      \\end{theglossary}\string\\glossarypostamble\string\n
      \string"}
    \write\glswrite{group_skip \string"\string\\glsgroupskip\string\n
      \string"}
    \write\glswrite{item_0 \string"\string\%\string\n\string"}
    \write\glswrite{item_1 \string"\string\%\string\n\string"}
    \write\glswrite{item_2 \string"\string\%\string\n\string"}
    \write\glswrite{item_01 \string"\string\%\string\n\string"}
    \write\glswrite{item_x1
      \string"\string\\relax \string\\glsresetentrylist\string\n
      \string"}
    \write\glswrite{item_12 \string"\string\%\string\n\string"}
    \write\glswrite{item_x2
      \string"\string\\relax \string\\glsresetentrylist\string\n
      \string"}
%    \end{macrocode}
%\changes{2.05}{2010 Feb 6}{Added \cs{string} before opening 
% and closing braces. Patch provided by Segiu Dotenco}
%    \begin{macrocode}
    \write\glswrite{delim_0 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_1 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_2 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_t \string"\string\}\string\}\string"}
    \write\glswrite{delim_n \string"\string\\delimN \string"}
    \write\glswrite{delim_r \string"\string\\delimR \string"}
    \write\glswrite{headings_flag 1}
    \write\glswrite{heading_prefix 
       \string"\string\\glsgroupheading\string\{\string"}
    \write\glswrite{heading_suffix
       \string"\string\}\string\\relax
       \string\\glsresetentrylist \string"}
    \write\glswrite{symhead_positive \string"glssymbols\string"}
    \write\glswrite{numhead_positive \string"glsnumbers\string"}
    \write\glswrite{page_compositor \string"\glscompositor\string"}
    \@gls@escbsdq\gls@suffixF
    \@gls@escbsdq\gls@suffixFF
    \ifx\gls@suffixF\@empty
    \else
      \write\glswrite{suffix_2p \string"\gls@suffixF\string"}
    \fi
    \ifx\gls@suffixFF\@empty
    \else
      \write\glswrite{suffix_3p \string"\gls@suffixFF\string"}
    \fi
    \closeout\glswrite
    \let\writeist\relax
  }
\fi
%    \end{macrocode}
%\end{macro}
%
%The command \cs{noist} will suppress the creation of
% the \filetype{.ist} file. Obviously you need to use this
% command before \cs{writeist} to have any effect.
%\begin{macro}{\noist}
%    \begin{macrocode}
\newcommand{\noist}{%
%    \end{macrocode}
% Update attributes list
%    \begin{macrocode}
  \@gls@addpredefinedattributes
  \let\writeist\relax
}
%    \end{macrocode}
%\end{macro}
%
% \cs{@makeglossary} is an internal command that takes an 
% argument indicating the glossary type. This command will 
% create the glossary file required by \app{makeindex} for the
% given glossary type, using the extension supplied by the
% \meta{out-ext} parameter used in \ics{newglossary} 
% (and it will also activate the \ics{glossary} command, 
% and create the customized \filetype{.ist} \app{makeindex} 
% style file). 
%
% Note that you can't use \cs{@makeglossary} for only some of the
% defined glossaries. You either need to have a \cs{makeglossary}
% for all glossaries or none (otherwise you will end up with a
% situation where \TeX\ is trying to write to a non-existant
% file). The relevant glossary must be
% defined prior to using \cs{@makeglossary}.
%\begin{macro}{\@makeglossary}
%    \begin{macrocode}
\newcommand*{\@makeglossary}[1]{%
  \ifglossaryexists{#1}%
  {%
%    \end{macrocode}
% Only create a new write if \pkgopt[false]{savewrites} otherwise
% create a token to collect the information.
%\changes{3.0}{2010 Jul 12}{Added check for \pkgopt{savewrites}}
%    \begin{macrocode}
    \ifglssavewrites
      \expandafter\newtoks\csname glo@#1@filetok\endcsname
    \else
      \expandafter\newwrite\csname glo@#1@file\endcsname
      \expandafter\@glsopenfile\csname glo@#1@file\endcsname{#1}%
    \fi
    \@gls@renewglossary
    \writeist
  }%
  {%
    \PackageError{glossaries}%
    {Glossary type `#1' not defined}%
    {New glossaries must be defined before using \string\makeglossary}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsopenfile}
% Open write file associated with the given glossary.
%    \begin{macrocode}
\newcommand*{\@glsopenfile}[2]{%
  \immediate\openout#1=\jobname.\csname @glotype@#2@out\endcsname
  \PackageInfo{glossaries}{Writing glossary file
     \jobname.\csname @glotype@#2@out\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\warn@nomakeglossaries}
% Issue warning that \cs{makeglossaries} hasn't been used.
%    \begin{macrocode}
\newcommand*{\warn@nomakeglossaries}{%
  \GlossariesWarningNoLine{\string\makeglossaries\space
  hasn't been used,^^Jthe glossaries will not be updated}%
}
%    \end{macrocode}
%\end{macro}
%
% \cs{makeglossaries} will use \cs{@makeglossary}
% for each glossary type that has been defined.  New glossaries
% need to be defined before using \cs{makeglossary}, so
% have \cs{makeglossaries} redefine \cs{newglossary}
% to prevent it being used afterwards.
%\begin{macro}{\makeglossaries}
%    \begin{macrocode}
\newcommand*{\makeglossaries}{%
%    \end{macrocode}
% Write the name of the style file to the aux file 
% (needed by \app{makeglossaries})
%    \begin{macrocode}
  \protected@write\@auxout{}{\string\@istfilename{\istfilename}}%
  \protected@write\@auxout{}{\string\@glsorder{\glsorder}}
%    \end{macrocode}
% Iterate through each glossary type and activate it.
%    \begin{macrocode}
  \@for\@glo@type:=\@glo@types\do{%
    \ifthenelse{\equal{\@glo@type}{}}{}{%
    \@makeglossary{\@glo@type}}%
  }%
%    \end{macrocode}
% New glossaries must be created before \cs{makeglossaries} 
% so disable \ics{newglossary}.
%    \begin{macrocode}
  \renewcommand*\newglossary[4][]{%
  \PackageError{glossaries}{New glossaries
  must be created before \string\makeglossaries}{You need
  to move \string\makeglossaries\space after all your 
  \string\newglossary\space commands}}%
%    \end{macrocode}
% Any subsequence instances of this command should have no effect
%    \begin{macrocode}
  \let\@makeglossary\relax
  \let\makeglossary\relax
  \let\makeglossaries\relax
%    \end{macrocode}
% Disable all commands that have no effect after \cs{makeglossaries}
%    \begin{macrocode}
  \@disable@onlypremakeg
%    \end{macrocode}
% Suppress warning about no \cs{makeglossaries}
%    \begin{macrocode}
  \let\warn@nomakeglossaries\relax
%    \end{macrocode}
% Declare list parser for \cs{glsdisplaynumberlist}
%\changes{3.02}{2012/05/21}{added list parser}
%    \begin{macrocode}
  \ifglssavenumberlist
    \edef\@gls@dodeflistparser{\noexpand\DeclareListParser
      {\noexpand\glsnumlistparser}{\delimN}}%
    \@gls@dodeflistparser
  \fi
}
%    \end{macrocode}
%\end{macro}
%
% The \cs{makeglossary} command is redefined to be
% identical to \cs{makeglossaries}. (This is done to 
% reinforce the message that you must either use 
% \cs{@makeglossary} for all the glossaries or for none 
% of them.)
%\begin{macro}{\makeglossary}
%    \begin{macrocode}
\let\makeglossary\makeglossaries
%    \end{macrocode}
%\end{macro}
%
% If \ics{makeglossaries} hasn't been used, issue a warning.
% Also issue a warning if neither \ics{printglossaries} nor
% \ics{printglossary} have been used.
%    \begin{macrocode}
\AtEndDocument{%
  \warn@nomakeglossaries
  \warn@noprintglossary
}
%    \end{macrocode}
%
%\subsection{Writing information to associated files}
%
%
%\begin{macro}{\glswrite}
% The write used for style file also used for all other output files
% if \pkgopt[true]{savewrites}.
%    \begin{macrocode}
\newwrite\glswrite
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\istfile}
%\changes{3.0}{2011/04/02}{deprecated}
% Deprecated.
%    \begin{macrocode}
\def\istfile{\glswrite}
%    \end{macrocode}
%\end{macro}
%
% At the end of the document, the files should be created if
% \pkgopt[true]{savewrites}.
%    \begin{macrocode}
\AtEndDocument{%
  \glswritefiles
}
%    \end{macrocode}
%\begin{macro}{\glswritefiles}
% Only write the files if \pkgopt[true]{savewrites}
%    \begin{macrocode}
\ifglssavewrites
  \newcommand*{\glswritefiles}{%
%    \end{macrocode}
% Iterate through all the glossaries
%\changes{3.01}{2011/04/12}{added check for empty glossaries}
%\changes{3.02}{2012/05/21}{added check for existence of token
% in case \cs{makeglossaries has been omitted}}
%    \begin{macrocode}
    \forallglossaries{\@glo@type}{%
%    \end{macrocode}
% Check for empty glossaries (patch provided by Patrick H\"acker)
%    \begin{macrocode}
       \ifcsundef{glo@\@glo@type @filetok}%
       {%
          \def\gls@tmp{}%
       }%
       {%
          \edef\gls@tmp{\expandafter\the
             \csname glo@\@glo@type @filetok\endcsname}%
       }%
       \ifx\gls@tmp\@empty
          \ifx\@glo@type\glsdefaulttype
            \GlossariesWarningNoLine{Glossary `\@glo@type' has no
               entries.^^JRemember to use package option `nomain' if
you
               don't want to^^Juse the main glossary}%
          \else
            \GlossariesWarningNoLine{Glossary `\@glo@type' has no
               entries}%
          \fi
       \else
          \@glsopenfile{\glswrite}{\@glo@type}%
          \immediate\write\glswrite{%
             \expandafter\the
               \csname glo@\@glo@type @filetok\endcsname}%
          \immediate\closeout\glswrite
       \fi
    }%
  }
\else
  \let\glswritefiles\relax
\fi
%    \end{macrocode}
%\end{macro}
%
% The \cs{glossary} command is redefined so that it takes an 
% optional argument \meta{type} to specify the glossary type (use 
% \cs{glsdefaulttype} glossary by default). 
% This shouldn't be used at user level
% as \cs{glslink} sets the correct format. The associated 
% number should be stored in \cs{theglsentrycounter}
% before using \cs{glossary}.
%\begin{macro}{\glossary}
%    \begin{macrocode}
\renewcommand*{\glossary}[1][\glsdefaulttype]{%
  \@glossary[#1]%
}
%    \end{macrocode}
%\end{macro}
%
% Define internal \cs{@glossary} to ignore its argument.
% This gets redefined in \cs{@makeglossary}. This is
% defined to just \cs{index} as \cls{memoir} changes the definition of
% \cs{@index}. (Thanks to Dan Luecking for pointing this out.)
%\begin{macro}{\@glossary}
%\changes{1.17}{2008 December 26}{changed definition to use
%\cs{index} instead of \cs{@index}}
%    \begin{macrocode}
\def\@glossary[#1]{\index}
%    \end{macrocode}
%\end{macro}
% This is a convenience command to set \cs{@glossary}.
% It is used by \cs{@makeglossary} and then redefined to
% do nothing, as it only needs to be done once.
%\begin{macro}{\@gls@renewglossary}
%    \begin{macrocode}
\newcommand{\@gls@renewglossary}{%
  \gdef\@glossary[##1]{\@bsphack\begingroup\@wrglossary{##1}}%
  \let\@gls@renewglossary\@empty
}
%    \end{macrocode}
%\end{macro}
% The \cs{@wrglossary} command is redefined to have
% two arguments. The first argument is the glossary type, 
% the second argument is the glossary entry 
% (the format of which is set in \cs{glslink}).
%\begin{macro}{\@wrglossary}
%\changes{1.17}{2008 December 26}{modified to allow for xindy support}
%\changes{3.0}{2010 Jul 12}{modified to take into account
%\pkgopt{savewrites}}
%    \begin{macrocode}
\renewcommand*{\@wrglossary}[2]{%
  \ifglssavewrites
    \protected@edef\@gls@tmp{\the\csname glo@#1@filetok\endcsname#2}%
    \expandafter\global\expandafter\csname glo@#1@filetok\endcsname
       \expandafter{\@gls@tmp^^J}%
  \else
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{added check for glossary file defined}%
%    \begin{macrocode}
    \ifcsdef{glo@#1@file}%
    {%
      \expandafter\protected@write\csname glo@#1@file\endcsname{%
        \gls@disablepagerefexpansion}{#2}%
    }%
    {%
       \GlossariesWarning{No file defined for glossary `#1'}%
    }%
  \fi
  \endgroup\@esphack
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@do@wrglossary}
%\changes{3.02}{2012/05/21}{changed \cs{@do@wr@glossary} to test for
%\pkgopt{indexonlyfirst} option; put old \cs{@do@wr@glossary} code
%into \cs{@@do@wrglossary}}
%    \begin{macrocode}
\newcommand*{\@do@wrglossary}[1]{%
  \ifglsindexonlyfirst
    \ifglsused{#1}{}{\@@do@wrglossary{#1}}%
  \else
    \@@do@wrglossary{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@protected@pagefmts}
%\changes{3.04}{2012-11-18}{new}
% List of page formats to be protected against expansion.
%    \begin{macrocode}
\newcommand{\gls@protected@pagefmts}{%
  \gls@numberpage,\gls@alphpage,\gls@Alphpage,\gls@romanpage
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@disablepagerefexpansion}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
\newcommand*{\gls@disablepagerefexpansion}{%
  \@for\@gls@this:=\gls@protected@pagefmts\do
  {%
    \expandafter\let\@gls@this\relax
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@alphpage}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
\newcommand*{\gls@alphpage}{\@alph\c@page}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@Alphpage}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
\newcommand*{\gls@Alphpage}{\@Alph\c@page}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@numberpage}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
\newcommand*{\gls@numberpage}{\number\c@page}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@romanpage}
%\changes{3.04}{2012-11-18}{new}
%    \begin{macrocode}
\newcommand*{\gls@romanpage}{\romannumeral\c@page}
%    \end{macrocode}
%\changes{1.17}{2008 December 26}{new}
% Write the glossary entry in the appropriate format.
% (Need to set \cs{@glsnumberformat} and \cs{@gls@counter} prior to use.)
% The argument is the entry's label.
%\changes{3.0}{2011/04/02}{modified to use new format}
%    \begin{macrocode}
\newcommand*{\@@do@wrglossary}[1]{%
  \begingroup
% First a bit of hackery to prevent premature
% expansion of \cs{c@page}. Store original definitions:
%\changes{3.04}{2012-11-18}{modified to compensate for possible
%incorrect page number}
%    \begin{macrocode}
    \let\orgnumber\number
    \let\orgromannumeral\romannumeral
    \let\orgalph\@alph
    \let\orgAlph\@Alph
%    \end{macrocode}
% Redefine:
%    \begin{macrocode}
    \def\the##1{%
      \ifx##1\c@page \gls@numberpage\else\orgnumber##1\fi}%
    \def\number##1{%
      \ifx##1\c@page \gls@numberpage\else\orgnumber##1\fi}%
    \def\romannumeral##1{%
      \ifx##1\c@page \gls@romanpage\else\orgnumber##1\fi}%
    \def\@alph##1{%
      \ifx##1\c@page \gls@alphpage\else\orgnumber##1\fi}%
    \def\@Alph##1{%
      \ifx##1\c@page \gls@Alphpage\else\orgnumber##1\fi}%
%    \end{macrocode}
% Prevent expansion:
%    \begin{macrocode}
    \gls@disablepagerefexpansion
%    \end{macrocode}
% Now store location in \cs{@glslocref}:
%    \begin{macrocode}
    \protected@xdef\@glslocref{\theglsentrycounter}%
  \endgroup
%    \end{macrocode}
% Escape any special characters
%    \begin{macrocode}
  \@gls@checkmkidxchars\@glslocref
%    \end{macrocode}
% Check if the hyper-location is the same as the location and set
% the hyper prefix.
%\changes{3.0}{2011/04/02}{added check for hyper location prefix}
%    \begin{macrocode}
  \expandafter\ifx\theHglsentrycounter\theglsentrycounter
    \def\@glo@counterprefix{}%
  \else
    \protected@edef\@glsHlocref{\theHglsentrycounter}%
    \@gls@checkmkidxchars\@glsHlocref
    \edef\@do@gls@getcounterprefix{\noexpand\@gls@getcounterprefix
      {\@glslocref}{\@glsHlocref}%
    }%
    \@do@gls@getcounterprefix
  \fi
%    \end{macrocode}
% Determine whether to use \app{xindy} or \app{makeindex}
% syntax
%    \begin{macrocode}
  \ifglsxindy
%    \end{macrocode}
% Need to determine if the formatting information starts with
% a ( or ) indicating a range.
%    \begin{macrocode}
    \expandafter\@glo@check@mkidxrangechar\@glsnumberformat\@nil
    \def\@glo@range{}%
    \expandafter\if\@glo@prefix(\relax
      \def\@glo@range{:open-range}%
    \else
      \expandafter\if\@glo@prefix)\relax
        \def\@glo@range{:close-range}%
      \fi
    \fi
%    \end{macrocode}
% Write to the glossary file using \app{xindy} syntax.
%    \begin{macrocode}
    \glossary[\csname glo@#1@type\endcsname]{%
    (indexentry :tkey (\csname glo@#1@index\endcsname)
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{changed \cs{@glslocref} to \cs{theglsentrycounter}}
%\changes{3.04}{2012-11-18}{changed \cs{theglsentrycounter} back to \cs{@glslocref}}
%    \begin{macrocode}
      :locref \string"{\@glo@counterprefix}{\@glslocref}\string" %
      :attr \string"\@gls@counter\@glo@suffix\string"
      \@glo@range
    )
    }%
  \else
%    \end{macrocode}
% Convert the format information into the format required for
% \app{makeindex}
%    \begin{macrocode}
    \@set@glo@numformat{\@glo@numfmt}{\@gls@counter}{\@glsnumberformat}%
      {\@glo@counterprefix}%
%    \end{macrocode}
% Write to the glossary file using \app{makeindex} syntax.
%    \begin{macrocode}
    \glossary[\csname glo@#1@type\endcsname]{%
    \string\glossaryentry{\csname glo@#1@index\endcsname
      \@gls@encapchar\@glo@numfmt}{\@glslocref}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@getcounterprefix}
% Get the prefix that needs to be prepended to counter in order to
% get the hyper counter. (For example, with the standard
% \cls{article} class and \sty{hyperref}, \ics{theequation} needs to
% be prefixed with \meta{section num}|.| to get the equivalent
% \ics{theHequation}.) NB this assumes that the prefix ends with a
% dot, which is the standard. (Otherwise it makes the xindy location
% classes more complicated.)
%    \begin{macrocode}
\newcommand*\@gls@getcounterprefix[2]{%
  \edef\@gls@thisloc{#1}\edef\@gls@thisHloc{#2}%
  \ifx\@gls@thisloc\@gls@thisHloc
    \def\@glo@counterprefix{}%
  \else
    \def\@gls@get@counterprefix##1.#1##2\end@getprefix{%
      \def\@glo@tmp{##2}%
      \ifx\@glo@tmp\@empty
        \def\@glo@counterprefix{}%
      \else
        \def\@glo@counterprefix{##1}%
      \fi
    }%
    \@gls@get@counterprefix#2.#1\end@getprefix
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Glossary Entry Cross-References}
%\begin{macro}{\@do@seeglossary}
%\changes{1.17}{2008 December 26}{new}
% Write the glossary entry with a cross reference.
% The first argument is the entry's label, the second must be in
% the form \oarg{tag}\marg{list}, where \meta{tag} is a tag
% such as ``see'' and \meta{list} is a list of labels.
%\changes{3.0}{2011/04/02}{Sanitize and escape cross-referencing
%information}
%    \begin{macrocode}
\newcommand{\@do@seeglossary}[2]{%
\def\@gls@xref{#2}%
\@onelevel@sanitize\@gls@xref
\@gls@checkmkidxchars\@gls@xref
\ifglsxindy
  \glossary[\csname glo@#1@type\endcsname]{%
    (indexentry
      :tkey (\csname glo@#1@index\endcsname)
      :xref (\string"\@gls@xref\string")
      :attr \string"see\string"
    )
  }%
\else
  \glossary[\csname glo@#1@type\endcsname]{%
  \string\glossaryentry{\csname glo@#1@index\endcsname
  \@gls@encapchar glsseeformat\@gls@xref}{Z}}%
\fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@fixbraces}
% If no optional argument is specified, list needs to be enclosed
% in a set of braces.
%    \begin{macrocode}
\def\@gls@fixbraces#1#2#3\@nil{%
  \ifx#2[\relax
    \def#1{#2#3}%
  \else
    \def#1{{#2#3}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssee}
%\cs{glssee}\marg{label}\marg{cross-ref list}
%\changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\newcommand*{\glssee}[3][\seename]{%
  \@do@seeglossary{#2}{[#1]{#3}}}
\newcommand*{\@glssee}[3][\seename]{%
  \glssee[#1]{#3}{#2}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsseeformat}
%\changes{1.17}{2008 December 26}{new}
% The first argument specifies what tag to use (e.g.\ ``see''),
% the second argument is a comma-separated list of labels.
% The final argument (the location) is ignored.
%    \begin{macrocode}
\newcommand*{\glsseeformat}[3][\seename]{\emph{#1} \glsseelist{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsseelist}
%\cs{glsseelist}\marg{list} formats list of entry labels.
%    \begin{macrocode}
\newcommand*{\glsseelist}[1]{%
%    \end{macrocode}
% If there is only one item in the list, set the last separator
% to do nothing.
%    \begin{macrocode}
  \let\@gls@dolast\relax
%    \end{macrocode}
% Don't display separator on the first iteration of the loop
%    \begin{macrocode}
  \let\@gls@donext\relax
%    \end{macrocode}
% Iterate through the labels
%    \begin{macrocode}
  \@for\@gls@thislabel:=#1\do{%
%    \end{macrocode}
% Check if on last iteration of loop
%    \begin{macrocode}
    \ifx\@xfor@nextelement\@nnil
      \@gls@dolast
    \else
      \@gls@donext
    \fi
%    \end{macrocode}
% display the entry for this label
%    \begin{macrocode}
    \glsseeitem{\@gls@thislabel}%
%    \end{macrocode}
% Update separators
%    \begin{macrocode}
    \let\@gls@dolast\glsseelastsep
    \let\@gls@donext\glsseesep
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsseelastsep}
% Separator to use between penultimate and ultimate entries in a
% cross-referencing list.
%    \begin{macrocode}
\newcommand*{\glsseelastsep}{\space\andname\space}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsseesep}
% Separator to use between entires in a cross-referencing list.
%    \begin{macrocode}
\newcommand*{\glsseesep}{, }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsseeitem}
%\cs{glsseeitem}\marg{label} formats individual entry in a 
% cross-referencing list.
%\changes{3.0}{2011/04/02}{hyperlink uses \cs{glsseeitemformat} instead
%of \cs{glsentryname}}
%    \begin{macrocode}
\newcommand*{\glsseeitem}[1]{\glshyperlink[\glsseeitemformat{#1}]{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsseeitemformat}
%\changes{3.0}{2011/04/02}{new}
% As from v3.0, default is to use \ics{glsentrytext} instead of
% \ics{glsentryname}. (To avoid problems with the \gloskey{name} key being
% sanitized.)
%    \begin{macrocode}
\newcommand*{\glsseeitemformat}[1]{\glsentrytext{#1}}
%    \end{macrocode}
%\end{macro}
%
% \subsection{Displaying the glossary}\label{sec:code:printglos}
% An individual glossary is displayed in the text using
% \cs{printglossary}\oarg{key-val list}. If the 
% \gloskey[printglossary]{type} key is omitted, the default glossary is displayed.
% The optional argument can be used to specify an alternative
% glossary, and can also be used to set the style, title and
% entry in the table of contents. Available keys are defined below.
%
%\begin{macro}{\gls@save@numberlist}
%\changes{3.02}{2012/05/21}{new}
% Provide command to store number list.
%    \begin{macrocode}
\newcommand*{\gls@save@numberlist}[1]{%
  \ifglssavenumberlist
    \toks@{#1}%
    \edef\@do@writeaux@info{%
        \noexpand\csgdef{glo@\glscurrententrylabel @numberlist}{\the\toks@}%
    }%
    \@onelevel@sanitize\@do@writeaux@info
    \protected@write\@auxout{}{\@do@writeaux@info}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\warn@noprintglossary}
% Warn the user if they have forgotten \ics{printglossaries}
% or \ics{printglossary}. (Will be suppressed if there is at
% least one occurance of \ics{printglossary}. There is no check
% to ensure that there is a \ics{printglossary} for each defined
% glossary.)
%    \begin{macrocode}
\def\warn@noprintglossary{%
  \GlossariesWarningNoLine{No \string\printglossary\space 
    or \string\printglossaries\space
    found.^^JThis document will not have a glossary}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\printglossary}
%\changes{1.17}{2008 December 26}{added print language to aux file}
%\changes{1.15}{2008 August 15}{changed the way the TOC title is set}
%\changes{1.17}{2008 December 26}{added check to determine if 'printglossary is already
% defined}
% The TOC title needs to be processed in a different manner
% to the main title in case the \sty{translator} and \sty{hyperref} packages
% are both being used.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{printglossary}{}%
{%
%    \end{macrocode}
% If \cs{printglossary} is already defined, issue a warning
% and undefine it.
%    \begin{macrocode}
  \GlossariesWarning{Overriding \string\printglossary}%
  \undef\printglossary
}
%    \end{macrocode}
% \cs{printglossary} has an optional argument. The default
% value is to set the glossary type to the main glossary.
%    \begin{macrocode}
\newcommand*{\printglossary}[1][type=\glsdefaulttype]{%
%    \end{macrocode}
% If \app{xindy} is being used, need to find the root language
% for \app{makeglossaries} to pass to \app{xindy}.
%    \begin{macrocode}
  \ifglsxindy\findrootlanguage\fi
%    \end{macrocode}
% Set up defaults.
%    \begin{macrocode}
  \def\@glo@type{\glsdefaulttype}%
  \def\glossarytitle{\csname @glotype@\@glo@type @title\endcsname}%
%    \end{macrocode}
%\changes{3.03}{2012/09/21}{allow title to override default toctitle}
%    \begin{macrocode}
  \def\glossarytoctitle{\glossarytitle}%
  \let\org@glossarytitle\glossarytitle
  \def\@glossarystyle{}%
  \def\gls@dotoctitle{\glssettoctitle{\@glo@type}}%
%    \end{macrocode}
% Store current value of \ics{glossaryentrynumbers}. (This may
% be changed via the optional argument)
%    \begin{macrocode}
  \let\@org@glossaryentrynumbers\glossaryentrynumbers
%    \end{macrocode}
% Localise the effects of the optional argument
%    \begin{macrocode}
  \bgroup
%    \end{macrocode}
% Determine settings specified in the optional argument.
%    \begin{macrocode}
    \setkeys{printgloss}{#1}%
%    \end{macrocode}
% If title has been set, but toctitle hasn't, make toctitle the same
% as given title (rather than the title used when the glossary was
% defined)
%\changes{3.0}{2011/04/02}{make toctitle default to title}
%    \begin{macrocode}
  \ifx\glossarytitle\org@glossarytitle
  \else
    \expandafter\let\csname @glotype@\@glo@type @title\endcsname
                    \glossarytitle
  \fi
%    \end{macrocode}
% Allow a high-level user command to indicate the current glossary
%\changes{3.0}{2011/04/02}{added \cs{currentglossary}}
%    \begin{macrocode}
    \let\currentglossary\@glo@type
%    \end{macrocode}
%Enable individual number lists to be suppressed.
%    \begin{macrocode}
    \let\org@glossaryentrynumbers\glossaryentrynumbers
    \let\glsnonextpages\@glsnonextpages
%    \end{macrocode}
% Enable individual number list to be activated:
%\changes{3.0}{2011/04/02}{added \cs{glsnextpages}}
%    \begin{macrocode}
    \let\glsnextpages\@glsnextpages
%    \end{macrocode}
% Enable suppression of description terminators.
%    \begin{macrocode}
    \let\nopostdesc\@nopostdesc
%    \end{macrocode}
% Set up the entry for the TOC
%    \begin{macrocode}
    \gls@dotoctitle
%    \end{macrocode}
% Set the glossary style
%    \begin{macrocode}
    \@glossarystyle
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{add a way to fetch current entry label}
% added a way to fetch the current entry label:
%    \begin{macrocode}
    \let\gls@org@glossaryentryfield\glossaryentryfield
    \let\gls@org@glossarysubentryfield\glossarysubentryfield
    \renewcommand{\glossaryentryfield}[1]{%
      \gdef\glscurrententrylabel{##1}%
      \gls@org@glossaryentryfield{##1}%
    }%
    \renewcommand{\glossarysubentryfield}[2]{%
      \gdef\glscurrententrylabel{##2}%
      \gls@org@glossarysubentryfield{##1}{##2}%
    }%
%    \end{macrocode}
% Some macros may end up being expanded into internals in the
% glossary, so need to make @ a letter.
%    \begin{macrocode}
    \makeatletter
%    \end{macrocode}
% Input the glossary file, if it exists.
%    \begin{macrocode}
    \@input@{\jobname.\csname @glotype@\@glo@type @in\endcsname}%
%    \end{macrocode}
% If the glossary file doesn't exist, do \cs{null}. (This ensures
% that the page is shipped out and all write commands are done.)
% This might produce an empty page, but at this point the document
% isn't complete, so it shouldn't matter.
%    \begin{macrocode}
  \IfFileExists{\jobname.\csname @glotype@\@glo@type @in\endcsname}%
  {}%
  {\null}%
%    \end{macrocode}
% If \app{xindy} is being used, need to write the language
% dependent information to the \filetype{.aux} file for
% \app{makeglossaries}.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%\changes{3.04}{2012-11-18}{Moved aux write to end of document to
%prevent unwanted whatsit occurring here.}
%    \begin{macrocode}
    \ifglsxindy
      \ifcsundef{@xdy@\@glo@type @language}%
      {%
        \edef\@do@auxoutstuff{%
          \noexpand\AtEndDocument{%
            \noexpand\immediate\noexpand\write\@auxout{%
              \string\@xdylanguage{\@glo@type}{\@xdy@main@language}}%
          }%
        }%
      }%
      {%
        \edef\@do@auxoutstuff{%
          \noexpand\AtEndDocument{%
            \noexpand\immediate\noexpand\write\@auxout{%
              \string\@xdylanguage{\@glo@type}{\csname @xdy@\@glo@type 
                @language\endcsname}}%
          }%
        }%
      }%
      \@do@auxoutstuff
      \edef\@do@auxoutstuff{%
        \noexpand\AtEndDocument{%
           \noexpand\immediate\noexpand\write\@auxout{%
            \string\@gls@codepage{\@glo@type}{\gls@codepage}}%
        }%
      }%
      \@do@auxoutstuff
    \fi
  \egroup
%    \end{macrocode}
% Reset \ics{glossaryentrynumbers}
%    \begin{macrocode}
  \global\let\glossaryentrynumbers\@org@glossaryentrynumbers
%    \end{macrocode}
% Suppress warning about no \ics{printglossary}
%\changes{2.02}{2007 July 13}{suppressed warning globally rather than locally}
%    \begin{macrocode}
  \global\let\warn@noprintglossary\relax
}
%    \end{macrocode}
%\end{macro}
%
% The \cs{printglossaries} command will do \cs{printglossary}
% for each glossary type that has been defined. It is better
% to use \cs{printglossaries} rather than individual
% \cs{printglossary} commands to ensure that you don't forget
% any new glossaries you may have created. It also makes it easier to
% chop and change the value of the \pkgopt{acronym} package option.
% However, if you want to list the glossaries in a different order,
% or if you want to set the title or table of contents entry, or
% if you want to use different glossary styles for each glossary, you
% will need to use \cs{printglossary} explicitly for each
% glossary type.
%\begin{macro}{\printglossaries}
%    \begin{macrocode}
\newcommand*{\printglossaries}{%
  \forallglossaries{\@@glo@type}{\printglossary[type=\@@glo@type]}%
}
%    \end{macrocode}
%\end{macro}
% The keys that can be used in the optional argument to
% \ics{printglossary} are as follows:
% The \gloskey[printglossary]{type} key sets the glossary type.
%    \begin{macrocode}
\define@key{printgloss}{type}{\def\@glo@type{#1}}
%    \end{macrocode}
% The \gloskey[printglossary]{title} key sets the title used in the glossary section
% header. This overrides the title used in \ics{newglossary}.
%\changes{3.03}{2012/09/21}{allow title to set toctitle}
%    \begin{macrocode}
\define@key{printgloss}{title}{%
 \def\glossarytitle{#1}%
 \let\gls@dotoctitle\relax
}
%    \end{macrocode}
% The \gloskey[printglossary]{toctitle} sets the text used for the relevant entry 
% in the table of contents.
%    \begin{macrocode}
\define@key{printgloss}{toctitle}{%
 \def\glossarytoctitle{#1}%
 \let\gls@dotoctitle\relax
}
%    \end{macrocode}
% The \gloskey[printglossary]{style} key sets the glossary style (but only for
% the given glossary).
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\define@key{printgloss}{style}{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}%
    {Glossary style `#1' undefined}{}%
  }%
  {%
    \def\@glossarystyle{\csname @glsstyle@#1\endcsname}%
  }%
}
%    \end{macrocode}
% \changes{1.14}{2008 June 17}{added numberedsection key to 'printglossary}
% The \gloskey[printglossary]{numberedsection} key determines if this
% glossary should be in a numbered section.
%    \begin{macrocode}
\define@choicekey{printgloss}{numberedsection}[\val\nr]{%
false,nolabel,autolabel}[nolabel]{%
\ifcase\nr\relax
  \renewcommand*{\@@glossarysecstar}{*}%
  \renewcommand*{\@@glossaryseclabel}{}%
\or
  \renewcommand*{\@@glossarysecstar}{}%
  \renewcommand*{\@@glossaryseclabel}{}%
\or
  \renewcommand*{\@@glossarysecstar}{}%
  \renewcommand*{\@@glossaryseclabel}{\label{\glsautoprefix\@glo@type}}%
\fi}
%    \end{macrocode}
% \changes{1.14}{2008 June 17}{added nonumberlist key to 'printglossary}
% The \gloskey[printglossary]{nonumberlist} key determines if this
% glossary should have a number list.
%    \begin{macrocode}
\define@boolkey{printgloss}[gls]{nonumberlist}[true]{%
\ifglsnonumberlist
   \def\glossaryentrynumbers##1{}%
\else
   \def\glossaryentrynumbers##1{##1}%
\fi}
%    \end{macrocode}
%
%\begin{macro}{\@glsnonextpages}
%\changes{1.17}{2008 December 26}{new}%
% Suppresses the next number list only. Global assignments required
% as it may not occur in the same level of grouping as the
% next numberlist. (For example, if \cs{glsnonextpages} is place
% in the entry's description and 3 column tabular style glossary
% is used.) \cs{org@glossaryentrynumbers} needs to be set at
% the start of each glossary, in the event that
% \ics{glossaryentrynumber} is redefined.
%    \begin{macrocode}
\newcommand*{\@glsnonextpages}{%
  \gdef\glossaryentrynumbers##1{%
     \glsresetentrylist
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsnextpages}
%\changes{3.0}{2011/04/02}{new}%
% Activate the next number list only. Global assignments required
% as it may not occur in the same level of grouping as the
% next numberlist. (For example, if \cs{glsnextpages} is place
% in the entry's description and 3 column tabular style glossary
% is used.) \cs{org@glossaryentrynumbers} needs to be set at
% the start of each glossary, in the event that
% \ics{glossaryentrynumber} is redefined.
%    \begin{macrocode}
\newcommand*{\@glsnextpages}{%
  \gdef\glossaryentrynumbers##1{%
     ##1\glsresetentrylist}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsresetentrylist}
% Resets \cs{glossaryentrynumbers}
%    \begin{macrocode}
\newcommand*{\glsresetentrylist}{%
  \global\let\glossaryentrynumbers\org@glossaryentrynumbers}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\glsnonextpages}
% Outside of \cs{printglossary} this does nothing.
%    \begin{macrocode}
\newcommand*{\glsnonextpages}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnextpages}
% Outside of \cs{printglossary} this does nothing.
%    \begin{macrocode}
\newcommand*{\glsnextpages}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{counter}{glossaryentry}
%\changes{3.0}{2011/04/02}{new}
% If the \pkgopt{entrycounter} package option has been used, define
% a counter to number each level~0 entry.
%    \begin{macrocode}
\ifglsentrycounter
  \ifx\@gls@counterwithin\@empty
    \newcounter{glossaryentry}
  \else
    \newcounter{glossaryentry}[\@gls@counterwithin]
  \fi
  \def\theHglossaryentry{\currentglossary.\theglossaryentry}
\fi
%    \end{macrocode}
%\end{counter}
%
%\begin{counter}{glossarysubentry}
%\changes{3.0}{2011/04/02}{new}
% If the \pkgopt{subentrycounter} package option has been used, define
% a counter to number each level~1 entry.
%    \begin{macrocode}
\ifglssubentrycounter
  \ifglsentrycounter
    \newcounter{glossarysubentry}[glossaryentry]
  \else
    \newcounter{glossarysubentry}
  \fi
  \def\theHglossarysubentry{\currentglssubentry.\theglossarysubentry}
\fi
%    \end{macrocode}
%\end{counter}
%
%\begin{macro}{\glsresetsubentrycounter}
%\changes{3.0}{2011/04/02}{new}
% Resets the \ctr{glossarysubentry} counter.
%    \begin{macrocode}
\ifglssubentrycounter
  \newcommand*{\glsresetsubentrycounter}{%
    \setcounter{glossarysubentry}{0}%
  }
\else
  \newcommand*{\glsresetsubentrycounter}{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsresetsubentrycounter}
%\changes{3.02}{2012/05/21}{new}
% Resets the \ctr{glossarentry} counter.
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsresetentrycounter}{%
    \setcounter{glossaryentry}{0}%
  }
\else
  \newcommand*{\glsresetentrycounter}{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsstepentry}
%\changes{3.0}{2011/04/02}{new}
% Advance the \ctr{glossaryentry} counter if in use. The argument is
% the label associated with the entry.
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsstepentry}[1]{%
    \refstepcounter{glossaryentry}%
    \label{glsentry-#1}%
  }
\else
  \newcommand*{\glsstepentry}[1]{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsstepsubentry}
%\changes{3.0}{2011/04/02}{new}
% Advance the \ctr{glossarysubentry} counter if in use. The argument is
% the label associated with the subentry.
%    \begin{macrocode}
\ifglssubentrycounter
  \newcommand*{\glsstepsubentry}[1]{%
    \def\currentglssubentry{#1}%
    \refstepcounter{glossarysubentry}%
    \label{glsentry-#1}%
  }
\else
  \newcommand*{\glsstepsubentry}[1]{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsrefentry}
%\changes{3.0}{2011/04/02}{new}
% Reference the entry or sub-entry counter if in use, otherwise just do
% \ics{gls}.
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsrefentry}[1]{\ref{glsentry-#1}}
\else
  \ifglssubentrycounter
    \newcommand*{\glsrefentry}[1]{\ref{glsentry-#1}}
  \else
    \newcommand*{\glsrefentry}[1]{\gls{#1}}
  \fi
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentrycounterlabel}
%\changes{3.0}{2011/04/02}{new}
% Defines how to display the \ctr{glossaryentry} counter.
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsentrycounterlabel}{\theglossaryentry.\space}
\else
  \newcommand*{\glsentrycounterlabel}{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssubentrycounterlabel}
%\changes{3.0}{2011/04/02}{new}
% Defines how to display the \ctr{glossarysubentry} counter.
%    \begin{macrocode}
\ifglssubentrycounter
  \newcommand*{\glssubentrycounterlabel}{\theglossarysubentry)\space}
\else
  \newcommand*{\glssubentrycounterlabel}{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryitem}
% Step and display \ctr{glossaryentry} counter, if appropriate.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsentryitem}[1]{%
    \glsstepentry{#1}\glsentrycounterlabel
  }
\else
  \newcommand*{\glsentryitem}[1]{\glsresetsubentrycounter}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssubentryitem}
% Step and display \ctr{glossarysubentry} counter, if appropriate.
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\ifglssubentrycounter
  \newcommand*{\glssubentryitem}[1]{%
    \glsstepsubentry{#1}\glssubentrycounterlabel
  }
\else
  \newcommand*{\glssubentryitem}[1]{}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{environment}{theglossary}
% If the \env{theglossary} environment has 
% already been defined, a warning will be issued. 
% This environment should be redefined by glossary styles.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{theglossary}%
{%
  \newenvironment{theglossary}{}{}%
}%
{%
  \GlossariesWarning{overriding `theglossary' environment}%
  \renewenvironment{theglossary}{}{}%
}
%    \end{macrocode}
%\end{environment}
%
% The glossary header is given by \cs{glossaryheader}. 
% This forms part of the glossary style, and
% must indicate what should appear immediately after the start of the
% \env{theglossary} environment. (For example, if the glossary
% uses a tabular-like environment, it may be used to set the
% header row.) Note that if you don't want a header row, the glossary
% style must redefine \cs{glossaryheader} to do nothing.
%\begin{macro}{\glossaryheader}
%    \begin{macrocode}
\newcommand*{\glossaryheader}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glstarget}
%\changes{1.18}{2009 January 14}{new}
%\cs{glstarget}\marg{label}\marg{name}\\[10pt]
% Provide user interface to \cs{@glstarget} to make it easier to
% modify the glossary style in the document.
%    \begin{macrocode}
\newcommand*{\glstarget}[2]{\@glstarget{\glolinkprefix#1}{#2}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossaryentryfield}
% \cs{glossaryentryfield}\marg{label}\marg{name}\marg{description}\marg{symbol}\marg{page-list}\\[10pt]
% This command governs how each entry row should be formatted 
% in the glossary. Glossary styles need to redefine this command.
% Most of the predefined styles ignore \meta{symbol}.
%    \begin{macrocode}
\newcommand*{\glossaryentryfield}[5]{%
\noindent\textbf{\glstarget{#1}{#2}} #4 #3. #5\par}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glossaryentryfield}
% \cs{glossarysubentryfield}\marg{level}\marg{label}\marg{name}\marg{description}\marg{symbol}\marg{page-list}\\[10pt]
% This command governs how each subentry should be formatted 
% in the glossary. Glossary styles need to redefine this command.
% Most of the predefined styles ignore \meta{symbol}. The first
% argument is a number indicating the level. (The level should
% be greater than or equal to 1.)
%    \begin{macrocode}
\newcommand*{\glossarysubentryfield}[6]{%
\glstarget{#2}{\strut}#4. #6\par}
%    \end{macrocode}
%\end{macro}
%
% Within each glossary, the entries form distinct groups
% which are determined by the first character of the \gloskey{sort} 
% key. When using \app{makeindex}, there will be a maximum of 28 groups: symbols, numbers,
% and the 26 alphabetical groups A, \ldots, Z\@. If you use
% \app{xindy} the groups will depend on whatever alphabet
% is used. This is determined by the language or custom
% alphabets can be created in the \app{xindy} style file.
% The command \cs{glsgroupskip} 
% specifies what to do between glossary groups. Glossary styles
% must redefine this command. (Note that \cs{glsgroupskip}
% only occurs between groups, not at the start or end of the
% glossary.)
%\begin{macro}{\glsgroupskip}
%    \begin{macrocode}
\newcommand*{\glsgroupskip}{}
%    \end{macrocode}
%\end{macro}
%
% Each of the 28 glossary groups described above is preceded by a 
% group heading.
% This is formatted by the command \cs{glsgroupheading}
% which takes one argument which is the \emph{label} assigned to that
% group (not the title). The corresponding labels are: \texttt{glssymbols},
% \texttt{glsnumbers}, \texttt{A}, \ldots, \texttt{Z}. 
% Glossary styles must redefined this command. (In between groups,
% \cs{glsgroupheading} comes immediately after \cs{glsgroupskip}.)
%\begin{macro}{\glsgroupheading}
%    \begin{macrocode}
\newcommand*{\glsgroupheading}[1]{}
%    \end{macrocode}
%\end{macro}
% It is possible to ``trick'' \app{makeindex} into
% treating entries as though they belong to the same group, 
% even if the terms don't start with the same letter, by
% modifying the \gloskey{sort} key. For example, all entries 
% belonging to one
% group could be defined so that the \gloskey{sort} key starts with an
% "a", while entries belonging to another group could be defined
% so that the \gloskey{sort} key starts with a "b", and so on. If
% you want each group to have a heading, you would then need to
% modify the translation control sequences \cs{glsgetgrouptitle}
% and \cs{glsgetgrouplabel} so that the label is translated
% into the required title (and vice-versa).
%\\[10pt]
%\cs{glsgetgrouptitle}\marg{label}\\[10pt]
% This command produces the title for the glossary group
% whose label is given by \meta{label}. By default, the group
% labelled \texttt{glssymbols} produces 
% \ics{glssymbolsgroupname}, the group labelled 
% \texttt{glsnumbers} produces \ics{glsnumbersgroupname}
% and all the other groups simply produce their label.
% As mentioned above, the group labels are: \texttt{glssymbols}, \texttt{glsnumbers},
% \texttt{A}, \ldots, \texttt{Z}\@. If you want to redefine
% the group titles, you will need to redefine this command.
%\begin{macro}{\glsgetgrouptitle}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand*{\glsgetgrouptitle}[1]{%
  \ifcsundef{#1groupname}{#1}{\csname #1groupname\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
%\cs{glsgetgrouplabel}\marg{title}\\[10pt]
%This command does the reverse to the previous command. The
% argument is the group title, and it produces the group label.
% Note that if you redefine \cs{glsgetgrouptitle}, you
% will also need to redefine \cs{glsgetgrouplabel}.
%\begin{macro}{\glsgetgrouplabel}
%    \begin{macrocode}
\newcommand*{\glsgetgrouplabel}[1]{%
\ifthenelse{\equals{#1}{\glssymbolsgroupname}}{glssymbols}{%
\ifthenelse{\equals{#1}{\glsnumbersgroupname}}{glsnumbers}{#1}}}
%    \end{macrocode}
%\end{macro}
%
% The command \cs{setentrycounter} sets the entry's 
% associated counter (required by 
% \cs{glshypernumber} etc.) \ics{glslink} and
% \ics{glsadd} encode the
% \ics{glossary} argument so that the relevant counter is
% set prior to the formatting command.
%\begin{macro}{\setentrycounter}
%\changes{3.0}{2011/04/02}{added optional argument}
%    \begin{macrocode}
\newcommand*{\setentrycounter}[2][]{%
  \def\@glo@counterprefix{#1}%
  \ifx\@glo@counterprefix\@empty
    \def\@glo@counterprefix{.}%
  \else
    \def\@glo@counterprefix{.#1.}%
  \fi
  \def\glsentrycounter{#2}%
}
%    \end{macrocode}
%\end{macro}
%
% The current glossary style can be set using
% \cs{glossarystyle}\marg{style}.
%\begin{macro}{\glossarystyle}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand*{\glossarystyle}[1]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}{Glossary style `#1' undefined}{}%
  }%
  {%
    \csname @glsstyle@#1\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newglossarystyle}
% New glossary styles can be defined using:\\[10pt]
% \cs{newglossarystyle}\marg{name}\marg{definition}\\[10pt]
% The \meta{definition} argument should redefine 
% \env{theglossary}, \ics{glossaryheader}, 
% \ics{glsgroupheading}, \ics{glossaryentryfield} and
% \ics{glsgroupskip} (see \autoref{sec:code:styles} for the
% definitions of predefined styles). Glossary styles should not 
% redefine \ics{glossarypreamble} and 
% \ics{glossarypostamble}, as
% the user should be able to switch between styles without affecting
% the pre- and postambles.
%\changes{1.17}{2008 December 26}{made 'newglossarystyle long}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand{\newglossarystyle}[2]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \expandafter\def\csname @glsstyle@#1\endcsname{#2}%
  }%
  {%
    \PackageError{glossaries}{Glossary style `#1' is already defined}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\renewglossarystyle}
%\changes{3.02}{2012/05/21}{new}
%Code for this macro supplied by Marco Daniel.
%    \begin{macrocode}
\newcommand{\renewglossarystyle}[2]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}{Glossary style `#1' isn't already defined}{}%
  }%
  {%
    \csdef{@glsstyle@#1}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Glossary entries are encoded so that the second argument
% to \ics{glossaryentryfield} is always specified as
% \cs{glsnamefont}\marg{name}. This allows the
% user to change the font used to display the name term
% without having to redefine \ics{glossaryentryfield}.
% The default uses the surrounding font, so in the list type
% styles (which place the name in the optional argument to
% \ics{item}) the name will appear in bold.
%\begin{macro}{\glsnamefont}
%    \begin{macrocode}
\newcommand*{\glsnamefont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% Each glossary entry has an associated number list (usually page
% numbers) that indicate where in the document the entry has been
% used. The format for these number lists can be changed using the
% \gloskey[glslink]{format}\igloskey[glsadd]{format} key in commands like \ics{glslink}.
% The default format is given by \cs{glshypernumber}. This takes
% a single argument which may be a single number, a number range
% or a number list. The number ranges are delimited with 
% \ics{delimR}, the number lists are delimited with 
% \ics{delimN}.
%
% If the document doesn't have hyperlinks, the numbers can be
% displayed just as they are, but if the document supports 
% hyperlinks, the numbers should link to the relevant location.
% This means extracting the individual numbers from the list or
% ranges. The \isty{hyperref} package does this with the
% \ics{hyperpage} command, but this is encoded for comma and
% dash delimiters and only for the page counter, but this code needs
% to be more general. So I have adapted the code used in the
% \isty{hyperref} package.
%\begin{macro}{\glshypernumber}
%\changes{1.17}{2008 December 26}{modified to allow material 
% to be attached to location}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\ifcsundef{hyperlink}%
{%
  \def\glshypernumber#1{#1}%
}%
{%
  \def\glshypernumber#1{\@glshypernumber#1\nohyperpage{}\@nil}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glshypernumber}
% This code was provided by Heiko~Oberdiek to allow material
% to be attached to the location.
%\changes{1.17}{2008 December 26}{new}
%    \begin{macrocode}
\def\@glshypernumber#1\nohyperpage#2#3\@nil{%
  \ifx\\#1\\%
  \else
    \@delimR#1\delimR\delimR\\%
  \fi
  \ifx\\#2\\%
  \else
    #2%
  \fi
  \ifx\\#3\\%
  \else
    \@glshypernumber#3\@nil
  \fi
}
%    \end{macrocode}
%\end{macro}
% \cs{@delimR} displays a range of numbers for the counter 
% whose name is given by 
% \cs{@gls@counter} (which must be set prior to using
% \cs{glshypernumber}).
%\begin{macro}{\@delimR}
%    \begin{macrocode}
\def\@delimR#1\delimR #2\delimR #3\\{%
\ifx\\#2\\%
  \@delimN{#1}%
\else
  \@gls@numberlink{#1}\delimR\@gls@numberlink{#2}%
\fi}
%    \end{macrocode}
%\end{macro}
% \cs{@delimN} displays a list of individual numbers, 
% instead of a range:
%\begin{macro}{\@delimN}
%    \begin{macrocode}
\def\@delimN#1{\@@delimN#1\delimN \delimN\\}
\def\@@delimN#1\delimN #2\delimN#3\\{%
\ifx\\#3\\%
  \@gls@numberlink{#1}%
\else
  \@gls@numberlink{#1}\delimN\@gls@numberlink{#2}%
\fi
}
%    \end{macrocode}
%\end{macro}
% The following code is modified from hyperref's 
% \cs{HyInd@pagelink} where
% the name of the counter being used is given by 
% \cs{@gls@counter}.
%    \begin{macrocode}
\def\@gls@numberlink#1{%
\begingroup
 \toks@={}%
 \@gls@removespaces#1 \@nil
\endgroup}
%    \end{macrocode}
%    \begin{macrocode}
\def\@gls@removespaces#1 #2\@nil{%
 \toks@=\expandafter{\the\toks@#1}%
 \ifx\\#2\\%
   \edef\x{\the\toks@}%
   \ifx\x\empty
   \else
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added prefix to hyperlink}
%    \begin{macrocode}
     \hyperlink{\glsentrycounter\@glo@counterprefix\the\toks@}%
               {\the\toks@}%
   \fi
 \else
   \@gls@ReturnAfterFi{%
     \@gls@removespaces#2\@nil
   }%
 \fi
}
\long\def\@gls@ReturnAfterFi#1\fi{\fi#1}
%    \end{macrocode}
%
% The following commands will switch to the
% appropriate font, and create a hyperlink, if hyperlinks are
% supported. If hyperlinks are not supported, they will just
% display their argument in the appropriate font.
%\begin{macro}{\hyperrm}
%    \begin{macrocode}
\newcommand*{\hyperrm}[1]{\textrm{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersf}
%    \begin{macrocode}
\newcommand*{\hypersf}[1]{\textsf{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypertt}
%    \begin{macrocode}
\newcommand*{\hypertt}[1]{\texttt{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperbf}
%    \begin{macrocode}
\newcommand*{\hyperbf}[1]{\textbf{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypermd}
%    \begin{macrocode}
\newcommand*{\hypermd}[1]{\textmd{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperit}
%    \begin{macrocode}
\newcommand*{\hyperit}[1]{\textit{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersl}
%    \begin{macrocode}
\newcommand*{\hypersl}[1]{\textsl{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperup}
%    \begin{macrocode}
\newcommand*{\hyperup}[1]{\textup{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hypersc}
%    \begin{macrocode}
\newcommand*{\hypersc}[1]{\textsc{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\hyperemph}
%    \begin{macrocode}
\newcommand*{\hyperemph}[1]{\emph{\glshypernumber{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Acronyms}\label{sec:acronym}
%If the \pkgopt{acronym} package option is used, a 
% new glossary called "acronym" is created
%    \begin{macrocode}
\ifglsacronym
  \newglossary[alg]{acronym}{acr}{acn}{\acronymname}
%    \end{macrocode}
%and \ics{acronymtype} is set to the name of this new glossary.
%    \begin{macrocode}
  \renewcommand*{\acronymtype}{acronym}
\fi
%    \end{macrocode}
%\begin{macro}{\oldacronym}
%\cs{oldacronym}\oarg{label}\marg{abbrv}\marg{long}\marg{key-val list}\\[10pt]
% This emulates the way the old \isty{glossary} package defined
% acronyms. It is equivalent to \ics{newacronym}\oarg{key-val
% list}\marg{label}\marg{abbrv}\marg{long} and it additionally
% defines the command \cs{}\meta{label} which is equivalent to
% \cs{gls}\marg{label} (thus \meta{label} must only contain
% alphabetical characters). If \meta{label} is omitted, \meta{abbrv}
% is used. This only emulates the syntax of the old \isty{glossary} 
% package. The way the acronyms appear in the list of acronyms is 
% determined by the definition of \ics{newacronym} and the
% glossary style.
%
% Note that \cs{}\meta{label} can't have an optional
% argument if the \isty{xspace} package is loaded. If 
% \isty{xspace} hasn't been loaded then you can do
% \cs{}\meta{label}\oarg{insert} but you can't do 
% \cs{}\meta{label}\oarg{key-val list}. For example if you define the
% acronym svm, then you can do "\svm['s]" but you can't do
% "\svm[format=textbf]". If the \isty{xspace} package is loaded,
% "\svm['s]" will appear as "svm ['s]" which is unlikely to be
% the desired result. In this case, you will need to use 
% \cs{gls} explicitly, e.g.\ "\gls{svm}['s]". Note that it is
% up to the user to load \isty{xspace} if desired.
%\changes{1.18}{2009 January 14}{new}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%    \begin{macrocode}
\newcommand{\oldacronym}[4][\gls@label]{%
  \def\gls@label{#2}%
  \newacronym[#4]{#1}{#2}{#3}%
  \ifcsundef{xspace}%
  {%
    \expandafter\edef\csname#1\endcsname{%
      \noexpand\@ifstar{\noexpand\Gls{#1}}{\noexpand\gls{#1}}%
    }%
  }%
  {%
    \expandafter\edef\csname#1\endcsname{%
      \noexpand\@ifstar{\noexpand\Gls{#1}\noexpand\xspace}{%
      \noexpand\gls{#1}\noexpand\xspace}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{newacronym}\oarg{key-val list}\marg{label}\marg{abbrev}\marg{long}\\[10pt]
% This is a quick way of defining acronyms, all it does
% is call \ics{newglossaryentry} with the appropriate
% values. It sets the
% glossary type to \ics{acronymtype} which will be
% "acronym" if the package option \pkgopt{acronym} has
% been used, otherwise it will be the default glossary.
% Since \cs{newacronym} merely calls \ics{newglossaryentry},
% the acronym is treated like any other glossary entry.
%
% If you prefer a different format, you
% can redefine \cs{newacronym} as required. The optional 
% argument can be used to override any of the settings.
%
% This is just a stub. It's redefined by commands like
% \cs{SetDefaultAcronymStyle}.
%\begin{macro}{\newacronym}
%    \begin{macrocode}
  \newcommand{\newacronym}[4][]{}
%    \end{macrocode}
%\changes{1.13}{2008 May 10}{Removed restriction on only using
% 'newacronym in the preamble}
%\end{macro}
% Set up some convenient short cuts. These need to be changed if
% \cs{newacronym} is changed (or if the \gloskey{description} key
% is changed).
%
%\begin{macro}{\acrpluralsuffix}
%\changes{1.13}{2008 May 10}{New}
% Plural suffix used by \cs{newacronym}. This just defaults to
% \cs{glspluralsuffix} but is changed to include \cs{textup} 
% if the smallcaps option is used, so that the suffix doesn't appear
% in small caps as it doesn't look right. For example, 
% \textsc{abcs} looks as though the ``s'' is part of the acronym, but
% \textsc{abc}s looks as though the ``s'' is a plural suffix. Since
% the entire text \texttt{abcs} is set in \cs{textsc}, \cs{textup}
% is need to cancel it out.
%    \begin{macrocode}
\newcommand*{\acrpluralsuffix}{\glspluralsuffix}
%    \end{macrocode}
%\end{macro}
%
% The following are defined for compatibility with version 2.07 and
% earlier.
%\begin{macro}{\glsshortkey}
%    \begin{macrocode}
\newcommand*{\glsshortkey}{short}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsshortpluralkey}
%    \begin{macrocode}
\newcommand*{\glsshortpluralkey}{shortplural}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongkey}
%    \begin{macrocode}
\newcommand*{\glslongkey}{long}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongpluralkey}
%    \begin{macrocode}
\newcommand*{\glslongpluralkey}{longplural}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\acrfull}
% Full form of the acronym.
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrfull}{%
  \@ifstar\s@acrfull\ns@acrfull
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@acrfull[2][]{%
  \new@ifnextchar[{\@acrfull{hyper=false,#1}{#2}}%
                  {\@acrfull{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@acrfull[2][]{%
  \new@ifnextchar[{\@acrfull{#1}{#2}}%
                  {\@acrfull{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@acrfull#1#2[#3]{%
  \acrlinkfullformat{\@acrlong}{\@acrshort}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\acrlinkfullformat}
% Format for full links like \ics{acrfull}. Syntax:
% \cs{acrlinkfullformat}\marg{long cs}\marg{short
% cs}\marg{options}\marg{label}\marg{insert}
%    \begin{macrocode}
\newcommand{\acrlinkfullformat}[5]{%
  \acrfullformat{#1{#3}{#4}[#5]}{#2{#3}{#4}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\acrfullformat}
% Default full form is \meta{long} \parg{short}.
%\changes{3.01}{2011/04/12}{removed \cs{acronymfont} as it should
%already be set in the second argument.}
%    \begin{macrocode}
\newcommand{\acrfullformat}[2]{#1\space(#2)}
%    \end{macrocode}
%\end{macro}
%
% Default format for full acronym
%\begin{macro}{\Acrfull}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrfull}{%
  \@ifstar\s@Acrfull\ns@Acrfull
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@Acrfull[2][]{%
  \new@ifnextchar[{\@Acrfull{hyper=false,#1}{#2}}%
                  {\@Acrfull{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@Acrfull[2][]{%
  \new@ifnextchar[{\@Acrfull{#1}{#2}}%
                  {\@Acrfull{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@Acrfull#1#2[#3]{%
  \acrlinkfullformat{\@Acrlong}{\@acrshort}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ACRfull}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRfull}{%
  \@ifstar\s@ACRfull\ns@ACRfull
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@ACRfull[2][]{%
  \new@ifnextchar[{\@ACRfull{hyper=false,#1}{#2}}%
                  {\@ACRfull{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@ACRfull[2][]{%
  \new@ifnextchar[{\@ACRfull{#1}{#2}}%
                  {\@ACRfull{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@ACRfull#1#2[#3]{%
  \acrlinkfullformat{\@ACRlong}{\@ACRshort}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
% Plural:
%\begin{macro}{\acrfullpl}
%\changes{1.13}{2008 May 10}{new}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\acrfullpl}{%
  \@ifstar\s@acrfullpl\ns@acrfullpl
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@acrfullpl[2][]{%
  \new@ifnextchar[{\@acrfullpl{hyper=false,#1}{#2}}%
                  {\@acrfullpl{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@acrfullpl[2][]{%
  \new@ifnextchar[{\@acrfullpl{#1}{#2}}%
                  {\@acrfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@acrfullpl#1#2[#3]{%
  \acrlinkfullformat{\@acrlongpl}{\@acrshortpl}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Acrfullpl}
%\changes{1.13}{2008 May 10}{new}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Acrfullpl}{%
  \@ifstar\s@Acrfullpl\ns@Acrfullpl
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@Acrfullpl[2][]{%
  \new@ifnextchar[{\@Acrfullpl{hyper=false,#1}{#2}}%
                  {\@Acrfullpl{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@Acrfullpl[2][]{%
  \new@ifnextchar[{\@Acrfullpl{#1}{#2}}%
                  {\@Acrfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@Acrfullpl#1#2[#3]{%
  \acrlinkfullformat{\@Acrlongpl}{\@acrshortpl}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ACRfullpl}
%\changes{1.13}{2008 May 10}{new}
%\changes{3.01}{2011/04/12}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\ACRfullpl}{%
  \@ifstar\s@ACRfullpl\ns@ACRfullpl
}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\s@ACRfullpl[2][]{%
  \new@ifnextchar[{\@ACRfullpl{hyper=false,#1}{#2}}%
                  {\@ACRfullpl{hyper=false,#1}{#2}[]}%
}
\newcommand*\ns@ACRfullpl[2][]{%
  \new@ifnextchar[{\@ACRfullpl{#1}{#2}}%
                  {\@ACRfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@ACRfullpl#1#2[#3]{%
  \acrlinkfullformat{\@ACRlongpl}{\@ACRshortpl}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Predefined acronym styles}
%\begin{macro}{\acronymfont}
%This is only used with the additional acronym styles:
%    \begin{macrocode}
\newcommand{\acronymfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\firstacronymfont}
%This is only used with the additional acronym styles:
%\changes{1.14}{2008 June 17}{new}
%    \begin{macrocode}
\newcommand{\firstacronymfont}[1]{\acronymfont{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\acrnameformat}
% The styles that allow an additional description use 
% \cs{acrnameformat}\marg{short}\marg{long} to determine what
% information is displayed in the name.
%    \begin{macrocode}
\newcommand*{\acrnameformat}[2]{\acronymfont{#1}}
%    \end{macrocode}
%\end{macro}
%
% Define some tokens used by \cs{newacronym}:
%\begin{macro}{\glskeylisttok}
%    \begin{macrocode}
\newtoks\glskeylisttok
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslabeltok}
%    \begin{macrocode}
\newtoks\glslabeltok
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsshorttok}
%    \begin{macrocode}
\newtoks\glsshorttok
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongtok}
%    \begin{macrocode}
\newtoks\glslongtok
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\newacronymhook}
% Provide a hook for \cs{newacronym}:
%    \begin{macrocode}
\newcommand*{\newacronymhook}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDefaultAcronymDisplayStyle}
% Sets the default acronym display style for given glossary.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetDefaultAcronymDisplayStyle}[1]{%
  \defglsdisplay[#1]{##1##4}%
  \defglsdisplayfirst[#1]{##1##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DefaultNewAcronymDef}
% Sets up the acronym definition for the default style.
% The information is provided by the tokens \cs{glslabeltok},
% \cs{glsshorttok}, \cs{glslongtok} and \cs{glskeylisttok}.
%    \begin{macrocode}
\newcommand*{\DefaultNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\the\glsshorttok},%
      sort={\the\glsshorttok},%
      text={\the\glsshorttok},%
      first={\acrfullformat{\the\glslongtok}{\the\glsshorttok}},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      firstplural={\acrfullformat{\noexpand\@glo@longpl}%
                                 {\noexpand\@glo@shortpl}},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\the\glslongtok\noexpand\acrpluralsuffix},%
%    \end{macrocode}
% Remaining options specified by the user:
%    \begin{macrocode}
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDefaultAcronymStyle}
%\changes{2.04}{2009 November 10}{new}
% Set up the default acronym style:
%    \begin{macrocode}
\newcommand*{\SetDefaultAcronymStyle}{%
%    \end{macrocode}
% Set the display style:
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetDefaultAcronymDisplayStyle{\@gls@type}%
  }%
%    \end{macrocode}
% Set up the definition of \cs{newacronym}:
%    \begin{macrocode}
  \renewcommand{\newacronym}[4][]{%
%    \end{macrocode}
% If user is just using the main glossary and hasn't identified it
% as a list of acronyms, then update. (This is done to ensure 
% backwards compatibility with versions prior to 2.04).
%    \begin{macrocode}
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetDefaultAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \DefaultNewAcronymDef
  }%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\acrfootnote}
%\changes{3.0}{2011/04/02}{new}
% Used by the footnote acronym styles.
%    \begin{macrocode}
\newcommand*{\acrfootnote}[3]{\acrlinkfootnote{#1}{#2}{#3}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\acrlinkfootnote}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\acrlinkfootnote}[3]{%
  \footnote{\glslink[#1]{#2}{#3}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\acrnolinkfootnote}
%\changes{3.0}{2011/04/02}{new}
%    \begin{macrocode}
\newcommand*{\acrnolinkfootnote}[3]{%
  \footnote{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetDescriptionFootnoteAcronymDisplayStyle}
% Sets the acronym display style for given glossary for the
% description and footnote combination.
%\changes{2.04}{2009 November 10}{new}
%\changes{3.0}{2011/04/02}{expanded options link options}
%    \begin{macrocode}
\newcommand*{\SetDescriptionFootnoteAcronymDisplayStyle}[1]{%
  \defglsdisplayfirst[#1]{%
    \firstacronymfont{##1}##4%
    \expandafter\protect\expandafter\acrfootnote\expandafter
       {\@gls@link@opts}{\@gls@link@label}{##3}%
  }%
  \defglsdisplay[#1]{\acronymfont{##1}##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DescriptionFootnoteNewAcronymDef}
%    \begin{macrocode}
\newcommand*{\DescriptionFootnoteNewAcronymDef}{%
    \edef\@do@newglossaryentry{%
      \noexpand\newglossaryentry{\the\glslabeltok}%
      {%
        type=\acronymtype,%
        name={\noexpand\acronymfont{\the\glsshorttok}},%
        sort={\the\glsshorttok},%
        text={\the\glsshorttok},%
        plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
        short={\the\glsshorttok},%
        shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
        long={\the\glslongtok},%
        longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
        symbol={\the\glslongtok},%
        symbolplural={\the\glslongtok\noexpand\acrpluralsuffix},%
        \the\glskeylisttok
      }%
    }%
    \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDescriptionFootnoteAcronymStyle}
% If a description and footnote are both required, store the long form 
% in the \gloskey{symbol} key. Store the short form in \gloskey{text}
% key. Note that since the long form is stored in the symbol key,
% if you want the long form to appear in the list of acronyms, you
% need to use a glossary style that displays the symbol key.
%    \begin{macrocode}
\newcommand*{\SetDescriptionFootnoteAcronymStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetDescriptionFootnoteAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \DescriptionFootnoteNewAcronymDef
  }%
%    \end{macrocode}
%
% If \pkgopt{footnote} package option is specified, set the first
% use to append the long form (stored in \gloskey{symbol}) as a 
% footnote.
%\changes{1.12}{2008 Mar 8}{Added 'protect before 'footnote
% and 'glslink}
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetDescriptionFootnoteAcronymDisplayStyle{\@gls@type}%
  }%
%    \end{macrocode}
% Redefine \ics{acronymfont} if small caps required. The plural suffix
% is set in an upright font so that it remains in normal lower case,
% otherwise it looks as though it's part of the acronym.
%\changes{1.19}{2009 Mar 2}{changed 'acronymfont to use 'textsmaller instead
%of 'smaller}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand*{\acronymfont}[1]{\textsc{##1}}%
    \renewcommand*{\acrpluralsuffix}{%
      \textup{\glspluralsuffix}}%
  \else
    \ifglsacrsmaller
      \renewcommand*{\acronymfont}[1]{\textsmaller{##1}}%
    \fi
  \fi
%    \end{macrocode}
% Check for package option clash
%    \begin{macrocode}
  \ifglsacrdua
    \PackageError{glossaries}{Option clash: `footnote' and `dua'
    can't both be set}{}%
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetDescriptionDUAAcronymDisplayStyle}
% Sets the acronym display style for given glossary with 
% description and dua combination.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetDescriptionDUAAcronymDisplayStyle}[1]{%
  \defglsdisplay[#1]{##1##4}%
  \defglsdisplayfirst[#1]{##1##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DescriptionDUANewAcronymDef}
%    \begin{macrocode}
\newcommand*{\DescriptionDUANewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\the\glslongtok},%
      sort={\the\glslongtok},
      text={\the\glslongtok},%
      plural={\the\glslongtok\noexpand\acrpluralsuffix},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      symbol={\the\glsshorttok},%
      symbolplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDescriptionDUAAcronymStyle}
% Description, don't use acronym and no footnote. 
% Note that the short form is stored in the \gloskey{symbol} key,
% so if the short form needs to be displayed in the glossary, 
% use a style the displays the symbol.
%    \begin{macrocode}
\newcommand*{\SetDescriptionDUAAcronymStyle}{%
  \ifglsacrsmallcaps
    \PackageError{glossaries}{Option clash: `smallcaps' and `dua'
    can't both be set}{}%
  \else
    \ifglsacrsmaller
      \PackageError{glossaries}{Option clash: `smaller' and `dua'
      can't both be set}{}%
    \fi
  \fi
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetDescriptionDUAAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \DescriptionDUANewAcronymDef
  }%
%    \end{macrocode}
% Set display.
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetDescriptionDUAAcronymDisplayStyle{\@gls@type}%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetDescriptionAcronymDisplayStyle}
% Sets the acronym display style for given glossary using
% the description setting (but not \pkgopt{footnote} or \pkgopt{dua}).
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetDescriptionAcronymDisplayStyle}[1]{%
  \defglsdisplayfirst[#1]{%
    ##1##4 (\firstacronymfont{##3})}%
  \defglsdisplay[#1]{\acronymfont{##1}##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DescriptionNewAcronymDef}
%    \begin{macrocode}
\newcommand*{\DescriptionNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand
        \acrnameformat{\the\glsshorttok}{\the\glslongtok}},%
      sort={\the\glsshorttok},%
      first={\the\glslongtok},%
      firstplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      text={\the\glsshorttok},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      symbol={\noexpand\@glo@text},%
      symbolplural={\noexpand\@glo@plural},%
      \the\glskeylisttok}%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDescriptionAcronymStyle}
% Option \pkgopt{description} is used, but not \pkgopt{dua}
% or \pkgopt{footnote}.
% Store long form in \gloskey{first} key
% and short form in \gloskey{text} and \gloskey{symbol} key.
% The name is stored using \ics{acrnameformat} to allow the
% user to override the way the name is displayed in the
% list of acronyms.
%    \begin{macrocode}
\newcommand*{\SetDescriptionAcronymStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetDescriptionAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \DescriptionNewAcronymDef
  }%
%    \end{macrocode}
% Set display.
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetDescriptionAcronymDisplayStyle{\@gls@type}%
  }%
%    \end{macrocode}
% Redefine \ics{acronymfont} if small caps required. The plural suffix
% is set in an upright font so that it remains in normal lower case,
% otherwise it looks as though it's part of the acronym.
%\changes{1.19}{2009 Mar 2}{changed 'acronymfont to use 'textsmaller instead
%of 'smaller}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand{\acronymfont}[1]{\textsc{##1}}
    \renewcommand*{\acrpluralsuffix}{%
      \textup{\glspluralsuffix}}%
  \else
    \ifglsacrsmaller
      \renewcommand*{\acronymfont}[1]{\textsmaller{##1}}%
    \fi
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetFootnoteAcronymDisplayStyle}
% Sets the acronym display style for given glossary with
% footnote setting (but not \pkgopt{description} or \pkgopt{dua}).
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetFootnoteAcronymDisplayStyle}[1]{%
  \defglsdisplayfirst[#1]{%
    \firstacronymfont{##1}##4%
    \expandafter\protect\expandafter\acrfootnote\expandafter
       {\@gls@link@opts}{\@gls@link@label}{##2}%
  }%
  \defglsdisplay[#1]{\acronymfont{##1}##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\FootnoteNewAcronymDef}
%    \begin{macrocode}
\newcommand*{\FootnoteNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand\acronymfont{\the\glsshorttok}},%
      sort={\the\glsshorttok},%
      text={\the\glsshorttok},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetFootnoteAcronymStyle}
% If \pkgopt{footnote} package option is specified, set the first
% use to append the long form (stored in \gloskey{description}) as a 
% footnote.
% Use the \gloskey{description} key to store the long form.
%    \begin{macrocode}
\newcommand*{\SetFootnoteAcronymStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetFootnoteAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \FootnoteNewAcronymDef
  }%
%    \end{macrocode}
% Set display
%\changes{1.12}{2008 Mar 8}{Added 'protect before 'footnote and
% 'glslink}
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetFootnoteAcronymDisplayStyle{\@gls@type}%
  }%
%    \end{macrocode}
% Redefine \ics{acronymfont} if small caps required. The plural suffix
% is set in an upright font so that it remains in normal lower case,
% otherwise it looks as though it's part of the acronym.
%\changes{1.19}{2009 Mar 2}{changed 'acronymfont to use 'textsmaller instead
%of 'smaller}
%    \begin{macrocode}
  \ifglsacrsmallcaps
     \renewcommand*{\acronymfont}[1]{\textsc{##1}}%
     \renewcommand*{\acrpluralsuffix}{%
        \textup{\glspluralsuffix}}%
  \else
     \ifglsacrsmaller
        \renewcommand*{\acronymfont}[1]{\textsmaller{##1}}%
     \fi
  \fi
%    \end{macrocode}
% Check for option clash
%    \begin{macrocode}
  \ifglsacrdua
     \PackageError{glossaries}{Option clash: `footnote' and `dua'
     can't both be set}{}%
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetSmallAcronymDisplayStyle}
% Sets the acronym display style for given glossary where neither
% footnote nor description is required, but smallcaps or smaller
% specified.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetSmallAcronymDisplayStyle}[1]{%
  \defglsdisplayfirst[#1]{##1##4 (\firstacronymfont{##3})}
  \defglsdisplay[#1]{\acronymfont{##1}##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SmallNewAcronymDef}
%\changes{3.02}{2012/05/21}{fixed broken short and long plural}
%    \begin{macrocode}
\newcommand*{\SmallNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand\acronymfont{\the\glsshorttok}},%
      sort={\the\glsshorttok},%
      text={\noexpand\@glo@symbol},%
%    \end{macrocode}
% Default to the short plural.
%    \begin{macrocode}
      plural={\noexpand\@glo@shortpl},%
      first={\the\glslongtok},%
%    \end{macrocode}
% Default to the long plural.
%    \begin{macrocode}
      firstplural={\noexpand\@glo@longpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\noexpand\@glo@first},%
      descriptionplural={\noexpand\@glo@firstplural},%
      symbol={\the\glsshorttok},%
%    \end{macrocode}
% Default to the short plural.
%    \begin{macrocode}
      symbolplural={\noexpand\@glo@shortpl},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetSmallAcronymStyle}
% Neither footnote nor description required, but smallcaps or
% smaller specified.
% Use the \gloskey{symbol} key to store the short form and
% \gloskey{first} to store the long form.
%    \begin{macrocode}
\newcommand*{\SetSmallAcronymStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetSmallAcronymDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \SmallNewAcronymDef
  }%
%    \end{macrocode}
% Change the display since \gloskey{first} only contains long form.
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetSmallAcronymDisplayStyle{\@gls@type}%
  }%
%    \end{macrocode}
% Redefine \ics{acronymfont} if small caps required. The plural suffix
% is set in an upright font so that it remains in normal lower case,
% otherwise it looks as though it's part of the acronym.
%\changes{1.19}{2009 Mar 2}{changed 'acronymfont to use 'textsmaller instead
%of 'smaller}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand*{\acronymfont}[1]{\textsc{##1}}
    \renewcommand*{\acrpluralsuffix}{%
       \textup{\glspluralsuffix}}%
  \else
    \renewcommand*{\acronymfont}[1]{\textsmaller{##1}}
  \fi
%    \end{macrocode}
% check for option clash
%    \begin{macrocode}
  \ifglsacrdua
    \ifglsacrsmallcaps
      \PackageError{glossaries}{Option clash: `smallcaps' and `dua'
      can't both be set}{}%
    \else
      \PackageError{glossaries}{Option clash: `smaller' and `dua'
      can't both be set}{}%
    \fi
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetDUADisplayStyle}
% Sets the acronym display style for given glossary with dua
% setting.
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\SetDUADisplayStyle}[1]{%
  \defglsdisplay[#1]{##1##4}%
  \defglsdisplayfirst[#1]{##1##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DUANewAcronymDef}
%    \begin{macrocode}
\newcommand*{\DUANewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\the\glsshorttok},%
      text={\the\glslongtok},%
      plural={\the\glslongtok\noexpand\acrpluralsuffix},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      symbol={\the\glsshorttok},%
      symbolplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetDUAStyle}
% Always expand acronyms.
%    \begin{macrocode}
\newcommand*{\SetDUAStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetDUADisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \DUANewAcronymDef
  }%
%    \end{macrocode}
% Set the display
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetDUADisplayStyle{\@gls@type}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SetAcronymStyle}
%    \begin{macrocode}
\newcommand*{\SetAcronymStyle}{%
  \SetDefaultAcronymStyle
  \ifglsacrdescription
    \ifglsacrfootnote
      \SetDescriptionFootnoteAcronymStyle
    \else
      \ifglsacrdua
        \SetDescriptionDUAAcronymStyle
      \else
        \SetDescriptionAcronymStyle
      \fi
    \fi
  \else
    \ifglsacrfootnote
      \SetFootnoteAcronymStyle
    \else
      \ifthenelse{\boolean{glsacrsmallcaps}\OR
        \boolean{glsacrsmaller}}%
      {%
        \SetSmallAcronymStyle
      }%
      {%
        \ifglsacrdua
          \SetDUAStyle
        \fi
      }%
    \fi
  \fi
}
%    \end{macrocode}
% Set the acronym style according to the package options
%    \begin{macrocode}
\SetAcronymStyle
%    \end{macrocode}
%\end{macro}
%
% Allow user to define their own custom acronyms.
% (For compatibility with versions before v3.0, the short form is
% stored in the user1 key, the plural short form is stored in the
% user2 key, the long form is stored in the user3 key and the
% plural long form is stored in the user4 key.) Defaults to
% displaying only the acronym with the long form as the description.
%\begin{macro}{\SetCustomDisplayStyle}
% Sets the acronym display style.
%\changes{2.06}{2010 June 14}{new}
%    \begin{macrocode}
\newcommand*{\SetCustomDisplayStyle}[1]{%
  \defglsdisplay[#1]{##1##4}%
  \defglsdisplayfirst[#1]{##1##4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\CustomAcronymFields}
%\changes{2.06}{2010 June 14}{new}
%    \begin{macrocode}
\newcommand*{\CustomAcronymFields}{%
  name={\the\glsshorttok},%
  description={\the\glslongtok},%
  first={\noexpand\acrfullformat{\the\glslongtok}{\the\glsshorttok}},%
  firstplural={\noexpand\acrfullformat
    {\the\glslongtok\noexpand\acrpluralsuffix}{\the\glsshorttok}}%
  text={\the\glsshorttok},%
  plural={\the\glsshorttok\noexpand\acrpluralsuffix}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\CustomNewAcronymDef}
%\changes{2.06}{2010 June 14}{new}
%    \begin{macrocode}
\newcommand*{\CustomNewAcronymDef}{%
  \protected@edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      user1={\the\glsshorttok},%
      user2={\the\glsshorttok\noexpand\acrpluralsuffix},%
      user3={\the\glslongtok},%
      user4={\the\glslongtok\noexpand\acrpluralsuffix},%
      \CustomAcronymFields,%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SetCustomStyle}
%\changes{2.06}{2010 June 14}{new}
%    \begin{macrocode}
\newcommand*{\SetCustomStyle}{%
  \renewcommand{\newacronym}[4][]{%
    \ifx\@glsacronymlists\@empty
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
      \SetCustomDisplayStyle{\@glo@type}%
    \fi
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \CustomNewAcronymDef
  }%
%    \end{macrocode}
% Set the display
%    \begin{macrocode}
  \@for\@gls@type:=\@glsacronymlists\do{%
    \SetCustomDisplayStyle{\@gls@type}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\DefineAcronymSynonyms}
%\changes{2.04}{2009 November 10}{new}
%    \begin{macrocode}
\newcommand*{\DefineAcronymSynonyms}{%
%    \end{macrocode}
%\end{macro}
% Short form
%\begin{macro}{\acs}
%    \begin{macrocode}
  \let\acs\acrshort
%    \end{macrocode}
%\end{macro}
% First letter uppercase short form
%\begin{macro}{\Acs}
%    \begin{macrocode}
  \let\Acs\Acrshort
%    \end{macrocode}
%\end{macro}
% Plural short form
%\begin{macro}{\acsp}
%    \begin{macrocode}
  \let\acsp\acrshortpl
%    \end{macrocode}
%\end{macro}
% First letter uppercase plural short form
%\begin{macro}{\Acsp}
%    \begin{macrocode}
  \let\Acsp\Acrshortpl
%    \end{macrocode}
%\end{macro}
% Long form
%\begin{macro}{\acl}
%    \begin{macrocode}
  \let\acl\acrlong
%    \end{macrocode}
%\end{macro}
% Plural long form
%\begin{macro}{\aclp}
%    \begin{macrocode}
  \let\aclp\acrlongpl
%    \end{macrocode}
%\end{macro}
% First letter upper case long form
%\begin{macro}{\Acl}
%    \begin{macrocode}
  \let\Acl\Acrlong
%    \end{macrocode}
%\end{macro}
% First letter upper case plural long form
%\begin{macro}{\Aclp}
%    \begin{macrocode}
  \let\Aclp\Acrlongpl
%    \end{macrocode}
%\end{macro}
% Full form
%\begin{macro}{\acf}
%    \begin{macrocode}
  \let\acf\acrfull
%    \end{macrocode}
%\end{macro}
% Plural full form
%\begin{macro}{\acfp}
%    \begin{macrocode}
  \let\acfp\acrfullpl
%    \end{macrocode}
%\end{macro}
% First letter upper case full form
%\begin{macro}{\Acf}
%    \begin{macrocode}
  \let\Acf\Acrfull
%    \end{macrocode}
%\end{macro}
% First letter upper case plural full form
%\begin{macro}{\Acfp}
%    \begin{macrocode}
  \let\Acfp\Acrfullpl
%    \end{macrocode}
%\end{macro}
% Standard form
%\begin{macro}{\ac}
%    \begin{macrocode}
  \let\ac\gls
%    \end{macrocode}
%\end{macro}
% First upper case standard form
%\begin{macro}{\Ac}
%    \begin{macrocode}
  \let\Ac\Gls
%    \end{macrocode}
%\end{macro}
% Standard plural form
%\begin{macro}{\acp}
%    \begin{macrocode}
  \let\acp\glspl
%    \end{macrocode}
%\end{macro}
% Standard first letter upper case plural form
%\begin{macro}{\Acp}
%    \begin{macrocode}
  \let\Acp\Glspl
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
}
%    \end{macrocode}
% Define synonyms if required
%    \begin{macrocode}
\ifglsacrshortcuts
  \DefineAcronymSynonyms
\fi
%    \end{macrocode}
%
% \subsection{Predefined Glossary Styles}\label{sec:code:styles}
% The \sty{glossaries} bundle comes with some predefined glossary
% styles. These need to be loaded now for the \pkgopt{style} option
% to use them.
%
% First, the glossary hyper-navigation commands need to be loaded.
%    \begin{macrocode}
\RequirePackage{glossary-hypernav}
%    \end{macrocode}
% The styles that use list-like environments. These are not loaded
% if the \pkgopt{nolist} option is used:
%    \begin{macrocode}
\@gls@loadlist
%    \end{macrocode}
% The styles that use the \env{longtable} environment. These are
% not loaded if the \pkgopt{nolong} package option is used.
%    \begin{macrocode}
\@gls@loadlong
%    \end{macrocode}
% The styles that use the \env{supertabular} environment. These are
% not loaded if the \pkgopt{nosuper} package option is used or if
% the \isty{supertabular} package isn't installed.
%    \begin{macrocode}
\@gls@loadsuper
%    \end{macrocode}
% The tree-like styles. These are not loaded if the \pkgopt{notree}
% package option is used.
%    \begin{macrocode}
\@gls@loadtree
%    \end{macrocode}
% The default glossary style is set according to the \pkgopt{style} package
% option, but can be overridden by \ics{glossarystyle}. The
% required style must be defined at this point.
%    \begin{macrocode}
\ifx\@glossary@default@style\relax
\else
  \glossarystyle{\@glossary@default@style}
\fi
%    \end{macrocode}
%
%\subsection{Debugging Commands}
%
%\begin{macro}{\showgloparent}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloparent}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloparent}[1]{%
  \expandafter\show\csname glo@#1@parent\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglolevel}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglolevel}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglolevel}[1]{%
  \expandafter\show\csname glo@#1@level\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglotext}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglotext}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglotext}[1]{%
  \expandafter\show\csname glo@#1@text\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloplural}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloplural}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloplural}[1]{%
  \expandafter\show\csname glo@#1@plural\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglofirst}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglofirst}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglofirst}[1]{%
  \expandafter\show\csname glo@#1@first\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglofirstpl}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglofirstpl}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglofirstpl}[1]{%
  \expandafter\show\csname glo@#1@firstpl\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglotype}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglotype}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglotype}[1]{%
  \expandafter\show\csname glo@#1@type\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglocounter}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglocounter}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglocounter}[1]{%
  \expandafter\show\csname glo@#1@counter\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouseri}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouseri}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouseri}[1]{%
  \expandafter\show\csname glo@#1@useri\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouserii}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouserii}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouserii}[1]{%
  \expandafter\show\csname glo@#1@userii\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouseriii}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouseriii}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouseriii}[1]{%
  \expandafter\show\csname glo@#1@useriii\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouseriv}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouseriv}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouseriv}[1]{%
  \expandafter\show\csname glo@#1@useriv\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouserv}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouserv}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouserv}[1]{%
  \expandafter\show\csname glo@#1@userv\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglouservi}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglouservi}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglouservi}[1]{%
  \expandafter\show\csname glo@#1@uservi\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloname}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloname}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloname}[1]{%
  \expandafter\show\csname glo@#1@name\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglodesc}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglodesc}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglodesc}[1]{%
  \expandafter\show\csname glo@#1@desc\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglodescplural}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglodescplural}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglodescplural}[1]{%
  \expandafter\show\csname glo@#1@descplural\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglosort}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglosort}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglosort}[1]{%
  \expandafter\show\csname glo@#1@sort\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglosymbol}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglosymbol}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglosymbol}[1]{%
  \expandafter\show\csname glo@#1@symbol\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglosymbolplural}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglosymbolplural}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showglosymbolplural}[1]{%
  \expandafter\show\csname glo@#1@symbolplural\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloindex}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloindex}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloindex}[1]{%
  \expandafter\show\csname glo@#1@index\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloflag}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloflag}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloflag}[1]{%
  \expandafter\show\csname ifglo@#1@flag\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showacronymlists}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showacronymlists}
%\end{definition}
% Show list of glossaries that have been flagged as a list of
% acronyms.
%    \begin{macrocode}
\newcommand*{\showacronymlists}{%
   \show\@glsacronymlists
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglossaries}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglossaries}
%\end{definition}
% Show list of defined glossaries.
%    \begin{macrocode}
\newcommand*{\showglossaries}{%
   \show\@glo@types
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglossaryin}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglossaryin}\marg{glossary-label}
%\end{definition}
% Show the `in' extension for the given glossary.
%    \begin{macrocode}
\newcommand*{\showglossaryin}[1]{%
  \expandafter\show\csname @glotype@#1@in\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglossaryout}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglossaryout}\marg{glossary-label}
%\end{definition}
% Show the `out' extension for the given glossary.
%    \begin{macrocode}
\newcommand*{\showglossaryout}[1]{%
  \expandafter\show\csname @glotype@#1@out\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglossarytitle}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglossarytitle}\marg{glossary-label}
%\end{definition}
% Show the title for the given glossary.
%    \begin{macrocode}
\newcommand*{\showglossarytitle}[1]{%
  \expandafter\show\csname @glotype@#1@title\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglossarycounter}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showglossarycounter}\marg{glossary-label}
%\end{definition}
% Show the counter for the given glossary.
%    \begin{macrocode}
\newcommand*{\showglossarycounter}[1]{%
  \expandafter\show\csname @glotype@#1@counter\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglossaryentries}
%\changes{3.0}{2011/04/02}{new}
%\changes{3.02}{2012/05/21}{fixed misspelt command}
%\begin{definition}
%\cs{showglossaryentries}\marg{glossary-label}
%\end{definition}
% Show the list of entry labels for the given glossary.
%    \begin{macrocode}
\newcommand*{\showglossaryentries}[1]{%
  \expandafter\show\csname glolist@#1\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Compatibility with version 2.07 and below}
%
% In order to fix some bugs in v3.0, it was necessary to change the
% way information is written to the \filetype{glo} file, which also meant
% a change in the format of the Xindy style file. The compatibility
% option is meant for documents that use a customised Xindy style
% file with \ics{noist}. With the compatibility option, hopefully
% \app{xindy} will still be able to process the old document, but
% the bugs will remain. The issues in versions 2.07 and below:
%\begin{itemize}
% \item With \pkgopt{xindy}, the counter used by the entry was
% hard-coded into the Xindy style file. This meant that you couldn't
% use the \gloskey[glslink]{counter} to swap counters.
% \item With both \pkgopt{xindy} and \pkgopt{makeindex}, if used
% with \sty{hyperref} and \cs{theH}\meta{counter} was different to
% \cs{thecounter}, the link in the location number would be
% undefined.
%\end{itemize}
%    \begin{macrocode}
\csname ifglscompatible-2.07\endcsname
  \RequirePackage{glossaries-compatible-207}
\fi
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*mfirstuc.sty>
%    \end{macrocode}
%\fi
%\section{Mfirstuc Documented Code}
%\label{sec:code:mfirstuc}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mfirstuc}[2012/05/21 v1.06 (NLCT)]
%    \end{macrocode}
% Requires \sty{etoolbox}:\changes{1.06}{2012/05/21}{now requires
% etoolbox}
%    \begin{macrocode}
\RequirePackage{etoolbox}
%    \end{macrocode}
%\begin{macro}{\makefirstuc}
% Syntax:\\
% \cs{makefirstuc}\marg{text}\\
% Makes the first letter uppercase, but will
% skip initial control sequences if they are followed by a group
% and make the first thing in the group uppercase, unless the group
% is empty.
% Thus \verb|\makefirstuc{abc}| will produce: Abc, 
% \verb|\makefirstuc{\ae bc}| will produce: \AE bc, but
% \verb|\makefirstuc{\emph{abc}}| will produce \emph{Abc}.
% This is required by \ics{Gls} and \ics{Glspl}.
%    \begin{macrocode}
\newif\if@glscs
\newtoks\@glsmfirst
\newtoks\@glsmrest
\def\makefirstuc#1{%
  \def\gls@argi{#1}%
  \ifx\gls@argi\@empty
%    \end{macrocode}
% If the argument is empty, do nothing.
%    \begin{macrocode}
  \else
%    \end{macrocode}
%\changes{1.03}{2008/12/22}{changed 'protected@edef to 'def}
%    \begin{macrocode}
    \def\@gls@tmp{\ #1}%
    \@onelevel@sanitize\@gls@tmp
    \expandafter\@gls@checkcs\@gls@tmp\relax\relax
    \if@glscs
      \@gls@getbody #1{}\@nil
      \ifx\@gls@rest\@empty
        \glsmakefirstuc{#1}%
      \else
        \expandafter\@gls@split\@gls@rest\@nil
        \ifx\@gls@first\@empty
           \glsmakefirstuc{#1}%
        \else
           \expandafter\@glsmfirst\expandafter{\@gls@first}%
           \expandafter\@glsmrest\expandafter{\@gls@rest}%
           \edef\@gls@domfirstuc{\noexpand\@gls@body
             {\noexpand\glsmakefirstuc\the\@glsmfirst}%
             \the\@glsmrest}%
           \@gls@domfirstuc
        \fi
      \fi
    \else
      \glsmakefirstuc{#1}%
    \fi
  \fi
}
%    \end{macrocode}
%\end{macro}
% Put first argument in \cs{@gls@first} and second argument in
% \cs{@gls@rest}:
%    \begin{macrocode}
\def\@gls@split#1#2\@nil{%
  \def\@gls@first{#1}\def\@gls@rest{#2}%
}
%    \end{macrocode}
%    \begin{macrocode}
\def\@gls@checkcs#1 #2#3\relax{%
  \def\@gls@argi{#1}\def\@gls@argii{#2}%
  \ifx\@gls@argi\@gls@argii
    \@glscstrue
  \else
    \@glscsfalse
  \fi
}
%    \end{macrocode}
% Make first thing upper case:
%    \begin{macrocode}
\def\@gls@makefirstuc#1{\MakeUppercase #1}
%    \end{macrocode}
%\begin{macro}{\glsmakefirstuc}
%\changes{1.05}{2011/04/02}{new}
% Provide a user command to make it easier to customise.
%    \begin{macrocode}
\newcommand*{\glsmakefirstuc}[1]{\@gls@makefirstuc{#1}}
%    \end{macrocode}
%\end{macro}
%
% Get the first grouped argument and stores in \cs{@gls@body}.
%    \begin{macrocode}
\def\@gls@getbody#1#{\def\@gls@body{#1}\@gls@gobbletonil}
%    \end{macrocode}
% Scoup up everything to \cs{@nil} and store in \cs{@gls@rest}:
%    \begin{macrocode}
\def\@gls@gobbletonil#1\@nil{\def\@gls@rest{#1}}
%    \end{macrocode}
%
%\begin{macro}{\xmakefirstuc}
% Expand argument once before applying \cs{makefirstuc}
% (added v1.01).
%    \begin{macrocode}
\newcommand*{\xmakefirstuc}[1]{%
\expandafter\makefirstuc\expandafter{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\capitalisewords}
%\changes{1.06}{2012/05/21}{new}
% Capitalise each word in the argument. Words are considered to be
% separated by plain spaces (i.e.\ non-breakable spaces won't be
% considered a word break).
%    \begin{macrocode}
\newcommand*{\capitalisewords}[1]{%
  \def\gls@add@space{}%
  \mfu@capitalisewords#1 \@nil\mfu@endcap
    %\gls@add@space\makefirstuc{##1}\def\gls@add@space{ }%
}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\def\mfu@capitalisewords#1 #2\mfu@endcap{%
  \def\mfu@cap@first{#1}%
  \def\mfu@cap@second{#2}%
  \gls@add@space
  \makefirstuc{#1}%
  \def\gls@add@space{ }%
  \ifx\mfu@cap@second\@nnil
    \let\next@mfu@cap\mfu@noop
  \else
    \let\next@mfu@cap\mfu@capitalisewords
  \fi
  \next@mfu@cap#2\mfu@endcap
}
\def\mfu@noop#1\mfu@endcap{}
%    \end{macrocode}
%
%\begin{macro}{\xcapitalisewords}
%\changes{1.06}{2012/05/21}{new}
% Short-cut command:
%    \begin{macrocode}
\newcommand*{\xcapitalisewords}[1]{%
  \expandafter\capitalisewords\expandafter{#1}%
}
%    \end{macrocode}
%\end{macro}
%\section{Glossary Styles}
%\iffalse
%    \begin{macrocode}
%</mfirstuc.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-hypernav.sty>
%    \end{macrocode}
%\fi
% \subsection{Glossary hyper-navigation definitions (glossary-hypernav package)}
%\label{sec:code:hypernav}
% Package Definition:
%    \begin{macrocode}
\ProvidesPackage{glossary-hypernav}[2007/07/04 v1.01 (NLCT)]
%    \end{macrocode}
%
% The commands defined in this package are provided to 
% help navigate around the groups within a glossary 
% (see \autoref{sec:code:printglos}.)
% \ics{printglossary} (and \ics{printglossaries})
% set \cs{@glo@type} to the label of the current
% glossary. This is used to create a unique hypertarget in
% the event of multiple glossaries.
%\\[10pt]
% \cs{glsnavhyperlink}\oarg{type}\marg{label}\marg{text}\\[10pt]
% This command makes \meta{text} a hyperlink to the glossary group
% whose label is given by \meta{label} for the glossary given
% by \meta{type}.
%\begin{macro}{\glsnavhyperlink}
%\changes{1.14}{2008 June 17}{changed 'edef to 'protected@edef}
%\changes{1.17}{2008 December 26}{replaced 'hyperlink to '@glslink}
%    \begin{macrocode}
\newcommand*{\glsnavhyperlink}[3][\@glo@type]{%
  \edef\gls@grplabel{#2}\protected@edef\@gls@grptitle{#3}%
  \@glslink{glsn:#1@#2}{#3}}
%    \end{macrocode}
%\end{macro}
%\vskip5pt
% \cs{glsnavhypertarget}\oarg{type}\marg{label}\marg{text}\\[10pt]
% This command makes \meta{text} a hypertarget for the glossary group
% whose label is given by \meta{label} in the glossary given
% by \meta{type}. If \meta{type} is omitted, \cs{@glo@type} is
% used which is set by \ics{printglossary} to the current
% glossary label.
%\begin{macro}{\glsnavhypertarget}
%\changes{1.14}{2008 June 17}{added write to aux file}
%\changes{1.15}{2008 August 15}{added check if rerun required}
%\changes{1.17}{2008 December 26}{replaced 'hypertarget to '@glstarget}
%    \begin{macrocode}
\newcommand*{\glsnavhypertarget}[3][\@glo@type]{%
%    \end{macrocode}
% Add this group to the aux file for re-run check.
%    \begin{macrocode}
  \protected@write\@auxout{}{\string\@gls@hypergroup{#1}{#2}}%
%    \end{macrocode}
% Add the target.
%    \begin{macrocode}
  \@glstarget{glsn:#1@#2}{#3}%
%    \end{macrocode}
% Check list of know groups to determine if a re-run is required.
%    \begin{macrocode}
  \expandafter\let
     \expandafter\@gls@list\csname @gls@hypergrouplist@#1\endcsname
%    \end{macrocode}
% Iterate through list and terminate loop if this group is found.
%    \begin{macrocode}
  \@for\@gls@elem:=\@gls@list\do{%
    \ifthenelse{\equal{\@gls@elem}{#2}}{\@endfortrue}{}}%
%    \end{macrocode}
% Check if list terminated prematurely.
%    \begin{macrocode}
  \if@endfor
  \else
%    \end{macrocode}
% This group was not included in the list, so issue a warning.
%    \begin{macrocode}
    \GlossariesWarningNoLine{Navigation panel 
       for glossary type `#1'^^Jmissing group `#2'}%
    \gdef\gls@hypergrouprerun{%
      \GlossariesWarningNoLine{Navigation panel 
      has changed. Rerun LaTeX}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@hypergrouprerun}
% Give a warning at the end if re-run required
%\changes{1.15}{2008 August 15}{new}
%    \begin{macrocode}
\let\gls@hypergrouprerun\relax
\AtEndDocument{\gls@hypergrouprerun}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@hypergroup}
% This adds to (or creates) the command \cs{@gls@hypergrouplist@}\meta{glossary type} 
% which lists all groups for a given glossary, so that
% the navigation bar only contains those groups that are present.
% However it requires at least 2 runs to ensure the information is
% up-to-date.
%\changes{1.14}{2008 June 17}{new}
%    \begin{macrocode}
\newcommand*{\@gls@hypergroup}[2]{%
\@ifundefined{@gls@hypergrouplist@#1}{%
   \expandafter\xdef\csname @gls@hypergrouplist@#1\endcsname{#2}%
}{%
   \expandafter\let\expandafter\@gls@tmp
      \csname @gls@hypergrouplist@#1\endcsname
   \expandafter\xdef\csname @gls@hypergrouplist@#1\endcsname{%
      \@gls@tmp,#2}%
}%
}
%    \end{macrocode}
%\end{macro}
%
% The \cs{glsnavigation} command displays a simple glossary 
% group navigation. 
% The symbol and number elements are defined separately, 
% so that they can be suppressed if need be. Note that this 
% command will produce a link to all 28 groups, but some groups
% may not be defined if there are groups that do not contain any
% terms, in which case you will get an undefined hyperlink warning.
% Now for the whole navigation bit:
%\begin{macro}{\glsnavigation}
% \changes{1.14}{2008 June 2008}{changed to only use labels for
% groups that are present}
%    \begin{macrocode}
\newcommand*{\glsnavigation}{%
\def\@gls@between{}%
\@ifundefined{@gls@hypergrouplist@\@glo@type}{%
   \def\@gls@list{}%
}{%
   \expandafter\let\expandafter\@gls@list
      \csname @gls@hypergrouplist@\@glo@type\endcsname
}%
\@for\@gls@tmp:=\@gls@list\do{%
   \@gls@between
   \glsnavhyperlink{\@gls@tmp}{\glsgetgrouptitle{\@gls@tmp}}%
   \let\@gls@between\glshypernavsep%
}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glshypernavsep}
% Separator for the hyper navigation bar.
%    \begin{macrocode}
\newcommand*{\glshypernavsep}{\space\textbar\space}
%    \end{macrocode}
%\end{macro}
% The \cs{glssymbolnav} produces a simple navigation set of
% links for just the symbol and number groups. This used to be used at
% the start of \cs{glsnavigation}. This command is no longer needed.
%\begin{macro}{\glssymbolnav}
%    \begin{macrocode}
\newcommand*{\glssymbolnav}{%
\glsnavhyperlink{glssymbols}{\glsgetgrouptitle{glssymbols}}%
\glshypernavsep
\glsnavhyperlink{glsnumbers}{\glsgetgrouptitle{glsnumbers}}%
\glshypernavsep
}
%    \end{macrocode}
%\end{macro}
%\iffalse
%    \begin{macrocode}
%</glossary-hypernav.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-inline.sty>
%    \end{macrocode}
%\fi
% \subsection{In-line Style (glossary-inline.sty)}
% This defines an in-line style where the entries are
% comma-separated with just the name and description displayed.
%    \begin{macrocode}
\ProvidesPackage{glossary-inline}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
%
%\begin{style}{inline}
% Define the inline style.
%    \begin{macrocode}
\newglossarystyle{inline}{%
%    \end{macrocode}
% Start of glossary sets up first empty separator between entries.
% (This is then changed by \cs{glossaryentryfield})
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {%
      \def\gls@inlinesep{}%
      \def\gls@inlinesubsep{}%
      \def\gls@inlinepostchild{}%
    }%
    {\glspostinline}%
%    \end{macrocode}
% No header:
%    \begin{macrocode}
 \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings (if heading is required, add
% \ics{glsinlinedopostchild} to start definition in case heading
% follows a child entry):
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Just display separator followed by name and description:
%    \begin{macrocode}
  \renewcommand{\glossaryentryfield}[5]{%
    \glsinlinedopostchild
    \gls@inlinesep
    \def\glo@desc{##3}%
    \def\@no@post@desc{\nopostdesc}%
    \glsentryitem{##1}\glsinlinenameformat{##1}{##2}%
    \ifx\glo@desc\@no@post@desc
      \glsinlineemptydescformat{##4}{##5}%
    \else
      \ifstrempty{##3}%
      {\glsinlineemptydescformat{##4}{##5}}%
      {\glsinlinedescformat{##3}{##4}{##5}}%
    \fi
    \ifglshaschildren{##1}%
    {%
       \glsresetsubentrycounter
       \glsinlineparentchildseparator
       \def\gls@inlinesubsep{}%
       \def\gls@inlinepostchild{\glsinlinepostchild}%
    }%
    {}%
    \def\gls@inlinesep{\glsinlineseparator}%
  }%
%    \end{macrocode}
% Sub-entries display description:
%    \begin{macrocode}
  \renewcommand{\glossarysubentryfield}[6]{%
    \gls@inlinesubsep%
    \glsinlinesubnameformat{##2}{##3}%
    \glssubentryitem{##2}\glsinlinesubdescformat{##4}{##5}{##6}%
    \def\gls@inlinesubsep{\glsinlinesubseparator}%
  }%
%    \end{macrocode}
% Nothing special between groups:
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{macro}{\glsinlinedopostchild}
%    \begin{macrocode}
\newcommand*{\glsinlinedopostchild}{%
    \gls@inlinepostchild
    \def\gls@inlinepostchild{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlineseparator}
% Separator to use between entries.
%    \begin{macrocode}
\newcommand*{\glsinlineseparator}{;\space}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinesubseparator}
% Separator to use between sub-entries.
%    \begin{macrocode}
\newcommand*{\glsinlinesubseparator}{,\space}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlineparentchildseparator}
% Separator to use between parent and children.
%    \begin{macrocode}
\newcommand*{\glsinlineparentchildseparator}{:\space}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinepostchild}
%\changes{}{}{new}
% Hook to use between child and next entry
%    \begin{macrocode}
\newcommand*{\glsinlinepostchild}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspostinline}
% Terminator for inline glossary.
%\changes{}{}{replaced ``.'' with \cs{glspostdescription}}
%    \begin{macrocode}
\newcommand*{\glspostinline}{\glspostdescription\space}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinenameformat}
%\changes{}{}{new}
% Formats the name of the entry (first argument label, second
% argument name):
%    \begin{macrocode}
\newcommand*{\glsinlinenameformat}[2]{\glstarget{#1}{#2}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinedescformat}
%\changes{}{}{new}
% Formats the entry's description, symbol and location list:
%    \begin{macrocode}
\newcommand*{\glsinlinedescformat}[3]{\space#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlineemptydescformat}
%\changes{}{}{new}
% Formats the entry's symbol and location list when the description
% is empty:
%    \begin{macrocode}
\newcommand*{\glsinlineemptydescformat}[2]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinesubnameformat}
%\changes{}{}{new}
% Formats the name of the subentry (first argument label, second
% argument name):
%    \begin{macrocode}
\newcommand*{\glsinlinesubnameformat}[2]{\glstarget{#1}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinesubdescformat}
%\changes{}{}{new}
% Formats the subentry's description, symbol and location list:
%    \begin{macrocode}
\newcommand*{\glsinlinesubdescformat}[3]{#1}
%    \end{macrocode}
%\end{macro}
%
%
%\iffalse
%    \begin{macrocode}
%</glossary-inline.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-list.sty>
%    \end{macrocode}
%\fi
% \subsection{List Style (glossary-list.sty)}
% The \isty{glossary-list} style file defines glossary styles
% that use the \env{description} environment. Note that since
% the entry name is placed in the optional argument to the
% \ics{item} command, it will appear in a bold font by
% default.
%    \begin{macrocode}
\ProvidesPackage{glossary-list}[2012/11/11 v3.04 (NLCT)]
%    \end{macrocode}
%\begin{style}{list}
% The \glostyle{list} glossary style 
% uses the \env{description} environment. The group separator
% \ics{glsgroupskip} is redefined as \cs{indexspace}
% which produces a gap between groups. The glossary heading
% and the group headings do nothing. Sub-entries immediately
% follow the main entry without the sub-entry name. This style
% does not use the entry's symbol. This is used as the default
% style for the \sty{glossaries} package.
%    \begin{macrocode}
\newglossarystyle{list}{%
%    \end{macrocode}
% Use \env{description} environment:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{description}}{\end{description}}%
%    \end{macrocode}
% No header at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries start a new item in the list:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[\glsentryitem{##1}\glstarget{##1}{##2}] 
       ##3\glspostdescription\space ##5}%
%    \end{macrocode}
% Sub-entries continue on the same line:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}##4\glspostdescription\space ##6.}%
%   \end{macrocode}
% Add vertical space between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%   \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{listgroup}
% The \glostyle{listgroup} style is like the \glostyle{list}
% style, but the glossary groups have headings.
%\changes{1.08}{2007 Oct 13}{changed listgroup style to use \cs{glsgetgrouptitle}}
%    \begin{macrocode}
\newglossarystyle{listgroup}{%
%    \end{macrocode}
% Base it on the \glostyle{list} style:
%    \begin{macrocode}
  \glossarystyle{list}%
%    \end{macrocode}
% Each group has a heading:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{\item[\glsgetgrouptitle{##1}]}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{listhypergroup}
% The \glostyle{listhypergroup} style is like the \glostyle{listgroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{listhypergroup}{%
%    \end{macrocode}
% Base it on the \glostyle{list} style:
%    \begin{macrocode}
  \glossarystyle{list}%
%    \end{macrocode}
% Add navigation links at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \item[\glsnavigation]}%
%    \end{macrocode}
% Each group has a heading with a hypertarget:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \item[\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}]}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlist}
% The \glostyle{altlist} glossary style is like the \glostyle{list}
% style, but places the description on a new line. Sub-entries
% follow in separate paragraphs without the sub-entry name. This
% style does not use the entry's symbol.
%    \begin{macrocode}
\newglossarystyle{altlist}{%
%    \end{macrocode}
% Base it on the \glostyle{list} style:
%    \begin{macrocode}
  \glossarystyle{list}%
%    \end{macrocode}
% Main (level 0) entries start a new item in the list with a
% line break after the entry name:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[\glsentryitem{##1}\glstarget{##1}{##2}]%
%    \end{macrocode}
%\changes{3.04}{2012-11-11}{replaced \cs{newline} with paragraph break}
% Version 3.04 changed \cs{newline} to the following paragraph break
% stuff (thanks to Daniel Gebhardt for supplying the fix) to prevent
% a page break occurring at this point.
%    \begin{macrocode}
      \mbox{}\par\nobreak\@afterheading
      ##3\glspostdescription\space ##5}%
%    \end{macrocode}
% Sub-entries start a new paragraph:
%    \begin{macrocode}
  \renewcommand{\glossarysubentryfield}[6]{%
    \par
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}##4\glspostdescription\space ##6}%
}
%    \end{macrocode}
%\end{style}
%\begin{style}{altlistgroup}
% The \glostyle{altlistgroup} glossary style is like the
% \glostyle{altlist} style, but the glossary groups have headings.
%\changes{1.08}{2007 Oct 13}{changed altlistgroup style to use \cs{glsgetgrouptitle}}
%    \begin{macrocode}
\newglossarystyle{altlistgroup}{%
%    \end{macrocode}
% Base it on the \glostyle{altlist} style:
%    \begin{macrocode}
  \glossarystyle{altlist}%
%    \end{macrocode}
% Each group has a heading:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{\item[\glsgetgrouptitle{##1}]}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlisthypergroup}
% The \glostyle{altlisthypergroup} glossary style is like the
% \glostyle{altlistgroup} style, but has a 
% set of links to the groups at the start of the glossary.
%    \begin{macrocode}
\newglossarystyle{altlisthypergroup}{%
%    \end{macrocode}
% Base it on the \glostyle{altlist} style:
%    \begin{macrocode}
  \glossarystyle{altlist}%
%    \end{macrocode}
% Add navigation links at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \item[\glsnavigation]}%
%    \end{macrocode}
% Each group has a heading with a hypertarget:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \item[\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}]}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{listdotted}
% The \glostyle{listdotted} glossary style was supplied by 
% Axel~Menzel. I've modified it slightly so that the distance from
% the start of the name to the end of the dotted line is specified 
% by \cs{glslistdottedwidth}.
% Note that this style ignores the page numbers as well as the
% symbol. Sub-entries are displayed in the same way as top-level
% entries.
%    \begin{macrocode}
\newglossarystyle{listdotted}{%
%    \end{macrocode}
% Base it on the \glostyle{list} style:
%    \begin{macrocode}
  \glossarystyle{list}%
%    \end{macrocode}
% Each main (level 0) entry starts a new item:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
      \glsentryitem{##1}\glstarget{##1}{##2}%
      \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}##3}%
%    \end{macrocode}
% Sub entries have the same format as main entries:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{##3}%
    \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}##4}%
}
%    \end{macrocode}
%\end{style}
%\begin{macro}{\glslistdottedwidth}
%\changes{2.01}{2009 May 30}{changed \cs{linewidth} to \cs{hsize}}
%    \begin{macrocode}
\newlength\glslistdottedwidth
\setlength{\glslistdottedwidth}{.5\hsize}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{sublistdotted}
% This style is similar to the glostyle{listdotted} style, except
% that the main entries just have the name displayed.
%    \begin{macrocode}
\newglossarystyle{sublistdotted}{%
%    \end{macrocode}
% Base it on the \glostyle{listdotted} style:
%    \begin{macrocode}
  \glossarystyle{listdotted}%
%    \end{macrocode}
% Main (level 0) entries just display the name:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[\glsentryitem{##1}\glstarget{##1}{##2}]}%
}
%    \end{macrocode}
%\end{style}
%\iffalse
%    \begin{macrocode}
%</glossary-list.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-long.sty>
%    \end{macrocode}
%\fi
% \subsection{Glossary Styles using longtable (the glossary-long
% package)}
% The glossary styles defined in the \isty{glossary-long} package
% used the \env{longtable} environment in the glossary.
%    \begin{macrocode}
\ProvidesPackage{glossary-long}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
% Requires the \isty{longtable} package:
%    \begin{macrocode}
\RequirePackage{longtable}
%    \end{macrocode}
%\begin{macro}{\glsdescwidth}
% This is a length that governs the width of the description column.
% (There's a chance that the user may specify \pkgopt{nolong}
% and then load \isty{glossary-long} later, in which case 
% \cs{glsdescwidth} may have already been defined by
% \isty{glossary-super}. The same goes for \cs{glspagelistwidth}.)
%\changes{2.01}{2009 May 30}{changed \cs{linewidth} to \cs{hsize}}
%    \begin{macrocode}
\@ifundefined{glsdescwidth}{%
  \newlength\glsdescwidth
  \setlength{\glsdescwidth}{0.6\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspagelistwidth}
% This is a length that governs the width of the page list column.
%\changes{2.01}{2009 May 30}{changed \cs{linewidth} to \cs{hsize}}
%    \begin{macrocode}
\@ifundefined{glspagelistwidth}{%
  \newlength\glspagelistwidth
  \setlength{\glspagelistwidth}{0.1\hsize}
}{}
%    \end{macrocode}
%\end{macro}
% 
%\begin{style}{long}
% The \glostyle{long} glossary style command which 
% uses the \env{longtable} environment:
%    \begin{macrocode}
\newglossarystyle{long}{%
%    \end{macrocode}
% Use \env{longtable} with two columns:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
     {\begin{longtable}{lp{\glsdescwidth}}}%
     {\end{longtable}}%
%    \end{macrocode}
% Do nothing at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No heading between groups:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries displayed in a row:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
%    \end{macrocode}
% Sub entries displayed on the following row without the name:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longborder}
% The \glostyle{longborder} style is like the above, but with horizontal and
% vertical lines:
%    \begin{macrocode}
\newglossarystyle{longborder}{%
%    \end{macrocode}
% Base it on the glostyle{long} style:
%    \begin{macrocode}
  \glossarystyle{long}%
%    \end{macrocode}
% Use \env{longtable} with two columns with vertical lines
% between each column:
%    \begin{macrocode}
  \renewenvironment{theglossary}{%
    \begin{longtable}{|l|p{\glsdescwidth}|}}{\end{longtable}}%
%    \end{macrocode}
% Place horizontal lines at the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longheader}
% The \glostyle{longheader} style is like the
% \glostyle{long} style but with a header:
%    \begin{macrocode}
\newglossarystyle{longheader}{%
%    \end{macrocode}
% Base it on the glostyle{long} style:
%    \begin{macrocode}
  \glossarystyle{long}%
%    \end{macrocode}
% Set the table's header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries \entryname & \bfseries \descriptionname\\\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longheaderborder}
% The \glostyle{longheaderborder} style is
% like the \glostyle{long} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{longheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{longborder} style:
%    \begin{macrocode}
  \glossarystyle{longborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line to table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline\bfseries \entryname & \bfseries \descriptionname\\\hline
    \endhead
    \hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long3col}
% The \glostyle{long3col} style is like \glostyle{long} but with 3 columns
%    \begin{macrocode}
\newglossarystyle{long3col}{%
%    \end{macrocode}
% Use a \env{longtable} with 3 columns:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{lp{\glsdescwidth}p{\glspagelistwidth}}}%
    {\end{longtable}}%
%    \end{macrocode}
% No table header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No headings between groups:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row (name in first column, 
% description in second column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\\}%
%    \end{macrocode}
% Sub-entries on a separate row (no name, description in
% second column, page list in third column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long3colborder}
% The \glostyle{long3colborder} style is like the
% \glostyle{long3col} style but with a border:
%    \begin{macrocode}
\newglossarystyle{long3colborder}{%
%    \end{macrocode}
% Base it on the glostyle{long3col} style:
%    \begin{macrocode}
  \glossarystyle{long3col}%
%    \end{macrocode}
% Use a \env{longtable} with 3 columns with vertical lines
% around them:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Place horizontal lines at the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long3colheader}
% The \glostyle{long3colheader} style is like \glostyle{long3col} but with a header row:
%    \begin{macrocode}
\newglossarystyle{long3colheader}{%
%    \end{macrocode}
% Base it on the glostyle{long3col} style:
%    \begin{macrocode}
  \glossarystyle{long3col}%
%    \end{macrocode}
% Set the table's header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\\\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long3colheaderborder}
% The \glostyle{long3colheaderborder} style is like the above but with a border
%    \begin{macrocode}
\newglossarystyle{long3colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{long3colborder} style:
%    \begin{macrocode}
  \glossarystyle{long3colborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line at table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\\\hline\endhead
    \hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long4col}
% The \glostyle{long4col} style has four columns where the third 
% column contains the value of the associated \gloskey{symbol} key.
%    \begin{macrocode}
\newglossarystyle{long4col}{%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{llll}}%
    {\end{longtable}}%
%    \end{macrocode}
% No table header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a single row (name in first column,
% description in second column, symbol in third column, page list
% in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\\}%
%    \end{macrocode}
% Sub entries on a single row with no name (description in second
% column, symbol in third column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long4colheader}
% The \glostyle{long4colheader} style is like \glostyle{long4col} 
% but with a header row.
%    \begin{macrocode}
\newglossarystyle{long4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{long4col} style:
%    \begin{macrocode}
  \glossarystyle{long4col}%
%    \end{macrocode}
% Table has a header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries \symbolname&
    \bfseries\pagelistname\\\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long4colborder}
% The \glostyle{long4colborder} style is like \glostyle{long4col} 
% but with a border.
%    \begin{macrocode}
\newglossarystyle{long4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{long4col} style:
%    \begin{macrocode}
  \glossarystyle{long4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns surrounded by vertical
% lines:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|l|l|l|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Add horizontal lines to the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{long4colheaderborder}
% The \glostyle{long4colheaderborder} style is like the above but 
% with a border.
%    \begin{macrocode}
\newglossarystyle{long4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{long4col} style:
%    \begin{macrocode}
  \glossarystyle{long4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns surrounded by vertical
% lines:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|l|l|l|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Add table header and horizontal line at the table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline\bfseries\entryname&\bfseries\descriptionname&
    \bfseries \symbolname&
    \bfseries\pagelistname\\\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlong4col}
% The \glostyle{altlong4col} style is like the \glostyle{long4col}
% style but can have multiline descriptions and page lists.
%    \begin{macrocode}
\newglossarystyle{altlong4col}{%
%    \end{macrocode}
% Base it on the glostyle{long4col} style:
%    \begin{macrocode}
   \glossarystyle{long4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{lp{\glsdescwidth}lp{\glspagelistwidth}}}%
    {\end{longtable}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlong4colheader}
% The \glostyle{altlong4colheader} style is like 
% \glostyle{altlong4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{altlong4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{long4colheader} style:
%    \begin{macrocode}
  \glossarystyle{long4colheader}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{lp{\glsdescwidth}lp{\glspagelistwidth}}}%
    {\end{longtable}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlong4colborder}
% The \glostyle{altlong4colborder} style is like
% \glostyle{altlong4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{altlong4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{long4colborder} style:
%    \begin{macrocode}
   \glossarystyle{long4colborder}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|p{\glsdescwidth}|l|p{\glspagelistwidth}|}}%
    {\end{longtable}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlong4colheaderborder}
% The \glostyle{altlong4colheaderborder} style is like the above but
% with a header as well as a border.
%    \begin{macrocode}
\newglossarystyle{altlong4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{long4colheaderborder} style:
%    \begin{macrocode}
  \glossarystyle{long4colheaderborder}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|p{\glsdescwidth}|l|p{\glspagelistwidth}|}}%
    {\end{longtable}}%
}
%    \end{macrocode}
%\end{style}
%\iffalse
%    \begin{macrocode}
%</glossary-long.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-longragged.sty>
%    \end{macrocode}
%\fi
% \subsection{Glossary Styles using longtable (the glossary-longragged
% package)}
% The glossary styles defined in the \isty{glossary-longragged} package
% used the \env{longtable} environment in the glossary and use
% ragged right formatting for the multiline columns.
%    \begin{macrocode}
\ProvidesPackage{glossary-longragged}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
% Requires the \isty{array} package:
%    \begin{macrocode}
\RequirePackage{array}
%    \end{macrocode}
% Requires the \isty{longtable} package:
%    \begin{macrocode}
\RequirePackage{longtable}
%    \end{macrocode}
%\begin{macro}{\glsdescwidth}
% This is a length that governs the width of the description column.
% This may have already been defined.
%    \begin{macrocode}
\@ifundefined{glsdescwidth}{%
  \newlength\glsdescwidth
  \setlength{\glsdescwidth}{0.6\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspagelistwidth}
% This is a length that governs the width of the page list column.
% This may already have been defined.
%    \begin{macrocode}
\@ifundefined{glspagelistwidth}{%
  \newlength\glspagelistwidth
  \setlength{\glspagelistwidth}{0.1\hsize}
}{}
%    \end{macrocode}
%\end{macro}
% 
%\begin{style}{longragged}
% The \glostyle{longragged} glossary style is like the
% \glostyle{long} but uses ragged right formatting for the
% description column.
%    \begin{macrocode}
\newglossarystyle{longragged}{%
%    \end{macrocode}
% Use \env{longtable} with two columns:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
     {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}}}%
     {\end{longtable}}%
%    \end{macrocode}
% Do nothing at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No heading between groups:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries displayed in a row:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5%
    \tabularnewline}%
%    \end{macrocode}
% Sub entries displayed on the following row without the name:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6%
    \tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longraggedborder}
% The \glostyle{longraggedborder} style is like the above, but with horizontal and
% vertical lines:
%    \begin{macrocode}
\newglossarystyle{longraggedborder}{%
%    \end{macrocode}
% Base it on the glostyle{longragged} style:
%    \begin{macrocode}
  \glossarystyle{longragged}%
%    \end{macrocode}
% Use \env{longtable} with two columns with vertical lines
% between each column:
%    \begin{macrocode}
  \renewenvironment{theglossary}{%
    \begin{longtable}{|l|>{\raggedright}p{\glsdescwidth}|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Place horizontal lines at the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longraggedheader}
% The \glostyle{longraggedheader} style is like the
% \glostyle{longragged} style but with a header:
%    \begin{macrocode}
\newglossarystyle{longraggedheader}{%
%    \end{macrocode}
% Base it on the glostyle{longragged} style:
%    \begin{macrocode}
  \glossarystyle{longragged}%
%    \end{macrocode}
% Set the table's header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries \entryname & \bfseries \descriptionname
    \tabularnewline\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longraggedheaderborder}
% The \glostyle{longraggedheaderborder} style is
% like the \glostyle{longragged} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{longraggedheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{longraggedborder} style:
%    \begin{macrocode}
  \glossarystyle{longraggedborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line to table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline\bfseries \entryname & \bfseries \descriptionname
    \tabularnewline\hline
    \endhead
    \hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longragged3col}
% The \glostyle{longragged3col} style is like \glostyle{longragged} but with 3 columns
%    \begin{macrocode}
\newglossarystyle{longragged3col}{%
%    \end{macrocode}
% Use a \env{longtable} with 3 columns:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}%
       >{\raggedright}p{\glspagelistwidth}}}%
    {\end{longtable}}%
%    \end{macrocode}
% No table header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No headings between groups:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row (name in first column, 
% description in second column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\tabularnewline}%
%    \end{macrocode}
% Sub-entries on a separate row (no name, description in
% second column, page list in third column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longragged3colborder}
% The \glostyle{longragged3colborder} style is like the
% \glostyle{longragged3col} style but with a border:
%    \begin{macrocode}
\newglossarystyle{longragged3colborder}{%
%    \end{macrocode}
% Base it on the glostyle{longragged3col} style:
%    \begin{macrocode}
  \glossarystyle{longragged3col}%
%    \end{macrocode}
% Use a \env{longtable} with 3 columns with vertical lines
% around them:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|>{\raggedright}p{\glsdescwidth}|%
      >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Place horizontal lines at the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longragged3colheader}
% The \glostyle{longragged3colheader} style is like \glostyle{longragged3col} but with a header row:
%    \begin{macrocode}
\newglossarystyle{longragged3colheader}{%
%    \end{macrocode}
% Base it on the glostyle{longragged3col} style:
%    \begin{macrocode}
  \glossarystyle{longragged3col}%
%    \end{macrocode}
% Set the table's header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\tabularnewline\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{longragged3colheaderborder}
% The \glostyle{longragged3colheaderborder} style is like the above but with a border
%    \begin{macrocode}
\newglossarystyle{longragged3colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{longragged3colborder} style:
%    \begin{macrocode}
  \glossarystyle{longragged3colborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line at table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\tabularnewline\hline\endhead
    \hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlongragged4col}
% The \glostyle{altlongragged4col} style is like the \glostyle{altlong4col}
% style defined in the \isty{glossary-long} package, except that
% ragged right formatting is used for the description and page list
% columns.
%    \begin{macrocode}
\newglossarystyle{altlongragged4col}{%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}l%
       >{\raggedright}p{\glspagelistwidth}}}%
    {\end{longtable}}%
%    \end{macrocode}
% No table header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a single row (name in first column,
% description in second column, symbol in third column, page list
% in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\tabularnewline}%
%    \end{macrocode}
% Sub entries on a single row with no name (description in second
% column, symbol in third column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlongragged4colheader}
% The \glostyle{altlongragged4colheader} style is like 
% \glostyle{altlongragged4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{altlongragged4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{altlongragged4col} style:
%    \begin{macrocode}
  \glossarystyle{altlongragged4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}l%
      >{\raggedright}p{\glspagelistwidth}}}%
    {\end{longtable}}%
%    \end{macrocode}
% Table has a header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries \symbolname&
    \bfseries\pagelistname\tabularnewline\endhead}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlongragged4colborder}
% The \glostyle{altlongragged4colborder} style is like
% \glostyle{altlongragged4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{altlongragged4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{altlongragged4col} style:
%    \begin{macrocode}
   \glossarystyle{altlongragged4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|>{\raggedright}p{\glsdescwidth}|l|%
      >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Add horizontal lines to the head and foot of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{\hline\endhead\hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altlongragged4colheaderborder}
% The \glostyle{altlongragged4colheaderborder} style is like the above but
% with a header as well as a border.
%    \begin{macrocode}
\newglossarystyle{altlongragged4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{altlongragged4col} style:
%    \begin{macrocode}
  \glossarystyle{altlongragged4col}%
%    \end{macrocode}
% Use a \env{longtable} with 4 columns where the second and
% last columns may have multiple lines in each row:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\begin{longtable}{|l|>{\raggedright}p{\glsdescwidth}|l|%
       >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{longtable}}%
%    \end{macrocode}
% Add table header and horizontal line at the table's foot:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline\bfseries\entryname&\bfseries\descriptionname&
    \bfseries \symbolname&
    \bfseries\pagelistname\tabularnewline\hline\endhead
      \hline\endfoot}%
}
%    \end{macrocode}
%\end{style}
%\iffalse
%    \begin{macrocode}
%</glossary-longragged.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-mcols.sty>
%    \end{macrocode}
%\fi
%\subsection{Glossary Styles using \styfmt{multicol}
%(glossary-mcols.sty)}
%The \isty{glossary-mcols} style file defines glossary styles that
%use the \sty{multicol} package. These use the tree-like glossary
%styles in a multicol environment.
%    \begin{macrocode}
\ProvidesPackage{glossary-mcols}[2012/05/21 v1.0 (NLCT)]
%    \end{macrocode}
% Required packages:
%    \begin{macrocode}
\RequirePackage{multicol}
\RequirePackage{glossary-tree}
%    \end{macrocode}
%
%\begin{macro}{\glsmcols}
% Define macro in which to store the number of columns. (Defaults to
% 2.)
%    \begin{macrocode}
\newcommand*{\glsmcols}{2}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{mcolindex}
% Multi-column index style. Same as the \glostyle{index}, but puts the
% glossary in multiple columns. (Ideally the glossary title should go in the
% optional argument of \env{multicols}, but the title isn't part of
% the glossary style.)
%    \begin{macrocode}
\newglossarystyle{mcolindex}{%
  \glossarystyle{index}%
  \renewenvironment{theglossary}%
    {%
     \begin{multicols}{2}
     \setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}%
     \let\item\@idxitem}%
    {\end{multicols}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcolindexgroup}
% As \glostyle{mcolindex} but has headings:
%    \begin{macrocode}
\newglossarystyle{mcolindexgroup}{%
 \glossarystyle{mcolindex}%
 \renewcommand*{\glsgroupheading}[1]{%
    \item\textbf{\glsgetgrouptitle{##1}}\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcolindexhypergroup}
% The \glostyle{mcolindexhypergroup} style is like the
% \glostyle{mcolindexgroup} style but has hyper navigation.
%    \begin{macrocode}
\newglossarystyle{mcolindexhypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcolindex} style:
%    \begin{macrocode}
  \glossarystyle{mcolindex}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the glossary:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \item\textbf{\glsnavigation}\indexspace}%
%    \end{macrocode}
% Add a heading for each group (with a target). The group's title is
% in bold followed by a vertical gap.
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \item\textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}%
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltree}
% Multi-column index style. Same as the \glostyle{tree}, but puts the
% glossary in multiple columns.
%    \begin{macrocode}
\newglossarystyle{mcoltree}{%
  \glossarystyle{tree}%
  \renewenvironment{theglossary}%
  {%
     \begin{multicols}{2}
     \setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}%
  }%
  {\end{multicols}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltreegroup}
% Like the \glostyle{mcoltree} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{mcoltreegroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcoltree} style:
%    \begin{macrocode}
  \glossarystyle{mcoltree}%
%    \end{macrocode}
% Each group has a heading (in bold) followed by a vertical gap):
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltreehypergroup}
% The \glostyle{mcoltreehypergroup} style is like the
% \glostyle{treegroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{mcoltreehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcoltree} style:
%    \begin{macrocode}
  \glossarystyle{mcoltree}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Each group has a heading (in bold with a target) followed by a 
% vertical gap):
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par\noindent
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltreenoname}
% Multi-column index style. Same as the \glostyle{treenoname}, but puts the
% glossary in multiple columns.
%    \begin{macrocode}
\newglossarystyle{mcoltreenoname}{%
  \glossarystyle{treenoname}%
  \renewenvironment{theglossary}%
  {%
     \begin{multicols}{2}
     \setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}%
  }%
  {\end{multicols}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltreenonamegroup}
% Like the \glostyle{mcoltreenoname} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{mcoltreenonamegroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcoltreenoname} style:
%    \begin{macrocode}
  \glossarystyle{mcoltreenoname}%
%    \end{macrocode}
% Give each group a heading:
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcoltreenonamehypergroup}
% The \glostyle{mcoltreenonamehypergroup} style is like the
% \glostyle{mcoltreenonamegroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{mcoltreenonamehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcoltreenoname} style:
%    \begin{macrocode}
  \glossarystyle{mcoltreenoname}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Each group has a heading (in bold with a target) followed by a 
% vertical gap):
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par\noindent
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcolalttree}
% Multi-column index style. Same as the \glostyle{alttree}, but puts the
% glossary in multiple columns.
%    \begin{macrocode}
\newglossarystyle{mcolalttree}{%
  \glossarystyle{alttree}%
  \renewenvironment{theglossary}%
  {%
     \begin{multicols}{2}%
     \def\@gls@prevlevel{-1}%
     \mbox{}\par
  }%
  {\par\end{multicols}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcolalttreegroup}
% Like the \glostyle{mcolalttree} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{mcolalttreegroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcolalttree} style:
%    \begin{macrocode}
  \glossarystyle{mcolalttree}%
%    \end{macrocode}
% Give each group a heading.
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{mcolalttreehypergroup}
% The \glostyle{mcolalttreehypergroup} style is like the 
% \glostyle{mcolalttreegroup} style, but has a set of links to the 
% groups at the start of the glossary.
%    \begin{macrocode}
\newglossarystyle{mcolalttreehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{mcolalttree} style:
%    \begin{macrocode}
  \glossarystyle{mcolalttree}%
%    \end{macrocode}
% Put the navigation links in the header
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Put a hypertarget at the start of each group
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}}
%    \end{macrocode}
%\end{style}


%\iffalse
%    \begin{macrocode}
%</glossary-mcols.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-super.sty>
%    \end{macrocode}
%\fi
% \subsection{Glossary Styles using supertabular environment (glossary-super package)}
% The glossary styles defined in the \isty{glossary-super} package
% use the \env{supertabular} environment.
%    \begin{macrocode}
\ProvidesPackage{glossary-super}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
% Requires the \isty{supertabular} package:
%    \begin{macrocode}
\RequirePackage{supertabular}
%    \end{macrocode}
%\begin{macro}{\glsdescwidth}
% This is a length that governs the width of the description column.
% This may already have been defined if \isty{glossary-long}
% has been loaded.\changes{2.01}{2009 May 30}{changed \cs{linewidth}
% to \cs{hsize}}
%    \begin{macrocode}
\@ifundefined{glsdescwidth}{%
  \newlength\glsdescwidth
  \setlength{\glsdescwidth}{0.6\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspagelistwidth}
% This is a length that governs the width of the page list column.
% This may already have been defined if \isty{glossary-long}
% has been loaded.\changes{2.01}{2009 May 30}{changed \cs{linewidth}
% to \cs{hsize}}
%    \begin{macrocode}
\@ifundefined{glspagelistwidth}{%
  \newlength\glspagelistwidth
  \setlength{\glspagelistwidth}{0.1\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{super}
% The \glostyle{super} glossary style uses the
% \env{supertabular} environment
% (it uses lengths defined in the \isty{glossary-long} package.)
%    \begin{macrocode}
\newglossarystyle{super}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{lp{\glsdescwidth}}}%
    {\end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries put in a row (name in first column,
% description and page list in second column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
%    \end{macrocode}
% Sub entries put in a row (no name, description and page list
% in second column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superborder}
% The \glostyle{superborder} style is like the above, but with 
% horizontal and vertical lines:
%    \begin{macrocode}
\newglossarystyle{superborder}{%
%    \end{macrocode}
% Base it on the glostyle{super} style:
%    \begin{macrocode}
  \glossarystyle{super}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|p{\glsdescwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superheader}
% The \glostyle{superheader} style is like the
% \glostyle{super} style, but with a header:
%    \begin{macrocode}
\newglossarystyle{superheader}{%
%    \end{macrocode}
% Base it on the glostyle{super} style:
%    \begin{macrocode}
  \glossarystyle{super}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and no tail:
%    \begin{macrocode}
\renewenvironment{theglossary}%
  {\tablehead{\bfseries \entryname & \bfseries \descriptionname\\}%
   \tabletail{}%
   \begin{supertabular}{lp{\glsdescwidth}}}%
  {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superheaderborder}
% The \glostyle{superheaderborder} style is like
% the \glostyle{super} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{superheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{super} style:
%    \begin{macrocode}
  \glossarystyle{super}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and horizontal lines above and below the
% table:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline\bfseries \entryname &
       \bfseries \descriptionname\\\hline}%
     \tabletail{\hline}
     \begin{supertabular}{|l|p{\glsdescwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super3col}
% The \glostyle{super3col} style is like the \glostyle{super} 
% style, but with 3 columns:
%    \begin{macrocode}
\newglossarystyle{super3col}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{lp{\glsdescwidth}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row (name in first column, 
% description in second column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\\}%
%    \end{macrocode}
% Sub entries on a row (no name, description in second column,
% page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super3colborder}
% The \glostyle{super3colborder} style is like the
% \glostyle{super3col} style, but with a border:
%    \begin{macrocode}
\newglossarystyle{super3colborder}{%
%    \end{macrocode}
% Base it on the glostyle{super3col} style:
%    \begin{macrocode}
  \glossarystyle{super3col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super3colheader}
% The \glostyle{super3colheader} style is like 
% the \glostyle{super3col} style but with a header row:
%    \begin{macrocode}
\newglossarystyle{super3colheader}{%
%    \end{macrocode}
% Base it on the glostyle{super3col} style:
%    \begin{macrocode}
  \glossarystyle{super3col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns, a header and no tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
       \bfseries\pagelistname\\}\tabletail{}%
     \begin{supertabular}{lp{\glsdescwidth}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super3colheaderborder}
% The \glostyle{super3colheaderborder} style is like
% the \glostyle{super3col} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{super3colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{super3colborder} style:
%    \begin{macrocode}
  \glossarystyle{super3colborder}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns, a header with horizontal lines and a horizontal
% line in the tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline
        \bfseries\entryname&\bfseries\descriptionname&
        \bfseries\pagelistname\\\hline}%
     \tabletail{\hline}%
     \begin{supertabular}{|l|p{\glsdescwidth}|p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super4col}
% The \glostyle{super4col} glossary style has four columns,
% where the third column contains the value of the
% corresponding \gloskey{symbol} key used when that entry
% was defined.
%    \begin{macrocode}
\newglossarystyle{super4col}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{llll}}{%
     \end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row with the name in the first
% column, description in second column, symbol in third column
% and page list in last column:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\\}%
%    \end{macrocode}
% Sub entries on a row with no name, the description in the second
% column, symbol in third column and page list in last column:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\\}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\\\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super4colheader}
% The \glostyle{super4colheader} style is like
% the \glostyle{super4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{super4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{super4col} style:
%    \begin{macrocode}
  \glossarystyle{super4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns, a header and no tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
        \bfseries\symbolname &
        \bfseries\pagelistname\\}%
     \tabletail{}%
     \begin{supertabular}{llll}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super4colborder}
% The \glostyle{super4colborder} style is like
% the \glostyle{super4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{super4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{super4col} style:
%    \begin{macrocode}
  \glossarystyle{super4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|l|l|l|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{super4colheaderborder}
% The \glostyle{super4colheaderborder} style is like
% the \glostyle{super4col} but with a header and border.
%    \begin{macrocode}
\newglossarystyle{super4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{super4col} style:
%    \begin{macrocode}
  \glossarystyle{super4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a header bordered by horizontal lines and 
% a horizontal line in the tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline\bfseries\entryname&\bfseries\descriptionname&
        \bfseries\symbolname &
        \bfseries\pagelistname\\\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|l|l|l|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuper4col}
% The \glostyle{altsuper4col} glossary style is like 
% \glostyle{super4col} but has provision for multiline descriptions.
%    \begin{macrocode}
\newglossarystyle{altsuper4col}{%
%    \end{macrocode}
% Base it on the glostyle{super4col} style:
%    \begin{macrocode}
  \glossarystyle{super4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{lp{\glsdescwidth}lp{\glspagelistwidth}}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuper4colheader}
% The \glostyle{altsuper4colheader} style is like
% the \glostyle{altsuper4col} but with a header row.
%    \begin{macrocode}
\newglossarystyle{altsuper4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{super4colheader} style:
%    \begin{macrocode}
  \glossarystyle{super4colheader}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns, a header and no tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
      \bfseries\symbolname &
      \bfseries\pagelistname\\}\tabletail{}%
     \begin{supertabular}{lp{\glsdescwidth}lp{\glspagelistwidth}}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuper4colborder}
% The \glostyle{altsuper4colborder} style is like
% the \glostyle{altsuper4col} but with a border.
%    \begin{macrocode}
\newglossarystyle{altsuper4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{super4colborder} style:
%    \begin{macrocode}
  \glossarystyle{super4colborder}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}%
       {|l|p{\glsdescwidth}|l|p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuper4colheaderborder}
% The \glostyle{altsuper4colheaderborder} style is like
% the \glostyle{altsuper4col} but with a header and border.
%    \begin{macrocode}
\newglossarystyle{altsuper4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{super4colheaderborder} style:
%    \begin{macrocode}
  \glossarystyle{super4colheaderborder}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a header bordered by horizontal lines and 
% a horizontal line in the tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline
       \bfseries\entryname &
       \bfseries\descriptionname &
       \bfseries\symbolname &
       \bfseries\pagelistname\\\hline}%
     \tabletail{\hline}%
     \begin{supertabular}%
       {|l|p{\glsdescwidth}|l|p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%\iffalse
%    \begin{macrocode}
%</glossary-super.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-superragged.sty>
%    \end{macrocode}
%\fi
% \subsection{Glossary Styles using supertabular environment (glossary-superragged package)}
% The glossary styles defined in the \isty{glossary-superragged}
% package use the \env{supertabular} environment. These styles 
% are like those provided by the \isty{glossary-super} package, 
% except that the multiline columns have ragged right justification.
%    \begin{macrocode}
\ProvidesPackage{glossary-superragged}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
% Requires the \isty{array} package:
%    \begin{macrocode}
\RequirePackage{array}
%    \end{macrocode}
% Requires the \isty{supertabular} package:
%    \begin{macrocode}
\RequirePackage{supertabular}
%    \end{macrocode}
%\begin{macro}{\glsdescwidth}
% This is a length that governs the width of the description column.
% This may already have been defined.
%    \begin{macrocode}
\@ifundefined{glsdescwidth}{%
  \newlength\glsdescwidth
  \setlength{\glsdescwidth}{0.6\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspagelistwidth}
% This is a length that governs the width of the page list column.
% This may already have been defined.
%    \begin{macrocode}
\@ifundefined{glspagelistwidth}{%
  \newlength\glspagelistwidth
  \setlength{\glspagelistwidth}{0.1\hsize}
}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{superragged}
% The \glostyle{superragged} glossary style uses the
% \env{supertabular} environment.
%    \begin{macrocode}
\newglossarystyle{superragged}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}}}%
    {\end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries put in a row (name in first column,
% description and page list in second column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5%
      \tabularnewline}%
%    \end{macrocode}
% Sub entries put in a row (no name, description and page list
% in second column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6%
     \tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & \tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superraggedborder}
% The \glostyle{superraggedborder} style is like the above, but with 
% horizontal and vertical lines:
%    \begin{macrocode}
\newglossarystyle{superraggedborder}{%
%    \end{macrocode}
% Base it on the glostyle{superragged} style:
%    \begin{macrocode}
  \glossarystyle{superragged}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|>{\raggedright}p{\glsdescwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superraggedheader}
% The \glostyle{superraggedheader} style is like the
% \glostyle{super} style, but with a header:
%    \begin{macrocode}
\newglossarystyle{superraggedheader}{%
%    \end{macrocode}
% Base it on the glostyle{superragged} style:
%    \begin{macrocode}
  \glossarystyle{superragged}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and no tail:
%    \begin{macrocode}
\renewenvironment{theglossary}%
  {\tablehead{\bfseries \entryname & \bfseries \descriptionname
     \tabularnewline}%
   \tabletail{}%
   \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}}}%
  {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superraggedheaderborder}
% The \glostyle{superraggedheaderborder} style is like
% the \glostyle{superragged} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{superraggedheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{super} style:
%    \begin{macrocode}
  \glossarystyle{superragged}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and horizontal lines above and below the
% table:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline\bfseries \entryname &
       \bfseries \descriptionname\tabularnewline\hline}%
     \tabletail{\hline}
     \begin{supertabular}{|l|>{\raggedright}p{\glsdescwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superragged3col}
% The \glostyle{superragged3col} style is like the \glostyle{superragged} 
% style, but with 3 columns:
%    \begin{macrocode}
\newglossarystyle{superragged3col}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}%
        >{\raggedright}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row (name in first column, 
% description in second column, page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\tabularnewline}%
%    \end{macrocode}
% Sub entries on a row (no name, description in second column,
% page list in last column):
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &\tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superragged3colborder}
% The \glostyle{superragged3colborder} style is like the
% \glostyle{superragged3col} style, but with a border:
%    \begin{macrocode}
\newglossarystyle{superragged3colborder}{%
%    \end{macrocode}
% Base it on the glostyle{superragged3col} style:
%    \begin{macrocode}
  \glossarystyle{superragged3col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}{|l|>{\raggedright}p{\glsdescwidth}|%
       >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superragged3colheader}
% The \glostyle{superragged3colheader} style is like 
% the \glostyle{superragged3col} style but with a header row:
%    \begin{macrocode}
\newglossarystyle{superragged3colheader}{%
%    \end{macrocode}
% Base it on the glostyle{superragged3col} style:
%    \begin{macrocode}
  \glossarystyle{superragged3col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns, a header and no tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
       \bfseries\pagelistname\tabularnewline}\tabletail{}%
     \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}%
       >{\raggedright}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{superraggedright3colheaderborder}
% The \glostyle{superragged3colheaderborder} style is like
% the \glostyle{superragged3col} style but with a header and border:
%    \begin{macrocode}
\newglossarystyle{superragged3colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{superragged3colborder} style:
%    \begin{macrocode}
  \glossarystyle{superragged3colborder}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns, a header with horizontal lines and a horizontal
% line in the tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline
        \bfseries\entryname&\bfseries\descriptionname&
        \bfseries\pagelistname\tabularnewline\hline}%
     \tabletail{\hline}%
     \begin{supertabular}{|l|>{\raggedright}p{\glsdescwidth}|%
       >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuperragged4col}
% The \glostyle{altsuperragged4col} glossary style is like 
% \glostyle{altsuper4col} style in the \isty{glossary-super}
% package but uses ragged right formatting in the description 
% and page list columns.
%    \begin{macrocode}
\newglossarystyle{altsuperragged4col}{%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and no head or tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{}\tabletail{}%
     \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}l%
       >{\raggedright}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
%    \end{macrocode}
% Do nothing at the start of the table:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries on a row with the name in the first
% column, description in second column, symbol in third column
% and page list in last column:
%    \begin{macrocode}
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\tabularnewline}%
%    \end{macrocode}
% Sub entries on a row with no name, the description in the second% column, symbol in third column and page list in last column:
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & & &\tabularnewline\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuperragged4colheader}
% The \glostyle{altsuperragged4colheader} style is like
% the \glostyle{altsuperragged4col} style but with a header row.
%    \begin{macrocode}
\newglossarystyle{altsuperragged4colheader}{%
%    \end{macrocode}
% Base it on the glostyle{altsuperragged4col} style:
%    \begin{macrocode}
  \glossarystyle{altsuperragged4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns, a header and no tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
      \bfseries\symbolname &
      \bfseries\pagelistname\tabularnewline}\tabletail{}%
     \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}l%
       >{\raggedright}p{\glspagelistwidth}}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuperragged4colborder}
% The \glostyle{altsuperragged4colborder} style is like
% the \glostyle{altsuperragged4col} style but with a border.
%    \begin{macrocode}
\newglossarystyle{altsuperragged4colborder}{%
%    \end{macrocode}
% Base it on the glostyle{altsuperragged4col} style:
%    \begin{macrocode}
  \glossarystyle{altsuper4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a horizontal line in the head and tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline}\tabletail{\hline}%
     \begin{supertabular}%
       {|l|>{\raggedright}p{\glsdescwidth}|l|%
         >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{altsuperragged4colheaderborder}
% The \glostyle{altsuperragged4colheaderborder} style is like
% the \glostyle{altsuperragged4col} style but with a header and border.
%    \begin{macrocode}
\newglossarystyle{altsuperragged4colheaderborder}{%
%    \end{macrocode}
% Base it on the glostyle{altsuperragged4col} style:
%    \begin{macrocode}
  \glossarystyle{altsuperragged4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns and a header bordered by horizontal lines and 
% a horizontal line in the tail:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline
       \bfseries\entryname &
       \bfseries\descriptionname &
       \bfseries\symbolname &
       \bfseries\pagelistname\tabularnewline\hline}%
     \tabletail{\hline}%
     \begin{supertabular}%
       {|l|>{\raggedright}p{\glsdescwidth}|l|%
          >{\raggedright}p{\glspagelistwidth}|}}%
    {\end{supertabular}}%
}
%    \end{macrocode}
%\end{style}
%\iffalse
%    \begin{macrocode}
%</glossary-superragged.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-tree.sty>
%    \end{macrocode}
%\fi
%\subsection{Tree Styles (glossary-tree.sty)}
% The \isty{glossary-tree} style file defines glossary styles
% that have a tree-like structure. These are designed for
% hierarchical glossaries.
%    \begin{macrocode}
\ProvidesPackage{glossary-tree}[2012/09/21 v3.03 (NLCT)]
%    \end{macrocode}
%
%\begin{style}{index}
% The \glostyle{index} glossary style 
% is similar in style to the way indices are usually typeset
% using \cs{item}, \cs{subitem} and \cs{subsubitem}.
% The entry name is 
% set in bold. If an entry has a symbol, it is placed in 
% brackets after the name. Then the description is displayed,
% followed by the number list. This style allows up to three
% levels.
%    \begin{macrocode}
\newglossarystyle{index}{%
%    \end{macrocode}
% Set the paragraph indentation and skip and define \ics{item}
% to be the same as that used by \env{theindex}:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}%
     \let\item\@idxitem}%
    {}%
%    \end{macrocode}
% Do nothing at the start of the environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headers:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entry starts a new item with the name in bold
% followed by the symbol in brackets (if it exists), the description
% and the page list.
%    \begin{macrocode}
\renewcommand*{\glossaryentryfield}[5]{%
\item\glsentryitem{##1}\textbf{\glstarget{##1}{##2}}%
  \ifx\relax##4\relax
  \else
    \space(##4)%
  \fi
  \space ##3\glspostdescription \space ##5}%
%    \end{macrocode}
% Sub entries: level 1 entries use \ics{subitem}, levels greater 
% than~1 use \ics{subsubitem}. The level ("##1") shouldn't be 0,
% as that's catered by \cs{glossaryentryfield}, but for completeness,
% if the level is 0, \ics{item} is used. The name is put in bold,
% followed by the symbol in brackets (if it exists), the description
% and the page list.
%    \begin{macrocode}
  \renewcommand*{\glossarysubentryfield}[6]{%
    \ifcase##1\relax
      % level 0
      \item
    \or
      % level 1
      \subitem
      \glssubentryitem{##2}%
    \else
      % all other levels
      \subsubitem
    \fi
    \textbf{\glstarget{##2}{##3}}%
    \ifx\relax##5\relax
    \else
      \space(##5)%
    \fi
    \space##4\glspostdescription\space ##6}%
%    \end{macrocode}
% Vertical gap between groups is the same as that used by indices:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{indexgroup}
% The \glostyle{indexgroup} style is like the \glostyle{index}
% style but has headings.
%    \begin{macrocode}
\newglossarystyle{indexgroup}{%
%    \end{macrocode}
% Base it on the glostyle{index} style:
%    \begin{macrocode}
  \glossarystyle{index}%
%    \end{macrocode}
% Add a heading for each group. This puts the group's title in
% bold followed by a vertical gap.
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \item\textbf{\glsgetgrouptitle{##1}}\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{indexhypergroup}
% The \glostyle{indexhypergroup} style is like the
% \glostyle{indexgroup} style but has hyper navigation.
%    \begin{macrocode}
\newglossarystyle{indexhypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{index} style:
%    \begin{macrocode}
  \glossarystyle{index}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the glossary:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \item\textbf{\glsnavigation}\indexspace}%
%    \end{macrocode}
% Add a heading for each group (with a target). The group's title is
% in bold followed by a vertical gap.
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \item\textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}%
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{tree}
% The \glostyle{tree} glossary style 
% is similar in style to the \glostyle{index} style, but
% can have arbitrary levels.
%    \begin{macrocode}
\newglossarystyle{tree}{%
%    \end{macrocode}
% Set the paragraph indentation and skip:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}}%
    {}%
%    \end{macrocode}
% Do nothing at the start of the \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries: name in bold, followed by symbol in
% brackets (if it exists), the description and the page list:
%    \begin{macrocode}
  \renewcommand{\glossaryentryfield}[5]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\textbf{\glstarget{##1}{##2}}%
    \ifx\relax##4\relax
    \else
      \space(##4)%
    \fi
    \space ##3\glspostdescription \space ##5\par}%
%    \end{macrocode}
% Sub entries: level \meta{n} is indented by \meta{n} times
% \ics{glstreeindent}. The name is in bold, followed by the
% symbol in brackets (if it exists), the description and the
% page list.
%    \begin{macrocode}
  \renewcommand{\glossarysubentryfield}[6]{%
    \hangindent##1\glstreeindent\relax
    \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \textbf{\glstarget{##2}{##3}}%
    \ifx\relax##5\relax
    \else
      \space(##5)%
    \fi
    \space##4\glspostdescription\space ##6\par}%
%    \end{macrocode}
% Vertical gap between groups is the same as that used by
% indices:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{treegroup}
% Like the \glostyle{tree} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{treegroup}{%
%    \end{macrocode}
% Base it on the glostyle{tree} style:
%    \begin{macrocode}
  \glossarystyle{tree}%
%    \end{macrocode}
% Each group has a heading (in bold) followed by a vertical gap):
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{treehypergroup}
% The \glostyle{treehypergroup} style is like the \glostyle{treegroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{treehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{tree} style:
%    \begin{macrocode}
  \glossarystyle{tree}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Each group has a heading (in bold with a target) followed by a 
% vertical gap):
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par\noindent
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{macro}{\glstreeindent}
% Length governing left indent for each level of the \glostyle{tree}
% style.
%    \begin{macrocode}
\newlength\glstreeindent
\setlength{\glstreeindent}{10pt}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{treenoname}
% The \glostyle{treenoname} glossary style 
% is like the \glostyle{tree} style, but
% doesn't print the name or symbol for sub-levels.
%    \begin{macrocode}
\newglossarystyle{treenoname}{%
%    \end{macrocode}
% Set the paragraph indentation and skip:
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\setlength{\parindent}{0pt}%
     \setlength{\parskip}{0pt plus 0.3pt}}%
    {}%
%    \end{macrocode}
% No header:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
%    \end{macrocode}
% No group headings:
%    \begin{macrocode}
\renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Main (level 0) entries: the name is in bold, followed by the
% symbol in brackets (if it exists), the description and the
% page list.
%    \begin{macrocode}
  \renewcommand{\glossaryentryfield}[5]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\textbf{\glstarget{##1}{##2}}%
    \ifx\relax##4\relax
    \else
      \space(##4)%
    \fi
    \space ##3\glspostdescription \space ##5\par}%
%    \end{macrocode}
% Sub entries: level \meta{n} is indented by \meta{n} times
% \ics{glstreeindent}. The name and symbol are omitted. The
% description followed by the page list are displayed.
%    \begin{macrocode}
  \renewcommand{\glossarysubentryfield}[6]{%
    \hangindent##1\glstreeindent\relax
    \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \glstarget{##2}{\strut}%
    ##4\glspostdescription\space ##6\par}%
%    \end{macrocode}
% Vertical gap between groups is the same as that used by indices:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{treenonamegroup}
% Like the \glostyle{treenoname} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{treenonamegroup}{%
%    \end{macrocode}
% Base it on the glostyle{treenoname} style:
%    \begin{macrocode}
  \glossarystyle{treenoname}%
%    \end{macrocode}
% Give each group a heading:
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{treenonamehypergroup}
% The \glostyle{treenonamehypergroup} style is like the \glostyle{treenonamegroup}
% style, but has a set of links to the groups at the
% start of the glossary.
%    \begin{macrocode}
\newglossarystyle{treenonamehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{treenoname} style:
%    \begin{macrocode}
  \glossarystyle{treenoname}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Each group has a heading (in bold with a target) followed by a 
% vertical gap):
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par\noindent
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{macro}{\glssetwidest}
% \cs{glssetwidest}\oarg{level}\marg{text} sets the widest
% text for the given level. It is used by the
% \glostyle{alttree} glossary styles to determine the
% indentation of each level.
%    \begin{macrocode}
\newcommand*{\glssetwidest}[2][0]{%
  \expandafter\def\csname @glswidestname\romannumeral#1\endcsname{%
    #2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glswidestname}
% Initialise \cs{@glswidestname}.
%    \begin{macrocode}
\newcommand*{\@glswidestname}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{style}{alttree}
% The \glostyle{alttree} glossary style 
% is similar in style to the \glostyle{tree} style, but
% the indentation is obtained from the width of 
% \cs{@glswidestname} which is set using \cs{glssetwidest}.
%    \begin{macrocode}
\newglossarystyle{alttree}{%
%    \end{macrocode}
% Redefine \env{theglossary} environment.
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\def\@gls@prevlevel{-1}%
     \mbox{}\par}%
    {\par}%
%    \end{macrocode}
% Set the header and group headers to nothing.
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{}%
  \renewcommand*{\glsgroupheading}[1]{}%
%    \end{macrocode}
% Redefine the way that the level~0 entries are displayed.
%    \begin{macrocode}
  \renewcommand{\glossaryentryfield}[5]{%
%    \end{macrocode}
% If the level hasn't changed, keep the same settings, otherwise
% change \cs{glstreeindent} accordingly.
%    \begin{macrocode}
    \ifnum\@gls@prevlevel=0\relax
    \else
%    \end{macrocode}
% Find out how big the indentation should be by measuring the
% widest entry.
%    \begin{macrocode}
       \settowidth{\glstreeindent}{\textbf{\@glswidestname\space}}%
%    \end{macrocode}
% Set the hangindent and paragraph indent.
%    \begin{macrocode}
      \hangindent\glstreeindent
      \parindent\glstreeindent
    \fi
%    \end{macrocode}
% Put the name to the left of the paragraph block.
%    \begin{macrocode}
    \makebox[0pt][r]{\makebox[\glstreeindent][l]{%
       \glsentryitem{##1}\textbf{\glstarget{##1}{##2}}}}%
%    \end{macrocode}
% If the symbol is missing, ignore it, otherwise put it in 
% brackets.
%    \begin{macrocode}
    \ifx\relax##4\relax
    \else
      (##4)\space
    \fi
%    \end{macrocode}
% Do the description followed by the description terminator and
% location list.
%    \begin{macrocode}
    ##3\glspostdescription \space ##5\par
%    \end{macrocode}
% Set the previous level to 0.
%    \begin{macrocode}
    \def\@gls@prevlevel{0}%
  }%
%    \end{macrocode}
% Redefine the way sub-entries are displayed.
%    \begin{macrocode}
  \renewcommand{\glossarysubentryfield}[6]{%
%    \end{macrocode}
% Increment and display the sub-entry counter if this is a level~1
% entry and the sub-entry counter is in use.
%    \begin{macrocode}
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
%    \end{macrocode}
% If the level hasn't changed, keep the same settings, otherwise
% adjust \cs{glstreeindent} accordingly.
%    \begin{macrocode}
    \ifnum\@gls@prevlevel=##1\relax
    \else
%    \end{macrocode}
% Compute the widest entry for this level, or for level~0 if not
% defined for this level. Store in \cs{gls@tmplen}
%    \begin{macrocode}
      \@ifundefined{@glswidestname\romannumeral##1}{%
        \settowidth{\gls@tmplen}{\textbf{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\textbf{%
           \csname @glswidestname\romannumeral##1\endcsname\space}}}%
%    \end{macrocode}
% Determine if going up or down a level
%    \begin{macrocode}
      \ifnum\@gls@prevlevel<##1\relax
%    \end{macrocode}
% Depth has increased, so add the width of the widest entry to
% \cs{glstreeindent}.
%    \begin{macrocode}
         \setlength\glstreeindent\gls@tmplen
         \addtolength\glstreeindent\parindent
         \parindent\glstreeindent
      \else
%    \end{macrocode}
% Depth has decreased, so subtract width of the widest entry 
% from the previous level to \cs{glstreeindent}. First 
% determine the width of the widest entry for the previous level
% and store in \cs{glstreeindent}.
%    \begin{macrocode}
         \@ifundefined{@glswidestname\romannumeral\@gls@prevlevel}{%
           \settowidth{\glstreeindent}{\textbf{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\textbf{%
              \csname @glswidestname\romannumeral\@gls@prevlevel
                 \endcsname\space}}}%
%    \end{macrocode}
% Subtract this length from the previous level's paragraph indent
% and set to \cs{glstreeindent}.
%    \begin{macrocode}
         \addtolength\parindent{-\glstreeindent}%
         \setlength\glstreeindent\parindent
      \fi
    \fi
%    \end{macrocode}
% Set the hanging indentation.
%    \begin{macrocode}
    \hangindent\glstreeindent
%    \end{macrocode}
% Put the name to the left of the paragraph block
%    \begin{macrocode}
    \makebox[0pt][r]{\makebox[\gls@tmplen][l]{%
      \textbf{\glstarget{##2}{##3}}}}%
%    \end{macrocode}
% If the symbol is missing, ignore it, otherwise put it in 
% brackets.
%    \begin{macrocode}
    \ifx##5\relax\relax
    \else
      (##5)\space
    \fi
%    \end{macrocode}
% Do the description followed by the description terminator and
% location list.
%    \begin{macrocode}
    ##4\glspostdescription\space ##6\par
%    \end{macrocode}
% Set the previous level macro to the current level.
%    \begin{macrocode}
    \def\@gls@prevlevel{##1}%
  }%
%    \end{macrocode}
% Vertical gap between groups is the same as that used by indices:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{alttreegroup}
% Like the \glostyle{alttree} style but the glossary groups have
% headings.
%    \begin{macrocode}
\newglossarystyle{alttreegroup}{%
%    \end{macrocode}
% Base it on the glostyle{alttree} style:
%    \begin{macrocode}
  \glossarystyle{alttree}%
%    \end{macrocode}
% Give each group a heading.
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsgetgrouptitle{##1}}\par\indexspace}%
}
%    \end{macrocode}
%\end{style}
%
%\begin{style}{alttreehypergroup}
% The \glostyle{alttreehypergroup} style is like the 
% \glostyle{alttreegroup} style, but has a set of links to the 
% groups at the start of the glossary.
%    \begin{macrocode}
\newglossarystyle{alttreehypergroup}{%
%    \end{macrocode}
% Base it on the glostyle{alttree} style:
%    \begin{macrocode}
  \glossarystyle{alttree}%
%    \end{macrocode}
% Put the navigation links in the header
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsnavigation}\par\indexspace}%
%    \end{macrocode}
% Put a hypertarget at the start of each group
%    \begin{macrocode}
  \renewcommand*{\glsgroupheading}[1]{%
    \par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \textbf{\glsnavhypertarget{##1}{\glsgetgrouptitle{##1}}}\par
    \indexspace}}
%    \end{macrocode}
%\end{style}
%
%\iffalse
%    \begin{macrocode}
%</glossary-tree.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-compatible-207.sty>
%    \end{macrocode}
%\fi
%\section{glossaries-compatible-207}
% Provides compatibility with version 2.07 and below. This uses
% original \sty{glossaries} xindy and makeindex formatting, so can
% be used with old documents that had customized style files, but
% hyperlinks may not work properly.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-compatible-207}[2011/04/02 v1.0 (NLCT)]
%    \end{macrocode}
%\begin{macro}{\GlsAddXdyAttribute}
% Adds an attribute in old format.
%    \begin{macrocode}
\ifglsxindy
  \renewcommand*\GlsAddXdyAttribute[1]{%
  \edef\@xdyattributes{\@xdyattributes ^^J \string"#1\string"}%
  \expandafter\toks@\expandafter{\@xdylocref}%
  \edef\@xdylocref{\the\toks@ ^^J%
  (markup-locref
  :open \string"\string~n\string\setentrycounter
    {\noexpand\glscounter}%
    \expandafter\string\csname#1\endcsname
    \expandafter\@gobble\string\{\string" ^^J
  :close \string"\expandafter\@gobble\string\}\string" ^^J
  :attr \string"#1\string")}}
%    \end{macrocode}
% Only has an effect before \ics{writeist}:
%    \begin{macrocode}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsAddXdyCounters}
%    \begin{macrocode}
\renewcommand*\GlsAddXdyCounters[1]{%
  \GlossariesWarning{\string\GlsAddXdyCounters\space not available
    in compatibility mode.}%
}
%    \end{macrocode}
%\end{macro}
% Add predefined attributes
%    \begin{macrocode}
  \GlsAddXdyAttribute{glsnumberformat}
  \GlsAddXdyAttribute{textrm}
  \GlsAddXdyAttribute{textsf}
  \GlsAddXdyAttribute{texttt}
  \GlsAddXdyAttribute{textbf}
  \GlsAddXdyAttribute{textmd}
  \GlsAddXdyAttribute{textit}
  \GlsAddXdyAttribute{textup}
  \GlsAddXdyAttribute{textsl}
  \GlsAddXdyAttribute{textsc}
  \GlsAddXdyAttribute{emph}
  \GlsAddXdyAttribute{glshypernumber}
  \GlsAddXdyAttribute{hyperrm}
  \GlsAddXdyAttribute{hypersf}
  \GlsAddXdyAttribute{hypertt}
  \GlsAddXdyAttribute{hyperbf}
  \GlsAddXdyAttribute{hypermd}
  \GlsAddXdyAttribute{hyperit}
  \GlsAddXdyAttribute{hyperup}
  \GlsAddXdyAttribute{hypersl}
  \GlsAddXdyAttribute{hypersc}
  \GlsAddXdyAttribute{hyperemph}
%    \end{macrocode}
%
%\begin{macro}{\GlsAddXdyLocation}
% Restore v2.07 definition:
%    \begin{macrocode}
\ifglsxindy
   \renewcommand*{\GlsAddXdyLocation}[2]{%
     \edef\@xdyuserlocationdefs{%
        \@xdyuserlocationdefs ^^J%
        (define-location-class \string"#1\string"^^J\space\space
        \space(#2))
     }%
     \edef\@xdyuserlocationnames{%
        \@xdyuserlocationnames^^J\space\space\space
        \string"#1\string"}%
   }
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@do@wrglossary}
%    \begin{macrocode}
\renewcommand{\@do@wrglossary}[1]{%
%    \end{macrocode}
% Determine whether to use \app{xindy} or \app{makeindex}
% syntax
%    \begin{macrocode}
\ifglsxindy
%    \end{macrocode}
% Need to determine if the formatting information starts with
% a ( or ) indicating a range.
%    \begin{macrocode}
  \expandafter\@glo@check@mkidxrangechar\@glsnumberformat\@nil
  \def\@glo@range{}%
  \expandafter\if\@glo@prefix(\relax
    \def\@glo@range{:open-range}%
  \else
    \expandafter\if\@glo@prefix)\relax
      \def\@glo@range{:close-range}%
    \fi
  \fi
%    \end{macrocode}
% Get the location and escape any special characters
%    \begin{macrocode}
  \protected@edef\@glslocref{\theglsentrycounter}%
  \@gls@checkmkidxchars\@glslocref
%    \end{macrocode}
% Write to the glossary file using \app{xindy} syntax.
%    \begin{macrocode}
  \glossary[\csname glo@#1@type\endcsname]{%
  (indexentry :tkey (\csname glo@#1@index\endcsname)
    :locref \string"\@glslocref\string" %
    :attr \string"\@glo@suffix\string" \@glo@range
  )
  }%
\else
%    \end{macrocode}
% Convert the format information into the format required for
% \app{makeindex}
%    \begin{macrocode}
  \@set@glo@numformat\@glo@numfmt\@gls@counter\@glsnumberformat
%    \end{macrocode}
% Write to the glossary file using \app{makeindex} syntax.
%    \begin{macrocode}
  \glossary[\csname glo@#1@type\endcsname]{%
  \string\glossaryentry{\csname glo@#1@index\endcsname
    \@gls@encapchar\@glo@numfmt}{\theglsentrycounter}}%
\fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@set@glo@numformat}
% Only had 3 arguments in v2.07
%    \begin{macrocode}
\def\@set@glo@numformat#1#2#3{%
  \expandafter\@glo@check@mkidxrangechar#3\@nil
  \protected@edef#1{%
    \@glo@prefix setentrycounter[]{#2}%
    \expandafter\string\csname\@glo@suffix\endcsname
  }%
  \@gls@checkmkidxchars#1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\writeist}
% Redefine \cs{writeist} back to the way it was in v2.07, but change
% \cs{istfile} to \cs{glswrite}.
%    \begin{macrocode}
\ifglsxindy
  \def\writeist{%
    \openout\glswrite=\istfilename
    \write\glswrite{;; xindy style file created by the glossaries
      package in compatible-2.07 mode}%
    \write\glswrite{;; for document '\jobname' on
      \the\year-\the\month-\the\day}%
    \write\glswrite{^^J; required styles^^J}
    \@for\@xdystyle:=\@xdyrequiredstyles\do{%
       \ifx\@xdystyle\@empty
       \else
         \protected@write\glswrite{}{(require
           \string"\@xdystyle.xdy\string")}%
       \fi
    }%
    \write\glswrite{^^J%
       ; list of allowed attributes (number formats)^^J}%
    \write\glswrite{(define-attributes ((\@xdyattributes)))}%
    \write\glswrite{^^J; user defined alphabets^^J}%
    \write\glswrite{\@xdyuseralphabets}%
    \write\glswrite{^^J; location class definitions^^J}%
    \protected@edef\@gls@roman{\@roman{0\string"
      \string"roman-numbers-lowercase\string" :sep \string"}}%
    \@onelevel@sanitize\@gls@roman
    \edef\@tmp{\string" \string"roman-numbers-lowercase\string"
       :sep \string"}%
    \@onelevel@sanitize\@tmp
    \ifx\@tmp\@gls@roman
       \write\glswrite{(define-location-class
         \string"roman-page-numbers\string"^^J\space\space\space
         (\string"roman-numbers-lowercase\string")
         :min-range-length \@glsminrange)}%
    \else
       \write\glswrite{(define-location-class
         \string"roman-page-numbers\string"^^J\space\space\space
         (:sep "\@gls@roman")
         :min-range-length \@glsminrange)}%
    \fi
    \write\glswrite{(define-location-class
      \string"Roman-page-numbers\string"^^J\space\space\space
      (\string"roman-numbers-uppercase\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{(define-location-class
      \string"arabic-page-numbers\string"^^J\space\space\space
      (\string"arabic-numbers\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{(define-location-class
      \string"alpha-page-numbers\string"^^J\space\space\space
      (\string"alpha\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{(define-location-class
      \string"Alpha-page-numbers\string"^^J\space\space\space
      (\string"ALPHA\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{(define-location-class
      \string"Appendix-page-numbers\string"^^J\space\space\space
      (\string"ALPHA\string"
       :sep \string"\@glsAlphacompositor\string"
       \string"arabic-numbers\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{(define-location-class
      \string"arabic-section-numbers\string"^^J\space\space\space
      (\string"arabic-numbers\string"
       :sep \string"\glscompositor\string"
       \string"arabic-numbers\string")
         :min-range-length \@glsminrange)}%
    \write\glswrite{^^J; user defined location classes}%
    \write\glswrite{\@xdyuserlocationdefs}%
    \write\glswrite{^^J; define cross-reference class^^J}%
    \write\glswrite{(define-crossref-class \string"see\string"
      :unverified )}%
    \write\glswrite{(markup-crossref-list
       :class \string"see\string"^^J\space\space\space
       :open \string"\string\glsseeformat\string"
       :close \string"{}\string")}%
    \write\glswrite{^^J; define the order of the location classes}%
    \write\glswrite{(define-location-class-order
       (\@xdylocationclassorder))}%
    \write\glswrite{^^J; define the glossary markup^^J}%
    \write\glswrite{(markup-index^^J\space\space\space
      :open \string"\string
      \glossarysection[\string\glossarytoctitle]{\string
      \glossarytitle}\string\glossarypreamble\string~n\string\begin
      {theglossary}\string\glossaryheader\string~n\string" ^^J\space
      \space\space:close \string"\expandafter\@gobble
        \string\%\string~n\string
        \end{theglossary}\string\glossarypostamble
        \string~n\string" ^^J\space\space\space
      :tree)}%
    \write\glswrite{(markup-letter-group-list
      :sep \string"\string\glsgroupskip\string~n\string")}%
    \write\glswrite{(markup-indexentry
      :open \string"\string\relax \string\glsresetentrylist
         \string~n\string")}%
    \write\glswrite{(markup-locclass-list :open
     \string"\glsopenbrace\string\glossaryentrynumbers
       \glsopenbrace\string\relax\space \string"^^J\space\space\space
     :sep \string", \string"
     :close \string"\glsclosebrace\glsclosebrace\string")}%
    \write\glswrite{(markup-locref-list
     :sep \string"\string\delimN\space\string")}%
    \write\glswrite{(markup-range
     :sep \string"\string\delimR\space\string")}%
    \@onelevel@sanitize\gls@suffixF
    \@onelevel@sanitize\gls@suffixFF
    \ifx\gls@suffixF\@empty
    \else
      \write\glswrite{(markup-range
      :close "\gls@suffixF" :length 1 :ignore-end)}%
    \fi
    \ifx\gls@suffixFF\@empty
    \else
      \write\glswrite{(markup-range
      :close "\gls@suffixFF" :length 2 :ignore-end)}%
    \fi
    \write\glswrite{^^J; define format to use for locations^^J}%
    \write\glswrite{\@xdylocref}%
    \write\glswrite{^^J; define letter group list format^^J}%
    \write\glswrite{(markup-letter-group-list
     :sep \string"\string\glsgroupskip\string~n\string")}%
    \write\glswrite{^^J; letter group headings^^J}%
    \write\glswrite{(markup-letter-group
      :open-head \string"\string\glsgroupheading
      \glsopenbrace\string"^^J\space\space\space
      :close-head \string"\glsclosebrace\string")}%
    \write\glswrite{^^J; additional letter groups^^J}%
    \write\glswrite{\@xdylettergroups}%
    \write\glswrite{^^J; additional sort rules^^J}
    \write\glswrite{\@xdysortrules}%
  \noist}
\else
  \edef\@gls@actualchar{\string?}
  \edef\@gls@encapchar{\string|}
  \edef\@gls@levelchar{\string!}
  \edef\@gls@quotechar{\string"}
  \def\writeist{\relax
    \openout\glswrite=\istfilename
    \write\glswrite{\expandafter\@gobble\string\% makeindex style file
      created by the glossaries package}
    \write\glswrite{\expandafter\@gobble\string\% for document
      '\jobname' on \the\year-\the\month-\the\day}
    \write\glswrite{actual '\@gls@actualchar'}
    \write\glswrite{encap '\@gls@encapchar'}
    \write\glswrite{level '\@gls@levelchar'}
    \write\glswrite{quote '\@gls@quotechar'}
    \write\glswrite{keyword \string"\string\\glossaryentry\string"}
    \write\glswrite{preamble \string"\string\\glossarysection[\string
      \\glossarytoctitle]{\string\\glossarytitle}\string
      \\glossarypreamble\string\n\string\\begin{theglossary}\string
      \\glossaryheader\string\n\string"}
    \write\glswrite{postamble \string"\string\%\string\n\string
      \\end{theglossary}\string\\glossarypostamble\string\n
      \string"}
    \write\glswrite{group_skip \string"\string\\glsgroupskip\string\n
      \string"}
    \write\glswrite{item_0 \string"\string\%\string\n\string"}
    \write\glswrite{item_1 \string"\string\%\string\n\string"}
    \write\glswrite{item_2 \string"\string\%\string\n\string"}
    \write\glswrite{item_01 \string"\string\%\string\n\string"}
    \write\glswrite{item_x1
      \string"\string\\relax \string\\glsresetentrylist\string\n
      \string"}
    \write\glswrite{item_12 \string"\string\%\string\n\string"}
    \write\glswrite{item_x2
      \string"\string\\relax \string\\glsresetentrylist\string\n
      \string"}
    \write\glswrite{delim_0 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_1 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_2 \string"\string\{\string
      \\glossaryentrynumbers\string\{\string\\relax \string"}
    \write\glswrite{delim_t \string"\string\}\string\}\string"}
    \write\glswrite{delim_n \string"\string\\delimN \string"}
    \write\glswrite{delim_r \string"\string\\delimR \string"}
    \write\glswrite{headings_flag 1}
    \write\glswrite{heading_prefix
       \string"\string\\glsgroupheading\string\{\string"}
    \write\glswrite{heading_suffix
       \string"\string\}\string\\relax
       \string\\glsresetentrylist \string"}
    \write\glswrite{symhead_positive \string"glssymbols\string"}
    \write\glswrite{numhead_positive \string"glsnumbers\string"}
    \write\glswrite{page_compositor \string"\glscompositor\string"}
    \@gls@escbsdq\gls@suffixF
    \@gls@escbsdq\gls@suffixFF
    \ifx\gls@suffixF\@empty
    \else
      \write\glswrite{suffix_2p \string"\gls@suffixF\string"}
    \fi
    \ifx\gls@suffixFF\@empty
    \else
      \write\glswrite{suffix_3p \string"\gls@suffixFF\string"}
    \fi
    \noist
  }
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\noist}
%    \begin{macrocode}
\renewcommand*{\noist}{\let\writeist\relax}
%    \end{macrocode}
%\end{macro}
%\iffalse
%    \begin{macrocode}
%</glossaries-compatible-207.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-accsupp.sty>
%    \end{macrocode}
%\fi
%\section{Accessibility Support (glossaries-accsupp Code)}
%\label{sec:code:accsupp}
% The \isty{glossaries-accsupp} package is experimental. It is
% intended to provide a means of using the PDF accessibilty support
% in glossary entries. See the \isty{accsupp} documentation for
% further details about accessibility support.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
%    \end{macrocode}
% Package version number now in line with main glossaries package number 
% but will only be updated when \texttt{glossaries-accsupp.sty} is
% modified.
%    \begin{macrocode}
\ProvidesPackage{glossaries-accsupp}[2011/04/02 v3.0 (NLCT)
  Experimental glossaries accessibility]
%    \end{macrocode}
% Pass all options to \sty{glossaries}:
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{glossaries}}
%    \end{macrocode}
% Process options:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
% Required packages:
%    \begin{macrocode}
\RequirePackage{glossaries}
\RequirePackage{accsupp}
%    \end{macrocode}
% 
%\subsection{Defining Replacement Text}
% The version 0.1 stored the replacement text in the
% \gloskey{symbol} key. This has been changed to use the
% new keys defined here. Example of use:
%\begin{verbatim}
%\newglossaryentry{dr}{name=Dr,description={},access={Doctor}}
%\end{verbatim}
%\begin{key}{access}
% The replacement text corresponding to the \gloskey{name} key:
%    \begin{macrocode}
\define@key{glossentry}{access}{%
  \def\@glo@access{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{textaccess}
% The replacement text corresponding to the \gloskey{text} key:
%    \begin{macrocode}
\define@key{glossentry}{textaccess}{%
  \def\@glo@textaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{firstaccess}
% The replacement text corresponding to the \gloskey{first} key:
%    \begin{macrocode}
\define@key{glossentry}{firstaccess}{%
  \def\@glo@firstaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{pluralaccess}
% The replacement text corresponding to the \gloskey{plural} key:
%    \begin{macrocode}
\define@key{glossentry}{pluralaccess}{%
  \def\@glo@pluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{firstpluralaccess}
% The replacement text corresponding to the \gloskey{firstplural} key:
%    \begin{macrocode}
\define@key{glossentry}{firstpluralaccess}{%
  \def\@glo@firstpluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{symbolaccess}
% The replacement text corresponding to the \gloskey{symbol} key:
%    \begin{macrocode}
\define@key{glossentry}{symbolaccess}{%
  \def\@glo@symbolaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{symbolpluralaccess}
% The replacement text corresponding to the \gloskey{symbolplural} key:
%    \begin{macrocode}
\define@key{glossentry}{symbolpluralaccess}{%
  \def\@glo@symbolpluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{descriptionaccess}
% The replacement text corresponding to the \gloskey{description} key:
%    \begin{macrocode}
\define@key{glossentry}{descriptionaccess}{%
  \def\@glo@descaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{descriptionpluralaccess}
% The replacement text corresponding to the \gloskey{descriptionplural} key:
%    \begin{macrocode}
\define@key{glossentry}{descriptionpluralaccess}{%
  \def\@glo@descpluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{shortaccess}
% The replacement text corresponding to the \gloskey{short} key:
%    \begin{macrocode}
\define@key{glossentry}{shortaccess}{%
  \def\@glo@shortaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{shortpluralaccess}
% The replacement text corresponding to the \gloskey{shortplural} key:
%    \begin{macrocode}
\define@key{glossentry}{shortpluralaccess}{%
  \def\@glo@shortpluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{longaccess}
% The replacement text corresponding to the \gloskey{long} key:
%    \begin{macrocode}
\define@key{glossentry}{longaccess}{%
  \def\@glo@longaccess{#1}%
}
%    \end{macrocode}
%\end{key}
%\begin{key}{longpluralaccess}
% The replacement text corresponding to the \gloskey{longplural} key:
%    \begin{macrocode}
\define@key{glossentry}{longpluralaccess}{%
  \def\@glo@longpluralaccess{#1}%
}
%    \end{macrocode}
%\end{key}
% There are no equivalent keys for the \gloskey{user1}\ldots
%\gloskey{user6} keys. The replacement text would have to be
% explicitly put in the value, e.g.,
% "user1={\glsaccsupp{inches}{in}}".
%
%\begin{macro}{\@gls@noaccess}
% Indicates that no replacement text has been provided.
%    \begin{macrocode}
\def\@gls@noaccess{\relax}
%    \end{macrocode}
%\end{macro}
%
% Add to the start hook (the \gloskey{access} key is initialised to
% the value of the \gloskey{symbol} key at the start for backwards 
% compatibility):
%    \begin{macrocode}
\let\@gls@oldnewglossaryentryprehook\@newglossaryentryprehook
\renewcommand*{\@newglossaryentryprehook}{%
  \@gls@oldnewglossaryentryprehook
  \def\@glo@access{\@glo@symbol}%
%    \end{macrocode}
% Initialise the other keys:
%    \begin{macrocode}
  \def\@glo@textaccess{\@glo@access}%
  \def\@glo@firstaccess{\@glo@access}%
  \def\@glo@pluralaccess{\@glo@textaccess}%
  \def\@glo@firstpluralaccess{\@glo@pluralaccess}%
  \def\@glo@symbolaccess{\relax}%
  \def\@glo@symbolpluralaccess{\@glo@symbolaccess}%
  \def\@glo@descaccess{\relax}%
  \def\@glo@descpluralaccess{\@glo@descaccess}%
  \def\@glo@shortaccess{\relax}%
  \def\@glo@shortpluralaccess{\@glo@shortaccess}%
  \def\@glo@longaccess{\relax}%
  \def\@glo@longpluralaccess{\@glo@longaccess}%
}
%    \end{macrocode}
% Add to the end hook:
%    \begin{macrocode}
\let\@gls@oldnewglossaryentryposthook\@newglossaryentryposthook
\renewcommand*{\@newglossaryentryposthook}{%
  \@gls@oldnewglossaryentryposthook
%    \end{macrocode}
% Store the access information:
%    \begin{macrocode}
  \expandafter
    \protected@xdef\csname glo@\@glo@label @access\endcsname{%
      \@glo@access}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @textaccess\endcsname{%
      \@glo@textaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @firstaccess\endcsname{%
      \@glo@firstaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @pluralaccess\endcsname{%
      \@glo@pluralaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @firstpluralaccess\endcsname{%
      \@glo@firstpluralaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @symbolaccess\endcsname{%
      \@glo@symbolaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @symbolpluralaccess\endcsname{%
      \@glo@symbolpluralaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @descaccess\endcsname{%
      \@glo@descaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @descpluralaccess\endcsname{%
      \@glo@descpluralaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @shortaccess\endcsname{%
      \@glo@shortaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @shortpluralaccess\endcsname{%
      \@glo@shortpluralaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @longaccess\endcsname{%
      \@glo@longaccess}%
  \expandafter
    \protected@xdef\csname glo@\@glo@label @longpluralaccess\endcsname{%
      \@glo@longpluralaccess}%
}
%    \end{macrocode}
%
%\subsection{Accessing Replacement Text}
%\begin{macro}{\glsentryaccess}
% Get the value of the \gloskey{access} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentryaccess}[1]{%
  \csname glo@#1@access\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrytextaccess}
% Get the value of the \gloskey{textaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrytextaccess}[1]{%
  \csname glo@#1@textaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryfirstaccess}
% Get the value of the \gloskey{firstaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentryfirstaccess}[1]{%
  \csname glo@#1@firstaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrypluralaccess}
% Get the value of the \gloskey{pluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrypluralaccess}[1]{%
  \csname glo@#1@pluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryfirstpluralaccess}
% Get the value of the \gloskey{firstpluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentryfirstpluralaccess}[1]{%
  \csname glo@#1@firstpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrysymbolaccess}
% Get the value of the \gloskey{symbolaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrysymbolaccess}[1]{%
  \csname glo@#1@symbolaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrysymbolpluralaccess}
% Get the value of the \gloskey{symbolpluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrysymbolpluralaccess}[1]{%
  \csname glo@#1@symbolpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrydescaccess}
% Get the value of the \gloskey{descriptionaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrydescaccess}[1]{%
  \csname glo@#1@descaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrydescpluralaccess}
% Get the value of the \gloskey{descriptionpluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrydescpluralaccess}[1]{%
  \csname glo@#1@descaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryshortaccess}
% Get the value of the \gloskey{shortaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentryshortaccess}[1]{%
  \csname glo@#1@shortaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryshortpluralaccess}
% Get the value of the \gloskey{shortpluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentryshortpluralaccess}[1]{%
  \csname glo@#1@shortpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrylongaccess}
% Get the value of the \gloskey{longaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrylongaccess}[1]{%
  \csname glo@#1@longaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrylongpluralaccess}
% Get the value of the \gloskey{longpluralaccess} key for the entry with
% the given label:
%    \begin{macrocode}
\newcommand*{\glsentrylongpluralaccess}[1]{%
  \csname glo@#1@longpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccsupp}
%\cs{glsaccsupp}\marg{replacement text}\marg{text}\\[10pt]
% This can be redefined to use "E" or "Alt" instead of
% "ActualText". (I don't have the software to test the "E" or
% "Alt" options.)
%    \begin{macrocode}
\newcommand*{\glsaccsupp}[2]{%
  \BeginAccSupp{ActualText=#1}#2\EndAccSupp{}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\xglsaccsupp}
% Fully expands replacement text before calling \cs{glsaccsupp}
%    \begin{macrocode}
\newcommand*{\xglsaccsupp}[2]{%
   \protected@edef\@gls@replacementtext{#1}%
   \expandafter\glsaccsupp\expandafter{\@gls@replacementtext}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnameaccessdisplay}
% Displays the first argument with the accessibility text for
% the entry with the label given by the second argument (if set).
%    \begin{macrocode}
\DeclareRobustCommand*{\glsnameaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentryaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glstextaccessdisplay}
% As above but for the \gloskey{textaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glstextaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrytextaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glspluralaccessdisplay}
% As above but for the \gloskey{pluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glspluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrypluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstaccessdisplay}
% As above but for the \gloskey{firstaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsfirstaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentryfirstaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstpluralaccessdisplay}
% As above but for the \gloskey{firstpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsfirstpluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentryfirstpluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssymbolaccessdisplay}
% As above but for the \gloskey{symbolaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glssymbolaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrysymbolaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssymbolpluralaccessdisplay}
% As above but for the \gloskey{symbolpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glssymbolpluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrysymbolpluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsdescriptionaccessdisplay}
% As above but for the \gloskey{descriptionaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsdescriptionaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrydescaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsdescriptionpluralaccessdisplay}
% As above but for the \gloskey{descriptionpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsdescriptionpluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrydescpluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsshortaccessdisplay}
% As above but for the \gloskey{shortaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsshortaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentryshortaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsshortpluralaccessdisplay}
% As above but for the \gloskey{shortpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsshortpluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentryshortpluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongaccessdisplay}
% As above but for the \gloskey{longaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glslongaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrylongaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongpluralaccessdisplay}
% As above but for the \gloskey{longpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glslongpluralaccessdisplay}[2]{%
  \protected@edef\@glo@access{\glsentrylongpluralaccess{#2}}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessdisplay}
% Gets the replacement text corresponding to the named key given
% by the first argument and calls the appropriate command 
% defined above.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsaccessdisplay}[3]{%
  \@ifundefined{gls#1accessdisplay}%
  {%
    \PackageError{glossaries-accsupp}{No accessibility support
     for key `#1'}{}%
  }%
  {%
    \csname gls#1accessdisplay\endcsname{#2}{#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@}
% Redefine \cs{@gls@} to change the way the link text is defined
%    \begin{macrocode}
\def\@gls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}). This is no longer expanded.
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glstextaccessdisplay{\glsentrytext{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \def\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
        {\glsfirstaccessdisplay{\glsentryfirst{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse{\(\boolean{@glsisacronymlist}\AND
        \boolean{glsacrfootnote}\) \OR\NOT\boolean{glshyperfirst}}%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Gls@}
%    \begin{macrocode}
\def\@Gls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}). The first character of the entry text is 
% converted to uppercase before passing to
% \cs{gls@}\meta{type}"@display" or 
% \cs{gls@}\meta{type}"@displayfirst"
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glstextaccessdisplay{\Glsentrytext{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \def\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
        {\glsfirstaccessdisplay{\Glsentryfirst{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}.
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%    \begin{macrocode}
  \ifglsused{#2}%
  {%
    \@gls@link[#1]{#2}{\@glo@text}%
  }%
  {%
    \gls@checkisacronymlist\@glo@type
    \ifthenelse{\(\boolean{@glsisacronymlist}\AND
      \boolean{glsacrfootnote}\) \OR\NOT\boolean{glshyperfirst}}%
    {%
      \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
    }%
    {%
    \@gls@link[#1]{#2}{\@glo@text}%
    }%
  }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLS@}
%    \begin{macrocode}
\def\@GLS@#1#2[#3]{%
  \glsdoifexists{#2}{%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}).
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glstextaccessdisplay{\glsentrytext{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \edef\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
        {\glsfirstaccessdisplay{\glsentryfirst{#2}}{#2}}%
        {\glsdescriptionaccessdisplay{\glsentrydesc{#2}}{#2}}%
        {\glssymbolaccessdisplay{\glsentrysymbol{#2}}{#2}}%
        {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse{\(\boolean{@glsisacronymlist}\AND
        \boolean{glsacrfootnote}\) \OR\NOT\boolean{glshyperfirst}}{%
        \@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@pl@}
%    \begin{macrocode}
\def\@glspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glspluralaccessdisplay{\glsentryplural{#2}}{#2}}%
        {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
        {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \def\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
        {\glsfirstpluralaccessdisplay{\glsentryfirstplural{#2}}{#2}}%
        {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
        {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
        {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%\changes{1.16}{2008 August 27}{Test glossary type is 'acronymtype in addition to
%checking if footnote option has been used}
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse{\(\boolean{@glsisacronymlist}\AND
        \boolean{glsacrfootnote}\) \OR\NOT\boolean{glshyperfirst}}%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glspl@}
%    \begin{macrocode}
\def\@Glspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}).
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glspluralaccessdisplay{\Glsentryplural{#2}}{#2}}%
        {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
        {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \def\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
        {\glsfirstpluralaccessdisplay{\Glsentryfirstplural{#2}}{#2}}%
        {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
        {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
        {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\@glo@text}%
    }%
    {%
      \ifthenelse{\equal{\@glo@type}{\acronymtype}\and
        \boolean{glsacrfootnote}}%
      {%
        \@gls@link[#1,hyper=false]{#2}{\@glo@text}%
      }%
      {%
        \@gls@link[#1]{#2}{\@glo@text}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSpl@}
%    \begin{macrocode}
\def\@GLSpl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \def\@gls@link@label{#2}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \def\@glo@text{\csname gls@\@glo@type @display\endcsname
        {\glspluralaccessdisplay{\glsentryplural{#2}}{#2}}%
        {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
        {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
        {#3}}%
    }%
    {%
      \def\@glo@text{\csname gls@\@glo@type @displayfirst\endcsname
      {\glsfirstpluralaccessdisplay{\glsentryfirstplural{#2}}{#2}}%
      {\glsdescriptionpluralaccessdisplay{\glsentrydescplural{#2}}{#2}}%
      {\glssymbolpluralaccessdisplay{\glsentrysymbolplural{#2}}{#2}}%
      {#3}}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
% If \pkgopt{footnote} package option has been used, suppress 
% hyperlink for first use.
%    \begin{macrocode}
    \ifglsused{#2}%
    {%
      \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
    }%
    {%
      \gls@checkisacronymlist\@glo@type
      \ifthenelse{\(\boolean{@glsisacronymlist}\AND
        \boolean{glsacrfootnote}\)\OR\NOT\boolean{glshyperfirst}}%
      {%
        \@gls@link[#1,hyper=false]{#2}{\MakeUppercase{\@glo@text}}%
      }%
      {%
        \@gls@link[#1]{#2}{\MakeUppercase{\@glo@text}}%
      }%
    }%
%    \end{macrocode}
% Indicate that this entry has now been used
%    \begin{macrocode}
    \glsunset{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrshort}
%    \begin{macrocode}
\def\@acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glsshortaccessdisplay{\glsentryshort{#2}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\@glo@text}#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrshort}
%    \begin{macrocode}
\def\@Acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glsshortaccessdisplay{\Glsentryshort{#2}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\@glo@text}#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRshort}
%    \begin{macrocode}
\def\@ACRshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glsshortaccessdisplay{\MakeUppercase{\glsentryshort{#2}}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\acronymfont{\@glo@text#3}}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrlong}
%    \begin{macrocode}
\def\@acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glslongaccessdisplay{\glsentrylong{#2}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\@glo@text#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrlong}
%    \begin{macrocode}
\def\@Acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glslongaccessdisplay{\Glsentrylong{#2}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\@glo@text#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRlong}
%    \begin{macrocode}
\def\@ACRlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \edef\@glo@type{\glsentrytype{#2}}%
%    \end{macrocode}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%    \begin{macrocode}
    \def\@glo@text{%
      \glslongaccessdisplay{\MakeUppercase{\glsentrylong{#2}}}{#2}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\@glo@text#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Displaying the Glossary}
% Entries within the glossary or list of acronyms are now formatted
% via \cs{accsuppglossaryentryfield} and
% \cs{accsuppglossarysubentryfield}.
%\begin{macro}{\@glossaryentryfield}
%    \begin{macrocode}
\ifglsxindy
  \renewcommand*{\@glossaryentryfield}{%
     \string\\accsuppglossaryentryfield}
\else
  \renewcommand*{\@glossaryentryfield}{%
     \string\accsuppglossaryentryfield}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glossarysubentryfield}
%    \begin{macrocode}
\ifglsxindy
  \renewcommand*{\@glossarysubentryfield}{%
    \string\\accsuppglossarysubentryfield}
\else
  \renewcommand*{\@glossarysubentryfield}{%
    \string\accsuppglossarysubentryfield}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\accsuppglossaryentryfield}
%    \begin{macrocode}
\newcommand*{\accsuppglossaryentryfield}[5]{%
  \glossaryentryfield{#1}%
  {\glsnameaccessdisplay{#2}{#1}}%
  {\glsdescriptionaccessdisplay{#3}{#1}}%
  {\glssymbolaccessdisplay{#4}{#1}}{#5}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\accsuppglossarysubentryfield}
%    \begin{macrocode}
\newcommand*{\accsuppglossarysubentryfield}[6]{%
  \glossaryentryfield{#1}{#2}%
  {\glsnameaccessdisplay{#3}{#2}}%
  {\glsdescriptionaccessdisplay{#4}{#2}}%
  {\glssymbolaccessdisplay{#5}{#2}}{#6}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Acronyms}
% Use \cs{newacronymhook} to modify the key list to set
% the access text to the long version by default.
%    \begin{macrocode}
\renewcommand*{\newacronymhook}{%
  \edef\@gls@keylist{shortaccess=\the\glslongtok,%
     \the\glskeylisttok}%
  \expandafter\glskeylisttok\expandafter{\@gls@keylist}%
}
%    \end{macrocode}
%\begin{macro}{\DefaultNewAcronymDef}
% Modify default style to use access text:
%    \begin{macrocode}
\renewcommand*{\DefaultNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\the\glsshorttok},%
      description={\the\glslongtok},%
      descriptionaccess=\relax,
      text={\the\glsshorttok},%
      access={\noexpand\@glo@textaccess},%
      sort={\the\glsshorttok},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      shortaccess={\the\glslongtok},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      descriptionplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      first={\noexpand\glslongaccessdisplay
        {\the\glslongtok}{\the\glslabeltok}\space
        (\noexpand\glsshortaccessdisplay
          {\the\glsshorttok}{\the\glslabeltok})},%
      plural={\the\glsshorttok\acrpluralsuffix},%
      firstplural={\noexpand\glslongpluralaccessdisplay
        {\noexpand\@glo@longpl}{\the\glslabeltok}\space
        (\noexpand\glsshortpluralaccessdisplay
          {\noexpand\@glo@shortpl}{\the\glslabeltok})},%
      firstaccess=\relax,
      firstpluralaccess=\relax,
      textaccess={\noexpand\@glo@shortaccess},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DescriptionFootnoteNewAcronymDef}
%    \begin{macrocode}
\renewcommand*{\DescriptionFootnoteNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand\acronymfont{\the\glsshorttok}},%
      sort={\the\glsshorttok},%
      text={\the\glsshorttok},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      shortaccess={\the\glslongtok},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      access={\noexpand\@glo@textaccess},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      symbol={\the\glslongtok},%
      symbolplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      firstpluralaccess=\relax,
      textaccess={\noexpand\@glo@shortaccess},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\DescriptionNewAcronymDef}
%    \begin{macrocode}
\renewcommand*{\DescriptionNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand
        \acrnameformat{\the\glsshorttok}{\the\glslongtok}},%
      access={\noexpand\@glo@textaccess},%
      sort={\the\glsshorttok},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      shortaccess={\the\glslongtok},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      first={\the\glslongtok},%
      firstaccess=\relax,
      firstplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      text={\the\glsshorttok},%
      textaccess={\the\glslongtok},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      symbol={\noexpand\@glo@text},%
      symbolaccess={\noexpand\@glo@textaccess},%
      symbolplural={\noexpand\@glo@plural},%
      firstpluralaccess=\relax,
      textaccess={\noexpand\@glo@shortaccess},%
      \the\glskeylisttok}%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\FootnoteNewAcronymDef}
%    \begin{macrocode}
\renewcommand*{\FootnoteNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand\acronymfont{\the\glsshorttok}},%
      sort={\the\glsshorttok},%
      text={\the\glsshorttok},%
      textaccess={\the\glslongtok},%
      access={\noexpand\@glo@textaccess},%
      plural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SmallNewAcronymDef}
%    \begin{macrocode}
\renewcommand*{\SmallNewAcronymDef}{%
  \edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\acronymtype,%
      name={\noexpand\acronymfont{\the\glsshorttok}},%
      access={\noexpand\@glo@symbolaccess},%
      sort={\the\glsshorttok},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      shortaccess={\the\glslongtok},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      text={\noexpand\@glo@short},%
      textaccess={\noexpand\@glo@shortaccess},%
      plural={\noexpand\@glo@shortpl},%
      first={\the\glslongtok},%
      firstaccess=\relax,
      firstplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\noexpand\@glo@first},%
      descriptionplural={\noexpand\@glo@firstplural},%
      symbol={\the\glsshorttok},%
      symbolaccess={\the\glslongtok},%
      symbolplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
}
%    \end{macrocode}
%\end{macro}
%
% The following are kept for compatibility with versions before
% 3.0:
%\begin{macro}{\glsshortaccesskey}
%    \begin{macrocode}
  \newcommand*{\glsshortaccesskey}{\glsshortkey access}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsshortpluralaccesskey}
%    \begin{macrocode}
  \newcommand*{\glsshortpluralaccesskey}{\glsshortpluralkey access}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongaccesskey}
%    \begin{macrocode}
  \newcommand*{\glslongaccesskey}{\glslongkey access}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongpluralaccesskey}
%    \begin{macrocode}
  \newcommand*{\glslongpluralaccesskey}{\glslongpluralkey access}%
%    \end{macrocode}
%\end{macro}
%\subsection{Debugging Commands}
%
%\begin{macro}{\showglonameaccess}
%    \begin{macrocode}
\newcommand*{\showglonameaccess}[1]{%
  \expandafter\show\csname glo@#1@textaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglotextaccess}
%    \begin{macrocode}
\newcommand*{\showglotextaccess}[1]{%
  \expandafter\show\csname glo@#1@textaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglopluralaccess}
%    \begin{macrocode}
\newcommand*{\showglopluralaccess}[1]{%
  \expandafter\show\csname glo@#1@pluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglofirstaccess}
%    \begin{macrocode}
\newcommand*{\showglofirstaccess}[1]{%
  \expandafter\show\csname glo@#1@firstaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglofirstpluralaccess}
%    \begin{macrocode}
\newcommand*{\showglofirstpluralaccess}[1]{%
  \expandafter\show\csname glo@#1@firstpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglosymbolaccess}
%    \begin{macrocode}
\newcommand*{\showglosymbolaccess}[1]{%
  \expandafter\show\csname glo@#1@symbolaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglosymbolpluralaccess}
%    \begin{macrocode}
\newcommand*{\showglosymbolpluralaccess}[1]{%
  \expandafter\show\csname glo@#1@symbolpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglodescaccess}
%    \begin{macrocode}
\newcommand*{\showglodescaccess}[1]{%
  \expandafter\show\csname glo@#1@descaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglodescpluralaccess}
%    \begin{macrocode}
\newcommand*{\showglodescpluralaccess}[1]{%
  \expandafter\show\csname glo@#1@descpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showgloshortaccess}
%    \begin{macrocode}
\newcommand*{\showgloshortaccess}[1]{%
  \expandafter\show\csname glo@#1@shortaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showgloshortpluralaccess}
%    \begin{macrocode}
\newcommand*{\showgloshortpluralaccess}[1]{%
  \expandafter\show\csname glo@#1@shortpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglolongaccess}
%    \begin{macrocode}
\newcommand*{\showglolongaccess}[1]{%
  \expandafter\show\csname glo@#1@longaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglolongpluralaccess}
%    \begin{macrocode}
\newcommand*{\showglolongpluralaccess}[1]{%
  \expandafter\show\csname glo@#1@longpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\iffalse
%    \begin{macrocode}
%</glossaries-accsupp.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-babel.sty>
%    \end{macrocode}
%\fi
%\section{Multi-Lingual Support}
% Many thanks to everyone who contributed to the translations both
% via email and on comp.text.tex.
%\subsection{Babel Captions}
% Define \isty{babel} captions if multi-lingual
% support is required, but the \isty{translator} package is not loaded.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-babel}[2009/04/16 v1.2 (NLCT)]
%    \end{macrocode}
% English:
%    \begin{macrocode}
\@ifundefined{captionsenglish}{}{%
  \addto\captionsenglish{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsamerican}{}{%
  \addto\captionsamerican{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsaustralian}{}{%
  \addto\captionsaustralian{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsbritish}{}{%
  \addto\captionsbritish{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}}%
\@ifundefined{captionscanadian}{}{%
  \addto\captionscanadian{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsnewzealand}{}{%
  \addto\captionsnewzealand{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsUKenglish}{}{%
  \addto\captionsUKenglish{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
\@ifundefined{captionsUSenglish}{}{%
  \addto\captionsUSenglish{%
    \renewcommand*{\glossaryname}{Glossary}%
    \renewcommand*{\acronymname}{Acronyms}%
    \renewcommand*{\entryname}{Notation}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Page List}%
    \renewcommand*{\glssymbolsgroupname}{Symbols}%
    \renewcommand*{\glsnumbersgroupname}{Numbers}%
}%
}
%    \end{macrocode}
% German (quite a few variations were suggested for German; 
% I settled on the following):
%    \begin{macrocode}
\@ifundefined{captionsgerman}{}{%
  \addto\captionsgerman{% 
    \renewcommand*{\glossaryname}{Glossar}%
    \renewcommand*{\acronymname}{Akronyme}%
    \renewcommand*{\entryname}{Bezeichnung}%
    \renewcommand*{\descriptionname}{Beschreibung}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Seiten}%
    \renewcommand*{\glssymbolsgroupname}{Symbole}%
    \renewcommand*{\glsnumbersgroupname}{Zahlen}} 
}
%    \end{macrocode}
% ngerman is identical to German:
%\changes{1.2}{2009 April 16}{fixed bug in ngerman captions}
%    \begin{macrocode}
\@ifundefined{captionsngerman}{}{%
  \addto\captionsngerman{% 
    \renewcommand*{\glossaryname}{Glossar}%
    \renewcommand*{\acronymname}{Akronyme}%
    \renewcommand*{\entryname}{Bezeichnung}%
    \renewcommand*{\descriptionname}{Beschreibung}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Seiten}%
    \renewcommand*{\glssymbolsgroupname}{Symbole}%
    \renewcommand*{\glsnumbersgroupname}{Zahlen}} 
}
%    \end{macrocode}
% Italian:
%    \begin{macrocode}
\@ifundefined{captionsitalian}{}{%
  \addto\captionsitalian{%
    \renewcommand*{\glossaryname}{Glossario}%
    \renewcommand*{\acronymname}{Acronimi}%
    \renewcommand*{\entryname}{Nomenclatura}%
    \renewcommand*{\descriptionname}{Descrizione}%
    \renewcommand*{\symbolname}{Simbolo}%
    \renewcommand*{\pagelistname}{Elenco delle pagine}%
    \renewcommand*{\glssymbolsgroupname}{Simboli}%
    \renewcommand*{\glsnumbersgroupname}{Numeri}} 
}
%    \end{macrocode}
% Dutch:
%    \begin{macrocode}
\@ifundefined{captionsdutch}{}{%
  \addto\captionsdutch{%
    \renewcommand*{\glossaryname}{Woordenlijst}%
    \renewcommand*{\acronymname}{Acroniemen}%
    \renewcommand*{\entryname}{Benaming}%
    \renewcommand*{\descriptionname}{Beschrijving}%
    \renewcommand*{\symbolname}{Symbool}%
    \renewcommand*{\pagelistname}{Pagina's}%
    \renewcommand*{\glssymbolsgroupname}{Symbolen}%
    \renewcommand*{\glsnumbersgroupname}{Cijfers}} 
}
%    \end{macrocode}
% Spanish:
%    \begin{macrocode}
\@ifundefined{captionsspanish}{}{%
  \addto\captionsspanish{%
    \renewcommand*{\glossaryname}{Glosario}%
    \renewcommand*{\acronymname}{Siglas}%
    \renewcommand*{\entryname}{Entrada}%
    \renewcommand*{\descriptionname}{Descripci\'on}%
    \renewcommand*{\symbolname}{S\'{\i}mbolo}%
    \renewcommand*{\pagelistname}{Lista de p\'aginas}%
    \renewcommand*{\glssymbolsgroupname}{S\'{\i}mbolos}%
    \renewcommand*{\glsnumbersgroupname}{N\'umeros}} 
}
%    \end{macrocode}
% French:
%    \begin{macrocode}
\@ifundefined{captionsfrench}{}{%
  \addto\captionsfrench{%
    \renewcommand*{\glossaryname}{Glossaire}%
    \renewcommand*{\acronymname}{Acronymes}%
    \renewcommand*{\entryname}{Terme}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbole}%
    \renewcommand*{\pagelistname}{Pages}%
    \renewcommand*{\glssymbolsgroupname}{Symboles}%
    \renewcommand*{\glsnumbersgroupname}{Nombres}} 
}
\@ifundefined{captionsfrenchb}{}{%
  \addto\captionsfrenchb{%
    \renewcommand*{\glossaryname}{Glossaire}%
    \renewcommand*{\acronymname}{Acronymes}%
    \renewcommand*{\entryname}{Terme}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbole}%
    \renewcommand*{\pagelistname}{Pages}%
    \renewcommand*{\glssymbolsgroupname}{Symboles}%
    \renewcommand*{\glsnumbersgroupname}{Nombres}} 
}
\@ifundefined{captionsfrancais}{}{%
  \addto\captionsfrancais{%
    \renewcommand*{\glossaryname}{Glossaire}%
    \renewcommand*{\acronymname}{Acronymes}%
    \renewcommand*{\entryname}{Terme}%
    \renewcommand*{\descriptionname}{Description}%
    \renewcommand*{\symbolname}{Symbole}%
    \renewcommand*{\pagelistname}{Pages}%
    \renewcommand*{\glssymbolsgroupname}{Symboles}%
    \renewcommand*{\glsnumbersgroupname}{Nombres}} 
}
%    \end{macrocode}
% Danish:
%    \begin{macrocode}
\@ifundefined{captionsdanish}{}{%
  \addto\captionsdanish{%
    \renewcommand*{\glossaryname}{Ordliste}%
    \renewcommand*{\acronymname}{Akronymer}%
    \renewcommand*{\entryname}{Symbolforklaring}%
    \renewcommand*{\descriptionname}{Beskrivelse}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Side}%
    \renewcommand*{\glssymbolsgroupname}{Symboler}%
    \renewcommand*{\glsnumbersgroupname}{Tal}} 
}
%    \end{macrocode}
% Irish:
%    \begin{macrocode}
\@ifundefined{captionsirish}{}{%
  \addto\captionsirish{%
    \renewcommand*{\glossaryname}{Gluais}%
    \renewcommand*{\acronymname}{Acrainmneacha}%
%    \end{macrocode}
% wasn't sure whether to go for N\'ota (Note), Ciall (`Meaning',
% `sense') or Br\'{\i} (`Meaning'). In the end I chose Ciall.
%    \begin{macrocode}
    \renewcommand*{\entryname}{Ciall}%
    \renewcommand*{\descriptionname}{Tuairisc}%
%    \end{macrocode}
% Again, not sure whether to use Comhartha/Comhartha\'{\i} or
% Siombail/Siombaile, so have chosen the former.
%    \begin{macrocode}
    \renewcommand*{\symbolname}{Comhartha}%
    \renewcommand*{\glssymbolsgroupname}{Comhartha\'{\i}}%
    \renewcommand*{\pagelistname}{Leathanaigh}%
    \renewcommand*{\glsnumbersgroupname}{Uimhreacha}} 
}
%    \end{macrocode}
% Hungarian:
%    \begin{macrocode}
\@ifundefined{captionsmagyar}{}{%
  \addto\captionsmagyar{%
    \renewcommand*{\glossaryname}{Sz\'ojegyz\'ek}%
    \renewcommand*{\acronymname}{Bet\H uszavak}%
    \renewcommand*{\entryname}{Kifejez\'es}%
    \renewcommand*{\descriptionname}{Magyar\'azat}%
    \renewcommand*{\symbolname}{Jel\"ol\'es}%
    \renewcommand*{\pagelistname}{Oldalsz\'am}%
    \renewcommand*{\glssymbolsgroupname}{Jelek}%
    \renewcommand*{\glsnumbersgroupname}{Sz\'amjegyek}%
  }
}
\@ifundefined{captionshungarian}{}{%
  \addto\captionshungarian{%
    \renewcommand*{\glossaryname}{Sz\'ojegyz\'ek}%
    \renewcommand*{\acronymname}{Bet\H uszavak}%
    \renewcommand*{\entryname}{Kifejez\'es}%
    \renewcommand*{\descriptionname}{Magyar\'azat}%
    \renewcommand*{\symbolname}{Jel\"ol\'es}%
    \renewcommand*{\pagelistname}{Oldalsz\'am}%
    \renewcommand*{\glssymbolsgroupname}{Jelek}%
    \renewcommand*{\glsnumbersgroupname}{Sz\'amjegyek}%
  }
}
%    \end{macrocode}
% Polish
% \changes{1.13}{2008 May 10}{Add Polish support}
%    \begin{macrocode}
\@ifundefined{captionspolish}{}{%
  \addto\captionspolish{%
    \renewcommand*{\glossaryname}{S{\l}ownik termin\'ow}%
    \renewcommand*{\acronymname}{Skr\'ot}%
    \renewcommand*{\entryname}{Termin}%
    \renewcommand*{\descriptionname}{Opis}%
    \renewcommand*{\symbolname}{Symbol}%
    \renewcommand*{\pagelistname}{Strony}%
    \renewcommand*{\glssymbolsgroupname}{Symbole}%
    \renewcommand*{\glsnumbersgroupname}{Liczby}}
}
%    \end{macrocode}
% Brazilian
%\changes{1.17}{2008 December 11}{Added Brazilian support}
%    \begin{macrocode}
\@ifundefined{captionsbrazil}{}{%
  \addto\captionsbrazil{%
    \renewcommand*{\glossaryname}{Gloss\'ario}%
    \renewcommand*{\acronymname}{Siglas}%
    \renewcommand*{\entryname}{Nota\c c\~ao}%
    \renewcommand*{\descriptionname}{Descri\c c\~ao}%
    \renewcommand*{\symbolname}{S\'imbolo}%
    \renewcommand*{\pagelistname}{Lista de P\'aginas}%
    \renewcommand*{\glssymbolsgroupname}{S\'imbolos}%
    \renewcommand*{\glsnumbersgroupname}{N\'umeros}%
  }%
}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-babel.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-polyglossia.sty>
%    \end{macrocode}
%\fi
%\subsection{Polyglossia Captions}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-polyglossia}[2009/11/09 v1.0 (NLCT)]
%    \end{macrocode}
% English:
%    \begin{macrocode}
\@ifundefined{captionsenglish}{}{%
  \expandafter\toks@\expandafter{\captionsenglish
    \renewcommand*{\glossaryname}{\textenglish{Glossary}}%
    \renewcommand*{\acronymname}{\textenglish{Acronyms}}%
    \renewcommand*{\entryname}{\textenglish{Notation}}%
    \renewcommand*{\descriptionname}{\textenglish{Description}}%
    \renewcommand*{\symbolname}{\textenglish{Symbol}}%
    \renewcommand*{\pagelistname}{\textenglish{Page List}}%
    \renewcommand*{\glssymbolsgroupname}{\textenglish{Symbols}}%
    \renewcommand*{\glsnumbersgroupname}{\textenglish{Numbers}}%
  }%
  \edef\captionsenglish{\the\toks@}%
}
%    \end{macrocode}
% German:
%    \begin{macrocode}
\@ifundefined{captionsgerman}{}{%
  \expandafter\toks@\expandafter{\captionsgerman
    \renewcommand*{\glossaryname}{\textgerman{Glossar}}%
    \renewcommand*{\acronymname}{\textgerman{Akronyme}}%
    \renewcommand*{\entryname}{\textgerman{Bezeichnung}}%
    \renewcommand*{\descriptionname}{\textgerman{Beschreibung}}%
    \renewcommand*{\symbolname}{\textgerman{Symbol}}%
    \renewcommand*{\pagelistname}{\textgerman{Seiten}}%
    \renewcommand*{\glssymbolsgroupname}{\textgerman{Symbole}}%
    \renewcommand*{\glsnumbersgroupname}{\textgerman{Zahlen}}%
  }% 
  \edef\captionsgerman{\the\toks@}%
}
%    \end{macrocode}
% Italian:
%    \begin{macrocode}
\@ifundefined{captionsitalian}{}{%
  \expandafter\toks@\expandafter{\captionsitalian
    \renewcommand*{\glossaryname}{\textitalian{Glossario}}%
    \renewcommand*{\acronymname}{\textitalian{Acronimi}}%
    \renewcommand*{\entryname}{\textitalian{Nomenclatura}}%
    \renewcommand*{\descriptionname}{\textitalian{Descrizione}}%
    \renewcommand*{\symbolname}{\textitalian{Simbolo}}%
    \renewcommand*{\pagelistname}{\textitalian{Elenco delle pagine}}%
    \renewcommand*{\glssymbolsgroupname}{\textitalian{Simboli}}%
    \renewcommand*{\glsnumbersgroupname}{\textitalian{Numeri}}%
  }%
  \edef\captionsitalian{\the\toks@}% 
}
%    \end{macrocode}
% Dutch:
%    \begin{macrocode}
\@ifundefined{captionsdutch}{}{%
  \expandafter\toks@\expandafter{\captionsdutch
    \renewcommand*{\glossaryname}{\textdutch{Woordenlijst}}%
    \renewcommand*{\acronymname}{\textdutch{Acroniemen}}%
    \renewcommand*{\entryname}{\textdutch{Benaming}}%
    \renewcommand*{\descriptionname}{\textdutch{Beschrijving}}%
    \renewcommand*{\symbolname}{\textdutch{Symbool}}%
    \renewcommand*{\pagelistname}{\textdutch{Pagina's}}%
    \renewcommand*{\glssymbolsgroupname}{\textdutch{Symbolen}}%
    \renewcommand*{\glsnumbersgroupname}{\textdutch{Cijfers}}%
  }%
  \edef\captionsdutch{\the\toks@}%
}
%    \end{macrocode}
% Spanish:
%    \begin{macrocode}
\@ifundefined{captionsspanish}{}{%
  \expandafter\toks@\expandafter{\captionsspanish
    \renewcommand*{\glossaryname}{\textspanish{Glosario}}%
    \renewcommand*{\acronymname}{\textspanish{Siglas}}%
    \renewcommand*{\entryname}{\textspanish{Entrada}}%
    \renewcommand*{\descriptionname}{\textspanish{Descripci\'on}}%
    \renewcommand*{\symbolname}{\textspanish{S\'{\i}mbolo}}%
    \renewcommand*{\pagelistname}{\textspanish{Lista de p\'aginas}}%
    \renewcommand*{\glssymbolsgroupname}{\textspanish{S\'{\i}mbolos}}%
    \renewcommand*{\glsnumbersgroupname}{\textspanish{N\'umeros}}%
  }%
  \edef\captionsspanish{\the\toks@}%
}
%    \end{macrocode}
% French:
%    \begin{macrocode}
\@ifundefined{captionsfrench}{}{%
  \expandafter\toks@\expandafter{\captionsfrench
    \renewcommand*{\glossaryname}{\textfrench{Glossaire}}%
    \renewcommand*{\acronymname}{\textfrench{Acronymes}}%
    \renewcommand*{\entryname}{\textfrench{Terme}}%
    \renewcommand*{\descriptionname}{\textfrench{Description}}%
    \renewcommand*{\symbolname}{\textfrench{Symbole}}%
    \renewcommand*{\pagelistname}{\textfrench{Pages}}%
    \renewcommand*{\glssymbolsgroupname}{\textfrench{Symboles}}%
    \renewcommand*{\glsnumbersgroupname}{\textfrench{Nombres}}%
  }%
  \edef\captionsfrench{\the\toks@}% 
}
%    \end{macrocode}
% Danish:
%    \begin{macrocode}
\@ifundefined{captionsdanish}{}{%
  \expandafter\toks@\expandafter{\captionsdanish
    \renewcommand*{\glossaryname}{\textdanish{Ordliste}}%
    \renewcommand*{\acronymname}{\textdanish{Akronymer}}%
    \renewcommand*{\entryname}{\textdanish{Symbolforklaring}}%
    \renewcommand*{\descriptionname}{\textdanish{Beskrivelse}}%
    \renewcommand*{\symbolname}{\textdanish{Symbol}}%
    \renewcommand*{\pagelistname}{\textdanish{Side}}%
    \renewcommand*{\glssymbolsgroupname}{\textdanish{Symboler}}%
    \renewcommand*{\glsnumbersgroupname}{\textdanish{Tal}}%
  }%
  \edef\captionsdanish{\the\toks@}%
}
%    \end{macrocode}
% Irish:
%    \begin{macrocode}
\@ifundefined{captionsirish}{}{%
  \expandafter\toks@\expandafter{\captionsirish
    \renewcommand*{\glossaryname}{\textirish{Gluais}}%
    \renewcommand*{\acronymname}{\textirish{Acrainmneacha}}%
    \renewcommand*{\entryname}{\textirish{Ciall}}%
    \renewcommand*{\descriptionname}{\textirish{Tuairisc}}%
    \renewcommand*{\symbolname}{\textirish{Comhartha}}%
    \renewcommand*{\glssymbolsgroupname}{\textirish{Comhartha\'{\i}}}%
    \renewcommand*{\pagelistname}{\textirish{Leathanaigh}}%
    \renewcommand*{\glsnumbersgroupname}{\textirish{Uimhreacha}}%
  }%
  \edef\captionsirish{\the\toks@}%
}
%    \end{macrocode}
% Hungarian:
%    \begin{macrocode}
\@ifundefined{captionsmagyar}{}{%
  \expandafter\toks@\expandafter{\captionsmagyar
    \renewcommand*{\glossaryname}{\textmagyar{Sz\'ojegyz\'ek}}%
    \renewcommand*{\acronymname}{\textmagyar{Bet\H uszavak}}%
    \renewcommand*{\entryname}{\textmagyar{Kifejez\'es}}%
    \renewcommand*{\descriptionname}{\textmagyar{Magyar\'azat}}%
    \renewcommand*{\symbolname}{\textmagyar{Jel\"ol\'es}}%
    \renewcommand*{\pagelistname}{\textmagyar{Oldalsz\'am}}%
    \renewcommand*{\glssymbolsgroupname}{\textmagyar{Jelek}}%
    \renewcommand*{\glsnumbersgroupname}{\textmagyar{Sz\'amjegyek}}%
  }%
  \edef\captionsmagyar{\the\toks@}%
}
%    \end{macrocode}
% Polish
% \changes{1.13}{2008 May 10}{Add Polish support}
%    \begin{macrocode}
\@ifundefined{captionspolish}{}{%
  \expandafter\toks@\expandafter{\captionspolish
    \renewcommand*{\glossaryname}{\textpolish{S{\l}ownik termin\'ow}}%
    \renewcommand*{\acronymname}{\textpolish{Skr\'ot}}%
    \renewcommand*{\entryname}{\textpolish{Termin}}%
    \renewcommand*{\descriptionname}{\textpolish{Opis}}%
    \renewcommand*{\symbolname}{\textpolish{Symbol}}%
    \renewcommand*{\pagelistname}{\textpolish{Strony}}%
    \renewcommand*{\glssymbolsgroupname}{\textpolish{Symbole}}%
    \renewcommand*{\glsnumbersgroupname}{\textpolish{Liczby}}%
  }%
  \edef\captionspolish{\the\toks@}%
}
%    \end{macrocode}
% Portugues
%    \begin{macrocode}
\@ifundefined{captionsportuges}{}{%
  \expandafter\toks@\expandafter{\captionsportuges
    \renewcommand*{\glossaryname}{\textportuges{Gloss\'ario}}%
    \renewcommand*{\acronymname}{\textportuges{Siglas}}%
    \renewcommand*{\entryname}{\textportuges{Nota\c c\~ao}}%
    \renewcommand*{\descriptionname}{\textportuges{Descri\c c\~ao}}%
    \renewcommand*{\symbolname}{\textportuges{S\'imbolo}}%
    \renewcommand*{\pagelistname}{\textportuges{Lista de P\'aginas}}%
    \renewcommand*{\glssymbolsgroupname}{\textportuges{S\'imbolos}}%
    \renewcommand*{\glsnumbersgroupname}{\textportuges{N\'umeros}}%
  }%
  \edef\captionsportuges{\the\toks@}%
}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-polyglossia.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Brazilian.dict>
%    \end{macrocode}
%\fi
%\subsection{Brazilian Dictionary}
% This is a dictionary file provided by Thiago de~Melo for
% use with the \isty{translator} package.
%\changes{1.17}{2008 November 17}{added Brazilian dictionary}
%\changes{2.02}{2009 July 13}{Changed Brazil to Brazilian}
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Brazilian}
%    \end{macrocode}
% Provide Brazilian translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Gloss\'ario}
\providetranslation{Acronyms}{Siglas}
\providetranslation{Notation (glossaries)}{Nota\c c\~ao}
\providetranslation{Description (glossaries)}{Descri\c c\~ao}
\providetranslation{Symbol (glossaries)}{S\'imbolo}
\providetranslation{Page List (glossaries)}{Lista de P\'aginas}
\providetranslation{Symbols (glossaries)}{S\'imbolos}
\providetranslation{Numbers (glossaries)}{N\'umeros}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Brazilian.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Danish.dict>
%    \end{macrocode}
%\fi
%\subsection{Danish Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Danish}
%    \end{macrocode}
% Provide Danish translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Ordliste}
\providetranslation{Acronyms}{Akronymer}
\providetranslation{Notation (glossaries)}{Symbolforklaring}
\providetranslation{Description (glossaries)}{Beskrivelse}
\providetranslation{Symbol (glossaries)}{Symbol}
\providetranslation{Page List (glossaries)}{Side}
\providetranslation{Symbols (glossaries)}{Symboler}
\providetranslation{Numbers (glossaries)}{Tal}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Danish.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Dutch.dict>
%    \end{macrocode}
%\fi
%\subsection{Dutch Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Dutch}
%    \end{macrocode}
% Provide Dutch translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Woordenlijst}
\providetranslation{Acronyms}{Acroniemen}
\providetranslation{Notation (glossaries)}{Benaming}
\providetranslation{Description (glossaries)}{Beschrijving}
\providetranslation{Symbol (glossaries)}{Symbool}
\providetranslation{Page List (glossaries)}{Pagina's}
\providetranslation{Symbols (glossaries)}{Symbolen}
\providetranslation{Numbers (glossaries)}{Cijfers}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Dutch.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-English.dict>
%    \end{macrocode}
%\fi
%\subsection{English Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{English}
%    \end{macrocode}
% Provide English translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Glossary}
\providetranslation{Acronyms}{Acronyms}
\providetranslation{Notation (glossaries)}{Notation}
\providetranslation{Description (glossaries)}{Description}
\providetranslation{Symbol (glossaries)}{Symbol}
\providetranslation{Page List (glossaries)}{Page List}
\providetranslation{Symbols (glossaries)}{Symbols}
\providetranslation{Numbers (glossaries)}{Numbers}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-English.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-French.dict>
%    \end{macrocode}
%\fi
%\subsection{French Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{French}
%    \end{macrocode}
% Provide French translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Glossaire}
\providetranslation{Acronyms}{Acronymes}
\providetranslation{Notation (glossaries)}{Terme}
\providetranslation{Description (glossaries)}{Description}
\providetranslation{Symbol (glossaries)}{Symbole}
\providetranslation{Page List (glossaries)}{Pages}
\providetranslation{Symbols (glossaries)}{Symboles}
\providetranslation{Numbers (glossaries)}{Nombres}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-French.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-German.dict>
%    \end{macrocode}
%\fi
%\subsection{German Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{German}
%    \end{macrocode}
% Provide German translations (quite a few variations were suggested
% for German; I settled on the following):
%    \begin{macrocode}
\providetranslation{Glossary}{Glossar}
\providetranslation{Acronyms}{Akronyme}
\providetranslation{Notation (glossaries)}{Bezeichnung}
\providetranslation{Description (glossaries)}{Beschreibung}
\providetranslation{Symbol (glossaries)}{Symbol}
\providetranslation{Page List (glossaries)}{Seiten}
\providetranslation{Symbols (glossaries)}{Symbole}
\providetranslation{Numbers (glossaries)}{Zahlen}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-German.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Irish.dict>
%    \end{macrocode}
%\fi
%\subsection{Irish Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Irish}
%    \end{macrocode}
% Provide Irish translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Gluais}
\providetranslation{Acronyms}{Acrainmneacha}
\providetranslation{Notation (glossaries)}{Ciall}
\providetranslation{Description (glossaries)}{Tuairisc}
\providetranslation{Symbol (glossaries)}{Comhartha}
\providetranslation{Page List (glossaries)}{Leathanaigh}
\providetranslation{Symbols (glossaries)}{Comhartha\'{\i}}
\providetranslation{Numbers (glossaries)}{Uimhreacha}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Irish.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Italian.dict>
%    \end{macrocode}
%\fi
%\subsection{Italian Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Italian}
%    \end{macrocode}
% Provide Italian translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Glossario}
\providetranslation{Acronyms}{Acronimi}
\providetranslation{Notation (glossaries)}{Nomenclatura}
\providetranslation{Description (glossaries)}{Descrizione}
\providetranslation{Symbol (glossaries)}{Simbolo}
\providetranslation{Page List (glossaries)}{Elenco delle pagine}
\providetranslation{Symbols (glossaries)}{Simboli}
\providetranslation{Numbers (glossaries)}{Numeri}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Italian.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Magyar.dict>
%    \end{macrocode}
%\fi
%\subsection{Magyar Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Magyar}
%    \end{macrocode}
% Provide translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Sz\'ojegyz\'ek}
\providetranslation{Acronyms}{Bet\H uszavak}
\providetranslation{Notation (glossaries)}{Kifejez\'es}
\providetranslation{Description (glossaries)}{Magyar\'azat}
\providetranslation{Symbol (glossaries)}{Jel\"ol\'es}
\providetranslation{Page List (glossaries)}{Oldalsz\'am}
\providetranslation{Symbols (glossaries)}{Jelek}
\providetranslation{Numbers (glossaries)}{Sz\'amjegyek}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Magyar.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Polish.dict>
%    \end{macrocode}
%\fi
%\subsection{Polish Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Polish}
%    \end{macrocode}
% Provide Polish translations:
%    \begin{macrocode}
\providetranslation{Glossary}{S{\l}ownik termin\'ow}
\providetranslation{Acronyms}{Skr\'ot}
\providetranslation{Notation (glossaries)}{Termin}
\providetranslation{Description (glossaries)}{Opis}
\providetranslation{Symbol (glossaries)}{Symbol}
\providetranslation{Page List (glossaries)}{Strony}
\providetranslation{Symbols (glossaries)}{Symbole}
\providetranslation{Numbers (glossaries)}{Liczby}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Polish.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Serbian.dict>
%    \end{macrocode}
%\fi
%\subsection{Serbian Dictionary}
% This dictionary was provided by Zoran Filipovic.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Serbian}
\providetranslation{Glossary}{Mali re\v cnik}
\providetranslation{Acronyms}{Skra\' cenice}
\providetranslation{Notation (glossaries)}{Oznaka}
\providetranslation{Description (glossaries)}{Opis}
\providetranslation{Symbol (glossaries)}{Simbol}
\providetranslation{Page List (glossaries)}{Stranica}
\providetranslation{Symbols (glossaries)}{Simboli}
\providetranslation{Numbers (glossaries)}{Brojevi}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Serbian.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-dictionary-Spanish.dict>
%    \end{macrocode}
%\fi
%\subsection{Spanish Dictionary}
% This is a dictionary file provided for use with the \isty{translator}
% package.
%    \begin{macrocode}
\ProvidesDictionary{glossaries-dictionary}{Spanish}
%    \end{macrocode}
% Provide Spanish translations:
%    \begin{macrocode}
\providetranslation{Glossary}{Glosario}
\providetranslation{Acronyms}{Siglas}
\providetranslation{Notation (glossaries)}{Entrada}
\providetranslation{Description (glossaries)}{Descripci\'on}
\providetranslation{Symbol (glossaries)}{S\'{\i}mbolo}
\providetranslation{Page List (glossaries)}{Lista de p\'aginas}
\providetranslation{Symbols (glossaries)}{S\'{\i}mbolos}
\providetranslation{Numbers (glossaries)}{N\'umeros}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-dictionary-Spanish.dict>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*minimalgls.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain.
 %
 % This is a minimal file for testing and debugging 
 % the glossaries package. Change the class file as 
 % desired, and add the relevant package options to
 % both the class file and the glossaries package.
 % Change the sample glossary entry and acronym if
 % required. If the problem occurs with an additional
 % glossary, add in the relevant \newglossary command
 % and a sample entry.
 %
 % Only add extra packages or commands if they 
 % contribute to whatever problem you are trying to
 % test.
 %
 % Remember that the document will not be complete
 % until you have successfully completed all of the
 % following steps:
 % 1. latex minimalgls
 % 2. makeglossaries minimalgls (note no extension)
 % 3. latex minimalgls
 % A further run through LaTeX will be required to ensure that
 % the table of contents is up to date if the toc option
 % is used.
\documentclass{article}
\listfiles

\usepackage[colorlinks]{hyperref}
 \usepackage{glossaries} % acronym will go in main glossary
 %\usepackage[acronym]{glossaries} % make a separate list of acronyms

\makeglossaries

\newglossaryentry{sample}{name={sample},
description={a sample entry}}

% This contrived acronym has non-standard plural forms.
% These are specified in the optional argument.
\newacronym[\glsshortpluralkey=cas,\glslongpluralkey=contrived 
acronyms]{aca}{aca}{a contrived acronym}

\begin{document}
A \gls{sample} entry and \gls{aca}. Second use: \gls{aca}.

Plurals: \glspl{sample}. Reset acronym\glsreset{aca}.
First use: \glspl{aca}. Second use: \glspl{aca}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</minimalgls.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-crossref.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[sanitize={description=false}]{glossaries}

\makeglossaries

\renewcommand{\glsseeitemformat}[1]{\textsc{\glsentryname{#1}}}

\newglossaryentry{pear}{name=pear,
description={an oddly shaped fruit}}

\newglossaryentry{apple}{name=apple,
description={firm, round fruit},
see=[see also]{pear}}

\newglossaryentry{banana}{name=banana,
description={a yellow fruit with an even odder shape than
a \gls{pear}}}

\newglossaryentry{fruit}{name=fruit,
description={sweet, fleshy product of plant containing seed}}

\glssee{fruit}{pear,apple,banana}

\begin{document}
\gls{pear}, \gls{apple} and \gls{banana}.

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-crossref.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-custom-acronym.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[acronym,         % create list of acronyms
            nomain,          % don't need main glossary for this example
            style=tree,      % need a style that displays the symbol
            hyperfirst=false,% don't hyperlink first use
            sanitize=none    % switch off sanitization as description 
                             % will be used in the main text
            ]{glossaries}

\makeglossaries

  % This is a sample file to illustrate how to define a custom
  % acronym. This example defines the acronym so that on first use
  % it displays the short form in the text and places the long form
  % and its description in a footnote. In the main body of the
  % document the short form will be displayed in small caps, but in
  % the list of acronyms the short form is displayed in normal
  % capitals. To ensure this, the short form should be written in
  % lower case when the acronym is defined, and \MakeUppercase is
  % used when it's displayed in the list of acronyms.

  % In the list of acronyms, the long form is used as the name, the
  % short form is used as the symbol and the user supplies the
  % description when defining the acronym.

\renewcommand*{\CustomAcronymFields}{%
  name={\the\glslongtok},%
  symbol={\MakeUppercase{\the\glsshorttok}},%
  text={\textsc{\the\glsshorttok}},%
  plural={\textsc{\the\glsshorttok}\noexpand\acrpluralsuffix}%
}

\renewcommand*{\SetCustomDisplayStyle}[1]{%
  % ##1 corresponds to the 'first' key
  % ##2 corresponds to the 'description' key
  % ##3 corresponds to the 'symbol' key
  % ##4 is the inserted text given by the final optional argument to
  % commands like \gls
  % The short form can be obtained via \glsentryshort{\glslabel}
  % The plural short form can be obtained via
  % \glsentryshortplural{\glslabel}
  % The long form can be obtained via \glsentrylong{\glslabel}
  % The plural long form can be obtained via
  % \glsentrylongplural{\glslabel}
  \defglsdisplayfirst[#1]{##1##4\protect\footnote{%
    \glsentrylong{\glslabel}: ##2}}%
  % ##1 corresponds to the 'text' key
  % the rest as above
  \defglsdisplay[#1]{##1##4}%
}

 % Now set the custom acronym style (to override the default style)
\SetCustomStyle

 % Now define the acronyms (must be done after setting the custom
 % style)

\newacronym[description={set of tags for use in developing hypertext
documents}]{html}{html}{Hyper Text Markup Language}

\newacronym[description={language used to describe the layout of a
document written in a markup language}]{css}{css}{Cascading Style
Sheet}

\begin{document}

\gls{css}. \gls{html}.

\gls{css}. \gls{html}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-custom-acronym.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-dual.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{article}

\usepackage[acronym]{glossaries}

 % \newdualentry[main options]{label}{short}{long}{description}

\newcommand*{\newdualentry}[5][]{%
  \newglossaryentry{main-#2}{name={#4},%
  text={#3\protect\glsadd{#2}},%
  description={#5},%
  #1
  }%
  \newacronym{#2}{#3\protect\glsadd{main-#2}}{#4}
}

\newdualentry{svm}% label
  {SVM}% abbreviation
  {support vector machine}% long form
  {Statistical pattern recognition technique}% description

\makeglossaries

\begin{document}

\gls{svm}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-dual.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-inline.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper]{report}

\usepackage[plainpages=false,colorlinks]{hyperref}
\usepackage[toc,order=word,subentrycounter]{glossaries}

\usepackage{glossary-inline}

\renewcommand*{\glossarysection}[2][]{\textbf{#1}: }
\renewcommand{\glsnamefont}[1]{\textsc{#1}}
\glossarystyle{inline}

\makeglossaries

\newglossaryentry{Perl}{name=\texttt{Perl},
sort=Perl, % need a sort key because name contains a command
description=A scripting language}

\newglossaryentry{glossary}{name=glossary,
description={\nopostdesc},
plural={glossaries}}

\newglossaryentry{glossarycol}{
description={collection of glosses},
sort={2},
parent={glossary}}

\newglossaryentry{glossarylist}{
description={list of technical words},
sort={1},
parent={glossary}}

\newglossaryentry{pagelist}{name=page list,
 % description value has to be enclosed in braces
 % because it contains commas
description={a list of individual pages or page ranges 
(e.g.\ 1,2,4,7-9)}}

\newglossaryentry{mtrx}{name=matrix,
description={rectangular array of quantities},
 % plural is not simply obtained by appending an s, so specify
plural=matrices}

 % entry with a paragraph break in the description

\newglossaryentry{par}{name=paragraph,
description={distinct section of piece of 
writing. Beginning on new, usually indented, line}}

 % entry with two types of plural. Set the plural form to the 
 % form most likely to be used. If you want to use a different
 % plural, you will need to explicity specify it in \glslink
\newglossaryentry{cow}{name=cow,
 % this isn't necessary, as this form (appending an s) is
 % the default
plural=cows,
 % description:
description={(\emph{pl.}\ cows, \emph{archaic} kine) an adult
female of any bovine animal}}

\newglossaryentry{bravo}{name={bravo},
description={\nopostdesc}}

\newglossaryentry{bravo1}{description={cry of approval (pl.\ bravos)},
sort={1},
plural={bravos},
parent=bravo}

\newglossaryentry{bravo2}{description={hired ruffian or killer (pl.\ bravoes)},
sort={2},
plural={bravoes},
parent=bravo}

\newglossaryentry{seal}{name=seal,description={sea mammal with
flippers that eats fish}}

\newglossaryentry{sealion}{name={sea lion},
description={large seal}}

\begin{document}

\title{Sample Document Using glossary Package}
\author{Nicola Talbot}
\pagenumbering{alph}% prevent duplicate page link names if using PDF
\maketitle

\pagenumbering{roman}
\tableofcontents

\chapter{Introduction}
\pagenumbering{arabic}

This document has a glossary in a footnote\footnote{\printglossaries}.

A \gls{glossarylist} (definition~\glsrefentry{glossarylist}) is a
very useful addition to any technical document, although a
\gls{glossarycol} (definition~\glsrefentry{glossarycol}) can also
simply be a collection of glosses, which is another thing entirely.
Some documents have multiple \glspl{glossarylist}.

Once you have run your document through \LaTeX, you
will then need to run the \texttt{.glo} file through
\texttt{makeindex}.  You will need to set the output
file so that it creates a \texttt{.gls} file instead
of an \texttt{.ind} file, and change the name of 
the log file so that it doesn't overwrite the index
log file (if you have an index for your document).  
Rather than having to remember all the command line
switches, you can call the \gls{Perl} script
\texttt{makeglossaries} which provides a convenient
wrapper.

If a comma appears within the name or description, grouping
must be used, e.g.\ in the description of \gls{pagelist}.

\chapter{Plurals and Paragraphs}

Plurals are assumed to have the letter s appended, but if this is
not the case, as in \glspl{mtrx}, then you need to specify the
plural when you define the entry. If a term may have multiple
plurals (for example \glspl{cow}/\glslink{cow}{kine}) then 
define the entry with the plural form most likely to be used and
explicitly specify the alternative form using \verb|\glslink|.
\Glspl{seal} and \glspl{sealion} have regular plural forms.

\Gls{bravo} is a homograph, but the plural forms are spelt
differently. The plural of \gls{bravo1}, a cry of approval
(definition~\glsrefentry{bravo1}), is \glspl{bravo1}, whereas the
plural of \gls{bravo2}, a hired ruffian or killer
(definition~\glsrefentry{bravo2}), is \glspl{bravo2}.

\Glspl{par} can cause a problem in commands, so care is needed
when having a paragraph break in a \gls{glossarylist} entry.

\chapter{Ordering}

There are two types of ordering: word ordering (which places
``\gls{sealion}'' before ``\gls{seal}'') and letter ordering
(which places ``\gls{seal}'' before ``\gls{sealion}'').



\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-inline.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-langdict.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
\documentclass[english,french]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[nomain]{glossaries}

\newglossary[glg]{english}{gls}{glo}{English to French}
\newglossary[flg]{french}{fls}{flo}{French to English}

\makeglossaries

 % \newword{label}{english}{determiner}{french}
\newcommand*{\newword}[4]{%
   \newglossaryentry{en-#1}{type=english,name={#2},description={#3 #4}}%
   \newglossaryentry{fr-#1}{type=french,name={#3 #4},text={#4},sort={#4},description={#2}}%
}

\newword{cat}{cat}{le}{chat}
\newword{mat}{mat}{la}{natte}

\begin{document}
\selectlanguage{english}
The \gls{en-cat} sat on the \gls{en-mat}.

\selectlanguage{french}
Le \gls{fr-cat} s'est repos\'e sur la \gls{fr-mat}.

\selectlanguage{english}
\printglossary[type=english]

\selectlanguage{french}
\printglossary[type=french]
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-langdict.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-mfirstuc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
\documentclass{article}

\usepackage{mfirstuc}

\begin{document}

\makefirstuc{abc}.

\makefirstuc{{\em abc}}.

\makefirstuc{\emph{abc}}.

\makefirstuc{\ae bc}.

\makefirstuc{{\ae}bc}.

\newcommand{\abc}{abc}%
\xmakefirstuc{\abc}.

\capitalisewords{a book of rhyme.}

\capitalisewords{a book\space of rhyme.}

\newcommand{\mytitle}{a book\space of rhyme.}
\capitalisewords{\mytitle}

\xcapitalisewords{\mytitle}


\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-mfirstuc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-numberlist.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[savenumberlist,counter=chapter]{glossaries}

\makeglossaries

\newglossaryentry{sample}{name=sample,description=an example}

\begin{document}
\chapter{Introduction}

This is a \glsentryname{sample} document. \Glsentryplural{sample}
are discussed in chapters~\glsdisplaynumberlist{sample}.

\chapter{Sample Documents}

\Gls{sample} documents are provided for testing and illustration
purposes.

\chapter{More About Samples}

Here's more information about \glspl{sample}.

\chapter{Another chapter}

A chapter about something else.

\chapter{Another About Samples}

Here's some more information about \glspl{sample}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-numberlist.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper]{report}

\usepackage[plainpages=false,colorlinks]{hyperref}
\usepackage[toc,style=treenoname,order=word,subentrycounter]{glossaries}

\makeglossaries

\newglossaryentry{Perl}{name=\texttt{Perl},
sort=Perl, % need a sort key because name contains a command
description=A scripting language}

\newglossaryentry{glossary}{name=glossary,
description={\nopostdesc},
plural={glossaries}}

\newglossaryentry{glossarycol}{
description={collection of glosses},
sort={2},
parent={glossary}}

\newglossaryentry{glossarylist}{
description={list of technical words},
sort={1},
parent={glossary}}

\newglossaryentry{pagelist}{name=page list,
 % description value has to be enclosed in braces
 % because it contains commas
description={a list of individual pages or page ranges 
(e.g.\ 1,2,4,7-9)}}

\newglossaryentry{mtrx}{name=matrix,
description={rectangular array of quantities},
 % plural is not simply obtained by appending an s, so specify
plural=matrices}

 % entry with a paragraph break in the description

\newglossaryentry{par}{name=paragraph,
description={distinct section of piece of 
writing.\glspar Beginning on new, usually indented, line}}

 % entry with two types of plural. Set the plural form to the 
 % form most likely to be used. If you want to use a different
 % plural, you will need to explicity specify it in \glslink
\newglossaryentry{cow}{name=cow,
 % this isn't necessary, as this form (appending an s) is
 % the default
plural=cows,
 % description:
description={(\emph{pl.}\ cows, \emph{archaic} kine) an adult
female of any bovine animal}}

\newglossaryentry{bravo}{name={bravo},
description={\nopostdesc}}

\newglossaryentry{bravo1}{description={cry of approval (pl.\ bravos)},
sort={1},
plural={bravos},
parent=bravo}

\newglossaryentry{bravo2}{description={hired ruffian or killer (pl.\ bravoes)},
sort={2},
plural={bravoes},
parent=bravo}

\newglossaryentry{seal}{name=seal,description={sea mammal with
flippers that eats fish}}

\newglossaryentry{sealion}{name={sea lion},
description={large seal}}

\begin{document}

\title{Sample Document Using glossary Package}
\author{Nicola Talbot}
\pagenumbering{alph}% prevent duplicate page link names if using PDF
\maketitle

\pagenumbering{roman}
\tableofcontents

\chapter{Introduction}
\pagenumbering{arabic}

A \gls{glossarylist} (definition~\glsrefentry{glossarylist}) is a
very useful addition to any technical document, although a
\gls{glossarycol} (definition~\glsrefentry{glossarycol}) can also
simply be a collection of glosses, which is another thing entirely.
Some documents have multiple \glspl{glossarylist}.

Once you have run your document through \LaTeX, you
will then need to run the \texttt{.glo} file through
\texttt{makeindex}.  You will need to set the output
file so that it creates a \texttt{.gls} file instead
of an \texttt{.ind} file, and change the name of 
the log file so that it doesn't overwrite the index
log file (if you have an index for your document).  
Rather than having to remember all the command line
switches, you can call the \gls{Perl} script
\texttt{makeglossaries} which provides a convenient
wrapper.

If a comma appears within the name or description, grouping
must be used, e.g.\ in the description of \gls{pagelist}.

\chapter{Plurals and Paragraphs}

Plurals are assumed to have the letter s appended, but if this is
not the case, as in \glspl{mtrx}, then you need to specify the
plural when you define the entry. If a term may have multiple
plurals (for example \glspl{cow}/\glslink{cow}{kine}) then 
define the entry with the plural form most likely to be used and
explicitly specify the alternative form using \verb|\glslink|.
\Glspl{seal} and \glspl{sealion} have regular plural forms.

\Gls{bravo} is a homograph, but the plural forms are spelt
differently. The plural of \gls{bravo1}, a cry of approval
(definition~\glsrefentry{bravo1}), is \glspl{bravo1}, whereas the
plural of \gls{bravo2}, a hired ruffian or killer
(definition~\glsrefentry{bravo2}), is \glspl{bravo2}.

\Glspl{par} can cause a problem in commands, so care is needed
when having a paragraph break in a \gls{glossarylist} entry.

\chapter{Ordering}

There are two types of ordering: word ordering (which places
``\gls{sealion}'' before ``\gls{seal}'') and letter ordering
(which places ``\gls{seal}'' before ``\gls{sealion}'').

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample4col.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper]{article}

\usepackage[style=long4colheaderborder]{glossaries}

\makeglossaries

\newglossaryentry{w}{name={$w$},
sort=w,
description={width},
symbol=m}

\newglossaryentry{M}{name={$M$},
sort=M,
description={mass},
symbol=kg}

\begin{document}

\printglossaries

The width, \gls{w}, is measured in meters. The mass, \gls{M} is
measured in kilograms.

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample4col.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleaccsupp.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{article}

\usepackage[acronym,smallcaps]{glossaries-accsupp}

\makeglossaries

\newglossaryentry{dr}{name=Dr,description={Doctor},access={Doctor}}

\newacronym[shortaccess=S V M]{svm}{svm}{support vector machine}

\newacronym{eg}{e.g.}{for example}

\begin{document}
\gls{dr}~Jones.
\gls{dr}~Jones.

\Gls{eg}, \gls{eg}, \acrshort{eg}, \acrlong{eg}, \acrfull{eg}.

\Acrshort{eg}, \ACRshort{eg}. \Acrlong{eg}, \ACRlong{eg}.
\Acrfull{eg}, \ACRfull{eg}.

\gls{svm}. \gls{svm}, \acrshort{svm}, \acrlong{svm}, \acrfull{svm}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleaccsupp.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleAcr.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper]{report}

\usepackage[colorlinks,plainpages=false]{hyperref}
\usepackage[style=long,% use 'long' style for the glossary
            toc,% add glossary to table of contents
            smallcaps% Use small caps for acronyms
           ]{glossaries}

\makeglossaries

\newacronym{svm}% label
{svm}% abbreviation
{support vector machine}% long form

\newacronym{ksvm}{ksvm}{kernel support vector machine}

\newacronym{rna}{rna}{ribonukleins\"aure}

\begin{document}
\tableofcontents

\chapter{Support Vector Machines}

\Glspl{svm} are used widely in the area of pattern recognition.
Subsequent use: \gls{svm}.

Short version: \acrshort{svm}. Long version: \acrlong{svm}. Full
version: \acrfull{svm}. Description: \glsentrydesc{svm}.

This is the entry in uppercase: \GLS{svm}.

\chapter{Kernel Support Vector Machines}

The \gls{ksvm} is \ifglsused{svm}{an}{a} \gls{svm} that uses
the so called ``kernel trick''. Plural: \glspl{ksvm}. Resetting
acronyms.

\glsresetall
Possessive: \gls{ksvm}['s].
Make the glossary entry number bold for this 
one \gls[format=hyperbf]{ksvm}.

\chapter{Short, Long and Full Forms}

These commands don't affect the first use flag:

\begin{center}
\begin{tabular}{lll}
 & Unstarred & Starred\\
acrshort & \acrshort{svm} & \acrshort*{svm}\\
Acrshort & \Acrshort{svm} & \Acrshort*{svm}\\
ACRshort & \ACRshort{svm} & \ACRshort*{svm}\\
acrlong & \acrlong{svm} & \acrlong*{svm}\\
Acrlong & \Acrlong{svm} & \Acrlong*{svm}\\
ACRlong & \ACRlong{svm} & \ACRlong*{svm}\\
acrfull & \acrfull{svm} & \acrfull*{svm}\\
Acrfull & \Acrfull{svm} & \Acrfull*{svm}\\
ACRfull & \ACRfull{svm} & \ACRfull*{svm}\\
\\
& Insert Unstarred & Insert Starred\\
acrshort & \acrshort{svm}['s] & \acrshort*{svm}['s]\\
Acrshort & \Acrshort{svm}['s] & \Acrshort*{svm}['s]\\
ACRshort & \ACRshort{svm}['s] & \ACRshort*{svm}['s]\\
acrlong & \acrlong{svm}['s] & \acrlong*{svm}['s]\\
Acrlong & \Acrlong{svm}['s] & \Acrlong*{svm}['s]\\
ACRlong & \ACRlong{svm}['s] & \ACRlong*{svm}['s]\\
acrfull & \acrfull{svm}['s] & \acrfull*{svm}['s]\\
Acrfull & \Acrfull{svm}['s] & \Acrfull*{svm}['s]\\
ACRfull & \ACRfull{svm}['s] & \ACRfull*{svm}['s]
\end{tabular}
\end{center}

\chapter{Another chapter}

You don't need to worry about makeindex's special characters:
\gls{rna}.

\printglossary[title={List of Acronyms}]

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleAcr.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleAcrDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper]{report}

\usepackage[colorlinks,plainpages=false]{hyperref}

\usepackage[acronym,% create 'acronym' glossary type
            nomain,% 'main' glossary not needed as using 'acronym'
            style=altlist, % use altlist style
            toc, % add the glossary to the table of contents
            sanitize={description=false},% want to use description in main document
            smallcaps,%
            description% acronyms have a user-supplied description
           ]{glossaries}

\makeglossaries

% Change the "see" items so that they use \acronymfont:
\renewcommand*{\glsseeitemformat}[1]{\acronymfont{\glsentrytext{#1}}}

% Change the default style for the "name" key:
\renewcommand*{\acrnameformat}[2]{\acronymfont{#1} (#2)}

% Not using a font that supports bold smallcaps so change the way
% the name is formatted in the glossary:

\renewcommand*{\glsnamefont}[1]{\textmd{#1}}

\newacronym[description={Statistical pattern recognition 
technique~\protect\cite{svm}}, % acronym's description
]{svm}{svm}{support vector machine}

\newacronym[description={Statistical pattern recognition technique
using the ``kernel trick''},% acronym's description
see={[see also]{svm}},
]{ksvm}{ksvm}{kernel 
support vector machine}

\begin{document}
\tableofcontents

\chapter{Support Vector Machines}

The \gls{svm} is used widely in the area of pattern recognition.
 % plural form with initial letter in uppercase:
\Glspl{svm} are \ldots

Short version: \acrshort{svm}. Long version: \acrlong{svm}. Full 
version: \acrfull{svm}. Description: \glsentrydesc{svm}.

This is the entry in uppercase: \GLS{svm}.

\chapter{Kernel Support Vector Machines}

The \gls{ksvm} is \ifglsused{svm}{an}{a} \gls{svm} that uses
the so called ``kernel trick''. This is the entry's description without
a link: \glsentrydesc{ksvm}.

\glsresetall
Possessive: \gls{ksvm}['s].
Make the glossary entry number bold for this 
one \gls[format=hyperbf]{svm}.

\begin{thebibliography}{1}
\bibitem{svm} \ldots
\end{thebibliography}

\printglossary

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleAcrDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleacronyms.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{article}

\usepackage[acronym,footnote,acronymlists={main,acronym2}]{glossaries}

\newglossary[alg2]{acronym2}{acr2}{acn2}{Statistical Acronyms}

\makeglossaries

% Main glossary is a list of calculus acronyms

\renewcommand{\glossaryname}{Calculus Acronyms}

\newacronym[type=main]{vc}{VC}{Vector Calculus}
\newacronym[type=main]{ftoc}{FTOC}{Fundamental Theorem of Calculus}

% "acronym" glossary is a list of computer related acronyms

\renewcommand{\acronymname}{Computer Acronyms}

\newacronym{kb}{kb}{KiloBit}
\newacronym{kB}{kB}{KiloByte}

% "acronym2" glossary is a list of statistical acronyms

\newacronym[type=acronym2]{svm}{SVM}{Support Vector Machine}

\begin{document}
\section{Sample Section}
\gls{kb}. \gls{kB}. \gls{vc}. \gls{ftoc}. \gls{svm}.

\gls{kb}. \gls{kB}. \gls{vc}. \gls{ftoc}. \gls{svm}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleacronyms.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleDB.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{article}

\usepackage[colorlinks,plainpages=false]{hyperref}
\usepackage[nonumberlist]{glossaries}

\newglossary[nlg]{symbols}{not}{ntn}{Symbols}

\makeglossaries

\loadglsentries{database1}
\loadglsentries[symbols]{database2}

\begin{document}

\glsaddall

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleDB.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 %
 % See also sampleAcrDesc.tex
\documentclass[a4paper]{report}

\usepackage[colorlinks,plainpages=false]{hyperref}

\usepackage[style=altlist, % use altlist style
            toc, % add the glossary to the table of contents
            sanitize={description=false}% don't sanitize description
           ]{glossaries}

\makeglossaries

\newglossaryentry{svm}{
 % how the entry name should appear in the glossary
name={Support vector machine (SVM)},
 % how the description should appear in the glossary
 % since I have used sanitize={description=false}
 % I have to protect fragile commands
description={Statistical pattern recognition
technique~\protect\cite{svm}},
 % how the entry should appear in the document text
text={svm},
 % how the entry should appear the first time it is
 % used in the document text
first={support vector machine (svm)}}

\newglossaryentry{ksvm}{
name={Kernel support vector machine (KSVM)},
description={Statistical pattern recognition technique
using the ``kernel trick'' (see also SVM)},
text={ksvm},
first={kernel support vector machine}}

\begin{document}
\tableofcontents

\chapter{Support Vector Machines}

The \gls{svm} is used widely in the area of pattern recognition.
 % plural form with initial letter in uppercase:
\Glspl{svm} are \ldots

This is the text produced without a link: \glsentrytext{svm}.
This is the text produced on first use without a link:
\glsentryfirst{svm}. This is the entry's description without
a link: \glsentrydesc{svm}.

This is the entry in uppercase: \GLS{svm}.

\chapter{Kernel Support Vector Machines}

The \gls{ksvm} is \ifglsused{svm}{an}{a} \gls{svm} that uses
the so called ``kernel trick''.

\glsresetall
Possessive: \gls{ksvm}['s].
Make the glossary entry number bold for this 
one \gls[format=hyperbf]{svm}.

\begin{thebibliography}{1}
\bibitem{svm} \ldots
\end{thebibliography}

\printglossary[title={Acronyms}]

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleEq.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass[a4paper,12pt]{report}

\usepackage{amsmath}
\usepackage[colorlinks]{hyperref}
\usepackage[toc,ucmark,style=long3colheader,counter=equation]{glossaries}

\makeglossaries

\newcommand{\erf}{\operatorname{erf}}
\newcommand{\erfc}{\operatorname{erfc}}

\pagestyle{headings}

 % redefine the way hyperref creates the target for equations
 % so that the glossary links to equation numbers work

 \renewcommand*\theHequation{\theHchapter.\arabic{equation}}

 % Change the glossary headings

\renewcommand{\entryname}{Notation}
\renewcommand{\descriptionname}{Function Name}
\renewcommand{\pagelistname}{Number of Formula}

 % define glossary entries

\newglossaryentry{Gamma}{name=\ensuremath{\Gamma(z)},
description=Gamma function,
sort=Gamma}

\newglossaryentry{gamma}{name={\ensuremath{\gamma(\alpha,x)}},
description=Incomplete gamma function,
sort=gamma}

\newglossaryentry{iGamma}{name={\ensuremath{\Gamma(\alpha,x)}},
description=Incomplete gamma function,
sort=Gamma}

\newglossaryentry{psi}{name=\ensuremath{\psi(x)},
description=Psi function,sort=psi}

\newglossaryentry{erf}{name=\ensuremath{\erf(x)},
description=Error function,sort=erf}

\newglossaryentry{erfc}{name=\ensuremath{\erfc},
description=Complementary error function,sort=erfc}

\newglossaryentry{B}{name={\ensuremath{B(x,y)}},
description=Beta function,sort=B}

\newglossaryentry{Bx}{name={\ensuremath{B_x(p,q)}},
description=Incomplete beta function,sort=Bx}

\newglossaryentry{Tn}{name=\ensuremath{T_n(x)},
description=Chebyshev's polynomials of the first kind,sort=Tn}

\newglossaryentry{Un}{name=\ensuremath{U_n(x)},
description=Chebyshev's polynomials of the second kind,sort=Un}

\newglossaryentry{Hn}{name=\ensuremath{H_n(x)},
description=Hermite polynomials,sort=Hn}

\newglossaryentry{Ln}{name=\ensuremath{L_n^\alpha(x)},
description=Laguerre polynomials,sort=Lna}

\newglossaryentry{Znu}{name=\ensuremath{Z_\nu(z)},
description=Bessel functions,sort=Z}

\newglossaryentry{Phi}{name={\ensuremath{\Phi(\alpha,\gamma;z)}},
description=confluent hypergeometric function,sort=Pagz}

\newglossaryentry{knu}{name=\ensuremath{k_\nu(x)},
description=Bateman's function,sort=kv}

\newglossaryentry{Dp}{name=\ensuremath{D_p(z)},
description=Parabolic cylinder functions,sort=Dp}

\newglossaryentry{F}{name={\ensuremath{F(\phi,k)}},
description=Elliptical integral of the first kind,sort=Fpk}

\newglossaryentry{C}{name=\ensuremath{C},
description=Euler's constant,sort=C}

\newglossaryentry{G}{name=\ensuremath{G},
description=Catalan's constant,sort=G}

\begin{document}
\title{A Sample Document Using glossaries.sty}
\author{Nicola Talbot}
\maketitle

\begin{abstract}
This is a sample document illustrating the use of the \textsf{glossaries}
package.  The functions here have been taken from ``Tables of
Integrals, Series, and Products'' by I.S.~Gradshteyn and I.M~Ryzhik.
The glossary is a list of special functions, so 
the equation number has been used rather than the page number.  This 
can be done using the \texttt{counter=equation} package
option.
\end{abstract}

\printglossary[title={Index of Special Functions and Notations}]

\chapter{Gamma Functions}

\begin{equation}
\gls{Gamma} = \int_{0}^{\infty}e^{-t}t^{z-1}\,dt
\end{equation}

\verb|\ensuremath| is only required here if using 
hyperlinks.
\begin{equation}
\glslink{Gamma}{\ensuremath{\Gamma(x+1)}} = x\Gamma(x)
\end{equation}

\begin{equation}
\gls{gamma} = \int_0^x e^{-t}t^{\alpha-1}\,dt
\end{equation}

\begin{equation}
\gls{iGamma} = \int_x^\infty e^{-t}t^{\alpha-1}\,dt
\end{equation}

\newpage

\begin{equation}
\gls{Gamma} = \Gamma(\alpha, x) + \gamma(\alpha, x)
\end{equation}

\begin{equation}
\gls{psi} = \frac{d}{dx}\ln\Gamma(x)
\end{equation}

\chapter{Error Functions}

\begin{equation}
\gls{erf} = \frac{2}{\surd\pi}\int_0^x e^{-t^2}\,dt
\end{equation}

\begin{equation}
\gls{erfc} = 1 - \erf(x)
\end{equation}

\chapter{Beta Function}

\begin{equation}
\gls{B} = 2\int_0^1 t^{x-1}(1-t^2)^{y-1}\,dt
\end{equation}
Alternatively:
\begin{equation}
\gls{B} = 2\int_0^{\frac\pi2}\sin^{2x-1}\phi\cos^{2y-1}\phi\,d\phi
\end{equation}

\begin{equation}
\gls{B} = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} = B(y,x)
\end{equation}

\begin{equation}
\gls{Bx} = \int_0^x t^{p-1}(1-t)^{q-1}\,dt
\end{equation}

\chapter{Polynomials}

\section{Chebyshev's polynomials}

\begin{equation}
\gls{Tn} = \cos(n\arccos x)
\end{equation}

\begin{equation}
\gls{Un} = \frac{\sin[(n+1)\arccos x]}{\sin[\arccos x]}
\end{equation}

\section{Hermite polynomials}

\begin{equation}
\gls{Hn} = (-1)^n e^{x^2} \frac{d^n}{dx^n}(e^{-x^2})
\end{equation}

\section{Laguerre polynomials}

\begin{equation}
L_n^{\alpha} (x) = \frac{1}{n!}e^x x^{-\alpha} 
\frac{d^n}{dx^n}(e^{-x}x^{n+\alpha})
\end{equation}

\chapter{Bessel Functions}

Bessel functions $Z_\nu$ are solutions of
\begin{equation}
\frac{d^2\glslink{Znu}{Z_\nu}}{dz^2} 
+ \frac{1}{z}\,\frac{dZ_\nu}{dz} + 
\left( 1-\frac{\nu^2}{z^2}Z_\nu = 0 \right)
\end{equation}

\chapter{Confluent hypergeometric function}

\begin{equation}
\gls{Phi} = 1 + \frac{\alpha}{\gamma}\,\frac{z}{1!}
+ \frac{\alpha(\alpha+1)}{\gamma(\gamma+1)}\,\frac{z^2}{2!}
+\frac{\alpha(\alpha+1)(\alpha+2)}{\gamma(\gamma+1)(\gamma+2)}\,
\frac{z^3}{3!} + \cdots
\end{equation}

\begin{equation}
\gls{knu} = \frac{2}{\pi}\int_0^{\pi/2}
\cos(x \tan\theta - \nu\theta)\,d\theta
\end{equation}

\chapter{Parabolic cylinder functions}

\begin{equation}
\gls{Dp} = 2^{\frac{p}{2}}e^{-\frac{z^2}{4}}
\left\{
\frac{\surd\pi}{\Gamma\left(\frac{1-p}{2}\right)}
\Phi\left(-\frac{p}{2},\frac{1}{2};\frac{z^2}{2}\right)
-\frac{\sqrt{2\pi}z}{\Gamma\left(-\frac{p}{2}\right)}
\Phi\left(\frac{1-p}{2},\frac{3}{2};\frac{z^2}{2}\right)
\right\}
\end{equation}

\chapter{Elliptical Integral of the First Kind}

\begin{equation}
\gls{F} = \int_0^\phi \frac{d\alpha}{\sqrt{1-k^2\sin^2\alpha}}
\end{equation}

\chapter{Constants}

\begin{equation}
\gls{C} = 0.577\,215\,664\,901\ldots
\end{equation}

\begin{equation}
\gls{G} = 0.915\,965\,594\ldots
\end{equation}

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleEq.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleEqPg.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 %
 % To ensure that the page numbers are up-to-date:
 %
 % latex sampleEqPg
 % makeglossaries sampleEqPg
 % latex sampleEqPg
 % makeglossaries sampleEqPg
 % latex sampleEqPg
 %
 % The extra makeglossaries run is required because adding the
 % glossary in the second LaTeX run shifts the page numbers on
 % which means that the glossary needs to be updated again.
 % (Note that this problem is avoided if the page numbering is
 % reset after the glossary. For example, if the glossary has
 % roman numbering and the subsequent pages have arabic numbering)
\documentclass[a4paper,12pt]{report}

\usepackage{amsmath}
\usepackage[colorlinks]{hyperref}
\usepackage[style=long3colheader,toc,
            counter=equation]{glossaries}

\newcommand{\erf}{\operatorname{erf}}
\newcommand{\erfc}{\operatorname{erfc}}

 % redefine the way hyperref creates the target for equations
 % so that the glossary links to equation numbers work

\renewcommand*\theHequation{\thechapter.\arabic{equation}}

\renewcommand{\glossaryname}{Index of Special Functions and Notations}

\renewcommand{\glossarypreamble}{Numbers in italic indicate the equation number,
numbers in bold indicate page numbers where the main definition occurs.\par}

 % set the glossary number style to italic
 % hyperit is used instead of textit because
 % the hyperref package is being used.
\renewcommand{\glsnumberformat}[1]{\hyperit{#1}}

 % 1st column heading
\renewcommand{\entryname}{Notation}

 % 2nd column heading
\renewcommand{\descriptionname}{Function Name}

 % 3rd column heading
\renewcommand{\pagelistname}{}

 % Redefine header row so that it
 % adds a blank row after the title row
\renewcommand{\glossaryheader}{\bfseries\entryname &
\bfseries\descriptionname&\bfseries\pagelistname\\
& & \\\endhead}

 % Define glossary entries

\newglossaryentry{Gamma}{name=\ensuremath{\Gamma(z)},
description=Gamma function,sort=Gamma}

\newglossaryentry{gamma}{name=\ensuremath{\gamma(\alpha,x)},
description=Incomplete gamma function,sort=gamma}

\newglossaryentry{iGamma}{name=\ensuremath{\Gamma(\alpha,x)},
description=Incomplete gamma function,sort=Gamma}

\newglossaryentry{psi}{name=\ensuremath{\psi(x)},
description=Psi function,sort=psi}

\newglossaryentry{erf}{name=\ensuremath{\erf(x)},
description=Error function,sort=erf}

\newglossaryentry{erfc}{name=\ensuremath{\erfc(x)},
description=Complementary error function,sort=erfc}

\newglossaryentry{beta}{name=\ensuremath{B(x,y)},
description=Beta function,sort=B}

\newglossaryentry{Bx}{name=\ensuremath{B_x(p,q)},
description=Incomplete beta function,sort=Bx}

\newglossaryentry{Tn}{name=\ensuremath{T_n(x)},
description=Chebyshev's polynomials of the first kind,
sort=Tn}

\newglossaryentry{Un}{name=\ensuremath{U_n(x)},
description=Chebyshev's polynomials of the second kind,
sort=Un}

\newglossaryentry{Hn}{name=\ensuremath{H_n(x)},
description=Hermite polynomials,sort=Hn}

\newglossaryentry{Lna}{name=\ensuremath{L_n^\alpha(x)},
description=Laguerre polynomials,sort=Lna}

\newglossaryentry{Znu}{name=\ensuremath{Z_\nu(z)},
description=Bessel functions,sort=Z}

\newglossaryentry{Pagz}{name=\ensuremath{\Phi(\alpha,\gamma;z)},
description=confluent hypergeometric function,sort=Pagz}

\newglossaryentry{kv}{name=\ensuremath{k_\nu(x)},
description=Bateman's function,sort=kv}

\newglossaryentry{Dp}{name=\ensuremath{D_p(z)},
description=Parabolic cylinder functions,sort=Dp}

\newglossaryentry{Fpk}{name=\ensuremath{F(\phi,k)},
description=Elliptical integral of the first kind,sort=Fpk}

\newglossaryentry{C}{name=\ensuremath{C},
description=Euler's constant,sort=C}

\newglossaryentry{G}{name=\ensuremath{G},
description=Catalan's constant,sort=G}

\makeglossaries

\pagestyle{headings}

\begin{document}

\title{Sample Document Using Interchangable Numbering}
\author{Nicola Talbot}
\maketitle

\begin{abstract}
This is a sample document illustrating the use of the \textsf{glossaries}
package.  The functions here have been taken from ``Tables of
Integrals, Series, and Products'' by I.S.~Gradshteyn and I.M~Ryzhik.

The glossary lists both page numbers and equation numbers.  
Since the majority of the entries use the equation number,
\texttt{counter=equation} was used as a package option.
Note that this example will only work where the
page number and equation number compositor is the same. So 
it won't work if, say, the page numbers are of the form 
2-4 and the equation numbers are of the form 4.6.  
As most of the glossary entries should have an italic 
format, it is easiest to set the default format to 
italic.

\end{abstract}

\tableofcontents

\printglossary[toctitle={Special Functions}]

\chapter{Gamma Functions}

The \glslink[format=hyperbf,counter=page]{Gamma}{gamma function} is 
defined as
\begin{equation}
\gls{Gamma} = \int_{0}^{\infty}e^{-t}t^{z-1}\,dt
\end{equation}

\begin{equation}
\glslink{Gamma}{\ensuremath{\Gamma(x+1)}} = x\Gamma(x)
\end{equation}

\begin{equation}
\gls{gamma} = \int_0^x e^{-t}t^{\alpha-1}\,dt
\end{equation}

\begin{equation}
\gls{iGamma} = \int_x^\infty e^{-t}t^{\alpha-1}\,dt
\end{equation}

\newpage

\begin{equation}
\glslink{Gamma}{\ensuremath{\Gamma(\alpha)}} = 
\Gamma(\alpha, x) + \gamma(\alpha, x)
\end{equation}

\begin{equation}
\gls{psi} = \frac{d}{dx}\ln\Gamma(x)
\end{equation}

\chapter{Error Functions}

The \glslink[format=hyperbf,counter=page]{erf}{error function} is defined as:
\begin{equation}
\gls{erf} = \frac{2}{\surd\pi}\int_0^x e^{-t^2}\,dt
\end{equation}

\begin{equation}
\gls{erfc} = 1 - \erf(x)
\end{equation}

\chapter{Beta Function}

\begin{equation}
\gls{beta} = 2\int_0^1 t^{x-1}(1-t^2)^{y-1}\,dt
\end{equation}
Alternatively:
\begin{equation}
\gls{beta} = 2\int_0^{\frac\pi2}\sin^{2x-1}\phi\cos^{2y-1}\phi\,d\phi
\end{equation}

\begin{equation}
\gls{beta} = \frac{\Gamma(x)\Gamma(y)}{\Gamma(x+y)} = B(y,x)
\end{equation}

\begin{equation}
\gls{Bx} = \int_0^x t^{p-1}(1-t)^{q-1}\,dt
\end{equation}

\chapter{Chebyshev's polynomials}

\begin{equation}
\gls{Tn} = \cos(n\arccos x)
\end{equation}

\begin{equation}
\gls{Un} = \frac{\sin[(n+1)\arccos x]}{\sin[\arccos x]}
\end{equation}

\chapter{Hermite polynomials}

\begin{equation}
\gls{Hn} = (-1)^n e^{x^2} \frac{d^n}{dx^n}(e^{-x^2})
\end{equation}

\chapter{Laguerre polynomials}

\begin{equation}
\gls{Lna} = \frac{1}{n!}e^x x^{-\alpha} 
\frac{d^n}{dx^n}(e^{-x}x^{n+\alpha})
\end{equation}

\chapter{Bessel Functions}

Bessel functions $Z_\nu(z)$ are solutions of
\begin{equation}
\frac{d^2\glslink{Znu}{Z_\nu}}{dz^2} + \frac{1}{z}\,\frac{dZ_\nu}{dz} + 
\left(
1-\frac{\nu^2}{z^2}Z_\nu = 0
\right)
\end{equation}

\chapter{Confluent hypergeometric function}

\begin{equation}
\gls{Pagz} = 1 + \frac{\alpha}{\gamma}\,\frac{z}{1!}
+ \frac{\alpha(\alpha+1)}{\gamma(\gamma+1)}\,\frac{z^2}{2!}
+\frac{\alpha(\alpha+1)(\alpha+2)}
      {\gamma(\gamma+1)(\gamma+2)}
\,\frac{z^3}{3!}
+ \cdots
\end{equation}

\begin{equation}
\gls{kv} = \frac{2}{\pi}\int_0^{\pi/2}
\cos(x \tan\theta - \nu\theta)\,d\theta
\end{equation}

\chapter{Parabolic cylinder functions}

\begin{equation}
\gls{Dp} = 2^{\frac{p}{2}}e^{-\frac{z^2}{4}}
\left\{
\frac{\surd\pi}{\Gamma\left(\frac{1-p}{2}\right)}
\Phi\left(-\frac{p}{2},\frac{1}{2};\frac{z^2}{2}\right)
-\frac{\sqrt{2\pi}z}{\Gamma\left(-\frac{p}{2}\right)}
\Phi\left(\frac{1-p}{2},\frac{3}{2};\frac{z^2}{2}\right)
\right\}
\end{equation}

\chapter{Elliptical Integral of the First Kind}

\begin{equation}
\gls{Fpk} = \int_0^\phi 
\frac{d\alpha}{\sqrt{1-k^2\sin^2\alpha}}
\end{equation}

\chapter{Constants}

\begin{equation}
\gls{C} = 0.577\,215\,664\,901\ldots
\end{equation}

\begin{equation}
\gls{G} = 0.915\,965\,594\ldots
\end{equation}

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleEqPg.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleNtn.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{report}

\usepackage[plainpages=false,colorlinks]{hyperref}
\usepackage{html}
\usepackage[toc,savewrites,xindy]{glossaries}

 % Define a new glossary type called notation
\newglossary[nlg]{notation}{not}{ntn}{Notation}

\makeglossaries

 % Notation definitions

\newglossaryentry{not:set}{type=notation, % glossary type
name={$\mathcal{S}$},
description={A set},
sort={S}}

\newglossaryentry{not:U}{type=notation,
name={$\mathcal{U}$},
description={The universal set},
sort=U}

\newglossaryentry{not:card}{type=notation,
name={$|\mathcal{S}|$},
description={cardinality of $\mathcal{S}$},
sort=cardinality}

\newglossaryentry{not:fact}{type=notation,
name={$!$},
description={factorial},
sort=factorial}

 % Main glossary definitions

\newglossaryentry{gls:set}{name=set,
description={A collection of distinct objects}}

\newglossaryentry{gls:card}{name=cardinality,
description={The number of elements in the specified set}}

\begin{document}
\title{Sample Document using the glossaries Package}
\author{Nicola Talbot}
\pagenumbering{alph}
\maketitle

\begin{abstract}
 %stop hyperref complaining about duplicate page identifiers:
\pagenumbering{Alph}
This is a sample document illustrating the use of the
\textsf{glossaries} package.  In this example, a new glossary type
called \texttt{notation} is defined, so that the document can have a 
separate glossary of terms and index of notation. The index of notation
doesn't have associated numbers.
\end{abstract}


\pagenumbering{roman}
\tableofcontents

\printglossaries

\chapter{Introduction}
\pagenumbering{arabic}

\glslink{gls:set}{Sets} 
are denoted by a caligraphic font 
e.g.\ \gls{not:set}.

Let \gls[format=hyperit]{not:U} denote the universal set.

The \gls{gls:card} of a set $\mathcal{S}$ is denoted 
\gls{not:card}.

\chapter{Another Chapter}

Another mention of the universal set \gls{not:U}.

The factorial symbol: \gls{not:fact}.

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleNtn.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleSec.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{report}

\usepackage[plainpages=false,colorlinks]{hyperref}
\usepackage[style=altlist,toc,counter=section]{glossaries}

\makeglossaries

\newglossaryentry{ident}{name=identity matrix,
description=diagonal matrix with 1s along the leading diagonal,
plural=identity matrices}

\newglossaryentry{diag}{name=diagonal matrix,
description=matrix whose only non-zero entries are along
the leading diagonal,
plural=diagonal matrices}

\newglossaryentry{sing}{name=singular matrix,
description=matrix with zero determinant,
plural=singular matrices}

\begin{document}

\pagenumbering{roman}
\tableofcontents

\printglossaries

\chapter{Introduction}
\pagenumbering{arabic}
This is a sample document illustrating the use of the
\textsf{glossaries} package.

\chapter{Diagonal matrices}

A \gls[format=hyperit]{diag} is a matrix where all elements not on the
leading diagonal are zero.  This is the
primary definition, so an italic font is used for the page number.

\newpage
\section{Identity matrix}
The \gls[format=hyperit]{ident} is a \gls{diag} whose leading
diagonal elements are all equal to 1.

Here is another entry for a \gls{diag}. And this is the
plural: \glspl{ident}.

This adds an entry into the glossary with a bold number, but
it doesn't create a hyperlink: \gls*[format=hyperbf]{ident}.

\chapter{Singular Matrices}

A \gls{sing} is a matrix with zero determinant.
\Glspl{sing} are non-invertible. Possessive:
a \gls{sing}['s] dimensions are not necessarily equal.

Another \gls{ident} entry.

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleSec.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampletree.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[style=alttreehypergroup,nolong,nosuper]{glossaries}

 % The alttree type of glossary styles need to know the
 % widest entry name for each level
\glssetwidest{Roman letters} % level 0 widest name
\glssetwidest[1]{Sigma}      % level 1 widest name

\makeglossaries

\newglossaryentry{greekletter}{name={Greek letters},
text={Greek letter},
description={\nopostdesc}}

\newglossaryentry{sigma}{name={Sigma},
text={\ensuremath{\Sigma}},
first={\ensuremath{\Sigma} (uppercase sigma)},
symbol={\ensuremath{\Sigma}},
description={Used to indicate summation},
parent=greekletter}

\newglossaryentry{pi}{name={pi},
text={\ensuremath{\pi}},
first={\ensuremath{\pi} (lowercase pi)},
symbol={\ensuremath{\pi}},
description={Transcendental number},
parent=greekletter}

\newglossaryentry{romanletter}{name={Roman letters},
text={Roman letter},
description={\nopostdesc}}

\newglossaryentry{e}{name={e},
description={Unique real number such that the derivative of
the function $e^x$ is the function itself},
parent=romanletter}

\newglossaryentry{C}{name={C},
description={Euler's constant},
parent=romanletter}

\begin{document}
This is a sample document illustrating hierarchical glossary
entries.

\chapter{Greek Letters Used in Mathematics}

Some information about \glspl{greekletter}.
The letter \gls{pi} is used to represent the ratio of a circle's
circumference to its diameter.
The letter \gls{sigma} is used to represent summation.

\chapter{Roman Letters Used in Mathematics}

Some information about \glspl{romanletter}.
The letter \gls{e} is the unique real number such that
the derivative of the function $e^x$ is the function itself.
The letter \gls{C} represents Euler's constant.

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampletree.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleutf8.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[xindy,nonumberlist,style=listgroup]{glossaries}

\makeglossaries

% Note that because the é is the first letter of the
% name, it needs to be grouped or it will cause a
% problem for \makefirstuc due to expansion issues.
\newglossaryentry{elite}{name={{é}lite},
description={select group or class}}

\newglossaryentry{elephant}{name=elephant,
description={large animal with trunk and tusks}}

\newglossaryentry{elk}{name=elk,
description=large deer}

\newglossaryentry{mannerly}{name=mannerly,
description=polite}

% The œ is not the first letter, so it doesn't need to
% be grouped.
\newglossaryentry{manoeuvre}{name={manœuvre},
description=planned and controlled movement}

\newglossaryentry{manor}{name=manor,
description=large landed estate or its house}

\newglossaryentry{odometer}{name=odometer,
description=instrument for measuring distance travelled by
a wheeled vehicle}

\newglossaryentry{oesophagus}{name={{œ}sophagus},
description={canal from mouth to stomach}}

\newglossaryentry{ogre}{name=ogre,
description=man-eating giant}

\begin{document}
\null % ensure that the first run produces some output
\glsaddall

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleutf8.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*samplexdy-compatible207.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain.
 %
 % This is a sample document illustrating how to use the
 % glossaries package with xindy using the compatibility option.
 % To create the document:
 %
 %   latex samplexdy-compatible207
 %   makeglossaries samplexdy-compatible207
 %   latex samplexdy-compatible207
 %
 % If you don't have Perl installed, then use one of the
 % following instead of makeglossaries:
 %
 % If you want to have a separate "Mc" letter group do:
 %
 %    xindy -I xindy -M samplexdy-mc207 -t samplexdy-compatible207.glg -o samplexdy-compatible207.gls samplexdy-compatible207.glo
 %
 % Otherwise do:
 %
 %  xindy -L english -C utf8 -I xindy -M samplexdy-compatible207 -t samplexdy-compatible207.glg -o samplexdy-compatible207.gls samplexdy-compatible207.glo
 % 
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}

 % remove redefinition of \thepage below if you want to uncomment
 % the following line:
 % \usepackage[colorlinks]{hyperref}

\usepackage[xindy,compatible-2.07,style=altlistgroup]{glossaries}

 % Define a new command to do bold italic (it uses \hyperbf
 % rather than \textbf in case I later introduce hyperlinks
 % - although I would have to remove the fancy page numbering
 % if I wanted to do that):

\newcommand*{\hyperbfit}[1]{\textit{\hyperbf{#1}}}

 % Need to add this to the list of attributes in order
 % to use it with xindy:
 % (This command will have no effect if \noist is used)

\GlsAddXdyAttribute{hyperbfit}

 % Redefine the page numbers so that they appear as a word:

 \renewcommand*{\thepage}{\Numberstring{page}}

 % Need to add this to the list of location styles.
 % \Numberstring{page} gets expanded to
 % \protect \Numberstringnum {<n>} (where <n> is the page number)
 % so need to define the location in that format:
 % (This command will have no effect if \noist is used)

\GlsAddXdyLocation{Numberstring}{:sep "\string\protect\space
  \string\Numberstringnum\space\glsopenbrace" 
  "arabic-numbers" :sep "\glsclosebrace"}

 % To have Mc as a separate group uncomment the following three
 % lines:

 \setStyleFile{samplexdy-mc207} % note no extension
 \noist
 \GlsSetXdyLanguage{}

 % The above three lines specify to use samplexdy-mc.xdy (supplied
 % with this file) and don't overwrite it. The language is
 % unset using \GlsSetXdyLanguage{} as all the language 
 % dependent information is contained in samplexdy-mc.xdy
 % Note that using \noist means that commands like
 % \GlsAddXdyAttribute and \GlsAddXdyLocation will no longer have
 % an effect.

 % Write the style file (if \noist isn't used)
 % and activate glossary entries

\makeglossaries

 % Define glossary entries
 % \glshyperlink is used instead of \gls to prevent the glossary
 % page numbers also appear in the locations, however I need
 % to ensure that the referenced entries are added to the 
 % glossary via commands that use \glslink, \glsadd or \glssee

\newglossaryentry{mcadam}{name={McAdam, John Loudon},
first={John Loudon McAdam},text={McAdam},
description={Scottish engineer}}

\newglossaryentry{maclaurin}{name={Maclaurin, Colin},
first={Colin Maclaurin},text={Maclaurin},
description={Scottish mathematician best known for the
\gls{maclaurinseries}}}

\newglossaryentry{maclaurinseries}{name={Maclaurin series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylorstheorem}{name={Taylor's theorem},
description={Theorem expressing a function $f(x)$ as the sum of
a polynomial and a remainder:
\[f(x) = f(a)+f'(a)(x-a)+f''(a)(x-a^2)/2!+\cdots+R_n\]
If $n\to\infty$ the expansion is a \glshyperlink{taylorseries}
and if $a=0$, the series is called a 
\gls{maclaurinseries}}}

\newglossaryentry{taylorseries}{name={Taylor series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylor}{name={Taylor, Brook},
first={Brook Taylor},text={Taylor},
description={English mathematician}}

\newglossaryentry{mcnemar}{name={McNemar, Quinn},
first={Quinn McNemar},text={McNemar},
description={Mathematician who introduced 
\gls{mcnemarstest}. This entry has the number list
suppressed},nonumberlist}

\newglossaryentry{mcnemarstest}{name={McNemar's test},
description={A nonparametric test introduced by
\gls{mcnemar} in 1947}}

\newglossaryentry{mach}{name={Mach, Ernst},
first={Ernst Mach},text={Mach},
 % if using samplexdy-mc.xdy, the following line is needed
 % to prevent this entry being put in the "Mc" group
sort={mach, Ernst},
description={Czech/Austrian physicist and philosopher}}

\newglossaryentry{machnumber}{name={Mach number},
 % if using samplexdy-mc.xdy, the following line is needed
 % to prevent this entry being put in the "Mc" group
sort={mach number},
description={Ratio of the speed of a body in a fluid to the
speed of sound in that fluid named after \gls{mach}}}

\newglossaryentry{malthus}{name={Malthus, Thomas Robert},
first={Thomas Robert Malthus},text={Malthus},
description={English mathematician, sociologist and classicist}}

\newglossaryentry{ampereandre}{name={Ampère, André-Marie},
first={André-Marie Ampère},text={Ampère},
description={French mathematician and physicist}}

\newglossaryentry{ampere}{name={ampere},
description={SI unit of electric current named after
\gls{ampereandre}}}

\newglossaryentry{archimedes}{name={Archimedes of Syracuse},
first={Archimedes of Syracuse},text={Archimedes},
description={Greek mathematician}}

\newglossaryentry{archimedesprinciple}{name={Archemedes' principle},
description={Principle that if a body is submerged in a fluid
it experiences upthrust equal to the weight of the displaced
fluid. Named after \gls{archimedes}}}

\newglossaryentry{galton}{name={Galton, Sir Francis},
first={Sir Francis Galton},text={Galton},
description={English anthropologist}}

\newglossaryentry{gauss}{name={Gauss, Karl Friedrich},
first={Karl Friedrich Gauss},text={Gauss},
description={German mathematician}}

\newglossaryentry{gaussianint}{name={Gaussian integer},
description={Complex number where both real and imaginary
parts are integers}}

\newglossaryentry{peano}{name={Peano, Giuseppe},
first={Giuseppe Peano},text={Peano},
description={Italian mathematician}}

\newglossaryentry{peanoscurve}{name={Peano's curve},
description={A space-filling curve discovered by 
\gls{peano}}}

\newglossaryentry{pearson}{name={Pearson, Karl},
first={Karl Pearson},text={Pearson},
description={English mathematician}}

\newglossaryentry{pearspmcc}{name={Pearson's product moment
correlation coefficient},description={Product moment correlation
coefficient named after \gls{pearson}}}

\begin{document}
\title{Sample Document Using the Glossaries Package With Xindy}
\author{Nicola Talbot}
\maketitle

\section{\glsentryfirst{gauss}}

This is a section on \gls[format=(]{gauss}. This section spans
several pages.

\newpage

This page talks about \glspl[format=hyperbfit]{gaussianint}. Since
it's the principle definition, the user-defined hyperbfit format is 
used.

\newpage

The section on \gls[format=)]{gauss} ends here.

\section{Series Expansions}

This section is about series expansions. It mentions
\gls{maclaurin} and \gls{taylor}. It also discusses 
\gls{taylorstheorem} which is related to the \gls{taylorseries}.
The \gls{maclaurinseries} is a special case of the
\gls{taylorseries}.

\section{\glsentryname{archimedesprinciple}}

This section discusses \gls{archimedesprinciple} which was
introduced by \gls{archimedes}.

\section{Another section}

This section covers \gls{mach} who introduced the \gls{machnumber}.
It also mentions \gls{ampereandre} after whom the
SI unit \gls{ampere} is named. It then discusses \gls{galton}
and \gls{malthus}. Finally it mentions \gls{mcadam}.

\newpage
This page discusses \gls{mcnemar} who introduced
\gls{mcnemarstest} and \gls{peano} who discovered \gls{peanoscurve}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplexdy-compatible207.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*samplexdy.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain.
 %
 % This is a sample document illustrating how to use the
 % glossaries package with xindy. To create the document:
 %
 %   latex samplexdy
 %   makeglossaries samplexdy
 %   latex samplexdy
 %
 % If you don't have Perl installed, then use one of the
 % following instead of makeglossaries:
 %
 % If you want to have a separate "Mc" letter group do:
 %
 %    xindy -I xindy -M samplexdy-mc -t samplexdy.glg -o samplexdy.gls samplexdy.glo
 %
 % Otherwise do:
 %
 %  xindy -L english -C utf8 -I xindy -M samplexdy -t samplexdy.glg -o samplexdy.gls samplexdy.glo
 % 
\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fmtcount}

\usepackage[colorlinks,plainpages]{hyperref}
\usepackage[xindy,style=altlistgroup]{glossaries}

 % Define a new command to do bold italic:

\newcommand*{\hyperbfit}[1]{\textit{\hyperbf{#1}}}

 % Need to add this to the list of attributes in order
 % to use it with xindy:
 % (This command will have no effect if \noist is used)

\GlsAddXdyAttribute{hyperbfit}

 % Redefine the page numbers so that they appear as a word:

 \renewcommand*{\thepage}{\texorpdfstring{\Numberstring{page}}{\arabic{page}}}

 % Need to add this to the list of location styles.
 % \Numberstring{page} gets expanded to
 % \protect \Numberstringnum {<n>} (where <n> is the page number)
 % so need to define the location in that format:
 % (This command will have no effect if \noist is used)

\GlsAddXdyLocation{Numberstring}{:sep "\string\protect\space
  \string\Numberstringnum\space\glsopenbrace" 
  "arabic-numbers" :sep "\glsclosebrace"}

 % (Need to redefine \glsXpageXhyperbfit and
 % \glsXpageXglsnumberformat after \makeglossaries to get the
 % hyperlinks working correctly.)

 % To have Mc as a separate group uncomment the following three
 % lines:

 %\setStyleFile{samplexdy-mc} % note no extension
 %\noist
 %\GlsSetXdyLanguage{}

 % The above three lines specify to use samplexdy-mc.xdy (supplied
 % with this file) and don't overwrite it. The language is
 % unset using \GlsSetXdyLanguage{} as all the language 
 % dependent information is contained in samplexdy-mc.xdy
 % Note that using \noist means that commands like
 % \GlsAddXdyAttribute and \GlsAddXdyLocation will no longer have
 % an effect.

 % Write the style file (if \noist isn't used)
 % and activate glossary entries

\makeglossaries

 % Each page location will be specified in the form:
 %
 % "\glsXpageXglsnumberformat{}{\protect \Numberstringnum "\marg{n}"}"
 % or
 % "\glsXpageXhyperbfit{}{\protect \Numberstringnum "\marg{n}"}"
 %
 % Redefine to allow hyperlinks:

\renewcommand{\glsXpageXglsnumberformat}[2]{%
 \linkpagenumber#2%
}

\renewcommand{\glsXpageXhyperbfit}[2]{%
 \textbf{\em\linkpagenumber#2}%
}

\newcommand{\linkpagenumber}[3]{\hyperlink{page.#3}{#1#2{#3}}}

 % Define glossary entries
 % \glshyperlink is used instead of \gls to prevent the glossary
 % page numbers also appear in the locations, however I need
 % to ensure that the referenced entries are added to the 
 % glossary via commands that use \glslink, \glsadd or \glssee

\newglossaryentry{mcadam}{name={McAdam, John Loudon},
first={John Loudon McAdam},text={McAdam},
description={Scottish engineer}}

\newglossaryentry{maclaurin}{name={Maclaurin, Colin},
first={Colin Maclaurin},text={Maclaurin},
description={Scottish mathematician best known for the
\gls{maclaurinseries}}}

\newglossaryentry{maclaurinseries}{name={Maclaurin series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylorstheorem}{name={Taylor's theorem},
description={Theorem expressing a function $f(x)$ as the sum of
a polynomial and a remainder:
\[f(x) = f(a)+f'(a)(x-a)+f''(a)(x-a^2)/2!+\cdots+R_n\]
If $n\to\infty$ the expansion is a \glshyperlink{taylorseries}
and if $a=0$, the series is called a 
\gls{maclaurinseries}}}

\newglossaryentry{taylorseries}{name={Taylor series},
description={Series expansion},see={taylorstheorem}}

\newglossaryentry{taylor}{name={Taylor, Brook},
first={Brook Taylor},text={Taylor},
description={English mathematician}}

\newglossaryentry{mcnemar}{name={McNemar, Quinn},
first={Quinn McNemar},text={McNemar},
description={Mathematician who introduced 
\gls{mcnemarstest}. This entry has the number list
suppressed},nonumberlist}

\newglossaryentry{mcnemarstest}{name={McNemar's test},
description={A nonparametric test introduced by
\gls{mcnemar} in 1947}}

\newglossaryentry{mach}{name={Mach, Ernst},
first={Ernst Mach},text={Mach},
 % if using samplexdy-mc.xdy, the following line is needed
 % to prevent this entry being put in the "Mc" group
sort={mach, Ernst},
description={Czech/Austrian physicist and philosopher}}

\newglossaryentry{machnumber}{name={Mach number},
 % if using samplexdy-mc.xdy, the following line is needed
 % to prevent this entry being put in the "Mc" group
sort={mach number},
description={Ratio of the speed of a body in a fluid to the
speed of sound in that fluid named after \gls{mach}}}

\newglossaryentry{malthus}{name={Malthus, Thomas Robert},
first={Thomas Robert Malthus},text={Malthus},
description={English mathematician, sociologist and classicist}}

\newglossaryentry{ampereandre}{name={Ampère, André-Marie},
first={André-Marie Ampère},text={Ampère},
description={French mathematician and physicist}}

\newglossaryentry{ampere}{name={ampere},
description={SI unit of electric current named after
\gls{ampereandre}}}

\newglossaryentry{archimedes}{name={Archimedes of Syracuse},
first={Archimedes of Syracuse},text={Archimedes},
description={Greek mathematician}}

\newglossaryentry{archimedesprinciple}{name={Archimedes' principle},
description={Principle that if a body is submerged in a fluid
it experiences upthrust equal to the weight of the displaced
fluid. Named after \gls{archimedes}}}

\newglossaryentry{galton}{name={Galton, Sir Francis},
first={Sir Francis Galton},text={Galton},
description={English anthropologist}}

\newglossaryentry{gauss}{name={Gauss, Karl Friedrich},
first={Karl Friedrich Gauss},text={Gauss},
description={German mathematician}}

\newglossaryentry{gaussianint}{name={Gaussian integer},
description={Complex number where both real and imaginary
parts are integers}}

\newglossaryentry{gaussianfn}{name={Gaussian function},
 description={A function of the form:
 \[f(x) = a \exp\left(-\frac{(x-b)^2}{2c^2}\right)\]
 for some constants $a$, $b$ and $c$}}

\newglossaryentry{peano}{name={Peano, Giuseppe},
first={Giuseppe Peano},text={Peano},
description={Italian mathematician}}

\newglossaryentry{peanoscurve}{name={Peano's curve},
description={A space-filling curve discovered by 
\gls{peano}}}

\newglossaryentry{pearson}{name={Pearson, Karl},
first={Karl Pearson},text={Pearson},
description={English mathematician}}

\newglossaryentry{pearspmcc}{name={Pearson's product moment
correlation coefficient},description={Product moment correlation
coefficient named after \gls{pearson}}}

\begin{document}
\title{Sample Document Using the Glossaries Package With Xindy}
\author{Nicola Talbot}
\maketitle

\section{\glsentryfirst{gauss}}

This is a section on \gls[format=(]{gauss}. This section spans
several pages.

\rule{1pt}{0.6\textheight}

This paragraph has been shoved to the bottom of the page using a rule. 
This paragraph spans a page break for testing purposes to ensure the
glossary entry in this paragraph has the correct location. Here's
the glossary entry: \gls{gaussianfn}.

This page talks about \glspl[format=hyperbfit]{gaussianint}. Since
it's the principle definition, the user-defined hyperbfit format is 
used.

\newpage

The section on \gls[format=)]{gauss} ends here.

\section{Series Expansions}

This section is about series expansions. It mentions
\gls{maclaurin} and \gls{taylor}. It also discusses 
\gls{taylorstheorem} which is related to the \gls{taylorseries}.
The \gls{maclaurinseries} is a special case of the
\gls{taylorseries}.

\section{\glsentryname{archimedesprinciple}}

This section discusses \gls{archimedesprinciple} which was
introduced by \gls{archimedes}.

\section{Another section}

This section covers \gls{mach} who introduced the \gls{machnumber}.
It also mentions \gls{ampereandre} after whom the
SI unit \gls{ampere} is named. It then discusses \gls{galton}
and \gls{malthus}. Finally it mentions \gls{mcadam}.

\newpage
This page discusses \gls{mcnemar} who introduced
\gls{mcnemarstest} and \gls{peano} who discovered \gls{peanoscurve}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplexdy.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*samplexdy2.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 %
 % This is a sample document illustrating how to use the 
 % glossaries package with xindy. To create the document:
 %
 % pdflatex samplexdy2
 % makeglossaries samplexdy2
 % pdflatex samplexdy2
 %
 % This sample file won't work with makeindex
 %
\documentclass{report}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[colorlinks]{hyperref}
\usepackage[xindy,counter=section]{glossaries}

 % Set up somewhat eccentric section numbering system:

\renewcommand*{\thesection}{[\thechapter]\arabic{section}}

\renewcommand*{\theHsection}{\thepart.\thesection}
\renewcommand*{\thepart}{\Roman{part}}

\GlsAddXdyLocation["roman-numbers-uppercase"]{section}{:sep "[" 
  "arabic-numbers" :sep "]" "arabic-numbers"
}

 % If part is 0, then \thepart will be empty, so add an extra
 % case to catch this:

\GlsAddXdyLocation{zero.section}{:sep "[" 
  "arabic-numbers" :sep "]" "arabic-numbers"
}

 % (Note that the above will stop xindy giving a warning, but the
 % location hyper links will be invalid if no \part is used.)

\makeglossaries

\newglossaryentry{sample}{name=sample,description={an example}}
\newglossaryentry{sample2}{name=sample2,description={another example}}

\begin{document}
This is a sample document illustrating Xindy specific commands in
the glossaries package.

\part{First Part}

\chapter{Sample Chapter}

\section{First Section}

\gls{sample}. \gls{sample2}.

\section{Second Section}

\gls{sample2}.

\section{Third Section}

\gls{sample}. \gls{sample2}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplexdy2.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*samplexdy-mc.xdy>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
;; xindy style file for samplexdy.tex that has Mc letter group

(define-letter-group "A" :prefixes (""))
(define-letter-group "B" :after "A" :prefixes (""))
(define-letter-group "C" :after "B" :prefixes (""))
(define-letter-group "D" :after "C" :prefixes (""))
(define-letter-group "E" :after "D" :prefixes (""))
(define-letter-group "F" :after "E" :prefixes (""))
(define-letter-group "G" :after "F" :prefixes (""))
(define-letter-group "H" :after "G" :prefixes ("¤"))
(define-letter-group "I" :after "H" :prefixes ("¨"))
(define-letter-group "J" :after "I" :prefixes ("¬"))
(define-letter-group "K" :after "J" :prefixes ("®"))
(define-letter-group "L" :after "K" :prefixes ("´"))
(define-letter-group "Mc" :after "L" :prefixes ("»"))
(define-letter-group "M" :after "Mc" :prefixes ("»"))
(define-letter-group "N" :after "M" :prefixes ("¼"))
(define-letter-group "O" :after "N" :prefixes ("Ã"))
(define-letter-group "P" :after "O" :prefixes ("È"))
(define-letter-group "Q" :after "P" :prefixes ("Ê"))
(define-letter-group "R" :after "Q" :prefixes ("Ë"))
(define-letter-group "S" :after "R" :prefixes ("Ð"))
(define-letter-group "T" :after "S" :prefixes ("Ú"))
(define-letter-group "U" :after "T" :prefixes ("à"))
(define-letter-group "V" :after "U" :prefixes ("å"))
(define-letter-group "W" :after "V" :prefixes ("æ"))
(define-letter-group "X" :after "W" :prefixes ("ë"))
(define-letter-group "Y" :after "X" :prefixes ("í"))
(define-letter-group "È" :after "Y" :prefixes ("ï"))
(define-letter-group "Z" :after "È" :prefixes ("ð"))
(define-letter-group "Ã" :after "Z" :prefixes ("ö"))
(define-letter-group "Æ¿" :after "Ã" :prefixes ("÷"))

(define-rule-set "en-alphabetize"

  :rules  (("Ã " "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã¦" "" :string)
           ("Ã" "" :string)
           ("Ã§" "" :string)
           ("Ã°" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã¨" "" :string)
           ("Ã«" "" :string)
           ("Ãª" "" :string)
           ("Ã©" "" :string)
           ("Ã" "¨" :string)
           ("Ã¯" "¨" :string)
           ("Ã" "¼" :string)
           ("Ã±" "¼" :string)
           ("Ã" "Ã" :string)
           ("Ã" "Ã" :string)
           ("Ã´" "Ã" :string)
           ("Ã¶" "Ã" :string)
           ("Å" "Ã" :string)
           ("Å" "Ã" :string)
           ("È" "ï" :string)
           ("È" "ï" :string)
           ("Ã¾" "ö" :string)
           ("Ã" "ö" :string)
           ("Ç·" "÷" :string)
           ("Æ¿" "÷" :string)
           ("a" "" :string)
           ("A" "" :string)
           ("b" "" :string)
           ("B" "" :string)
           ("C" "" :string)
           ("c" "" :string)
           ("d" "" :string)
           ("D" "" :string)
           ("E" "" :string)
           ("e" "" :string)
           ("F" "" :string)
           ("f" "" :string)
           ("g" "" :string)
           ("G" "" :string)
           ("H" "¤" :string)
           ("h" "¤" :string)
           ("I" "¨" :string)
           ("i" "¨" :string)
           ("J" "¬" :string)
           ("j" "¬" :string)
           ("K" "®" :string)
           ("k" "®" :string)
           ("L" "´" :string)
           ("l" "´" :string)
           ("Mc" "»" :string)
           ("Mac" "»" :string)
           ("M" "»" :string)
           ("m" "»" :string)
           ("N" "¼" :string)
           ("n" "¼" :string)
           ("O" "Ã" :string)
           ("o" "Ã" :string)
           ("P" "È" :string)
           ("p" "È" :string)
           ("q" "Ê" :string)
           ("Q" "Ê" :string)
           ("r" "Ë" :string)
           ("R" "Ë" :string)
           ("S" "Ð" :string)
           ("s" "Ð" :string)
           ("T" "Ú" :string)
           ("t" "Ú" :string)
           ("u" "à" :string)
           ("U" "à" :string)
           ("v" "å" :string)
           ("V" "å" :string)
           ("w" "æ" :string)
           ("W" "æ" :string)
           ("X" "ë" :string)
           ("x" "ë" :string)
           ("Y" "í" :string)
           ("y" "í" :string)
           ("z" "ð" :string)
           ("Z" "ð" :string)
           ))

(define-rule-set "en-resolve-diacritics"

  :rules  (("È" "¢" :string)
           ("Ã¾" "¢" :string)
           ("Ç·" "¢" :string)
           ("Ã" "¢" :string)
           ("È" "¢" :string)
           ("Æ¿" "¢" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã°" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã¯" "£" :string)
           ("Ã¶" "£" :string)
           ("Ã±" "£" :string)
           ("Ã§" "£" :string)
           ("Ã " "£" :string)
           ("Ã" "£" :string)
           ("Ã©" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "¤" :string)
           ("Ã´" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã¨" "¤" :string)
           ("Ã" "¥" :string)
           ("Ã«" "¥" :string)
           ("Ã" "¦" :string)
           ("Ãª" "¦" :string)
           ("Å" "ÿ" :string)
           ("Ã" "ÿ" :string)
           ("Å" "ÿ" :string)
           ("Ã¦" "ÿ" :string)
           ("S" "¢" :string)
           ("K" "¢" :string)
           ("d" "¢" :string)
           ("Y" "¢" :string)
           ("E" "¢" :string)
           ("y" "¢" :string)
           ("g" "¢" :string)
           ("e" "¢" :string)
           ("J" "¢" :string)
           ("q" "¢" :string)
           ("D" "¢" :string)
           ("b" "¢" :string)
           ("z" "¢" :string)
           ("w" "¢" :string)
           ("Q" "¢" :string)
           ("M" "¢" :string)
           ("C" "¢" :string)
           ("L" "¢" :string)
           ("X" "¢" :string)
           ("P" "¢" :string)
           ("T" "¢" :string)
           ("a" "¢" :string)
           ("N" "¢" :string)
           ("j" "¢" :string)
           ("Z" "¢" :string)
           ("u" "¢" :string)
           ("k" "¢" :string)
           ("t" "¢" :string)
           ("W" "¢" :string)
           ("v" "¢" :string)
           ("s" "¢" :string)
           ("B" "¢" :string)
           ("H" "¢" :string)
           ("c" "¢" :string)
           ("I" "¢" :string)
           ("G" "¢" :string)
           ("U" "¢" :string)
           ("F" "¢" :string)
           ("r" "¢" :string)
           ("x" "¢" :string)
           ("V" "¢" :string)
           ("h" "¢" :string)
           ("f" "¢" :string)
           ("i" "¢" :string)
           ("A" "¢" :string)
           ("O" "¢" :string)
           ("n" "¢" :string)
           ("m" "¢" :string)
           ("l" "¢" :string)
           ("p" "¢" :string)
           ("R" "¢" :string)
           ("o" "¢" :string)
           ))

(define-rule-set "en-resolve-case"

  :rules  (("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ç·" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("È" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "89" :string)
           ("Å" "89" :string)
           ("Ã°" "9" :string)
           ("Ã´" "9" :string)
           ("È" "9" :string)
           ("Ã¯" "9" :string)
           ("Ã¶" "9" :string)
           ("Ã±" "9" :string)
           ("Ã§" "9" :string)
           ("Ã " "9" :string)
           ("Ã¾" "9" :string)
           ("Ã¨" "9" :string)
           ("Ã«" "9" :string)
           ("Ãª" "9" :string)
           ("Ã©" "9" :string)
           ("Æ¿" "9" :string)
           ("Å" "99" :string)
           ("Ã¦" "99" :string)
           ("S" "8" :string)
           ("K" "8" :string)
           ("Y" "8" :string)
           ("E" "8" :string)
           ("J" "8" :string)
           ("D" "8" :string)
           ("Q" "8" :string)
           ("M" "8" :string)
           ("C" "8" :string)
           ("L" "8" :string)
           ("X" "8" :string)
           ("P" "8" :string)
           ("T" "8" :string)
           ("N" "8" :string)
           ("Z" "8" :string)
           ("W" "8" :string)
           ("B" "8" :string)
           ("H" "8" :string)
           ("I" "8" :string)
           ("G" "8" :string)
           ("U" "8" :string)
           ("F" "8" :string)
           ("V" "8" :string)
           ("A" "8" :string)
           ("O" "8" :string)
           ("R" "8" :string)
           ("d" "9" :string)
           ("y" "9" :string)
           ("g" "9" :string)
           ("e" "9" :string)
           ("q" "9" :string)
           ("b" "9" :string)
           ("z" "9" :string)
           ("w" "9" :string)
           ("a" "9" :string)
           ("j" "9" :string)
           ("u" "9" :string)
           ("k" "9" :string)
           ("t" "9" :string)
           ("v" "9" :string)
           ("s" "9" :string)
           ("c" "9" :string)
           ("r" "9" :string)
           ("x" "9" :string)
           ("h" "9" :string)
           ("f" "9" :string)
           ("i" "9" :string)
           ("n" "9" :string)
           ("m" "9" :string)
           ("l" "9" :string)
           ("p" "9" :string)
           ("o" "9" :string)
           ))

(define-rule-set "en-ignore-special"

  :rules  (("-" "" :string)
           ("!" "" :string)
           ("{" "" :string)
           ("'" "" :string)
           ("}" "" :string)
           ("?" "" :string)
           ("." "" :string)
           ))

(define-rule-set "en-resolve-special"

  :rules  (("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã°" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã´" "¤" :string)
           ("Ã" "¤" :string)
           ("È" "¤" :string)
           ("Ã¯" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã¶" "¤" :string)
           ("Ã±" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã§" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã " "¤" :string)
           ("Ã¾" "¤" :string)
           ("Ç·" "¤" :string)
           ("Ã¨" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã«" "¤" :string)
           ("Ã" "¤" :string)
           ("Ãª" "¤" :string)
           ("Ã©" "¤" :string)
           ("È" "¤" :string)
           ("Æ¿" "¤" :string)
           ("Ã" "¤" :string)
           ("Å" "¤¤" :string)
           ("Ã" "¤¤" :string)
           ("Å" "¤¤" :string)
           ("Ã¦" "¤¤" :string)
           ("?" "¡" :string)
           ("!" "¢" :string)
           ("." "£" :string)
           ("S" "¤" :string)
           ("K" "¤" :string)
           ("d" "¤" :string)
           ("Y" "¤" :string)
           ("E" "¤" :string)
           ("y" "¤" :string)
           ("g" "¤" :string)
           ("e" "¤" :string)
           ("J" "¤" :string)
           ("q" "¤" :string)
           ("D" "¤" :string)
           ("b" "¤" :string)
           ("z" "¤" :string)
           ("w" "¤" :string)
           ("Q" "¤" :string)
           ("M" "¤" :string)
           ("C" "¤" :string)
           ("L" "¤" :string)
           ("X" "¤" :string)
           ("P" "¤" :string)
           ("T" "¤" :string)
           ("a" "¤" :string)
           ("N" "¤" :string)
           ("j" "¤" :string)
           ("Z" "¤" :string)
           ("u" "¤" :string)
           ("k" "¤" :string)
           ("t" "¤" :string)
           ("W" "¤" :string)
           ("v" "¤" :string)
           ("s" "¤" :string)
           ("B" "¤" :string)
           ("H" "¤" :string)
           ("c" "¤" :string)
           ("I" "¤" :string)
           ("G" "¤" :string)
           ("U" "¤" :string)
           ("F" "¤" :string)
           ("r" "¤" :string)
           ("x" "¤" :string)
           ("V" "¤" :string)
           ("h" "¤" :string)
           ("f" "¤" :string)
           ("i" "¤" :string)
           ("A" "¤" :string)
           ("O" "¤" :string)
           ("n" "¤" :string)
           ("m" "¤" :string)
           ("l" "¤" :string)
           ("p" "¤" :string)
           ("R" "¤" :string)
           ("o" "¤" :string)
           ("-" "¥" :string)
           ("'" "¦" :string)
           ("{" "§" :string)
           ("}" "¨" :string)
           ))

; The following section is customised for samplexdy.tex
; (copied from samplexdy.xdy automatically generated by
; samplexdy.tex)

; required styles

(require "tex.xdy")

; list of allowed attributes (number formats)

(define-attributes (("default"
 "hyperbfit" 
 "pagehyperbfit"
 "glsnumberformat" 
 "pageglsnumberformat"
 "textrm" 
 "pagetextrm"
 "textsf" 
 "pagetextsf"
 "texttt" 
 "pagetexttt"
 "textbf" 
 "pagetextbf"
 "textmd" 
 "pagetextmd"
 "textit" 
 "pagetextit"
 "textup" 
 "pagetextup"
 "textsl" 
 "pagetextsl"
 "textsc" 
 "pagetextsc"
 "emph" 
 "pageemph"
 "glshypernumber" 
 "pageglshypernumber"
 "hyperrm" 
 "pagehyperrm"
 "hypersf" 
 "pagehypersf"
 "hypertt" 
 "pagehypertt"
 "hyperbf" 
 "pagehyperbf"
 "hypermd" 
 "pagehypermd"
 "hyperit" 
 "pagehyperit"
 "hyperup" 
 "pagehyperup"
 "hypersl" 
 "pagehypersl"
 "hypersc" 
 "pagehypersc"
 "hyperemph" 
 "pagehyperemph")))

; user defined alphabets



; location class definitions

(define-location-class "roman-page-numbers"
   ( :sep "{}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-roman-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-roman-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-roman-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-roman-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-roman-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-roman-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-roman-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "roman-numbers-lowercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers"
   ( :sep "{}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-Roman-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-Roman-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-Roman-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-Roman-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-Roman-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-Roman-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-Roman-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "roman-numbers-uppercase" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers"
   ( :sep "{}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-arabic-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-arabic-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-arabic-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-arabic-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-arabic-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-arabic-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-arabic-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers"
   ( :sep "{}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-alpha-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-alpha-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-alpha-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-alpha-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-alpha-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-alpha-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-alpha-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "alpha" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers"
   ( :sep "{}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-Alpha-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-Alpha-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "ALPHA" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers"
   ( :sep "{}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "alpha" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-Appendix-page-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-Appendix-page-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "ALPHA" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers"
   ( :sep "{}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "roman-page-numbers-arabic-section-numbers" 
   ( :sep "{" "roman-numbers-lowercase" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Roman-page-numbers-arabic-section-numbers" 
   ( :sep "{" "roman-numbers-uppercase" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-page-numbers-arabic-section-numbers" 
   ( :sep "{" "arabic-numbers" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "alpha-page-numbers-arabic-section-numbers" 
   ( :sep "{" "alpha" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Alpha-page-numbers-arabic-section-numbers" 
   ( :sep "{" "ALPHA" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "Appendix-page-numbers-arabic-section-numbers" 
   ( :sep "{" "ALPHA" :sep "." "arabic-numbers" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 
(define-location-class "arabic-section-numbers-arabic-section-numbers" 
   ( :sep "{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}{" "arabic-numbers" :sep "." "arabic-numbers" :sep "}" ) 
   :min-range-length 2
) 

; user defined location classes

(define-location-class "Numberstring"
   (:sep "{}{" :sep "\protect \Numberstringnum {" "arabic-numbers" :sep "}" :sep "}")) 

; define cross-reference class

(define-crossref-class "see" :unverified )
(markup-crossref-list :class "see"
   :open "\glsseeformat" :close "{}")

; define the order of the location classes
(define-location-class-order (
   "roman-page-numbers"
   "arabic-page-numbers"
   "arabic-section-numbers"
   "alpha-page-numbers"
   "Roman-page-numbers"
   "Alpha-page-numbers"
   "Appendix-page-numbers" 
   "see" ))

; define the glossary markup

(markup-index
   :open "\glossarysection[\glossarytoctitle]{\glossarytitle}\glossarypreamble
\providecommand*\glsXpageXhyperbfit[2]{\setentrycounter[#1]{page}\hyperbfit{#2}}
\providecommand*\glsXpageXglsnumberformat[2]{\setentrycounter[#1]{page}\glsnumberformat{#2}}
\providecommand*\glsXpageXtextrm[2]{\setentrycounter[#1]{page}\textrm{#2}}
\providecommand*\glsXpageXtextsf[2]{\setentrycounter[#1]{page}\textsf{#2}}
\providecommand*\glsXpageXtexttt[2]{\setentrycounter[#1]{page}\texttt{#2}}
\providecommand*\glsXpageXtextbf[2]{\setentrycounter[#1]{page}\textbf{#2}}
\providecommand*\glsXpageXtextmd[2]{\setentrycounter[#1]{page}\textmd{#2}}
\providecommand*\glsXpageXtextit[2]{\setentrycounter[#1]{page}\textit{#2}}
\providecommand*\glsXpageXtextup[2]{\setentrycounter[#1]{page}\textup{#2}}
\providecommand*\glsXpageXtextsl[2]{\setentrycounter[#1]{page}\textsl{#2}}
\providecommand*\glsXpageXtextsc[2]{\setentrycounter[#1]{page}\textsc{#2}}
\providecommand*\glsXpageXemph[2]{\setentrycounter[#1]{page}\emph{#2}}
\providecommand*\glsXpageXglshypernumber[2]{\setentrycounter[#1]{page}\glshypernumber{#2}}
\providecommand*\glsXpageXhyperrm[2]{\setentrycounter[#1]{page}\hyperrm{#2}}
\providecommand*\glsXpageXhypersf[2]{\setentrycounter[#1]{page}\hypersf{#2}}
\providecommand*\glsXpageXhypertt[2]{\setentrycounter[#1]{page}\hypertt{#2}}
\providecommand*\glsXpageXhyperbf[2]{\setentrycounter[#1]{page}\hyperbf{#2}}
\providecommand*\glsXpageXhypermd[2]{\setentrycounter[#1]{page}\hypermd{#2}}
\providecommand*\glsXpageXhyperit[2]{\setentrycounter[#1]{page}\hyperit{#2}}
\providecommand*\glsXpageXhyperup[2]{\setentrycounter[#1]{page}\hyperup{#2}}
\providecommand*\glsXpageXhypersl[2]{\setentrycounter[#1]{page}\hypersl{#2}}
\providecommand*\glsXpageXhypersc[2]{\setentrycounter[#1]{page}\hypersc{#2}}
\providecommand*\glsXpageXhyperemph[2]{\setentrycounter[#1]{page}\hyperemph{#2}}
\begin{theglossary}\glossaryheader~n" 
   :close "%~n\end{theglossary}\glossarypostamble~n" 
   :tree)
(markup-letter-group-list :sep "\glsgroupskip~n")
(markup-indexentry :open "\relax\glsresetentrylist~n")
(markup-locclass-list :open "{\glossaryentrynumbers{\relax "
   :sep ", " :close "}}")
(markup-locref-list :sep "\delimN ")
(markup-range :sep "\delimR ")

; define format to use for locations


(markup-locref :open "~n\glsXpageXhyperbfit" 
 :close "" 
 :attr "pagehyperbfit")
(markup-locref :open "~n\glsXpageXglsnumberformat" 
 :close "" 
 :attr "pageglsnumberformat")
(markup-locref :open "~n\glsXpageXtextrm" 
 :close "" 
 :attr "pagetextrm")
(markup-locref :open "~n\glsXpageXtextsf" 
 :close "" 
 :attr "pagetextsf")
(markup-locref :open "~n\glsXpageXtexttt" 
 :close "" 
 :attr "pagetexttt")
(markup-locref :open "~n\glsXpageXtextbf" 
 :close "" 
 :attr "pagetextbf")
(markup-locref :open "~n\glsXpageXtextmd" 
 :close "" 
 :attr "pagetextmd")
(markup-locref :open "~n\glsXpageXtextit" 
 :close "" 
 :attr "pagetextit")
(markup-locref :open "~n\glsXpageXtextup" 
 :close "" 
 :attr "pagetextup")
(markup-locref :open "~n\glsXpageXtextsl" 
 :close "" 
 :attr "pagetextsl")
(markup-locref :open "~n\glsXpageXtextsc" 
 :close "" 
 :attr "pagetextsc")
(markup-locref :open "~n\glsXpageXemph" 
 :close "" 
 :attr "pageemph")
(markup-locref :open "~n\glsXpageXglshypernumber" 
 :close "" 
 :attr "pageglshypernumber")
(markup-locref :open "~n\glsXpageXhyperrm" 
 :close "" 
 :attr "pagehyperrm")
(markup-locref :open "~n\glsXpageXhypersf" 
 :close "" 
 :attr "pagehypersf")
(markup-locref :open "~n\glsXpageXhypertt" 
 :close "" 
 :attr "pagehypertt")
(markup-locref :open "~n\glsXpageXhyperbf" 
 :close "" 
 :attr "pagehyperbf")
(markup-locref :open "~n\glsXpageXhypermd" 
 :close "" 
 :attr "pagehypermd")
(markup-locref :open "~n\glsXpageXhyperit" 
 :close "" 
 :attr "pagehyperit")
(markup-locref :open "~n\glsXpageXhyperup" 
 :close "" 
 :attr "pagehyperup")
(markup-locref :open "~n\glsXpageXhypersl" 
 :close "" 
 :attr "pagehypersl")
(markup-locref :open "~n\glsXpageXhypersc" 
 :close "" 
 :attr "pagehypersc")
(markup-locref :open "~n\glsXpageXhyperemph" 
 :close "" 
 :attr "pagehyperemph")

; define letter group list format

(markup-letter-group-list :sep "\glsgroupskip~n")

; letter group headings

(markup-letter-group :open-head "\glsgroupheading{"
   :close-head "}")

; additional letter groups

(define-letter-group "glsnumbers"
   :prefixes ("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
   :before "A")

; additional sort rules


; The following is copied from xindy/lang/english/utf8-lang.xdy

(define-sort-rule-orientations (forward backward forward forward))
(use-rule-set :run 0
	      :rule-set ("en-alphabetize" "en-ignore-special"))
(use-rule-set :run 1
	      :rule-set ("en-resolve-diacritics" "en-ignore-special"))
(use-rule-set :run 2
	      :rule-set ("en-resolve-case" "en-ignore-special"))
(use-rule-set :run 3
	      :rule-set ("en-resolve-special"))

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplexdy-mc.xdy>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*samplexdy-mc207.xdy>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
;; xindy style file for samplexdy.tex that has Mc letter group

(define-letter-group "A" :prefixes (""))
(define-letter-group "B" :after "A" :prefixes (""))
(define-letter-group "C" :after "B" :prefixes (""))
(define-letter-group "D" :after "C" :prefixes (""))
(define-letter-group "E" :after "D" :prefixes (""))
(define-letter-group "F" :after "E" :prefixes (""))
(define-letter-group "G" :after "F" :prefixes (""))
(define-letter-group "H" :after "G" :prefixes ("¤"))
(define-letter-group "I" :after "H" :prefixes ("¨"))
(define-letter-group "J" :after "I" :prefixes ("¬"))
(define-letter-group "K" :after "J" :prefixes ("®"))
(define-letter-group "L" :after "K" :prefixes ("´"))
(define-letter-group "Mc" :after "L" :prefixes ("»"))
(define-letter-group "M" :after "Mc" :prefixes ("»"))
(define-letter-group "N" :after "M" :prefixes ("¼"))
(define-letter-group "O" :after "N" :prefixes ("Ã"))
(define-letter-group "P" :after "O" :prefixes ("È"))
(define-letter-group "Q" :after "P" :prefixes ("Ê"))
(define-letter-group "R" :after "Q" :prefixes ("Ë"))
(define-letter-group "S" :after "R" :prefixes ("Ð"))
(define-letter-group "T" :after "S" :prefixes ("Ú"))
(define-letter-group "U" :after "T" :prefixes ("à"))
(define-letter-group "V" :after "U" :prefixes ("å"))
(define-letter-group "W" :after "V" :prefixes ("æ"))
(define-letter-group "X" :after "W" :prefixes ("ë"))
(define-letter-group "Y" :after "X" :prefixes ("í"))
(define-letter-group "È" :after "Y" :prefixes ("ï"))
(define-letter-group "Z" :after "È" :prefixes ("ð"))
(define-letter-group "Ã" :after "Z" :prefixes ("ö"))
(define-letter-group "Æ¿" :after "Ã" :prefixes ("÷"))

(define-rule-set "en-alphabetize"

  :rules  (("Ã " "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã¦" "" :string)
           ("Ã" "" :string)
           ("Ã§" "" :string)
           ("Ã°" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã" "" :string)
           ("Ã¨" "" :string)
           ("Ã«" "" :string)
           ("Ãª" "" :string)
           ("Ã©" "" :string)
           ("Ã" "¨" :string)
           ("Ã¯" "¨" :string)
           ("Ã" "¼" :string)
           ("Ã±" "¼" :string)
           ("Ã" "Ã" :string)
           ("Ã" "Ã" :string)
           ("Ã´" "Ã" :string)
           ("Ã¶" "Ã" :string)
           ("Å" "Ã" :string)
           ("Å" "Ã" :string)
           ("È" "ï" :string)
           ("È" "ï" :string)
           ("Ã¾" "ö" :string)
           ("Ã" "ö" :string)
           ("Ç·" "÷" :string)
           ("Æ¿" "÷" :string)
           ("a" "" :string)
           ("A" "" :string)
           ("b" "" :string)
           ("B" "" :string)
           ("C" "" :string)
           ("c" "" :string)
           ("d" "" :string)
           ("D" "" :string)
           ("E" "" :string)
           ("e" "" :string)
           ("F" "" :string)
           ("f" "" :string)
           ("g" "" :string)
           ("G" "" :string)
           ("H" "¤" :string)
           ("h" "¤" :string)
           ("I" "¨" :string)
           ("i" "¨" :string)
           ("J" "¬" :string)
           ("j" "¬" :string)
           ("K" "®" :string)
           ("k" "®" :string)
           ("L" "´" :string)
           ("l" "´" :string)
           ("Mc" "»" :string)
           ("Mac" "»" :string)
           ("M" "»" :string)
           ("m" "»" :string)
           ("N" "¼" :string)
           ("n" "¼" :string)
           ("O" "Ã" :string)
           ("o" "Ã" :string)
           ("P" "È" :string)
           ("p" "È" :string)
           ("q" "Ê" :string)
           ("Q" "Ê" :string)
           ("r" "Ë" :string)
           ("R" "Ë" :string)
           ("S" "Ð" :string)
           ("s" "Ð" :string)
           ("T" "Ú" :string)
           ("t" "Ú" :string)
           ("u" "à" :string)
           ("U" "à" :string)
           ("v" "å" :string)
           ("V" "å" :string)
           ("w" "æ" :string)
           ("W" "æ" :string)
           ("X" "ë" :string)
           ("x" "ë" :string)
           ("Y" "í" :string)
           ("y" "í" :string)
           ("z" "ð" :string)
           ("Z" "ð" :string)
           ))

(define-rule-set "en-resolve-diacritics"

  :rules  (("È" "¢" :string)
           ("Ã¾" "¢" :string)
           ("Ç·" "¢" :string)
           ("Ã" "¢" :string)
           ("È" "¢" :string)
           ("Æ¿" "¢" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã°" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "£" :string)
           ("Ã¯" "£" :string)
           ("Ã¶" "£" :string)
           ("Ã±" "£" :string)
           ("Ã§" "£" :string)
           ("Ã " "£" :string)
           ("Ã" "£" :string)
           ("Ã©" "£" :string)
           ("Ã" "£" :string)
           ("Ã" "¤" :string)
           ("Ã´" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã¨" "¤" :string)
           ("Ã" "¥" :string)
           ("Ã«" "¥" :string)
           ("Ã" "¦" :string)
           ("Ãª" "¦" :string)
           ("Å" "ÿ" :string)
           ("Ã" "ÿ" :string)
           ("Å" "ÿ" :string)
           ("Ã¦" "ÿ" :string)
           ("S" "¢" :string)
           ("K" "¢" :string)
           ("d" "¢" :string)
           ("Y" "¢" :string)
           ("E" "¢" :string)
           ("y" "¢" :string)
           ("g" "¢" :string)
           ("e" "¢" :string)
           ("J" "¢" :string)
           ("q" "¢" :string)
           ("D" "¢" :string)
           ("b" "¢" :string)
           ("z" "¢" :string)
           ("w" "¢" :string)
           ("Q" "¢" :string)
           ("M" "¢" :string)
           ("C" "¢" :string)
           ("L" "¢" :string)
           ("X" "¢" :string)
           ("P" "¢" :string)
           ("T" "¢" :string)
           ("a" "¢" :string)
           ("N" "¢" :string)
           ("j" "¢" :string)
           ("Z" "¢" :string)
           ("u" "¢" :string)
           ("k" "¢" :string)
           ("t" "¢" :string)
           ("W" "¢" :string)
           ("v" "¢" :string)
           ("s" "¢" :string)
           ("B" "¢" :string)
           ("H" "¢" :string)
           ("c" "¢" :string)
           ("I" "¢" :string)
           ("G" "¢" :string)
           ("U" "¢" :string)
           ("F" "¢" :string)
           ("r" "¢" :string)
           ("x" "¢" :string)
           ("V" "¢" :string)
           ("h" "¢" :string)
           ("f" "¢" :string)
           ("i" "¢" :string)
           ("A" "¢" :string)
           ("O" "¢" :string)
           ("n" "¢" :string)
           ("m" "¢" :string)
           ("l" "¢" :string)
           ("p" "¢" :string)
           ("R" "¢" :string)
           ("o" "¢" :string)
           ))

(define-rule-set "en-resolve-case"

  :rules  (("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("Ç·" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "8" :string)
           ("È" "8" :string)
           ("Ã" "8" :string)
           ("Ã" "89" :string)
           ("Å" "89" :string)
           ("Ã°" "9" :string)
           ("Ã´" "9" :string)
           ("È" "9" :string)
           ("Ã¯" "9" :string)
           ("Ã¶" "9" :string)
           ("Ã±" "9" :string)
           ("Ã§" "9" :string)
           ("Ã " "9" :string)
           ("Ã¾" "9" :string)
           ("Ã¨" "9" :string)
           ("Ã«" "9" :string)
           ("Ãª" "9" :string)
           ("Ã©" "9" :string)
           ("Æ¿" "9" :string)
           ("Å" "99" :string)
           ("Ã¦" "99" :string)
           ("S" "8" :string)
           ("K" "8" :string)
           ("Y" "8" :string)
           ("E" "8" :string)
           ("J" "8" :string)
           ("D" "8" :string)
           ("Q" "8" :string)
           ("M" "8" :string)
           ("C" "8" :string)
           ("L" "8" :string)
           ("X" "8" :string)
           ("P" "8" :string)
           ("T" "8" :string)
           ("N" "8" :string)
           ("Z" "8" :string)
           ("W" "8" :string)
           ("B" "8" :string)
           ("H" "8" :string)
           ("I" "8" :string)
           ("G" "8" :string)
           ("U" "8" :string)
           ("F" "8" :string)
           ("V" "8" :string)
           ("A" "8" :string)
           ("O" "8" :string)
           ("R" "8" :string)
           ("d" "9" :string)
           ("y" "9" :string)
           ("g" "9" :string)
           ("e" "9" :string)
           ("q" "9" :string)
           ("b" "9" :string)
           ("z" "9" :string)
           ("w" "9" :string)
           ("a" "9" :string)
           ("j" "9" :string)
           ("u" "9" :string)
           ("k" "9" :string)
           ("t" "9" :string)
           ("v" "9" :string)
           ("s" "9" :string)
           ("c" "9" :string)
           ("r" "9" :string)
           ("x" "9" :string)
           ("h" "9" :string)
           ("f" "9" :string)
           ("i" "9" :string)
           ("n" "9" :string)
           ("m" "9" :string)
           ("l" "9" :string)
           ("p" "9" :string)
           ("o" "9" :string)
           ))

(define-rule-set "en-ignore-special"

  :rules  (("-" "" :string)
           ("!" "" :string)
           ("{" "" :string)
           ("'" "" :string)
           ("}" "" :string)
           ("?" "" :string)
           ("." "" :string)
           ))

(define-rule-set "en-resolve-special"

  :rules  (("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã°" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã´" "¤" :string)
           ("Ã" "¤" :string)
           ("È" "¤" :string)
           ("Ã¯" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã¶" "¤" :string)
           ("Ã±" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã§" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã " "¤" :string)
           ("Ã¾" "¤" :string)
           ("Ç·" "¤" :string)
           ("Ã¨" "¤" :string)
           ("Ã" "¤" :string)
           ("Ã«" "¤" :string)
           ("Ã" "¤" :string)
           ("Ãª" "¤" :string)
           ("Ã©" "¤" :string)
           ("È" "¤" :string)
           ("Æ¿" "¤" :string)
           ("Ã" "¤" :string)
           ("Å" "¤¤" :string)
           ("Ã" "¤¤" :string)
           ("Å" "¤¤" :string)
           ("Ã¦" "¤¤" :string)
           ("?" "¡" :string)
           ("!" "¢" :string)
           ("." "£" :string)
           ("S" "¤" :string)
           ("K" "¤" :string)
           ("d" "¤" :string)
           ("Y" "¤" :string)
           ("E" "¤" :string)
           ("y" "¤" :string)
           ("g" "¤" :string)
           ("e" "¤" :string)
           ("J" "¤" :string)
           ("q" "¤" :string)
           ("D" "¤" :string)
           ("b" "¤" :string)
           ("z" "¤" :string)
           ("w" "¤" :string)
           ("Q" "¤" :string)
           ("M" "¤" :string)
           ("C" "¤" :string)
           ("L" "¤" :string)
           ("X" "¤" :string)
           ("P" "¤" :string)
           ("T" "¤" :string)
           ("a" "¤" :string)
           ("N" "¤" :string)
           ("j" "¤" :string)
           ("Z" "¤" :string)
           ("u" "¤" :string)
           ("k" "¤" :string)
           ("t" "¤" :string)
           ("W" "¤" :string)
           ("v" "¤" :string)
           ("s" "¤" :string)
           ("B" "¤" :string)
           ("H" "¤" :string)
           ("c" "¤" :string)
           ("I" "¤" :string)
           ("G" "¤" :string)
           ("U" "¤" :string)
           ("F" "¤" :string)
           ("r" "¤" :string)
           ("x" "¤" :string)
           ("V" "¤" :string)
           ("h" "¤" :string)
           ("f" "¤" :string)
           ("i" "¤" :string)
           ("A" "¤" :string)
           ("O" "¤" :string)
           ("n" "¤" :string)
           ("m" "¤" :string)
           ("l" "¤" :string)
           ("p" "¤" :string)
           ("R" "¤" :string)
           ("o" "¤" :string)
           ("-" "¥" :string)
           ("'" "¦" :string)
           ("{" "§" :string)
           ("}" "¨" :string)
           ))

; The following section is customised for samplexdy.tex
; (copied from samplexdy.xdy automatically generated by
; samplexdy.tex)

; required styles

(require "tex.xdy")

; list of allowed attributes (number formats)

(define-attributes (("default"
 "glsnumberformat"
 "textrm"
 "textsf"
 "texttt"
 "textbf"
 "textmd"
 "textit"
 "textup"
 "textsl"
 "textsc"
 "emph"
 "glshypernumber"
 "hyperrm"
 "hypersf"
 "hypertt"
 "hyperbf"
 "hypermd"
 "hyperit"
 "hyperup"
 "hypersl"
 "hypersc"
 "hyperemph"
 "hyperbfit")))

; user defined alphabets



; location class definitions

(define-location-class "roman-page-numbers"
   ("roman-numbers-lowercase"))
(define-location-class "Roman-page-numbers"
   ("roman-numbers-uppercase"))
(define-location-class "arabic-page-numbers"
   ("arabic-numbers"))
(define-location-class "alpha-page-numbers"
   ("alpha"))
(define-location-class "Alpha-page-numbers"
   ("ALPHA"))
(define-location-class "Appendix-page-numbers"
   ("ALPHA" :sep "." "arabic-numbers"))
(define-location-class "arabic-section-numbers"
   ("arabic-numbers" :sep "." "arabic-numbers"))

; user defined location classes

(define-location-class "Numberstring"
   (:sep "\protect \Numberstringnum {" "arabic-numbers" :sep "}")) 

; define cross-reference class

(define-crossref-class "see" :unverified )
(markup-crossref-list :class "see"
   :open "\glsseeformat" :close "{}")

; define the order of the location classes
(define-location-class-order (
   "roman-page-numbers"
   "arabic-page-numbers"
   "arabic-section-numbers"
   "alpha-page-numbers"
   "Roman-page-numbers"
   "Alpha-page-numbers"
   "Appendix-page-numbers" 
   "see" ))

; define the glossary markup

(markup-index
   :open "\glossarysection[\glossarytoctitle]{\glossarytitle}\glossarypreamble~n\begin{theglossary}\glossaryheader~n" 
   :close "~n\end{theglossary}~n\glossarypostamble~n" 
   :tree)
(markup-letter-group-list :sep "\glsgroupskip~n")
(markup-indexentry :open "~n" :depth 0)
(markup-locclass-list :open "{\glossaryentrynumbers{\relax "
   :sep ", " :close "}}")
(markup-locref-list :sep "\delimN ")
(markup-range :sep "\delimR ")

; define format to use for locations


(markup-locref :open "~n\setentrycounter{page}\glsnumberformat{" 
 :close "}" 
 :attr "glsnumberformat")
(markup-locref :open "~n\setentrycounter{page}\textrm{" 
 :close "}" 
 :attr "textrm")
(markup-locref :open "~n\setentrycounter{page}\textsf{" 
 :close "}" 
 :attr "textsf")
(markup-locref :open "~n\setentrycounter{page}\texttt{" 
 :close "}" 
 :attr "texttt")
(markup-locref :open "~n\setentrycounter{page}\textbf{" 
 :close "}" 
 :attr "textbf")
(markup-locref :open "~n\setentrycounter{page}\textmd{" 
 :close "}" 
 :attr "textmd")
(markup-locref :open "~n\setentrycounter{page}\textit{" 
 :close "}" 
 :attr "textit")
(markup-locref :open "~n\setentrycounter{page}\textup{" 
 :close "}" 
 :attr "textup")
(markup-locref :open "~n\setentrycounter{page}\textsl{" 
 :close "}" 
 :attr "textsl")
(markup-locref :open "~n\setentrycounter{page}\textsc{" 
 :close "}" 
 :attr "textsc")
(markup-locref :open "~n\setentrycounter{page}\emph{" 
 :close "}" 
 :attr "emph")
(markup-locref :open "~n\setentrycounter{page}\glshypernumber{" 
 :close "}" 
 :attr "glshypernumber")
(markup-locref :open "~n\setentrycounter{page}\hyperrm{" 
 :close "}" 
 :attr "hyperrm")
(markup-locref :open "~n\setentrycounter{page}\hypersf{" 
 :close "}" 
 :attr "hypersf")
(markup-locref :open "~n\setentrycounter{page}\hypertt{" 
 :close "}" 
 :attr "hypertt")
(markup-locref :open "~n\setentrycounter{page}\hyperbf{" 
 :close "}" 
 :attr "hyperbf")
(markup-locref :open "~n\setentrycounter{page}\hypermd{" 
 :close "}" 
 :attr "hypermd")
(markup-locref :open "~n\setentrycounter{page}\hyperit{" 
 :close "}" 
 :attr "hyperit")
(markup-locref :open "~n\setentrycounter{page}\hyperup{" 
 :close "}" 
 :attr "hyperup")
(markup-locref :open "~n\setentrycounter{page}\hypersl{" 
 :close "}" 
 :attr "hypersl")
(markup-locref :open "~n\setentrycounter{page}\hypersc{" 
 :close "}" 
 :attr "hypersc")
(markup-locref :open "~n\setentrycounter{page}\hyperemph{" 
 :close "}" 
 :attr "hyperemph")
(markup-locref :open "~n\setentrycounter{page}\hyperbfit{" 
 :close "}" 
 :attr "hyperbfit")

; define letter group list format

(markup-letter-group-list :sep "\glsgroupskip~n")

; letter group headings

(markup-letter-group :open-head "\glsgroupheading{"
   :close-head "}")

(define-letter-group "glsnumbers"
   :prefixes ("0" "1" "2" "3" "4" "5" "6" "7" "8" "9")
   :before "A")

; The following is copied from xindy/lang/english/utf8-lang.xdy

(define-sort-rule-orientations (forward backward forward forward))
(use-rule-set :run 0
	      :rule-set ("en-alphabetize" "en-ignore-special"))
(use-rule-set :run 1
	      :rule-set ("en-resolve-diacritics" "en-ignore-special"))
(use-rule-set :run 2
	      :rule-set ("en-resolve-case" "en-ignore-special"))
(use-rule-set :run 3
	      :rule-set ("en-resolve-special"))

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplexdy-mc207.xdy>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*database1.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This is a sample database of glossary entries
 % Only those entries used in the document with \glslink, \gls,
 % \glspl, and uppercase variants will have entries in the
 % glossary. Note that the type key is not used, as the
 % glossary type can be specified in \loadglsentries

\newglossaryentry{array}{name=array,
description={A list of values identified by a numeric value}}

\newglossaryentry{binary}{name=binary,
description={Pertaining to numbers represented in base 2}}

\newglossaryentry{comment}{name=comment,
description={A remark that doesn't affect the meaning of the 
code}}

\newglossaryentry{global}{name=global,
description={Something that maintains its state when it leaves
the current group}}

\newglossaryentry{local}{name=local,
description={Something that only maintains its state until
it leaves the group in which it was defined/changed}}

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</database1.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*database2.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This is a sample database of glossary entries
 % Only those entries used in the document with \glslink, \gls,
 % \glspl, and uppercase variants will have entries in the
 % glossary. Note that the type key is not used, as the
 % glossary type can be specified in \loadglsentries

 % Don't need to worry about makeindex special characters
\newglossaryentry{quote}{name={"},
description={the double quote symbol}}

\newglossaryentry{at}{name={@},
description={the ``at'' symbol}}

\newglossaryentry{excl}{name={!},
description={the exclamation mark symbol}}

\newglossaryentry{bar}{name={\ensuremath{|}},
description={the vertical bar symbol}}

\newglossaryentry{hash}{name={\#},
description={the hash symbol}}

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</database2.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries.perl>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
# File          : glossaries.perl
# Author        : Nicola L.C. Talbot
# Date          : 14th June 2007
# Last Modified : 2012-09-21
# Version       : 1.05
# Description   : LaTeX2HTML (limited!) implementation of glossaries 
#                  package. Note that not all the glossaries.sty
#                  macros have been implemented.

# This is a LaTeX2HTML style implementing the glossaries package, and
# is distributed as part of that package.
# Copyright 2007 Nicola L.C. Talbot
# This work may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.3
# of this license of (at your option) any later version.
# The latest version of this license is in
#   http://www.latex-project.org/lppl.txt
# and version 1.3 or later is part of all distributions of LaTeX
# version 2005/12/01 or later.
#
# This work has the LPPL maintenance status `maintained'.
#
# The Current Maintainer of this work is Nicola Talbot.

# This work consists of the files glossaries.dtx and glossaries.ins 
# and the derived files glossaries.sty, glossary-hypernav.sty, 
# glossary-list.sty, glossary-long.sty, glossary-super.sty, 
# glossaries.perl, mfrstuc.perl. Also makeglossaries and makeglossaries.bat


package main;

&do_require_package("mfirstuc");

 %glossary_style = ();
 &set_glossarystyle('altlist');# default style

 $CURRENT_STYLE='altlist';

&process_commands_nowrap_in_tex( <<_RAW_ARG_CMDS_);
newglossarystyle # {} # {}
_RAW_ARG_CMDS_

# These are the only package options implemented.

sub do_glossaries_style_altlist{
}

sub do_glossaries_toc{
}

sub do_glossaries_toc_true{
}

$INDEXONLYFIRST=0;

sub do_glossaries_indexonlyfirst{
  $INDEXONLYFIRST=1;
}

$gls_nonumberlist{'main'} = 0;

sub do_glossaries_nonumberlist{
  $gls_nonumberlist{'main'} = 1;
}

$GLSCURRENTFORMAT="textrm" if (!defined($GLSCURRENTFORMAT));
$GLOSSARY_END_DESCRIPTION = '.' if (!defined($GLOSSARY_END_DESCRIPTION));

sub do_cmd_glossaryname{
   "Glossary$_[0]"
}

$gls_mark{'main'} = "<tex2html_gls_main_mark>";
$gls_file_mark{'main'} = "<tex2html_gls_main_file_mark>";
$gls_title{'main'} = "\\glossaryname";
$gls_toctitle{'main'} = "\\glossaryname";
$delimN{'main'} = ", ";
$glsnumformat{'main'} = $GLSCURRENTFORMAT;
@{$gls_entries{'main'}} = ();
$gls_displayfirst{'main'} = "glsdisplayfirst";
$gls_display{'main'} = "glsdisplay";

 %glsentry = ();

$acronymtype = 'main';

sub do_glossaries_acronym{
   &do_glossaries_acronym_true
}

sub do_glossaries_acronym_true{
   &make_newglossarytype("acronym", "\\acronymname");
   $acronymtype = 'acronym';
}

sub do_glossaries_acronym_false{
   $acronymtype = 'main';
}

sub do_cmd_acronymname{
   join('', 'Acronyms', $_[0]);
}

sub do_cmd_acronymtype{
   join('', $acronymtype, $_[0]);
}

$global{'glossaryentry'} = 0;
$global{'glossarysubentry'} = 0;

sub do_cmd_theglossaryentry{
  join('', $global{'glossaryentry'}, $_[0]);
}

sub do_cmd_theglossarysubentry{
  join('', $global{'glossarysubentry'}, $_[0]);
}

sub do_glossaries_entrycounter{
  &do_glossaries_entrycounter_true
}

sub do_glossaries_entrycounter_true{
  eval(<<'_END_DEF');
  sub do_cmd_glsresetentrycounter{
    $global{'entrycounter'} = 0;
    $_[0];
  }
_END_DEF
}

sub do_glossaries_entrycounter_false{
  eval(<<'_END_DEF');
  sub do_cmd_glsresetentrycounter{
    $_[0];
  }
_END_DEF
}

sub do_cmd_glsresetentrycounter{$_[0];}

sub do_glossaries_subentrycounter{
  &do_glossaries_subentrycounter_true
}

sub do_glossaries_subentrycounter_true{
  eval(<<'_END_DEF');
  sub do_cmd_glsresetsubentrycounter{
    $global{'subentrycounter'} = 0;
    $_[0];
  }
_END_DEF
}

sub do_glossaries_subentrycounter_false{
  eval(<<'_END_DEF');
  sub do_cmd_glsresetsubentrycounter{
    $_[0];
  }
_END_DEF
}

sub do_cmd_glsresetsubentrycounter{ $_[0]; }

# modify set_depth_levels so that glossary is added

sub replace_glossary_markers{
   foreach $type (keys %gls_mark)
   {
      if (defined &add_gls_hook)
        {&add_gls_hook if (/$gls_mark{$type}/);}
      else
        {&add_gls($type) if (/$gls_mark{$type}/);}

      s/$gls_file_mark{$type}/$glsfile{$type}/g;
   }
}

# there must be a better way of doing this
# other than copying the original code and adding to it.
sub replace_general_markers {
    if (defined &replace_infopage_hook) {&replace_infopage_hook if (/$info_page_mark/);}
    else { &replace_infopage if (/$info_page_mark/); }
    if (defined &add_idx_hook) {&add_idx_hook if (/$idx_mark/);}
    else {&add_idx if (/$idx_mark/);}
    &replace_glossary_markers;

    if ($segment_figure_captions) {
s/$lof_mark/$segment_figure_captions/o
    } else { s/$lof_mark/$figure_captions/o }
    if ($segment_table_captions) {
s/$lot_mark/$segment_table_captions/o
    } else { s/$lot_mark/$table_captions/o }
    &replace_morelinks();
    if (defined &replace_citations_hook) {&replace_citations_hook if /$bbl_mark/;}
    else {&replace_bbl_marks if /$bbl_mark/;}
    if (defined &add_toc_hook) {&add_toc_hook if (/$toc_mark/);}
    else {&add_toc if (/$toc_mark/);}
    if (defined &add_childs_hook) {&add_childs_hook if (/$childlinks_on_mark/);}
    else {&add_childlinks if (/$childlinks_on_mark/);}
    &remove_child_marks;

    if (defined &replace_cross_references_hook) {&replace_cross_references_hook;}
    else {&replace_cross_ref_marks if /$cross_ref_mark||$cross_ref_visible_mark/;}
    if (defined &replace_external_references_hook) {&replace_external_references_hook;}
    else {&replace_external_ref_marks if /$external_ref_mark/;}
    if (defined &replace_cite_references_hook) {&replace_cite_references_hook;}
    else { &replace_cite_marks if /$cite_mark/; }
    if (defined &replace_user_references) {
  &replace_user_references if /$user_ref_mark/; }

}

sub add_gls{
    local($sidx_style, $eidx_style) =('<STRONG>','</STRONG>');
    if ($INDEX_STYLES) {
if ($INDEX_STYLES =~/,/) {
local(@styles) = split(/\s*,\s*/,$INDEX_STYLES);
    $sidx_style = join('','<', join('><',@styles) ,'>');
    $eidx_style = join('','</', join('></',reverse(@styles)) ,'>');
} else {
    $sidx_style = join('','<', $INDEX_STYLES,'>');
    $eidx_style = join('','</', $INDEX_STYLES,'>');
}
    }
    &add_real_gls
}

sub gls_compare{
   local($x, $y) = @_;

   if ($x eq '' or $y eq '')
   {
      if ($x ne '')
      {
         # y is the shorter string
         return 1;
      }
      elsif ($y ne '')
      {
         # x is the shorter string
         return -1;
      }
      else
      {
         # both empty
         return 0;
      }
   }

   local($x0) = '';
   local($y0) = '';

   if ($x=~s/^(&#(?:\d+|x[\da-f]+);)//)
   {
      $x0 = $1;
   }
   elsif ($x=~s/^(.)//)
   {
      $x0 = $1;
   }

   if ($y=~s/^(&#(?:\d+|x[\da-f]+);)//)
   {
      $y0 = $1;
   }
   elsif ($y=~s/^(.)//)
   {
      $y0 = $1;
   }

   local($numx);

   if ($x0=~/&#(\d+|x[\da-f]+);/)
   {
      $numx = $1;

      $numx = hex("0$numx") if $numx=~/^x/;
   }
   else
   {
      $numx = ord($x0);
   }

   local($numy);

   if ($y0=~/&#(\d+|x[\da-f]+);/)
   {
      $numy = $1;

      $numy = hex("0$numy") if $numy=~/^x/;
   }
   else
   {
      $numy = ord($y0);
   }

   if ($numx == $numy)
   {
      return &gls_compare($x, $y);
   }
   elsif ($numx >= 48 and $numx <= 57) # x in range '0' ... '9'
   {
      if ($numy >= 48 and $numy <= 57) # y in range '0' ... '9'
      {
         return $numx <=> $numy;
      }
      elsif (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter
      {
         # digits are less than letters
         return -1;
      }
      else
      {
         # digits are greater than symbols
         return 1;
      }
   }
   elsif (($numx >= 97 and $numx <= 122) or ($numx >= 65 and $numx <= 90)) # x a letter
   {
      if (($numy >= 97 and $numy <= 122) or ($numy >= 65 and $numy <= 90)) # y a letter
      {
         if (($numx <= 90 and $numy <= 90) or ($numx >= 97 and $numy >= 97))
         {
            # same case (already checked if they are equal)

            return $numx <=> $numy;
         }

         # are they upper/lower case versions of each other?

         if (($numx >= 97 and $numy == $numx-32))
         {
            # x is upper case version of y

            if ($x or $y)
            {
               return &gls_compare($x, $y);
            }
            else
            {
               return -1;
            }
         }

         if (($numy >= 97 and $numx == $numy-32))
         {
            # y is upper case version of x

            if ($x or $y)
            {
               return &gls_compare($x, $y);
            }
            else
            {
               return 1;
            }
         }

         # compare lower case values
         return lc(chr($numx)) cmp lc(chr($numy));
      }
      else
      {
         # a-z greater than symbols and digits
         return 1;
      }
   }
   elsif ($numy >= 48 and $numy <= 57) # y in range '0' ... '9'
   {
      # already checked for '0' < x < '9' and '0' < y < '9'
      # already checked for 'a' < x < 'z' and '0' < y < '9'
      
      # digits greater than symbols
      return 1;
   }
   elsif (($numy >= 97 and $numy <= 122)  or ($numy >= 65 and $numy <= 90)) # y is a letter
   {
      # already checked for x is digit and y a is letter
      # already checked for x is letter and y a is letter
      
      # symbols and digits are less than letters

      return -1;
   }

   $numx <=> $numy
}

sub gloskeysort{

   $a=~/^(.*)###(\d+)$/;

   local($labelx) = $1;
   local($x_id) =$2;

   $b=~/^(.*)###(\d+)$/;

   local($labely) = $1;
   local($y_id) = $2;

   local($sortx) = &gls_get_sort($labelx);
   local($sorty) = &gls_get_sort($labely);

   local($n);

   # are they case-insensitive equivalent?

   if (lc($sortx) eq lc($sorty))
   {
      $n = ($sortx cmp $sorty);
   }
   else
   {
      $n = &gls_compare($sortx, $sorty);
   }

   unless ($n)
   {
      $n = ($x_id <=> $y_id);
   }

   $n
}

sub add_parent_if_required{
   local($label) = @_;

   local($parent) = &gls_get_parent($label);

   if ($parent)
   {
      local($type) = &gls_get_type($parent);

      # does this parent have a backlink?

      for my $key (keys %{$glossary{$type}})
      {
         return if $key=~/^$parent###\d+$/;
      }

      # none found, so add empty one

      my $id = ++$global{'max_id'};

      $glossary{$type}{"$parent###$id"} = '';
      $glossary_entry{$type}{"$parent###$id"} = $parent;

      # check if parent also has a parent

      &add_parent_if_required($parent);
   }
}

sub add_real_gls{
   local($type) = @_;
   print "\nDoing glossary '$type' ...";
   local($key, $str, @keys, $thisglsentry, $level, $count,
   $previous, $current, $id, $linktext, $delimN);

   $TITLE = $gls_toctitle{$type};

   local($oldstyle) = $CURRENT_STYLE;

   if ($gls_style{$type})
   {
      &set_glossarystyle($gls_style{$type});
   }

   # add any parent entries that haven't been referenced

   for my $key (keys %{$glossary{$type}})
   {
      my $label = $key;
      $label =~ s/###\d+$//o; # Remove the unique id's

      &add_parent_if_required($label);
   }

   @keys = keys %{$glossary{$type}};

   @keys = sort gloskeysort @keys;

   $level = 0;

   $delimN = $delimN{$type};

   $previous = '';

   local($previousentry) = '';

   my $glossaryentryfield = '';

   my $previouscat = '';

   local ($entry);

   foreach $key (@keys)
   {
      $current = $key;
      $current =~ s/\#\#\#\d+$//o; # Remove the unique id's

      my $issame = ($current eq $previous ? 1 : 0);

      $previous = $current;

      $entry = $glossary_entry{$type}{$key};

      unless ($issame)
      {
         if ($glossaryentryfield)
         {
            $id = ++$global{'max_id'};

            my $level = &gls_get_level($previousentry);

            if ($level > 0)
            {
              my $id2 = ++$global{'max_id'};

              $thisglsentry .= 
                 "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP";
            }
            else
            {
              $thisglsentry .= 
                 "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP";
            }

            $glossaryentryfield = '';
         }

         $linktext = '';

         my $currentcat = substr(&gls_get_sort($current), 0, 1);

         if ($currentcat=~/[a-zA-Z]/)
         {
            $currentcat = uc($currentcat);
         }
         elsif ($currentcat=~/[0-9]/)
         {
            $currentcat = 'glsnumbers';
         }
         else
         {
            $currentcat = 'glssymbols';
         }

         unless ($previouscat eq $currentcat)
         {
            $id = ++$global{'max_id'};
            $thisglsentry .= "\\glsgroupheading$OP$id$CP$currentcat$OP$id$CP";

            $previouscat = $currentcat;
         }
      }

      $previousentry = $entry;

      # Back ref
      
      if ($gls_nonumberlist{$type})
      {
         $linktext = '';
      }
      elsif ($glossary{$type}{$key})
      {
         $id = ++$global{'max_id'};

         $linktext .= $delimN if ($linktext);

         $linktext .= "$glossary{$type}{$key}\\$glossary_format{$type}{$key}${OP}$id${CP}$glossary_linktext{$type}{$key}${OP}$id${CP}</A>";

      }

      unless ($issame)
      {
         $id = ++$global{'max_id'};
         local($name) = &translate_commands(
            "\\glsnamefont $OP$id$CP$glsentry{$entry}{name}$OP$id$CP");

         local($symbol) = ($glsentry{$entry}{'symbol'} ?
                        " $glsentry{$entry}{symbol}" : '');

         $id = ++$global{'max_id'};
         my $id2 = ++$global{'max_id'};
         my $id3 = ++$global{'max_id'};
         my $id4 = ++$global{'max_id'};

         $glossaryentryfield = "$OP$id$CP$entry$OP$id$CP" # label
           . "$OP$id2$CP$name$OP$id2$CP" # name
           . "$OP$id3$CP$glsentry{$entry}{description}$OP$id3$CP" # description
           . "$OP$id4$CP$symbol$OP$id4$CP" # symbol
      }

   }

   if ($glossaryentryfield and $entry)
   {
      my $level = &gls_get_level($entry);

      if ($level > 0)
      {
        my $id2 = ++$global{'max_id'};

        $thisglsentry .= 
           "\\glossarysubentryfield $OP$id2$CP$level$OP$id2$CP$glossaryentryfield$OP$id$CP$linktext$OP$id$CP";
      }
      else
      {
         $id = ++$global{'max_id'};
         $thisglsentry .= 
            "\\glossaryentryfield $glossaryentryfield$OP$id$CP$linktext$OP$id$CP";
      }
   }

   $str = &do_env_theglossary($thisglsentry) . &translate_commands("\\glossarypostamble");

   if ($gls_style{$type})
   {
      &set_glossarystyle($oldstyle);
   }

   s/$gls_mark{$type}/$preglossary\n$str\n/s;
}

sub do_cmd_glstarget{
  local($_) = @_;

  local($id, $label, $text);

  $label = &missing_braces unless
   s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo;

  $text = &missing_braces unless
   s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo;

  "<A NAME=\"gls:$label\">$text</A>$_";
}

sub do_cmd_newglossarystyle{
   local($_) = @_;

   local($id,$style,$defs);

   $style = &missing_braces unless 
     s/$next_pair_rx/$id=$1;$style=$2;''/eo;

   $defs = &missing_braces unless 
     s/$next_pair_rx/$id=$1;$defs=$2;''/eo;

   $glossary_style{$style} = $defs;

   $_;
}

sub do_cmd_glossarystyle{
   local($_) = @_;

   local($id,$style);

   $style = &missing_braces unless 
     s/$next_pair_pr_rx/$id=$1;$style=$2;''/eo;

   &set_glossarystyle($style);

   $_;
}

sub set_glossarystyle{
   local($style) = @_;

   $CURRENT_STYLE = $style;

   if ($glossary_style{$style})
   {
      local($_) = $glossary_style{$style};

      s/$O(\d+)$C/$OP$1$CP/g;

      &translate_commands($_);
   }
   else
   {
      my $cmd_sub = "set_glossarystyle_$style";

      if (defined(&$cmd_sub))
      {
         &$cmd_sub();
      }
      else
      {
         &write_warnings("Unknown glossary style '$style', defaulting to 'altlist'");
         &set_glossarystyle_altlist();

         $CURRENT_STYLE = 'altlist';
      }
   }

}

sub do_cmd_glspar{ "<P>".$_[0]; }

sub do_cmd_glossaryheader{ 
  local($_) = @_;
  $_
}

sub do_cmd_glsentryitem{
  local($_) = @_;

  local($id, $label);

  $label = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo;

  $_
}

sub do_cmd_glssubentryitem{
  local($_) = @_;

  local($id, $label);

  $label = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo;

  $_
}

sub do_cmd_glsgroupheading{ 
  local($_) = @_;

  local($id, $heading);

  $heading = &missing_braces unless
   s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo;

  $_;
}

sub do_cmd_glossaryentryfield{
   local($_) = @_;

   local($id, $label, $name, $desc, $symbol, $backlink);

   $label = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo;

   $name = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo;

   $desc = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo;

   $symbol = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo;

   $backlink = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo;

   local($id2) = ++$global{'max_id'};

   "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_";
}

sub do_cmd_glossarysubentryfield{
   local($_) = @_;

   local($id, $level, $label, $name, $desc, $symbol, $backlink);

   $level = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo;

   $label = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo;

   $name = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$name=$2;''/eo;

   $desc = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$desc=$2;''/eo;

   $symbol = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$symbol=$2;''/eo;

   $backlink = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1;$backlink=$2;''/eo;

   local($id2) = ++$global{'max_id'};

   "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n$desc $backlink\n$_";
}

sub do_env_theglossary{
  local($_) = @_;

   &translate_commands($_);
}

sub set_glossarystyle_altlist{
  eval(<<'END_STYLE'); 
  sub do_cmd_glossaryheader{ 
    local($_) = @_;
    $_
  }

  sub do_cmd_glsgroupheading{ 
     local($_) = @_;

     local($id, $heading);

     $heading = &missing_braces unless
      s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo;

    $_
  }

  sub do_cmd_glossaryentryfield{
     local($_) = @_;

     local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink);

     $label = &missing_braces unless
       s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo;

     $name = &missing_braces unless
       s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo;

     $desc = &missing_braces unless
       s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo;

     $symbol = &missing_braces unless
       s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo;

     $backlink = &missing_braces unless
       s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo;

     "<DT>\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP\n<DD>"
     . "$desc\\glspostdescription\\space $backlink$_";
  }

  sub do_cmd_glossarysubentryfield{
     local($_) = @_;

     local($id, $id2, $id3, $id4, $id5, $id6, $level, 
       $label, $name, $desc, $symbol, $backlink);

     $level = &missing_braces unless
       s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo;

     $label = &missing_braces unless
       s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo;

     $name = &missing_braces unless
       s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo;

     $desc = &missing_braces unless
       s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo;

     $symbol = &missing_braces unless
       s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo;

     $backlink = &missing_braces unless
       s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo;
  
     "<P>\\glssubentryitem $OP$id$CP$label$OP$id$CP"
     ."\\glstarget $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP"
     ."$desc\\glspostdescription\\space $backlink\n$_";
  }

  sub do_env_theglossary{
    local($_) = @_;

     "<DL>".&translate_commands("\\glossaryheader $_")."</DL>";
  }
END_STYLE
}

sub set_glossarystyle_inline{
  eval(<<'END_STYLE'); 
  sub do_cmd_glossaryheader{ 
    local($_) = @_;
    $_
  }

  sub do_cmd_glsgroupheading{ 
    local($_) = @_;

    local($id, $heading);

    $heading = &missing_braces unless
     s/$next_pair_pr_rx/$id=$1,$heading=$2;''/eo;

    $_;
  }

  sub do_cmd_glossaryentryfield{
     local($_) = @_;

     local($id, $id2, $id3, $id4, $id5, $label, $name, $desc, $symbol, $backlink);

     $label = &missing_braces unless
       s/$next_pair_pr_rx/$id=$1;$label=$2;''/eo;

     $name = &missing_braces unless
       s/$next_pair_pr_rx/$id2=$1;$name=$2;''/eo;

     $desc = &missing_braces unless
       s/$next_pair_pr_rx/$id3=$1;$desc=$2;''/eo;

     $symbol = &missing_braces unless
       s/$next_pair_pr_rx/$id4=$1;$symbol=$2;''/eo;

     $backlink = &missing_braces unless
       s/$next_pair_pr_rx/$id5=$1;$backlink=$2;''/eo;

     local($field) = "\\glsinlinedopostchild $glsinlinesep";

     $field .= "\\glsentryitem $OP$id$CP$label$OP$id$CP"
             . "\\glsinlinenameformat $OP$id2$CP$label$OP$id2$CP$OP$id3$CP$name$OP$id3$CP";

     $id3 = ++$global{'max_id'};

     if ($desc)
     {
       $field .= 
           "\\glsinlinedescformat $OP$id3$CP$desc$OP$id3$CP"
          ."$OP$id4$CP$symbol$OP$id4$CP"
          ."$OP$id5$CP$backlink$OP$id5$CP";
     }
     else
     {
       $field .= 
           "\\glsinlineemptydescformat "
          ."$OP$id4$CP$symbol$OP$id4$CP"
          ."$OP$id5$CP$backlink$OP$id5$CP";
     }

# TODO : check if has children

     local($haschildren) = 0;

     if ($haschildren)
     {
       $field .= "\\glsresetsubentrycounter "
               . "\\glsinlineparentchildseparator "
               . "\\glsinlinepostchild ";
     }

    $glsinlinesep = &translate_commands("\\glsinlineseparator ")
       unless $glsinlinesep;

     $field.$_;
  }

  sub do_cmd_glossarysubentryfield{
     local($_) = @_;

     local($id, $id2, $id3, $id4,$id5,$id6,$level, 
       $label, $name, $desc, $symbol, $backlink);

     $level = &missing_braces unless
       s/$next_pair_pr_rx/$id=$1;$level=$2;''/eo;

     $label = &missing_braces unless
       s/$next_pair_pr_rx/$id2=$1;$label=$2;''/eo;

     $name = &missing_braces unless
       s/$next_pair_pr_rx/$id3=$1;$name=$2;''/eo;

     $desc = &missing_braces unless
       s/$next_pair_pr_rx/$id4=$1;$desc=$2;''/eo;

     $symbol = &missing_braces unless
       s/$next_pair_pr_rx/$id5=$1;$symbol=$2;''/eo;

     $backlink = &missing_braces unless
       s/$next_pair_pr_rx/$id6=$1;$backlink=$2;''/eo;

     "\\glsinlinesubnameformat $OP$id$CP$label$OP$id$CP$OP$id2$CP$name$OP$id2$CP"
     ."\\glssubentryitem $OP$id3$CP$label$OP$id3$CP"
     ."\\glsinlinesubdescformat $OP$id4$CP$desc$OP$id4$CP$OP$id5$CP$symbol$OP$id5$CP$OP$id6$CP$backlink$OP$id6$CP"
     .$_;
  }

  sub do_env_theglossary{
    local($_) = @_;

    $glsinlinesep = '';

     &translate_commands("\\glossaryheader $_\\glspostinline ");
  }
END_STYLE
}

local($glsinlinesep,$glsinlinepostchild);

sub do_cmd_glsinlineseparator{
  local($_) = @_;

  "; $_";
}

sub do_cmd_glsinlinedopostchild{
  local($_) = @_;

  $_;
}

sub do_cmd_glspostdescription{
  local($_) = @_;

  $GLOSSARY_END_DESCRIPTION.$_;
}

sub do_cmd_glspostinline{
  local($_) = @_;

  &translate_commands("\\glspostdescription\\space ").$_;
}

sub do_cmd_glsinlinepostchild{
  local($_) = @_;

  $_;
}

sub do_cmd_glsinlineparentchildseparator{
  local($_) = @_;

  ": $_";
}

sub do_cmd_glsinlinesubseparator{
  local($_) = @_;

  ", $_";
}

sub do_cmd_glsinlinenameformat{
  &do_cmd_glstarget(@_);
}

sub do_cmd_glsinlinedescformat{
  local($_) = @_;

  local($id, $desc, $symbol, $backlinks);

  $desc = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo;

  $symbol = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo;

  $backlinks = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo;

  "\\space $desc$_";
}

sub do_cmd_glsinlineemptydescformat{
  local($_) = @_;

  local($id, $symbol, $backlinks);

  $symbol = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo;

  $backlinks = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo;

  $_;
}

sub do_cmd_glsinlinesubnameformat{
  local($_) = @_;

  local($id, $id2, $label, $name);

  $label = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo;

  $name = &missing_braces unless
    s/$next_pair_pr_rx/$id2=$1,$name=$2;''/eo;

  "\\glstarget $OP$id$CP$label$OP$id$CP$OP$id2$CP$OP$id2$CP$_";
}

sub do_cmd_glsinlinesubdescformat{
  local($_) = @_;

  local($id, $desc, $symbol, $backlinks);

  $desc = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$desc=$2;''/eo;

  $symbol = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$symbol=$2;''/eo;

  $backlinks = &missing_braces unless
    s/$next_pair_pr_rx/$id=$1,$backlinks=$2;''/eo;

  "$desc$_";
}

sub set_depth_levels {
    # Sets $outermost_level
    local($level);
    # scan the document body, not the preamble, for use of sectioning commands
    my ($contents) = $_;
    if ($contents =~ /\\begin\s*((?:$O|$OP)\d+(?:$C|$CP))document\1|\\startdocument/s) {
$contents = $';
    }
    foreach $level ("part", "chapter", "section", "subsection",
    "subsubsection", "paragraph") {
last if (($outermost_level) = $contents =~ /\\($level)$delimiter_rx/);
last if (($outermost_level) = $contents =~ /\\endsegment\s*\[\s*($level)\s*\]/s);
if ($contents =~ /\\segment\s*($O\d+$C)[^<]+\1\s*($O\d+$C)\s*($level)\s*\2/s)
{ $outermost_level = $3; last };
    }
    $level = ($outermost_level ? $section_commands{$outermost_level} :
      do {$outermost_level = 'section'; 3;});

    if ($REL_DEPTH && $MAX_SPLIT_DEPTH) {
$MAX_SPLIT_DEPTH = $level + $MAX_SPLIT_DEPTH;
    } elsif (!($MAX_SPLIT_DEPTH)) { $MAX_SPLIT_DEPTH = 1 };

    %unnumbered_section_commands = (
          'tableofcontents', $level
, 'listoffigures', $level
, 'listoftables', $level
, 'bibliography', $level
, 'textohtmlindex', $level
, 'textohtmlglossary', $level
, 'textohtmlglossaries', $level
        , %unnumbered_section_commands
        );

    %section_commands = (
  %unnumbered_section_commands
        , %section_commands
        );
}

sub add_bbl_and_idx_dummy_commands {
    local($id) = $global{'max_id'};

    s/([\\]begin\s*$O\d+$C\s*thebibliography)/$bbl_cnt++; $1/eg;
    ## if ($bbl_cnt == 1) {
s/([\\]begin\s*$O\d+$C\s*thebibliography)/$id++; "\\bibliography$O$id$C$O$id$C $1"/geo;
    #}
    $global{'max_id'} = $id;
    s/([\\]begin\s*$O\d+$C\s*theindex)/\\textohtmlindex $1/o;
    s/[\\]printindex/\\textohtmlindex /o;
    &add_gls_dummy_commands;
    &lib_add_bbl_and_idx_dummy_commands() if defined(&lib_add_bbl_and_idx_dummy_commands);
}

sub add_gls_dummy_commands{
   s/[\\]printglossary/\\textohtmlglossary/sg;
   s/[\\]printglossaries/\\textohtmlglossaries/sg;
}

sub get_firstkeyval{
   local($key,$_) = @_;
   local($value);

   s/\b$key\s*=$OP(\d+)$CP(.*)$OP\1$CP\s*(,|$)/$value=$2;','/es;
   undef($value) if $`=~/\b$key\s*=/;

   unless (defined($value))
   {
      s/(^|,)\s*$key\s*=\s*([^,]*)\s*(,|$)/,/s;
      $value=$2;
   }

   ($value,$_);
}

# need to get the value of the last key of a given name
# in the event of multiple occurrences.
sub get_keyval{
   local($key,$_) = @_;
   local($value);

   while (/\b$key\s*=/g)
   {
      ($value,$_) = &get_firstkeyval($key, $_);
      last unless defined($value);
   }

   ($value,$_);
}

sub get_boolval{
   local($key,$_) = @_;
   local($value);

   while (/\b$key\s*(?:=(true|false))?\b/g)
   {
     $value = ($1 ? $1 : 'true');
   }

   ($value eq 'true' ? 1 : 0, $_);
}

# This is modified from do_cmd_textohtmlindex

sub do_cmd_textohtmlglossary{
   local($_) = @_;

   local($keyval,$pat) = &get_next_optional_argument;

   local($type,$title,$toctitle,$style,$nonumberlist);

   $nonumberlist = 'default';

   ($type,$keyval) = &get_keyval('type', $keyval);
   ($title,$keyval) = &get_keyval('title', $keyval);
   ($toctitle,$keyval) = &get_keyval('toctitle', $keyval);
   ($style,$keyval) = &get_keyval('style', $keyval);
   ($nonumberlist,$keyval) = &get_boolval('nonumberlist', $keyval);

   &make_textohtmlglossary($type,$toctitle,$title,$style,$nonumberlist).$_;
}

# add_real_gls does the actual glossary
sub make_textohtmlglossary{
   local($type,$toctitle,$title,$style,$nonumberlist) = @_;

   unless (defined($type)) {$type = 'main';}

   unless (defined $gls_mark{$type})
   {
      &write_warnings("glossary type '$type' not implemented");
   }

   if ($style)
   {
      $gls_style{$type} = $style;
   }

   $toctitle = $gls_toctitle{$type} unless ($toctitle or $title);

   $title = $gls_title{$type} unless ($title);
   $toctitle = $title unless ($toctitle);

   $gls_toctitle{$type} = $toctitle;

   $gls_nonumberlist{$type} = $nonumberlist unless ($nonumberlist eq 'default');

   $toc_sec_title = $toctitle;
   $glsfile{$type} = $CURRENT_FILE;

   if (defined($frame_main_suffix))
   {
      $glsfile{$type}=~s/$frame_main_suffix/$frame_body_suffix/;
   }

   $TITLE=&translate_commands($toctitle);

   if (%glossary_labels) { &make_glossary_labels(); }

   if (($SHORT_INDEX) && (%glossary_segment))
   {
      &make_preglossary();
   }
   else
   {
      $preglossary = &translate_commands("\\glossarypreamble");
   }

   local $idx_head = $section_headings{'textohtmlindex'};
   local($heading) = join(''
        , &make_section_heading($title, $idx_head)
        , $gls_mark{$type} );
   local($pre,$post) = &minimize_open_tags($heading);

   join('',"<BR>\n" , $pre);
}

sub do_cmd_textohtmlglossaries{
   local($_) = @_;

   foreach $type (keys %gls_mark)
   {
      $id = ++$global{'max_id'};
      $_ = &make_textohtmlglossary($type,$gls_title{'main'}).$_;
   }

   $_;
}

sub make_glossary_labels {
    local($key, @keys);
    @keys = keys %glossary_labels;
    foreach $key (@keys) {
        if (($ref_files{$key}) && !($ref_files{$key} eq "$glsfile{'main'}")) {
            local($tmp) = $ref_files{$key};
            &write_warnings("\nmultiple label $key , target in $glsfile{'main'} masks $tmp ");
        }
        $ref_files{$key} .= $glsfile{'main'};
    }
}

sub make_preglossary{ &make_real_preglossary }
sub make_real_preglossary{
    local($key, @keys, $head, $body);
    $head = "<HR>\n<H4>Legend:</H4>\n<DL COMPACT>";
    @keys = keys %glossary_segment;
    foreach $key (@keys) {
        local($tmp) = "segment$key";
        $tmp = $ref_files{$tmp};
        $body .= "\n<DT>$key<DD>".&make_named_href('',$tmp,$glossary_segment{$key});
    }
    $preglossary = join('', $head, $body, "\n</DL>") if ($body);
}

sub do_cmd_glossary { &do_real_glossary(@_) }
sub do_real_glossary {
   local($_) = @_;
   local($type) = "main";
   local($anchor,$entry);

   local($type,$pat) = &get_next_optional_argument;

   $entry = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($entry=$2));

   $anchor = &make_glossary_entry($entry,$anchor_invisible_mark,$type);

   join('', $anchor, $_);
}

sub make_glossary_entry { &make_real_glossary_entry(@_) }
sub make_real_glossary_entry {
    local($entry,$text,$type) = @_;
    local($this_file) = $CURRENT_FILE;

    $TITLE = $saved_title
       if (($saved_title)&&(!($TITLE)||($TITLE eq $default_title)));

    # Save the reference
    local($str) = "$label###" . ++$global{'max_id'}; # Make unique

    local($id) = ++$glsentry{$entry}{'maxid'};
    local($glsanchor)="gls:$entry$id";

    local($target) = $frame_body_name;

    if (defined($frame_main_suffix))
    {
       $this_file=~s/$frame_main_suffix/$frame_body_suffix/;
    }

    $glossary{$type}{$str} .= &make_half_href($this_file."#$glsanchor");
    $glossary_format{$type}{$str} = $GLSCURRENTFORMAT;
    $glossary_entry{$type}{$str} = $entry;
    $glossary_linktext{$type}{$str} = $TITLE;

    local($mark) = $gls_file_mark{$type};

    $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark));

    $text = &translate_commands($text);

    if (defined($frame_foot_name))
    {
       "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>";
    }
    else
    {
       "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\">$text<\/A>";
    }
}

sub make_real_glossary_entry_no_backlink {
    local($entry,$text,$type) = @_;
    local($this_file) = $CURRENT_FILE;

    local($target) = $frame_body_name;

    if (defined($frame_main_suffix))
    {
       $this_file=~s/$frame_main_suffix/$frame_body_suffix/;
    }

    local($mark) = $gls_file_mark{$type};

    $mark = &get_gls_file_mark($type, $entry) if (defined(&get_gls_file_mark));

    $text = &translate_commands($text);

    if (defined($frame_foot_name))
    {
       "<A HREF=\"$mark#gls:$entry\" NAME=\"$glsanchor\" TARGET=\"$frame_foot_name\">$text<\/A>";
    }
    else
    {
       "<A HREF=\"$mark#gls:$entry\" >$text<\/A>";
    }
}

sub do_cmd_newglossary{
   local($_) = @_;
   local($type,$out,$in,$opt,$pat,$title);

   ($opt,$pat) = &get_next_optional_argument;

   $type = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($type=$2));
   $in = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($in=$2));
   $out = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($out=$2));
   $title = &missing_braces unless 
           (s/$next_pair_pr_rx//o&&($title=$2));

   ($opt,$pat) = &get_next_optional_argument;

   &make_newglossarytype($type, $title);

   $_;
}

sub make_newglossarytype{
   local($type, $title) = @_;

   $gls_mark{$type} = "<tex2html_gls_${type}_mark>";
   $gls_file_mark{$type} = "<tex2html_gls_${type}_file_mark>";
   $gls_title{$type} = $title;
   $gls_toctitle{$type} = $title;
   $delimN{$type} = ", ";
   $glsnumformat{$type} = $GLSCURRENTFORMAT;
   @{$gls_entries{$type}} = ();
   $gls_displayfirst{$type} = "glsdisplayfirst";
   $gls_display{$type} = "glsdisplay";
   $gls_nonumberlist{$type} = $gls_nonumberlist{'main'};
}

sub do_cmd_glsdisplay{
   local($_) = @_;
   local($text,$description,$symbol,$insert);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   $description = &missing_braces unless
        (s/$next_pair_pr_rx/$description=$2;''/eo);

   $symbol = &missing_braces unless
        (s/$next_pair_pr_rx/$symbol=$2;''/eo);

   $insert = &missing_braces unless
        (s/$next_pair_pr_rx/$insert=$2;''/eo);

   "$text$insert" . $_;
}

sub do_cmd_glsdisplayfirst{
   local($_) = @_;
   local($text,$description,$symbol,$insert);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   $description = &missing_braces unless
        (s/$next_pair_pr_rx/$description=$2;''/eo);

   $symbol = &missing_braces unless
        (s/$next_pair_pr_rx/$symbol=$2;''/eo);

   $insert = &missing_braces unless
        (s/$next_pair_pr_rx/$insert=$2;''/eo);

   "$text$insert" . $_;
}

sub gls_get_displayfirst{
   local($type) = @_;
   local($display)= $gls_displayfirst{$type};

   if (not defined($display))
   {
      &write_warnings("Glossary '$type' is not defined");
      $display='';
   }
   elsif ($display eq '')
   {
      &write_warnings("glsdisplayfirst not set for glossary '$type'");
   }
   else
   {
      $display = "\\$display ";
   }

   $display;
}

sub gls_get_display{
   local($type) = @_;
   local($display)= $gls_display{$type};

   if (not defined($display))
   {
      &write_warnings("Glossary '$type' is not defined");
      $display = '';
   }
   elsif ($display eq '')
   {
      &write_warnings("glsdisplay not set for glossary '$type'");
   }
   else
   {
      $display = "\\$display ";
   }

   $display;
}

sub do_cmd_glsnamefont{
   local($_) = @_;
   local($text);

   $text = &missing_braces unless
        (s/$next_pair_pr_rx/$text=$2;''/eo);

   "<B>$text</B>$_";
}

sub do_cmd_newacronym{
   local($_) = @_;
   local($label,$abbrev,$long,$opt);

   ($opt,$pat) = &get_next_optional_argument;

   $label = &missing_braces unless
        (s/$next_pair_pr_rx/$label=$2;''/eo);
   $abbrv = &missing_braces unless
        (s/$next_pair_pr_rx/$abbrv=$2;''/eo);
   $long = &missing_braces unless
        (s/$next_pair_pr_rx/$long=$2;''/eo);

   local($cmd) = "\\newglossaryentry";
   local($id);
   $id = ++$global{'max_id'};
   $cmd .= "$OP$id$CP$label$OP$id$CP";
   $id = ++$global{'max_id'};
   local($entry) = "type=$OP$id$CP\\acronymtype$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "name=$OP$id$CP$abbrv$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "description=$OP$id$CP$long$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "text=$OP$id$CP$abbrv$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "first=$OP$id$CP$long ($abbrv)$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "plural=$OP$id$CP${abbrv}s$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "firstplural=$OP$id$CP${long}s (${abbrv}s)$OP$id$CP";

   $id = ++$global{'max_id'};
   $cmd .= "$OP$id$CP$entry,$opt$OP$id$CP";

   &translate_commands($cmd).$_;
}

sub gls_entry_init{
   local($label, $type, $name, $desc) = @_;

   %{$glsentry{$label}} = 
     ( type => $type,
       name => $name,
       'sort' => $name,
       description => $desc,
       text => $name,
       first => $name,
       plural => "${name}s",
       firstplural => "${name}s",
       symbol => '',
       flag => 0,
       maxid => 0,
       level => 0,
       parent => ''
     );

   $#{@{$glsentry{$label}{children}}} = -1; 

   $glsentry{$label};
}

sub gls_get_type{
   local($label) = @_;
   local($type) = '';

   if (&gls_entry_defined($label))
   {
      $type = $glsentry{$label}{'type'};
   }
   else
   {
      &write_warnings("gls_get_type: glossary entry '$label' has not been defined");
   }

   $type;
}

sub gls_set_type{
   local($label, $type) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'type'} = $type;
   }
   else
   {
      &write_warnings("gls_set_type: glossary entry '$label' has not been defined");
   }
}

sub gls_get_name{
   local($label) = @_;
   local($name) = '';

   if (&gls_entry_defined($label))
   {
      $name = $glsentry{$label}{'name'};
   }
   else
   {
      &write_warnings("gls_get_name: glossary entry '$label' has not been defined");
   }

   $name;
}

sub gls_set_name{
   local($label, $name) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'name'} = $name;
   }
   else
   {
      &write_warnings("gls_set_name: glossary entry '$label' has not been defined");
   }
}

sub gls_get_description{
   local($label) = @_;
   local($description) = '';

   if (&gls_entry_defined($label))
   {
      $description = $glsentry{$label}{'description'};
   }
   else
   {
      &write_warnings("gls_get_description: glossary entry '$label' has not been defined");
   }

   $description;
}

sub gls_set_description{
   local($label, $description) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'description'} = $description;
   }
   else
   {
      &write_warnings("gls_set_description: glossary entry '$label' has not been defined");
   }
}

sub gls_get_symbol{
   local($label) = @_;
   local($symbol) = '';

   if (&gls_entry_defined($label))
   {
      $symbol = $glsentry{$label}{'symbol'};
   }
   else
   {
      &write_warnings("gls_get_symbol: glossary entry '$label' has not been defined");
   }

   $symbol;
}

sub gls_set_symbol{
   local($label, $symbol) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'symbol'} = $symbol;
   }
   else
   {
      &write_warnings("gls_set_symbol: glossary entry '$label' has not been defined");
   }
}

sub gls_get_sort{
   local($label) = @_;
   local($sort) = '';

   if (&gls_entry_defined($label))
   {
      $sort = $glsentry{$label}{'sort'};
   }
   else
   {
      &write_warnings("gls_get_sort: glossary entry '$label' has not been defined");
   }

   $sort;
}

sub gls_set_sort{
   local($label, $sort) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'sort'} = $sort;
   }
   else
   {
      &write_warnings("gls_set_sort: glossary entry '$label' has not been defined");
   }
}

sub gls_get_text{
   local($label) = @_;
   local($text) = '';

   if (&gls_entry_defined($label))
   {
      $text = $glsentry{$label}{'text'};
   }
   else
   {
      &write_warnings("gls_get_text: glossary entry '$label' has not been defined");
   }

   $text;
}

sub gls_set_text{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'text'} = $text;
   }
   else
   {
      &write_warnings("gls_set_text: glossary entry '$label' has not been defined");
   }
}

sub gls_get_plural{
   local($label) = @_;
   local($plural) = '';

   if (&gls_entry_defined($label))
   {
      $plural = $glsentry{$label}{'plural'};
   }
   else
   {
      &write_warnings("gls_get_plural: glossary entry '$label' has not been defined");
   }

   $plural;
}

sub gls_set_plural{
   local($label, $plural) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'plural'} = $plural;
   }
   else
   {
      &write_warnings("gls_set_plural: glossary entry '$label' has not been defined");
   }
}

sub gls_get_firstplural{
   local($label) = @_;
   local($firstplural) = '';

   if (&gls_entry_defined($label))
   {
      $firstplural = $glsentry{$label}{'firstplural'};
   }
   else
   {
      &write_warnings("gls_get_firstplural: glossary entry '$label' has not been defined");
   }

   $firstplural;
}

sub gls_set_firstplural{
   local($label, $firstplural) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'firstplural'} = $firstplural;
   }
   else
   {
      &write_warnings("gls_set_firstplural: glossary entry '$label' has not been defined");
   }
}

sub gls_get_first{
   local($label) = @_;
   local($first) = '';

   if (&gls_entry_defined($label))
   {
      $first = $glsentry{$label}{'first'};
   }
   else
   {
      &write_warnings("gls_get_first: glossary entry '$label' has not been defined");
   }

   $first;
}

sub gls_set_first{
   local($label, $first) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'first'} = $first;
   }
   else
   {
      &write_warnings("gls_set_first: glossary entry '$label' has not been defined");
   }
}

sub gls_get_parent{
  local($label) = @_;

  local($parent);

  if (&gls_entry_defined($label))
  {
     $parent = $glsentry{$label}{'parent'};
  }
  else
  {
     &write_warnings("gls_get_parent: glossary entry '$label' has not been defined");
  }

  $parent;
}

sub gls_get_level{
   local($label) = @_;

   local($level) = 0;

   if (&gls_entry_defined($label))
   {
      $level = $glsentry{$label}{'level'};
   }
   else
   {
     &write_warnings("gls_get_level: glossary entry '$label' has not been defined");
   }

   $level;
}

sub gls_set_parent{
  local ($label, $parent) = @_;

  if (&gls_entry_defined($label))
  {
     if ($parent)
     {
        if (&gls_entry_defined($parent))
        {
           $glsentry{$label}{'parent'} = $parent;

           push @{$glsentry{$parent}{'children'}}, $label;

           $glsentry{$label}{'level'} = $glsentry{$parent}{'level'}+1;
        }
        else
        {
           &write_warnings("gls_set_parent: parent '$parent' for glossary entry '$label' has not been defined");
        }
     }
     else
     {
        $glsentry{$label}{'parent'} = '';
     }
  }
  else
  {
     &write_warnings("gls_set_parent: glossary entry '$label' has not been defined");
  }
}

sub gls_get_childcount{
   my($label) = @_;

   my($count) = 0;

   if (&gls_entry_defined($label))
   {
      $count = scalar(@{$glsentry{$label}{'children'}});
   }
   else
   {
      &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined");
   }

   $count;
}

sub gls_get_referenced_childcount{
   my($label) = @_;

   my($count) = 0;

   if (&gls_entry_defined($label))
   {
      $count = scalar(grep(($glsentry{$_}{'maxid'} > 0), @{$glsentry{$label}{'children'}}));
   }
   else
   {
      &write_warnings("gls_get_childcount: glossary entry '$label' has not been defined");
   }

   $count;
}

sub gls_set_userkeys{
   local($label, @user) = @_;

   if (&gls_entry_defined($label))
   {
      for (my $idx = 0; $idx < 6; $idx++)
      {
         $glsentry{$label}{"user".($idx+1)} = $user[$idx];
      }
   }
   else
   {
      &write_warnings("gls_set_user: glossary entry '$label' has not been defined");
   }
}

sub gls_set_user{
   local($label, $idx, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{"user$idx"} = $text;
   }
   else
   {
      &write_warnings("gls_set_user: glossary entry '$label' has not been defined");
   }
}

sub gls_set_useri{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user1'} = $text;
   }
   else
   {
      &write_warnings("gls_set_useri: glossary entry '$label' has not been defined");
   }
}

sub gls_set_userii{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user2'} = $text;
   }
   else
   {
      &write_warnings("gls_set_userii: glossary entry '$label' has not been defined");
   }
}

sub gls_set_useriii{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user3'} = $text;
   }
   else
   {
      &write_warnings("gls_set_useriii: glossary entry '$label' has not been defined");
   }
}

sub gls_set_useriv{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user4'} = $text;
   }
   else
   {
      &write_warnings("gls_set_useriv: glossary entry '$label' has not been defined");
   }
}

sub gls_set_userv{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user5'} = $text;
   }
   else
   {
      &write_warnings("gls_set_userv: glossary entry '$label' has not been defined");
   }
}

sub gls_set_uservi{
   local($label, $text) = @_;

   if (&gls_entry_defined($label))
   {
      $glsentry{$label}{'user6'} = $text;
   }
   else
   {
      &write_warnings("gls_set_uservi: glossary entry '$label' has not been defined");
   }
}

sub gls_get_user{
   local($label, $idx) = @_;
   local($value) = '';

   if (&gls_entry_defined($label))
   {
      $value = $glsentry{$label}{"user".$idx};
   }
   else
   {
      &write_warnings("gls_get_user[$idx]: glossary entry '$label' has not been defined");
   }

   $value;
}

sub gls_used{
   local($label) = @_;
   local($flag) = 0;

   if (&gls_entry_defined($label))
   {
      $flag = $glsentry{$label}{'flag'};
   }
   else
   {
      &write_warnings("gls_used: glossary entry '$label' has not been defined");
   }

   $flag;
}

sub gls_entry_defined{
   local($label) = @_;

   (%{$glsentry{$label}}) ? 1 : 0;
}

sub do_cmd_newglossaryentry{
   local($_) = @_;
   local($label,$name,$description,$symbol,$sort,$text,$first,
     $plural,$firstplural,$type,$keyval,$parent,@user);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $keyval = &missing_braces unless
              s/$next_pair_pr_rx/$keyval=$2;''/eo;

   ($name,$keyval) = &get_keyval('name', $keyval);
   ($description,$keyval) = &get_keyval('description', $keyval);
   ($symbol,$keyval) = &get_keyval('symbol', $keyval);
   ($sort,$keyval) = &get_keyval('sort', $keyval);
   ($text,$keyval) = &get_keyval('text', $keyval);
   ($first,$keyval) = &get_keyval('first', $keyval);
   ($firstplural,$keyval) = &get_keyval('firstplural', $keyval);
   ($plural,$keyval) = &get_keyval('plural', $keyval);
   ($type,$keyval) = &get_keyval('type', $keyval);
   ($parent,$keyval) = &get_keyval('parent', $keyval);

   if ($parent and not $name)
   {
     $name = &gls_get_name($parent);
   }

   @user = ();

   for (my $idx = 0; $idx < 6; $idx++)
   {
      ($user[$idx],$keyval) = &get_keyval("user".($idx+1), $keyval);
   }

   if (defined($type))
   {
      $type = &translate_commands($type);
   }
   else
   {
      $type = 'main';
   }

   &gls_entry_init($label, $type, $name, $description);

   &gls_set_symbol($label, defined($symbol)?$symbol:'');

   $sort = "$name $description" unless (defined($sort) and $sort);

   &gls_set_sort($label, $sort);

   $text = $name unless (defined($text) and $text);

   &gls_set_text($label, $text);

   $first = $text unless (defined($first) and $first);

   &gls_set_first($label, $first);

   $plural = "${text}s" unless (defined($plural) and $plural);

   &gls_set_plural($label, $plural);

   $firstplural = "${first}s" unless (defined($firstplural) and $firstplural);

   &gls_set_firstplural($label, $firstplural);

   &gls_set_userkeys($label, @user);

   &gls_set_parent($label, $parent);

   push @{$gls_entries{$type}}, $label;

   $_;
}

sub reset_entry{
   local($label) = @_;

   $glsentry{$label}{'flag'} = 0;
}

sub unset_entry{
   local($label) = @_;

   $glsentry{$label}{'flag'} = 1;
}

sub do_cmd_glsreset{
   local($_) = @_;
   local($label);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   &reset_entry($label);

   $_;
}

sub do_cmd_glsunset{
   local($_) = @_;
   local($label);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   &unset_entry($label);

   $_;
}

sub do_cmd_ifglsused{
   local($_) = @_;
   local($label,$true,$false);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $true = &missing_braces unless
              s/$next_pair_pr_rx/$true=$2;''/eo;

   $false = &missing_braces unless
              s/$next_pair_pr_rx/$false=$2;''/eo;

   (&gls_used($label) ? $true : $false) . $_;
}

sub do_cmd_ifglsentryexists{
   local($_) = @_;
   local($label,$true,$false);

   $label = &missing_braces unless
              s/$next_pair_pr_rx/$label=$2;''/eo;

   $true = &missing_braces unless
              s/$next_pair_pr_rx/$true=$2;''/eo;

   $false = &missing_braces unless
              s/$next_pair_pr_rx/$false=$2;''/eo;

   (&gls_entry_defined($label) ? $true : $false) . $_;
}

sub gls_add_entry{
   local($type, $label, $format, $text) = @_;

   local($oldfmt) = $GLSCURRENTFORMAT;

   if (defined($format))
   {
      $format=~s/[\(\)]//;

      if ($format)
      {
         $GLSCURRENTFORMAT=$format;
      }
   }

   $id = ++$global{'max_id'};

   local($str) = &make_real_glossary_entry($label,$text,$type);
   $GLSCURRENTFORMAT = $oldfmt;

   $str;
}

sub do_cmd_glsadd{
   local($_) = @_;
   local($optarg,$pat,$label,$str,$id,$type,$format);
   ($optarg,$pat) = &get_next_optional_argument;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $type = &gls_get_type($label);

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      &unset_entry($label);
   }

   if (defined $type)
   {
      ($format,$optarg) = &get_keyval('format', $optarg);
      $format='' unless(defined($format));

      if ($dobacklink)
      {
         &gls_add_entry($type,$label,$format,"");
      }
      else
      {
         $glsentry{$label}{'maxid'} = ++$glsentry{$entry}{'maxid'};
         my $key = $label."###".$glsentry{$label}{'maxid'};
         $glossary{$type}{$key}='';
      }
   }
   else
   {
      &write_warnings("gls_add: glossary entry '$label' undefined");
      $str = '';
   }

   $str . $_;
}

sub do_cmd_glsaddall{
   local($_) = @_;
   local($optarg,$pat) = &get_next_optional_argument;

   local($format,$list);

   ($list,$optarg) = &get_keyval('types', $optarg);
   ($format,$optarg) = &get_keyval('format', $optarg);

   $format='' unless(defined($format));

   local(@types) = keys(%gls_mark);

   if ($list)
   {
      @types = split /\s*,\s*/, $list;
   }

   foreach $type (@types)
   {
      # strip leading and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         local($dobacklink) = 1;

         if (&gls_used($label))
         {
            if ($INDEXONLYFIRST)
            {
              $dobacklink = 0;
            }
         }
         else
         {
            &unset_entry($label);
         }

         if ($dobacklink)
         {
            &gls_add_entry($type,$label,$format,"");
         }
      }
   }

   $_;
}

sub do_cmd_glsresetall{
   local($_) = @_;
   local($types,$pat) = &get_next_optional_argument;

   local(@types) = keys(%gls_mark);

   if (defined($types) and $types)
   {
      @types = split /,/, $types;
   }

   foreach $type (@types)
   {
      # strip leasing and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         &reset_entry($label);
      }
   }

   $_;
}

sub do_cmd_glsunsetall{
   local($_) = @_;
   local($types,$pat) = &get_next_optional_argument;

   local(@types) = keys(%gls_mark);

   if (defined($types) and $types)
   {
      @types = split /,/, $types;
   }

   foreach $type (@types)
   {
      # strip leasing and trailing spaces
      $type=~s/^\s*([^\s]+)\s*$/\1/;

      foreach $label (@{$gls_entries{$type}})
      {
         &reset_entry($label);
      }
   }

   $_;
}

$glslabel = '';

sub do_cmd_glslabel{ $glslabel.$_[0] }

sub make_glslink{
   local($type,$label,$format,$text) = @_;
   local($str) = '';

   $glslabel = $label;

   if (defined $type)
   {
      $str = &gls_add_entry($type,$label,$format,$text);
   }
   else
   {
      &write_warnings("glossary '$type' undefined");
   }

   $str;
}

sub do_cmd_glslink{
   local($_) = @_;
   local($optarg,$pat,$label,$text,$type,$format,$str);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $text = &missing_braces unless
             (s/$next_pair_pr_rx/$text=$2;''/eo);

   # v1.01 removed following lines (\glslink doesn't have
   # a final optional argument!
   #local ($space) = '';
   #if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}
   #($optarg,$pat) = &get_next_optional_argument;

   $type = &gls_get_type($label);

   #&make_glslink($type, $label, $format, $text).$space . $_;
   &make_glslink($type, $label, $format, $text) . $_;
}

sub do_cmd_glslinkstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text,$type,$format,$str);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $text = &missing_braces unless
             (s/$next_pair_pr_rx/$text=$2;''/eo);

   $type = &gls_get_type($label);

   $text . $_;
}

sub do_cmd_glsdisp{
   local($_) = @_;
   local($optarg,$pat,$label,$text,$type,$format,$str);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   $text = &missing_braces unless
             (s/$next_pair_pr_rx/$text=$2;''/eo);

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      &unset_entry($label);
   }

   $type = &gls_get_type($label);

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $text, $type). $space . $_;
   }
}

sub do_cmd_glshyperlink{
   local($_) = @_;

   local($text,$pat) = &get_next_optional_argument;

   local($id, $label);

   $label = &missing_braces unless
      s/$next_pair_pr_rx/$id=$1,$label=$2;''/eo;

   $text = &gls_get_text($label) unless $text;

   local($type) = &gls_get_type($label);

   "<A HREF=\"$gls_file_mark{$type}#gls:$label\">$text<\/A>"
   .$_;
}

sub do_cmd_glsentrydesc{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_description($label).$_;
}

sub do_cmd_Glsentrydesc{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_description($label)).$_;
}

sub do_cmd_glsentrytext{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_text($label).$_;
}

sub do_cmd_Glsentrytext{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_text($label)).$_;
}

sub do_cmd_glsentryname{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_name($label).$_;
}

sub do_cmd_Glsentryname{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_name($label)).$_;
}

sub do_cmd_glsentryfirst{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_first($label).$_;
}

sub do_cmd_Glsentryfirst{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_first($label)).$_;
}

sub do_cmd_glsentryplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_plural($label).$_;
}

sub do_cmd_Glsentryplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_plural($label)).$_;
}

sub do_cmd_glsentryfirstplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local($text)=$glsentry{$label}{'firstplural'};

   unless (defined($text))
   {
      &write_warnings("glossary entry '$label' has not been defined");
      $text = '';
   }

   "$text$_";
   &gls_get_firstplural($label).$_;
}

sub do_cmd_Glsentryfirstplural{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_firstplural($label)).$_;
}

sub do_cmd_glsentrysymbol{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_symbol($label).$_;
}

sub do_cmd_Glsentrysymbol{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &do_real_makefirstuc(&gls_get_symbol($label)).$_;
}

sub do_cmd_glsentryuseri{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 1).$_;
}

sub do_cmd_glsentryuserii{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 2).$_;
}

sub do_cmd_glsentryuseriii{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 3).$_;
}

sub do_cmd_glsentryuseriv{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 4).$_;
}

sub do_cmd_glsentryuserv{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 5).$_;
}

sub do_cmd_glsentryuservi{
   local($_) = @_;

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   &gls_get_user($label, 6).$_;
}

sub do_cmd_gls{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_glsstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   $link_text . $space . $_;
}

sub do_cmd_glspl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_glsplstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   $link_text . $space . $_;
}

sub do_cmd_Gls{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args"));

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_Glsstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &do_real_makefirstuc($link_text). $space . $_;
}

sub do_cmd_Glspl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &do_real_makefirstuc(&translate_commands("$display$args"));

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_Glsplstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   &do_real_makefirstuc($link_text).$space . $_;
}

sub do_cmd_GLS{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = uc(&translate_commands("$display$args"));

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_GLSstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_text($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_first($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   uc($link_text).$space . $_;
}

sub do_cmd_GLSpl{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   local($dobacklink) = 1;

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;

      if ($INDEXONLYFIRST)
      {
        $dobacklink = 0;
      }
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = uc(&translate_commands("$display$args"));

   if ($dobacklink)
   {
      &make_glslink($type, $label, $format, $link_text) .$space . $_;
   }
   else
   {
      &make_real_glossary_entry_no_backlink($label, $link_text, $type). $space . $_;
   }
}

# added v1.04
sub do_cmd_GLSplstar{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = $glsentry{$label}{'type'};

   if (&gls_used($label))
   {
      # entry has already been used

      $text = &gls_get_plural($label);
      $display = &gls_get_display($type);;
   }
   else
   {
      # entry hasn't been used

      $text = &gls_get_firstplural($label);
      $display = &gls_get_displayfirst($type);

      &unset_entry($label);
   }

   local($args) = '';

   local($id) = ++$global{'max_id'};
   $args .= "$OP$id$CP$text$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{description}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$glsentry{$label}{symbol}$OP$id$CP";

   $id = ++$global{'max_id'};
   $args .= "$OP$id$CP$insert$OP$id$CP";

   local($link_text) = &translate_commands("$display$args");

   uc($link_text).$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glstext{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_text($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glstext{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_text($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLStext{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_text($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glsname{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_name($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glsname{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_name($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSname{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_name($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glsfirst{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_first($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glsfirst{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_first($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSfirst{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_first($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glsfirstplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_firstplural($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glsfirstplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_firstplural($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSfirstplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_firstplural($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glsplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_plural($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glsplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_plural($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSplural{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_plural($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glsdesc{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_description($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glsdesc{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_description($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSdesc{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_description($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_glssymbol{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_symbol($label);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_Glssymbol{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_symbol($label);

   &make_glslink($type, $label, $format, &do_real_makefirstuc($text)) .$space . $_;
}

# added 22 Feb 2008
sub do_cmd_GLSsymbol{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_symbol($label);

   &make_glslink($type, $label, $format, uc($text)) .$space . $_;
}

sub do_cmd_glsuseri{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 1);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuseri{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 1));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_glsuserii{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 2);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuserii{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 2));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_glsuseriii{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 3);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuseriii{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 3));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_glsuseriv{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 4);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuseriv{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 4));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_glsuserv{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 5);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuserv{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 5));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_glsuservi{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &gls_get_user($label, 6);

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_Glsuservi{
   local($_) = @_;
   local($optarg,$pat,$label,$text, $format, $insert);

   ($optarg,$pat) = &get_next_optional_argument;

   ($format,$optarg) = &get_keyval('format', $optarg);

   $label = &missing_braces unless
             (s/$next_pair_pr_rx/$label=$2;''/eo);

   local ($space) = '';
   if (/^\s+[^\[]/ or /^\s*\[.*\]\s/) {$space = ' ';}

   $insert = '';
   ($insert,$pat) = &get_next_optional_argument;

   local($display) = '';

   local($type) = &gls_get_type($label);

   $text = &do_real_makefirstuc(&gls_get_user($label, 6));

   &make_glslink($type, $label, $format, $text) .$space . $_;
}

sub do_cmd_acrshort{
  &do_cmd_glstext(@_)
}

sub do_cmd_Acrshort{
  &do_cmd_Glstext(@_)
}

sub do_cmd_ACRshort{
  &do_cmd_GLStext(@_)
}

sub do_cmd_acrlong{
  &do_cmd_glsdesc(@_)
}

sub do_cmd_Acrlong{
  &do_cmd_Glsdesc(@_)
}

sub do_cmd_ACRlong{
  &do_cmd_GLSdesc(@_)
}

sub do_cmd_acrfull{
  &do_cmd_glsfirst(@_)
}

sub do_cmd_Acrfull{
  &do_cmd_Glsfirst(@_)
}

sub do_cmd_ACRfull{
  &do_cmd_GLSfirst(@_)
}

sub do_cmd_glossarypreamble{
   local($_) = @_;
   $_[0];
}

sub do_cmd_glossarypostamble{
   local($_) = @_;
   $_[0];
}

sub do_cmd_glsnumformat{
   local($_) = @_;

   $_;
}

sub do_cmd_hyperit{
   join('', "\\textit ", $_[0]);
}

sub do_cmd_hyperrm{
   join('', "\\textrm ", $_[0]);
}

sub do_cmd_hypertt{
   join('', "\\texttt ", $_[0]);
}

sub do_cmd_hypersf{
   join('', "\\textsf ", $_[0]);
}

sub do_cmd_hyperbf{
   join('', "\\textbf ", $_[0]);
}

&ignore_commands( <<_IGNORED_CMDS_ );
makeglossary
makeglossaries
glossaryentrynumbers # {}
_IGNORED_CMDS_

1;
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</glossaries.perl>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*mfirstuc.perl>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
# File        : mfirstuc.perl
# Author      : Nicola L. C. Talbot
# Date        : 2012-09-21
# Version     : 1.0
# Description : LaTeX2HTML (limited!) implementation of mfirstuc package

# This is a LaTeX2HTML style implementing the mfirstuc package, and
# is distributed as part of the glossaries package.
# Copyright 2007 Nicola L.C. Talbot
# This work may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either version 1.3
# of this license of (at your option) any later version.
# The latest version of this license is in
#   http://www.latex-project.org/lppl.txt
# and version 1.3 or later is part of all distributions of LaTeX
# version 2005/12/01 or later.
#
# This work has the LPPL maintenance status `maintained'.
#
# The Current Maintainer of this work is Nicola Talbot.

use warnings;

package main;

sub do_cmd_makefirstuc{
   local($_) = @_;

   local($id,$text);

   $text = &missing_braces unless
      s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo;

   &translate_commands("\\glsmakefirstuc $text") . $_;
}

sub do_cmd_xmakefirstuc{
   local($_) = @_;

   local($id,$text);
  
   $text = &missing_braces unless
      s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo;

   unless ($id)
   {
      $id = ++$global{'max_id'};
   }
   
   &translate_commands("\\expandafter \\makefirstuc $OP$id$CP$text$OP$id$CP")
   . $_;
}

sub do_cmd_glsmakefirstuc{
   local($_) = @_;

   local($id,$text);

   $text = &get_next_object unless
      s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo;

   &do_real_makefirstuc($text).$_;
}

sub do_real_makefirstuc{
   local($text) = @_;

   if ($text=~/^((?:\s*<[^>]+>\s*)+)(.*)/)
   {
      $text = $1 . ucfirst($2);
   }
   else
   {
      $text = ucfirst($text);
   }

   $text;
}

sub do_cmd_capitalisewords{
   local($_) = @_;

   local($id,$text);

   $text = &missing_braces unless
      s/$next_pair_pr_rx/$id=$1;$text=$2;''/eo;

   local($newtext) = '';

   foreach my $word (split ' ', $text)
   {
      $id = ++$global{'max_id'};

      $word = &translate_commands("\\makefirstuc $OP$id$CP$word$OP$id$CP");

      if ($newtext)
      {
         $newtext .= ' ' . $word;
      }
      else
      {
         $newtext = $word;
      }
   }

   $newtext.$_;
}

sub get_next_object{
    local($next, $revert, $thisline);
    local($this_cmd) = $cmd;
    $this_cmd =~ s/^\\// unless ($cmd eq "\\");
    if (/^[\s%]*([^\n]*)\n/ ) {
        $thisline = &revert_to_raw_tex($1)
    } else {
        $thisline = &revert_to_raw_tex($_);
    }
    s/^\s*//;
    if ($_ =~ s/$next_token_rx//) { $next = $& };
    $next =~ s/$comment_mark(\d+\n?)?//g;
    if ($next =~ /^\\(\W|\d|[a-zA-z]*\b)/) {
        $revert = $next = "\\".$1;
    } elsif ($next =~ /\W/) {
        $revert = &revert_to_raw_tex($next);
    } else { $revert = $next };
    $next;
}

1;
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</mfirstuc.perl>
%    \end{macrocode}
%\fi
%\Finale
\endinput
