%\iffalse
% glossaries.dtx generated using makedtx version 1.1 (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 "glossaries-prefix.sty\Z=>glossaries-prefix.sty"
%   -src "mfirstuc.sty\Z=>mfirstuc.sty"
%   -src "mfirstuc-english.sty\Z=>mfirstuc-english.sty"
%   -src "(glossary-.+)\.(sty)\Z=>\1.\2"
%   -src "(glossaries-compatible-.+)\.(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 "(glossary-lipsum-examples\.tex)\Z=>\1"
%   -src "(example-glossaries-.*\.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 2014/9/1 21:18
%\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) 2014 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

\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}

\RecordChanges

\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}
\doxitem{AcrStyle}{acrstyle}{acronym styles}

\setcounter{IndexColumns}{2}

\CheckSum{18645}

\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 v4.11}
% \author{Nicola L.C. Talbot\\[10pt]
%Dickimaw Books\\
%\url{http://www.dickimaw-books.com/}}
%
% \date{2014-09-01}
% \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 v4.11:
%\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-code.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}
%
%The user level commands described in the user manual
%(glossaries-user.pdf) may be considered ``future-proof''. Even if
%they become deprecated, they should still work for
%old documents (although they may not work in a document that also
%contains new commands introduced since the old commands were
%deprecated, and you may need to specify a compatibility mode).
%
%The internal commands in \emph{this} document that aren't documented in the
%\emph{user manual} should not be considered future-proof and are liable to
%change. If you want a new user level command, you can post a feature
%request at \url{http://www.dickimaw-books.com/feature-request.html}.
%If you are a package writer wanting to integrate your package with
%\styfmt{glossaries}, it's better to request a new user level command
%than to hack these internals.
%
%\clearpage
%\tableofcontents
%
%\StopEventually{%
%  \printglossaries
%  \phantomsection
%  \addcontentsline{toc}{section}{Change History}%
%  \raggedright
%  \PrintChanges
%  \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}[2014/09/01 v4.11 (NLCT)]
%    \end{macrocode}
% Required packages:
%    \begin{macrocode}
\RequirePackage{ifthen}
\RequirePackage{xkeyval}[2006/11/18]
\RequirePackage{mfirstuc}
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{Now requires textcase}
% The \sty{textcase} package has much better case changing handling,
% so use \cs{MakeTextUppercase} instead of \cs{MakeUppercase}
%    \begin{macrocode}
\RequirePackage{textcase}
\renewcommand*{\mfirstucMakeUppercase}{\MakeTextUppercase}%
%    \end{macrocode}
%    \begin{macrocode}
\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
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
\@ifpackageloaded{doc}%
{%
  \@gls@docloadedtrue
}%
{%
  \@ifclassloaded{nlctdoc}{\@gls@docloadedtrue}{\@gls@docloadedfalse}%
}
\if@gls@docloaded
%    \end{macrocode}
% \cs{doc} has been loaded, so some modifications need to be made to
% ensure both packages can work together. The amount of conflict has
% been reduced as from v4.11 and no longer involves patching
% internal commands.
%
%\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}
%\changes{4.02}{2013-12-05}{added nameref option}
%    \begin{macrocode}
\define@choicekey{glossaries.sty}{numberedsection}[\val\nr]{%
false,nolabel,autolabel,nameref}[nolabel]{%
  \ifcase\nr\relax
    \renewcommand*{\@@glossarysecstar}{*}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{%
      \label{\glsautoprefix\@glo@type}}%
  \or
    \renewcommand*{\@@glossarysecstar}{*}%
    \renewcommand*{\@@glossaryseclabel}{%
      \protected@edef\@currentlabelname{\glossarytoctitle}%
      \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 \cs{DeclareOptionX} needs a corresponding \cs{DeclareOption}
% so that it can be passed as a document class option, so define a
% command that will implement both.
%\changes{4.01}{2013-11-16}{fixed non-value options so that they can be passed to
%document class}
%\begin{macro}{\@gls@declareoption}
%    \begin{macrocode}
\newcommand*{\@gls@declareoption}[2]{%
  \DeclareOptionX{#1}{#2}%
  \DeclareOption{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
% 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}
\@gls@declareoption{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}
\@gls@declareoption{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}
\@gls@declareoption{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}
\@gls@declareoption{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}
\@gls@declareoption{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}
\@gls@declareoption{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}
\@gls@declareoption{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.
%\changes{3.07}{2013-07-05}{Added spacefactor code}
% The spacefactor is adjusted in case the description ends with an
% upper case letter. (Patch provided by Michael Pock.)
%    \begin{macrocode}
\newcommand*{\glspostdescription}{%
  \ifglsnopostdot\else.\spacefactor\sfcode`\. \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
% use upper case in definition of \ics{glsglossarymark}
%\changes{3.02}{2012/05/21}{new}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{ucmark}[true]{}
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{added check for memoir}
%    \begin{macrocode}
\@ifclassloaded{memoir}
{%
  \glsucmarktrue
}%
{%
  \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{macro}{\@glo@default@sorttype}
% Initialise default sort for \cs{printnoidxglossary}
%    \begin{macrocode}
\newcommand*{\@glo@default@sorttype}{standard}
%    \end{macrocode}
%\end{macro}
%
%\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}{%
  \renewcommand*{\@glo@default@sorttype}{#1}%
  \csname @gls@setupsort@#1\endcsname
}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\glsprestandardsort}
%\changes{3.13a}{2013-11-05}{new}
%\begin{definition}
%\cs{glsprestandardsort}\marg{sort cs}\marg{type}\marg{label}
%\end{definition}
% Allow user to hook into sort mechanism. The first argument
% \meta{sort cs} is the temporary control sequence containing the
% sort value before it has been sanitized and had
% \gls{makeindex}\slash\gls{xindy} special characters escaped.
%    \begin{macrocode}
\newcommand*{\glsprestandardsort}[3]{%
  \glsdosanitizesort
}
%    \end{macrocode}
%\end{macro}
%\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}).
% (First argument glossary type, second argument entry label.)
%    \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}}
%\changes{3.13a}{2013-11-05}{moved \cs{@gls@santizesort} to
%\cs{glsprestandardsort}}
%    \begin{macrocode}
    \let\glsdosanitizesort\@gls@sanitizesort
    \glsprestandardsort{\@glo@sort}{##1}{##2}%
    \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}
% Define hook to set the toc title when \sty{translator} is in use.
%\changes{4.06}{2014-03-12}{added hook to set toc title}
%    \begin{macrocode}
  \newcommand*{\gls@tr@set@main@toctitle}{%
    \translatelet{\glossarytoctitle}{Glossary}%
  }%
}
%    \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}
%
%\begin{option}{nomain}
%\changes{2.01}{2009 May 30}{added nomain package option}
% The \pkgopt{nomain} option suppress the creation of the main 
% glossary.
%    \begin{macrocode}
\@gls@declareoption{nomain}{%
   \let\glsdefaulttype\relax
   \renewcommand*{\glsdefmain}{}%
}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{acronym}
% The \pkgopt{acronym} option sets an associated conditional 
% which is used in \autoref{sec:code:acronym} to determine whether
% or not to define a separate glossary for acronyms.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{acronym}[true]{%
  \ifglsacronym
    \renewcommand{\@gls@do@acronymsdef}{%
      \DeclareAcronymList{acronym}%
      \newglossary[alg]{acronym}{acr}{acn}{\acronymname}%
      \renewcommand*{\acronymtype}{acronym}%
%    \end{macrocode}
% Define hook to set the toc title when \sty{translator} is in use.
%\changes{4.06}{2014-03-12}{added hook to set toc title}
%    \begin{macrocode}
      \newcommand*{\gls@tr@set@acronym@toctitle}{%
        \translatelet{\glossarytoctitle}{Acronyms}%
      }%
    }%
  \else
    \let\@gls@do@acronymsdef\relax
  \fi
}
%    \end{macrocode}
%\end{option}
%\begin{macro}{\printacronyms}
% Define \cs{printacronyms} at the start of the document if
% \pkgopt{acronym} is set and compatibility mode isn't on and
% \cs{printacronyms} hasn't already been defined.
%    \begin{macrocode}
\AtBeginDocument{%
  \ifglsacronym
    \ifbool{glscompatible-3.07}%
    {}%
    {%
      \providecommand*{\printacronyms}[1][]{%
        \printglossary[type=\acronymtype,#1]}%
    }%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@do@acronymsdef}
% Set default value
%    \begin{macrocode}
\newcommand*{\@gls@do@acronymsdef}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{acronyms}
%\changes{3.14a}{2013-11-12}{new}
% Provide a synonym for \pkgopt[true]{acronym} that can be passed
% via the document class options.
%    \begin{macrocode}
\@gls@declareoption{acronyms}{%
  \glsacronymtrue
  \renewcommand{\@gls@do@acronymsdef}{%
     \DeclareAcronymList{acronym}%
     \newglossary[alg]{acronym}{acr}{acn}{\acronymname}%
     \renewcommand*{\acronymtype}{acronym}%
%    \end{macrocode}
% Define hook to set the toc title when \sty{translator} is in use.
%\changes{4.06}{2014-03-12}{added hook to set toc title}
%    \begin{macrocode}
      \newcommand*{\gls@tr@set@acronym@toctitle}{%
        \translatelet{\glossarytoctitle}{Acronyms}%
      }%
   }%
}
%    \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}
%\begin{definition}
%\cs{glsIfListOfAcronyms}\marg{label}\marg{true part}\marg{false part}
%\end{definition}
% 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}%
%\changes{3.11a}{2013-10-15}{replaced \cs{@addtoacronymlists} with
%\cs{DeclareAcronymList}}
%    \begin{macrocode}
\define@key{glossaries.sty}{acronymlists}{%
  \DeclareAcronymList{#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}
%
%\begin{macro}{\@gls@nohyperlist}
%\changes{3.05}{2013/04/21}{new}
%    \begin{macrocode}
\newcommand*{\@gls@nohyperlist}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsDeclareNoHyperList}
%\changes{3.05}{2013/04/21}{new}
%    \begin{macrocode}
\newcommand*{\GlsDeclareNoHyperList}[1]{%
  \ifdefempty\@gls@nohyperlist
  {%
     \renewcommand*{\@gls@nohyperlist}{#1}%
  }%
  {%
     \appto\@gls@nohyperlist{,#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{nohypertypes}
%\changes{3.05}{2013/04/21}{new}
%    \begin{macrocode}
\define@key{glossaries.sty}{nohypertypes}{%
  \GlsDeclareNoHyperList{#1}%
}
%    \end{macrocode}
%\end{option}
%
%\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}
%
%\begin{option}{nowarn}
% Define package option to suppress warnings
%    \begin{macrocode}
\@gls@declareoption{nowarn}{%
  \renewcommand*{\GlossariesWarning}[1]{}%
  \renewcommand*{\GlossariesWarningNoLine}[1]{}%
}
%    \end{macrocode}
%\end{option}
%
%
%\begin{macro}{\@gls@warnonglossdefined}
%\changes{4.04}{2014-03-06}{new}
% Issue a warning if overriding \cs{printglossary}
%    \begin{macrocode}
\newcommand*{\@gls@warnonglossdefined}{%
  \GlossariesWarning{Overriding \string\printglossary}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@warnontheglossdefined}
%\changes{4.04}{2014-03-06}{new}
% Issue a warning if overriding \env{theglossary}
%    \begin{macrocode}
\newcommand*{\@gls@warnontheglossdefined}{%
  \GlossariesWarning{Overriding `theglossary' environment}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{noredefwarn}
% Suppress warning on redefinition of \cs{printglossary}
%    \begin{macrocode}
\@gls@declareoption{noredefwarn}{%
  \renewcommand*{\@gls@warnonglossdefined}{}%
  \renewcommand*{\@gls@warnontheglossdefined}{}%
}
%    \end{macrocode}
%\end{option}
%
% As from version 3.08a, the only information written to the external
% glossary files are the label and sort values. Therefore, now, the
% only sanitize option that makes sense is the one for the sort key.
% so the sanitize option is now deprecated and there is only a
% sanitizesort option.
%
%\begin{macro}{\@gls@sanitizedesc}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizedesc}{%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssetexpandfield}
%\changes{3.13a}{2013-11-05}{new}
%\begin{definition}
%\cs{glssetexpandfield}\marg{field}
%\end{definition}
% Sets field to always expand.
%    \begin{macrocode}
\newcommand*{\glssetexpandfield}[1]{%
  \csdef{gls@assign@#1@field}##1##2{%
    \@@gls@expand@field{##1}{#1}{##2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssetnoexpandfield}
%\changes{3.13a}{2013-11-05}{new}
%\begin{definition}
%\cs{glssetnoexpandfield}\marg{field}
%\end{definition}
% Sets field to never expand.
%    \begin{macrocode}
\newcommand*{\glssetnoexpandfield}[1]{%
  \csdef{gls@assign@#1@field}##1##2{%
    \@@gls@noexpand@field{##1}{#1}{##2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@assign@type@field}
%\changes{3.10a}{2013-09-28}{new}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetexpandfield}}
% The type must always be expandable.
%    \begin{macrocode}
\glssetexpandfield{type}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@assign@desc@field}
%\changes{3.08a}{2013-09-28}{new}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetnoexpandfield}}
% The description is not expanded by default:
%    \begin{macrocode}
\glssetnoexpandfield{desc}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@assign@descplural@field}
%\changes{3.08a}{2013-09-28}{new}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetnoexpandfield}}
%    \begin{macrocode}
\glssetnoexpandfield{descplural}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizename}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizename}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@assign@name@field}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetnoexpandfield}}
% Don't expand name by default.
%    \begin{macrocode}
\glssetnoexpandfield{name}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@sanitizesymbol}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizesymbol}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@assign@symbol@field}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetnoexpandfield}}
% Don't expand symbol by default.
%    \begin{macrocode}
\glssetnoexpandfield{symbol}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@assign@symbolplural@field}
%\changes{3.13a}{2013-11-05}{changed to use \cs{glssetnoexpandfield}}
%\changes{3.09a}{2013-10-09}{new}
%    \begin{macrocode}
\glssetnoexpandfield{symbolplural}
%    \end{macrocode}
%\end{macro}
%
% Sanitizing stuff:
%\begin{macro}{\@gls@sanitizesort}
%\changes{3.03}{2012/09/21}{new}
%    \begin{macrocode}
\newcommand*{\@gls@sanitizesort}{%
  \ifglssanitizesort
    \@@gls@sanitizesort
  \else
    \@@gls@nosanitizesort
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@gls@sanitizesort}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*\@@gls@sanitizesort{%
  \@onelevel@sanitize\@glo@sort
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@gls@nosanitizesort}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@@gls@nosanitizesort}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@gls@noidx@sanitizesort}
%\changes{4.04}{2014-03-06}{new}
% Remove braces around first character (if present) before
% sanitizing.
%    \begin{macrocode}
\newcommand*\@gls@noidx@sanitizesort{%
  \ifdefvoid\@glo@sort
  {}%
  {%
    \expandafter\@@gls@noidx@sanitizesort\@glo@sort\gls@end@sanitizesort
  }%
}
\def\@@gls@noidx@sanitizesort#1#2\gls@end@sanitizesort{%
  \def\@glo@sort{#1#2}%
  \@onelevel@sanitize\@glo@sort
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@gls@noidx@nosanitizesort}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@@gls@noidx@nosanitizesort}{%
  \ifdefvoid\@glo@sort
  {}%
  {%
    \expandafter\@@gls@noidx@no@sanitizesort\@glo@sort\gls@end@sanitizesort
  }%
}
\def\@@gls@noidx@no@sanitizesort#1#2\gls@end@sanitizesort{%
  \bgroup
    \glsnoidxstripaccents
    \protected@xdef\@@glo@sort{#1#2}%
  \egroup
  \let\@glo@sort\@@glo@sort
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnoidxstripaccents}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*\glsnoidxstripaccents{%
  \let\IeC\@firstofone
  \let\'\@firstofone
  \let\`\@firstofone
  \let\^\@firstofone
  \let\"\@firstofone
  \let\u\@firstofone
  \let\t\@firstofone
  \let\d\@firstofone
  \let\r\@firstofone
  \let\=\@firstofone
  \let\.\@firstofone
  \let\~\@firstofone
  \let\v\@firstofone
  \let\H\@firstofone
  \let\c\@firstofone
  \let\b\@firstofone
  \def\AE{AE}%
  \def\ae{ae}%
  \def\OE{OE}%
  \def\oe{oe}%
  \def\AA{AA}%
  \def\aa{aa}%
  \def\L{L}%
  \def\l{l}%
  \def\O{O}%
  \def\o{o}%
  \def\SS{SS}%
  \def\ss{ss}%
  \def\th{th}%
}
%    \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}.
%
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{description}[true]{%
  \GlossariesWarning{sanitize={description} package option deprecated}%
  \ifgls@sanitize@description
    \glssetnoexpandfield{desc}%
    \glssetnoexpandfield{descplural}%
  \else
    \glssetexpandfield{desc}%
    \glssetexpandfield{descplural}%
  \fi
}
%    \end{macrocode}
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{name}[true]{%
  \GlossariesWarning{sanitize={name} package option deprecated}%
  \ifgls@sanitize@name
    \glssetnoexpandfield{name}%
  \else
    \glssetexpandfield{name}%
  \fi
}
%    \end{macrocode}
%    \begin{macrocode}
\define@boolkey[gls]{sanitize}{symbol}[true]{%
  \GlossariesWarning{sanitize={symbol} package option deprecated}%
  \ifgls@sanitize@symbol
    \glssetnoexpandfield{symbol}%
    \glssetnoexpandfield{symbolplural}%
  \else
    \glssetexpandfield{symbol}%
    \glssetexpandfield{symbolplural}%
  \fi
}
%    \end{macrocode}
%
%\begin{option}{sanitizesort}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{sanitizesort}[true]{%
  \ifglssanitizesort
    \glssetnoexpandfield{sortvalue}%
    \renewcommand*{\@gls@noidx@setsanitizesort}{%
      \glssanitizesorttrue
      \glssetnoexpandfield{sortvalue}%
    }%
  \else
    \glssetexpandfield{sortvalue}%
    \renewcommand*{\@gls@noidx@setsanitizesort}{%
      \glssanitizesortfalse
      \glssetexpandfield{sortvalue}%
    }%
  \fi
}
%    \end{macrocode}
% Default setting:
%    \begin{macrocode}
\glssanitizesorttrue
\glssetnoexpandfield{sortvalue}%
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@noidx@setsanitizesort}
% Default behaviour for \ics{makenoidxglossaries} is
% sanitizesort=false.
%    \begin{macrocode}
\newcommand*{\@gls@noidx@setsanitizesort}{%
  \glssanitizesortfalse
  \glssetexpandfield{sortvalue}%
}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\define@choicekey[gls]{sanitize}{sort}{true,false}[true]{%
  \setbool{glssanitizesort}{#1}%
  \ifglssanitizesort
    \glssetnoexpandfield{sortvalue}%
  \else
    \glssetexpandfield{sortvalue}%
  \fi
  \GlossariesWarning{sanitize={sort} package option
    deprecated. Use sanitizesort instead}%
}
%    \end{macrocode}
%
%\begin{option}{sanitize}
% \changes{4.02}{2013-12-05}{fixed bug that caused an error here}
% \changes{4.11}{2014-09-01}{fixed backward compatibility support of
% deprecated sanitize=none option}
%    \begin{macrocode}
\define@key{glossaries.sty}{sanitize}[description=true,symbol=true,name=true]{%
  \ifthenelse{\equal{#1}{none}}%
  {%
    \GlossariesWarning{sanitize package option deprecated}%
    \glssetexpandfield{name}%
    \glssetexpandfield{symbol}%
    \glssetexpandfield{symbolplural}%
    \glssetexpandfield{desc}%
    \glssetexpandfield{descplural}%
  }%
  {%
    \setkeys[gls]{sanitize}{#1}%
  }%
}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\ifglstranslate}
% As from version 3.13a, the \pkgopt{translator} package option is a
% choice rather than boolean option so now need to define
% conditional:
%    \begin{macrocode}
\newif\ifglstranslate
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@notranslatorhook}
%\changes{3.13a}{2013-11-05}{new}
%    \begin{macrocode}
\newcommand*\@gls@notranslatorhook{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{notranslate}
%\changes{3.14a}{2013-11-12}{new}
% Provide a synonym for \pkgopt[false]{translate} that can be passed
% via the document class.
%    \begin{macrocode}
\@gls@declareoption{notranslate}{%
   \glstranslatefalse
   \let\@gls@notranslatorhook\relax
}
%    \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@choicekey{glossaries.sty}{translate}[\val\nr]%
  {true,false,babel}[true]%
  {%
    \ifcase\nr\relax
      \glstranslatetrue
    \or
      \glstranslatefalse
      \let\@gls@notranslatorhook\relax
    \or
      \glstranslatefalse
      \def\@gls@notranslatorhook{\RequirePackage{glossaries-babel}}%
    \fi
  }
%    \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{macro}{\@gls@setacrstyle}
% Keep track of whether an acronym style has been set (for the
% benefit of \cs{setupglossaries}):
%    \begin{macrocode}
\newcommand*{\@gls@setacrstyle}{}
%    \end{macrocode}
%\end{macro}
%\begin{option}{footnote}
% Set the long form of the acronym in footnote on first use.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[glsacr]{footnote}[true]{%
  \ifbool{glsacrdescription}%
  {}%
  {%
    \renewcommand*{\@gls@sanitizedesc}{}%
  }%
  \renewcommand*{\@gls@setacrstyle}{\SetAcronymStyle}%
}
%    \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}{}%
  \renewcommand*{\@gls@setacrstyle}{\SetAcronymStyle}%
}
%    \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}{}%
  \renewcommand*{\@gls@setacrstyle}{\SetAcronymStyle}%
}
%    \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}{}%
  \renewcommand*{\@gls@setacrstyle}{\SetAcronymStyle}%
}
%    \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}{}%
  \renewcommand*{\@gls@setacrstyle}{\SetAcronymStyle}%
}
%    \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}
%
%\begin{option}{makeindex}
% Define package option to specify that \app{makeindex} will 
% be used to sort the glossaries:
%    \begin{macrocode}
\@gls@declareoption{makeindex}{\glsxindyfalse}
%    \end{macrocode}
%\end{option}
%
% 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}
%\changes{3.06}{2013/06/17}{Changed back to using \cs{languagename}}
% 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{\languagename}%
%    \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}
%
%\begin{option}{xindy}
% 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}
%\end{option}
%
%\begin{option}{xindygloss}
%\changes{3.14a}{2013-11-12}{new}
% Provide a synonym for \pkgopt[]{xindy} that can be passed via the
% document class options.
%    \begin{macrocode}
\@gls@declareoption{xindygloss}{%
  \glsxindytrue
}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{xindynoglsnumbers}
%\changes{4.02}{2013-12-05}{new}
% Provide a synonym for \texttt{xindy={glsnumbers=false}} that can
% be passed via the document class options.
%    \begin{macrocode}
\@gls@declareoption{xindynoglsnumbers}{%
  \glsxindytrue
  \gls@xindy@glsnumbersfalse
}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{automake}
%\changes{4.08}{2014-07-30}{new}
% If this setting is on, automatically run
% \gls{makeindex}\slash\gls{xindy} at the end of the document.
% Must be used with \ics{makeglossaries}.
% Default is false.
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{automake}[true]{%
  \ifglsautomake
    \renewcommand*{\@gls@doautomake}{%
      \PackageError{glossaries}{You must use
      \string\makeglossaries\space with automake=true}
      {%
         Either remove the automake=true setting or
         add \string\makeglossaries\space to your document preamble.%
      }%
    }%
  \else
    \renewcommand*{\@gls@doautomake}{}%
  \fi
}
\glsautomakefalse
%    \end{macrocode}
%\end{option}
%\begin{macro}{\@gls@doautomake}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\@gls@doautomake}{}
\AtEndDocument{\@gls@doautomake}
%    \end{macrocode}
%\end{macro}
%
%\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]{%
  \ifglssavewrites
    \renewcommand*{\glswritefiles}{\@glswritefiles}%
  \else
    \let\glswritefiles\@empty
  \fi
}
%    \end{macrocode}
%\end{option}
% Set default:
%\changes{4.03}{2014-01-17}{changed default to \cs{@empty} instead
%of \cs{relax}}
%    \begin{macrocode}
\glssavewritesfalse
\let\glswritefiles\@empty
%    \end{macrocode}
%
%\begin{option}{compatible-3.07}
%\changes{3.11a}{2013-10-15}{cnew}
%    \begin{macrocode}
\define@boolkey{glossaries.sty}[gls]{compatible-3.07}[true]{}
\boolfalse{glscompatible-3.07}
%    \end{macrocode}
%\end{option}
%
%\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]{%
%    \end{macrocode}
% Also set 3.07 compatibility if this option is set.
%\changes{3.14a}{2013-11-12}{added check for 2.07 before setting 3.07
%compatibility}
%    \begin{macrocode}
  \ifbool{glscompatible-2.07}%
  {%
    \booltrue{glscompatible-3.07}%
  }%
  {}%
}
\boolfalse{glscompatible-2.07}
%    \end{macrocode}
%\end{option}
%
%\begin{option}{symbols}
% Create a \qt{symbols} glossary type
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\@gls@declareoption{symbols}{%
  \let\@gls@do@symbolsdef\@gls@symbolsdef
}
%    \end{macrocode}
% Default is not to define the symbols glossary:
%    \begin{macrocode}
\newcommand*{\@gls@do@symbolsdef}{}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@symbolsdef}
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\newcommand*{\@gls@symbolsdef}{%
  \newglossary[slg]{symbols}{sls}{slo}{\glssymbolsgroupname}%
  \newcommand*{\printsymbols}[1][]{\printglossary[type=symbols,##1]}%
%    \end{macrocode}
% Define hook to set the toc title when \sty{translator} is in use.
%\changes{4.06}{2014-03-12}{added hook to set toc title}
%    \begin{macrocode}
  \newcommand*{\gls@tr@set@symbols@toctitle}{%
    \translatelet{\glossarytoctitle}{Symbols (glossaries)}%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{numbers}
% Create a \qt{symbols} glossary type
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\@gls@declareoption{numbers}{%
  \let\@gls@do@numbersdef\@gls@numbersdef
}
%    \end{macrocode}
% Default is not to define the numbers glossary:
%    \begin{macrocode}
\newcommand*{\@gls@do@numbersdef}{}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@numbersdef}
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\newcommand*{\@gls@numbersdef}{%
  \newglossary[nlg]{numbers}{nls}{nlo}{\glsnumbersgroupname}%
  \newcommand*{\printnumbers}[1][]{\printglossary[type=numbers,##1]}%
%    \end{macrocode}
% Define hook to set the toc title when \sty{translator} is in use.
%\changes{4.06}{2014-03-12}{added hook to set toc title}
%    \begin{macrocode}
  \newcommand*{\gls@tr@set@numbers@toctitle}{%
    \translatelet{\glossarytoctitle}{Numbers (glossaries)}%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{index}
% Create an \qt{index} glossary type
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\@gls@declareoption{index}{%
  \let\@gls@do@indexdef\@gls@indexdef
}
%    \end{macrocode}
% Default is not to define index glossary:
%    \begin{macrocode}
\newcommand*{\@gls@do@indexdef}{}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@gls@indexdef}
%\changes{4.02}{2013-12-05}{new}
%\cs{indexname} isn't set by \sty{glossaries}.
%    \begin{macrocode}
\newcommand*{\@gls@indexdef}{%
  \newglossary[ilg]{index}{ind}{idx}{\indexname}%
  \newcommand*{\printindex}[1][]{\printglossary[type=index,##1]}%
  \newcommand*{\newterm}[2][]{%
    \newglossaryentry{##2}%
    {type={index},name={##2},description={\nopostdesc},##1}}
}%
%    \end{macrocode}
%\end{macro}
%
% Process package options. First process any options that have been
% passed via the document class.
%    \begin{macrocode}
\@for\CurrentOption :=\@declaredoptions\do{%
  \ifx\CurrentOption\@empty
  \else
    \@expandtwoargs
      \in@ {,\CurrentOption ,}{,\@classoptionslist,\@curroptions,}%
    \ifin@
      \@use@ption
      \expandafter \let\csname ds@\CurrentOption\endcsname\@empty
    \fi
  \fi
}
%    \end{macrocode}
% Now process options passed to the package:
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
% Load backward compatibility stuff:
%    \begin{macrocode}
\RequirePackage{glossaries-compatible-307}
%    \end{macrocode}
%
%\begin{macro}{\setupglossaries}
%\changes{3.11a}{2013-10-15}{new}
% Provide way to set options after package has been loaded. However,
% some options must be set before \cs{ProcessOptionsX}, so they have
% to be disabled:
%    \begin{macrocode}
\disable@keys{glossaries.sty}{compatible-2.07,%
 xindy,xindygloss,xindynoglsnumbers,makeindex,%
 acronym,translate,notranslate,nolong,nosuper,notree,nostyles,nomain}
%    \end{macrocode}
%Now define \cs{setupglossaries}:
%    \begin{macrocode}
\newcommand*{\setupglossaries}[1]{%
  \renewcommand*{\@gls@setacrstyle}{}%
  \ifglsacrshortcuts
    \def\@gls@setupshortcuts{\glsacrshortcutstrue}%
  \else
    \def\@gls@setupshortcuts{%
      \ifglsacrshortcuts
        \DefineAcronymSynonyms
      \fi
    }%
  \fi
  \glsacrshortcutsfalse
  \let\@gls@do@numbersdef\relax
  \let\@gls@do@symbolssdef\relax
  \let\@gls@do@indexdef\relax
  \let\@gls@do@acronymsdef\relax
  \setkeys{glossaries.sty}{#1}%
  \@gls@setacrstyle
  \@gls@setupshortcuts
  \@gls@do@acronymsdef
  \@gls@do@numbersdef
  \@gls@do@symbolssdef
  \@gls@do@indexdef
}
%    \end{macrocode}
%\end{macro}
%
% 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 \cs{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]{%
      \ifcsdef{gls@tr@set@#1@toctitle}%
      {%
        \csuse{gls@tr@set@#1@toctitle}%
      }%
      {%
        \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}}{}%
    }}
\else
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{added cs{@gls@nottranslatorhook} to else clause}
%    \begin{macrocode}
   \@gls@notranslatorhook
\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}
%\changes{3.05}{2013-04-21}{made robust}
%    \begin{macrocode}
\DeclareRobustCommand*{\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}{\@no@post@desc}
% Used for comparison purposes.
%    \begin{macrocode}
\newcommand*{\@no@post@desc}{\nopostdesc}
%    \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 relevant extension is appended.
%    \begin{macrocode}
\newcommand{\setStyleFile}[1]{%
  \renewcommand*{\gls@istfilebase}{#1}%
%    \end{macrocode}
% Just in case \cs{istfilename} has been modified.
%    \begin{macrocode}
  \ifglsxindy
    \def\istfilename{\gls@istfilebase.xdy}
  \else
    \def\istfilename{\gls@istfilebase.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{\gls@istfilebase.xdy}
\else
  \def\istfilename{\gls@istfilebase.ist}
\fi
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@istfilebase}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\gls@istfilebase}{\jobname}
%    \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}
%\changes{3.07}{2013-07-05}{modified to work with
%\cs{setglossarypreamble}}
%    \begin{macrocode}
\newcommand*{\glossarypreamble}{%
  \csuse{@glossarypreamble@\currentglossary}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\setglossarypreamble}
%\begin{definition}
%\cs{setglossarypreamble}\oarg{type}\marg{text}
%\end{definition}
% Code provided by Michael Pock.
%\changes{3.07}{2013-07-05}{new}
%    \begin{macrocode}
\newcommand{\setglossarypreamble}[2][\glsdefaulttype]{%
  \ifglossaryexists{#1}{%
    \csgdef{@glossarypreamble@#1}{#2}%
  }{%
    \GlossariesWarning{%
      Glossary `#1' is not defined%
    }%
  }%
}
%    \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 \cs{@mkboth} to
%\cs{glossarysection}}
%\changes{2.02}{2009 July 13}{changed \cs{@mkboth} to
%\cs{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}%
  }%
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{changed \cs{glossarymark} to \cs{glsglossarymark}}
%    \begin{macrocode}
  \glsglossarymark{\glossarytoctitle}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsglossarymark}
%\changes{2.02}{2009 July 13}{New}
%\changes{2.03}{2009 Sep 23}{Added check to see if it's already 
%defined}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%\changes{3.11a}{2013-10-15}{replaced \cs{MakeUppercase} with
%\cs{mfirstucMakeUppercase}}
%\changes{3.13a}{2013-11-05}{renamed \cs{glossarymark} to
%\cs{glsglossarymark} to avoid conflict with memoir}
% Sets the header mark for the glossary. Takes the glossary short
% (TOC) title as the argument.
%    \begin{macrocode}
\ifcsundef{glossarymark}%
{%
  \newcommand{\glsglossarymark}[1]{\glossarymark{#1}}
}%
{%
  \@ifclassloaded{memoir}
  {%
    \newcommand{\glsglossarymark}[1]{%
      \ifglsucmark
        \markboth{\memUChead{#1}}{\memUChead{#1}}%
      \else
        \markboth{#1}{#1}%
      \fi
    }
  }%
  {%
    \newcommand{\glsglossarymark}[1]{%
      \ifglsucmark
        \@mkboth{\mfirstucMakeUppercase{#1}}{\mfirstucMakeUppercase{#1}}%
      \else
        \@mkboth{#1}{#1}%
      \fi
    }
  }
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glossarymark}
% Provided for backward compatibility:
%    \begin{macrocode}
\providecommand{\glossarymark}[1]{%
  \ifglsucmark
    \@mkboth{\mfirstucMakeUppercase{#1}}{\mfirstucMakeUppercase{#1}}%
  \else
    \@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}
%\changes{4.07}{2014-04-04}{added optional argument when using unstarred
%version}
%    \begin{macrocode}
\newcommand*{\@glossarysection}[2]{%
  \ifdefempty\@@glossarysecstar
  {%
    \csname\@@glossarysec\endcsname[#1]{#2}%
  }%
  {%
    \csname\@@glossarysec\endcsname*{#2}%
    \@gls@toc{#1}{\@@glossarysec}%
  }%
%    \end{macrocode}
% Do automatic labelling if required
%    \begin{macrocode}
  \@@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
  \ifdefempty\@@glossarysecstar
  {%
    \csname\@@glossarysec\endcsname{#2}%
  }%
  {%
    \@gls@toc{#1}{\@@glossarysec}%
      \csname\@@glossarysec\endcsname*{#2}%
  }%
%    \end{macrocode}
% Do automatic labelling if required
%    \begin{macrocode}
  \@@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}}
%\changes{3.07}{2013-07-05}{added check for openright}
%    \begin{macrocode}
\newcommand*{\gls@doclearpage}{%
  \ifthenelse{\equal{\@@glossarysec}{chapter}}%
  {%
    \ifcsundef{cleardoublepage}%
    {%
      \clearpage
    }%
    {%
      \ifcsdef{if@openright}%
      {%
         \if@openright
           \cleardoublepage
         \else
           \clearpage
         \fi
      }%
      {%
         \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"\glstildechar 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}
%\changes{3.06}{2013/06/17}{Obsoleted}
% This used to determine the root language, using a~bit of trickery
% since \sty{babel} doesn't supply the information, but now that
% \sty{babel} is once again actively maintained, we can't do this
% any more, so \cs{findrootlanguage} is no longer available. Now
% provide a command that does nothing (in case it's been patched),
% but this may be removed completely in the future.
%    \begin{macrocode}
\newcommand*{\findrootlanguage}{}
%    \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}%
  }
%    \end{macrocode}
%\changes{3.07}{2013-07-05}{Added check for fontspec}
% Suggested by egreg:
%    \begin{macrocode}
  \AtBeginDocument{%
    \ifx\gls@codepage\@empty
      \@ifpackageloaded{fontspec}{\def\gls@codepage{utf8}}{}%
    \fi
  }
\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}{\forallacronyms}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\forallacronyms}[2]{%
  \@for#1:=\@glsacronymlists\do{\ifx#1\@empty\else#2\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}}
%\changes{3.11a}{2013-10-15}{replaced \cs{ifx} with \cs{ifdefempty}}
%    \begin{macrocode}
\newcommand*{\forglsentries}[3][\glsdefaulttype]{%
  \edef\@@glo@list{\csname glolist@#1\endcsname}%
  \@for#2:=\@@glo@list\do
  {%
    \ifdefempty{#2}{}{#3}%
  }%
}
%    \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}
%
% Since the label is used to form the name of control sequences, by
% default UTF8 etc characters can't be used in the label. A possible
% workaround is to use \ics{scantokens}, but commands such as
% \ics{glsentrytext} will no longer be usable in sectioning, caption
% etc commands. If the user really wants to be able to construct a
% label with UTF8 characters, allow them the means to do so (but on
% their own head be it, if they then use entries in \ics{section}
% etc). This can be done via:
%\begin{verbatim}
%\renewcommand*{\glsdetoklabel}[1]{\scantokens{#1\noexpand}}
%\end{verbatim}
% (Note, don't use \ics{detokenize} or it will cause commands like
% \ics{glsaddall} to fail.)
% Since redefining \cs{glsdetoklabel} can cause things to go
% badly wrong, I'm not going to mention it in the main user guide.
% Only advanced users who know what they're doing ought to attempt
% it.
%\begin{macro}{\glsdetoklabel}
%\changes{4.03}{2014-01-20}{new}
%    \begin{macrocode}
\newcommand*{\glsdetoklabel}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglsentryexists}
% To check to see if a glossary entry has been defined use:
%\begin{definition}
% \cs{ifglsentryexists}\marg{label}\marg{true text}\marg{false text}
%\end{definition}
%where \meta{label} is the entry's label.
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand{\ifglsentryexists}[3]{%
  \ifcsundef{glo@\glsdetoklabel{#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:
%\begin{definition}
% \cs{ifglsused}\marg{label}\marg{true text}\marg{false text}
%\end{definition}
% where \meta{label} is the entry's label.
% If true it will do \meta{true text}
% otherwise it will do \meta{false text}.
%\changes{3.11a}{2013-10-15}{replaced \cs{ifthenelse} with
%\cs{ifbool}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\ifglsused}[3]{%
  \ifbool{glo@\glsdetoklabel{#1}@flag}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%The following two commands will cause an error if the given
% condition fails:
%
%\begin{macro}{\glsdoifexists}
%\begin{definition}
%\cs{glsdoifexists}\marg{label}\marg{code}
%\end{definition}
% 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 `\glsdetoklabel{#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 `\glsdetoklabel{#1}' has already
    been defined}{}}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdoifexistsorwarn}
%\begin{definition}
%\cs{glsdoifexistsorwarn}\marg{label}\marg{code}
%\end{definition}
% Generate a warning if entry specified by \meta{label} doesn't 
% exists, otherwise do \meta{code}.
%\changes{4.03}{2014-01-20}{new}
%    \begin{macrocode}
\newcommand{\glsdoifexistsorwarn}[2]{%
  \ifglsentryexists{#1}{#2}{%
    \GlossariesWarning{Glossary entry `\glsdetoklabel{#1}'
      has not been defined}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshaschildren}
% \cs{ifglshaschildren}\marg{label}\marg{true part}\marg{false part}
%\changes{3.02}{2012/05/21}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand{\ifglshaschildren}[3]{%
  \glsdoifexists{#1}%
  {%
     \def\do@glshaschildren{#3}%
     \edef\@gls@thislabel{\glsdetoklabel{#1}}%
     \expandafter\forglsentries\expandafter
       [\csname glo@\@gls@thislabel @type\endcsname]
     {\glo@label}%
     {%
       \letcs\glo@parent{glo@\glo@label @parent}%
       \ifdefequal\@gls@thislabel\glo@parent
       {%
         \def\do@glshaschildren{#2}%
         \@endfortrue
       }%
       {}%
     }%
     \do@glshaschildren
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshasparent}
%\begin{definition}
% \cs{ifglshasparent}\marg{label}\marg{true part}\marg{false part}
%\end{definition}
%\changes{3.02}{2012/05/21}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand{\ifglshasparent}[3]{%
  \glsdoifexists{#1}%
  {%
    \ifcsempty{glo@\glsdetoklabel{#1}@parent}{#3}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshasdesc}
%\cs{ifglshasdesc}\marg{label}\marg{true part}\marg{false part}
%\changes{3.08a}{2013-09-28}{new}
%\changes{3.11a}{2013-10-15}{replaced \cs{ifdefempty} with
%\cs{ifcsempty}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\ifglshasdesc}[3]{%
  \ifcsempty{glo@\glsdetoklabel{#1}@desc}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglsdescsuppressed}
%\cs{ifglsdescsuppressed}\marg{label}\marg{true part}\marg{false part}
%\changes{3.08a}{2013-09-28}{new}
% Does \meta{true part} if the description is just \cs{nopostdesc}
% otherwise does \meta{false part}.
%\changes{4.03}{2014-01-20}{fixed typo}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\ifglsdescsuppressed}[3]{%
  \ifcsequal{glo@\glsdetoklabel{#1}@desc}{@no@post@desc}%
  {#2}%
  {#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshassymbol}
%\cs{ifglshassymbol}\marg{label}\marg{true part}\marg{false part}
%\changes{3.08a}{2013-09-28}{new}
%\changes{3.09a}{2013-10-09}{changed test to check for
%\cs{@gls@default@symbol}}
%\changes{3.11a}{2013-10-15}{replaced \cs{ifdefempty} with
%\cs{ifcsempty}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%\changes{4.03}{2014-01-20}{replaced \cs{ifcsempty} with
%\cs{ifdefempty} and replaced \cs{ifx} with \cs{ifdefequal}}
%    \begin{macrocode}
\newcommand*{\ifglshassymbol}[3]{%
  \letcs{\@glo@symbol}{glo@\glsdetoklabel{#1}@symbol}%
  \ifdefempty\@glo@symbol
  {#3}%
  {%
    \ifdefequal\@glo@symbol\@gls@default@value
    {#3}%
    {#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshaslong}
%\cs{ifglshaslong}\marg{label}\marg{true part}\marg{false part}
%\changes{3.11a}{2013-10-15}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\ifglshaslong}[3]{%
  \letcs{\@glo@long}{glo@\glsdetoklabel{#1}@long}%
  \ifdefempty\@glo@long
  {#3}%
  {%
    \ifdefequal\@glo@long\@gls@default@value
    {#3}%
    {#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshasshort}
%\cs{ifglshasshort}\marg{label}\marg{true part}\marg{false part}
%\changes{3.11a}{2013-10-15}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\ifglshasshort}[3]{%
  \letcs{\@glo@short}{glo@\glsdetoklabel{#1}@short}%
  \ifdefempty\@glo@short
  {#3}%
  {%
    \ifdefequal\@glo@short\@gls@default@value
    {#3}%
    {#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifglshasfield}
%\changes{4.03}{2014-01-20}{new}
%\begin{definition}
%\cs{ifglshasfield}\marg{field}\marg{label}\marg{true part}\marg{false
%part}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\ifglshasfield}[4]{%
  \glsdoifexists{#2}%
  {%
    \letcs{\@glo@thisvalue}{glo@\glsdetoklabel{#2}@#1}%
%    \end{macrocode}
% First check supplied field label is defined.
%    \begin{macrocode}
    \ifdef\@glo@thisvalue
    {%
%    \end{macrocode}
% Is defined, so now check if empty.
%    \begin{macrocode}
      \ifdefempty\@glo@thisvalue
      {%
%    \end{macrocode}
% Is empty, so doesn't have field set.
%    \begin{macrocode}
        #4%
      }%
      {%
%    \end{macrocode}
% Not empty, so check if set to \cs{@gls@default@value}
%    \begin{macrocode}
        \ifdefequal\@glo@thisvalue\@gls@default@value{#4}{#3}%
      }%
    }%
    {%
%    \end{macrocode}
% Field given isn't defined, so check if mapping exists.
%    \begin{macrocode}
       \@gls@fetchfield{\@gls@thisfield}{#1}%
%    \end{macrocode}
% If \cs{@gls@thisfield} is defined, we've found a map. If not, the
% field supplied doesn't exist.
%    \begin{macrocode}
       \ifdef\@gls@thisfield
       {%
%    \end{macrocode}
% Is defined, so now check if empty.
%    \begin{macrocode}
         \letcs{\@glo@thisvalue}{glo@\glsdetoklabel{#2}@\@gls@thisfield}%
         \ifdefempty\@glo@thisvalue
         {%
%    \end{macrocode}
% Is empty so field hasn't been set.
%    \begin{macrocode}
           #4%
         }%
         {%
%    \end{macrocode}
% Isn't empty so check if it's been set to \cs{@gls@default@value}.
%    \begin{macrocode}
           \ifdefequal\@glo@thisvalue\@gls@default@value{#4}{#3}%
         }%
       }%
       {%
%    \end{macrocode}
% Not defined.
%    \begin{macrocode}
         \GlossariesWarning{Unknown entry field `#1'}%
         #4%
       }%
    }%
  }%
}
%    \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}
%
%\begin{macro}{\@gls@provide@newglossary}
%\changes{3.10a}{2013-10-13}{new}
% If the user removes the glossary package from their document,
% ensure the next run doesn't throw a load of undefined control
% sequence errors when the aux file is parsed.
%    \begin{macrocode}
\newcommand*\@gls@provide@newglossary{%
  \protected@write\@auxout{}{\string\providecommand\string\@newglossary[4]{}}%
%    \end{macrocode}
% Only need to do this once.
%    \begin{macrocode}
  \let\@gls@provide@newglossary\relax
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\defglsentryfmt}
%\changes{3.11a}{2013-10-15}{new}
% Allow different glossaries to have different display styles.
%    \begin{macrocode}
\newcommand*{\defglsentryfmt}[2][\glsdefaulttype]{%
  \csgdef{gls@#1@entryfmt}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@doentryfmt}
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\newcommand*{\gls@doentryfmt}[1]{\csuse{gls@#1@entryfmt}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@forbidtexext}
%\changes{4.08}{2014-07-30}{new}
% As a security precaution, don't allow the user to specify a `tex'
% extension for any of the glossary files. (Just in case a seriously
% confused novice user doesn't know what they're doing.) The
% argument must be a control sequence whose replacement text is the
% requested extension.
%    \begin{macrocode}
\newcommand*{\@gls@forbidtexext}[1]{%
 \ifboolexpr{test {\ifdefstring{#1}{tex}}
          or test {\ifdefstring{#1}{TEX}}}
 {%
   \def#1{nottex}%
   \PackageError{glossaries}%
    {Forbidden `.tex' extension replaced with `.nottex'}%
    {I'm sorry, I can't allow you to do something so reckless.\MessageBreak
     Don't use `.tex' as an extension for a temporary file.}%
 }%
 {%
 }%
}
%    \end{macrocode}
%\end{macro}
%
% A new glossary type is defined using \cs{newglossary}.
% Syntax:
%\begin{definition}
%\cs{newglossary}\oarg{log-ext}\marg{name}\marg{in-ext}\marg{out-ext}%
%\marg{title}\oarg{counter}
%\end{definition}
% 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}
%\changes{4.08}{2014-07-30}{added starred version}
%    \begin{macrocode}
\newcommand*{\newglossary}{\@ifstar\s@newglossary\ns@newglossary}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\s@newglossary}
% The starred version will construct the extension based on the
% label.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\s@newglossary}[2]{%
 \ns@newglossary[#1-glg]{#1}{#1-gls}{#1-glo}{#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ns@newglossary}
%\changes{4.08}{2014-07-30}{new}
% Define the unstarred version.
%    \begin{macrocode}
\newcommand*{\ns@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}
  \ifundef\glsdefaulttype
  {%
    \gdef\glsdefaulttype{#2}%
  }{}%
%    \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 the file extensions:
%\changes{4.08}{2014-07-30}{added \cs{@glotype@\meta{name}@log}}
%    \begin{macrocode}
  \expandafter\edef\csname @glotype@#2@log\endcsname{#1}%
  \expandafter\edef\csname @glotype@#2@in\endcsname{#3}%
  \expandafter\edef\csname @glotype@#2@out\endcsname{#4}%
  \expandafter\@gls@forbidtexext\csname @glotype@#2@log\endcsname
  \expandafter\@gls@forbidtexext\csname @glotype@#2@in\endcsname
  \expandafter\@gls@forbidtexext\csname @glotype@#2@out\endcsname
%    \end{macrocode}
% Store the title:
%    \begin{macrocode}
  \expandafter\def\csname @glotype@#2@title\endcsname{#5}%
%    \end{macrocode}
%\changes{3.10a}{2013-10-13}{added \cs{@gls@provide@newglossary}}
%    \begin{macrocode}
  \@gls@provide@newglossary
  \protected@write\@auxout{}{\string\@newglossary{#2}{#1}{#3}{#4}}%
%    \end{macrocode}
% How to display this entry in the document text (uses
% \cs{glsentry} by
% default). This can be redefined by the user later if required
% (see \ics{defglsentry}). This
% 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}}
%\changes{3.11a}{2013-10-15}{replaced \cs{glsdisplay} and
%\cs{glsdisplayfirst} with \cs{glsentryfmt}}
%    \begin{macrocode}
  \ifcsundef{gls@#2@entryfmt}%
  {%
    \defglsentryfmt[#2]{\glsentryfmt}%
  }%
  {}%
%    \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}
% Define the \qt{acronym} glossaries if required.
%    \begin{macrocode}
\@gls@do@acronymsdef
%    \end{macrocode}
% Define the \qt{symbols}, \qt{numbers} and \qt{index} glossaries if required.
%    \begin{macrocode}
\@gls@do@symbolsdef
\@gls@do@numbersdef
\@gls@do@indexdef
%    \end{macrocode}
%
%\begin{macro}{\newignoredglossary}
% Creates a new glossary that doesn't have associated files.
% This glossary is ignored by and commands that iterate over
% glossaries, such as \ics{printglossaries}, and won't work with
% commands like \ics{printglossary}. It's intended for entries that
% are so commonly-known they don't require a glossary.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\newignoredglossary}[1]{%
  \ifdefempty\@ignored@glossaries
  {%
    \edef\@ignored@glossaries{#1}%
  }%
  {%
    \eappto\@ignored@glossaries{,#1}%
  }%
  \csgdef{glolist@#1}{,}%
  \ifcsundef{gls@#1@entryfmt}%
  {%
    \defglsentryfmt[#1]{\glsentryfmt}%
  }%
  {}%
  \ifdefempty\@gls@nohyperlist
  {%
     \renewcommand*{\@gls@nohyperlist}{#1}%
  }%
  {%
     \eappto\@gls@nohyperlist{,#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ignored@glossaries}
% List of ignored glossaries.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\@ignored@glossaries}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ifignoredglossary}
% Tests if the given glossary is an ignored glossary.
% Expansion is used in case the first argument is a control
% sequence.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\ifignoredglossary}[3]{%
  \edef\@gls@igtype{#1}%
  \expandafter\DTLifinlist\expandafter
    {\@gls@igtype}{\@ignored@glossaries}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\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{glsentryfmt} or using \ics{defglsentryfmt}. The 
% \gloskey{description} key is required when
% defining a new glossary entry. If a long description is required,
% use \ics{longnewglossaryentry} instead of \ics{newglossaryentry}.
%    \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
%\cs{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{macro}{\@gls@default@value}
%\changes{3.09a}{2013-10-09}{new}
%    \begin{macrocode}
\newcommand*{\@gls@default@value}{\relax}
%    \end{macrocode}
%\end{macro}
%
%\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{glossentry}.
% 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{glsentryfmt} (or use for \ics{defglsentryfmt} 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}}
%\changes{3.13a}{2013-11-05}{added \cs{gls@checkseeallowed}}
%    \begin{macrocode}
\define@key{glossentry}{see}{%
  \gls@checkseeallowed
  \def\@glo@see{#1}%
  \@glo@seeautonumberlist
}
%    \end{macrocode}
%\end{key}
%
%\begin{macro}{\gls@checkseeallowed}
%\changes{3.13a}{2013-11-05}{new}
%    \begin{macrocode}
\newcommand*{\gls@checkseeallowed}{%
  \PackageError{glossaries}%
  {`see' key may only be used after \string\makeglossaries\space
   or \string\makenoidxglossaries}%
  {You must use \string\makeglossaries\space
   or \string\makenoidxglossaries\space before defining
   any entries that have a `see' key}%
}
%    \end{macrocode}
%\end{macro}
%
%\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. (Additional keys can be added by
% the user.)
%\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}{\@glsnodesc}
% \changes{3.10a}{2013-10-13}{new}
% Define command to generate error if \gloskey{description} key is missing.
%    \begin{macrocode}
\newcommand*\@glsnodesc{%
  \PackageError{glossaries}
  {%
    description key required in \string\newglossaryentry\space
    for entry `\@glo@label'%
  }%
  {%
    You haven't specified the entry description%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdefaultplural}
% \changes{1.17}{2008 December 26}{new}
%\changes{3.10a}{2013-10-13}{Obsolete}
% Now obsolete. Don't use.
%    \begin{macrocode}
\newcommand*{\@glsdefaultplural}{}
%    \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}{\@gls@noexpand@field}
%    \begin{macrocode}
\newcommand{\@@gls@noexpand@field}[3]{%
 \expandafter\global\expandafter
    \let\csname glo@#1@#2\endcsname#3%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@noexpand@fields}
%    \begin{macrocode}
\newcommand{\@gls@noexpand@fields}[4]{%
  \ifcsdef{gls@assign@#3@field}
  {%
     \ifdefequal{#4}{\@gls@default@value}%
     {%
       \edef\@gls@value{\expandonce{#1}}%
       \csuse{gls@assign@#3@field}{#2}{\@gls@value}%
     }%
     {%
       \csuse{gls@assign@#3@field}{#2}{#4}%
     }%
  }%
  {%
    \ifdefequal{#4}{\@gls@default@value}%
    {%
       \edef\@gls@value{\expandonce{#1}}%
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{Fixed bug \texttt{expand} replaced with
%\texttt{noexpand}}
%    \begin{macrocode}
       \@@gls@noexpand@field{#2}{#3}{\@gls@value}%
    }%
    {%
      \@@gls@noexpand@field{#2}{#3}{#4}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@@gls@expand@field}
%    \begin{macrocode}
\newcommand{\@@gls@expand@field}[3]{%
 \expandafter
   \protected@xdef\csname glo@#1@#2\endcsname{#3}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{@gls@expand@fields}
%    \begin{macrocode}
\newcommand{\@gls@expand@fields}[4]{%
  \ifcsdef{gls@assign@#3@field}
  {%
     \ifdefequal{#4}{\@gls@default@value}%
     {%
       \edef\@gls@value{\expandonce{#1}}%
       \csuse{gls@assign@#3@field}{#2}{\@gls@value}%
     }%
     {%
       \expandafter\@gls@startswithexpandonce#4\relax\relax\gls@endcheck
       {%
         \@@gls@expand@field{#2}{#3}{#4}%
       }%
       {%
         \csuse{gls@assign@#3@field}{#2}{#4}%
       }%
     }%
  }%
  {%
    \ifdefequal{#4}{\@gls@default@value}%
    {%
      \@@gls@expand@field{#2}{#3}{#1}%
    }%
    {%
      \@@gls@expand@field{#2}{#3}{#4}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@startswithexpandonce}
%    \begin{macrocode}
\def\@gls@expandonce{\expandonce}
\def\@gls@startswithexpandonce#1#2\gls@endcheck#3#4{%
  \def\@gls@tmp{#1}%
  \ifdefequal{\@gls@expandonce}{\@gls@tmp}{#3}{#4}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@assign@field}
%\begin{definition}
%\cs{gls@assign@field}\marg{def value}\marg{glossary type}\marg{field}\marg{tmp
%cs}
%\end{definition}
% Assigns an entry field. Expansion performed by default (except for
% name, symbol and description where backward compatibility required).
% If \meta{tmp cs} is \meta{@gls@default@value}, \meta{def value} is
% used instead.
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\let\gls@assign@field\@gls@expand@fields
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsexpandfields}
%\changes{3.08a}{2013-09-28}{new}
% Fully expand values when assigning fields (except for specific
% fields that are overridden by \cs{glssetnoexpandfield}).
%    \begin{macrocode}
\newcommand*{\glsexpandfields}{%
  \let\gls@assign@field\@gls@expand@fields
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsnoexpandfields}
%\changes{3.08a}{2013-09-28}{new}
% Don't expand values when assigning fields (except for specific
% fields that are overridden by \cs{glssetexpandfield}).
%    \begin{macrocode}
\newcommand*{\glsnoexpandfields}{%
  \let\gls@assign@field\@gls@noexpand@fields
}
%    \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}%
  {%
     \gls@defglossaryentry{#1}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\provideglossaryentry}
% Like \cs{newglossaryentry} but does nothing if the entry has
% already been defined.
%\changes{3.14a}{2013-11-12}{new}
%    \begin{macrocode}
\newrobustcmd{\provideglossaryentry}[2]{%
  \ifglsentryexists{#1}%
  {}%
  {%
    \gls@defglossaryentry{#1}{#2}%
  }%
}
\@onlypreamble{\provideglossaryentry}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\new@glossaryentry}
%\changes{3.10a}{2013-10-13}{new}
% For use in document environment.
%    \begin{macrocode}
\newrobustcmd{\new@glossaryentry}[2]{%
  \ifundef\@gls@deffile
  {%
     \global\newwrite\@gls@deffile
     \immediate\openout\@gls@deffile=\jobname.glsdefs
  }%
  {}%
  \ifglsentryexists{#1}{}%
  {%
     \gls@defglossaryentry{#1}{#2}%
  }%
  \@gls@writedef{#1}%
}
\AtBeginDocument
{
  \makeatletter
  \InputIfFileExists{\jobname.glsdefs}{}{}%
  \makeatother
  \let\newglossaryentry\new@glossaryentry
}
\AtEndDocument{\ifdef\@gls@deffile{\closeout\@gls@deffile}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@writedef}
%\changes{3.10a}{2013-10-13}{new}
% Writes glossary entry definition to \cs{@gls@deffile}.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\@gls@writedef}[1]{%
  \immediate\write\@gls@deffile
  {%
    \string\ifglsentryexists{#1}{}\glspercentchar^^J%
    \expandafter\@gobble\string\{\glspercentchar^^J%
      \string\gls@defglossaryentry{\glsdetoklabel{#1}}\glspercentchar^^J%
      \expandafter\@gobble\string\{\glspercentchar%
  }%
%    \end{macrocode}
% Write key value information:
%    \begin{macrocode}
  \@for\@gls@map:=\@gls@keymap\do
  {%
    \edef\glo@value{\expandafter\expandonce
       \csname glo@\glsdetoklabel{#1}@\expandafter
         \@secondoftwo\@gls@map\endcsname}%
    \@onelevel@sanitize\glo@value
    \immediate\write\@gls@deffile
    {%
      \expandafter\@firstoftwo\@gls@map
        =\expandafter\@gobble\string\{\glo@value\expandafter\@gobble\string\},%
        \glspercentchar%
    }%
  }%
%    \end{macrocode}
% Provide hook:
%    \begin{macrocode}
  \glswritedefhook
  \immediate\write\@gls@deffile
  {%
           \glspercentchar^^J%
      \expandafter\@gobble\string\}\glspercentchar^^J%
    \expandafter\@gobble\string\}\glspercentchar%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@keymap}
%\changes{3.10a}{2013-10-13}{new}
% List of entry definition key names and corresponding tag in
% control sequence used to store the value.
%    \begin{macrocode}
\newcommand*{\@gls@keymap}{%
  {name}{name},%
  {sort}{sortvalue},% unescaped sort value
  {type}{type},%
  {first}{first},%
  {firstplural}{firstpl},%
  {text}{text},%
  {plural}{plural},%
  {description}{desc},%
  {descriptionplural}{descplural},%
  {symbol}{symbol},%
  {symbolplural}{symbolplural},%
  {user1}{useri},%
  {user2}{userii},%
  {user3}{useriii},%
  {user4}{useriv},%
  {user5}{userv},%
  {user6}{uservi},%
  {long}{long},%
  {longplural}{longpl},%
  {short}{short},%
  {shortplural}{shortpl},%
  {counter}{counter},%
  {parent}{parent}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@fetchfield}
%\changes{4.03}{2014-01-20}{new}
%\begin{definition}
%\cs{@gls@fetchfield}\marg{cs}\marg{field}
%\end{definition}
% Fetches the internal field label from the given user \meta{field} and
% stores in \meta{cs}.
%    \begin{macrocode}
\newcommand*{\@gls@fetchfield}[2]{%
%    \end{macrocode}
% Ensure user field name is fully expanded
%    \begin{macrocode}
  \edef\@gls@thisval{#2}%
%    \end{macrocode}
% Iterate through known mappings until we find the one for this
% field.
%    \begin{macrocode}
  \@for\@gls@map:=\@gls@keymap\do{%
   \edef\@this@key{\expandafter\@firstoftwo\@gls@map}%
   \ifdefequal{\@this@key}{\@gls@thisval}%
   {%
%    \end{macrocode}
% Found it.
%    \begin{macrocode}
     \edef#1{\expandafter\@secondoftwo\@gls@map}%
%    \end{macrocode}
% Break out of loop.
%    \begin{macrocode}
     \@endfortrue
   }%
   {}%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaddkey}
%\begin{definition}
%\cs{glsaddkey}\marg{key}\marg{default value}\marg{no link cs}\marg{no link ucfirst
%cs}\marg{link cs}\marg{link ucfirst cs}\marg{link allcaps cs}
%\end{definition}
%\changes{3.12a}{2013-10-16}{new}
% Allow user to add their own custom keys.
%    \begin{macrocode}
\newcommand*{\glsaddkey}{\@ifstar\@sglsaddkey\@glsaddkey}
%    \end{macrocode}
% Starred version switches on expansion for this key.
%    \begin{macrocode}
\newcommand*{\@sglsaddkey}[1]{%
  \key@ifundefined{glossentry}{#1}%
  {%
    \expandafter\newcommand\expandafter*\expandafter
     {\csname gls@assign@#1@field\endcsname}[2]{%
       \@@gls@expand@field{##1}{#1}{##2}%
     }%
  }%
  {}%
  \@glsaddkey{#1}%
}
%    \end{macrocode}
% Unstarred version doesn't override default expansion.
%    \begin{macrocode}
\newcommand*{\@glsaddkey}[7]{%
%    \end{macrocode}
% Check the specified key doesn't already exist.
%    \begin{macrocode}
  \key@ifundefined{glossentry}{#1}%
  {%
%    \end{macrocode}
% Set up the key.
%    \begin{macrocode}
    \define@key{glossentry}{#1}{\csdef{@glo@#1}{##1}}%
    \appto\@gls@keymap{,{#1}{#1}}%
%    \end{macrocode}
% Set the default value.
%    \begin{macrocode}
    \appto\@newglossaryentryprehook{\csdef{@glo@#1}{#2}}%
%    \end{macrocode}
% Assignment code.
%    \begin{macrocode}
    \appto\@newglossaryentryposthook{%
      \letcs{\@glo@tmp}{@glo@#1}%
      \gls@assign@field{#2}{\@glo@label}{#1}{\@glo@tmp}%
    }%
%    \end{macrocode}
% Define the no-link commands.
%    \begin{macrocode}
    \newcommand*{#3}[1]{\@gls@entry@field{##1}{#1}}%
    \newcommand*{#4}[1]{\@Gls@entry@field{##1}{#1}}%
%    \end{macrocode}
% Now for the commands with links. First the version with no case
% change:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@field@link}}
%    \begin{macrocode}
    \ifcsdef{@gls@user@#1@}%
    {%
       \PackageError{glossaries}%
       {Can't define `\string#5' as helper command 
        `\expandafter\string\csname @gls@user@#1@\endcsname' already exists}%
       {}%
    }%
    {%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%\changes{4.08}{2014-07-30}{removed \cs{@sgls@user@\meta{key}}}
%\changes{4.09}{2014-08-12}{fixed bug in user commands}
%    \begin{macrocode}
      \expandafter\newcommand\expandafter*\expandafter
        {\csname @gls@user@#1\endcsname}[2][]{%
          \new@ifnextchar[%
            {\csuse{@gls@user@#1@}{##1}{##2}}%
            {\csuse{@gls@user@#1@}{##1}{##2}[]}}%
      \csdef{@gls@user@#1@}##1##2[##3]{%
        \@gls@field@link{##1}{##2}{#3{##2}##3}%
      }%
      \newrobustcmd*{#5}{%
        \expandafter\@gls@hyp@opt\csname @gls@user@#1\endcsname}%
    }%
%    \end{macrocode}
% Next the version with the first letter converted to upper case:
%    \begin{macrocode}
    \ifcsdef{@Gls@user@#1@}%
    {%
       \PackageError{glossaries}%
       {Can't define `\string#6' as helper command 
        `\expandafter\string\csname @Gls@user@#1@\endcsname' already exists}%
       {}%
    }%
    {%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%\changes{4.08}{2014-07-30}{removed \cs{@sGls@user@\meta{key}}}
%    \begin{macrocode}
      \expandafter\newcommand\expandafter*\expandafter
        {\csname @Gls@user@#1\endcsname}[2][]{%
          \new@ifnextchar[%
            {\csuse{@Gls@user@#1@}{##1}{##2}}%
            {\csuse{@Gls@user@#1@}{##1}{##2}[]}}%
      \csdef{@Gls@user@#1@}##1##2[##3]{%
        \@gls@field@link{##1}{##2}{#4{##2}##3}%
      }%
      \newrobustcmd*{#6}{%
        \expandafter\@gls@hyp@opt\csname @Gls@user@#1\endcsname}%
    }%
%    \end{macrocode}
% Finally the all caps version:
%    \begin{macrocode}
    \ifcsdef{@GLS@user@#1@}%
    {%
       \PackageError{glossaries}%
       {Can't define `\string#7' as helper command 
        `\expandafter\string\csname @GLS@user@#1@\endcsname' already exists}%
       {}%
    }%
    {%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLS@user@\meta{key}}}
%    \begin{macrocode}
      \expandafter\newcommand\expandafter*\expandafter
        {\csname @GLS@user@#1\endcsname}[2][]{%
          \new@ifnextchar[%
            {\csuse{@GLS@user@#1@}{##1}{##2}}%
            {\csuse{@GLS@user@#1@}{##1}{##2}[]}}%
      \csdef{@GLS@user@#1@}##1##2[##3]{%
        \@gls@field@link{##1}{##2}{\mfirstucMakeUppercase{#3{##2}##3}}%
      }%
      \newrobustcmd*{#7}{%
        \expandafter\@gls@hyp@opt\csname @GLS@user@#1\endcsname}%
    }%
  }%
  {%
    \PackageError{glossaries}{Key `#1' already exists}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glswritedefhook}
%\changes{3.10a}{2013-10-13}{new}
%    \begin{macrocode}
\newcommand*{\glswritedefhook}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gls@assign@desc}
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\newcommand*{\gls@assign@desc}[1]{%
  \gls@assign@field{}{#1}{desc}{\@glo@desc}%
  \gls@assign@field{\@glo@desc}{#1}{descplural}{\@glo@descplural}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\longnewglossaryentry}
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\newcommand{\longnewglossaryentry}[3]{%
  \glsdoifnoexists{#1}%
  {%
     \bgroup
       \let\@org@newglossaryentryprehook\@newglossaryentryprehook
       \long\def\@newglossaryentryprehook{%
         \long\def\@glo@desc{#3\leavevmode\unskip\nopostdesc}%
         \@org@newglossaryentryprehook
       }%
       \renewcommand*{\gls@assign@desc}[1]{%
          \global\cslet{glo@\glsdetoklabel{#1}@desc}{\@glo@desc}%
          \global\cslet{glo@\glsdetoklabel{#1}@descplural}{\@glo@desc}%
        }
       \gls@defglossaryentry{#1}{#2}%
     \egroup
  }
}
%    \end{macrocode}
% Only allowed in the preamble. (Otherwise a long description could
% cause problems when writing the entry definition to the temporary
% file.)
%    \begin{macrocode}
\@onlypreamble{\longnewglossaryentry}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\longprovideglossaryentry}
%\changes{3.14a}{2013-11-12}{new}
% As the above but only defines the entry if it doesn't already
% exist.
%    \begin{macrocode}
\newcommand{\longprovideglossaryentry}[3]{%
  \ifglsentryexists{#1}{}%
  {\longnewglossaryentry{#1}{#2}{#3}}%
}
\@onlypreamble{\longprovideglossaryentry}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@defglossaryentry}
%\begin{definition}
%\cs{gls@defglossaryentry}\marg{label}\marg{key-val list}
%\end{definition}
% Defines a new entry without checking if it already exists.
%\changes{3.10a}{2013-10-13}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand{\gls@defglossaryentry}[2]{%
%    \end{macrocode}
% Store label
%    \begin{macrocode}
    \edef\@glo@label{\glsdetoklabel{#1}}%
%    \end{macrocode}
% \changes{3.12a}{2013-10-16}{added \cs{glslabel}}
% Provide a means for user defined keys to reference the label:
%    \begin{macrocode}
    \let\glslabel\@glo@label
%    \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
    \let\@glo@desc\@glsnodesc
%    \end{macrocode}
% \changes{1.12}{2008 Mar 8}{descriptionplural support added}
%    \begin{macrocode}
    \let\@glo@descplural\@gls@default@value
%    \end{macrocode}
%    \begin{macrocode}
    \let\@glo@type\@gls@default@value
    \let\@glo@symbol\@gls@default@value
%    \end{macrocode}
% \changes{1.12}{2008 Mar 8}{symbolplural support added}
%    \begin{macrocode}
    \let\@glo@symbolplural\@gls@default@value
%    \end{macrocode}
%    \begin{macrocode}
    \let\@glo@text\@gls@default@value
%    \end{macrocode}
%    \begin{macrocode}
    \let\@glo@plural\@gls@default@value
%    \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}
%\changes{3.10a}{2013-10-13}{Changed to using \cs{@gls@default@value}}
%    \begin{macrocode}
    \let\@glo@first\@gls@default@value
%    \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\@gls@default@value
%    \end{macrocode}
% Set the default sort:
%\changes{3.10a}{2013-10-13}{Changed to using \cs{@gls@default@value}}
%\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 \cs{@glsdefaultsort}}
%    \begin{macrocode}
    \let\@glo@sort\@gls@default@value
%    \end{macrocode}
% Set the default counter:
%    \begin{macrocode}
    \let\@glo@counter\@gls@default@value
%    \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}
%\changes{3.14a}{2013-11-12}{added check for existence of default glossary}
% Check there is a default glossary. 
%    \begin{macrocode}
    \ifundef\glsdefaulttype
    {%
       \PackageError{glossaries}%
       {No default glossary type (have you used `nomain'?)}%
       {If you use package option `nomain' you must define
        a new glossary before you can define entries}%
    }%
    {}%
%    \end{macrocode}
% Assign type. This must be fully expandable
%\changes{4.03}{2014-01-20}{replaced \#1 with \cs{@glo@label}}
%    \begin{macrocode}
    \gls@assign@field{\glsdefaulttype}{\@glo@label}{type}{\@glo@type}%
    \edef\@glo@type{\glsentrytype{\@glo@label}}%
%    \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}%
    }%
    {%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{added check for ignored glossary}
% Check if it's an ignored glossary
%    \begin{macrocode}
      \ifignoredglossary\@glo@type
      {%
%    \end{macrocode}
% The description may be omitted for an entry in an ignored
% glossary.
%    \begin{macrocode}
        \ifx\@glo@desc\@glsnodesc
          \let\@glo@desc\@empty
        \fi
      }%
      {%
      }%
      \protected@edef\@glolist@{\csname glolist@\@glo@type\endcsname}%
      \expandafter\xdef\csname glolist@\@glo@type\endcsname{%
        \@glolist@{\@glo@label},}%
    }%
%    \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@\@glo@label @parent\endcsname{}%
    \else
%    \end{macrocode}
% Has a parent. Check to ensure this entry isn't its own parent.
%\changes{4.03}{2014-01-20}{replaced \cs{ifthenelse} with
%\cs{ifdefequal}}
%    \begin{macrocode}
      \ifdefequal\@glo@label\@glo@parent%
      {%
        \PackageError{glossaries}{Entry `\@glo@label' can't be its own parent}{}%
        \def\@glo@parent{}%
        \expandafter\gdef\csname glo@\@glo@label @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@\@glo@label @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\@gls@default@value
              \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 `\@glo@label' - parent doesn't exist%
          }%
          {%
            Parent entries must be defined before their children%
          }%
          \def\@glo@parent{}%
          \expandafter\gdef\csname glo@\@glo@label @parent\endcsname{}%
        }%
      }%
    \fi
%    \end{macrocode}
% Set the level for this entry
%    \begin{macrocode}
    \expandafter\xdef\csname glo@\@glo@label @level\endcsname{\number\gls@level}%
%    \end{macrocode}
% Define commands associated with this entry:
%    \begin{macrocode}
    \gls@assign@field{\@glo@name}{\@glo@label}{sortvalue}{\@glo@sort}%
    \letcs\@glo@sort{glo@\@glo@label @sortvalue}%
    \gls@assign@field{\@glo@name}{\@glo@label}{text}{\@glo@text}%
    \expandafter\gls@assign@field\expandafter
       {\csname glo@\@glo@label @text\endcsname\glspluralsuffix}%
       {\@glo@label}{plural}{\@glo@plural}%
    \expandafter\gls@assign@field\expandafter
       {\csname glo@\@glo@label @text\endcsname}%
       {\@glo@label}{first}{\@glo@first}%
%    \end{macrocode}
%\changes{3.14a}{2013-11-12}{set the default for firstplural to be the value
%of plural}
%\changes{4.0}{2013-11-14}{added check for first key}
% If \gloskey{first} has been specified, make the default by appending
% \cs{glspluralsuffix}, otherwise make the default the value of the 
% \gloskey{plural} key.
%    \begin{macrocode}
    \ifx\@glo@first\@gls@default@value
      \expandafter\gls@assign@field\expandafter
         {\csname glo@\@glo@label @plural\endcsname}%
         {\@glo@label}{firstpl}{\@glo@firstplural}%
    \else
      \expandafter\gls@assign@field\expandafter
         {\csname glo@\@glo@label @first\endcsname\glspluralsuffix}%
         {\@glo@label}{firstpl}{\@glo@firstplural}%
    \fi
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{Fixed default counter if none supplied}
%    \begin{macrocode}
    \ifcsundef{@glotype@\@glo@type @counter}%
    {%
      \def\@glo@defaultcounter{\glscounter}%
    }%
    {%
      \letcs\@glo@defaultcounter{@glotype@\@glo@type @counter}%
    }%
    \gls@assign@field{\@glo@defaultcounter}{\@glo@label}{counter}{\@glo@counter}%
    \gls@assign@field{}{\@glo@label}{useri}{\@glo@useri}%
    \gls@assign@field{}{\@glo@label}{userii}{\@glo@userii}%
    \gls@assign@field{}{\@glo@label}{useriii}{\@glo@useriii}%
    \gls@assign@field{}{\@glo@label}{useriv}{\@glo@useriv}%
    \gls@assign@field{}{\@glo@label}{userv}{\@glo@userv}%
    \gls@assign@field{}{\@glo@label}{uservi}{\@glo@uservi}%
    \gls@assign@field{}{\@glo@label}{short}{\@glo@short}%
    \gls@assign@field{}{\@glo@label}{shortpl}{\@glo@shortpl}%
    \gls@assign@field{}{\@glo@label}{long}{\@glo@long}%
    \gls@assign@field{}{\@glo@label}{longpl}{\@glo@longpl}%
    \ifx\@glo@name\@glsnoname
      \@glsnoname
      \let\@gloname\@gls@default@value
    \fi
    \gls@assign@field{}{\@glo@label}{name}{\@glo@name}%
%    \end{macrocode}
%\changes{3.02}{2012/05/21}{added numberlist element}
% Set default numberlist if not defined:
%    \begin{macrocode}
    \ifcsundef{glo@\@glo@label @numberlist}%
    {%
      \csxdef{glo@\@glo@label @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 \cs{@glo@first} in description}%
%    \begin{macrocode}
    \def\@glo@@desc{\@glo@first}%
    \ifx\@glo@desc\@glo@@desc
      \let\@glo@desc\@glo@first
    \fi
    \ifx\@glo@desc\@glsnodesc
      \@glsnodesc
      \let\@glodesc\@gls@default@value
    \fi
    \gls@assign@desc{\@glo@label}%
%    \end{macrocode}
%\changes{1.18}{2009 January 14}{moved sort sanitization to
% \cs{newglossaryentry}}
%\changes{3.0}{2011/04/02}{added \cs{@gls@defsort}}
% Set the sort key for this entry:
%    \begin{macrocode}
    \@gls@defsort{\@glo@type}{\@glo@label}%
%    \end{macrocode}
%\changes{1.15}{2008 August 15}{check for \cs{@glo@text} in symbol}%
%    \begin{macrocode}
    \def\@glo@@symbol{\@glo@text}%
    \ifx\@glo@symbol\@glo@@symbol
      \let\@glo@symbol\@glo@text
    \fi
    \gls@assign@field{\relax}{\@glo@label}{symbol}{\@glo@symbol}%
    \expandafter
      \gls@assign@field\expandafter
      {\csname glo@\@glo@label @symbol\endcsname}
      {\@glo@label}{symbolplural}{\@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\xdef\csname glo@\@glo@label @flagfalse\endcsname{%
      \noexpand\global
        \noexpand\let\expandafter\noexpand
          \csname ifglo@\@glo@label @flag\endcsname\noexpand\iffalse
    }%
    \expandafter\xdef\csname glo@\@glo@label @flagtrue\endcsname{%
      \noexpand\global
        \noexpand\let\expandafter\noexpand
          \csname ifglo@\@glo@label @flag\endcsname\noexpand\iftrue
    }%
    \csname glo@\@glo@label @flagfalse\endcsname
%    \end{macrocode}
% Sort out any cross-referencing if required.
%\changes{4.04}{2014-03-06}{replaced \cs{ifx} with \cs{ifdefvoid}}
%    \begin{macrocode}
    \ifdefvoid\@glo@see
    {}%
    {%
      \protected@edef\@do@glssee{%
        \noexpand\@gls@fixbraces\noexpand\@glo@list\@glo@see
          \noexpand\@nil
        \noexpand\expandafter\noexpand\@glssee\noexpand\@glo@list{\@glo@label}}%
      \@do@glssee
    }%
%    \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}
  \ifignoredglossary\@glo@type
  {%
    \csdef{glo@\@glo@label @index}{}%
  }
  {%
    \do@glo@storeentry{\@glo@label}%
  }%
%    \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
% \cs{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.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glsmoveentry}[2]{%
  \edef\@glo@thislabel{\glsdetoklabel{#1}}%
  \edef\glo@type{\csname glo@\@glo@thislabel @type\endcsname}%
  \def\glo@list{,}%
  \forglsentries[\glo@type]{\glo@label}%
   {%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{replaced \cs{ifthenelse} with
%\cs{ifdefequal}}
%    \begin{macrocode}
     \ifdefequal\@glo@thislabel\glo@label
       {}{\eappto\glo@list{\glo@label,}}%
   }%
  \cslet{glolist@\glo@type}{\glo@list}%
  \csdef{glo@\@glo@thislabel @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}
%\changes{3.08a}{2013-09-28}{switched to \cs{glossentry}}
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@glossaryentryfield}{\string\\glossentry}
\else
  \newcommand*{\@glossaryentryfield}{\string\glossentry}
\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}
%\changes{3.08a}{2013-09-28}{switched to \cs{subglossentry}}
%    \begin{macrocode}
\ifglsxindy
  \newcommand*{\@glossarysubentryfield}{%
    \string\\subglossentry}
\else
  \newcommand*{\@glossarysubentryfield}{%
    \string\subglossentry}
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@storeentry}
%\begin{definition}
%\cs{@glo@storeentry}\marg{label}
%\end{definition}
%\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 (should already have been
% de-tok'ed if required).
% The result is stored in \cs{glo@}\meta{label}"@index", 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}
% Escape makeindex/xindy special characters in the label:
%    \begin{macrocode}
  \edef\@glo@esclabel{#1}%
  \@gls@checkmkidxchars\@glo@esclabel
%    \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.
%\changes{3.08a}{2013-09-28}{no longer need to check for special characters
%in any of the fields other than sort}
% 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
%\changes{3.08a}{2013-09-28}{updated for \cs{glossentry}}
%    \begin{macrocode}
      \expandafter\protected@xdef\csname glo@#1@index\endcsname{%
       (\string"\@glo@sort\string" %
       \string"\@glo@prefix\@glossaryentryfield{\@glo@esclabel}\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}{\@glo@esclabel}\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{\@glo@esclabel}%
      }%
    \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}{\@glo@esclabel}%
      }%
    \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, but first we need to
% know if we're in \sty{amsmath}'s \env{align} environment's
% measuring pass.
%
%\begin{macro}{\gls@ifnotmeasuring}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifpackageloaded{amsmath}%
  {\let\gls@ifnotmeasuring\@gls@ifnotmeasuring}%
  {}%
}
\newcommand*{\@gls@ifnotmeasuring}[1]{%
  \ifmeasuring@
  \else
    #1%
  \fi
}
\newcommand*\gls@ifnotmeasuring[1]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsreset}
% 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.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glsreset}[1]{%
  \gls@ifnotmeasuring
  {%
    \glsdoifexists{#1}%
    {%
       \expandafter\global\csname glo@\glsdetoklabel{#1}@flagfalse\endcsname
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslocalreset}
% As above, but with only a local effect:
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glslocalreset}[1]{%
  \gls@ifnotmeasuring
  {%
    \glsdoifexists{#1}%
    {%
       \expandafter\let\csname ifglo@\glsdetoklabel{#1}@flag\endcsname\iffalse
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsunset}
% 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.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glsunset}[1]{%
  \gls@ifnotmeasuring
  {%
    \glsdoifexists{#1}%
    {%
      \expandafter\global\csname glo@\glsdetoklabel{#1}@flagtrue\endcsname
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslocalunset}
% As above, but with only a local effect:
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glslocalunset}[1]{%
  \gls@ifnotmeasuring
  {%
    \glsdoifexists{#1}%
    {%
      \expandafter\let\csname ifglo@\glsdetoklabel{#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 \cs{glstextformat}}%
%\begin{macro}{\glstextformat}
%    \begin{macrocode}
\newcommand*{\glstextformat}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryfmt}
% As from version 3.11a, the way in which an entry is displayed is now
% governed by \cs{glsentryfmt}. This doesn't take any arguments. The
% required information is set by commands like \cs{gls}.
% To ensure backward compatibility, the default use the old
% \cs{glsdisplay} and \cs{glsdisplayfirst} style of commands
%    \begin{macrocode}
\newcommand*{\glsentryfmt}{%
  \@@gls@default@entryfmt\glsdisplayfirst\glsdisplay
}
%    \end{macrocode}
% Format that provides backwards compatibility:
%    \begin{macrocode}
\newcommand*{\@@gls@default@entryfmt}[2]{%
  \ifdefempty\glscustomtext
  {%
    \glsifplural
    {%
%    \end{macrocode}
% Plural form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          #2{\glsentryplural{\glslabel}}%
            {\glsentrydescplural{\glslabel}}%
            {\glsentrysymbolplural{\glslabel}}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsentryfirstplural{\glslabel}}%
            {\glsentrydescplural{\glslabel}}%
            {\glsentrysymbolplural{\glslabel}}{\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use. (Expansion was used in version 3.07 and below
% in case the name wasn't the first thing to be displayed, but now
% the user can sort out the upper casing in \ics{defglsentryfmt},
% which avoids the issues caused by fragile commands.)
%    \begin{macrocode}
          \ifbool{glscompatible-3.07}%
          {%
            \protected@edef\@glo@etext{%
              #2{\glsentryplural{\glslabel}}%
                {\glsentrydescplural{\glslabel}}%
                {\glsentrysymbolplural{\glslabel}}{\glsinsert}}%
            \xmakefirstuc\@glo@etext
          }%
          {%
            #2{\Glsentryplural{\glslabel}}%
              {\glsentrydescplural{\glslabel}}%
              {\glsentrysymbolplural{\glslabel}}{\glsinsert}%
          }%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \ifbool{glscompatible-3.07}%
          {%
            \protected@edef\@glo@etext{%
              #1{\glsentryfirstplural{\glslabel}}%
                {\glsentrydescplural{\glslabel}}%
                {\glsentrysymbolplural{\glslabel}}{\glsinsert}}%
            \xmakefirstuc\@glo@etext
          }%
          {%
            #1{\Glsentryfirstplural{\glslabel}}%
              {\glsentrydescplural{\glslabel}}%
              {\glsentrysymbolplural{\glslabel}}{\glsinsert}%
          }%
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \mfirstucMakeUppercase{#2{\glsentryplural{\glslabel}}%
            {\glsentrydescplural{\glslabel}}%
            {\glsentrysymbolplural{\glslabel}}{\glsinsert}}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \mfirstucMakeUppercase{#1{\glsentryfirstplural{\glslabel}}%
            {\glsentrydescplural{\glslabel}}%
            {\glsentrysymbolplural{\glslabel}}{\glsinsert}}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          #2{\glsentrytext{\glslabel}}%
            {\glsentrydesc{\glslabel}}%
            {\glsentrysymbol{\glslabel}}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsentryfirst{\glslabel}}%
            {\glsentrydesc{\glslabel}}%
            {\glsentrysymbol{\glslabel}}{\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \ifbool{glscompatible-3.07}%
          {%
            \protected@edef\@glo@etext{%
              #2{\glsentrytext{\glslabel}}%
                {\glsentrydesc{\glslabel}}%
                {\glsentrysymbol{\glslabel}}{\glsinsert}}%
            \xmakefirstuc\@glo@etext
          }%
          {%
            #2{\Glsentrytext{\glslabel}}%
              {\glsentrydesc{\glslabel}}%
              {\glsentrysymbol{\glslabel}}{\glsinsert}%
          }%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \ifbool{glscompatible-3.07}%
          {%
            \protected@edef\@glo@etext{%
              #1{\glsentryfirst{\glslabel}}%
                {\glsentrydesc{\glslabel}}%
                {\glsentrysymbol{\glslabel}}{\glsinsert}}%
              \xmakefirstuc\@glo@etext
          }%
          {%
            #1{\Glsentryfirst{\glslabel}}%
              {\glsentrydesc{\glslabel}}%
              {\glsentrysymbol{\glslabel}}{\glsinsert}%
          }%
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \mfirstucMakeUppercase{#2{\glsentrytext{\glslabel}}%
            {\glsentrydesc{\glslabel}}%
            {\glsentrysymbol{\glslabel}}{\glsinsert}}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \mfirstucMakeUppercase{#1{\glsentryfirst{\glslabel}}%
            {\glsentrydesc{\glslabel}}%
            {\glsentrysymbol{\glslabel}}{\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Custom text provided in \cs{glsdisp}
%    \begin{macrocode}
    \ifglsused{\glslabel}%
    {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
      #2{\glscustomtext}%
        {\glsentrydesc{\glslabel}}%
        {\glsentrysymbol{\glslabel}}{}%
    }%
    {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
      #1{\glscustomtext}%
        {\glsentrydesc{\glslabel}}%
        {\glsentrysymbol{\glslabel}}{}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgenentryfmt}
% Define a generic format that just uses the first, text, plural or
% first plural keys (or the custom text) with the insert text appended.
%\changes{3.11a}{2013-10-15}{new}
%    \begin{macrocode}
\newcommand*{\glsgenentryfmt}{%
  \ifdefempty\glscustomtext
  {%
    \glsifplural
    {%
%    \end{macrocode}
% Plural form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \glsentryplural{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsentryfirstplural{\glslabel}\glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use.
%    \begin{macrocode}
           \Glsentryplural{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
           \Glsentryfirstplural{\glslabel}\glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \mfirstucMakeUppercase
             {\glsentryplural{\glslabel}\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \mfirstucMakeUppercase
             {\glsentryfirstplural{\glslabel}\glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \glsentrytext{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsentryfirst{\glslabel}\glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
           \Glsentrytext{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \Glsentryfirst{\glslabel}\glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \mfirstucMakeUppercase{\glsentrytext{\glslabel}\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \mfirstucMakeUppercase{\glsentryfirst{\glslabel}\glsinsert}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Custom text provided in \cs{glsdisp}. (The insert is most likely
% to be empty at this point.)
%    \begin{macrocode}
    \glscustomtext\glsinsert
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgenacfmt}
%\changes{4.02}{2013-12-05}{new}
% Define a generic acronym format that uses the \gloskey{long} and 
% \gloskey{short} keys (or their plurals) and \ics{acrfullformat},
% \ics{firstacronymfont} and \ics{acronymfont}.
%    \begin{macrocode}
\newcommand*{\glsgenacfmt}{%
  \ifdefempty\glscustomtext
  {%
    \ifglsused\glslabel
    {%
%    \end{macrocode}
% Subsequent use:
%    \begin{macrocode}
      \glsifplural
      {%
%    \end{macrocode}
% Subsequent plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Subsequent plural form, don't adjust case:
%    \begin{macrocode}
          \acronymfont{\glsentryshortpl{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, make first letter upper case:
%    \begin{macrocode}
          \acronymfont{\Glsentryshortpl{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\acronymfont{\glsentryshortpl{\glslabel}}\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Subsequent singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Subsequent singular form, don't adjust case:
%    \begin{macrocode}
          \acronymfont{\glsentryshort{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, make first letter upper case:
%    \begin{macrocode}
          \acronymfont{\Glsentryshort{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\acronymfont{\glsentryshort{\glslabel}}\glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% First use:
%    \begin{macrocode}
      \glsifplural
      {%
%    \end{macrocode}
% First use plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% First use plural form, don't adjust case:
%    \begin{macrocode}
          \genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, make first letter upper case:
%    \begin{macrocode}
          \Genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\genplacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
      {%
%    \end{macrocode}
% First use singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% First use singular form, don't adjust case:
%    \begin{macrocode}
          \genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, make first letter upper case:
%    \begin{macrocode}
          \Genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
           {\genacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% User supplied text.
%    \begin{macrocode}
    \glscustomtext
  }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\genacrfullformat}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{genacrfullformat}\marg{label}\marg{insert}
%\end{definition}
% The full format used by \cs{glsgenacfmt} (singular).
%    \begin{macrocode}
\newcommand*{\genacrfullformat}[2]{%
   \glsentrylong{#1}#2\space
   (\protect\firstacronymfont{\glsentryshort{#1}})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Genacrfullformat}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{Genacrfullformat}\marg{label}\marg{insert}
%\end{definition}
% As above but makes the first letter upper case.
%    \begin{macrocode}
\newcommand*{\Genacrfullformat}[2]{%
  \protected@edef\gls@text{\genacrfullformat{#1}{#2}}%
  \xmakefirstuc\gls@text
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\genplacrfullformat}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{genplacrfullformat}\marg{label}\marg{insert}
%\end{definition}
% The full format used by \cs{glsgenacfmt} (plural).
%    \begin{macrocode}
\newcommand*{\genplacrfullformat}[2]{%
   \glsentrylongpl{#1}#2\space
   (\protect\firstacronymfont{\glsentryshortpl{#1}})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Genplacrfullformat}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{Genplacrfullformat}\marg{label}\marg{insert}
%\end{definition}
% As above but makes the first letter upper case.
%    \begin{macrocode}
\newcommand*{\Genplacrfullformat}[2]{%
  \protected@edef\gls@text{\genplacrfullformat{#1}{#2}}%
  \xmakefirstuc\gls@text
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdisplayfirst}
% Deprecated. Kept for backward compatibility.
%\changes{3.11a}{2013-10-15}{obsoleted}
%    \begin{macrocode}
\newcommand*{\glsdisplayfirst}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdisplay}
% Deprecated. Kept for backward compatibility.
%\changes{3.11a}{2013-10-15}{obsoleted}
%    \begin{macrocode}
\newcommand*{\glsdisplay}[4]{#1#4}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\defglsdisplay}
%\changes{3.11a}{2013-10-15}{obsoleted}
% Deprecated. Kept for backward compatibility.
%    \begin{macrocode}
\newcommand*{\defglsdisplay}[2][\glsdefaulttype]{%
  \GlossariesWarning{\string\defglsdisplay\space is now obsolete.^^J
  Use \string\defglsentryfmt\space instead}%
  \expandafter\def\csname gls@#1@display\endcsname##1##2##3##4{#2}%
  \edef\@gls@doentrydef{%
    \noexpand\defglsentryfmt[#1]{%
      \noexpand\ifcsdef{gls@#1@displayfirst}%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}%
          {\noexpand\csuse{gls@#1@display}}%
      }%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\glsdisplayfirst}%
          {\noexpand\csuse{gls@#1@display}}%
      }%
    }%
  }%
  \@gls@doentrydef
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\defglsdisplayfirst}
% Deprecated. Kept for backward compatibility.
%\changes{3.11a}{2013-10-15}{obsoleted}
%    \begin{macrocode}
\newcommand*{\defglsdisplayfirst}[2][\glsdefaulttype]{%
  \GlossariesWarning{\string\defglsdisplayfirst\space is now obsolete.^^J
  Use \string\defglsentryfmt\space instead}%
  \expandafter\def\csname gls@#1@displayfirst\endcsname##1##2##3##4{#2}%
  \edef\@gls@doentrydef{%
    \noexpand\defglsentryfmt[#1]{%
      \noexpand\ifcsdef{gls@#1@display}%
      {%
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}%
          {\noexpand\csuse{gls@#1@display}}%
      }%
      {%
%    \end{macrocode}
%\changes{4.04}{2014-03-06}{fixed unwanted space}
%    \begin{macrocode}
        \noexpand\@@gls@default@entryfmt
          {\noexpand\csuse{gls@#1@displayfirst}}%
          {\noexpand\glsdisplay}%
      }%
    }%
  }%
  \@gls@doentrydef
}
%    \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}
% and \cs{glsdisp},
% 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{defentryfmt}). 
% 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{4.08}{2014-07-30}{explicitly initialise hyper key}
% Initialise hyper key.
%    \begin{macrocode}
\ifdef{\hyperlink}{\KV@glslink@hypertrue}{\KV@glslink@hyperfalse}
%    \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}
%
% The original \cs{glsifhyper} command isn't particularly useful
% as it makes more sense to check the actual hyperlink setting
% rather than testing whether the starred or unstarred version
% has been used. Therefore, as from version 4.08, \cs{glsifhyper}
% is deprecated in favour of \ics{glsifhyperon}. In case there is
% a particular need to know whether the starred or unstarred version
% was used, provide a new command that determines whether the
% *-version, +-version or unmodified version was used.
%\begin{definition}
%\cs{glslinkvar}\marg{unmodified case}\marg{star case}\marg{plus case}
%\end{definition}
%\begin{macro}{\glslinkvar}
%\changes{4.08}{2014-07-30}{new}
% Initialise to unmodified case.
%    \begin{macrocode}
\newcommand*{\glslinkvar}[3]{#1}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsifhyper}
% Now deprecated.
%\changes{4.08}{2014-07-30}{deprecated}
%    \begin{macrocode}
\newcommand*{\glsifhyper}[2]{%
 \glslinkvar{#1}{#2}{#1}%
 \GlossariesWarning{\string\glsifhyper\space is deprecated. Did
  you mean \string\glsifhyperon\space or \string\glslinkvar?}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@hyp@opt}
% Used by the commands such as \cs{glslink} to determine whether to
% modify the hyper option.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\@gls@hyp@opt}[1]{%
 \let\glslinkvar\@firstofthree
 \let\@gls@hyp@opt@cs#1\relax
 \@ifstar{\s@gls@hyp@opt}%
 {\@ifnextchar+{\@firstoftwo{\p@gls@hyp@opt}}{#1}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\s@gls@hyp@opt}
% Starred version
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\s@gls@hyp@opt}[1][]{%
 \let\glslinkvar\@secondofthree
 \@gls@hyp@opt@cs[hyper=false,#1]}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\p@gls@hyp@opt}
% Plus version
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\p@gls@hyp@opt}[1][]{%
 \let\glslinkvar\@thirdofthree
 \@gls@hyp@opt@cs[hyper=true,#1]}
%    \end{macrocode}
%\end{macro}
%
%Syntax:
%\begin{definition}
% \cs{glslink}\oarg{options}\marg{label}\marg{text}
%\end{definition}
% 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:
%\begin{definition}
% \cs{glslink*}\oarg{options}\marg{label}\marg{text}
%\end{definition}
% which is equivalent to 
% \cs{glslink}"[hyper=false,"\meta{options}"]"\marg{label}\marg{text}
%
% First determine which version is being used:
%\begin{macro}{\glslink}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glslink}{%
 \@gls@hyp@opt\@gls@@link
}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sgls@link}}
%\begin{macro}{\@gls@@link}
%\changes{2.03}{2009 Sep 23}{new}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
    \@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@checkfirsthyper}
% Check for first use and switch off \gloskey[glslink]{hyper} key
% if hyperlink not wanted. (Should be off if first use and
% hyper=false is on or if first use and both the entry is in an acronym
% list and the acrfootnote setting is on.)
% This assumes the glossary type is stored in \cs{glstype} and the
% label is stored in \cs{glslabel}.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\@gls@link@checkfirsthyper}{%
  \ifglsused{\glslabel}%
  {%
  }%
  {%
    \gls@checkisacronymlist\glstype
    \ifglshyperfirst
      \if@glsisacronymlist
        \ifglsacrfootnote
           \KV@glslink@hyperfalse
        \fi
      \fi
    \else
       \KV@glslink@hyperfalse
    \fi
  }%
%    \end{macrocode}
% Allow user to hook into this
%    \begin{macrocode}
  \glslinkcheckfirsthyperhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslinkcheckfirsthyperhook}
% Allow used to hook into the \cs{\@gls@link@checkfirsthyper} macro
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\glslinkcheckfirsthyperhook}{}
%    \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 \cs{glslabel}}
%    \begin{macrocode}
\def\@gls@link[#1]#2#3{%
%    \end{macrocode}
%\changes{2.03}{2009 Sep 23}{Moved entry existence check to 
% avoid duplicate code}
% Inserting \cs{leavevmode} suggested by Donald~Arseneau (avoids
% problem with tabularx).
%\changes{2.03}{2009 Sep 23}{added \cs{leavevmode}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
    \leavevmode
    \edef\glslabel{\glsdetoklabel{#2}}%
%    \end{macrocode}
% Save options in \cs{@gls@link@opts} and label in \cs{@gls@link@label}
%\changes{4.03}{2014-01-20}{moved \cs{@gls@link@opts} and
%\cs{@gls@link@label} to \cs{@gls@link}}
%    \begin{macrocode}
    \def\@gls@link@opts{#1}%
    \let\@gls@link@label\glslabel
%    \end{macrocode}
%    \begin{macrocode}
    \def\@glsnumberformat{glsnumberformat}%
    \edef\@gls@counter{\csname glo@\glslabel @counter\endcsname}%
%    \end{macrocode}
%\changes{3.05}{2013-04-21}{added check for ``nohypertypes''}%
%\changes{3.07}{2013-07-05}{fixed bug that failed to find entry in list}%
% If this is in one of the ``nohypertypes'' glossaries, suppress the
% hyperlink by default
%\changes{4.08}{2014-07-30}{renamed \cs{gls@type} to \cs{glstype}}
%    \begin{macrocode}
    \edef\glstype{\csname glo@\glslabel @type\endcsname}%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{removed redundancy}
% Save original setting
%    \begin{macrocode}
    \let\org@ifKV@glslink@hyper\ifKV@glslink@hyper
%    \end{macrocode}
% Switch off hyper setting if the glossary type has been identified
% in nohyperlist.
%    \begin{macrocode}
    \expandafter\DTLifinlist\expandafter
      {\glstype}{\@gls@nohyperlist}%
    {%
       \KV@glslink@hyperfalse
    }%
    {%
    }%
%    \end{macrocode}
% Macros must set this before calling \cs{@gls@link}. The
% commands that check the first use flag should set this to
% \cs{@gls@link@checkfirsthyper} otherwise it should be set to
% \cs{relax}.
%    \begin{macrocode}
    \do@gls@link@checkfirsthyper
    \setkeys{glslink}{#1}%
%    \end{macrocode}
% Define \cs{glsifhyperon}
%    \begin{macrocode}
    \ifKV@glslink@hyper
      \let\glsifhyperon\@firstoftwo
    \else
      \let\glsifhyperon\@secondoftwo
    \fi
%    \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{\glslabel}%
%    \end{macrocode}
%\changes{2.01}{2009 May 30}{moved \cs{@do@wrglossary} before term is displayed
% to prevent unwanted whatsit}
% (De-tok'ing done by \cs{@@do@wrglossary})
%    \begin{macrocode}
    \@do@wrglossary{#2}%
    \ifKV@glslink@hyper
      \@glslink{\glolinkprefix\glslabel}{\glstextformat{#3}}%
    \else
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{removed \cs{relax}}
%    \begin{macrocode}
      \glstextformat{#3}%
    \fi
%    \end{macrocode}
% Restore original setting
%    \begin{macrocode}
    \let\ifKV@glslink@hyper\org@ifKV@glslink@hyper
}
%    \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're 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}{\glsdohypertarget}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newlength\gls@tmplen
\newcommand*{\glsdohypertarget}[2]{%
  \settoheight{\gls@tmplen}{#2}%
  \raisebox{\gls@tmplen}{\hypertarget{#1}{}}#2%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsdohyperlink}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newcommand*{\glsdohyperlink}[2]{\hyperlink{#1}{#2}}
%    \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}%
{%
  \let\@glslink\@secondoftwo
}%
{%
  \let\@glslink\glsdohyperlink
}
%    \end{macrocode}
%\end{macro}
%\changes{1.12}{2008 Mar 8}{added check for \cs{hypertarget} separate
% to \cs{hyperlink} (memoir defines \cs{hyperlink} but not
% \cs{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}
\ifcsundef{hypertarget}%
{%
  \let\@glstarget\@secondoftwo
}%
{%
  \let\@glstarget\glsdohypertarget
}
%    \end{macrocode}
%\end{macro}
%
% Glossary hyperlinks can be disabled using \cs{glsdisablehyper}
% (effect can be localised):
%\begin{macro}{\glsdisablehyper}
%\changes{4.08}{2014-07-30}{added \cs{KV@glslink@hyperfalse}
% to definition}
%    \begin{macrocode}
\newcommand{\glsdisablehyper}{%
  \KV@glslink@hyperfalse
  \let\@glslink\@secondoftwo
  \let\@glstarget\@secondoftwo
}
%    \end{macrocode}
%\end{macro}
% Glossary hyperlinks can be enabled using \cs{glsenablehyper}
% (effect can be localised):
%\begin{macro}{\glsenablehyper}
%\changes{4.08}{2014-07-30}{added \cs{KV@glslink@hypertrue}
% to definition}
%    \begin{macrocode}
\newcommand{\glsenablehyper}{%
 \KV@glslink@hypertrue
 \let\@glslink\glsdohyperlink
 \let\@glstarget\glsdohypertarget
}
%    \end{macrocode}
%\end{macro}
%
%
% Provide some convenience commands if not already defined:
%\changes{4.08}{2014-07-30}{removed \cs{@thirdofthree} (defined in kernel)}
%    \begin{macrocode}
\providecommand{\@firstofthree}[3]{#1}
\providecommand{\@secondofthree}[3]{#2}
%    \end{macrocode}
%
%Syntax:
%\begin{definition}
% \cs{gls}\oarg{options}\marg{label}\oarg{insert text}
%\end{definition}
% 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 which version is being used:
%\begin{macro}{\gls}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\gls}{\@gls@hyp@opt\@gls}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sgls}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{add \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
%    \begin{macrocode}
    \@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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Gls}{\@gls@hyp@opt\@Gls}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGls}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
%\changes{3.11a}{2013-10-15}{removed \cs{makefirstuc} (now dealt
%with in \cs{glsentryfmt})}
%    \begin{macrocode}
    \@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 \ics{gls}, but the link
% text is converted to uppercase:
%\changes{3.01}{2011/04/12}{made robust}
%\begin{macro}{\GLS}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLS}{\@gls@hyp@opt\@GLS}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLS}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text}).
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
%\changes{3.11a}{2013-10-15}{removed \cs{MakeUppercase} (now moved
%to \cs{glsentryfmt})}
%    \begin{macrocode}
    \@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{gls} except
% it uses the plural form.
%\begin{macro}{\glspl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glspl}{\@gls@hyp@opt\@glspl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglspl}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{1.12}{2008 Mar 8}{now uses \cs{glsentrydescplural} and
% \cs{glsentrysymbolplural} instead of \cs{glsentrydesc} and
% \cs{glsentrysymbol}}
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
    \@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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glspl}{\@gls@hyp@opt\@Glspl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlspl}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% 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 \cs{glsentrydescplural} and
% \cs{glsentrysymbolplural} instead of \cs{glsentrydesc} and
% \cs{glsentrysymbol}}
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
%\changes{3.11a}{2013-10-15}{removed \cs{makefirstuc} (now dealt
%with in \cs{glsentryfmt})}
%    \begin{macrocode}
    \@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 like \ics{glspl} except that all the
% link text is converted to uppercase.
%\begin{macro}{\GLSpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSpl}{\@gls@hyp@opt\@GLSpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSpl}}
% 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}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glscustomtext\@empty
    \def\glsinsert{#3}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{1.12}{2008 Mar 8}{now uses \cs{glsentrydescplural} and
% \cs{glsentrysymbolplural} instead of \cs{glsentrydesc} and
% \cs{glsentrysymbol}}
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
%\changes{3.11a}{2013-10-15}{removed \cs{MakeUppercase} as now dealt
%with in \cs{glsentryfmt}}
%    \begin{macrocode}
    \@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}
%
%\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:
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsdisp}{\@gls@hyp@opt\@glsdisp}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsdisp}}
% 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}
    \let\do@gls@link@checkfirsthyper\@gls@link@checkfirsthyper
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%\changes{3.11a}{2013-10-15}{add \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glscustomtext} and \cs{glsinsert}}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \def\glscustomtext{#3}%
    \def\glsinsert{}%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved check for first use to
%\cs{@gls@link}}
% Determine what the link text should be (this is stored in 
% \cs{@glo@text})
%\changes{3.11a}{2013-10-15}{change to using \cs{glsentryfmt} style
%commands}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \def\@glo@text{\csname gls@\glstype @entryfmt\endcsname}%
%    \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
%\cs{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}
    \@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}
%
%\begin{macro}{\@gls@field@link}
%\changes{4.03}{2014-01-20}{new}
%\changes{4.08}{2014-07-30}{added assignment of \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\newcommand{\@gls@field@link}[3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
    \@gls@link[#1]{#2}{#3}%
  }%
}
%    \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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glstext}{\@gls@hyp@opt\@glstext}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglstext}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentrytext}}
%    \begin{macrocode}
\def\@glstext@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentrytext{#2}#3}%
}
%    \end{macrocode}
%
% \cs{GLStext} behaves like \cs{glstext} except the text is converted
% to uppercase.
%\begin{macro}{\GLStext}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLStext}{\@gls@hyp@opt\@GLStext}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLStext}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%    \begin{macrocode}
\def\@GLStext@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentrytext{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glstext}{\@gls@hyp@opt\@Glstext}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlstext}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{Changed to just use \cs{Glsentrytext}}
%    \begin{macrocode}
\def\@Glstext@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentrytext{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsfirst}{\@gls@hyp@opt\@glsfirst}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsfirst}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryfirst}}
%    \begin{macrocode}
\def\@glsfirst@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryfirst{#2}#3}%
}
%    \end{macrocode}
%
% \cs{Glsfirst} behaves like \ics{glsfirst} except it displays the 
% first letter in uppercase.
%\begin{macro}{\Glsfirst}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsfirst}{\@gls@hyp@opt\@Glsfirst}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsfirst}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryfirst}}
%    \begin{macrocode}
\def\@Glsfirst@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryfirst{#2}#3}%
}
%    \end{macrocode}
%
% \cs{GLSfirst} behaves like \ics{Glsfirst} except it displays the 
% text in uppercase.
%\begin{macro}{\GLSfirst}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSfirst}{\@gls@hyp@opt\@GLSfirst}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSfirst}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryfirst}}
%    \begin{macrocode}
\def\@GLSfirst@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryfirst{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsplural}{\@gls@hyp@opt\@glsplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsplural}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryplural}}
%    \begin{macrocode}
\def\@glsplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryplural{#2}#3}%
}
%    \end{macrocode}
%
% \cs{Glsplural} behaves like \ics{glsplural} except that the first
% letter is converted to uppercase.
%\begin{macro}{\Glsplural}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsplural}{\@gls@hyp@opt\@Glsplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsplural}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryplural}}
%    \begin{macrocode}
\def\@Glsplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSplural}{\@gls@hyp@opt\@GLSplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSplural}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryplural}}
%    \begin{macrocode}
\def\@GLSplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsfirstplural}{\@gls@hyp@opt\@glsfirstplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsfirstplural}}
% 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentryfirstplural}}
%    \begin{macrocode}
\def\@glsfirstplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryfirstplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsfirstplural}{\@gls@hyp@opt\@Glsfirstplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsfirstplural}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{Glsentryfirstplural}}
%    \begin{macrocode}
\def\@Glsfirstplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryfirstplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSfirstplural}{\@gls@hyp@opt\@GLSfirstplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSfirstplural}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentryfirstplural}}
%    \begin{macrocode}
\def\@GLSfirstplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryfirstplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsname}{\@gls@hyp@opt\@glsname}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsname}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryname}}
%    \begin{macrocode}
\def\@glsname@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryname{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsname}{\@gls@hyp@opt\@Glsname}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsname}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryname}}
%    \begin{macrocode}
\def\@Glsname@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryname{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSname}{\@gls@hyp@opt\@GLSname}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSname}}
% Define 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryname}}
%    \begin{macrocode}
\def\@GLSname@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryname{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsdesc}{\@gls@hyp@opt\@glsdesc}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsdesc}}
% 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentrydesc}}
%    \begin{macrocode}
\def\@glsdesc@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentrydesc{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsdesc}{\@gls@hyp@opt\@Glsdesc}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsdesc}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentrydesc}}
%    \begin{macrocode}
\def\@Glsdesc@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentrydesc{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSdesc}{\@gls@hyp@opt\@GLSdesc}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSdesc}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentrydesc}}
%    \begin{macrocode}
\def\@GLSdesc@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentrydesc{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsdescplural}{\@gls@hyp@opt\@glsdescplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsdescplural}}
% Define 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentrydescplural}}
%    \begin{macrocode}
\def\@glsdescplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentrydescplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsdescplural}{\@gls@hyp@opt\@Glsdescplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsdescplural}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{Glsentrydescplural}}
%    \begin{macrocode}
\def\@Glsdescplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentrydescplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSdescplural}{\@gls@hyp@opt\@GLSdescplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSdescplural}}
% Define 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:
% \changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentrydescplural}}
%    \begin{macrocode}
\def\@GLSdescplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentrydescplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glssymbol}{\@gls@hyp@opt\@glssymbol}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglssymbol}}
% 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentrysymbol}}
%    \begin{macrocode}
\def\@glssymbol@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentrysymbol{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glssymbol}{\@gls@hyp@opt\@Glssymbol}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlssymbol}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentrysymbol}}
%    \begin{macrocode}
\def\@Glssymbol@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentrysymbol{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSsymbol}{\@gls@hyp@opt\@GLSsymbol}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSsymbol}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentrysymbol}}
%    \begin{macrocode}
\def\@GLSsymbol@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentrysymbol{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glssymbolplural}{\@gls@hyp@opt\@glssymbolplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglssymbolplural}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentrysymbolplural}}
%    \begin{macrocode}
\def\@glssymbolplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentrysymbolplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glssymbolplural}{\@gls@hyp@opt\@Glssymbolplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlssymbolplural}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{Glsentrysymbolplural}}
%    \begin{macrocode}
\def\@Glssymbolplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentrysymbolplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSsymbolplural}{\@gls@hyp@opt\@GLSsymbolplural}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSsymbolplural}}
% Define 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:
%\changes{1.13}{2008 May 10}{fixed bug that ignored 3rd parameter}
%\changes{3.11a}{2013-10-15}{changed to just use
%\cs{glsentrysymbolplural}}
%    \begin{macrocode}
\def\@GLSsymbolplural@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentrysymbolplural{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuseri}{\@gls@hyp@opt\@glsuseri}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuseri}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseri}}
%    \begin{macrocode}
\def\@glsuseri@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuseri{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseri}{\@gls@hyp@opt\@Glsuseri}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuseri}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuseri}}
%    \begin{macrocode}
\def\@Glsuseri@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuseri{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseri}{\@gls@hyp@opt\@GLSuseri}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuseri}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseri}}
%    \begin{macrocode}
\def\@GLSuseri@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuseri{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuserii}{\@gls@hyp@opt\@glsuserii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuserii}}
% 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuserii}}
%    \begin{macrocode}
\def\@glsuserii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuserii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuserii}{\@gls@hyp@opt\@Glsuserii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuserii}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuserii}}
%    \begin{macrocode}
\def\@Glsuserii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuserii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuserii}{\@gls@hyp@opt\@GLSuserii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuserii}}
% 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuserii}}
%    \begin{macrocode}
\def\@GLSuserii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuserii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuseriii}{\@gls@hyp@opt\@glsuseriii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuseriii}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseriii}}
%    \begin{macrocode}
\def\@glsuseriii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuseriii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseriii}{\@gls@hyp@opt\@Glsuseriii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuseriii}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuseriii}}
%    \begin{macrocode}
\def\@Glsuseriii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuseriii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseriii}{\@gls@hyp@opt\@GLSuseriii}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuseriii}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseriii}}
%    \begin{macrocode}
\def\@GLSuseriii@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuseriii{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuseriv}{\@gls@hyp@opt\@glsuseriv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuseriv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseriv}}
%    \begin{macrocode}
\def\@glsuseriv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuseriv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuseriv}{\@gls@hyp@opt\@Glsuseriv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuseriv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuseriv}}
%    \begin{macrocode}
\def\@Glsuseriv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuseriv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuseriv}{\@gls@hyp@opt\@GLSuseriv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuseriv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuseriv}}
%    \begin{macrocode}
\def\@GLSuseriv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuseriv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuserv}{\@gls@hyp@opt\@glsuserv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuserv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuserv}}
%    \begin{macrocode}
\def\@glsuserv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuserv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuserv}{\@gls@hyp@opt\@Glsuserv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuserv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuserv}}
%    \begin{macrocode}
\def\@Glsuserv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuserv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuserv}{\@gls@hyp@opt\@GLSuserv}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuserv}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuserv}}
%    \begin{macrocode}
\def\@GLSuserv@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuserv{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\glsuservi}{\@gls@hyp@opt\@glsuservi}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sglsuservi}}
% 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuservi}}
%    \begin{macrocode}
\def\@glsuservi@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\glsentryuservi{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Glsuservi}{\@gls@hyp@opt\@Glsuservi}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGlsuservi}}
% 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{Glsentryuservi}}
%    \begin{macrocode}
\def\@Glsuservi@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\Glsentryuservi{#2}#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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\GLSuservi}{\@gls@hyp@opt\@GLSuservi}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sGLSuservi}}
% Define 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:
%\changes{3.11a}{2013-10-15}{changed to just use \cs{glsentryuservi}}
%    \begin{macrocode}
\def\@GLSuservi@#1#2[#3]{%
  \@gls@field@link{#1}{#2}{\mfirstucMakeUppercase{\glsentryuservi{#2}#3}}%
}
%    \end{macrocode}
%
% Now deal with acronym related keys. First the short form:
%\begin{macro}{\acrshort}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrshort}{\@gls@hyp@opt\ns@acrshort}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sacrshort}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsentryshort{#2}}#3%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrshort}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrshort}{\@gls@hyp@opt\ns@Acrshort}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sAcrshort}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsentryshort{#2}}#3%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRshort}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRshort}{\@gls@hyp@opt\ns@ACRshort}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sACRshort}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsentryshort{#2}}#3}%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
% Short plural:
%\begin{macro}{\acrshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrshortpl}{\@gls@hyp@opt\ns@acrshortpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sacrshortpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsentryshortpl{#2}}#3%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrshortpl}{\@gls@hyp@opt\ns@Acrshortpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sAcrshortpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsentryshortpl{#2}}#3%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRshortpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRshortpl}{\@gls@hyp@opt\ns@ACRshortpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sACRshortpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsentryshortpl{#2}}#3}%
    }%
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\acrlong}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrlong}{\@gls@hyp@opt\ns@acrlong}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sacrlong}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \glsentrylong{#2}#3%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrlong}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrlong}{\@gls@hyp@opt\ns@Acrlong}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sAcrlong}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \Glsentrylong{#2}#3%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}.
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRlong}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRlong}{\@gls@hyp@opt\ns@ACRlong}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sACRlong}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\glsentrylong{#2}#3}%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}.
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
% Short plural:
%\begin{macro}{\acrlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrlongpl}{\@gls@hyp@opt\ns@acrlongpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sacrlongpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \glsentrylongpl{#2}#3%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}.
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\Acrlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrlongpl}{\@gls@hyp@opt\ns@Acrlongpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sAcrlongpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \Glsentrylongpl{#2}#3%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}.
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\@glo@type @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%
%\begin{macro}{\ACRlongpl}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRlongpl}{\@gls@hyp@opt\ns@ACRlongpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \cs{@sACRlongpl}}
% Define 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}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%    \begin{macrocode}
    \def\glslabel{#2}%
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
%    \end{macrocode}
%\changes{4.06}{2014-03-12}{added \cs{glsifhyper}}
% Bug fix v4.02 removed \cs{acronymfont} from \cs{glscustomtext}
% (\cs{acronymfont} only designed for short form).
% \changes{4.02}{2013-12-05}{Removed \cs{acronymfont}}
%    \begin{macrocode}
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\glsentrylongpl{#2}#3}%
    }%
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{moved \cs{glsifhyper}}
% Call \cs{@gls@link}.
% Note that \cs{@gls@link} sets \cs{glstype}.
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \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.
%
%\begin{macro}{\@gls@entry@field}
% Generic version.
%\changes{4.03}{2014-01-20}{new}
%\begin{definition}
%\cs{@gls@entry@field}\marg{label}\marg{field}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\@gls@entry@field}[2]{%
  \csname glo@\glsdetoklabel{#1}@#2\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsletentryfield}
%\changes{4.07}{2014-04-04}{new}
%\begin{definition}
%\cs{glsletentryfield}\marg{cs}\marg{label}\marg{field}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\glsletentryfield}[3]{%
  \letcs{#1}{glo@\glsdetoklabel{#2}@#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Gls@entry@field}
% Generic first letter uppercase version.
%\changes{4.03}{2014-01-20}{new}
%\begin{definition}
%\cs{@Gls@entry@field}\marg{label}\marg{field}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\@Gls@entry@field}[2]{%
  \letcs\@glo@text{glo@\glsdetoklabel{#1}@#2}%
  \ifdef\@glo@text
  {%
    \xmakefirstuc{\@glo@text}%
  }%
  {%
    \PackageError{glossaries}{Either glossary entry
     `\glsdetoklabel{#1}' doesn't exist or the field `#2'
     doesn't exist}{Check you have correctly spelt the entry
     label and the field name}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% 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]{\@gls@entry@field{#1}{name}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryname}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryname}[1]{%
  \@Gls@entryname{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Gls@entryname}
%\changes{4.10}{2014-08-27}{new}
% This is a workaround in the event that the user defies the warning
% in the manual about not using \cs{Glsname} or \cs{Glsentryname} with acronyms.
% First the default behaviour:
%    \begin{macrocode}
\newcommand*{\@Gls@entryname}[1]{%
  \@Gls@entry@field{#1}{name}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@Gls@acrentryname}
%\changes{4.10}{2014-08-27}{new}
% Now the behaviour when \cs{setacronymstyle} is used:
%    \begin{macrocode}
\newcommand*{\@Gls@acrentryname}[1]{%
  \ifglshaslong{#1}%
  {%
    \letcs\@glo@text{glo@\glsdetoklabel{#1}@name}%
    \expandafter\@gls@getbody\@glo@text{}\@nil
    \expandafter\ifx\@gls@body\glsentrylong\relax
      \expandafter\Glsentrylong\@gls@rest
    \else
      \expandafter\ifx\@gls@body\glsentryshort\relax
        \expandafter\Glsentryshort\@gls@rest
      \else
        \expandafter\ifx\@gls@body\acronymfont\relax
%    \end{macrocode}
% Temporarily make \cs{glsentryshort} behave like
% \cs{Glsentryshort}. (This is on the assumption that the argument
% of \cs{acronymfont} is \cs{glsentryshort}\marg{label}, as that's
% the behaviour of the predefined acronym styles.)
% This is scoped to localise the effect of the assignment.
%    \begin{macrocode}
         {%
            \let\glsentryshort\Glsentryshort
            \@glo@text
         }%
        \else
          \xmakefirstuc{\@glo@text}%
        \fi
      \fi
    \fi
  }%
  {%
%    \end{macrocode}
% Not an acronym
%    \begin{macrocode}
    \@Gls@entry@field{#1}{name}%
  }%
}
%    \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]{\@gls@entry@field{#1}{desc}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrydesc}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrydesc}[1]{%
  \@Gls@entry@field{#1}{desc}%
}
%    \end{macrocode}
%\end{macro}
% Plural form:
%\begin{macro}{\glsentrydescplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\glsentrydescplural}[1]{%
  \@gls@entry@field{#1}{descplural}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrydescplural}
%\changes{1.12}{2008 Mar 8}{New}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrydescplural}[1]{%
  \@Gls@entry@field{#1}{descplural}%
}
%    \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]{\@gls@entry@field{#1}{text}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrytext}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrytext}[1]{%
  \@Gls@entry@field{#1}{text}%
}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form:
%\begin{macro}{\glsentryplural}
%    \begin{macrocode}
\newcommand*{\glsentryplural}[1]{%
  \@gls@entry@field{#1}{plural}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryplural}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryplural}[1]{%
  \@Gls@entry@field{#1}{plural}%
}
%    \end{macrocode}
%\end{macro}
%
% Get the symbol associated with this entry. The argument
% is the label associated with the entry.
%\begin{macro}{\glsentrysymbol}
%    \begin{macrocode}
\newcommand*{\glsentrysymbol}[1]{%
  \@gls@entry@field{#1}{symbol}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrysymbol}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrysymbol}[1]{%
  \@Gls@entry@field{#1}{symbol}%
}
%    \end{macrocode}
%\end{macro}
% Plural form:
%\begin{macro}{\glsentrysymbolplural}
%\changes{1.12}{2008 Mar 8}{New}
%    \begin{macrocode}
\newcommand*{\glsentrysymbolplural}[1]{%
  \@gls@entry@field{#1}{symbolplural}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrysymbolplural}
%\changes{1.12}{2008 Mar 8}{New}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrysymbolplural}[1]{%
  \@Gls@entry@field{#1}{symbolplural}%
}
%    \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]{%
  \@gls@entry@field{#1}{first}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirst}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryfirst}[1]{%
  \@Gls@entry@field{#1}{first}%
}
%    \end{macrocode}
%\end{macro}
%
% Get the plural form (as specified by the \gloskey{firstplural}
% key when the entry was defined).
%\begin{macro}{\glsentryfirstplural}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glsentryfirstplural}[1]{%
  \@gls@entry@field{#1}{firstpl}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfirstplural}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryfirstplural}[1]{%
  \@Gls@entry@field{#1}{firstpl}%
}
%    \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]{\@gls@entry@field{#1}{type}}
%    \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]{%
  \@gls@entry@field{#1}{sort}%
}
%    \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]{%
  \@gls@entry@field{#1}{useri}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseri}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuseri}[1]{%
  \@Gls@entry@field{#1}{useri}%
}
%    \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]{%
  \@gls@entry@field{#1}{userii}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuserii}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuserii}[1]{%
  \@Gls@entry@field{#1}{userii}%
}
%    \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]{%
  \@gls@entry@field{#1}{useriii}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseriii}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuseriii}[1]{%
  \@Gls@entry@field{#1}{useriii}%
}
%    \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]{%
  \@gls@entry@field{#1}{useriv}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuseriv}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuseriv}[1]{%
  \@Gls@entry@field{#1}{useriv}%
}
%    \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]{%
  \@gls@entry@field{#1}{userv}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuserv}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuserv}[1]{%
  \@Gls@entry@field{#1}{userv}%
}
%    \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]{%
  \@gls@entry@field{#1}{uservi}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryuservi}
%\changes{2.04}{2009 November 10}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryuservi}[1]{%
  \@Gls@entry@field{#1}{uservi}%
}
%    \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]{\@gls@entry@field{#1}{short}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryshort}
%\changes{3.0}{2011/04/02}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryshort}[1]{%
  \@Gls@entry@field{#1}{short}%
}
%    \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]{\@gls@entry@field{#1}{shortpl}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryshortpl}
%\changes{3.0}{2011/04/02}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryshortpl}[1]{%
  \@Gls@entry@field{#1}{shortpl}%
}
%    \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]{\@gls@entry@field{#1}{long}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrylong}
%\changes{3.0}{2011/04/02}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrylong}[1]{%
  \@Gls@entry@field{#1}{long}%
}
%    \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]{\@gls@entry@field{#1}{longpl}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentrylongpl}
%\changes{3.0}{2011/04/02}{new}
%\changes{3.09a}{2013-10-09}{made robust}
%    \begin{macrocode}
\newrobustcmd*{\Glsentrylongpl}[1]{%
  \@Gls@entry@field{#1}{longpl}%
}
%    \end{macrocode}
%\end{macro}
%
% Short cut macros to access full form:
%\begin{macro}{\glsentryfull}
%\changes{3.13a}{2013-11-05}{changed to use \cs{acrfullformat}}
%\changes{4.02}{2013-12-05}{bug fix: added missing \cs{acronymfont}}
%    \begin{macrocode}
\newcommand*{\glsentryfull}[1]{%
  \acrfullformat{\glsentrylong{#1}}{\acronymfont{\glsentryshort{#1}}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfull}
%\changes{3.09a}{2013-10-09}{made robust}
%\changes{3.02}{2012/05/21}{fixed bug (replaced \cs{glsentryshortpl}
%with \cs{glsentryshort})}
%\changes{3.13a}{2013-11-05}{changed to use \cs{acrfullformat}}
%\changes{4.02}{2013-12-05}{bug fix: added missing \cs{acronymfont}}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryfull}[1]{%
  \acrfullformat{\Glsentrylong{#1}}{\acronymfont{\glsentryshort{#1}}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryfullpl}
%\changes{3.02}{2012/05/21}{fixed bug (replaced \cs{glsentryshort}
%with \cs{glsentryshortpl})}
%\changes{3.13a}{2013-11-05}{changed to use \cs{acrfullformat}}
%\changes{4.02}{2013-12-05}{bug fix: added missing \cs{acronymfont}}
%    \begin{macrocode}
\newcommand*{\glsentryfullpl}[1]{%
  \acrfullformat{\glsentrylongpl{#1}}{\acronymfont{\glsentryshortpl{#1}}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryfullpl}
%\changes{3.09a}{2013-10-09}{made robust}
%\changes{3.13a}{2013-11-05}{changed to use \cs{acrfullformat}}
%\changes{4.02}{2013-12-05}{bug fix: added missing \cs{acronymfont}}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryfullpl}[1]{%
  \acrfullformat{\Glsentrylongpl{#1}}{\acronymfont{\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}%
  {%
    \@gls@entry@field{#1}{numberlist}%
  }%
}
%    \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
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
         \edef\@glo@label{\glsdetoklabel{#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}}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glshyperlink}[2][\glsentrytext{\@glo@label}]{%
 \def\@glo@label{#2}%
 \@glslink{\glolinkprefix\glsdetoklabel{#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}
%
%\begin{definition}
%\cs{glsadd}\oarg{options}\marg{label}
%\end{definition}
% 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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newrobustcmd*{\glsadd}[2][]{%
  \glsdoifexists{#2}%
  {%
    \def\@glsnumberformat{glsnumberformat}%
    \edef\@gls@counter{\csname glo@\glsdetoklabel{#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}
%
%\begin{definition}
%\cs{glsaddall}\oarg{option list}
%\end{definition}
% 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}
%\begin{macro}{\glsaddallunused}
%\begin{definition}
%\cs{glsaddallunused}\oarg{glossary type}
%\end{definition}
% Add all used terms defined for the listed glossaries (without displaying
% any text). If optional argument is omitted, apply to all
% glossary types. This should typically go at the end of the
% document.
%\changes{3.08a}{2013-09-28}{new}
%\changes{3.13a}{2013-11-05}{set default to \cs{@glo@types}}
%    \begin{macrocode}
\newrobustcmd*{\glsaddallunused}[1][\@glo@types]{%
 \forallglsentries[#1]{\@glo@entry}%
 {%
    \ifglsused{\@glo@entry}{}{\glsadd[format=@gobble]{\@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}{\glsbackslash}
%\changes{4.11}{2014-09-01}{new}
% Define \cs{glsbackslash} to make it easier to write a backslash to a file.
%    \begin{macrocode}
\edef\glsbackslash{\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}{\glspercentchar}
%\changes{4.10}{2014-08-27}{new}
% Define \cs{glspercentchar} to make it easier to write a percent
% character to a file.
%    \begin{macrocode}
\edef\glspercentchar{\expandafter\@gobble\string\%}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glstildechar}
%\changes{4.10}{2014-08-27}{new}
% Define \cs{glstildechar} to make it easier to write a tilde
% character to a file.
%    \begin{macrocode}
\edef\glstildechar{\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 \cs{delimN} and
%\cs{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}
% Define write register if not already defined
%\changes{4.04}{2014-03-06}{checked for definition of \cs{glswrite}}
%    \begin{macrocode}
    \ifundef{\glswrite}{\newwrite\glswrite}{}%
%    \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\glstildechar n\string" ^^J\space
        \space\space:close \string"\glspercentchar\glstildechar n\string
          \end{theglossary}\string\glossarypostamble
          \glstildechar 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\glstildechar n\string")}%
%    \end{macrocode}
% Specify what to put between entries
%    \begin{macrocode}
    \write\glswrite{(markup-indexentry
        :open \string"\string\relax \string\glsresetentrylist
           \glstildechar 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\glstildechar 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}
%\changes{4.04}{2014-03-06}{checked for definition of \cs{glswrite}}
%    \begin{macrocode}
  \edef\@gls@actualchar{\string?}
  \edef\@gls@encapchar{\string|}
  \edef\@gls@levelchar{\string!}
  \edef\@gls@quotechar{\string"}
  \def\writeist{\relax
   \ifundef{\glswrite}{\newwrite\glswrite}{}\relax
   \openout\glswrite=\istfilename
    \write\glswrite{\glspercentchar\space makeindex style file
      created by the glossaries package}
    \write\glswrite{\glspercentchar\space 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}{\@closegls}
%\changes{4.08}{2014-07-30}{new}
%   \begin{macrocode}
\newcommand*{\@closegls}[1]{%
  \closeout\csname glo@#1@file\endcsname
}
%   \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@automake}
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\ifglsxindy
 \newcommand*{\@gls@automake}[1]{%
   \ifglossaryexists{#1}
   {%
     \@closegls{#1}%
     \ifdefstring{\glsorder}{letter}%
      {\def\@gls@order{-M ord/letorder }}%
      {\let\@gls@order\@empty}%
     \ifcsundef{@xdy@#1@language}%
      {\let\@gls@langmod\@xdy@main@language}%
      {\letcs\@gls@langmod{@xdy@#1@language}}%
     \edef\@gls@dothiswrite{\noexpand\write18{xindy 
       -I xindy
       \@gls@order 
       -L \@gls@langmod\space
       -M \gls@istfilebase\space
       -C \gls@codepage\space
       -t \jobname.\csuse{@glotype@#1@log}
       -o \jobname.\csuse{@glotype@#1@in}
       \jobname.\csuse{@glotype@#1@out}}%
     }%
     \@gls@dothiswrite
   }%
   {%
     \GlossariesWarning{Can't make glossary `#1', it doesn't exist}%
   }%
 }
\else
 \newcommand*{\@gls@automake}[1]{%
   \ifglossaryexists{#1}
   {%
     \@closegls{#1}%
     \ifdefstring{\glsorder}{letter}%
      {\def\@gls@order{-l }}%
      {\let\@gls@order\@empty}%
     \edef\@gls@dothiswrite{\noexpand\write18{makeindex \@gls@order 
       -s \istfilename\space
       -t \jobname.\csuse{@glotype@#1@log}
       -o \jobname.\csuse{@glotype@#1@in}
       \jobname.\csuse{@glotype@#1@out}}%
     }%
     \@gls@dothiswrite
   }%
   {%
     \GlossariesWarning{Can't make glossary `#1', it doesn't exist}%
   }%
 }
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\warn@nomakeglossaries}
% Issue warning that \cs{makeglossaries} hasn't been used.
%    \begin{macrocode}
\newcommand*{\@warn@nomakeglossaries}{}
%    \end{macrocode}
% Only use this if warning if \cs{printglossary} has been used
% without \cs{makeglossaries}
%    \begin{macrocode}
\newcommand*{\warn@nomakeglossaries}{\@warn@nomakeglossaries}
%    \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}
% Define the write used for style file also used for all other output files
% if \pkgopt[true]{savewrites}.
%\changes{4.04}{2014-03-06}{Moved definition of \cs{glswrite} to
%\cs{makeglossaries}}
%    \begin{macrocode}
  \ifundef{\glswrite}{\newwrite\glswrite}{}%
%    \end{macrocode}
%\changes{3.10a}{2013-10-13}{Added providecommand code to aux file}
% If the user removes the glossary package from their document,
% ensure the next run doesn't throw a load of undefined control
% sequence errors when the aux file is parsed.
%    \begin{macrocode}
  \protected@write\@auxout{}{\string\providecommand\string\@glsorder[1]{}}
  \protected@write\@auxout{}{\string\providecommand\string\@istfilename[1]{}}
%    \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}
% Allow \gloskey{see} key:
%    \begin{macrocode}
  \let\gls@checkseeallowed\relax
%    \end{macrocode}
% Suppress warning about no \cs{makeglossaries}
%    \begin{macrocode}
  \let\warn@nomakeglossaries\relax
%    \end{macrocode}
% Activate warning about missing \cs{printglossary}
%    \begin{macrocode}
  \def\warn@noprintglossary{%
    \GlossariesWarningNoLine{No \string\printglossary\space 
      or \string\printglossaries\space
      found.^^J(Remove \string\makeglossaries\space if you don't want
      any glossaries.)^^JThis document will not have a glossary}%
  }%
%    \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}
% Prevent user from also using \cs{makenoidxglossaries}
%    \begin{macrocode}
  \let\makenoidxglossaries\@no@makeglossaries
%    \end{macrocode}
% Prohibit sort key in printgloss family:
%    \begin{macrocode}
  \renewcommand*{\@printgloss@setsort}{%
    \let\@glo@assign@sortkey\@glo@no@assign@sortkey
  }%
%    \end{macrocode}
% Check the automake setting:
%    \begin{macrocode}
  \ifglsautomake
    \renewcommand*{\@gls@doautomake}{%
      \@for\@gls@type:=\@glo@types\do{%
        \ifdefempty{\@gls@type}{}%
        {\@gls@automake{\@gls@type}}%
      }%
    }%
  \fi
}
%    \end{macrocode}
%\changes{4.02}{2013-13-05}{made preamble only}
% Must occur in the preamble:
%    \begin{macrocode}
\@onlypreamble{\makeglossaries}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glswrite}
% The definition of \cs{glswrite} has now been moved to 
% \cs{makeglossaries} so that it's only defined if needed.
%\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}
%
%\begin{macro}{\makenoidxglossaries}
%\changes{4.04}{2014-03-06}{new}
% Analogous to \cs{makeglossaries} this activates the commands
% needed for \cs{printnoidxglossary}
%    \begin{macrocode}
\newcommand*{\makenoidxglossaries}{%
%    \end{macrocode}
% Redefine empty glossary warning:
%    \begin{macrocode}
  \renewcommand{\@gls@noref@warn}[1]{%
    \GlossariesWarning{Empty glossary for
    \string\printnoidxglossary[type={##1}]. 
    Rerun may be required (or you may have forgotten to use 
    commands like \string\gls).}%
  }%
%    \end{macrocode}
% Don't escape makeindex/xindy characters
%    \begin{macrocode}
  \let\@gls@checkmkidxchars\@gobble
%    \end{macrocode}
% Write glossary information to aux instead of glossary files
%    \begin{macrocode}
  \let\@@do@@wrglossary\gls@noidxglossary
%    \end{macrocode}
% Switch on group headings that use the character code:
%    \begin{macrocode}
  \let\@gls@getgrouptitle\@gls@noidx@getgrouptitle
%    \end{macrocode}
% Allow \gloskey{see} key:
%    \begin{macrocode}
  \let\gls@checkseeallowed\relax
%    \end{macrocode}
% Redefine cross-referencing macro:
%    \begin{macrocode}
  \renewcommand{\@do@seeglossary}[2]{%
    \edef\@gls@label{\glsdetoklabel{##1}}%
    \protected@write\@auxout{}{%
      \string\@gls@reference
        {\csname glo@\@gls@label @type\endcsname}%
        {\@gls@label}%
        {%
          \string\glsseeformat##2{}%
        }%
    }%
  }%
%    \end{macrocode}
% If user removes the glossaries package from their document, ensure
% the next run doesn't throw a load of undefined control sequence
% errors when the aux file is parsed.
%    \begin{macrocode}
  \AtBeginDocument
  {%
    \write\@auxout{\string\providecommand\string\@gls@reference[3]{}}%
  }%
%    \end{macrocode}
% Change warning about no glossares
%    \begin{macrocode}
  \def\warn@noprintglossary{%
    \GlossariesWarningNoLine{No \string\printnoidxglossary\space 
      or \string\printnoidxglossaries ^^J
      found. (Remove \string\makenoidxglossaries\space if you
      don't want any glossaries.)^^JThis document will not have a glossary}%
  }%
%    \end{macrocode}
% Suppress warning about no \cs{makeglossaries}
%    \begin{macrocode}
  \let\warn@nomakeglossaries\relax
%    \end{macrocode}
% Prevent user from also using \cs{makeglossaries}
%    \begin{macrocode}
  \let\makeglossaries\@no@makeglossaries
%    \end{macrocode}
% Allow sort key in printgloss family:
%    \begin{macrocode}
  \renewcommand*{\@printgloss@setsort}{%
    \let\@glo@assign@sortkey\@@glo@assign@sortkey
%    \end{macrocode}
% Initialise default sort order:
%    \begin{macrocode}
    \def\@glo@sorttype{\@glo@default@sorttype}%
  }%
%    \end{macrocode}
% All entries must be defined in the preamble:
%    \begin{macrocode}
  \renewcommand*\new@glossaryentry[2]{%
    \PackageError{glossaries}{Glossary entries must be
     defined in the preamble^^Jwhen you use
     \string\makenoidxglossaries}%
    {Either move your definitions to the preamble or use
     \string\makeglossaries}%
  }%
%    \end{macrocode}
% Redefine \ics{glsentrynumberlist}
%    \begin{macrocode}
  \renewcommand*{\glsentrynumberlist}[1]{%
    \letcs{\@gls@loclist}{glo@\glsdetoklabel{##1}@loclist}%
    \ifdef\@gls@loclist
    {%
      \glsnoidxloclist{\@gls@loclist}%
    }%
    {%
      \ifglsentryexists{##1}%
      {%
        \GlossariesWarning{Missing location list for `##1'. Either
          a rerun is required or you haven't referenced the entry.}%
      }%
      {%
        \PackageError{glossaries}{Glossary entry `##1' has not been
         defined.}{}%
      }%
    }%
  }%
%    \end{macrocode}
% Redefine \ics{glsdisplaynumberlist}
%    \begin{macrocode}
  \renewcommand*{\glsdisplaynumberlist}[1]{%
    \letcs{\@gls@loclist}{glo@\glsdetoklabel{##1}@loclist}%
    \ifdef\@gls@loclist
    {%
      \def\@gls@noidxloclist@sep{%
        \def\@gls@noidxloclist@sep{%
          \def\@gls@noidxloclist@sep{%
            \glsnumlistsep
          }%
          \def\@gls@noidxloclist@finalsep{\glsnumlistlastsep}%
        }%
      }%
      \def\@gls@noidxloclist@finalsep{}%
      \def\@gls@noidxloclist@prev{}%
      \forlistloop{\glsnoidxdisplayloclisthandler}{\@gls@loclist}%
      \@gls@noidxloclist@finalsep
      \@gls@noidxloclist@prev
    }%
    {%
      ??\ifglsentryexists{##1}%
      {%
        \GlossariesWarning{Missing location list for `##1'. Either
          a rerun is required or you haven't referenced the entry.}%
      }%
      {%
        \PackageError{glossaries}{Glossary entry `##1' has not been
         defined.}{}%
      }%
    }%
  }%
%    \end{macrocode}
% Provide a generic way of iterating through the number list:
%    \begin{macrocode}
  \renewcommand*{\glsnumberlistloop}[3]{%
    \letcs{\@gls@loclist}{glo@\glsdetoklabel{##1}@loclist}%
    \let\@gls@org@glsnoidxdisplayloc\glsnoidxdisplayloc
    \let\@gls@org@glsseeformat\glsseeformat
    \let\glsnoidxdisplayloc##2\relax
    \let\glsseeformat##3\relax
    \ifdef\@gls@loclist
    {%
      \forlistloop{\glsnoidxnumberlistloophandler}{\@gls@loclist}%
    }%
    {%
      \ifglsentryexists{##1}%
      {%
        \GlossariesWarning{Missing location list for `##1'. Either
          a rerun is required or you haven't referenced the entry.}%
      }%
      {%
        \PackageError{glossaries}{Glossary entry `##1' has not been
         defined.}{}%
      }%
    }%
    \let\glsnoidxdisplayloc\@gls@org@glsnoidxdisplayloc
    \let\glsseeformat\@gls@org@glsseeformat
  }%
%    \end{macrocode}
% Modify sanitize sort function
%    \begin{macrocode}
  \let\@@gls@sanitizesort\@gls@noidx@sanitizesort
  \let\@@gls@nosanitizesort\@@gls@noidx@nosanitizesort
  \@gls@noidx@setsanitizesort
}
%    \end{macrocode}
% Preamble-only command:
%    \begin{macrocode}
\@onlypreamble{\makenoidxglossaries}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnumberlistloop}
%\begin{definition}
%\cs{glsnumberlistloop}\marg{label}\marg{handler}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\glsnumberlistloop}[2]{%
   \PackageError{glossaries}{\string\glsnumberlistloop\space
    only works with \string\makenoidxglossaries}{}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsnoidxnumberlistloophandler}
% Handler macro for \cs{glsnumberlistloop}.
% (The argument should be in the form
% \cs{glsnoidxdisplayloc}\marg{prefix}\marg{counter}\marg{format}\marg{n})
%    \begin{macrocode}
\newcommand*{\glsnoidxnumberlistloophandler}[1]{%
  #1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@no@makeglossaries}
%\changes{4.04}{2014-03-06}{new}
% Can't use both \cs{makeglossaries} and \cs{makenoidxglossaries}
%    \begin{macrocode}
\newcommand*{\@no@makeglossaries}{%
  \PackageError{glossaries}{You can't use both
  \string\makeglossaries\space and \string\makenoidxglossaries}%
  {Either use one or other (or none) of those commands but not both
  together.}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@noref@warn}
%\changes{4.04}{2014-03-06}{new}
% Warning when no instances of \cs{@gls@reference} found.
%    \begin{macrocode}
\newcommand{\@gls@noref@warn}[1]{%
  \GlossariesWarning{\string\makenoidxglossaries\space
   is required to make \string\printnoidxglossary[type={#1}] work}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@noidxglossary}
% Write the glossary information to the aux file:
%    \begin{macrocode}
\newcommand*{\gls@noidxglossary}{%
  \protected@write\@auxout{}{%
    \string\@gls@reference
      {\csname glo@\@gls@label @type\endcsname}%
      {\@gls@label}%
      {\string\glsnoidxdisplayloc
        {\@glo@counterprefix}%
        {\@gls@counter}%
        {\@glsnumberformat}%
        {\@glslocref}%
      }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Writing information to associated files}
%
%
%\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}
%\changes{3.14a}{2013-11-12}{renamed \cs{glswritefiles} to
%\cs{@glswritefiles} and used ``savewrites'' option to set
%\cs{glswritefiles}}
%    \begin{macrocode}
\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
  }%
}
%    \end{macrocode}
%\end{macro}
%
% As from v4.10, the \cs{glossary} command is 
% used by the \styfmt{glossaries} package. Since the
% user isn't expected to use this command (as \styfmt{glossaries}
% takes care of the particular format required for
% \gls{makeindex}\slash\gls{xindy}) there's no need for a user level
% command. Using a custom internal command prevents any conflict
% with other packages (and with the \cs{mark} mechanism).
%
% In v4.10, the redefinition of \cs{glossary} was removed since it
% wasn't intended as a user level command, however it
% seems there are packages that have hacked the internal macros used
% by \styfmt{glossaries} and no longer work with this redefinition
% removed, so it's been restored in v4.11 but is not used at all by
% \styfmt{glossaries}. (This may be removed or moved to a
% compatibility mode in future.)
%\begin{macro}{\glossary}
%    \begin{macrocode}
\if@gls@docloaded
\else
  \renewcommand*{\glossary}[1][main]{\gls@glossary{#1}}
\fi
%    \end{macrocode}
%\end{macro}
%
% The associated number should be stored in \cs{theglsentrycounter}
% before using \cs{gls@glossary}.
%\begin{macro}{\gls@glossary}
%    \begin{macrocode}
\newcommand*{\gls@glossary}[1]{%
  \@gls@glossary{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@glossary}
% (In v4.10, \cs{@glossary} was redefined to \cs{@gls@glossary} to
% avoid conflict with other packages.)
% Define internal \cs{@gls@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.)
%\changes{1.17}{2008 December 26}{changed definition to use
%\cs{index} instead of \cs{@index}}
%\changes{4.10}{2014-08-27}{Renamed \cs{@glossary} to \cs{@gls@glossary}}
% The argument \verb|#1| is the glossary type.
%    \begin{macrocode}
\newcommand*{\@gls@glossary}[1]{\index}
%    \end{macrocode}
%\end{macro}
% This is a convenience command to set \cs{@gls@glossary}.
% It's 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\@gls@glossary##1{\@bsphack\begingroup\gls@wrglossary{##1}}%
  \let\@gls@renewglossary\@empty
}
%    \end{macrocode}
%\end{macro}
% The \cs{gls@wrglossary} command is defined 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}{\gls@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}}
%\changes{4.11}{2014-09-01}{renamed from \cs{@wrglossary} to
%\cs{gls@wrglossary}}
%    \begin{macrocode}
\newcommand*{\gls@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}%
    }%
    {%
       \ifignoredglossary{#1}{}%
       {%
          \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}
%\changes{3.05}{2013-04-21}{added Roman to list}
% List of page formats to be protected against expansion.
%    \begin{macrocode}
\newcommand{\gls@protected@pagefmts}{%
  \gls@numberpage,\gls@alphpage,\gls@Alphpage,\gls@romanpage,\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}
%\end{macro}
%\begin{macro}{\gls@Romanpage}
%\changes{3.05}{2013-04-21}{new}
%    \begin{macrocode}
\newcommand*{\gls@Romanpage}{\@Roman\c@page}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaddprotectedpagefmt}
%\begin{definition}
%\cs{glsaddprotectedpagefmt}\marg{cs name}
%\end{definition}
% Added a page format to the list of protected page formats.
% The argument should be the name (without a backslash) of the
% command that takes a \TeX\ register as the argument 
% (\verb|\|\meta{csname}\verb|\c@page| must be valid).
%\changes{4.11}{2014-09-01}{new}
%    \begin{macrocode}
\newcommand*{\glsaddprotectedpagefmt}[1]{%
  \eappto\gls@protected@pagefmts{,\expandonce{\csname gls#1page\endcsname}}%
  \csedef{gls#1page}{\expandonce{\csname#1\endcsname}\noexpand\c@page}%
  \eappto\@wrglossarynumberhook{%
    \noexpand\let\expandonce{\csname org@gls#1\endcsname}%
      \expandonce{\csname#1\endcsname}%
    \noexpand\def\expandonce{\csname#1\endcsname}{%
      \noexpand\@wrglossary@pageformat
         \expandonce{\csname gls#1page\endcsname}%
         \expandonce{\csname org@gls#1\endcsname}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@wrglossarynumberhook}
% Hook used by \cs{@@do@wrglossary}
%    \begin{macrocode}
\newcommand*\@wrglossarynumberhook{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@wrglossary@pageformat}
%    \begin{macrocode}
\newcommand{\@wrglossary@pageformat}[3]{%
  \ifx#3\c@page #1\else #2#3\fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@do@wrglossary}
%\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
%    \end{macrocode}
% 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\orgthe\the
    \let\orgnumber\number
    \let\orgromannumeral\romannumeral
    \let\orgalph\@alph
    \let\orgAlph\@Alph
    \let\orgRoman\@Roman
%    \end{macrocode}
% Redefine:
%\changes{3.05}{2013-04-21}{add Roman case. Fixed bugs in the else statements}
%    \begin{macrocode}
    \def\the##1{%
      \ifx##1\c@page \gls@numberpage\else\orgthe##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\orgromannumeral##1\fi}%
    \def\@Roman##1{%
      \ifx##1\c@page \gls@Romanpage\else\orgRoman##1\fi}%
    \def\@alph##1{%
      \ifx##1\c@page \gls@alphpage\else\orgalph##1\fi}%
    \def\@Alph##1{%
      \ifx##1\c@page \gls@Alphpage\else\orgAlph##1\fi}%
%    \end{macrocode}
% Add hook to allow for other number formats:
%\changes{4.11}{2014-09-01}{added hook}
%    \begin{macrocode}
   \@wrglossarynumberhook
%    \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\relax
    \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}
% De-tok label if required
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
  \edef\@gls@label{\glsdetoklabel{#1}}%
%    \end{macrocode}
% Write the information to file:
%    \begin{macrocode}
  \@@do@@wrglossary
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@do@@wrglossary}
%    \begin{macrocode}
\newcommand*{\@@do@@wrglossary}{%
%    \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}
    \gls@glossary{\csname glo@\@gls@label @type\endcsname}{%
    (indexentry :tkey (\csname glo@\@gls@label @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}
    \gls@glossary{\csname glo@\@gls@label @type\endcsname}{%
    \string\glossaryentry{\csname glo@\@gls@label @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
%    \end{macrocode}
% Warn if no prefix can be formed.
%\changes{4.04}{2014-0304}{added warning if no prefix can be formed}
%    \begin{macrocode}
    \ifx\@glo@counterprefix\@empty
      \GlossariesWarning{Hyper target `#2' can't be formed by
       prefixing^^Jlocation `#1'. You need to modify the
       definition of \string\theH\@gls@counter^^Jotherwise you
       will get the warning: "`name{\@gls@counter.#1}' has been^^J
       referenced but does not exist"}%
    \fi
  \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
  \gls@glossary{\csname glo@#1@type\endcsname}{%
    (indexentry
      :tkey (\csname glo@#1@index\endcsname)
      :xref (\string"\@gls@xref\string")
      :attr \string"see\string"
    )
  }%
\else
  \gls@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
   \@@gls@fixbraces#1#2#3\@end@fixbraces
  \else
    \def#1{{#2#3}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@@gls@fixbraces}
%    \begin{macrocode}
\def\@@gls@fixbraces#1[#2]#3\@end@fixbraces{%
  \def#1{[#2]{#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssee}
%\cs{glssee}\marg{label}\marg{cross-ref list}
%\changes{1.17}{2008 December 26}{new}
%\changes{3.08a}{2013-09-28}{made robust}
%    \begin{macrocode}
\DeclareRobustCommand*{\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}
%\changes{3.08a}{2013-09-28}{made robust}
% 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}
\DeclareRobustCommand*{\glsseeformat}[3][\seename]{%
  \emph{#1} \glsseelist{#2}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsseelist}
%\cs{glsseelist}\marg{list} formats list of entry labels.
%\changes{3.08a}{2013-09-28}{made robust}
%    \begin{macrocode}
\DeclareRobustCommand*{\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.
% (Expanding label as it's a temporary control sequence that's used
% elsewhere.)
%\changes{4.03}{2014-01-20}{added \cs{expandafter} commands}
%    \begin{macrocode}
    \expandafter\glsseeitem\expandafter{\@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}}
%\changes{3.08a}{2013-09-28}{made robust}
%    \begin{macrocode}
\DeclareRobustCommand*{\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 occurrence of \ics{printglossary}. There is no check
% to ensure that there is a \ics{printglossary} for each defined
% glossary.)
%\changes{4.04}{2014-03-06}{Activate warning in \cs{makeglossaries}}
%    \begin{macrocode}
\newcommand*{\warn@noprintglossary}{}%
%    \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
%\cs{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}
  \@gls@warnonglossdefined
  \undef\printglossary
}
%    \end{macrocode}
% \cs{printglossary} has an optional argument. The default
% value is to set the glossary type to the main glossary.
%\changes{4.04}{2014-03-06}{changed to use new \cs{@printglossary}}
%    \begin{macrocode}
\newcommand*{\printglossary}[1][type=\glsdefaulttype]{%
  \@printglossary{#1}{\@print@glossary}%
}
%    \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}
%
%\begin{macro}{\printnoidxglossary}
%\changes{4.04}{2014-03-06}{new}
% Provide an alternative to \cs{printglossary} that doesn't require
% an external indexing application. Entries won't be sorted and the
% location list will be empty.
%    \begin{macrocode}
\newcommand*{\printnoidxglossary}[1][type=\glsdefaulttype]{%
  \@printglossary{#1}{\@print@noidx@glossary}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\printnoidxglossaries}
% Analogous to \cs{printglossaries}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\printnoidxglossaries}{%
  \forallglossaries{\@@glo@type}{\printnoidxglossary[type=\@@glo@type]}%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\@printgloss@setsort}
% Initialise to do nothing.
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@printgloss@setsort}{}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\@printglossary}
%\changes{4.04}{2014-03-06}{new}
% Sets up the glossary for either \cs{printglossary} or
% \cs{printnoidxglossary}. The first argument is the options list,
% the second argument is the handler macro that
% deals with the actual glossary.
%    \begin{macrocode}
\newcommand{\@printglossary}[2]{%
%    \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}
% Activate or deactivate sort key:
%    \begin{macrocode}
    \@printgloss@setsort
%    \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 (v3.08 updated for
% new \cs{glossentry} and \cs{subglossentry}, but this is now only
% needed for backward compatibility):
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
    \let\gls@org@glossaryentryfield\glossentry
    \let\gls@org@glossarysubentryfield\subglossentry
    \renewcommand{\glossentry}[1]{%
      \xdef\glscurrententrylabel{\glsdetoklabel{##1}}%
      \gls@org@glossaryentryfield{##1}%
    }%
    \renewcommand{\subglossentry}[2]{%
      \xdef\glscurrententrylabel{\glsdetoklabel{##2}}%
      \gls@org@glossarysubentryfield{##1}{##2}%
    }%
%    \end{macrocode}
% Now do the handler macro that deals with the actual glossary:
%    \begin{macrocode}
    #2%
%    \end{macrocode}
% End the current scope
%    \begin{macrocode}
  \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}
%
%\begin{macro}{\@print@glossary}
%\changes{4.04}{2014-03-06}{new}
% Internal workings of \cs{printglossary} dealing with reading the
% external file.
%    \begin{macrocode}
\newcommand{\@print@glossary}{%
%    \end{macrocode}
% Some macros may end up being expanded into internals in the
% glossary, so need to make @ a letter. (Unlikely to be a problem
% since v3.08a but kept for backward compatibility.)
%    \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{%
%    \end{macrocode}
%\changes{3.10a}{2013-10-13}{Added providecommand code to aux file}
% If the user removes the glossary package from their document,
% ensure the next run doesn't throw a load of undefined control
% sequence errors when the aux file is parsed.
%    \begin{macrocode}
          \noexpand\immediate\noexpand\write\@auxout{%
            \string\providecommand\string\@xdylanguage[2]{}}%
          \noexpand\immediate\noexpand\write\@auxout{%
            \string\@xdylanguage{\@glo@type}{\@xdy@main@language}}%
        }%
      }%
    }%
    {%
      \edef\@do@auxoutstuff{%
        \noexpand\AtEndDocument{%
          \noexpand\immediate\noexpand\write\@auxout{%
            \string\providecommand\string\@xdylanguage[2]{}}%
          \noexpand\immediate\noexpand\write\@auxout{%
            \string\@xdylanguage{\@glo@type}{\csname @xdy@\@glo@type 
              @language\endcsname}}%
        }%
      }%
    }%
    \@do@auxoutstuff
    \edef\@do@auxoutstuff{%
      \noexpand\AtEndDocument{%
%    \end{macrocode}
%\changes{3.10a}{2013-10-13}{Added providecommand code to aux file}
% If the user removes the glossaries package from their document,
% ensure the next run doesn't throw a load of undefined control
% sequence errors when the aux file is parsed.
%    \begin{macrocode}
         \noexpand\immediate\noexpand\write\@auxout{%
          \string\providecommand\string\@gls@codepage[2]{}}%
         \noexpand\immediate\noexpand\write\@auxout{%
          \string\@gls@codepage{\@glo@type}{\gls@codepage}}%
      }%
    }%
    \@do@auxoutstuff
  \fi
%    \end{macrocode}
% Activate warning if \cs{makeglossaries} hasn't been used.
%    \begin{macrocode}
  \renewcommand*{\@warn@nomakeglossaries}{%
    \GlossariesWarningNoLine{\string\makeglossaries\space
    hasn't been used,^^Jthe glossaries will not be updated}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% The sort macros all have the syntax:
%\begin{definition}
%\cs{@glo@sortmacro@\meta{order}}\marg{type}
%\end{definition}
% where \meta{order} is the sort order as specified by the sort key
% and \meta{type} is the glossary type. (The referenced entry list
% is stored in \cs{@glsref@\meta{type}.} The actual sorting is done
% by \cs{@glo@sortentries}\marg{handler}\marg{type}.
%
%\begin{macro}{\@glo@sortentries}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@glo@sortentries}[2]{%
  \def\@glo@sortinglist{}%
  \def\@glo@sortinghandler{#1}%
  \edef\@glo@type{#2}%
  \forlistcsloop{\@glo@do@sortentries}{@glsref@#2}%
  \csdef{@glsref@#2}{}%
  \@for\@this@label:=\@glo@sortinglist\do{%
%    \end{macrocode}
% Has this entry already been added?
%    \begin{macrocode}
    \xifinlistcs{\@this@label}{@glsref@#2}%
    {}%
    {%
      \listcsxadd{@glsref@#2}{\@this@label}%
    }%
    \ifcsdef{@glo@sortingchildren@\@this@label}%
    {%
      \@glo@addchildren{#2}{\@this@label}%
    }%
    {}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@addchildren}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{@glo@addchildren}\marg{type}\marg{parent}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\@glo@addchildren}[2]{%
%    \end{macrocode}
% Scope to allow nesting.
%    \begin{macrocode}
  \bgroup
     \letcs{\@glo@childlist}{@glo@sortingchildren@#2}%
     \@for\@this@childlabel:=\@glo@childlist\do
     {%
%    \end{macrocode}
% Check this label hasn't already been added.
%    \begin{macrocode}
       \xifinlistcs{\@this@childlabel}{@glsref@#1}%
       {}%
       {%
         \listcsxadd{@glsref@#1}{\@this@childlabel}%
       }%
%    \end{macrocode}
% Does this child have children?
%    \begin{macrocode}
       \ifcsdef{@glo@sortingchildren@\@this@childlabel}%
       {%
         \@glo@addchildren{#1}{\@this@childlabel}%
       }%
       {%
       }%
     }%
  \egroup
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@do@sortentries}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@glo@do@sortentries}[1]{%
  \ifglshasparent{#1}%
  {%
%    \end{macrocode}
% This entry has a parent, so add it to the child list
%    \begin{macrocode}
    \edef\@glo@parent{\csuse{glo@\glsdetoklabel{#1}@parent}}%
    \ifcsundef{@glo@sortingchildren@\@glo@parent}%
    {%
      \csdef{@glo@sortingchildren@\@glo@parent}{}%
    }%
    {}%
    \expandafter\@glo@sortedinsert
      \csname @glo@sortingchildren@\@glo@parent\endcsname{#1}%
%    \end{macrocode}
% Has the parent been added?
%    \begin{macrocode}
    \xifinlistcs{\@glo@parent}{@glsref@\@glo@type}%
    {%
%    \end{macrocode}
% Yes, it has so do nothing.
%    \begin{macrocode}
    }%
    {%
%    \end{macrocode}
% No, it hasn't so add it now.
%    \begin{macrocode}
       \expandafter\@glo@do@sortentries\expandafter{\@glo@parent}%
    }%
  }%
  {%
    \@glo@sortedinsert{\@glo@sortinglist}{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortedinsert}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{@glo@sortedinsert}\marg{list}\marg{entry label}
%\end{definition}
% Insert into list.
%    \begin{macrocode}
\newcommand*{\@glo@sortedinsert}[2]{%
  \dtl@insertinto{#2}{#1}{\@glo@sortinghandler}%
}%
%    \end{macrocode}
%\end{macro}
%
% The sort handlers need to be in the form required by
% \sty{datatool}'s \cs{dtl@sortlist} macro. These must set the count
% register \cs{dtl@sortresult} to either $-1$ (\#1 less than \#2), 0
% (\#1 = \#2) or $+1$ (\#1 greater than \#2).
%\begin{macro}{\@glo@sorthandler@word}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@glo@sorthandler@word}[2]{%
  \letcs\@gls@sort@A{glo@\glsdetoklabel{#1}@sort}%
  \letcs\@gls@sort@B{glo@\glsdetoklabel{#2}@sort}%
  \edef\glo@do@compare{%
    \noexpand\dtlwordindexcompare{\noexpand\dtl@sortresult}%
    {\expandonce\@gls@sort@B}%
    {\expandonce\@gls@sort@A}%
  }%
  \glo@do@compare
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sorthandler@letter}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\newcommand*{\@glo@sorthandler@letter}[2]{%
  \letcs\@gls@sort@A{glo@\glsdetoklabel{#1}@sort}%
  \letcs\@gls@sort@B{glo@\glsdetoklabel{#2}@sort}%
  \edef\glo@do@compare{%
    \noexpand\dtlletterindexcompare{\noexpand\dtl@sortresult}%
    {\expandonce\@gls@sort@B}%
    {\expandonce\@gls@sort@A}%
  }%
  \glo@do@compare
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sorthandler@case}
%\changes{4.04}{2014-03-06}{new}
% Case-sensitive sort.
%    \begin{macrocode}
\newcommand*{\@glo@sorthandler@case}[2]{%
  \letcs\@gls@sort@A{glo@\glsdetoklabel{#1}@sort}%
  \letcs\@gls@sort@B{glo@\glsdetoklabel{#2}@sort}%
  \edef\glo@do@compare{%
    \noexpand\dtlcompare{\noexpand\dtl@sortresult}%
    {\expandonce\@gls@sort@B}%
    {\expandonce\@gls@sort@A}%
  }%
  \glo@do@compare
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sorthandler@nocase}
%\changes{4.04}{2014-03-06}{new}
% Case-insensitive sort.
%    \begin{macrocode}
\newcommand*{\@glo@sorthandler@nocase}[2]{%
  \letcs\@gls@sort@A{glo@\glsdetoklabel{#1}@sort}%
  \letcs\@gls@sort@B{glo@\glsdetoklabel{#2}@sort}%
  \edef\glo@do@compare{%
    \noexpand\dtlicompare{\noexpand\dtl@sortresult}%
    {\expandonce\@gls@sort@B}%
    {\expandonce\@gls@sort@A}%
  }%
  \glo@do@compare
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@word}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `word'
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@word}[1]{%
  \ifdefstring{\@glo@default@sorttype}{standard}%
  {%
    \@glo@sortentries{\@glo@sorthandler@word}{#1}%
  }%
  {%
    \PackageError{glossaries}{Conflicting sort options:^^J
     \string\usepackage[sort=\@glo@default@sorttype]{glossaries}^^J
     \string\printnoidxglossary[sort=word]}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@letter}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `letter'
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@letter}[1]{%
  \ifdefstring{\@glo@default@sorttype}{standard}%
  {%
    \@glo@sortentries{\@glo@sorthandler@letter}{#1}%
  }%
  {%
    \PackageError{glossaries}{Conflicting sort options:^^J
     \string\usepackage[sort=\@glo@default@sorttype]{glossaries}^^J
     \string\printnoidxglossary[sort=letter]}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@standard}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `standard'. (Use either `word' or `letter' order.)
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@standard}[1]{%
  \ifdefstring{\@glo@default@sorttype}{standard}%
  {%
    \ifcsdef{@glo@sorthandler@\glsorder}%
    {%
      \@glo@sortentries{\csuse{@glo@sorthandler@\glsorder}}{#1}%
    }%
    {%
      \PackageError{glossaries}{Unknown sort handler `\glsorder'}{}%
    }%
  }%
  {%
    \PackageError{glossaries}{Conflicting sort options:^^J
     \string\usepackage[sort=\@glo@default@sorttype]{glossaries}^^J
     \string\printnoidxglossary[sort=standard]}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@case}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `case'
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@case}[1]{%
  \ifdefstring{\@glo@default@sorttype}{standard}%
  {%
    \@glo@sortentries{\@glo@sorthandler@case}{#1}%
  }%
  {%
    \PackageError{glossaries}{Conflicting sort options:^^J
     \string\usepackage[sort=\@glo@default@sorttype]{glossaries}^^J
     \string\printnoidxglossary[sort=case]}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@nocase}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `nocase'
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@nocase}[1]{%
  \ifdefstring{\@glo@default@sorttype}{standard}%
  {%
    \@glo@sortentries{\@glo@sorthandler@nocase}{#1}%
  }%
  {%
    \PackageError{glossaries}{Conflicting sort options:^^J
     \string\usepackage[sort=\@glo@default@sorttype]{glossaries}^^J
     \string\printnoidxglossary[sort=nocase]}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@def}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `def'. The order of definition is given in 
% \cs{glolist@\meta{type}}.
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@def}[1]{%
  \def\@glo@sortinglist{}%
  \forglsentries[#1]{\@gls@thislabel}%
  {%
    \xifinlistcs{\@gls@thislabel}{@glsref@#1}%
    {%
      \listeadd{\@glo@sortinglist}{\@gls@thislabel}%
    }%
    {%
%    \end{macrocode}
% Hasn't been referenced.
%    \begin{macrocode}
    }%
  }%
  \cslet{@glsref@#1}{\@glo@sortinglist}%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\@glo@sortmacro@def@do}
%\changes{4.04}{2014-03-06}{new}
% This won't include parent entries that haven't been referenced.
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@def@do}[1]{%
  \ifinlistcs{#1}{@glsref@\@glo@type}%
  {}%
  {%
    \listcsadd{@glsref@\@glo@type}{#1}%
  }%
  \ifcsdef{@glo@sortingchildren@#1}%
  {%
    \@glo@addchildren{\@glo@type}{#1}%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@sortmacro@use}
%\changes{4.04}{2014-03-06}{new}
% Sort macro for `use'. (No sorting is required, as the entries are
% already in order of use, so do nothing.)
%    \begin{macrocode}
\newcommand*{\@glo@sortmacro@use}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@print@noidx@glossary}
%\changes{4.04}{2014-03-06}{new}
% Glossary handler for \cs{printnoidxglossary} which doesn't use an
% indexing application. Since \cs{printnoidxglossary} may occur at 
% the start of the document, we can't just check if an entry has
% been used. Instead, the first pass needs to write information to
% the aux file every time an entry is referenced. This needs to be
% read in on the second run and stored in a~list corresponding to
% the appropriate glossary.
%    \begin{macrocode}
\newcommand*{\@print@noidx@glossary}{%
  \ifcsdef{@glsref@\@glo@type}%
  {%
%    \end{macrocode}
% Sort the entries:
%    \begin{macrocode}
    \ifcsdef{@glo@sortmacro@\@glo@sorttype}%
    {%
      \csuse{@glo@sortmacro@\@glo@sorttype}{\@glo@type}%
    }%
    {%
       \PackageError{glossaries}{Unknown sort handler `\@glo@sorttype'}{}%
    }%
%    \end{macrocode}
% Do the glossary heading and preamble
%    \begin{macrocode}
    \glossarysection[\glossarytoctitle]{\glossarytitle}%
    \glossarypreamble
    \begin{theglossary}%
    \glossaryheader
    \glsresetentrylist
    \def\@gls@currentlettergroup{}%
%    \end{macrocode}
% Iterate through the entries.
%    \begin{macrocode}
   \forlistcsloop{\@gls@noidx@do}{@glsref@\@glo@type}%
%    \end{macrocode}
% Finally end the glossary and do the postamble:
%    \begin{macrocode}
    \end{theglossary}%
    \glossarypostamble
  }%
  {%
    \@gls@noref@warn{\@glo@type}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glo@grabfirst}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\def\glo@grabfirst#1#2\@nil{%
  \def\@gls@firsttok{#1}%
  \ifdefempty\@gls@firsttok
  {%
    \def\@glo@thislettergrp{0}%
  }%
  {%
%    \end{macrocode}
% Sanitize it:
%    \begin{macrocode}
    \@onelevel@sanitize\@gls@firsttok
%    \end{macrocode}
% Fetch the first letter:
%    \begin{macrocode}
    \expandafter\@glo@grabfirst\@gls@firsttok{}{}\@nil
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glo@grabfirst}
%\changes{4.04}{2014-03-06}{new}
%    \begin{macrocode}
\def\@glo@grabfirst#1#2\@nil{%
  \ifdefempty\@glo@thislettergrp
  {%
     \def\@glo@thislettergrp{glssymbols}%
  }%
  {%
    \count@=\uccode`#1\relax
    \ifnum\count@=0\relax
      \def\@glo@thislettergrp{glssymbols}%
    \else
      \ifdefstring\@glo@sorttype{case}%
      {%
         \count@=`#1\relax
      }%
      {%
      }%
      \edef\@glo@thislettergrp{\the\count@}%
    \fi
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@noidx@do}
%\changes{4.04}{2014-03-06}{new}
% Handler for list iteration used by \cs{@print@noidx@glossary}.
% The argument is the entry label. This only allows one sublevel.
%    \begin{macrocode}
\newcommand{\@gls@noidx@do}[1]{%
%    \end{macrocode}
% Get this entry's location list
%\changes{4.07}{2014-04-04}{added \cs{global} in case it's used in a
%tabular-like style}
%    \begin{macrocode}
  \global\letcs{\@gls@loclist}{glo@\glsdetoklabel{#1}@loclist}%
%    \end{macrocode}
% Does this entry have a~parent?
%    \begin{macrocode}
  \ifglshasparent{#1}%
  {%
%    \end{macrocode}
% Has a~parent.
%    \begin{macrocode}
    \gls@level=\csuse{glo@\glsdetoklabel{#1}@level}\relax
    \ifdefvoid{\@gls@loclist}
    {%
      \subglossentry{\gls@level}{#1}{}%
    }%
    {%
      \subglossentry{\gls@level}{#1}%
      {%
        \glossaryentrynumbers{\glsnoidxloclist{\@gls@loclist}}%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Doesn't have a parent
% Get this entry's sort key
%    \begin{macrocode}
    \letcs{\@gls@sort}{glo@\glsdetoklabel{#1}@sort}%
%    \end{macrocode}
% Fetch the first letter:
%    \begin{macrocode}
    \expandafter\glo@grabfirst\@gls@sort{}{}\@nil
    \ifdefequal{\@glo@thislettergrp}{\@gls@currentlettergroup}%
    {}%
    {%
%    \end{macrocode}
% Do the group header:
%    \begin{macrocode}
      \ifdefempty{\@gls@currentlettergroup}{}{\glsgroupskip}%
      \glsgroupheading{\@glo@thislettergrp}%
    }%
    \let\@gls@currentlettergroup\@glo@thislettergrp
%    \end{macrocode}
% Do this entry:
%    \begin{macrocode}
    \ifdefvoid{\@gls@loclist}
    {%
      \glossentry{#1}{}%
    }%
    {%
      \glossentry{#1}%
      {%
        \glossaryentrynumbers{\glsnoidxloclist{\@gls@loclist}}%
      }%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnoidxloclist}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{glsnoidxloclist}\marg{list cs}
%\end{definition}
% Display location list.
%    \begin{macrocode}
\newcommand*{\glsnoidxloclist}[1]{%
  \def\@gls@noidxloclist@sep{}%
  \def\@gls@noidxloclist@prev{}%
  \forlistloop{\glsnoidxloclisthandler}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnoidxloclisthandler}
%\changes{4.04}{2014-03-06}{new}
% Handler for location list iterator.
%    \begin{macrocode}
\newcommand*{\glsnoidxloclisthandler}[1]{%
  \ifdefstring{\@gls@noidxloclist@prev}{#1}%
  {%
%    \end{macrocode}
% Same as previous location so skip.
%    \begin{macrocode}
  }%
  {%
    \@gls@noidxloclist@sep
    #1%
    \def\@gls@noidxloclist@sep{\delimN}%
    \def\@gls@noidxloclist@prev{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnoidxdisplayloclisthandler}
%\changes{4.04}{2014-03-06}{new}
% Handler for location list iterator when used with
% \ics{glsdisplaynumberlist}.
%    \begin{macrocode}
\newcommand*{\glsnoidxdisplayloclisthandler}[1]{%
  \ifdefstring{\@gls@noidxloclist@prev}{#1}%
  {%
%    \end{macrocode}
% Same as previous location so skip.
%    \begin{macrocode}
  }%
  {%
    \@gls@noidxloclist@sep
    \@gls@noidxloclist@prev
    \def\@gls@noidxloclist@prev{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsnoidxdisplayloc}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{glsnoidxdisplayloc}\marg{prefix}\marg{counter}\marg{format}\marg{location}
%\end{definition}
% Display a location in the location list.
%    \begin{macrocode}
\newcommand*\glsnoidxdisplayloc[4]{%
  \setentrycounter[#1]{#2}%
  \csuse{#3}{#4}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@reference}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{@gls@reference}\marg{type}\marg{label}\marg{loc}
%\end{definition}
% Identifies that a reference has been used (for use in the aux file).
% All entries must be defined in the preamble.
%    \begin{macrocode}
\newcommand*{\@gls@reference}[3]{%
%    \end{macrocode}
% Add to label list
%    \begin{macrocode}
  \glsdoifexistsorwarn{#2}%
  {%
    \ifcsundef{@glsref@#1}{\csgdef{@glsref@#1}{}}{}%
    \ifinlistcs{#2}{@glsref@#1}%
    {}%
    {\listcsgadd{@glsref@#1}{#2}}%
%    \end{macrocode}
% Add to location list
%    \begin{macrocode}
    \ifcsundef{glo@\glsdetoklabel{#2}@loclist}%
    {\csgdef{glo@\glsdetoklabel{#2}@loclist}{}}%
    {}%
    \listcsgadd{glo@\glsdetoklabel{#2}@loclist}{#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% The keys that can be used in the optional argument to
% \ics{printglossary} or \ics{printnoidxglossary} 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{\setglossentrycompatibility
      \csname @glsstyle@#1\endcsname}%
  }%
}
%    \end{macrocode}
% \changes{1.14}{2008 June 17}{added numberedsection key to
% \cs{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,nameref}[nolabel]{%
  \ifcase\nr\relax
    \renewcommand*{\@@glossarysecstar}{*}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{}%
  \or
    \renewcommand*{\@@glossarysecstar}{}%
    \renewcommand*{\@@glossaryseclabel}{\label{\glsautoprefix\@glo@type}}%
  \or
    \renewcommand*{\@@glossarysecstar}{*}%
    \renewcommand*{\@@glossaryseclabel}{%
      \protected@edef\@currentlabelname{\glossarytoctitle}%
      \label{\glsautoprefix\@glo@type}}%
  \fi
}
%    \end{macrocode}
%
%\changes{3.08a}{2013-09-28}{added nogroupskip key to \cs{printglossary}}
% The \gloskey[printglossary]{nogroupskip} key determines whether or
% not there should be a vertical gap between glossary groups.
%    \begin{macrocode}
\define@choicekey{printgloss}{nogroupskip}{true,false}[true]{%
  \csuse{glsnogroupskip#1}%
}
%    \end{macrocode}
%
%\changes{4.08}{2014-07-30}{added nopostdot option to
%\texttt{printgloss} family}
% The \gloskey[printglossary]{nopostdot} key has the same effect as
% the package option of the same name.
%    \begin{macrocode}
\define@choicekey{printgloss}{nopostdot}{true,false}[true]{%
  \csuse{glsnopostdot#1}%
}
%    \end{macrocode}
%
%\changes{4.08}{2014-07-30}{added entrycounter option to
%\texttt{printgloss} family}
% The \gloskey[printglossary]{entrycounter} key is the same as the
% package option but localised to the current glossary.
%    \begin{macrocode}
\define@choicekey{printgloss}{entrycounter}{true,false}[true]{%
  \csuse{glsentrycounter#1}%
  \ifglsentrycounter
    \ifx\@gls@counterwithin\@empty
      \newcounter{glossaryentry}%
    \else
      \newcounter{glossaryentry}[\@gls@counterwithin]%
    \fi
    \def\theHglossaryentry{\currentglossary.\theglossaryentry}%
    \renewcommand*{\glsresetentrycounter}{%
      \setcounter{glossaryentry}{0}%
    }%
    \renewcommand*{\glsstepentry}[1]{%
      \refstepcounter{glossaryentry}%
      \label{glsentry-\glsdetoklabel{##1}}%
    }%
    \renewcommand*{\glsentrycounterlabel}{\theglossaryentry.\space}%
    \renewcommand*{\glsentryitem}[1]{%
      \glsstepentry{##1}\glsentrycounterlabel
    }%
  \else
    \renewcommand*{\glsresetentrycounter}{}%
    \renewcommand*{\glsstepentry}[1]{}%
    \renewcommand*{\glsentrycounterlabel}{}%
    \renewcommand*{\glsentryitem}[1]{\glsresetsubentrycounter}
  \fi
}
%    \end{macrocode}
%
%\changes{4.08}{2014-07-30}{added subentrycounter option to
%\texttt{printgloss} family}
% The \gloskey[printglossary]{subentrycounter} key is the same as the
% package option but localised to the current glossary.
% Note that this doesn't affect the master/slave counter attributes,
% which occurs if \pkgopt{subentrycounter} and \pkgopt{entrycounter}
% package options are set to true.
%    \begin{macrocode}
\define@choicekey{printgloss}{subentrycounter}{true,false}[true]{%
  \csuse{glssubentrycounter#1}%
  \ifglssubentrycounter
    \ifundef\c@glossarysubentry
    {%
      \ifglsentrycounter
        \newcounter{glossarysubentry}[glossaryentry]%
      \else
        \newcounter{glossarysubentry}
      \fi
    }{}%
    \renewcommand*{\glsstepsubentry}[1]{%
      \edef\currentglssubentry{\glsdetoklabel{##1}}%
      \refstepcounter{glossarysubentry}%
      \label{glsentry-\currentglssubentry}%
    }%
    \renewcommand*{\glsresetsubentrycounter}{%
      \setcounter{glossarysubentry}{0}%
    }%
    \renewcommand*{\glssubentryitem}[1]{%
      \glsstepsubentry{##1}\glssubentrycounterlabel
    }%
    \renewcommand*{\glssubentrycounterlabel}{\theglossarysubentry)\space}%
    \def\theHglossarysubentry{\currentglssubentry.\theglossarysubentry}
  \else
    \renewcommand*{\glssubentryitem}[1]{}%
    \renewcommand*{\glsstepsubentry}[1]{}%
    \renewcommand*{\glsresetsubentrycounter}{}%
    \renewcommand*{\glssubentrycounterlabel}{}%
  \fi
}
%    \end{macrocode}
%
% \changes{1.14}{2008 June 17}{added nonumberlist key to
% \cs{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}
%
%\changes{4.04}{2014-03-06}{added sort key to printgloss group}
% The \gloskey[printnoidxglossary]{sort} key sets the glossary sort
% handler (\cs{printnoidxglossary} only).
%    \begin{macrocode}
\define@key{printgloss}{sort}{\@glo@assign@sortkey{#1}}
%    \end{macrocode}
%
%\begin{macro}{\@glo@no@assign@sortkey}
% Issue error if used with \cs{printglossary}
%    \begin{macrocode}
\newcommand*{\@glo@no@assign@sortkey}[1]{%
   \PackageError{glossaries}{`sort' key not permitted with
   \string\printglossary}%
   {The `sort' key may only be used with \string\printnoidxglossary}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@glo@assign@sortkey}
% For use with \cs{printnoidxglossary}
%    \begin{macrocode}
\newcommand*{\@@glo@assign@sortkey}[1]{%
  \def\@glo@sorttype{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%
%\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.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsstepentry}[1]{%
    \refstepcounter{glossaryentry}%
    \label{glsentry-\glsdetoklabel{#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.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\ifglssubentrycounter
  \newcommand*{\glsstepsubentry}[1]{%
    \edef\currentglssubentry{\glsdetoklabel{#1}}%
    \refstepcounter{glossarysubentry}%
    \label{glsentry-\currentglssubentry}%
  }
\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}.
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\ifglsentrycounter
  \newcommand*{\glsrefentry}[1]{\ref{glsentry-\glsdetoklabel{#1}}}
\else
  \ifglssubentrycounter
    \newcommand*{\glsrefentry}[1]{\ref{glsentry-\glsdetoklabel{#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}{}{}%
}%
{%
  \@gls@warnontheglossdefined
  \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}
%
% As from version 3.08, glossary information is now written to the
% external files using \ics{glossentry} and \ics{subglossentry}
% instead of \cs{glossaryentryfield} and \cs{glossarysubentryfield}.
% The default definition provides backward compatibility for
% glossary styles that use the old forms.
%\begin{macro}{\compatibleglossentry}
%\changes{3.08a}{2013-09-28}{new}
%\begin{definition}
% \cs{glossentry}\marg{label}\marg{page-list}
%\end{definition}
%    \begin{macrocode}
\providecommand*{\compatibleglossentry}[2]{%
  \toks@{#2}%
  \protected@edef\@do@glossentry{\noexpand\glossaryentryfield{#1}%
    {\noexpand\glsnamefont
       {\expandafter\expandonce\csname glo@#1@name\endcsname}}%
    {\expandafter\expandonce\csname glo@#1@desc\endcsname}%
    {\expandafter\expandonce\csname glo@#1@symbol\endcsname}%
    {\the\toks@}%
  }%
  \@do@glossentry
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossentryname}
%\changes{3.08a}{2013-09-28}{new}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\glossentryname}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \letcs{\glo@name}{glo@\glsdetoklabel{#1}@name}%
    \expandafter\glsnamefont\expandafter{\glo@name}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentryname}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\Glossentryname}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \glsnamefont{\Glsentryname{#1}}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossentrydesc}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\glossentrydesc}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
     \glsentrydesc{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentrydesc}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\Glossentrydesc}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \Glsentrydesc{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossentrysymbol}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\glossentrysymbol}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
     \glsentrysymbol{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentrysymbol}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\Glossentrysymbol}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
     \Glsentrysymbol{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\compatiblesubglossentry}
%\changes{3.08a}{2013-09-28}{new}
%\begin{definition}
% \cs{subglossentry}\marg{level}\marg{label}\marg{page-list}
%\end{definition}
%    \begin{macrocode}
\providecommand*{\compatiblesubglossentry}[3]{%
  \toks@{#3}%
  \protected@edef\@do@subglossentry{\noexpand\glossarysubentryfield{\number#1}%
  {#2}%
    {\noexpand\glsnamefont
      {\expandafter\expandonce\csname glo@#2@name\endcsname}}%
    {\expandafter\expandonce\csname glo@#2@desc\endcsname}%
    {\expandafter\expandonce\csname glo@#2@symbol\endcsname}%
    {\the\toks@}%
  }%
  \@do@subglossentry
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\setglossentrycompatibility}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\setglossentrycompatibility}{%
  \let\glossentry\compatibleglossentry
  \let\subglossentry\compatiblesubglossentry
}
\setglossentrycompatibility
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\glossaryentryfield}
%\begin{definition}
% \cs{glossaryentryfield}\marg{label}\marg{name}\marg{description}\marg{symbol}\marg{page-list}
%\end{definition}
% This command formerly governed how each entry row should be formatted 
% in the glossary. Now deprecated.
%\changes{3.08a}{2013-09-28}{deprecated}
%    \begin{macrocode}
\newcommand{\glossaryentryfield}[5]{%
  \GlossariesWarning
  {Deprecated use of \string\glossaryentryfield.^^J
   I recommend you change to \string\glossentry.^^J
   If you've just upgraded, try removing your gls auxiliary 
   files^^J and recompile}%
  \noindent\textbf{\glstarget{#1}{#2}} #4 #3. #5\par}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glossarysubentryfield}
%\begin{definition}
% \cs{glossarysubentryfield}\marg{level}\marg{label}\marg{name}\marg{description}\marg{symbol}\marg{page-list}
%\end{definition}
% 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]{%
  \GlossariesWarning
  {Deprecated use of \string\glossarysubentryfield.^^J
   I recommend you change to \string\subglossentry.^^J
   If you've just upgraded, try removing your gls auxiliary 
   files^^J and recompile}%
  \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).
%
%\begin{definition}
%\cs{glsgetgrouptitle}\marg{label}
%\end{definition}
% 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.
% Languages other than English may produce labels that are
% non-expandable, so we need to check for that otherwise it will
% create a \qt{missing \cs{endcsname} inserted} error.
%\begin{macro}{\glsgetgrouptitle}
%\changes{3.0}{2011/04/02}{replaced \cs{@ifundefined} with
%\cs{ifcsundef}}
%\changes{3.11a}{2013-10-15}{Added check in case non-Latin alphabet
%in use}
%    \begin{macrocode}
\newcommand*{\glsgetgrouptitle}[1]{%
  \@gls@getgrouptitle{#1}{\@gls@grptitle}%
  \@gls@grptitle
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@getgrouptitle}
% Gets the group title specified by the label (first argument) and
% stores in the second argument, which must be a control sequence.
%    \begin{macrocode}
\newcommand*{\@gls@getgrouptitle}[2]{%
%    \end{macrocode}
% Even if the argument appears to be a single letter, it won't be
% considered a single letter by \cs{dtl@ifsingle} if it's an active
% character.
%    \begin{macrocode}
 \dtl@ifsingle{#1}%
 {%
   \ifcsundef{#1groupname}{\def#2{#1}}{\letcs#2{#1groupname}}%
 }%
 {%
   \ifboolexpr{test{\ifstrequal{#1}{glssymbols}}
            or test{\ifstrequal{#1}{glsnumbers}}}%
   {%
     \ifcsundef{#1groupname}{\def#2{#1}}{\letcs#2{#1groupname}}%
   }%
   {%
     \def#2{#1}%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@gls@getothergrouptitle}
%\changes{4.04}{2014-03-06}{new}
% Version for the no-indexing app option:
%    \begin{macrocode}
\newcommand*{\@gls@noidx@getgrouptitle}[2]{%
  \DTLifint{#1}%
  {\edef#2{\char#1\relax}}%
  {%
    \ifcsundef{#1groupname}{\def#2{#1}}{\letcs#2{#1groupname}}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{definition}
%\cs{glsgetgrouplabel}\marg{title}
%\end{definition}
%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}
%\changes{3.05}{2013-04-21}{fixed bug (typo in \cs{equal})}
%    \begin{macrocode}
\newcommand*{\glsgetgrouplabel}[1]{%
\ifthenelse{\equal{#1}{\glssymbolsgroupname}}{glssymbols}{%
\ifthenelse{\equal{#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{setglossarystyle}\marg{style}.
%\begin{macro}{\setglossarystyle}
%\changes{3.08a}{2013-09-28}{new}
%    \begin{macrocode}
\newcommand*{\setglossarystyle}[1]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}{Glossary style `#1' undefined}{}%
  }%
  {%
    \csname @glsstyle@#1\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%\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}{}%
  }%
  {%
    \GlossariesWarning
    {Deprecated command \string\glossarystyle.^^J
     I recommend you switch to \string\setglossarystyle\space unless 
     you want to maintain backward compatibility}%
    \setglossentrycompatibility
    \csname @glsstyle@#1\endcsname
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{fixed bug caused by using \cs{ifdef} instead of
%\cs{ifcsdef}}
%    \begin{macrocode}
    \ifcsdef{@glscompstyle@#1}%
    {\setglossentrycompatibility\csuse{@glscompstyle@#1}}%
    {}%
  }%
}
%    \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 \cs{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:code:acronym}
%\begin{macro}{\oldacronym}
%\begin{definition}
%\cs{oldacronym}\oarg{label}\marg{abbrv}\marg{long}\marg{key-val list}
%\end{definition}
% 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}
%
%\begin{definition}
% \cs{newacronym}\oarg{key-val list}\marg{label}\marg{abbrev}\marg{long}
%\end{definition}
% This is a quick way of defining acronyms,
% using \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
% \cs{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}
% If \sty{garamondx} has been loaded, need to use \cs{textulc}
% instead of \cs{textup}.
%\begin{macro}{\glstextup}
%\changes{3.09a}{2013-10-09}{new}
%    \begin{macrocode}
\newrobustcmd*{\glstextup}[1]{\ifdef\textulc{\textulc{#1}}{\textup{#1}}}
%    \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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrfull}{\@gls@hyp@opt\ns@acrfull}
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{removed \cs{@sacrfull}}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\ns@acrfull[2][]{%
  \new@ifnextchar[{\@acrfull{#1}{#2}}%
                  {\@acrfull{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@acrfull}
%\changes{4.02}{2013-12-05}{now using \cs{acrfullfmt}}
% Low-level macro:
%    \begin{macrocode}
\def\@acrfull#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \acrfullfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
% Using \cs{acrlinkfullformat} and \cs{acrfullformat} is now
% deprecated as it can cause complications with the first letter
% upper case variants, but the package needs to provide backward
% compatibility support.
%
%\begin{macro}{\acrfullfmt}
%\changes{4.02}{2013-12-05}{new}
% No case change full format.
%    \begin{macrocode}
\newcommand*{\acrfullfmt}[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\glsspace(#2)}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsspace}
% Robust space to ensure it's written to the \texttt{.glsdefs} file.
%\changes{4.08}{2014-07-30}{new}
%    \begin{macrocode}
\newrobustcmd{\glsspace}{\space}
%    \end{macrocode}
%\end{macro}
%
% Default format for full acronym
%\begin{macro}{\Acrfull}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrfull}{\@gls@hyp@opt\ns@Acrfull}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%\changes{4.08}{2014-07-30}{removed \cs{@sAcrfull}}
%    \begin{macrocode}
\newcommand*\ns@Acrfull[2][]{%
  \new@ifnextchar[{\@Acrfull{#1}{#2}}%
                  {\@Acrfull{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@Acrfull#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \Acrfullfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Acrfullfmt}
%\changes{4.02}{2013-12-05}{new}
% First letter upper case full format.
%    \begin{macrocode}
\newcommand*{\Acrfullfmt}[3]{%
  \acrlinkfullformat{\@Acrlong}{\@acrshort}{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ACRfull}
%\changes{3.01}{2011/04/12}{made robust}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRfull}{\@gls@hyp@opt\ns@ACRfull}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%\changes{4.08}{2014-07-30}{removed \cs{s@ACRfull}}
%    \begin{macrocode}
\newcommand*\ns@ACRfull[2][]{%
  \new@ifnextchar[{\@ACRfull{#1}{#2}}%
                  {\@ACRfull{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@ACRfull#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \ACRfullfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ACRfullfmt}
%\changes{4.02}{2013-12-05}{new}
% All upper case full format.
%    \begin{macrocode}
\newcommand*{\ACRfullfmt}[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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\acrfullpl}{\@gls@hyp@opt\ns@acrfullpl}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%\changes{4.08}{2014-07-30}{removed \cs{s@acrfullpl}}
%    \begin{macrocode}
\newcommand*\ns@acrfullpl[2][]{%
  \new@ifnextchar[{\@acrfullpl{#1}{#2}}%
                  {\@acrfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@acrfullpl#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \acrfullplfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\acrfullplfmt}
%\changes{4.02}{2013-12-05}{new}
% No case change plural full format.
%    \begin{macrocode}
\newcommand*{\acrfullplfmt}[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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\Acrfullpl}{\@gls@hyp@opt\ns@Acrfullpl}
%    \end{macrocode}
%\changes{4.08}{2014-07-30}{removed \cs{s@Acrfullpl}}
%\changes{3.0}{2011/04/02}{added starred version}
%    \begin{macrocode}
\newcommand*\ns@Acrfullpl[2][]{%
  \new@ifnextchar[{\@Acrfullpl{#1}{#2}}%
                  {\@Acrfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@Acrfullpl#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \Acrfullplfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Acrfullplfmt}
%\changes{4.02}{2013-12-05}{new}
% First letter upper case plural full format.
%\changes{4.07}{2014-04-04}{fixed no case change bug}
%    \begin{macrocode}
\newcommand*{\Acrfullplfmt}[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}
%\changes{4.08}{2014-07-30}{switched to using \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd*{\ACRfullpl}{\@gls@hyp@opt\ns@ACRfullpl}
%    \end{macrocode}
%\changes{3.0}{2011/04/02}{added starred version}
%\changes{4.08}{2014-07-30}{removed \cs{s@ACRfullpl}}
%    \begin{macrocode}
\newcommand*\ns@ACRfullpl[2][]{%
  \new@ifnextchar[{\@ACRfullpl{#1}{#2}}%
                  {\@ACRfullpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Low-level macro:
%    \begin{macrocode}
\def\@ACRfullpl#1#2[#3]{%
%    \end{macrocode}
% Make it easier for acronym styles to change this:
%    \begin{macrocode}
  \ACRfullplfmt{#1}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ACRfullplfmt}
%\changes{4.02}{2013-12-05}{new}
% All upper case plural full format.
%    \begin{macrocode}
\newcommand*{\ACRfullplfmt}[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}{\SetGenericNewAcronym}
% New improved version of setting the acronym style.
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\newcommand*{\SetGenericNewAcronym}{%
%    \end{macrocode}
% Change the behaviour of \cs{Glsentryname} to workaround expansion
% issues that cause a problem for \cs{makefirstuc}
%    \begin{macrocode}
  \let\@Gls@entryname\@Gls@acrentryname
%    \end{macrocode}
% Change the way acronyms are defined:
%    \begin{macrocode}
  \renewcommand{\newacronym}[4][]{%
    \ifdefempty{\@glsacronymlists}%
    {%
      \def\@glo@type{\acronymtype}%
      \setkeys{glossentry}{##1}%
      \DeclareAcronymList{\@glo@type}%
    }%
    {}%
    \glskeylisttok{##1}%
    \glslabeltok{##2}%
    \glsshorttok{##3}%
    \glslongtok{##4}%
    \newacronymhook
    \protected@edef\@do@newglossaryentry{%
      \noexpand\newglossaryentry{\the\glslabeltok}%
      {%
        type=\acronymtype,%
        name={\expandonce{\acronymentry{##2}}},%
        sort={\acronymsort{\the\glsshorttok}{\the\glslongtok}},%
        text={\the\glsshorttok},%
        short={\the\glsshorttok},%
        shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
        long={\the\glslongtok},%
        longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
        \GenericAcronymFields,%
        \the\glskeylisttok
      }%
    }%
    \@do@newglossaryentry
  }%
%    \end{macrocode}
% Make sure that \ics{acrfull} etc reflects the new style:
%    \begin{macrocode}
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{\genacrfullformat{##2}{##3}}}%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{\Genacrfullformat{##2}{##3}}}%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\genacrfullformat{##2}{##3}}}}%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\genplacrfullformat{##2}{##3}}}%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\Genplacrfullformat{##2}{##3}}}%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\genplacrfullformat{##2}{##3}}}}%
%    \end{macrocode}
% Make sure that \ics{glsentryfull} etc reflects the new style:
%    \begin{macrocode}
  \renewcommand*{\glsentryfull}[1]{\genacrfullformat{##1}{}}%
  \renewcommand*{\Glsentryfull}[1]{\Genacrfullformat{##1}{}}%
  \renewcommand*{\glsentryfullpl}[1]{\genplacrfullformat{##1}{}}%
  \renewcommand*{\Glsentryfullpl}[1]{\Genplacrfullformat{##1}{}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GenericAcronymFields}
%\changes{4.02}{2013-12-05}{new}
% Fields used by \cs{SetGenericNewAcronym} that can be changed by
% the acronym style.
%    \begin{macrocode}
\newcommand*{\GenericAcronymFields}{description={\the\glslongtok}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\acronymentry}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{acronymentry}\marg{label}
%\end{definition}
% Display style for the name field in the list of acronyms.
%    \begin{macrocode}
\newcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{#1}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\acronymsort}
%\begin{definition}
%\cs{acronymsort}\marg{short}\marg{long}
%\end{definition}
% Default sort format for acronyms.
%    \begin{macrocode}
\newcommand*{\acronymsort}[2]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\setacronymstyle}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{setacronymstyle}\marg{style name}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\setacronymstyle}[1]{%
  \ifcsundef{@glsacr@dispstyle@#1}
  {%
    \PackageError{glossaries}{Undefined acronym style `#1'}{}%
  }%
  {%
    \ifdefempty{\@glsacronymlists}%
    {%
      \DeclareAcronymList{\acronymtype}%
    }%
    {}%
    \SetGenericNewAcronym
    \GlsUseAcrStyleDefs{#1}%
    \@for\@gls@type:=\@glsacronymlists\do{%
      \defglsentryfmt[\@gls@type]{\GlsUseAcrEntryDispStyle{#1}}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newacronymstyle}
%\changes{4.02}{2013-12-05}{new}
%\begin{definition}
%\cs{newacronymstyle}\marg{style name}\marg{entry format
%definition}\marg{display definitions}
%\end{definition}
% Defines a new acronym style called \meta{style name}.
%    \begin{macrocode}
\newcommand*{\newacronymstyle}[3]{%
  \ifcsdef{@glsacr@dispstyle@#1}%
  {%
    \PackageError{glossaries}{Acronym style `#1' already exists}{}%
  }%
  {%
    \csdef{@glsacr@dispstyle@#1}{#2}%
    \csdef{@glsacr@styledefs@#1}{#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\renewacronymstyle}
% Redefines the given acronym style.
%\changes{4.03}{2014-01-20}{new}
%    \begin{macrocode}
\newcommand*{\renewacronymstyle}[3]{%
  \ifcsdef{@glsacr@dispstyle@#1}%
  {%
    \csdef{@glsacr@dispstyle@#1}{#2}%
    \csdef{@glsacr@styledefs@#1}{#3}%
  }%
  {%
    \PackageError{glossaries}{Acronym style `#1' doesn't exist}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsUseAcrEntryDispStyle}
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\newcommand*{\GlsUseAcrEntryDispStyle}[1]{\csuse{@glsacr@dispstyle@#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\GlsUseAcrStyleDefs}
%\changes{4.02}{2013-12-05}{new}
%    \begin{macrocode}
\newcommand*{\GlsUseAcrStyleDefs}[1]{\csuse{@glsacr@styledefs@#1}}
%    \end{macrocode}
%\end{macro}
%
%Predefined acronym styles:
%\begin{acrstyle}{long-short}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\meta{short}) acronym style.
%    \begin{macrocode}
\newacronymstyle{long-short}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \Glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \Glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{short-long}
%\changes{4.02}{2013-12-05}{new}
% \meta{short} (\meta{long}) acronym style.
%    \begin{macrocode}
\newacronymstyle{short-long}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
  \renewcommand*{\genacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshort{##1}}##2\space
   (\glsentrylong{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \protect\firstacronymfont{\Glsentryshort{##1}}##2\space
   (\glsentrylong{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshortpl{##1}}##2\space
   (\glsentrylongpl{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \protect\firstacronymfont{\Glsentryshortpl{##1}}##2\space
   (\glsentrylongpl{##1})%
  }%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{commented spurious EOL}
%    \begin{macrocode}
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sc-short}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsc}\marg{short}) acronym style.
%    \begin{macrocode}
\newacronymstyle{long-sc-short}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand{\acronymfont}[1]{\textsc{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sm-short}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsmaller}\marg{short}) acronym style.
%    \begin{macrocode}
\newacronymstyle{long-sm-short}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand{\acronymfont}[1]{\textsmaller{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sc-short-long}
%\changes{4.02}{2013-12-05}{new}
% \meta{short} (\cs{textsc}\marg{long}) acronym style.
%    \begin{macrocode}
\newacronymstyle{sc-short-long}%
{%
  \GlsUseAcrEntryDispStyle{short-long}%
}%
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand{\acronymfont}[1]{\textsc{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sm-short-long}
%\changes{4.02}{2013-12-05}{new}
% \meta{short} (\cs{textsmaller}\marg{long}) acronym style.
%    \begin{macrocode}
\newacronymstyle{sm-short-long}%
{%
  \GlsUseAcrEntryDispStyle{short-long}%
}%
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand{\acronymfont}[1]{\textsmaller{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-short-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{long-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sc-short-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsc}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{long-sc-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-sc-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-sc-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sm-short-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsmaller}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{long-sm-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-sm-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-sm-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{short-long-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{short} (\marg{long}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{short-long}%
}%
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sc-short-long-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsc}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{sc-short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{sc-short-long}%
}%
{%
  \GlsUseAcrStyleDefs{sc-short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sm-short-long-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} (\cs{textsmaller}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{sm-short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{sm-short-long}%
}%
{%
  \GlsUseAcrStyleDefs{sm-short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{dua}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} only acronym style.
%    \begin{macrocode}
\newacronymstyle{dua}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifdefempty\glscustomtext
  {%
    \ifglshaslong{\glslabel}%
    {%
      \glsifplural
      {%
%    \end{macrocode}
% Plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Plural form, don't adjust case:
%    \begin{macrocode}
          \glsentrylongpl{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Plural form, make first letter upper case:
%    \begin{macrocode}
          \Glsentrylongpl{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\glsentrylongpl{\glslabel}\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Singular form, don't adjust case:
%    \begin{macrocode}
          \glsentrylong{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, make first letter upper case:
%    \begin{macrocode}
          \Glsentrylong{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\glsentrylong{\glslabel}\glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Not an acronym:
%    \begin{macrocode}
      \glsgenentryfmt
    }%
  }%
  {\glscustomtext\glsinsert}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{fixed bug in \cs{acrfullfmt}}
%    \begin{macrocode}
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{\glsentrylong{##2}##3\space
      (\acronymfont{\glsentryshort{##2}})}}%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{\Glsentrylong{##2}##3\space
      (\acronymfont{\glsentryshort{##2}})}}%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\glsentrylong{##2}##3\space
      (\acronymfont{\glsentryshort{##2}})}}}%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{fixed bug in \cs{acrfullplfmt}}
%    \begin{macrocode}
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\glsentrylongpl{##2}##3\space
      (\acronymfont{\glsentryshortpl{##2}})}}%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{fixed bug in \cs{Acrfullplfmt}}
%    \begin{macrocode}
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\Glsentrylongpl{##2}##3\space
      (\acronymfont{\glsentryshortpl{##2}})}}%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\glsentrylongpl{##2}##3\space
      (\acronymfont{\glsentryshortpl{##2}})}}}%
  \renewcommand*{\glsentryfull}[1]{%
    \glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Glsentryfull}[1]{%
    \Glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\glsentryfullpl}[1]{%
    \glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Glsentryfullpl}[1]{%
    \Glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{dua-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{long} only acronym style with user-supplied description.
%    \begin{macrocode}
\newacronymstyle{dua-desc}%
{%
  \GlsUseAcrEntryDispStyle{dua}%
}%
{%
  \GlsUseAcrStyleDefs{dua}%
  \renewcommand*{\GenericAcronymFields}{}%
%    \end{macrocode}
%\changes{4.03}{2014-01-20}{commented spurious EOL}
%    \begin{macrocode}
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentrylong{##1}}}%
  \renewcommand*{\acronymsort}[2]{##2}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote}
%\changes{4.02}{2013-12-05}{new}
% \meta{short}\cs{footnote}\marg{long} acronym style.
%    \begin{macrocode}
\newacronymstyle{footnote}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
%    \end{macrocode}
% Need to ensure hyperlinks are switched off on first use:
%    \begin{macrocode}
  \glshyperfirstfalse
  \renewcommand*{\genacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshort{##1}}##2%
   \protect\footnote{\glsentrylong{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \protect\footnote{\glsentrylong{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshortpl{##1}}##2%
   \protect\footnote{\glsentrylongpl{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \protect\firstacronymfont{\Glsentryshortpl{##1}}##2%
   \protect\footnote{\glsentrylongpl{##1}}%
  }%
  \renewcommand*{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
%    \end{macrocode}
% Don't use footnotes for \ics{acrfull}:
%    \begin{macrocode}
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{\acronymfont{\glsentryshort{##2}}##3\space
      (\glsentrylong{##2})}}%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{\acronymfont{\Glsentryshort{##2}}##3\space
      (\glsentrylong{##2})}}%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\acronymfont{\glsentryshort{##2}}##3\space
      (\glsentrylong{##2})}}}%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\acronymfont{\glsentryshortpl{##2}}##3\space
      (\glsentrylongpl{##2})}}%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{\acronymfont{\Glsentryshortpl{##2}}##3\space
      (\glsentrylongpl{##2})}}%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \mfirstucMakeUppercase{\acronymfont{\glsentryshortpl{##2}}##3\space
      (\glsentrylongpl{##2})}}}%
%    \end{macrocode}
% Similarly for \ics{glsentryfull} etc:
%    \begin{macrocode}
  \renewcommand*{\glsentryfull}[1]{%
     \acronymfont{\glsentryshort{##1}}\space(\glsentrylong{##1})}%
  \renewcommand*{\Glsentryfull}[1]{%
     \acronymfont{\Glsentryshort{##1}}\space(\glsentrylong{##1})}%
  \renewcommand*{\glsentryfullpl}[1]{%
     \acronymfont{\glsentryshortpl{##1}}\space(\glsentrylongpl{##1})}%
  \renewcommand*{\Glsentryfullpl}[1]{%
     \acronymfont{\Glsentryshortpl{##1}}\space(\glsentrylongpl{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sc}
%\changes{4.02}{2013-12-05}{new}
% \cs{textsc}\marg{short}\cs{footnote}\marg{long} acronym style.
%    \begin{macrocode}
\newacronymstyle{footnote-sc}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}
  \renewcommand{\acronymfont}[1]{\textsc{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sm}
%\changes{4.02}{2013-12-05}{new}
% \cs{textsmaller}\marg{short}\cs{footnote}\marg{long} acronym style.
%    \begin{macrocode}
\newacronymstyle{footnote-sm}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand{\acronymentry}[1]{\acronymfont{\glsentryshort{##1}}}
  \renewcommand{\acronymfont}[1]{\textsmaller{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-desc}
%\changes{4.02}{2013-12-05}{new}
% \meta{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{footnote-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sc-desc}
%\changes{4.02}{2013-12-05}{new}
% \cs{textsc}\marg{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{footnote-sc-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote-sc}%
}%
{%
  \GlsUseAcrStyleDefs{footnote-sc}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sm-desc}
%\changes{4.02}{2013-12-05}{new}
% \cs{textsmaller}\marg{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%    \begin{macrocode}
\newacronymstyle{footnote-sm-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote-sm}%
}%
{%
  \GlsUseAcrStyleDefs{footnote-sm}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glsentrylong{##1}\space (\acronymfont{\glsentryshort{##1}})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%
%
%\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}
%
% These commands for setting the style are now deprecated but are
% kept for backward compatibility.
%
%\begin{macro}{\SetDefaultAcronymDisplayStyle}
% Sets the default acronym display style for given glossary.
%\changes{2.04}{2009 November 10}{new}
%\changes{3.11a}{2013-10-15}{changed to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetDefaultAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{\glsgenentryfmt}%
}
%    \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={\noexpand\expandonce\noexpand\@glo@shortpl},%
      firstplural={\acrfullformat{\noexpand\expandonce\noexpand\@glo@longpl}%
                                 {\noexpand\expandonce\noexpand\@glo@shortpl}},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\noexpand\expandonce\noexpand\@glo@longpl},%
%    \end{macrocode}
% Remaining options specified by the user:
%    \begin{macrocode}
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetDescriptionFootnoteAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{%
%    \end{macrocode}
%\changes{4.02}{2013-12-05}{Moved check for empty custom text to prevent
%unwanted parenthetical material}
%    \begin{macrocode}
    \ifdefempty\glscustomtext
    {%
      \ifglsused{\glslabel}%
      {%
        \acronymfont{\glsgenentryfmt}%
      }%
      {%
        \firstacronymfont{\glsgenentryfmt}%
        \ifglshassymbol{\glslabel}%
        {%
          \expandafter\protect\expandafter\acrfootnote\expandafter
           {\@gls@link@opts}{\@gls@link@label}%
           {%
            \glsifplural
              {\glsentrysymbolplural{\glslabel}}%
              {\glsentrysymbol{\glslabel}}%
           }%
        }%
      }%
    }%
    {\glscustomtext\glsinsert}%
  }%
}
%    \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},%
      first={\the\glsshorttok},%
      firstplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      text={\the\glsshorttok},%
      plural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      symbol={\the\glslongtok},%
      symbolplural={\noexpand\expandonce\noexpand\@glo@longpl},%
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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 \cs{protect} before \cs{footnote}
% and \cs{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 \cs{acronymfont} to use
%\cs{textsmaller} instead
%of \cs{smaller}}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand*{\acronymfont}[1]{\textsc{##1}}%
%    \end{macrocode}
%    \begin{macrocode}
    \renewcommand*{\acrpluralsuffix}{%
      \glstextup{\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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetDescriptionDUAAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{\glsgenentryfmt}%
}
%    \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},%
      first={\the\glslongtok},%
      plural={\noexpand\expandonce\noexpand\@glo@longpl},%
      firstplural={\noexpand\expandonce\noexpand\@glo@longpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      symbol={\the\glsshorttok},%
      symbolplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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}
%\changes{3.07}{2013-07-05}{now using \cs{glsdoparenifnotempty}}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetDescriptionAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{%
%    \end{macrocode}
%\changes{4.02}{2013-12-05}{Moved check for empty custom text to prevent
%unwanted parenthetical material}
%    \begin{macrocode}
    \ifdefempty\glscustomtext
    {%
      \ifglsused{\glslabel}%
      {%
%    \end{macrocode}
% Move the inserted text outside of \cs{acronymfont}
%    \begin{macrocode}
        \let\gls@org@insert\glsinsert
        \let\glsinsert\@empty
        \acronymfont{\glsgenentryfmt}\gls@org@insert
      }%
      {%
        \glsgenentryfmt
        \ifglshassymbol{\glslabel}%
          {%
             \glsifplural
             {%
               \def\@glo@symbol{\glsentrysymbolplural{\glslabel}}%
             }%
             {%
               \def\@glo@symbol{\glsentrysymbol{\glslabel}}%
             }%
             \space(\protect\firstacronymfont
             {\glscapscase
              {\@glo@symbol}
              {\@glo@symbol}
              {\mfirstucMakeUppercase{\@glo@symbol}}})%
          }%
          {}%
      }%
    }%
    {\glscustomtext\glsinsert}%
  }%
}
%    \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={\noexpand\expandonce\noexpand\@glo@longpl},%
      text={\the\glsshorttok},%
      plural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      symbol={\noexpand\@glo@text},%
      symbolplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      \the\glskeylisttok}%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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 \cs{acronymfont} to use
%\cs{textsmaller} instead
%of \cs{smaller}}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand{\acronymfont}[1]{\textsc{##1}}
    \renewcommand*{\acrpluralsuffix}{%
      \glstextup{\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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetFootnoteAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{%
%    \end{macrocode}
%\changes{4.02}{2013-12-05}{Moved check for empty custom text to prevent
%unwanted parenthetical material}
%    \begin{macrocode}
    \ifdefempty\glscustomtext
    {%
%    \end{macrocode}
% Move the inserted text outside of \cs{acronymfont}
%    \begin{macrocode}
      \let\gls@org@insert\glsinsert
      \let\glsinsert\@empty
      \ifglsused{\glslabel}%
      {%
        \acronymfont{\glsgenentryfmt}\gls@org@insert
      }%
      {%
        \firstacronymfont{\glsgenentryfmt}\gls@org@insert
        \ifglshaslong{\glslabel}%
        {%
          \expandafter\protect\expandafter\acrfootnote\expandafter
           {\@gls@link@opts}{\@gls@link@label}%
           {%
            \glsifplural
              {\glsentrylongpl{\glslabel}}%
              {\glsentrylong{\glslabel}}%
           }%
        }%
%    \end{macrocode}
%\changes{3.13a}{2013-11-05}{fixed missing argument bug}
%    \begin{macrocode}
        {}%
      }%
    }%
    {\glscustomtext\glsinsert}%
  }%
}
%    \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={\noexpand\expandonce\noexpand\@glo@shortpl},%
      first={\the\glsshorttok},%
      firstplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\noexpand\expandonce\noexpand\@glo@longpl},%
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@descplural\@org@gls@assign@descplural
}
%    \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 \cs{protect} before \cs{footnote} and
% \cs{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 \cs{acronymfont} to use
%\cs{textsmaller} instead
%of \cs{smaller}}
%    \begin{macrocode}
  \ifglsacrsmallcaps
     \renewcommand*{\acronymfont}[1]{\textsc{##1}}%
     \renewcommand*{\acrpluralsuffix}{%
        \glstextup{\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}{\glsdoparenifnotempty}
% Do a space followed by the argument if the argument doesn't expand
% to empty or \cs{relax}. If argument isn't empty (or \cs{relax}), apply 
% the macro to it given in the second argument.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsdoparenifnotempty}[2]{%
  \protected@edef\gls@tmp{#1}%
  \ifdefempty\gls@tmp
  {}%
  {%
    \ifx\gls@tmp\@gls@default@value
    \else
      \space (#2{#1})%
    \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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetSmallAcronymDisplayStyle}[1]{%
  \defglsentryfmt[#1]{%
%    \end{macrocode}
%\changes{4.02}{2013-12-05}{Moved check for empty custom text to prevent
%unwanted parenthetical material}
%    \begin{macrocode}
    \ifdefempty\glscustomtext
    {%
%    \end{macrocode}
% Move the inserted text outside of \cs{acronymfont}
%    \begin{macrocode}
      \let\gls@org@insert\glsinsert
      \let\glsinsert\@empty
      \ifglsused{\glslabel}%
      {%
        \acronymfont{\glsgenentryfmt}\gls@org@insert
      }%
      {%
        \glsgenentryfmt
        \ifglshassymbol{\glslabel}%
        {%
          \glsifplural
          {%
            \def\@glo@symbol{\glsentrysymbolplural{\glslabel}}%
          }%
          {%
            \def\@glo@symbol{\glsentrysymbol{\glslabel}}%
          }%
          \space
            (\glscapscase
            {\firstacronymfont{\@glo@symbol}}%
            {\firstacronymfont{\@glo@symbol}}%
            {\firstacronymfont{\mfirstucMakeUppercase{\@glo@symbol}}})%
        }%
        {}%
      }%
    }%
    {\glscustomtext\glsinsert}%
  }%
}
%    \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={\the\glsshorttok},%
%    \end{macrocode}
% Default to the short plural.
%    \begin{macrocode}
      plural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      first={\the\glslongtok},%
%    \end{macrocode}
% Default to the long plural.
%    \begin{macrocode}
      firstplural={\noexpand\expandonce\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\expandonce\noexpand\@glo@longpl},%
      symbol={\the\glsshorttok},%
%    \end{macrocode}
% Default to the short plural.
%    \begin{macrocode}
      symbolplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@descplural\@org@gls@assign@descplural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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 \cs{acronymfont} to use
%\cs{textsmaller} instead
%of \cs{smaller}}
%    \begin{macrocode}
  \ifglsacrsmallcaps
    \renewcommand*{\acronymfont}[1]{\textsc{##1}}
    \renewcommand*{\acrpluralsuffix}{%
       \glstextup{\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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetDUADisplayStyle}[1]{%
  \defglsentryfmt[#1]{\glsgenentryfmt}%
}
%    \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},%
      first={\the\glslongtok},%
      plural={\noexpand\expandonce\noexpand\@glo@longpl},%
      firstplural={\noexpand\expandonce\noexpand\@glo@longpl},%
      short={\the\glsshorttok},%
      shortplural={\the\glsshorttok\noexpand\acrpluralsuffix},%
      long={\the\glslongtok},%
      longplural={\the\glslongtok\noexpand\acrpluralsuffix},%
      description={\the\glslongtok},%
      descriptionplural={\noexpand\expandonce\noexpand\@glo@longpl},%
      symbol={\the\glsshorttok},%
      symbolplural={\noexpand\expandonce\noexpand\@glo@shortpl},%
      \the\glskeylisttok
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
  \let\gls@assign@descplural\@org@gls@assign@descplural
}
%    \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}
%\changes{3.11a}{2013-10-15}{updated to use \cs{defglsentryfmt}}
%    \begin{macrocode}
\newcommand*{\SetCustomDisplayStyle}[1]{%
  \defglsentryfmt[#1]{\glsgenentryfmt}%
}
%    \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={\acrfullformat{\the\glslongtok}{\the\glsshorttok}},%
  firstplural={\acrfullformat
    {\noexpand\glsentrylongpl{\the\glslabeltok}}%
    {\noexpand\glsentryshortpl{\the\glslabeltok}}},%
%    \end{macrocode}
% \changes{4.01}{2013-11-16}{inserted missing comma}
%    \begin{macrocode}
  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}
%
%
% \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
  \setglossarystyle{\@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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloparent}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglolevel}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglotext}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloplural}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglofirst}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglofirstpl}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglotype}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglocounter}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouseri}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouserii}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouseriii}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouseriv}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouserv}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglouservi}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloname}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglodesc}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglodescplural}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglosort}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglosymbol}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglosymbolplural}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@symbolplural\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloshort}
%\changes{3.11a}{2013-10-15}{new}
%\begin{definition}
%\cs{showgloshort}\marg{label}
%\end{definition}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloshort}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@short\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showglolong}
%\changes{3.11a}{2013-10-15}{new}
%\begin{definition}
%\cs{showglolong}\marg{label}
%\end{definition}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglolong}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@long\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloindex}
%\changes{3.0}{2011/04/02}{new}
%\begin{definition}
%\cs{showgloindex}\marg{label}
%\end{definition}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloindex}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloflag}[1]{%
  \expandafter\show\csname ifglo@\glsdetoklabel{#1}@flag\endcsname
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\showgloloclist}
%\changes{4.04}{2014-03-06}{new}
%\begin{definition}
%\cs{showgloloclist}\marg{label}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\showgloloclist}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@loclist\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}
%<*glossaries-prefix.sty>
%    \end{macrocode}
%\fi
%\section{Prefix Support (glossaries-prefix Code)}
%\label{sec:code:prefix}
%\changes{3.14a}{2013-11-12}{new}
% This package provides a means of adding prefixes to your glossary
% entries. For example, you may want to use ``a
% \cs{gls}\marg{label}'' on first use but use ``an
% \cs{gls}\marg{label}'' on subsequent use.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-prefix}[2014/07/30 v4.08 (NLCT)]
%    \end{macrocode}
% Pass all options to \sty{glossaries}:
%    \begin{macrocode}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{glossaries}}
%    \end{macrocode}
% Process options:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
% Load \sty{glossaries}:
%    \begin{macrocode}
\RequirePackage{glossaries}
%    \end{macrocode}
% Add the new keys:
%    \begin{macrocode}
\define@key{glossentry}{prefixfirst}{\def\@glo@entryprefixfirst{#1}}%
\define@key{glossentry}{prefixfirstplural}{\def\@glo@entryprefixfirstplural{#1}}%
\define@key{glossentry}{prefix}{\def\@glo@entryprefix{#1}}%
\define@key{glossentry}{prefixplural}{\def\@glo@entryprefixplural{#1}}%
%    \end{macrocode}
% Add them to \ics{@gls@keymap}:
%    \begin{macrocode}
\appto\@gls@keymap{,%
   {prefixfirst}{prefixfirst},%
   {prefixfirstplural}{prefixfirstplural},%
   {prefix}{prefix},%
   {prefixplural}{prefixplural}%
 }
%    \end{macrocode}
% Set the default values:
%    \begin{macrocode}
\appto\@newglossaryentryprehook{%
  \def\@glo@entryprefix{}%
  \def\@glo@entryprefixplural{}%
  \let\@glo@entryprefixfirst\@gls@default@value
  \let\@glo@entryprefixfirstplural\@gls@default@value
}
%    \end{macrocode}
% Set the assignment code:
%    \begin{macrocode}
\appto\@newglossaryentryposthook{%
  \gls@assign@field{}{\@glo@label}{prefix}{\@glo@entryprefix}%
  \gls@assign@field{}{\@glo@label}{prefixplural}{\@glo@entryprefixplural}%
%    \end{macrocode}
% If \gloskey{prefixfirst} has not been supplied, make it the same
% as \gloskey{prefix}.
%    \begin{macrocode}
  \expandafter\gls@assign@field\expandafter
    {\csname glo@\@glo@label @prefix\endcsname}{\@glo@label}{prefixfirst}%
    {\@glo@entryprefixfirst}%
%    \end{macrocode}
% If \gloskey{prefixfirstplural} has not been supplied, make it the same
% as \gloskey{prefixplural}.
%    \begin{macrocode}
  \expandafter\gls@assign@field\expandafter
    {\csname glo@\@glo@label @prefixplural\endcsname}{\@glo@label}%
    {prefixfirstplural}{\@glo@entryprefixfirstplural}%
}
%    \end{macrocode}
%
% Define commands to access these fields:
%\begin{macro}{\glsentryprefixfirst}
%    \begin{macrocode}
\newcommand*{\glsentryprefixfirst}[1]{\csuse{glo@#1@prefixfirst}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryprefixfirstplural}
%    \begin{macrocode}
\newcommand*{\glsentryprefixfirstplural}[1]{\csuse{glo@#1@prefixfirstplural}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryprefix}
%    \begin{macrocode}
\newcommand*{\glsentryprefix}[1]{\csuse{glo@#1@prefix}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryprefixplural}
%    \begin{macrocode}
\newcommand*{\glsentryprefixplural}[1]{\csuse{glo@#1@prefixplural}}
%    \end{macrocode}
%\end{macro}
%
% Now for the initial upper case variants:
%\begin{macro}{\Glsentryprefixfirst}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryprefixfirst}[1]{%
  \protected@edef\@glo@text{\csname glo@#1@prefixfirst\endcsname}%
  \xmakefirstuc\@glo@text
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryprefixfirstplural}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryprefixfirstplural}[1]{%
  \protected@edef\@glo@text{\csname glo@#1@prefixfirstplural\endcsname}%
  \xmakefirstuc\@glo@text
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryprefix}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryprefix}[1]{%
  \protected@edef\@glo@text{\csname glo@#1@prefix\endcsname}%
  \xmakefirstuc\@glo@text
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsentryprefixplural}
%    \begin{macrocode}
\newrobustcmd*{\Glsentryprefixplural}[1]{%
  \protected@edef\@glo@text{\csname glo@#1@prefixplural\endcsname}%
  \xmakefirstuc\@glo@text
}
%    \end{macrocode}
%\end{macro}
%
% Define commands to determine if the prefix keys have been set:
%\begin{macro}{\ifglshasprefix}
%    \begin{macrocode}
\newcommand*{\ifglshasprefix}[3]{%
  \ifcsempty{glo@#1@prefix}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifglshasprefixplural}
%    \begin{macrocode}
\newcommand*{\ifglshasprefixplural}[3]{%
  \ifcsempty{glo@#1@prefixplural}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifglshasprefixfirst}
%    \begin{macrocode}
\newcommand*{\ifglshasprefixfirst}[3]{%
  \ifcsempty{glo@#1@prefixfirst}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\ifglshasprefixfirstplural}
%    \begin{macrocode}
\newcommand*{\ifglshasprefixfirstplural}[3]{%
  \ifcsempty{glo@#1@prefixfirstplural}%
  {#3}%
  {#2}%
}
%    \end{macrocode}
%\end{macro}
%
% Define commands that insert the prefix before commands like \ics{gls}:
%\begin{macro}{\pgls}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\pgls}{\@gls@hyp@opt\@pgls}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@spgls}
%\begin{macro}{\@pgls}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@pgls}[2][]{%
  \new@ifnextchar[%
  {\@pgls@{#1}{#2}}%
  {\@pgls@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@pgls@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@pgls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \glsentryprefix{#2}%
    }%
    {%
      \glsentryprefixfirst{#2}%
    }%
    \@gls@{#1}{#2}[#3]%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Similarly for the plural version:
%\begin{macro}{\pglspl}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\pglspl}{\@gls@hyp@opt\@pglspl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@spglspl}
%\begin{macro}{\@pglspl}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@pglspl}[2][]{%
  \new@ifnextchar[%
  {\@pglspl@{#1}{#2}}%
  {\@pglspl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@pglspl@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@pglspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \glsentryprefixplural{#2}%
    }%
    {%
      \glsentryprefixfirstplural{#2}%
    }%
    \@glspl@{#1}{#2}[#3]%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Now for the first letter upper case versions:
%\begin{macro}{\Pgls}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\Pgls}{\@gls@hyp@opt\@Pgls}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@sPgls}
%\begin{macro}{\@Pgls}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@Pgls}[2][]{%
  \new@ifnextchar[%
  {\@Pgls@{#1}{#2}}%
  {\@Pgls@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Pgls@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Pgls@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \ifglshasprefix{#2}%
      {%
        \Glsentryprefix{#2}%
        \@gls@{#1}{#2}[#3]%
      }%
      {\@Gls@{#1}{#2}[#3]}%
    }%
    {%
      \ifglshasprefixfirst{#2}%
      {%
        \Glsentryprefixfirst{#2}%
        \@gls@{#1}{#2}[#3]%
      }%
      {\@Gls@{#1}{#2}[#3]}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Similarly for the plural version:
%\begin{macro}{\Pglspl}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\Pglspl}{\@gls@hyp@opt\@Pglspl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@sPglspl}
%\begin{macro}{\@Pglspl}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@Pglspl}[2][]{%
  \new@ifnextchar[%
  {\@Pglspl@{#1}{#2}}%
  {\@Pglspl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Pglspl@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Pglspl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \ifglshasprefixplural{#2}%
      {%
        \Glsentryprefixplural{#2}%
        \@glspl@{#1}{#2}[#3]%
      }%
      {\@Glspl@{#1}{#2}[#3]}%
    }%
    {%
      \ifglshasprefixfirstplural{#2}%
      {%
        \Glsentryprefixfirstplural{#2}%
        \@glspl@{#1}{#2}[#3]%
      }%
      {\@Glspl@{#1}{#2}[#3]}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Finally the all upper case versions:
%\begin{macro}{\PGLS}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\PGLS}{\@gls@hyp@opt\@PGLS}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@sPGLS}
%\begin{macro}{\@PGLS}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@PGLS}[2][]{%
  \new@ifnextchar[%
  {\@PGLS@{#1}{#2}}%
  {\@PGLS@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@PGLS@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@PGLS@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \mfirstucMakeUppercase{\glsentryprefix{#2}}%
    }%
    {%
      \mfirstucMakeUppercase{\glsentryprefixfirst{#2}}%
    }%
    \@GLS@{#1}{#2}[#3]%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Plural version:
%\begin{macro}{\PGLSpl}
%\changes{4.08}{2014-07-30}{changed to use \cs{@gls@hyp@opt}}
%    \begin{macrocode}
\newrobustcmd{\PGLSpl}{\@gls@hyp@opt\@PGLSpl}
%    \end{macrocode}
%\end{macro}
%\changes{4.08}{2014-07-30}{removed \@sPGLSpl}
%\begin{macro}{\@PGLSpl}
% Unstarred version.
%    \begin{macrocode}
\newcommand*{\@PGLSpl}[2][]{%
  \new@ifnextchar[%
  {\@PGLSpl@{#1}{#2}}%
  {\@PGLSpl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@PGLSpl@}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@PGLSpl@#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \ifglsused{#2}%
    {%
      \mfirstucMakeUppercase{\glsentryprefixplural{#2}}%
    }%
    {%
      \mfirstucMakeUppercase{\glsentryprefixfirstplural{#2}}%
    }%
    \@GLSpl@{#1}{#2}[#3]%
  }%
}
%    \end{macrocode}
%\end{macro}
%\iffalse
%    \begin{macrocode}
%</glossaries-prefix.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}[2014/07/30 v1.09 (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:
%\begin{definition}
% \cs{makefirstuc}\marg{text}
%\end{definition}
% 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}.
%\changes{1.08}{2013-11-04}{made robust}
%    \begin{macrocode}
\newif\if@glscs
\newtoks\@glsmfirst
\newtoks\@glsmrest
\newrobustcmd*{\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}
%\begin{macro}{\@gls@makefirstuc}
% Make first thing upper case:
%    \begin{macrocode}
\def\@gls@makefirstuc#1{\mfirstucMakeUppercase #1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\mfirstucMakeUppercase}
% Allow user to replace \cs{MakeUppercase} with another case
% changing command.
%    \begin{macrocode}
\newcommand*{\mfirstucMakeUppercase}{\MakeUppercase}
%    \end{macrocode}
%\end{macro}
%\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 store 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).
%\changes{1.08}{2013-11-04}{made robust}
%\changes{1.09}{2017-07-30}{added check for words that shouldn't be
%capitalised}
%    \begin{macrocode}
\newrobustcmd*{\capitalisewords}[1]{%
  \def\gls@add@space{}%
  \let\@mfu@domakefirstuc\makefirstuc
  \let\@mfu@checkword\@gobble
  \mfu@capitalisewords#1 \@nil\mfu@endcap
}
%    \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
  \@mfu@checkword{#1}%
  \@mfu@domakefirstuc{#1}%
  \def\gls@add@space{ }%
  \ifx\mfu@cap@second\@nnil
    \let\next@mfu@cap\mfu@noop
  \else
    \let\next@mfu@cap\mfu@capitalisewords
    \let\@mfu@checkword\mfu@checkword
  \fi
  \next@mfu@cap#2\mfu@endcap
}
\def\mfu@noop#1\mfu@endcap{}
%    \end{macrocode}
%
%\begin{macro}{\mfu@checkword}
% Check if word should be capitalised.
%\changes{1.09}{2017-07-30}{new}
%    \begin{macrocode}
\newcommand*\mfu@checkword[1]{%
  \ifinlist{#1}{\@mfu@nocaplist}%
  {%
    \let\@mfu@domakefirstuc\@firstofone
  }%
  {%
    \let\@mfu@domakefirstuc\makefirstuc
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@mfu@nocaplist}
% List of words that shouldn't be capitalised.
%\changes{1.09}{2017-07-30}{new}
%    \begin{macrocode}
\newcommand*{\@mfu@nocaplist}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\MFUnocap}
% Provide the user with a means to add a word to the list.
%    \begin{macrocode}
\newcommand*{\MFUnocap}[1]{\listadd{\@mfu@nocaplist}{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\gMFUnocap}
% Global version.
%\changes{1.09}{2017-07-30}{new}
%    \begin{macrocode}
\newcommand*{\gMFUnocap}[1]{\listgadd{\@mfu@nocaplist}{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\MFUclear}
% Clear the list
%\changes{1.09}{2017-07-30}{new}
%    \begin{macrocode}
\newcommand*{\MFUclear}{\renewcommand*{\@mfu@nocaplist}{}}
%    \end{macrocode}
%\end{macro}
%
%\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}
%\iffalse
%    \begin{macrocode}
%</mfirstuc.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*mfirstuc-english.sty>
%    \end{macrocode}
%\fi
%\section{Mfirstuc-english Documented Code}
%\label{sec:code:mfirstuc-english}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mfirstuc-english}[2014/07/30 v1.0 (NLCT)]
%    \end{macrocode}
% Load \sty{mfirstuc} if not already loaded:
%    \begin{macrocode}
\RequirePackage{mfirstuc}
%    \end{macrocode}
% Add no-cap words. (List isn't a complete list.)
%    \begin{macrocode}
\MFUnocap{a}
\MFUnocap{an}
\MFUnocap{and}
\MFUnocap{but}
\MFUnocap{for}
\MFUnocap{in}
\MFUnocap{of}
\MFUnocap{or}
\MFUnocap{no}
\MFUnocap{nor}
\MFUnocap{so}
\MFUnocap{some}
\MFUnocap{the}
\MFUnocap{with}
\MFUnocap{yet}
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</mfirstuc-english.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-hypernav.sty>
%    \end{macrocode}
%\fi
%\section{Glossary Styles}
% \subsection{Glossary hyper-navigation definitions (glossary-hypernav package)}
%\label{sec:code:hypernav}
% Package Definition:
%    \begin{macrocode}
\ProvidesPackage{glossary-hypernav}[2013/11/14 v4.0 (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
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{switched to using
%\cs{@gls@getgrouptitle}}
%    \begin{macrocode}
   \@gls@getgrouptitle{\@gls@tmp}{\@gls@grptitle}%
   \glsnavhyperlink{\@gls@tmp}{\@gls@grptitle}%
   \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}[2013/11/14 v4.0 (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{glossentry})
%    \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:
%\changes{3.08a}{2013-08-30}{updated inline style to use
%\cs{glossentry} and \cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsinlinedopostchild
    \gls@inlinesep
    \glsentryitem{##1}%
    \glsinlinenameformat{##1}{%
      \glossentryname{##1}%
    }%
   \ifglsdescsuppressed{##1}%
   {%
      \glsinlineemptydescformat
      {%
         \glossentrysymbol{##1}%
      }%
      {%
        ##2%
      }%
    }%
    {%
      \ifglshasdesc{##1}%
      {\glsinlinedescformat{\glossentrydesc{##1}}{\glossentrysymbol{##1}}{##2}}%
      {\glsinlineemptydescformat{\glossentrysymbol{##1}}{##2}}%
    }%
    \ifglshaschildren{##1}%
    {%
       \glsresetsubentrycounter
       \glsinlineparentchildseparator
       \def\gls@inlinesubsep{}%
       \def\gls@inlinepostchild{\glsinlinepostchild}%
    }%
    {}%
    \def\gls@inlinesep{\glsinlineseparator}%
  }%
%    \end{macrocode}
% Sub-entries display description:
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
    \gls@inlinesubsep%
    \glsinlinesubnameformat{##2}{%
       \glossentryname{##2}}%
    \glssubentryitem{##2}%
    \glsinlinesubdescformat{\glossentrydesc{##2}}{\glossentrysymbol{##2}}{##3}%
    \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{3.03}{2012/09/21}{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{3.03}{2012/09/21}{replaced ``.'' with \cs{glspostdescription}}
%    \begin{macrocode}
\newcommand*{\glspostinline}{\glspostdescription\space}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsinlinenameformat}
%\changes{3.03}{2012/09/21}{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{3.03}{2012/09/21}{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{3.03}{2012/09/21}{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{3.03}{2012/09/21}{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{3.03}{2012/09/21}{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}[2013/11/14 v4.0 (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:
%\changes{3.08a}{2013-08-30}{updated list style to use
%\cs{glossentry} and \cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}] 
       \glossentrydesc{##1}\glspostdescription\space ##2}%
%    \end{macrocode}
% Sub-entries continue on the same line:
%    \begin{macrocode}
  \renewcommand*{\subglossentry}[3]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}%
    \glossentrydesc{##2}\glspostdescription\space ##3.}%
%   \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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{list}%
%    \end{macrocode}
% Main (level 0) entries start a new item in the list with a
% line break after the entry name:
%\changes{3.08a}{2013-08-30}{updated altlist style to use
%\cs{glossentry} and \cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
      \glstarget{##1}{\glossentryname{##1}}]%
%    \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
      \glossentrydesc{##1}\glspostdescription\space ##2}%
%    \end{macrocode}
% Sub-entries start a new paragraph:
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
    \par
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription\space ##3}%
}
%    \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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{list}%
%    \end{macrocode}
% Each main (level 0) entry starts a new item:
%\changes{3.08a}{2013-08-30}{updated listdotted style to use
%\cs{glossentry} and \cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand*{\glossentry}[2]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
      \glsentryitem{##1}%
      \glstarget{##1}{\glossentryname{##1}}%
      \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}\glossentrydesc{##1}}%
%    \end{macrocode}
% Sub entries have the same format as main entries:
%    \begin{macrocode}
  \renewcommand*{\subglossentry}[3]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{\glossentryname{##2}}%
    \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}\glossentrydesc{##2}}%
}
%    \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}
  \setglossarystyle{listdotted}%
%    \end{macrocode}
% Main (level 0) entries just display the name:
%    \begin{macrocode}
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}}]}%
}
%    \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}[2013/11/14 v4.0 (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:
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub entries displayed on the following row without the name:
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glosentrydesc{##2}\glspostdescription\space
     ##3\tabularnewline
  }%
%    \end{macrocode}
% Blank row between groups:
%\changes{3.03}{2012/09/21}{added check for glsnogroupskip}
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else &
\tabularnewline\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}
  \setglossarystyle{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}
  \setglossarystyle{long}%
%    \end{macrocode}
% Set the table's header:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries \entryname & \bfseries \descriptionname\tabularnewline\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}
  \setglossarystyle{longborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line to table's foot:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline\bfseries \entryname & \bfseries
    \descriptionname\tabularnewline\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):
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub-entries on a separate row (no name, description in
% second column, page list in third column):
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     ##3\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}{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}
  \setglossarystyle{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}
  \setglossarystyle{long3col}%
%    \end{macrocode}
% Set the table's header:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\tabularnewline\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}
  \setglossarystyle{long3colborder}%
%    \end{macrocode}
% Set the table's header and add horizontal line at table's foot:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \hline
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries\pagelistname\tabularnewline\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):
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} &
    \glossentrysymbol{##1} &
    ##2\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{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     \glossentrysymbol{##2} & ##3\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}{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}
  \setglossarystyle{long4col}%
%    \end{macrocode}
% Table has a header:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \bfseries\entryname&\bfseries\descriptionname&
    \bfseries \symbolname&
    \bfseries\pagelistname\tabularnewline\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}
  \setglossarystyle{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}
  \setglossarystyle{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\tabularnewline\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}
   \setglossarystyle{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}
  \setglossarystyle{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}
   \setglossarystyle{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}
  \setglossarystyle{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}[2014/07/30 v4.08 (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:
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2%
    \tabularnewline
  }%
%    \end{macrocode}
% Sub entries displayed on the following row without the name:
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2}%
     \glspostdescription\space ##3%
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{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):
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub-entries on a separate row (no name, description in
% second column, page list in third column):
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     ##3\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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{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):
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%\changes{4.08}{2014-07-30}{fixed bug that displayed description instead of
%symbol}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & \glossentrysymbol{##1} &
    ##2\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{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     \glossentrysymbol{##2} & ##3\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}
  \setglossarystyle{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}
   \setglossarystyle{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}
  \setglossarystyle{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}[2013/11/14 v4.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}{%
  \setglossarystyle{index}%
  \renewenvironment{theglossary}%
    {%
%    \end{macrocode}
%\changes{3.05}{2013-04-21}{replaced `2' with \cs{glsmcols}}
%    \begin{macrocode}
     \begin{multicols}{\glsmcols}
     \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}{%
 \setglossarystyle{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}
  \setglossarystyle{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}{%
  \setglossarystyle{tree}%
  \renewenvironment{theglossary}%
  {%
%    \end{macrocode}
%\changes{3.05}{2013-04-21}{replaced `2' with \cs{glsmcols}}
%    \begin{macrocode}
     \begin{multicols}{\glsmcols}
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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}{%
  \setglossarystyle{treenoname}%
  \renewenvironment{theglossary}%
  {%
%    \end{macrocode}
%\changes{3.05}{2013-04-21}{replaced `2' with \cs{glsmcols}}
%    \begin{macrocode}
     \begin{multicols}{\glsmcols}
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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}{%
  \setglossarystyle{alttree}%
  \renewenvironment{theglossary}%
  {%
%    \end{macrocode}
%\changes{3.05}{2013-04-21}{replaced `2' with \cs{glsmcols}}
%    \begin{macrocode}
     \begin{multicols}{\glsmcols}
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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}[2013/11/14 v4.0 (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):
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub entries put in a row (no name, description and page list
% in second column):
%\changes{??}{??}{fixed typo in \cs{subglossentry} (\cs{glossentrydesc})}
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription\space
     ##3\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}{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}
  \setglossarystyle{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}
  \setglossarystyle{super}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and no tail:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
\renewenvironment{theglossary}%
  {\tablehead{\bfseries \entryname & 
   \bfseries\descriptionname\tabularnewline}%
   \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}
  \setglossarystyle{super}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% two columns, a header and horizontal lines above and below the
% table:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline\bfseries \entryname &
       \bfseries \descriptionname\tabularnewline\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):
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} & ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub entries on a row (no name, description in second column,
% page list in last column):
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     ##3\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}{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}
  \setglossarystyle{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}
  \setglossarystyle{super3col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% three columns, a header and no tail:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
       \bfseries\pagelistname\tabularnewline}\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}
  \setglossarystyle{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\tabularnewline\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:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} &
    \glossentrysymbol{##1} & ##3\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{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     \glossentrysymbol{##2} & ##3\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}{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}
  \setglossarystyle{super4col}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns, a header and no tail:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
        \bfseries\symbolname &
        \bfseries\pagelistname\tabularnewline}%
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline\bfseries\entryname&\bfseries\descriptionname&
        \bfseries\symbolname &
        \bfseries\pagelistname\tabularnewline\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}
  \setglossarystyle{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}
  \setglossarystyle{super4colheader}%
%    \end{macrocode}
% Put the glossary in a \env{supertabular} environment with
% four columns, a header and no tail:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\bfseries\entryname&\bfseries\descriptionname&
      \bfseries\symbolname &
      \bfseries\pagelistname\tabularnewline}\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}
  \setglossarystyle{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}
  \setglossarystyle{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:
%\changes{3.13a}{2013-11-05}{switched to \cs{tabularnewline}}
%    \begin{macrocode}
  \renewenvironment{theglossary}%
    {\tablehead{\hline
       \bfseries\entryname &
       \bfseries\descriptionname &
       \bfseries\symbolname &
       \bfseries\pagelistname\tabularnewline\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}[2013/11/14 v4.0 (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):
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription\space ##2%
    \tabularnewline
  }%
%    \end{macrocode}
% Sub entries put in a row (no name, description and page list
% in second column):
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription\space
     ##3%
     \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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{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{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} &
    ##2\tabularnewline
  }%
%    \end{macrocode}
% Sub entries on a row (no name, description in second column,
% page list in last column):
%    \begin{macrocode}
  \renewcommand{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     ##3\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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{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{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1} &
    \glossentrysymbol{##1} & ##2\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{\subglossentry}[3]{%
     & 
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}\glossentrydesc{##2} &
     \glossentrysymbol{##2} & ##3\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}
  \setglossarystyle{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}
  \setglossarystyle{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}
  \setglossarystyle{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}[2014/08/27 v4.10 (NLCT)]
%    \end{macrocode}
%
%\begin{macro}{\glstreenamefmt}
%\changes{4.08}{2014-07-30}{new}
% Format used to display the name in the tree styles. (This may be
% counteracted by \ics{glsnamefont}.) This command is also used to
% format the group headings.
%    \begin{macrocode}
\newcommand*{\glstreenamefmt}[1]{\textbf{#1}}
%    \end{macrocode}
%\end{macro}
%
%\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}
%\changes{3.08a}{2013-09-28}{added paragraph break at end of environment}
%    \begin{macrocode}
    {\par}%
%    \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.
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand*{\glossentry}[2]{%
     \item\glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}%
     \ifglshassymbol{##1}{\space(\glossentrysymbol{##1})}{}%
     \space \glossentrydesc{##1}\glspostdescription\space ##2%
  }%
%    \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{glossentry}, 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{\subglossentry}[3]{%
    \ifcase##1\relax
      % level 0
      \item
    \or
      % level 1
      \subitem
      \glssubentryitem{##2}%
    \else
      % all other levels
      \subsubitem
    \fi
    \glstreenamefmt{\glstarget{##2}{\glossentryname{##2}}}%
    \ifglshassymbol{##2}{\space(\glossentrysymbol{##2})}{}%
    \space\glossentrydesc{##2}\glspostdescription\space ##3%
  }%
%    \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}
  \setglossarystyle{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\glstreenamefmt{\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}
  \setglossarystyle{index}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the glossary:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \item\glstreenamefmt{\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\glstreenamefmt{\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:
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}%
    \ifglshassymbol{##1}{\space(\glossentrysymbol{##1})}{}%
    \space\glossentrydesc{##1}\glspostdescription\space##2\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{\subglossentry}[3]{%
    \hangindent##1\glstreeindent\relax
    \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \glstreenamefmt{\glstarget{##2}{\glossentryname{##2}}}%
    \ifglshassymbol{##2}{\space(\glossentrysymbol{##2})}{}%
    \space\glossentrydesc{##2}\glspostdescription\space ##3\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}
  \setglossarystyle{tree}%
%    \end{macrocode}
% Each group has a heading (in bold) followed by a vertical gap):
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\glstreenamefmt{\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}
  \setglossarystyle{tree}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\glstreenamefmt{\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
    \glstreenamefmt{\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{\glossentry}[2]{%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}%
    \ifglshassymbol{##1}{\space(\glossentrysymbol{##1})}{}%
    \space\glossentrydesc{##1}\glspostdescription\space##2\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{\subglossentry}[3]{%
    \hangindent##1\glstreeindent\relax
    \parindent##1\glstreeindent\relax
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \glstarget{##2}{\strut}%
    \glossentrydesc{##2}\glspostdescription\space##3\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}
  \setglossarystyle{treenoname}%
%    \end{macrocode}
% Give each group a heading:
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \noindent\glstreenamefmt{\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}
  \setglossarystyle{treenoname}%
%    \end{macrocode}
% Put navigation links to the groups at the start of the
% \env{theglossary} environment:
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par\noindent\glstreenamefmt{\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
    \glstreenamefmt{\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.
%\changes{3.08a}{2013-09-28}{updated to use \cs{glossentry} and
%\cs{subglossentry}}
%    \begin{macrocode}
  \renewcommand{\glossentry}[2]{%
    \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}{\glstreenamefmt{\@glswidestname\space}}%
    \fi
%    \end{macrocode}
% Set the hangindent and paragraph indent.
%\changes{4.04}{2014-03-06}{moved hangindent and parindent assignments
%outside level test}
%    \begin{macrocode}
      \hangindent\glstreeindent
      \parindent\glstreeindent
%    \end{macrocode}
% Put the name to the left of the paragraph block.
%    \begin{macrocode}
    \makebox[0pt][r]{\makebox[\glstreeindent][l]{%
       \glsentryitem{##1}\glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}}}%
%    \end{macrocode}
% If the symbol is missing, ignore it, otherwise put it in 
% brackets.
%\changes{4.10}{2014-08-27}{moved space after symbol}
%    \begin{macrocode}
    \ifglshassymbol{##1}{(\glossentrysymbol{##1})\space}{}%
%    \end{macrocode}
% Do the description followed by the description terminator and
% location list.
%    \begin{macrocode}
    \glossentrydesc{##1}\glspostdescription \space ##2\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{\subglossentry}[3]{%
%    \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}{\glstreenamefmt{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\glstreenamefmt{%
           \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}{\glstreenamefmt{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\glstreenamefmt{%
              \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]{%
      \glstreenamefmt{\glstarget{##2}{\glossentryname{##2}}}}}%
%    \end{macrocode}
% If the symbol is missing, ignore it, otherwise put it in 
% brackets.
%\changes{4.10}{2014-08-27}{moved space after symbol}
%    \begin{macrocode}
    \ifglshassymbol{##2}{(\glossentrysymbol{##2})\space}{}%
%    \end{macrocode}
% Do the description followed by the description terminator and
% location list.
%    \begin{macrocode}
    \glossentrydesc{##2}\glspostdescription\space ##3\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}
  \setglossarystyle{alttree}%
%    \end{macrocode}
% Give each group a heading.
%    \begin{macrocode}
  \renewcommand{\glsgroupheading}[1]{\par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glstreenamefmt{\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}
  \setglossarystyle{alttree}%
%    \end{macrocode}
% Put the navigation links in the header
%    \begin{macrocode}
  \renewcommand*{\glossaryheader}{%
    \par
    \def\@gls@prevlevel{-1}%
    \hangindent0pt\relax
    \parindent0pt\relax
    \glstreenamefmt{\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
    \glstreenamefmt{\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-compatible-307.sty>
%    \end{macrocode}
%\fi
% Compatibility macros.
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-compatible-307}[2013/11/14 v4.0 (NLCT)]
%    \end{macrocode}
%
% Compatibility macros for predefined glossary styles:
%\begin{macro}{\compatglossarystyle}
% Defines a compatibility glossary style.
%    \begin{macrocode}
\newcommand{\compatglossarystyle}[2]{%
  \ifcsundef{@glscompstyle@#1}%
  {%
    \csdef{@glscompstyle@#1}{#2}%
  }%
  {%
    \PackageError{glossaries}{Glossary compatibility style `#1' is already defined}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
% Backward compatible \glostyle{inline} style.
%    \begin{macrocode}
\compatglossarystyle{inline}{%
  \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}
% Backward compatible \glostyle{list} style.
%    \begin{macrocode}
\compatglossarystyle{list}{%
  \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}
% Backward compatible \glostyle{listgroup} style.
%    \begin{macrocode}
\compatglossarystyle{listgroup}{%
 \csuse{@glscompstyle@list}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{listhypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{listhypergroup}{%
 \csuse{@glscompstyle@list}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlist} style.
%    \begin{macrocode}
\compatglossarystyle{altlist}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[\glsentryitem{##1}\glstarget{##1}{##2}]%
      \mbox{}\par\nobreak\@afterheading
      ##3\glspostdescription\space ##5}%
  \renewcommand{\glossarysubentryfield}[6]{%
    \par
    \glssubentryitem{##2}%
    \glstarget{##2}{\strut}##4\glspostdescription\space ##6}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlistgroup} style.
%    \begin{macrocode}
\compatglossarystyle{altlistgroup}{%
 \csuse{@glscompstyle@altlist}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlisthypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{altlisthypergroup}{%
 \csuse{@glscompstyle@altlist}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{listdotted} style.
%    \begin{macrocode}
\compatglossarystyle{listdotted}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
      \glsentryitem{##1}\glstarget{##1}{##2}%
      \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}##3}%
  \renewcommand*{\glossarysubentryfield}[6]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{##3}%
    \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}##4}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{sublistdotted} style.
%    \begin{macrocode}
\compatglossarystyle{sublistdotted}{%
  \csuse{@glscompstyle@listdotted}%
  \renewcommand*{\glossaryentryfield}[5]{%
    \item[\glsentryitem{##1}\glstarget{##1}{##2}]}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long} style.
%    \begin{macrocode}
\compatglossarystyle{long}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longborder} style.
%    \begin{macrocode}
\compatglossarystyle{longborder}{%
 \csuse{@glscompstyle@long}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longheader} style.
%    \begin{macrocode}
\compatglossarystyle{longheader}{%
 \csuse{@glscompstyle@long}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{longheaderborder}{%
 \csuse{@glscompstyle@long}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long3col} style.
%    \begin{macrocode}
\compatglossarystyle{long3col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long3colborder} style.
%    \begin{macrocode}
\compatglossarystyle{long3colborder}{%
 \csuse{@glscompstyle@long3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long3colheader} style.
%    \begin{macrocode}
\compatglossarystyle{long3colheader}{%
 \csuse{@glscompstyle@long3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long3colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{long3colheaderborder}{%
 \csuse{@glscompstyle@long3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long4col} style.
%    \begin{macrocode}
\compatglossarystyle{long4col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{long4colheader}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{long4colborder}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{long4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{long4colheaderborder}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlong4col} style.
%    \begin{macrocode}
\compatglossarystyle{altlong4col}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlong4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{altlong4colheader}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlong4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{altlong4colborder}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlong4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{altlong4colheaderborder}{%
 \csuse{@glscompstyle@long4col}%
}%
%    \end{macrocode}
%
% Backward compatible \glostyle{long} style.
%    \begin{macrocode}
\compatglossarystyle{longragged}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5%
    \tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6%
    \tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longraggedborder} style.
%    \begin{macrocode}
\compatglossarystyle{longraggedborder}{%
 \csuse{@glscompstyle@longragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longraggedheader} style.
%    \begin{macrocode}
\compatglossarystyle{longraggedheader}{%
 \csuse{@glscompstyle@longragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longraggedheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{longraggedheaderborder}{%
 \csuse{@glscompstyle@longragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longragged3col} style.
%    \begin{macrocode}
\compatglossarystyle{longragged3col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longragged3colborder} style.
%    \begin{macrocode}
\compatglossarystyle{longragged3colborder}{%
 \csuse{@glscompstyle@longragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longragged3colheader} style.
%    \begin{macrocode}
\compatglossarystyle{longragged3colheader}{%
 \csuse{@glscompstyle@longragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{longragged3colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{longragged3colheaderborder}{%
 \csuse{@glscompstyle@longragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlongragged4col} style.
%    \begin{macrocode}
\compatglossarystyle{altlongragged4col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlongragged4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{altlongragged4colheader}{%
 \csuse{@glscompstyle@altlong4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlongragged4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{altlongragged4colborder}{%
 \csuse{@glscompstyle@altlong4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altlongragged4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{altlongragged4colheaderborder}{%
 \csuse{@glscompstyle@altlong4col}%
}%
%    \end{macrocode}
%
% Backward compatible \glostyle{index} style.
%    \begin{macrocode}
\compatglossarystyle{index}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \item\glsentryitem{##1}\textbf{\glstarget{##1}{##2}}%
      \ifx\relax##4\relax
      \else
        \space(##4)%
      \fi
      \space ##3\glspostdescription \space ##5}%
  \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}
% Backward compatible \glostyle{indexgroup} style.
%    \begin{macrocode}
\compatglossarystyle{indexgroup}{%
 \csuse{@glscompstyle@index}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{indexhypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{indexhypergroup}{%
 \csuse{@glscompstyle@index}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{tree} style.
%    \begin{macrocode}
\compatglossarystyle{tree}{%
  \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}%
  \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}
% Backward compatible \glostyle{treegroup} style.
%    \begin{macrocode}
\compatglossarystyle{treegroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{treehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{treehypergroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{treenoname} style.
%    \begin{macrocode}
\compatglossarystyle{treenoname}{%
  \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}%
  \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}
% Backward compatible \glostyle{treenonamegroup} style.
%    \begin{macrocode}
\compatglossarystyle{treenonamegroup}{%
 \csuse{@glscompstyle@treenoname}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{treenonamehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{treenonamehypergroup}{%
 \csuse{@glscompstyle@treenoname}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{alttree} style.
%    \begin{macrocode}
\compatglossarystyle{alttree}{%
  \renewcommand{\glossaryentryfield}[5]{%
    \ifnum\@gls@prevlevel=0\relax
    \else
       \settowidth{\glstreeindent}{\textbf{\@glswidestname\space}}%
      \hangindent\glstreeindent
      \parindent\glstreeindent
    \fi
    \makebox[0pt][r]{\makebox[\glstreeindent][l]{%
       \glsentryitem{##1}\textbf{\glstarget{##1}{##2}}}}%
    \ifx\relax##4\relax
    \else
      (##4)\space
    \fi
    ##3\glspostdescription \space ##5\par
    \def\@gls@prevlevel{0}%
  }%
  \renewcommand{\glossarysubentryfield}[6]{%
    \ifnum##1=1\relax
      \glssubentryitem{##2}%
    \fi
    \ifnum\@gls@prevlevel=##1\relax
    \else
      \@ifundefined{@glswidestname\romannumeral##1}{%
        \settowidth{\gls@tmplen}{\textbf{\@glswidestname\space}}}{%
        \settowidth{\gls@tmplen}{\textbf{%
           \csname @glswidestname\romannumeral##1\endcsname\space}}}%
      \ifnum\@gls@prevlevel<##1\relax
         \setlength\glstreeindent\gls@tmplen
         \addtolength\glstreeindent\parindent
         \parindent\glstreeindent
      \else
         \@ifundefined{@glswidestname\romannumeral\@gls@prevlevel}{%
           \settowidth{\glstreeindent}{\textbf{%
              \@glswidestname\space}}}{%
           \settowidth{\glstreeindent}{\textbf{%
              \csname @glswidestname\romannumeral\@gls@prevlevel
                 \endcsname\space}}}%
         \addtolength\parindent{-\glstreeindent}%
         \setlength\glstreeindent\parindent
      \fi
    \fi
    \hangindent\glstreeindent
    \makebox[0pt][r]{\makebox[\gls@tmplen][l]{%
      \textbf{\glstarget{##2}{##3}}}}%
    \ifx##5\relax\relax
    \else
      (##5)\space
    \fi
    ##4\glspostdescription\space ##6\par
    \def\@gls@prevlevel{##1}%
  }%
}%
%    \end{macrocode}
% Backward compatible \glostyle{alttreegroup} style.
%    \begin{macrocode}
\compatglossarystyle{alttreegroup}{%
 \csuse{@glscompstyle@alttree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{alttreehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{alttreehypergroup}{%
 \csuse{@glscompstyle@alttree}%
}%
%    \end{macrocode}
%
% Backward compatible \glostyle{mcolindex} style.
%    \begin{macrocode}
\compatglossarystyle{mcolindex}{%
 \csuse{@glscompstyle@index}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcolindexgroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolindexgroup}{%
 \csuse{@glscompstyle@index}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcolindexhypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolindexhypergroup}{%
 \csuse{@glscompstyle@index}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltree} style.
%    \begin{macrocode}
\compatglossarystyle{mcoltree}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltreegroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolindextreegroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltreehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolindextreehypergroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltreenoname} style.
%    \begin{macrocode}
\compatglossarystyle{mcoltreenoname}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltreenonamegroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcoltreenonamegroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcoltreenonamehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcoltreenonamehypergroup}{%
 \csuse{@glscompstyle@tree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcolalttree} style.
%    \begin{macrocode}
\compatglossarystyle{mcolalttree}{%
 \csuse{@glscompstyle@alttree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcolalttreegroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolalttreegroup}{%
 \csuse{@glscompstyle@alttree}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{mcolalttreehypergroup} style.
%    \begin{macrocode}
\compatglossarystyle{mcolalttreehypergroup}{%
 \csuse{@glscompstyle@alttree}%
}%
%    \end{macrocode}

% Backward compatible \glostyle{superragged} style.
%    \begin{macrocode}
\compatglossarystyle{superragged}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5%
      \tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6%
     \tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superraggedborder} style.
%    \begin{macrocode}
\compatglossarystyle{superraggedborder}{%
 \csuse{@glscompstyle@superragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superraggedheader} style.
%    \begin{macrocode}
\compatglossarystyle{superraggedheader}{%
 \csuse{@glscompstyle@superragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superraggedheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{superraggedheaderborder}{%
 \csuse{@glscompstyle@superragged}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superragged3col} style.
%    \begin{macrocode}
\compatglossarystyle{superragged3col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superragged3colborder} style.
%    \begin{macrocode}
\compatglossarystyle{superragged3colborder}{%
 \csuse{@glscompstyle@superragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superragged3colheader} style.
%    \begin{macrocode}
\compatglossarystyle{superragged3colheader}{%
 \csuse{@glscompstyle@superragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superragged3colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{superragged3colheaderborder}{%
 \csuse{@glscompstyle@superragged3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuperragged4col} style.
%    \begin{macrocode}
\compatglossarystyle{altsuperragged4col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\tabularnewline}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\tabularnewline}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuperragged4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{altsuperragged4colheader}{%
 \csuse{@glscompstyle@altsuperragged4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuperragged4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{altsuperragged4colborder}{%
 \csuse{@glscompstyle@altsuperragged4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuperragged4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{altsuperragged4colheaderborder}{%
 \csuse{@glscompstyle@altsuperragged4col}%
}%
%    \end{macrocode}
%
% Backward compatible \glostyle{super} style.
%    \begin{macrocode}
\compatglossarystyle{super}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3\glspostdescription\space ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4\glspostdescription\space ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superborder} style.
%    \begin{macrocode}
\compatglossarystyle{superborder}{%
 \csuse{@glscompstyle@super}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superheader} style.
%    \begin{macrocode}
\compatglossarystyle{superheader}{%
 \csuse{@glscompstyle@super}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{superheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{superheaderborder}{%
 \csuse{@glscompstyle@super}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super3col} style.
%    \begin{macrocode}
\compatglossarystyle{super3col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super3colborder} style.
%    \begin{macrocode}
\compatglossarystyle{super3colborder}{%
 \csuse{@glscompstyle@super3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super3colheader} style.
%    \begin{macrocode}
\compatglossarystyle{super3colheader}{%
 \csuse{@glscompstyle@super3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super3colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{super3colheaderborder}{%
 \csuse{@glscompstyle@super3col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super4col} style.
%    \begin{macrocode}
\compatglossarystyle{super4col}{%
  \renewcommand*{\glossaryentryfield}[5]{%
    \glsentryitem{##1}\glstarget{##1}{##2} & ##3 & ##4 & ##5\\}%
  \renewcommand*{\glossarysubentryfield}[6]{%
     &
     \glssubentryitem{##2}%
     \glstarget{##2}{\strut}##4 & ##5 & ##6\\}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{super4colheader}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{super4colborder}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{super4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{super4colheaderborder}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuper4col} style.
%    \begin{macrocode}
\compatglossarystyle{altsuper4col}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuper4colheader} style.
%    \begin{macrocode}
\compatglossarystyle{altsuper4colheader}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuper4colborder} style.
%    \begin{macrocode}
\compatglossarystyle{altsuper4colborder}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
% Backward compatible \glostyle{altsuper4colheaderborder} style.
%    \begin{macrocode}
\compatglossarystyle{altsuper4colheaderborder}{%
 \csuse{@glscompstyle@super4col}%
}%
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-compatible-307.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}[2014/07/30 v4.08 (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}
%\begin{macro}{\compatibleglossentry}
% Override style compatibility macros:
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%\changes{4.04}{2014-03-06}{changed \cs{newcommand} to \cs{def} as is may or
%may not be defined}
%    \begin{macrocode}
\def\compatibleglossentry#1#2{%
  \toks@{#2}%
  \protected@edef\@do@glossentry{%
    \noexpand\accsuppglossaryentryfield{#1}%
    {\noexpand\glsnamefont
       {\expandafter\expandonce\csname glo@\glsdetoklabel{#1}@name\endcsname}}%
    {\expandafter\expandonce\csname glo@\glsdetoklabel{#1}@desc\endcsname}%
    {\expandafter\expandonce\csname glo@\glsdetoklabel{#1}@symbol\endcsname}%
    {\the\toks@}%
  }%
  \@do@glossentry
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\compatiblesubglossentry}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%\changes{4.04}{2014-03-06}{changed \cs{newcommand} to \cs{def} as is may or
%may not be defined}
%    \begin{macrocode}
\def\compatiblesubglossentry#1#2#3{%
  \toks@{#3}%
  \protected@edef\@do@subglossentry{%
    \noexpand\accsuppglossarysubentryfield{\number#1}%
    {#2}%
    {\noexpand\glsnamefont
      {\expandafter\expandonce\csname glo@\glsdetoklabel{#2}@name\endcsname}}%
    {\expandafter\expandonce\csname glo@\glsdetoklabel{#2}@desc\endcsname}%
    {\expandafter\expandonce\csname glo@\glsdetoklabel{#2}@symbol\endcsname}%
    {\the\toks@}%
  }%
  \@do@subglossentry
}
%    \end{macrocode}
%\end{macro}
% 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}}".
%
% Append these new keys to \cs{@gls@keymap}:
%    \begin{macrocode}
\appto\@gls@keymap{,%
  {access}{access},%
  {textaccess}{textaccess},%
  {firstaccess}{firstaccess},%
  {pluralaccess}{pluralaccess},%
  {firstpluralaccess}{firstpluralaccess},%
  {symbolaccess}{symbolaccess},%
  {symbolpluralaccess}{symbolpluralaccess},%
  {descaccess}{descaccess},%
  {descpluralaccess}{descpluralaccess},%
  {shortaccess}{shortaccess},%
  {shortpluralaccess}{shortpluralaccess},%
  {longaccess}{longaccess},%
  {longpluralaccess}{longpluralaccess}%
}
%    \end{macrocode}
%
%\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:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentryaccess}[1]{%
  \@gls@entry@field{#1}{access}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrytextaccess}
% Get the value of the \gloskey{textaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrytextaccess}[1]{%
  \@gls@entry@field{#1}{textaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryfirstaccess}
% Get the value of the \gloskey{firstaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentryfirstaccess}[1]{%
  \@gls@entry@field{#1}{firstaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrypluralaccess}
% Get the value of the \gloskey{pluralaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrypluralaccess}[1]{%
  \@gls@entry@field{#1}{pluralaccess}%
}
%    \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:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrysymbolaccess}[1]{%
  \@gls@entry@field{#1}{symbolaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrysymbolpluralaccess}
% Get the value of the \gloskey{symbolpluralaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrysymbolpluralaccess}[1]{%
  \@gls@entry@field{#1}{symbolpluralaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrydescaccess}
% Get the value of the \gloskey{descriptionaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrydescaccess}[1]{%
  \@gls@entry@field{#1}{descaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrydescpluralaccess}
% Get the value of the \gloskey{descriptionpluralaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrydescpluralaccess}[1]{%
  \@gls@entry@field{#1}{descaccess}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryshortaccess}
% Get the value of the \gloskey{shortaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentryshortaccess}[1]{%
  \@gls@entry@field{#1}{shortaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentryshortpluralaccess}
% Get the value of the \gloskey{shortpluralaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentryshortpluralaccess}[1]{%
  \@gls@entry@field{#1}{shortpluralaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrylongaccess}
% Get the value of the \gloskey{longaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrylongaccess}[1]{%
  \@gls@entry@field{#1}{longaccess}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsentrylongpluralaccess}
% Get the value of the \gloskey{longpluralaccess} key for the entry with
% the given label:
%\changes{4.03}{2014-01-20}{switched to using \cs{@gls@entry@field}}
%    \begin{macrocode}
\newcommand*{\glsentrylongpluralaccess}[1]{%
  \@gls@entry@field{#1}{longpluralaccess}%
}
%    \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}{\@gls@access@display}
%\changes{4.03}{2014-01-20}{new}
%    \begin{macrocode}
\newcommand*{\@gls@access@display}[2]{%
  \protected@edef\@glo@access{#2}%
  \ifx\@glo@access\@gls@noaccess
    #1%
  \else
    \xglsaccsupp{\@glo@access}{#1}%
  \fi
}
%    \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]{%
  \@gls@access@display{#1}{\glsentryaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glstextaccessdisplay}
% As above but for the \gloskey{textaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glstextaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrytextaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glspluralaccessdisplay}
% As above but for the \gloskey{pluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glspluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrypluralaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstaccessdisplay}
% As above but for the \gloskey{firstaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsfirstaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentryfirstaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstpluralaccessdisplay}
% As above but for the \gloskey{firstpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsfirstpluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentryfirstpluralaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssymbolaccessdisplay}
% As above but for the \gloskey{symbolaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glssymbolaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrysymbolaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glssymbolpluralaccessdisplay}
% As above but for the \gloskey{symbolpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glssymbolpluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrysymbolpluralaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsdescriptionaccessdisplay}
% As above but for the \gloskey{descriptionaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsdescriptionaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrydescaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsdescriptionpluralaccessdisplay}
% As above but for the \gloskey{descriptionpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsdescriptionpluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrydescpluralaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsshortaccessdisplay}
% As above but for the \gloskey{shortaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsshortaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentryshortaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsshortpluralaccessdisplay}
% As above but for the \gloskey{shortpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glsshortpluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentryshortpluralaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongaccessdisplay}
% As above but for the \gloskey{longaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glslongaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrylongaccess{#2}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongpluralaccessdisplay}
% As above but for the \gloskey{longpluralaccess} replacement text.
%    \begin{macrocode}
\DeclareRobustCommand*{\glslongpluralaccessdisplay}[2]{%
  \@gls@access@display{#1}{\glsentrylongpluralaccess{#2}}%
}
%    \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@default@entryfmt}
% Redefine the default entry format to use accessibility information
%    \begin{macrocode}
\renewcommand*{\@@gls@default@entryfmt}[2]{%
  \ifdefempty\glscustomtext
  {%
    \glsifplural
    {%
%    \end{macrocode}
% Plural form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          #2{\glspluralaccessdisplay
               {\glsentryplural{\glslabel}}{\glslabel}}%
            {\glsdescriptionpluralaccessdisplay
               {\glsentrydescplural{\glslabel}}{\glslabel}}%
            {\glssymbolpluralaccessdisplay
               {\glsentrysymbolplural{\glslabel}}{\glslabel}}
            {\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsfirstpluralaccessdisplay
               {\glsentryfirstplural{\glslabel}}{\glslabel}}%
            {\glsdescriptionpluralaccessdisplay
               {\glsentrydescplural{\glslabel}}{\glslabel}}%
            {\glssymbolpluralaccessdisplay
               {\glsentrysymbolplural{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use.
%    \begin{macrocode}
          #2{\glspluralaccessdisplay
              {\Glsentryplural{\glslabel}}{\glslabel}}%
            {\glsdescriptionpluralaccessdisplay
              {\glsentrydescplural{\glslabel}}{\glslabel}}%
            {\glssymbolpluralaccessdisplay
              {\glsentrysymbolplural{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsfirstpluralaccessdisplay
               {\Glsentryfirstplural{\glslabel}}{\glslabel}}%
            {\glsdescriptionpluralaccessdisplay
               {\glsentrydescplural{\glslabel}}{\glslabel}}%
            {\glssymbolpluralaccessdisplay
               {\glsentrysymbolplural{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \MakeUppercase{%
            #2{\glspluralaccessdisplay
                {\glsentryplural{\glslabel}}{\glslabel}}%
              {\glsdescriptionpluralaccessdisplay
                {\glsentrydescplural{\glslabel}}{\glslabel}}%
              {\glssymbolpluralaccessdisplay
                {\glsentrysymbolplural{\glslabel}}{\glslabel}}%
              {\glsinsert}}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \MakeUppercase{%
            #1{\glsfirstpluralaccessdisplay
                {\glsentryfirstplural{\glslabel}}{\glslabel}}%
              {\glsdescriptionpluralaccessdisplay
                {\glsentrydescplural{\glslabel}}{\glslabel}}%
              {\glssymbolpluralaccessdisplay
                {\glsentrysymbolplural{\glslabel}}{\glslabel}}%
              {\glsinsert}}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          #2{\glstextaccessdisplay
               {\glsentrytext{\glslabel}}{\glslabel}}%
            {\glsdescriptionaccessdisplay
               {\glsentrydesc{\glslabel}}{\glslabel}}%
            {\glssymbolaccessdisplay
               {\glsentrysymbol{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsfirstaccessdisplay
              {\glsentryfirst{\glslabel}}{\glslabel}}%
            {\glsdescriptionaccessdisplay
              {\glsentrydesc{\glslabel}}{\glslabel}}%
            {\glssymbolaccessdisplay
              {\glsentrysymbol{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          #2{\glstextaccessdisplay
               {\Glsentrytext{\glslabel}}{\glslabel}}%
            {\glsdescriptionaccessdisplay
               {\glsentrydesc{\glslabel}}{\glslabel}}%
            {\glssymbolaccessdisplay
               {\glsentrysymbol{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          #1{\glsfirstaccessdisplay
              {\Glsentryfirst{\glslabel}}{\glslabel}}%
            {\glsdescriptionaccessdisplay
              {\glsentrydesc{\glslabel}}{\glslabel}}%
            {\glssymbolaccessdisplay
              {\glsentrysymbol{\glslabel}}{\glslabel}}%
            {\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \MakeUppercase{%
            #2{\glstextaccessdisplay
                {\glsentrytext{\glslabel}}{\glslabel}}%
              {\glsdescriptionaccessdisplay
                {\glsentrydesc{\glslabel}}{\glslabel}}%
              {\glssymbolaccessdisplay
                {\glsentrysymbol{\glslabel}}{\glslabel}}%
              {\glsinsert}}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \MakeUppercase{%
            #1{\glsfirstaccessdisplay
                {\glsentryfirst{\glslabel}}{\glslabel}}%
              {\glsdescriptionaccessdisplay
                {\glsentrydesc{\glslabel}}{\glslabel}}%
              {\glssymbolaccessdisplay
                {\glsentrysymbol{\glslabel}}{\glslabel}}%
              {\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Custom text provided in \cs{glsdisp}
%    \begin{macrocode}
    \ifglsused{\glslabel}%
    {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
      #2{\glscustomtext}%
        {\glsdescriptionaccessdisplay
          {\glsentrydesc{\glslabel}}{\glslabel}}%
        {\glssymbolaccessdisplay
          {\glsentrysymbol{\glslabel}}{\glslabel}}%
        {\glsinsert}%
    }%
    {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
      #1{\glscustomtext}%
        {\glsdescriptionaccessdisplay
          {\glsentrydesc{\glslabel}}{\glslabel}}%
        {\glssymbolaccessdisplay
          {\glsentrysymbol{\glslabel}}{\glslabel}}%
        {\glsinsert}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgenentryfmt}
% Redefine to use accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\glsgenentryfmt}{%
  \ifdefempty\glscustomtext
  {%
    \glsifplural
    {%
%    \end{macrocode}
% Plural form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \glspluralaccessdisplay
               {\glsentryplural{\glslabel}}{\glslabel}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstpluralaccessdisplay
              {\glsentryfirstplural{\glslabel}}{\glslabel}%
          \glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use.
%    \begin{macrocode}
          \glspluralaccessdisplay
              {\Glsentryplural{\glslabel}}{\glslabel}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstpluralaccessdisplay
              {\Glsentryfirstplural{\glslabel}}{\glslabel}%
          \glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
           \glspluralaccessdisplay
              {\mfirstucMakeUppercase{\glsentryplural{\glslabel}}}%
              {\glslabel}%
           \mfirstucMakeUppercase{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstpluralacessdisplay
             {\mfirstucMakeUppercase{\glsentryfirstplural{\glslabel}}}%
             {\glslabel}%
          \mfirstucMakeUppercase{\glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
      \glscapscase
      {%
%    \end{macrocode}
% Don't adjust case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \glstextaccessdisplay{\glsentrytext{\glslabel}}{\glslabel}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstaccessdisplay{\glsentryfirst{\glslabel}}{\glslabel}%
          \glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make first letter upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
           \glstextaccessdisplay{\Glsentrytext{\glslabel}}{\glslabel}%
           \glsinsert
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstaccessdisplay{\Glsentryfirst{\glslabel}}{\glslabel}%
          \glsinsert
        }%
      }%
      {%
%    \end{macrocode}
% Make all upper case
%    \begin{macrocode}
        \ifglsused\glslabel
        {%
%    \end{macrocode}
% Subsequent use
%    \begin{macrocode}
          \glstextaccessdisplay
            {\mfirstucMakeUppercase{\glsentrytext{\glslabel}}}{\glslabel}%
          \mfirstucMakeUppercase{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use
%    \begin{macrocode}
          \glsfirstaccessdisplay
            {\mfirstucMakeUppercase{\glsentryfirst{\glslabel}}}{\glslabel}%
          \mfirstucMakeUppercase{\glsinsert}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% Custom text provided in \cs{glsdisp}. (The insert should
% be empty at this point.) The accessibility information, if
% required, will have to be explicitly included in the custom text.
%    \begin{macrocode}
    \glscustomtext\glsinsert
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgenacfmt}
% Redefine to include accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\glsgenacfmt}{%
  \ifdefempty\glscustomtext
  {%
    \ifglsused\glslabel
    {%
%    \end{macrocode}
% Subsequent use:
%    \begin{macrocode}
      \glsifplural
      {%
%    \end{macrocode}
% Subsequent plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Subsequent plural form, don't adjust case:
%    \begin{macrocode}
          \acronymfont
           {\glsshortpluralaccessdisplay
              {\glsentryshortpl{\glslabel}}{\glslabel}}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, make first letter upper case:
%    \begin{macrocode}
          \acronymfont
           {\glsshortpluralaccessdisplay
              {\Glsentryshortpl{\glslabel}}{\glslabel}}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
          {\acronymfont
           {\glsshortpluralaccessdisplay
              {\glsentryshortpl{\glslabel}}{\glslabel}}%
          \glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Subsequent singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Subsequent singular form, don't adjust case:
%    \begin{macrocode}
          \acronymfont
           {\glsshortaccessdisplay{\glsentryshort{\glslabel}}{\glslabel}}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, make first letter upper case:
%    \begin{macrocode}
          \acronymfont
           {\glsshortaccessdisplay{\Glsentryshort{\glslabel}}{\glslabel}}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\acronymfont{%
              \glsshortaccessdisplay{\glsentryshort{\glslabel}}{\glslabel}}%
             \glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% First use:
%    \begin{macrocode}
      \glsifplural
      {%
%    \end{macrocode}
% First use plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% First use plural form, don't adjust case:
%    \begin{macrocode}
          \genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, make first letter upper case:
%    \begin{macrocode}
          \Genplacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\genplacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
      {%
%    \end{macrocode}
% First use singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% First use singular form, don't adjust case:
%    \begin{macrocode}
          \genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, make first letter upper case:
%    \begin{macrocode}
          \Genacrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
           {\genacrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% User supplied text. (The insert should be empty at this point.)
% The accessibility information, if
% required, will have to be explicitly included in the custom text.
%    \begin{macrocode}
    \glscustomtext
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\genacrfullformat}
% Redefine to include accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\genacrfullformat}[2]{%
   \glslongaccessdisplay{\glsentrylong{#1}}{#1}#2\space
   (\glsshortaccessdisplay{\protect\firstacronymfont{\glsentryshort{#1}}}{#1})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Genacrfullformat}
% Redefine to include accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\Genacrfullformat}[2]{%
   \glslongaccessdisplay{\Glsentrylong{#1}}{#1}#2\space
   (\glsshortaccessdisplay{\protect\firstacronymfont{\Glsentryshort{#1}}}{#1})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\genplacrfullformat}
% Redefine to include accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\genplacrfullformat}[2]{%
   \glslongpluralaccessdisplay{\glsentrylongpl{#1}}{#1}#2\space
   (\glsshortpluralaccessdisplay
      {\protect\firstacronymfont{\glsentryshortpl{#1}}}{#1})%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Genplacrfullformat}
% Redefine to include accessibility information.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewcommand*{\Genplacrfullformat}[2]{%
   \glslongpluralaccessdisplay{\Glsentrylongpl{#1}}{#1}#2\space
   (\glsshortpluralaccessdisplay
      {\protect\firstacronymfont{\glsentryshortpl{#1}}}{#1})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrshort}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsshortaccessdisplay{\glsentryshort{#2}}{#2}}#3%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrshort}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@Acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsshortaccessdisplay{\Glsentryshort{#2}}{#2}}#3%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRshort}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@ACRshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsshortaccessdisplay
          {\MakeUppercase{\glsentryshort{#2}}}{#2}}#3%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrlong}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glslongaccessdisplay{\glsentrylong{#2}}{#2}}#3%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrlong}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@Acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glslongaccessdisplay{\Glsentrylong{#2}}{#2}}#3%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRlong}
%\changes{4.08}{2014-07-30}{added \cs{do@gls@link@checkfirsthyper}}
%    \begin{macrocode}
\def\@ACRlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
%    \end{macrocode}
%\changes{3.11a}{2013-10-15}{added \cs{glslabel}, \cs{glsifplural},
% \cs{glscapscase}, \cs{glsinsert} and \cs{glscustomtext}}
%\changes{4.03}{2014-01-20}{removed \cs{glslabel} (defined in
%\cs{@gls@link})}
%    \begin{macrocode}
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glslongaccessdisplay{%
        \MakeUppercase{\glsentrylong{#2}}}{#2}#3}%
    }%
%    \end{macrocode}
% Call \cs{@gls@link}
%    \begin{macrocode}
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Displaying the Glossary}
%\changes{3.08a}{2013-09-28}{removed definition of \cs{@glossaryentryfield}}
%\changes{3.08a}{2013-09-28}{removed definition of \cs{@glossarysubentryfield}}
%
% We need to redefine the way the glossary entries are formatted to
% include the accessibility support. The predefined glossary styles
% use \ics{glossentryname}, \ics{glossentrydesc} and
% \ics{glossentrysymbol}, but we need to provide compatibility with
% earlier versions in case users have defined their own styles using
% \cs{accsuppglossaryentryfield} and
% \cs{accsuppglossarysubentryfield}.
%
% Now redefine \cs{glossentryname}, \cs{glossentrydesc} and
% \cs{glossentrysymbol} etc so they use the accessibility stuff.
%    \begin{macrocode}
\renewcommand*{\glossentryname}[1]{%
  \glsdoifexists{#1}%
  {%
    \glsnamefont{\glsnameaccessdisplay{\glsentryname{#1}}{#1}}%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\glossentryname}[1]{%
  \glsdoifexists{#1}%
  {%
    \glsnamefont{\glsnameaccessdisplay{\Glsentryname{#1}}{#1}}%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\glossentrydesc}[1]{%
  \glsdoifexists{#1}%
  {%
     \glsdescriptionaccessdisplay{\glsentrydesc{#1}}{#1}%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\Glossentrydesc}[1]{%
  \glsdoifexists{#1}%
  {%
     \glsdescriptionaccessdisplay{\Glsentrydesc{#1}}{#1}%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\glossentrysymbol}[1]{%
  \glsdoifexists{#1}%
  {%
     \glssymbolaccessdisplay{\glsentrysymbol{#1}}{#1}%
  }%
}
%    \end{macrocode}
%
%    \begin{macrocode}
\renewcommand*{\Glossentrysymbol}[1]{%
  \glsdoifexists{#1}%
  {%
     \glssymbolaccessdisplay{\Glsentrysymbol{#1}}{#1}%
  }%
}
%    \end{macrocode}
%
%\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]{%
  \glossarysubentryfield{#1}{#2}%
  {\glsnameaccessdisplay{#3}{#2}}%
  {\glsdescriptionaccessdisplay{#4}{#2}}%
  {\glssymbolaccessdisplay{#5}{#2}}{#6}%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Acronyms}
% Redefine acronym styles provided by \styfmt{glossaries}:
%
%\begin{acrstyle}{long-short}
% \meta{long} (\meta{short}) acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{long-short}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glslongaccessdisplay{\glsentrylong{##1}}{##1}##2\space
   (\glsshortaccessdisplay
      {\protect\firstacronymfont{\glsentryshort{##1}}}{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glslongaccessdisplay{\Glsentrylong{##1}}{##1}##2\space
   (\glsshortaccessdisplay
      {\protect\firstacronymfont{\glsentryshort{##1}}}{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1}##2\space
   (\glsshortpluralaccessdisplay
      {\protect\firstacronymfont{\glsentryshortpl{##1}}}{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glslongpluralaccessdisplay{\Glsentrylongpl{##1}}{##1}##2\space
   (\glsshortpluralaccessdisplay
      {\protect\firstacronymfont{\glsentryshortpl{##1}}}{##1})%
  }%
  \renewcommand*{\acronymentry}[1]{%
    \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{short-long}
% \meta{short} (\meta{long}) acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{short-long}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsshortaccessdisplay
     {\protect\firstacronymfont{\glsentryshort{##1}}}{##1}##2\space
   (\glslongaccessdisplay{\glsentrylong{##1}}{##1})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glsshortaccessdisplay
      {\protect\firstacronymfont{\Glsentryshort{##1}}}{##1}##2\space
   (\glslongaccessdisplay{\glsentrylong{##1}}{##1})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsshortpluralaccessdisplay
     {\protect\firstacronymfont{\glsentryshortpl{##1}}}{##1}##2\space
   (\glslongpluralaccessdisplay
     {\glsentrylongpl{##1}}{##1})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glsshortpluralaccessdisplay
    {\protect\firstacronymfont{\Glsentryshortpl{##1}}}{##1}##2\space
   (\glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1})%
  }%
  \renewcommand*{\acronymentry}[1]{%
    \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\firstacronymfont}[1]{\acronymfont{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-short-desc}
% \meta{long} (\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{long-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sc-short-desc}
% \meta{long} (\cs{textsc}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{long-sc-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-sc-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-sc-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{long-sm-short-desc}
% \meta{long} (\cs{textsmaller}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{long-sm-short-desc}%
{%
  \GlsUseAcrEntryDispStyle{long-sm-short}%
}%
{%
  \GlsUseAcrStyleDefs{long-sm-short}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{short-long-desc}
% \meta{short} (\marg{long}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{short-long}%
}%
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sc-short-long-desc}
% \meta{long} (\cs{textsc}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{sc-short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{sc-short-long}%
}%
{%
  \GlsUseAcrStyleDefs{sc-short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{sm-short-long-desc}
% \meta{long} (\cs{textsmaller}\marg{short}) acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{sm-short-long-desc}%
{%
  \GlsUseAcrEntryDispStyle{sm-short-long}%
}%
{%
  \GlsUseAcrStyleDefs{sm-short-long}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{dua}
% \meta{long} only acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{dua}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifdefempty\glscustomtext
  {%
    \ifglshaslong{\glslabel}%
    {%
      \glsifplural
      {%
%    \end{macrocode}
% Plural form:
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Plural form, don't adjust case:
%    \begin{macrocode}
          \glslongpluralaccessdisplay{\glsentrylongpl{\glslabel}}{\glslabel}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Plural form, make first letter upper case:
%    \begin{macrocode}
          \glslongpluralaccessdisplay{\Glsentrylongpl{\glslabel}}{\glslabel}%
          \glsinsert
        }%
        {%
%    \end{macrocode}
% Plural form, all caps:
%    \begin{macrocode}
          \glslongpluralaccessdisplay
            {\mfirstucMakeUppercase{\glsentrylongpl{\glslabel}}}{\glslabel}%
          \mfirstucMakeUppercase{\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Singular form, don't adjust case:
%    \begin{macrocode}
          \glslongaccessdisplay{\glsentrylong{\glslabel}}{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, make first letter upper case:
%    \begin{macrocode}
          \glslongaccessdisplay{\Glsentrylong{\glslabel}}{\glslabel}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, all caps:
%    \begin{macrocode}
          \glslongaccessdisplay
           {\mfirstucMakeUppercase
              {\glsentrylong{\glslabel}\glsinsert}}{\glslabel}%
          \mfirstucMakeUppercase{\glsinsert}%
        }%
      }%
    }%
    {%
%    \end{macrocode}
% Not an acronym:
%    \begin{macrocode}
      \glsgenentryfmt
    }%
  }%
  {\glscustomtext\glsinsert}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongaccessdisplay{\glsentrylong{##2}}{##2}##3\space
      (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##2}}}{##2})}}%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongaccessdisplay{\Glsentrylong{##2}}{##2}##3\space
      (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##2}}}{##2})}}%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongaccessdisplay
        {\mfirstucMakeUppercase{\glsentrylong{##2}}{##2}##3\space
      (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##2}}}{##2})}}}%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongpluralaccessdisplay
        {\glsentrylongpl{##2}}{##2}##3\space
      (\glsshortpluralaccessdisplay
        {\acronymfont{\glsentryshortpl{##2}}}{##2})}}%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongpluralaccessdisplay
        {\Glsentrylongpl{##2}}{##2}##3\space
      (\glsshortpluralaccessdisplay
        {\acronymfont{\glsentryshortpl{##2}}}{##2})}}%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glslongpluralaccessdisplay
         {\mfirstucMakeUppercase{\glsentrylongpl{##2}}{##2}##3\space
      (\glsshortpluralaccessdisplay
         {\acronymfont{\glsentryshortpl{##2}}}{##2})}}}%
  \renewcommand*{\glsentryfull}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})%
  }%
  \renewcommand*{\Glsentryfull}[1]{%
    \glslongaccessdisplay{\Glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})%
  }%
  \renewcommand*{\glsentryfullpl}[1]{%
    \glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1}\space
    (\glsshortpluralaccessdisplay{\acronymfont{\glsentryshortpl{##1}}}{##1})%
  }%
  \renewcommand*{\Glsentryfullpl}[1]{%
    \glslongpluralaccessdisplay{\Glsentrylongpl{##1}}{##1}\space
    (\glsshortpluralaccessdisplay{\acronymfont{\glsentryshortpl{##1}}}{##1})%
  }%
  \renewcommand*{\acronymentry}[1]{%
     \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{dua-desc}
% \meta{long} only acronym style with user-supplied description.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{dua-desc}%
{%
  \GlsUseAcrEntryDispStyle{dua}%
}%
{%
  \GlsUseAcrStyleDefs{dua}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\acronymfont{\glsentrylong{##1}}}{##1}}%
  \renewcommand*{\acronymsort}[2]{##2}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote}
% \meta{short}\cs{footnote}\marg{long} acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote}%
{%
%    \end{macrocode}
% Check for long form in case this is a mixed glossary.
%    \begin{macrocode}
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{%
  \renewcommand*{\GenericAcronymFields}{description={\the\glslongtok}}%
%    \end{macrocode}
% Need to ensure hyperlinks are switched off on first use:
%    \begin{macrocode}
  \glshyperfirstfalse
  \renewcommand*{\genacrfullformat}[2]{%
   \glsshortaccessdisplay
     {\protect\firstacronymfont{\glsentryshort{##1}}}{##1}##2%
   \protect\footnote{\glslongaccessdisplay{\glsentrylong{##1}}{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \glsshortaccessdisplay
     {\firstacronymfont{\Glsentryshort{##1}}}{##1}##2%
   \protect\footnote{\glslongaccessdisplay{\glsentrylong{##1}}{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsshortpluralaccessdisplay
     {\protect\firstacronymfont{\glsentryshortpl{##1}}}{##1}##2%
   \protect\footnote{\glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \glsshortpluralaccessdisplay
     {\protect\firstacronymfont{\Glsentryshortpl{##1}}}{##1}##2%
   \protect\footnote{\glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1}}%
  }%
  \renewcommand*{\acronymentry}[1]{%
    \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}%
  \renewcommand*{\acronymsort}[2]{##1}%
  \renewcommand*{\acronymfont}[1]{##1}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
%    \end{macrocode}
% Don't use footnotes for \ics{acrfull}:
%    \begin{macrocode}
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortaccessdisplay{\acronymfont{\glsentryshort{##2}}}{##2}##3\space
      (\glslongaccessdisplay{\glsentrylong{##2}}{##2})}}%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortaccessdisplay{\acronymfont{\Glsentryshort{##2}}}{##2}##3\space
      (\glslongaccessdisplay{\glsentrylong{##2}}{##2})}}%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortaccessdisplay
         {\mfirstucMakeUppercase
           {\acronymfont{\glsentryshort{##2}}}{##2}##3\space
      (\glslongaccessdisplay{\glsentrylong{##2}}{##2})}}}%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortpluralaccessdisplay
         {\acronymfont{\glsentryshortpl{##2}}}{##2}##3\space
      (\glslongpluralaccessdisplay{\glsentrylongpl{##2}}{##2})}}%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortpluralaccessdisplay
        {\acronymfont{\Glsentryshortpl{##2}}}{##2}##3\space
      (\glslongpluralaccessdisplay{\glsentrylongpl{##2}})}}%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
      \glsshortpluralaccessdisplay
        {\mfirstucMakeUppercase
           {\acronymfont{\glsentryshortpl{##2}}}{##2}##3\space
      (\glslongpluralaccessdisplay{\glsentrylongpl{##2}}{##2})}}}%
%    \end{macrocode}
% Similarly for \ics{glsentryfull} etc:
%    \begin{macrocode}
  \renewcommand*{\glsentryfull}[1]{%
     \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}\space
      (\glslongaccessdisplay{\glsentrylong{##1}}{##1})}%
  \renewcommand*{\Glsentryfull}[1]{%
     \glsshortaccessdisplay{\acronymfont{\Glsentryshort{##1}}}{##1}\space
     (\glslongaccessdisplay{\glsentrylong{##1}}{##1})}%
  \renewcommand*{\glsentryfullpl}[1]{%
     \glsshortpluralaccessdisplay
       {\acronymfont{\glsentryshortpl{##1}}}{##1}\space
       (\glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1})}%
  \renewcommand*{\Glsentryfullpl}[1]{%
     \glsshortpluralaccessdisplay
        {\acronymfont{\Glsentryshortpl{##1}}}{##1}\space
     (\glslongpluralaccessdisplay{\glsentrylongpl{##1}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sc}
% \cs{textsc}\marg{short}\cs{footnote}\marg{long} acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote-sc}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand{\acronymentry}[1]{%
     \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}
  \renewcommand{\acronymfont}[1]{\textsc{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sm}
% \cs{textsmaller}\marg{short}\cs{footnote}\marg{long} acronym style.
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote-sm}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand{\acronymentry}[1]{%
    \glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1}}
  \renewcommand{\acronymfont}[1]{\textsmaller{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glspluralsuffix}%
}%
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-desc}
% \meta{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote}%
}%
{%
  \GlsUseAcrStyleDefs{footnote}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sc-desc}
% \cs{textsc}\marg{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote-sc-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote-sc}%
}%
{%
  \GlsUseAcrStyleDefs{footnote-sc}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
%\begin{acrstyle}{footnote-sm-desc}
% \cs{textsmaller}\marg{short}\cs{footnote}\marg{long} acronym style that has an
% accompanying description (which the user needs to supply).
%\changes{4.03}{2014-01-20}{redefined to use accessibility
%information}
%    \begin{macrocode}
\renewacronymstyle{footnote-sm-desc}%
{%
  \GlsUseAcrEntryDispStyle{footnote-sm}%
}%
{%
  \GlsUseAcrStyleDefs{footnote-sm}%
  \renewcommand*{\GenericAcronymFields}{}%
  \renewcommand*{\acronymsort}[2]{##2}%
  \renewcommand*{\acronymentry}[1]{%
    \glslongaccessdisplay{\glsentrylong{##1}}{##1}\space
    (\glsshortaccessdisplay{\acronymfont{\glsentryshort{##1}}}{##1})}%
}
%    \end{macrocode}
%\end{acrstyle}
%
% 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
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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}%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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
    }%
  }%
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@descplural\@org@gls@assign@descplural
}
%    \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
    }%
  }%
  \let\@org@gls@assign@firstpl\gls@assign@firstpl
  \let\@org@gls@assign@plural\gls@assign@plural
  \let\@org@gls@assign@descplural\gls@assign@descplural
  \let\@org@gls@assign@symbolplural\gls@assign@symbolplural
  \def\gls@assign@firstpl##1##2{%
    \@@gls@expand@field{##1}{firstpl}{##2}%
  }%
  \def\gls@assign@plural##1##2{%
    \@@gls@expand@field{##1}{plural}{##2}%
  }%
  \def\gls@assign@descplural##1##2{%
    \@@gls@expand@field{##1}{descplural}{##2}%
  }%
  \def\gls@assign@symbolplural##1##2{%
    \@@gls@expand@field{##1}{symbolplural}{##2}%
  }%
  \@do@newglossaryentry
  \let\gls@assign@firstpl\@org@gls@assign@firstpl
  \let\gls@assign@plural\@org@gls@assign@plural
  \let\gls@assign@descplural\@org@gls@assign@descplural
  \let\gls@assign@symbolplural\@org@gls@assign@symbolplural
}
%    \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}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglonameaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@textaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglotextaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglotextaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@textaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglopluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglopluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@pluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglofirstaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglofirstaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@firstaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglofirstpluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglofirstpluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@firstpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglosymbolaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglosymbolaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@symbolaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglosymbolpluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglosymbolpluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@symbolpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglodescaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglodescaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@descaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglodescpluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglodescpluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@descpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showgloshortaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloshortaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@shortaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showgloshortpluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showgloshortpluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@shortpluralaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglolongaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglolongaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#1}@longaccess\endcsname
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\showglolongpluralaccess}
%\changes{4.03}{2014-01-20}{added \cs{glsdetoklabel}}
%    \begin{macrocode}
\newcommand*{\showglolongpluralaccess}[1]{%
  \expandafter\show\csname glo@\glsdetoklabel{#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}[2013/11/14 v4.0 (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}[2013/11/14 v4.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.
 % Alternatively, if you use arara, you can add the following
 % directives in your document:
 %
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }

\documentclass{article}
\listfiles

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

\makeglossaries

\longnewglossaryentry{par}{name={par}}%
{%
  A long description with a paragraph break.

  This is the next paragraph.
}

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

 % set the acronym style:
\setacronymstyle{long-short}

 % 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}.

\glsresetall
First letter upper case: \Gls{sample}. First use: \Gls{aca}.
Subsequent use: \Gls{aca}.
\glsresetall
Plurals: \Glspl{sample}. First use: \Glspl{aca}. Next: \Glspl{aca}.

If you want paragraph breaks in the description use
\verb|\longnewglossaryentry|, as with entry \gls{par}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</minimalgls.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossary-lipsum-examples.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % arara: pdflatex
 % arara: makeglossaries
 % arara: pdflatex
 % arara: bibtex
 % arara: pdflatex
 % arara: pdflatex
\documentclass{report}

\usepackage{graphicx}
%\usepackage{scrwfile}

\usepackage[colorlinks]{hyperref}
\usepackage[savewrites,nopostdot,toc,acronym,symbols]{glossaries}
\usepackage{glossary-mcols}
\usepackage{glossary-longragged}

\newglossary[glg2]{long}{gls2}{glo2}{Long Descriptions}
\newglossary[glg3]{multipar}{gls3}{glo3}{Multi-Paragraph Descriptions}
\newglossary[glg4]{acronymdesc}{gls4}{glo4}{Acronyms with Descriptions}
\newglossary[glg5]{images}{gls5}{glo5}{Descriptions with Images}
\newglossary[glg6]{acronymslang}{gls6}{glo6}{Acronyms with
Translations}

\newglossary[glg7]{parent}{gls7}{glo7}{Hierarchical Entries}
\newglossary[glg8]{homographs}{gls8}{glo8}{Homographs}
\newglossary[glg9]{cites}{gls9}{glo9}{Entries with Citations}
\newglossary[glg10]{urls}{gls10}{glo10}{Entries with URLs}

\DeclareAcronymList{acronymdesc,acronymslang}

\makeglossaries

\loadglsentries{example-glossaries-brief}
\loadglsentries[long]{example-glossaries-long}
\loadglsentries[multipar]{example-glossaries-multipar}
\loadglsentries[symbols]{example-glossaries-symbols}
\loadglsentries[images]{example-glossaries-images}
\loadglsentries[parent]{example-glossaries-parent}
\loadglsentries[homographs]{example-glossaries-childnoname}
\loadglsentries[cites]{example-glossaries-cite}
\loadglsentries[urls]{example-glossaries-url}

\setacronymstyle{long-short}

\loadglsentries[acronym]{example-glossaries-acronym}

\setacronymstyle{long-short-desc}

\loadglsentries[acronymdesc]{example-glossaries-acronym-desc}

 % define an acronym style for the acronyms with a translation:

\newacronymstyle{acronymslang}%
{%
  \GlsUseAcrEntryDispStyle{long-short}%
}
{%
  \GlsUseAcrStyleDefs{short-long}%
  \renewcommand*{\genacrfullformat}[2]{%
   \glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \Glsentrylong{##1}##2\space
   (\protect\firstacronymfont{\glsentryshort{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \Glsentrylongpl{##1}##2\space
   (\protect\firstacronymfont{\glsentryshortpl{##1}}%
    \ifglshasfield{useri}{##1}%
    {, English: \glsentryuseri{##1}}{})%
  }%
}

\setacronymstyle{acronymslang}

\loadglsentries[acronymslang]{example-glossaries-acronyms-lang}

 % Define a style for the "images" glossary. The image names are
 % stored in the user1 key.
 % (The image insertion can probably be done more neatly using an
 % appropriate package, but this is just a sample file.)

\newsavebox\glsimagebox
\newlength\glswidth

\newglossarystyle{images}%
{%
  \setglossarystyle{tree}%
  \renewenvironment{theglossary}{}{}%
  \renewcommand{\glossentry}[2]{%
    \ifglshasfield{useri}{##1}%
    {\savebox
      {\glsimagebox}%
      {\includegraphics[height=4\baselineskip]{\glsentryuseri{##1}}}%
      \settowidth{\glswidth}{\usebox\glsimagebox}%
      \glswidth=\dimexpr\linewidth-\glswidth-1em\relax
      \parshape=5
        0pt \glswidth
        0pt \glswidth
        0pt \glswidth
        0pt \glswidth
        0pt \linewidth\relax
    }%
    {%
      \savebox{\glsimagebox}{}%
    }%
    \noindent
    \makebox[0pt][l]{%
     \smash{\makebox[\linewidth][r]{\raisebox{-3\baselineskip}{\usebox\glsimagebox}}}}%
    \glsentryitem{##1}\textbf{\glstarget{##1}{\glossentryname{##1}}}%
    \space\glossentrydesc{##1}\par
    \indexspace
  }%
  \renewcommand*{\glsgroupskip}{}%
}

 % glossary style for acronyms with a translation

\newglossarystyle{acronymslang}
{%
  \setglossarystyle{long}%
  \renewcommand*{\glsgroupskip}{}%
  \renewcommand{\glossentry}[2]{%
    \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
    \glossentrydesc{##1}\glspostdescription
    \ifglshasfield{useri}{##1}{ (English: \glsentryuseri{##1})}{}%
    \space ##2\tabularnewline
  }%
}

 % glossary style for the cites glossary

\newglossarystyle{cites}
{% based on list style
  \setglossarystyle{list}%
    \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \glossentrydesc{##1}\glspostdescription
    \ifglshasfield{useri}{##1}{\space
     % in the event of multiple cites (as in the vestibulum2
     % sample entry), \glsentryuseri{##1} needs to be expanded
     % before being passed to \cite.
     \glsletentryfield{\thiscite}{##1}{useri}%
     (See \expandafter\cite\expandafter{\thiscite})}{}%
    \space ##2}%
}

 % glossary style for the urls glossary

\newglossarystyle{urls}
{% based on list style
  \setglossarystyle{list}%
    \renewcommand{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \glossentrydesc{##1}\glspostdescription\space##2%
    \ifglshasfield{useri}{##1}{\glspar
     \glsletentryfield{\thisurl}{##1}{useri}%
     \expandafter\url\expandafter{\thisurl}}{}}%
}

\begin{document}
\tableofcontents

\chapter{Sample}

This is a sample document that uses the dummy glossary entries
supplied with the glossaries bundle for testing.

Here are all the entries (including acronyms):

\forallglossaries{\thistype}{\section{Glossary `\thistype'}
\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }}

\section{Acronyms Revisited}

Here are just the acronyms again:
\forallacronyms{\thistype}{\forglsentries[\thistype]{\thislabel}{\gls{\thislabel}. }}

\printglossary[style=mcolindex,title={Brief Descriptions}]

\printglossary[type=long,style=list]

\printglossary[type=multipar,style=altlist]

\printglossary[type=symbols,style=altlongragged4col,nogroupskip]

\printglossary[type=acronym,style=long]

\printglossary[type=acronymdesc,style=altlist]

\printglossary[type=images,style=images]

\printglossary[type=acronymslang,style=acronymslang]

\printglossary[type=homographs,style=mcoltreenoname,subentrycounter]

\printglossary[type=parent,style=tree]

\printglossary[type=cites,style=cites,nopostdot=false,nogroupskip]

\printglossary[type=urls,style=urls,nopostdot=false,nogroupskip]

\bibliographystyle{plain}
\bibliography{xampl}

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</glossary-lipsum-examples.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-acronym-desc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test acronym entries with descriptions.

\newacronym[type=\glsdefaulttype,description={fringilla a, euismod sodales,
  sollicitudin vel, wisi}]{ndl}{NDL}{nam dui ligula}

\newacronym[type=\glsdefaulttype,description={non justo}]{mal}{MAL}{morbi auctor lorem}

\newacronym[type=\glsdefaulttype,description={pretium at, lobortis vitae, ultricies et,
tellus}]{nll}{NLL}{name lacus libero}

\newacronym[type=\glsdefaulttype,description={tortor sed accumsan bibendum, erat ligula
aliquet magna, vitae ornare odio metus a mi}]{da}{DA}{donec aliquet}

\newacronym[type=\glsdefaulttype,description={et nisl hendrerit mollis}]{mao}{MAO}{morbi ac orci}

\newacronym[type=\glsdefaulttype,description={cras nec ante}]{sum}{SUM}{suspendisse ut massa}

\newacronym[type=\glsdefaulttype,description={cum sociis natoque penatibus et magnis dis
parturient montes, nascetur ridiculus mus}]{pan}{PAN}{pellentesque a nulla}

\newacronym[type=\glsdefaulttype,description={nulla ullamcorper vestibulum 
turpis}]{atu}{ATU}{aliquam tincidunt urna}

\newacronym[type=\glsdefaulttype,description={nulla malesuada porttitor diam}]%
 {pclm}{PCLM}{pellentesque cursus luctus mauris}

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-acronym-desc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-acronym.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test acronym entries

\newacronym[type=\glsdefaulttype]{lid}{LID}{lorem ipsum dolor}

\newacronym[type=\glsdefaulttype]{stc}{STC}{sit amet consectetuer}

\newacronym[type=\glsdefaulttype]{aeu}{AEU}{adipiscing elit ut}

\newacronym[type=\glsdefaulttype]{pev}{PEV}{purus elit vestibulum}

\newacronym[type=\glsdefaulttype]{upa}{UPA}{ut placerat ac}

\newacronym[type=\glsdefaulttype]{avf}{AVF}{adipiscing vitae felis}

\newacronym[type=\glsdefaulttype]{cdg}{CDG}{curabitur dictum gravida}

\newacronym[type=\glsdefaulttype]{mna}{MNA}{mauris nam arcu}

\newacronym[type=\glsdefaulttype]{lne}{LNE}{libero nonummy eget}

\newacronym[type=\glsdefaulttype]{civ}{CIV}{consectetuer id vulputate}

\newacronym[type=\glsdefaulttype]{amd}{AMD}{a magna donec}

\newacronym[type=\glsdefaulttype]{vae}{VAE}{vehicula augue eu}

\newacronym[type=\glsdefaulttype]{nph}{NPH}{neque pellentesque habitant}

\newacronym[type=\glsdefaulttype]{mts}{MTS}{morbi tristique senectus}

\newacronym[type=\glsdefaulttype]{ene}{ENE}{et netus et}

\newacronym[type=\glsdefaulttype]{mfa}{MFA}{malesuada fames ac}

\newacronym[type=\glsdefaulttype]{tem}{TEM}{turpis egestas mauris}

\newacronym[type=\glsdefaulttype]{ulc}{ULC}{ut leo cras}

\newacronym[type=\glsdefaulttype]{vmr}{VMR}{viverra metus rhoncus}

\newacronym[type=\glsdefaulttype]{sne}{SNE}{sem nulla et}

\newacronym[type=\glsdefaulttype]{lvu}{LVU}{lectus vestibulum urna}

\newacronym[type=\glsdefaulttype]{fup}{FUP}{fringilla ultrices phasellus}

\newacronym[type=\glsdefaulttype]{ets}{ETS}{eu tellus sit}

\newacronym[type=\glsdefaulttype]{atg}{ATG}{amet tortor gravida}

\newacronym[type=\glsdefaulttype]{pis}{PIS}{placerat integer sapien}

\newacronym[type=\glsdefaulttype]{eii}{EII}{est iaculis in}

\newacronym[type=\glsdefaulttype]{pqv}{PQV}{pretium quis viverra}

\newacronym[type=\glsdefaulttype]{anp}{ANP}{ac nunc praesent}

\newacronym[type=\glsdefaulttype]{esv}{ESV}{eget sem vel}

\newacronym[type=\glsdefaulttype]{lub}{LUB}{leo ultrices bibendum}

\newacronym[type=\glsdefaulttype]{afm}{AFM}{aenean faucibus morbi}

\newacronym[type=\glsdefaulttype]{dnm}{DNM}{dolor nulla malesuada}

\newacronym[type=\glsdefaulttype]{epa}{EPA}{eu pulvinar at}

\newacronym[type=\glsdefaulttype]{man}{MAC}{mollis ac nulla}

\newacronym[type=\glsdefaulttype]{cas}{CAS}{curabitur auctor semper}

\newacronym[type=\glsdefaulttype]{ndv}{NDV}{nulla donec varius}

\newacronym[type=\glsdefaulttype]{oer}{OER}{orci eget risus}

\newacronym[type=\glsdefaulttype]{dnmc}{DNMC}{duis nibh mi congue}

\newacronym[type=\glsdefaulttype]{cea}{CEA}{congue eu accumsan}

\newacronym[type=\glsdefaulttype]{esq}{ESQ}{eleifend sagittis quis}

\newacronym[type=\glsdefaulttype]{dia}{DIA}{duis eget orci}

\newacronym[type=\glsdefaulttype]{sao}{SAO}{sit amet orci}

\newacronym[type=\glsdefaulttype]{drn}{DRN}{dignissim rutrum nam}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-acronym.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-acronyms-lang.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test acronym entries where some are provided with
 % "translations", which are stored in the user1 key.

\newacronym[type=\glsdefaulttype,user1={love itself}]{li}{LI}{lorem ipsum}

\newacronym[type=\glsdefaulttype,user1={produces none}]{np}{NP}{nulla pariatur}

\newacronym[type=\glsdefaulttype,user1={blame belongs}]{sic}{SIC}{sunt in culpa}

\newacronym[type=\glsdefaulttype,user1={blinded by
desire}]{esoc}{ESOC}{excepturi sint obcaecati cupiditat}

\newacronym[type=\glsdefaulttype]{nmruu}{NMRUU}{nulla malesuada
risus ut urna}

\newacronym[type=\glsdefaulttype]{di}{DI}{duis iaculi}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-acronyms-lang.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-brief.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with brief descriptions.

\newglossaryentry{lorem}{name={lorem},description={ipsum}}

\newglossaryentry{dolor}{name={dolor},description={sit}}

\newglossaryentry{amet}{name={amet},description={consectetuer}}

\newglossaryentry{adipiscing}{name={adipiscing},description={elit}}

\newglossaryentry{ut}{name={ut},description={purus}}

\newglossaryentry{elit}{name={elit},description={vestibulum}}

\newglossaryentry{placerat}{name={placerat},description={ac}}

\newglossaryentry{vitae}{name={vitae},description={felis}}

\newglossaryentry{curabitur}{name={curabitur},description={gravida}}

\newglossaryentry{mauris}{name={mauris},description={nam}}

\newglossaryentry{arcu}{name={arcu},description={libero}}

\newglossaryentry{nonummy}{name={nonummy},description={eget}}

\newglossaryentry{consectetuer}{name={consectetuer},description={id}}

\newglossaryentry{vulputate}{name={vulputate},description={a magna}}

\newglossaryentry{donec}{name={donec},description={vehicula}}

\newglossaryentry{augue}{name={augue},description={eu neque}}

\newglossaryentry{pellentesque}{name={pellentesque},description={habitant}}

\newglossaryentry{morbi}{name={morbi},description={tristique}}

\newglossaryentry{senectus}{name={senectus},description={et netus}}

\newglossaryentry{et}{name={et},description={malesuada}}

\newglossaryentry{fames}{name={fames},description={ac}}

\newglossaryentry{turpis}{name={turpis},description={egestas}}

\newglossaryentry{leo}{name={leo},description={cras}}

\newglossaryentry{viverra}{name={viverra},description={metus}}

\newglossaryentry{rhoncus}{name={rhoncus},description={sem}}

\newglossaryentry{nulla}{name={nulla},description={et}}

\newglossaryentry{lectus}{name={lectus},description={vestibulum}}

\newglossaryentry{urna}{name={urna},description={fringilla}}

\newglossaryentry{ultrices}{name={ultrices},description={phasellus}}

\newglossaryentry{eu}{name={eu},description={tellus}}

\newglossaryentry{sit}{name={sit},description={amet}}

\newglossaryentry{tortor}{name={tortor},description={gravida}}

\newglossaryentry{integer}{name={integer},description={sapien}}

\newglossaryentry{est}{name={est},description={iaculis}}

\newglossaryentry{in}{name={in},description={pretium}}

\newglossaryentry{quis}{name={quis},description={viverra}}

\newglossaryentry{ac}{name={ac},description={nunc}}

\newglossaryentry{praesent}{name={praesent},description={eget}}

\newglossaryentry{sem}{name={sem},description={vel leo}}

\newglossaryentry{bibendum}{name={bibendum},description={ultrices}}

\newglossaryentry{aenean}{name={aenean},description={faucibus}}

\newglossaryentry{malesuada}{name={malesuada},description={eu}}

\newglossaryentry{pulvinar}{name={pulvinar},description={at}}

\newglossaryentry{mollis}{name={mollis},description={ac nulla}}

\newglossaryentry{auctor}{name={auctor},description={semper}}

\newglossaryentry{varius}{name={varius},description={orci}}

\newglossaryentry{eget}{name={eget},description={risus}}

\newglossaryentry{duis}{name={duis},description={nibh}}

\newglossaryentry{mi}{name={mi},description={congue}}

\newglossaryentry{accumsan}{name={accumsan},description={eleifend}}

\newglossaryentry{sagittis}{name={sagittis},description={quis}}

\newglossaryentry{diam}{name={diam},description={duis}}

\newglossaryentry{orci}{name={orci},description={dignissim}}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-brief.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-childnoname.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with child entries that don't have
 % a name supplied. (The name is the same as the parent name.)

\newglossaryentry{scelerisque}{name={scelerisque},description={at}}

\newglossaryentry{vestibulum}{parent={scelerisque},description={eu, nulla}}

\newglossaryentry{utodionisl}{parent={scelerisque},description={facilisis id}}

\newglossaryentry{molliset}{parent={scelerisque},description={nec, enim}}

\newglossaryentry{aeneansem}{parent={scelerisque},description={sem leo}}

\newglossaryentry{pellentesquesit}{parent={scelerisque},description={sit amet}}

\newglossaryentry{sapien}{parent={scelerisque},description={vehicula
pellentesque}}

\newglossaryentry{consequat}{parent={scelerisque},description={tellus
et tortor}}

\newglossaryentry{uttempor}{name={ut tempor},description={laoreet
quam}}

\newglossaryentry{nullamid}{parent={uttempor},description={wisi a
libero}}

\newglossaryentry{tristique}{parent={uttempor},description={semper}}

\newglossaryentry{nullamnislmassa}{parent={uttempor},description={rutrum
ut}}

\newglossaryentry{eleifend}{name={eleifend},description={sit amet
faucibus}}

\newglossaryentry{elementum}{parent={eleifend},description={elementum}}

\newglossaryentry{urnasapien}{parent={eleifend},description={urna sapien}}

\newglossaryentry{consectetuermauris}{name={consectetuer},description={mauris}}

\newglossaryentry{quisegestas}{parent={consectetuermauris},description={quis egestas}}

\newglossaryentry{leojusto}{parent={consectetuermauris},description={leo
justo}}

\newglossaryentry{nonrisus}{name={non risus},description={morbi non
felis}}

\newglossaryentry{aclibero}{parent={nonrisus},description={ac libero}}

\newglossaryentry{vulputatefringilla}{parent={nonrisus},description={vulputate
fringilla}}

\newglossaryentry{maurislibero}{name={mauris},description={libero eros}}

\newglossaryentry{lacinia}{parent={maurislibero},description={lacinia
non}}

\newglossaryentry{sodales}{parent={maurislibero},description={sodales
quis}}

\newglossaryentry{dapibus}{parent={maurislibero},description={dapibus
porttitor, pede}}

\newglossaryentry{class}{name={class},description={aptent taciti}}

\newglossaryentry{sociosqu}{parent={class},description={sociosqu}}

\newglossaryentry{adlitora}{parent={class},description={ad litora}}

\newglossaryentry{torquent}{parent={class},description={torquent per
conubia}}

\newglossaryentry{nostra}{name={nostra},description={per inceptos
hymenaeos}}

\newglossaryentry{morbidapibus}{parent={nostra},description={morbi
dapibus}}

\newglossaryentry{mauriscondimentum}{parent={nostra},description={mauris
condimentum nulla}}

\newglossaryentry{cumsociis}{name={cum sociis},description={natoque
penatibus}}

\newglossaryentry{etmagnis}{parent={cumsociis},description={et
magnis}}

\newglossaryentry{disparturient}{parent={cumsociis},description={dis
parturient montes}}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-childnoname.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-cite.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with citation labels stored in
 % the user1 field. (The citations are defined in the xampl.bib file
 % that should be available on modern TeX distributions.)

\newglossaryentry{fusce}{name={fusce},
description={suscipit cursus sem},user1={article-minimal}}

\newglossaryentry{vivamus}{name={vivamus},
description={risus mi, egestas ac},user1={article-full}}

\newglossaryentry{imperdiet}{name={imperdiet},
description={varius, faucibus quis, leo},user1={whole-journal}}

\newglossaryentry{aenean2}{name={aenean},
description={tincidunt},user1={inbook-minimal}}

\newglossaryentry{crasid}{name={cras id},
description={justo quis nibh scelerisque dignissim},
user1={inbook-full}}

\newglossaryentry{aliquam2}{name={aliquam},
description={sagittis elementum dolor},
user1={book-minimal}}

\newglossaryentry{aeneanconsectetuer}{name={aenean consectetuer},
description={justo in pede},
user1={book-full}}

\newglossaryentry{curabiturullamcorper}{name={curabitur ullamcorper},
description={ligula nec orci},
user1={booklet-minimal}}

\newglossaryentry{aliquampurus}{name={aliquam purus},
description={turpis, aliquam id},
user1={booklet-full}}

\newglossaryentry{ornarevitae}{name={ornare vitae},
description={porttitor non, wisi},
user1={incollection-minimal}}

\newglossaryentry{maecenasluctus}{name={maecenas luctus},
description={porta lorem},
user1={incollection-full}}

\newglossaryentry{donecvitae}{name={donec vitae},
description={ligula eu ante pretium varius},
user1={manual-minimal}}

\newglossaryentry{proin}{name={proin},
description={tortor metus, convallis et},
user1={manual-full}}

\newglossaryentry{hendrerit}{name={hendrerit},
description={non, scelerisque in, urna},
user1={mastersthesis-minimal}}

\newglossaryentry{crasquis}{name={cras qui},
description={libero eu ligula bibendum tempor},
user1={mastersthesis-full}}

\newglossaryentry{vivamustellus}{name={vivamus tellus},
description={quam, malesuada eu, tempus sed, tempor sed, velit},
user1={misc-minimal}}

\newglossaryentry{doneclacinia}{name={donec lacinia},
description={auctor libero},
user1={misc-full}}

\newglossaryentry{praesent2}{name={praesent},
description={sed neque id pede mollis rutrum},
user1={inproceedings-minimal}}

 % Here's one with multiple cites:
\newglossaryentry{vestibulum2}{name={vestibulum},
description={iaculis risus},
user1={inproceedings-minimal,phdthesis-minimal}}

 % Here's one without a user1 key for comparison:
\newglossaryentry{pellentesque2}{name={pellentesque},
description={lacus}}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-cite.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-images.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with multi-paragraph descriptions
 % that have an associated image file (stored in user1).
 % The referenced image files are provided by the mwe package.

\longnewglossaryentry{sedfeugiat}{name={sed feugiat},user1={example-image}}%
{%
Cum sociis natoque penatibus et magnis dis parturient montes,
nascetur ridiculus mus. Ut pellentesque augue sed urna. Vestibulum
diam eros, fringilla et, consectetuer eu, nonummy id, sapien. Nullam
at lectus. In sagittis ultrices mauris. Curabitur malesuada erat sit
amet massa. Fusce blandit. Aliquam erat volutpat.  Aliquam euismod.
Aenean vel lectus.  Nunc imperdiet justo nec dolor.

Etiam euismod. Fusce facilisis lacinia dui.  Suspendisse potenti. In
mi erat, cursus id, nonummy sed, ullamcorper eget, sapien. Praesent
pretium, magna in eleifend egestas, pede pede pretium lorem, quis
consectetuer tortor sapien facilisis magna.  Mauris quis magna
varius nulla scelerisque imperdiet. Aliquam non quam. Aliquam
porttitor quam a lacus. Praesent vel arcu ut tortor cursus volutpat.
In vitae pede quis diam bibendum placerat. Fusce elementum convallis
neque. Sed dolor orci, scelerisque ac, dapibus nec, ultricies ut,
mi. Duis nec dui quis leo sagittis commodo.
}

\longnewglossaryentry{aliquamlectus}%
{name={aliquam lectus},user1={example-image-a}}%
{%
Vivamus leo. Quisque ornare tellus ullamcorper nulla. Mauris
porttitor pharetra tortor. Sed fringilla justo sed mauris. Mauris
tellus. Sed non leo. Nullam elementum, magna in cursus sodales,
augue est scelerisque sapien, venenatis congue nulla arcu et pede.
Ut suscipit enim vel sapien.  Donec congue. Maecenas urna mi,
suscipit in, placerat ut, vestibulum ut, massa. Fusce ultrices nulla
et nisl.

Etiam ac leo a risus tristique nonummy. Donec dignissim tincidunt
nulla. Vestibulum rhoncus molestie odio. Sed lobortis, justo et
pretium lobortis, mauris turpis condimentum augue, nec ultricies
nibh arcu pretium enim. Nunc purus neque, placerat id, imperdiet
sed, pellentesque nec, nisl. Vestibulum imperdiet neque non sem
accumsan laoreet. In hac habitasse platea dictumst. Etiam
condimentum facilisis libero. Suspendisse in elit quis nisl aliquam
dapibus. Pellentesque auctor sapien. Sed egestas sapien nec lectus.
Pellentesque vel dui vel neque bibendum viverra.  Aliquam porttitor
nisl nec pede. Proin mattis libero vel turpis.  Donec rutrum mauris
et libero. Proin euismod porta felis. Nam lobortis, metus quis
elementum commodo, nunc lectus elementum mauris, eget vulputate
ligula tellus eu neque. Vivamus eu dolor.
}

\longnewglossaryentry{nullainipsum}%
{name={nulla in ipsum},user1={example-image-b}}%
{%
 Praesent eros nulla, congue vitae, euismod ut, commodo a, wisi.
Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas.  Aenean nonummy magna non leo. Sed felis
erat, ullamcorper in, dictum non, ultricies ut, lectus. Proin vel
arcu a odio lobortis euismod.  Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Proin ut
est. Aliquam odio. Pellentesque massa turpis, cursus eu, euismod
nec, tempor congue, nulla. Duis viverra gravida mauris. Cras
tincidunt. Curabitur eros ligula, varius ut, pulvinar in, cursus
faucibus, augue.

Nulla mattis luctus nulla. Duis commodo velit at leo.  Aliquam
vulputate magna et leo. Nam vestibulum ullamcorper leo.  Vestibulum
condimentum rutrum mauris. Donec id mauris. Morbi molestie justo et
pede. Vivamus eget turpis sed nisl cursus tempor.  Curabitur mollis
sapien condimentum nunc. In wisi nisl, malesuada at, dignissim sit
amet, lobortis in, odio. Aenean consequat arcu a ante. Pellentesque
porta elit sit amet orci. Etiam at turpis nec elit ultricies
imperdiet. Nulla facilisi. In hac habitasse platea dictumst.
Suspendisse viverra aliquam risus. Nullam pede justo, molestie
nonummy, scelerisque eu, facilisis vel, arcu.
}

\longnewglossaryentry{curabiturtellusmagna}%
{name={curabitur tellus magna},user1={example-image-c}}%
{%
Donec interdum. Praesent scelerisque.  Maecenas posuere sodales
odio. Vivamus metus lacus, varius quis, imperdiet quis, rhoncus a,
turpis. Etiam ligula arcu, elementum a, venenatis quis, sollicitudin
sed, metus. Donec nunc pede, tincidunt in, venenatis vitae, faucibus
vel, nibh. Pellentesque wisi. Nullam malesuada. Morbi ut tellus ut
pede tincidunt porta. Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Etiam congue neque id dolor.

Donec et nisl at wisi luctus bibendum. Nam interdum tellus ac
libero. Sed sem justo, laoreet vitae, fringilla at, adipiscing ut,
nibh. Maecenas non sem quis tortor eleifend fermentum. Etiam id
tortor ac mauris porta vulputate. Integer porta neque vitae massa.
Maecenas tempus libero a libero posuere dictum.  Vestibulum ante
ipsum primis in faucibus orci luctus et ultrices posuere cubilia
Curae; Aenean quis mauris sed elit commodo placerat.  Class aptent
taciti sociosqu ad litora torquent per conubia nostra, per inceptos
hymenaeos. Vivamus rhoncus tincidunt libero. Etiam elementum pretium
justo. Vivamus est. Morbi a tellus eget pede tristique commodo.
Nulla nisl. Vestibulum sed nisl eu sapien cursus rutrum.
}

\longnewglossaryentry{nullanonmauris}%
{name={nulla non mauris},user1={example-image-16x10}}%
{%
Nullam varius. Etiam dignissim elementum metus. Vestibulum faucibus,
metus sit amet mattis rhoncus, sapien dui laoreet odio, nec
ultricies nibh augue a enim. Fusce in ligula. Quisque at magna et
nulla commodo consequat.  Proin accumsan imperdiet sem. Nunc porta.
Donec feugiat mi at justo.  Phasellus facilisis ipsum quis ante. In
ac elit eget ipsum pharetra faucibus.  Maecenas viverra nulla in
massa.

Nulla ac nisl. Nullam urna nulla, ullamcorper in, interdum sit amet,
gravida ut, risus. Aenean ac enim. In luctus.  Phasellus eu quam
vitae turpis viverra pellentesque. Duis feugiat felis ut enim.
Phasellus pharetra, sem id porttitor sodales, magna nunc aliquet
nibh, nec blandit nisl mauris at pede. Suspendisse risus risus,
lobortis eget, semper at, imperdiet sit amet, quam.  Quisque
scelerisque dapibus nibh. Nam enim. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Nunc ut metus. Ut metus justo, auctor
at, ultrices eu, sagittis ut, purus. Aliquam aliquam.
}

\longnewglossaryentry{etiampedemassa}%
{name={etiam pede massa},user1={example-image-10x16}}%
{%
Vestibulum luctus commodo lacus. Morbi lacus dui, tempor sed,
euismod eget, condimentum at, tortor. Phasellus aliquet odio ac
lacus tempor faucibus. Praesent sed sem. Praesent iaculis.  Cras
rhoncus tellus sed justo ullamcorper sagittis.  Donec quis orci.
Sed ut tortor quis tellus euismod tincidunt. Suspendisse congue nisl
eu elit. Aliquam tortor diam, tempus id, tristique eget, sodales
vel, nulla. Praesent tellus mi, condimentum sed, viverra at,
consectetuer quis, lectus. In auctor vehicula orci. Sed pede sapien,
euismod in, suscipit in, pharetra placerat, metus. Vivamus commodo
dui non odio. Donec et felis.

Etiam suscipit aliquam arcu. Aliquam sit amet est ac purus bibendum
congue. Sed in eros. Morbi non orci.  Pellentesque mattis lacinia
elit. Fusce molestie velit in ligula.  Nullam et orci vitae nibh
vulputate auctor. Aliquam eget purus.  Nulla auctor wisi sed ipsum.
Morbi porttitor tellus ac enim. Fusce ornare. Proin ipsum enim,
tincidunt in, ornare venenatis, molestie a, augue. Donec vel pede in
lacus sagittis porta. Sed hendrerit ipsum quis nisl.  Suspendisse
quis massa ac nibh pretium cursus.  Sed sodales. Nam eu neque quis
pede dignissim ornare. Maecenas eu purus ac urna tincidunt congue.
}

\longnewglossaryentry{donecetnisl}%
{name={donec et nisl},user1={example-image-16x9}}%
{%
Aenean dictum odio sit amet risus. Morbi purus. Nulla a est sit amet
purus venenatis iaculis. Vivamus viverra purus vel magna. Donec in
justo sed odio malesuada dapibus. Nunc ultrices aliquam nunc.
Vivamus facilisis pellentesque velit. Nulla nunc velit, vulputate
dapibus, vulputate id, mattis ac, justo. Nam mattis elit dapibus
purus.  Quisque enim risus, congue non, elementum ut, mattis quis,
sem.  Quisque elit.

Maecenas non massa. Vestibulum pharetra nulla at lorem. Duis quis
quam id lacus dapibus interdum. Nulla lorem.  Donec ut ante quis
dolor bibendum condimentum. Etiam egestas tortor vitae lacus.
Praesent cursus. Mauris bibendum pede at elit. Morbi et felis a
lectus interdum facilisis. Sed suscipit gravida turpis.  Nulla at
lectus. Vestibulum ante ipsum primis in faucibus orci luctus et
ultrices posuere cubilia Curae; Praesent nonummy luctus nibh. Proin
turpis nunc, congue eu, egestas ut, fringilla at, tellus. In hac
habitasse platea dictumst.
}

\longnewglossaryentry{vivamuseutellus}%
{name={vivamus eu tellus},user1={example-image-9x16}}%
{%
 Nam orci orci, malesuada id, gravida nec, ultricies vitae, erat.
Donec risus turpis, luctus sit amet, interdum quis, porta sed,
ipsum.  Suspendisse condimentum, tortor at egestas posuere, neque
metus tempor orci, et tincidunt urna nunc a purus. Sed facilisis
blandit tellus. Nunc risus sem, suscipit nec, eleifend quis, cursus
quis, libero. Curabitur et dolor. Sed vitae sem. Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Maecenas ante. Duis ullamcorper enim. Donec tristique enim eu leo.
Nullam molestie elit eu dolor. Nullam bibendum, turpis vitae
tristique gravida, quam sapien tempor lectus, quis pretium tellus
purus ac quam. Nulla facilisi.

Duis aliquet dui in est. Donec eget est. Nunc lectus odio, varius
at, fermentum in, accumsan non, enim. Aliquam erat volutpat. Proin
sit amet nulla ut eros consectetuer cursus.  Phasellus dapibus
aliquam justo. Nunc laoreet. Donec consequat placerat magna. Duis
pretium tincidunt justo. Sed sollicitudin vestibulum quam. Nam quis
ligula. Vivamus at metus. Etiam imperdiet imperdiet pede. Aenean
turpis. Fusce augue velit, scelerisque sollicitudin, dictum vitae,
tempor et, pede. Donec wisi sapien, feugiat in, fermentum ut,
sollicitudin adipiscing, metus.
}

\longnewglossaryentry{donecvelnibh}%
{name={donec vel nibh},user1={example-image-golden}}%
{%
  Donec pede. Sed id quam id wisi laoreet suscipit. Nulla lectus
dolor, aliquam ac, fringilla eget, mollis ut, orci. In pellentesque
justo in ligula. Maecenas turpis. Donec eleifend leo at felis
tincidunt consequat. Aenean turpis metus, malesuada sed, condimentum
sit amet, auctor a, wisi. Pellentesque sapien elit, bibendum ac,
posuere et, congue eu, felis. Vestibulum mattis libero quis metus
scelerisque ultrices. Sed purus.

Donec molestie, magna ut luctus ultrices, tellus arcu nonummy velit,
sit amet pulvinar elit justo et mauris.  In pede.  Maecenas euismod
elit eu erat. Aliquam augue wisi, facilisis congue, suscipit in,
adipiscing et, ante. In justo. Cras lobortis neque ac ipsum. Nunc
fermentum massa at ante. Donec orci tortor, egestas sit amet,
ultrices eget, venenatis eget, mi.  Maecenas vehicula leo semper
est. Mauris vel metus. Aliquam erat volutpat. In rhoncus sapien ac
tellus. Pellentesque ligula.
}

\longnewglossaryentry{crasdapibus}%
{name={cras dapibus},user1={example-image-golden-upright}}%
{%
Aenean interdum nibh sed wisi. Praesent sollicitudin vulputate dui.
Praesent iaculis viverra augue. Quisque in libero. Aenean gravida
lorem vitae sem ullamcorper cursus. Nunc adipiscing rutrum ante.
Nunc ipsum massa, faucibus sit amet, viverra vel, elementum semper,
orci. Cras eros sem, vulputate et, tincidunt id, ultrices eget,
magna. Nulla varius ornare odio. Donec accumsan mauris sit amet
augue. Sed ligula lacus, laoreet non, aliquam sit amet, iaculis
tempor, lorem. Suspendisse eros. Nam porta, leo sed congue tempor,
felis est ultrices eros, id mattis velit felis non metus.  Curabitur
vitae elit non mauris varius pretium. Aenean lacus sem, tincidunt
ut, consequat quis, porta vitae, turpis. Nullam laoreet fermentum
urna. Proin iaculis lectus.

Sed mattis, erat sit amet gravida malesuada, elit augue egestas
diam, tempus scelerisque nunc nisl vitae libero.  Sed consequat
feugiat massa. Nunc porta, eros in eleifend varius, erat leo rutrum
dui, non convallis lectus orci ut nibh. Sed lorem massa, nonummy
quis, egestas id, condimentum at, nisl. Maecenas at nibh.  Aliquam
et augue at nunc pellentesque ullamcorper. Duis nisl nibh, laoreet
suscipit, convallis ut, rutrum id, enim. Phasellus odio.  Nulla
nulla elit, molestie non, scelerisque at, vestibulum eu, nulla. Ut
odio nisl, facilisis id, mollis et, scelerisque nec, enim.  Aenean
sem leo, pellentesque sit amet, scelerisque sit amet, vehicula
pellentesque, sapien.
}

\longnewglossaryentry{sedconsequat}%
{name={sed consequat},user1={example-image-1x1}}%
{%
Ut tempor laoreet quam. Nullam id wisi a libero tristique semper.
Nullam nisl massa, rutrum ut, egestas semper, mollis id, leo. Nulla
ac massa eu risus blandit mattis. Mauris ut nunc. In hac habitasse
platea dictumst.  Aliquam eget tortor. Quisque dapibus pede in erat.
Nunc enim. In dui nulla, commodo at, consectetuer nec, malesuada
nec, elit. Aliquam ornare tellus eu urna. Sed nec metus. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus.  Pellentesque habitant morbi tristique senectus et
netus et malesuada fames ac turpis egestas.

Phasellus id magna. Duis malesuada interdum arcu.  Integer metus.
Morbi pulvinar pellentesque mi. Suspendisse sed est eu magna
molestie egestas. Quisque mi lorem, pulvinar eget, egestas quis,
luctus at, ante. Proin auctor vehicula purus. Fusce ac nisl aliquam
ante hendrerit pellentesque. Class aptent taciti sociosqu ad litora
torquent per conubia nostra, per inceptos hymenaeos. Morbi wisi.
Etiam arcu mauris, facilisis sed, eleifend non, nonummy ut, pede.
Cras ut lacus tempor metus mollis placerat.  Vivamus eu tortor vel
metus interdum malesuada.
}

 % This one doesn't have an image. The style can test whether an
 % image has been supplied using \ifglshasfield

\longnewglossaryentry{sedeleifend}%
{name={sed eleifend}}%
{%
Morbi non felis ac libero vulputate fringilla. Mauris libero eros,
lacinia non, sodales quis, dapibus porttitor, pede.  Class aptent
taciti sociosqu ad litora torquent per conubia nostra, per inceptos
hymenaeos. Morbi dapibus mauris condimentum nulla.  Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur
ridiculus mus. Etiam sit amet erat. Nulla varius. Etiam tincidunt
dui vitae turpis. Donec leo. Morbi vulputate convallis est.  Integer
aliquet. Pellentesque aliquet sodales urna.
}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-images.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-long.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with long descriptions.

\newglossaryentry{loremipsum}{name={lorem ipsum},
description={dolor sit amet, consectetuer adipiscing elit. Ut purus
elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur
dictum gravida mauris.}}

\newglossaryentry{namearcu}{name={name arcu},
description={libero, nonummy eget, consectetuer id, vulputate a, magna. Donec
vehicula augue eu neque. Pellentesque habitant morbi tristique
senectus et netus et malesuada fames ac turpis egestas. Mauris ut
leo.}}

\newglossaryentry{crasviverra}{name={cras viverra},
description={metus rhoncus sem. Nulla et lectus vestibulum
urna fringilla ultrices.  Phasellus eu tellus sit amet tortor gravida
placerat.}}

\newglossaryentry{integersapien}{name={integer sapien},
description={est, iaculis in, pretium quis, viverra ac,
nunc. Praesent eget sem vel leo ultrices bibendum. Aenean
faucibus.}}

\newglossaryentry{morbidolor}{name={morbi dolor},
description={nulla, malesuada eu, pulvinar at, mollis ac, nulla.
Curabitur auctor semper nulla. Donec varius orci eget risus. Duis
nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis
eget orci sit amet orci dignissim rutrum.}}

\newglossaryentry{namdui}{name={nam dui},
description={ligula, fringilla a, euismod sodales,
sollicitudin vel, wisi. Morbi auctor lorem non justo.}}

\newglossaryentry{namlacus}{name={nam lacus},
description={libero, pretium at, lobortis vitae, ultricies et,
tellus. Donec aliquet, tortor sed accumsan bibendum, erat ligula aliquet magna,
vitae ornare odio metus a mi.}}

\newglossaryentry{morbiac}{name={morbi ac},
description={orci et nisl hendrerit mollis. Suspendisse ut massa.
Cras nec ante. Pellentesque a nulla.  Cum sociis natoque penatibus
et magnis dis parturient montes, nascetur ridiculus mus.}}

\newglossaryentry{aliquam}{name={aliquam},
description={tincidunt urna. Nulla ullamcorper
vestibulum turpis. Pellentesque cursus luctus mauris.}}

\newglossaryentry{nullamalesuada}{name={nulla malesuada},
description={porttitor diam. Donec felis erat, congue non, volutpat at, 
tincidunt tristique, libero.  Vivamus viverra fermentum felis.}}

\newglossaryentry{donecnonummy}{name={donec nonummy},
description={pellentesque ante. Phasellus
adipiscing semper elit. Proin fermentum massa ac quam. Sed diam
turpis, molestie vitae, placerat a, molestie nec, leo.}}

\newglossaryentry{maecenaslacinia}{name={maecenas lacinia},
description={nam ipsum ligula, eleifend at, accumsan nec, suscipit
a, ipsum. Morbi blandit ligula feugiat magna. Nunc eleifend consequat
lorem.}}

\newglossaryentry{sedlacinia}{name={sed lacinia},
description={nulla vitae enim. Pellentesque tincidunt purus
vel magna. Integer non enim. Praesent euismod nunc eu purus. Donec
bibendum quam in tellus.}}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-long.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-multipar.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with multi-paragraph descriptions.

\longnewglossaryentry{loremi-ii}{name={lorem 1--2}}%
{%
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur
dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer
id, vulputate a, magna. Donec vehicula augue eu neque. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac
turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla
et lectus vestibulum urna fringilla ultrices.  Phasellus eu tellus
sit amet tortor gravida placerat. Integer sapien est, iaculis in,
pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices
bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar
at, mollis ac, nulla.  Curabitur auctor semper nulla. Donec varius
orci eget risus. Duis nibh mi, congue eu, accumsan eleifend,
sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum.

Nam dui ligula, fringilla a, euismod sodales, sollicitudin vel,
wisi. Morbi auctor lorem non justo. Nam lacus libero, pretium at,
lobortis vitae, ultricies et, tellus. Donec aliquet, tortor sed
accumsan bibendum, erat ligula aliquet magna, vitae ornare odio
metus a mi. Morbi ac orci et nisl hendrerit mollis. Suspendisse ut
massa. Cras nec ante. Pellentesque a nulla.  Cum sociis natoque
penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Aliquam tincidunt urna. Nulla ullamcorper vestibulum turpis.
Pellentesque cursus luctus mauris.%
}

\longnewglossaryentry{loremiii-iv}{name={lorem 3--4}}%
{%
Nulla malesuada porttitor diam. Donec felis erat, congue non,
volutpat at, tincidunt tristique, libero.  Vivamus viverra fermentum
felis. Donec nonummy pellentesque ante.  Phasellus adipiscing semper
elit. Proin fermentum massa ac quam. Sed diam turpis, molestie
vitae, placerat a, molestie nec, leo. Maecenas lacinia. Nam ipsum
ligula, eleifend at, accumsan nec, suscipit a, ipsum. Morbi blandit
ligula feugiat magna. Nunc eleifend consequat lorem. Sed lacinia
nulla vitae enim. Pellentesque tincidunt purus vel magna. Integer
non enim. Praesent euismod nunc eu purus. Donec bibendum quam in
tellus. Nullam cursus pulvinar lectus. Donec et mi.  Nam vulputate
metus eu enim. Vestibulum pellentesque felis eu massa. 

Quisque ullamcorper placerat ipsum. Cras nibh.  Morbi vel justo
vitae lacus tincidunt ultrices. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. In hac habitasse platea dictumst.
Integer tempus convallis augue. Etiam facilisis. Nunc elementum
fermentum wisi. Aenean placerat. Ut imperdiet, enim sed gravida
sollicitudin, felis odio placerat quam, ac pulvinar elit purus eget
enim. Nunc vitae tortor. Proin tempus nibh sit amet nisl.  Vivamus
quis tortor vitae risus porta vehicula.%
}

\longnewglossaryentry{loremv-vi}{name={lorem 5--6}}%
{%
Fusce mauris. Vestibulum luctus nibh at lectus.  Sed bibendum, nulla
a faucibus semper, leo velit ultricies tellus, ac venenatis arcu
wisi vel nisl. Vestibulum diam. Aliquam pellentesque, augue quis
sagittis posuere, turpis lacus congue quam, in hendrerit risus eros
eget felis. Maecenas eget erat in sapien mattis porttitor.
Vestibulum porttitor. Nulla facilisi. Sed a turpis eu lacus commodo
facilisis. Morbi fringilla, wisi in dignissim interdum, justo lectus
sagittis dui, et vehicula libero dui cursus dui. Mauris tempor
ligula sed lacus. Duis cursus enim ut augue.  Cras ac magna. Cras
nulla. Nulla egestas. Curabitur a leo. Quisque egestas wisi eget
nunc. Nam feugiat lacus vel est. Curabitur consectetuer.%

Suspendisse vel felis. Ut lorem lorem, interdum eu, tincidunt sit
amet, laoreet vitae, arcu. Aenean faucibus pede eu ante. Praesent
enim elit, rutrum at, molestie non, nonummy vel, nisl. Ut lectus
eros, malesuada sit amet, fermentum eu, sodales cursus, magna. Donec
eu purus. Quisque vehicula, urna sed ultricies auctor, pede lorem
egestas dui, et convallis elit erat sed nulla.  Donec luctus.
Curabitur et nunc. Aliquam dolor odio, commodo pretium, ultricies
non, pharetra in, velit. Integer arcu est, nonummy in, fermentum
faucibus, egestas vel, odio.%
}

\longnewglossaryentry{loremvii-viii}{name={lorem 7--8}}%
{%
Sed commodo posuere pede. Mauris ut est. Ut quis purus. Sed ac odio.
Sed vehicula hendrerit sem. Duis non odio.  Morbi ut dui. Sed
accumsan risus eget odio. In hac habitasse platea dictumst.
Pellentesque non elit. Fusce sed justo eu urna porta tincidunt.
Mauris felis odio, sollicitudin sed, volutpat a, ornare ac, erat.
Morbi quis dolor. Donec pellentesque, erat ac sagittis semper, nunc
dui lobortis purus, quis congue purus metus ultricies tellus. Proin
et quam. Class aptent taciti sociosqu ad litora torquent per conubia
nostra, per inceptos hymenaeos. Praesent sapien turpis, fermentum
vel, eleifend faucibus, vehicula eu, lacus.

Pellentesque habitant morbi tristique senectus et netus et malesuada
fames ac turpis egestas. Donec odio elit, dictum in, hendrerit sit
amet, egestas sed, leo. Praesent feugiat sapien aliquet odio.
Integer vitae justo. Aliquam vestibulum fringilla lorem. Sed neque
lectus, consectetuer at, consectetuer sed, eleifend ac, lectus.
Nulla facilisi. Pellentesque eget lectus.  Proin eu metus. Sed
porttitor. In hac habitasse platea dictumst.  Suspendisse eu lectus.
Ut mi mi, lacinia sit amet, placerat et, mollis vitae, dui. Sed ante
tellus, tristique ut, iaculis eu, malesuada ac, dui.  Mauris nibh
leo, facilisis non, adipiscing quis, ultrices a, dui.%
}

\longnewglossaryentry{loremix-x}{name={lorem 9--10}}%
{%
Morbi luctus, wisi viverra faucibus pretium, nibh est placerat odio,
nec commodo wisi enim eget quam. Quisque libero justo, consectetuer
a, feugiat vitae, porttitor eu, libero.  Suspendisse sed mauris
vitae elit sollicitudin malesuada. Maecenas ultricies eros sit amet
ante. Ut venenatis velit. Maecenas sed mi eget dui varius euismod.
Phasellus aliquet volutpat odio.  Vestibulum ante ipsum primis in
faucibus orci luctus et ultrices posuere cubilia Curae; Pellentesque
sit amet pede ac sem eleifend consectetuer. Nullam elementum, urna
vel imperdiet sodales, elit ipsum pharetra ligula, ac pretium ante
justo a nulla. Curabitur tristique arcu eu metus. Vestibulum lectus.
Proin mauris. Proin eu nunc eu urna hendrerit faucibus. Aliquam
auctor, pede consequat laoreet varius, eros tellus scelerisque quam,
pellentesque hendrerit ipsum dolor sed augue. Nulla nec lacus.

Suspendisse vitae elit. Aliquam arcu neque, ornare in, ullamcorper
quis, commodo eu, libero. Fusce sagittis erat at erat tristique
mollis. Maecenas sapien libero, molestie et, lobortis in, sodales
eget, dui. Morbi ultrices rutrum lorem. Nam elementum ullamcorper
leo. Morbi dui. Aliquam sagittis. Nunc placerat.  Pellentesque
tristique sodales est. Maecenas imperdiet lacinia velit. Cras non
urna. Morbi eros pede, suscipit ac, varius vel, egestas non, eros.
Praesent malesuada, diam id pretium elementum, eros sem dictum
tortor, vel consectetuer odio sem sed wisi.%
}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-multipar.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-parent.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with child entries.

\newglossaryentry{sedmattis}{name={sed mattis},description={erat sit amet}}

\newglossaryentry{gravida}{parent={sedmattis},name={gravida},description={malesuada}}

\newglossaryentry{elitaugue}{parent={sedmattis},name={elit augue},
description={egestas diam}}

\newglossaryentry{tempus}{parent={sedmattis},name={tempus},
description={scelerisque}}

\newglossaryentry{nunc}{name={nunc},description={nisl vitae}}

\newglossaryentry{libero}{parent={nunc},name={libero},description={sed
consequat}}

\newglossaryentry{feugiat}{parent={nunc},name={feugiat},description={massa}}

\newglossaryentry{porta}{parent={nunc},name={porta},description={eros
in eleifend}}

\newglossaryentry{variuserat}{parent={nunc},name={varius erat},
description={leo rutrum dui}}

\newglossaryentry{nonconvallis}{name={non
convallis},description={lectus orci ut nibh}}

\newglossaryentry{sedlorem}{parent={nonconvallis},name={sedlorem},description={massa}}

\newglossaryentry{nonummyquis}{parent={nonconvallis},name={nonummy
quis}, description={egestas id}}

\newglossaryentry{condimentum}{name={condimentum},description={at
nisl}}

\newglossaryentry{maecenas}{parent={condimentum},name={maecenas},
description={at nibh}}

\newglossaryentry{aliquamet}{name={aliquam et},description={augue}}

\newglossaryentry{atnunc}{parent={aliquamet},name={at nunc},description={pellentesque
ullamcorper}}

\newglossaryentry{duisnisl}{parent={atnunc},name={duisnisl},description={laoreet
suscipit}}

\newglossaryentry{duisnibh}{parent={atnunc},name={duisnibh},
description={convallis ut}}

\newglossaryentry{rutrum}{name={rutrum},description={id, enim}}

\newglossaryentry{phasellus}{parent={rutrum},name={phasellus},
description={odio}}

\newglossaryentry{nullanulla}{parent={rutrum},name={nulla nulla},
description={elit, molestie non}}

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-parent.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-symbols.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with associated symbols.

\newglossaryentry{alpha}{name={alpha},symbol={\ensuremath{\alpha}},
description={Quisque ullamcorper placerat ipsum.}}

\newglossaryentry{beta}{name={beta},symbol={\ensuremath{\beta}},
description={Cras nibh.}}

\newglossaryentry{gamma}{name={gamma},symbol={\ensuremath{\gamma}},
description={Morbi vel justo vitae lacus tincidunt ultrices.}}

\newglossaryentry{delta}{name={delta},symbol={\ensuremath{\delta}},
description={Lorem ipsum dolor sit amet, consectetuer adipiscing
elit.}}

\newglossaryentry{epsilon}{name={epsilon},symbol={\ensuremath{\epsilon}},
description={In hac habitasse platea dictumst.}}

\newglossaryentry{zeta}{name={zeta},symbol={\ensuremath{\zeta}},
description={Integer tempus convallis augue.}}

\newglossaryentry{eta}{name={eta},symbol={\ensuremath{\eta}},
description={Etiam facilisis.}}

\newglossaryentry{theta}{name={theta},symbol={\ensuremath{\theta}},
description={Nunc elementum fermentum wisi.}}

\newglossaryentry{iota}{name={iota},symbol={\ensuremath{i}},
description={Aenean placerat.}}

\newglossaryentry{kappa}{name={kappa},symbol={\ensuremath{\kappa}},
description={Ut imperdiet, enim sed gravida sollicitudin, felis odio
placerat quam, ac pulvinar elit purus eget enim.}}

\newglossaryentry{lambda}{name={lambda},symbol={\ensuremath{\lambda}},
description={Nunc vitae tortor.}}

\newglossaryentry{mu}{name={mu},symbol={\ensuremath{\mu}},
description={Proin tempus nibh sit amet nisl.}}

\newglossaryentry{nu}{name={nu},symbol={\ensuremath{\nu}},
description={Vivamus quis tortor vitae risus porta vehicula.}}

\newglossaryentry{xi}{name={xi},symbol={\ensuremath{\xi}},
description={Fusce mauris.}}

\newglossaryentry{pi}{name={pi},symbol={\ensuremath{\pi}},
description={Vestibulum luctus nibh at lectus.}}

\newglossaryentry{rho}{name={rho},symbol={\ensuremath{\rho}},
description={Sed bibendum, nulla a faucibus semper, leo velit
ultricies tellus, ac venenatis arcu wisi vel nisl. Vestibulum diam.}}

\newglossaryentry{sigma}{name={sigma},symbol={\ensuremath{\sigma}},
description={Aliquam pellentesque, augue quis sagittis posuere,
turpis lacus congue quam, in hendrerit risus eros eget felis.}}

\newglossaryentry{tau}{name={tau},symbol={\ensuremath{\tau}},
description={Maecenas eget erat in sapien mattis porttitor.}}

\newglossaryentry{upsilon}{name={upsilon},symbol={\ensuremath{\upsilon}},
description={Vestibulum porttitor.}}

\newglossaryentry{phi}{name={phi},symbol={\ensuremath{\phi}},
description={Nulla facilisi.}}

\newglossaryentry{chi}{name={chi},symbol={\ensuremath{\chi}},
description={Sed a turpis eu lacus commodo facilisis.}}

\newglossaryentry{psi}{name={psi},symbol={\ensuremath{\psi}},
description={Morbi fringilla, wisi in dignissim interdum, justo
lectus sagittis dui, et vehicula libero dui cursus dui.}}

\newglossaryentry{omega}{name={omega},symbol={\ensuremath{\omega}},
description={Mauris tempor ligula sed lacus.}}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-symbols.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*example-glossaries-url.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is part of the glossaries bundle
 % These are test glossary entries with URLs stored in
 % the user1 field.

\newglossaryentry{aenean-url}{name={aenean},
 description={adipiscing auctor est},
 user1={http://uk.tug.org/}}

\newglossaryentry{morbi-url}{name={morbi},
 description={quam arcu, malesuada sed, volutpat et, elementum sit
amet, libero},
 user1={http://www.ctan.org/}}

\newglossaryentry{duis-url}{name={duis},
 description={mattis},
 user1={http://www.tug.org/}}

 % Now try an active character
\newglossaryentry{sed-url}{name={sed},
 description={cursus lectus quis odio (uses
\texttt{\string\protect\string~})},
 user1={http://theoval.cmp.uea.ac.uk/\protect~nlct/}}

\newglossaryentry{sed2-url}{name={sed},
 description={cursus lectus quis odio (uses
\texttt{\string\string\string~})},
 user1={http://theoval.cmp.uea.ac.uk/\string~nlct/}}

\newglossaryentry{sed3-url}{name={sed},
 description={cursus lectus quis odio (uses
\texttt{\string\glstildechar})},
 user1={http://theoval.cmp.uea.ac.uk/\glstildechar nlct/}}

 % How do we deal with a percent character?

 % Temporarily change the category code

\catcode`\%=12
\newglossaryentry{phasellus-url}{name={phasellus},
 description={arcu (catcode change)},
 user1=http://theoval.cmp.uea.ac.uk/%7Enlct
}
\catcode`\%=14

 % Use \%

\newglossaryentry{phasellus2-url}{name={phasellus},
 description={arcu (uses \texttt{\string\%})},
 user1=http://theoval.cmp.uea.ac.uk/\%7Enlct
}

 % Use \glspercentchar

\newglossaryentry{phasellus3-url}{name={phasellus},
 description={arcu  (uses 
 \texttt{\string\glspercentchar})},
 user1=http://theoval.cmp.uea.ac.uk/\glspercentchar 7Enlct
}

%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</example-glossaries-url.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-crossref.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[acronym,         % create list of acronyms
            nomain,          % don't need main glossary for this example
            ]{glossaries}

\makeglossaries

  % This is a sample file to illustrate how to define a custom
  % acronym style. This example defines the acronyms so that on first use
  % they display the short form in the text and with the long form
  % and 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 \MakeTextUppercase is
  % used when it's displayed in the list of acronyms.

\newacronymstyle{custom-fn}% new style name
{% Check for long form in case of a mixed glossary
  \ifglshaslong{\glslabel}{\glsgenacfmt}{\glsgenentryfmt}%
}%
{% Style definitions:
 % User needs to supply the description:
 \renewcommand*{\GenericAcronymFields}{}%
 % Need to ensure hyperlinks are switched off on first use:
 \glshyperfirstfalse
 % Redefine the commands used by \glsgenacfmt on first use:
  \renewcommand*{\genacrfullformat}[2]{%
   \firstacronymfont{\glsentryshort{##1}}##2%
   \footnote{\glsentrylong{##1}: \glsentrydesc{##1}}%
  }%
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \footnote{\glsentrylong{##1}: \glsentrydesc{##1}}%
  }%
  \renewcommand*{\genplacrfullformat}[2]{%
   \firstacronymfont{\glsentryshortpl{##1}}##2%
   \footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}%
  }%
  \renewcommand*{\Genplacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshortpl{##1}}##2%
   \footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}%
  }%
 % Redefine the no-link full forms:
  \renewcommand*{\glsentryfull}[1]{%
    \glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\Glsentryfull}[1]{%
    \Glsentrylong{##1}\space(\acronymfont{\glsentryshort{##1}})%
  }%
  \renewcommand*{\glsentryfullpl}[1]{%
    \glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
  \renewcommand*{\Glsentryfullpl}[1]{%
    \Glsentrylongpl{##1}\space(\acronymfont{\glsentryshortpl{##1}})%
  }%
 % Redefine the link full forms:
  \renewcommand*{\acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
    }%
  }%
  \renewcommand*{\Acrfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \Glsentrylong{##2}##3\space(\acronymfont{\glsentryshort{##2}})%
    }%
  }%
  \renewcommand*{\ACRfullfmt}[3]{%
    \glslink[##1]{##2}{%
     \MakeTextUppercase{%
       \glsentrylong{##2}##3\space
         (\acronymfont{\glsentryshort{##2}})%
     }%
    }%
  }%
  \renewcommand*{\acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \glsentrylongpl{##2}##3\space
       (\acronymfont{\glsentryshortpl{##2}})%
    }%
  }%
  \renewcommand*{\Acrfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \Glsentrylongpl{##2}##3\space
       (\acronymfont{\glsentryshortpl{##2}})%
    }%
  }%
  \renewcommand*{\ACRfullplfmt}[3]{%
    \glslink[##1]{##2}{%
     \MakeTextUppercase{%
       \glsentrylongpl{##2}##3\space
         (\acronymfont{\glsentryshortpl{##2}})%
     }%
    }%
  }%
 % Use smallcaps for the acronym in the document text:
  \renewcommand*{\acronymfont}[1]{\textsc{##1}}%
  \renewcommand*{\acrpluralsuffix}{\glstextup{\glspluralsuffix}}%
 % Sort acronyms according to the long form:
  \renewcommand*{\acronymsort}[2]{##2}%
 % Set the name in the list of acronyms to the long form followed by
 % the short form (in upper case) in parentheses:
 \renewcommand*{\acronymentry}[1]{%
   \Glsentrylong{##1}\space(\MakeTextUppercase{\glsentryshort{##1}})}%
}

 % Now set the new acronym style (to override the default style)
\setacronymstyle{custom-fn}

 % Set an appropriate glossary style:
\setglossarystyle{altlist}

 % 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}.

No-link full forms: \glsentryfull{css}, \Glsentryfull{css}.
Linking full forms: \acrfull{css}, \Acrfull{css}, \ACRfull{css}.
Linking with insert: \acrfull{css}['s], \Acrfull{css}['s],
\ACRfull{css}['s].

Now test plurals.

No-link full forms: \glsentryfullpl{html}, \Glsentryfullpl{html}.
Linking full forms: \acrfullpl{html}, \Acrfullpl{html}, \ACRfullpl{html}.
Linking with insert: \acrfullpl{html}['s], \Acrfullpl{html}['s],
\ACRfullpl{html}['s].

\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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[acronym]{glossaries}

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

\newcommand*{\newdualentry}[5][]{%
  \newglossaryentry{main-#2}{name={#4},%
  text={#3\glsadd{#2}},%
  description={#5},%
  #1
  }%
  \newacronym{#2}{#3\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-entryfmt.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[style=tree]{glossaries}

\makeglossaries

\renewcommand*{\glsentryfmt}{%
  \glsgenentryfmt
  \ifglsused{\glslabel}{}{\space (\glsentrysymbol{\glslabel})}%
}

\newglossaryentry{distance}{name=distance,
description={The length between two points},
symbol={km}}

\begin{document}

First use: \gls{distance}. Next use: \gls{distance}.

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-entryfmt.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-FnDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you are using arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[hyperfirst=false]{glossaries}

\makeglossaries

\renewcommand*{\glsentryfmt}{%
  \glsgenentryfmt
  \ifglsused{\glslabel}{}{\footnote{\glsentrydesc{\glslabel}}}%
}

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

\begin{document}
\chapter{Sample Chapter}

First use: \gls{sample}.

Next use: \gls{sample}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-FnDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-ignored.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\newignoredglossary{common}

\makeglossaries

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

\newglossaryentry{commonex}{type=common,name={common term}}

\begin{document}

\gls{sample}. \gls{commonex}.

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-ignored.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-index.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[toc,index,nohypertypes={index}]{glossaries}
\usepackage{glossary-mcols}

\makeglossaries

 % define terms for the index

\newterm[plural={stegosauruses}]{stegosaurus}
\newterm[plural={triceratopses}]{triceratops}
\newterm[plural={apatosauruses}]{apatosaurus}

 % To avoid labels conflicting with the same name in the main glossary
 % prefix the index label with "ind-". (This means that the name must
 % be set independently.)
\newterm[name={dinosaur}]{ind-dinosaur}
\newterm[name={Triassic}]{ind-triassic}

 % define terms for the main glossary

\newglossaryentry{dinosaur}%
{%
  name={dinosaur\glsadd{ind-dinosaur}},%
  description={One of a group of dinosauria}%
}

\newglossaryentry{Triassic}%
{%
  name={Triassic\glsadd{ind-triassic}},%
  description={The first period of the Mesozoic Era}
}

\begin{document}
\tableofcontents

\chapter{Dinosaurs}

\Glspl{dinosaur} are now extinct. They first appeared during the
\gls{Triassic} period. Examples of \glspl{dinosaur} include the
\gls{triceratops}, the \gls{apatosaurus} and the \gls{stegosaurus}.

Indexed term: \gls{ind-dinosaur}.

\renewcommand*{\glsnamefont}[1]{\textbf{\makefirstuc{#1}}}

\printglossary[style=long,nogroupskip]

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

\printindex[style=mcolindexgroup]

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-index.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-inline.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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}}
\setglossarystyle{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}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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}{flx}{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}
 % This file is public domain
 % If you want to use arara, you need the following directive:
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage{mfirstuc-english}

\begin{document}

\makefirstuc{abc}.

\makefirstuc{{\em abc}}.

\makefirstuc{\emph{abc}}.

\makefirstuc{\ae bc}.

\makefirstuc{{\ae}bc}.

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

\capitalisewords{the wind in the willows}

\capitalisewords{a book of rhyme.}

\MFUclear

\capitalisewords{the wind in the willows}

\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-newkeys.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you are using arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[nopostdot,nogroupskip]{glossaries}

\glsaddkey*% star version needed as default value needs expanding
 {ed}% key
 {\glsentrytext{\glslabel}ed}% default value
 {\glsentryed}% command analogous to \glsentrytext
 {\Glsentryed}% command analogous to \Glsentrytext
 {\glsed}% command analogous to \glstext
 {\Glsed}% command analogous to \Glstext
 {\GLSed}% command analogous to \GLStext

\glsaddkey*
 {ing}% key
 {\glsentrytext{\glslabel}ing}% default value
 {\glsentrying}% command analogous to \glsentrytext
 {\Glsentrying}% command analogous to \Glsentrytext
 {\glsing}% command analogous to \glstext
 {\Glsing}% command analogous to \Glstext
 {\GLSing}% command analogous to \GLStext


\makeglossaries

\newglossaryentry{jump}{name={jump},description={}}

\newglossaryentry{run}{name={run},%
 ed={ran},%
 ing={running},
 description={}}

\newglossaryentry{waddle}{name={waddle},%
 ed={waddled},%
 ing={waddling},%
 description={}}

\begin{document}

This is a sample document illustrating how to add new glossary entry
keys.

The dog \glsed{jump} over the duck.

The duck was \glsing{waddle} round the dog.

The dog \glsed{run} away from the duck.

First letter uppercase: \Glsed{jump}, \Glsing{jump}, 
\Glsed{waddle}, \Glsing{waddle},
\Glsed{run}, \Glsing{run}.

All uppercase: \GLSed{jump}, \GLSing{jump}, 
\GLSed{waddle}, \GLSing{waddle},
\GLSed{run}, \GLSing{run}.

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-newkeys.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-noidxapp-utf8.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % arara: pdflatex
 % arara: pdflatex
\documentclass{report}

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

\usepackage[colorlinks]{hyperref}
\usepackage[index,symbols,nohypertypes={index}]{glossaries}
\usepackage{glossary-mcols}

\makenoidxglossaries

\renewcommand{\theHequation}{\theequation}

 % main entries

\newglossaryentry{elite}{%
  name={{é}lite},
  description={select group of people}
}

\newglossaryentry{elephant}{%
  name={elephant},
  description={very large mammal with tusks}
}

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

\newglossaryentry{emigre}{%
  name={{é}migré},
  description={person who has emigrated to another country,
   especially for political reasons}
}

 % Symbols

\newglossaryentry{set}{%
  type=symbols,
  name={$\mathcal{S}$},
  text={\mathcal{S}},
  sort={S},
  description={A set}}

\newglossaryentry{U}{%
  type=symbols,
  name={$\mathcal{U}$},
  text={\mathcal{U}},
  sort={U},
  description={The universal set}}

\newglossaryentry{card}{%
  type=symbols,
  name={$|\glsentrytext{set}|$},
  text={|\glsentrytext{set}|},
  sort={|},
  description={cardinality of $\gls{set}$}}

\newglossaryentry{factorial}{%
  type=symbols,
  name={$!$},
  text={!},
  sort={!},
  description={factorial}}

 % index entries

\newterm{seal}

\newterm{dinosaur}

\newterm[parent=dinosaur]{ceratopsidae}

\newterm[parent=dinosaur,plural={stegosauruses}]{stegosaurus}
\newterm[parent=ceratopsidae,plural={triceratopses}]{triceratops}
\newterm[parent=ceratopsidae,plural={styracosauruses}]{styracosaurus}
\newterm[parent=dinosaur,plural={apatosauruses}]{apatosaurus}

\newterm{Triassic}

\newterm{Devonian}

\newterm[see={[see also]seal}]{sea lion}

\begin{document}

\chapter{Mathematical Notation}

The cardinality of a set $\gls{set}$ is denoted $\gls{card}$
The $\gls{factorial}$ symbol indicates factorial.
$\gls{U}$ is the universal set.

\glsaddall[types=main]

\chapter{Dinosaurs}

\Glspl{dinosaur} are now extinct. They first appeared during the
\gls{Triassic} period. Examples of \glspl{dinosaur} include the
\gls{triceratops}, the \gls{styracosaurus}, the \gls{apatosaurus} and the \gls{stegosaurus}.

\Glspl{seal} and \glspl{sea lion} are marine mammals.
The \gls{Devonian} period was the age of fish.

\glsaddall[types=main]

\chapter{Location Lists}

Dinosaur: \glsdisplaynumberlist{dinosaur}.

Set: \glsdisplaynumberlist{set}.

\Gls{elite}: \glsdisplaynumberlist{elite}.

\begin{equation}
3\gls[counter=equation]{factorial} = 3 \times 2 \times 1
\end{equation}

\newcommand{\myhandler}[4]{%
  Prefix: #1.
  Counter: #2.
  Format: #3.
  Value: #4.
  Link: \setentrycounter[#1]{#2}%
  \csuse{#3}{#4}.
  \par
}
\newcommand{\myxrhandler}[2][]{XR (#1): #2. }

Factorial locations:
\glsnumberlistloop{factorial}{\myhandler}{\myxrhandler}

Sea lion locations:
\glsnumberlistloop{sea lion}{\myhandler}{\myxrhandler}

\printnoidxglossary[type=main,sort=word]

\printnoidxglossary[type=symbols,sort=use]

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

\printnoidxglossary[type=index,style=mcolindexgroup,sort=word]

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-noidxapp-utf8.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-noidxapp.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % arara: pdflatex
 % arara: pdflatex
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[index,symbols,nohypertypes={index}]{glossaries}
\usepackage{glossary-mcols}

\makenoidxglossaries

\renewcommand{\theHequation}{\theequation}

 % main entries

\newglossaryentry{elite}{%
  name={{\'e}lite},
  description={select group of people}
}

\newglossaryentry{elephant}{%
  name={elephant},
  description={very large mammal with tusks}
}

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

\newglossaryentry{emigre}{%
  name={{\'e}migr\'e},
  description={person who has emigrated to another country,
   especially for political reasons}
}

 % Symbols

\newglossaryentry{set}{%
  type=symbols,
  name={$\mathcal{S}$},
  text={\mathcal{S}},
  sort={S},
  description={A set}}

\newglossaryentry{U}{%
  type=symbols,
  name={$\mathcal{U}$},
  text={\mathcal{U}},
  sort={U},
  description={The universal set}}

\newglossaryentry{card}{%
  type=symbols,
  name={$|\glsentrytext{set}|$},
  text={|\glsentrytext{set}|},
  sort={|},
  description={cardinality of $\gls{set}$}}

\newglossaryentry{factorial}{%
  type=symbols,
  name={$!$},
  text={!},
  sort={!},
  description={factorial}}

 % index entries

\newterm{seal}

\newterm{dinosaur}

\newterm[parent=dinosaur]{ceratopsidae}

\newterm[parent=dinosaur,plural={stegosauruses}]{stegosaurus}
\newterm[parent=ceratopsidae,plural={triceratopses}]{triceratops}
\newterm[parent=ceratopsidae,plural={styracosauruses}]{styracosaurus}
\newterm[parent=dinosaur,plural={apatosauruses}]{apatosaurus}

\newterm{Triassic}

\newterm{Devonian}

\newterm[see={[see also]seal}]{sea lion}

\begin{document}

\chapter{Mathematical Notation}

The cardinality of a set $\gls{set}$ is denoted $\gls{card}$
The $\gls{factorial}$ symbol indicates factorial.
$\gls{U}$ is the universal set.

\glsaddall[types=main]

\chapter{Dinosaurs}

\Glspl{dinosaur} are now extinct. They first appeared during the
\gls{Triassic} period. Examples of \glspl{dinosaur} include the
\gls{triceratops}, the \gls{styracosaurus}, the \gls{apatosaurus} and the \gls{stegosaurus}.

\Glspl{seal} and \glspl{sea lion} are marine mammals.
The \gls{Devonian} period was the age of fish.

\glsaddall[types=main]

\chapter{Location Lists}

Dinosaur: \glsdisplaynumberlist{dinosaur}.

Set: \glsdisplaynumberlist{set}.

\Gls{elite}: \glsdisplaynumberlist{elite}.

\begin{equation}
3\gls[counter=equation]{factorial} = 3 \times 2 \times 1
\end{equation}

\newcommand{\myhandler}[4]{%
  Prefix: #1.
  Counter: #2.
  Format: #3.
  Value: #4.
  Link: \setentrycounter[#1]{#2}%
  \csuse{#3}{#4}.
  \par
}
\newcommand{\myxrhandler}[2][]{XR (#1): #2. }

Factorial locations:
\glsnumberlistloop{factorial}{\myhandler}{\myxrhandler}

Sea lion locations:
\glsnumberlistloop{sea lion}{\myhandler}{\myxrhandler}

\printnoidxglossary[type=main,sort=word]

\printnoidxglossary[type=symbols,sort=use]

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

\printnoidxglossary[type=index,style=mcolindexgroup,sort=letter]

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-noidxapp.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-nomathhyper.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage{glossaries}

\GlsDeclareNoHyperList{main}

\makeglossaries

 % redefine \glsentryfmt so that it adds a hyperlink
 % if not in math mode and the hyperlinks haven't been forced on
\renewcommand*{\glsentryfmt}{%
  \ifmmode
    \glsgenentryfmt
  \else
    \glsifhyperon
    {\glsgenentryfmt}% hyperlink already on
    {\glshyperlink[\glsgenentryfmt]{\glslabel}}%
  \fi
}

 % define a sample entry:
\newglossaryentry{x}{name={x},description={sample entry}}

\begin{document}
\chapter{Sample}
In text mode: \gls{x}. Inline maths: $\gls{x}$. Displayed
maths:
\[
  \gls{x}
\]

Back to text mode again: \gls{x}. Don't check the first use flag:
\glstext{x}. Force on the hyperlink: \glstext+{x}.

\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-nomathhyper.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-numberlist.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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-prefix.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }

\documentclass{article}

\usepackage[colorlinks]{hyperref}
\usepackage[toc,acronym]{glossaries-prefix}

\makeglossaries

\newglossaryentry{sample}{name={sample},
  description={an example},
  prefix={a~},
  prefixplural={the\space}%
}

\newglossaryentry{oeil}{name={oeil},
  plural={yeux},
  description={eye},
  prefix={l'},
  prefixplural={les\space}}

\newacronym
 [%
   prefix={an\space},prefixfirst={a~}%
 ]{svm}{SVM}{support vector machine}

\newglossarystyle{plist}{%
  \setglossarystyle{list}%
  \renewcommand*{\glossentry}[2]{%
    \item[\glsentryitem{##1}%
          \Glsentryprefix{##1}%
          \glstarget{##1}{\glossentryname{##1}}]
       \glossentrydesc{##1}\glspostdescription\space ##2}%
}

\begin{document}

\tableofcontents

\section{Sample}

First use: \pgls{sample}, \pgls{svm}, \pgls{oeil}. Next use: \pgls{sample}, \pgls{svm}, \pgls{oeil}.

Reset. \glsresetall

First use: \pglspl{sample}, \pglspl{svm}, \pglspl{oeil}. Next use:
\pglspl{sample}, \pglspl{svm}, \pglspl{oeil}.

Reset. \glsresetall

First use: \Pgls{sample}, \Pgls{svm}. Next use: \Pgls{sample}, \Pgls{svm}.

Reset. \glsresetall

First use: \Pglspl{sample}, \Pglspl{svm}. Next use: \Pglspl{sample}, \Pglspl{svm}.

Reset. \glsresetall

First use: \PGLS{sample}, \PGLS{svm}. Next use: \PGLS{sample}, \PGLS{svm}.

Reset. \glsresetall

First use: \PGLSpl{sample}, \PGLSpl{svm}. Next use: \PGLSpl{sample}, \PGLSpl{svm}.

\printglossary[style=plist]

\printacronyms
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-prefix.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample-si.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}
\usepackage{siunitx}
\usepackage[style=long4col]{glossaries}
%
\makeglossaries
%
\newglossaryentry{ohm}{%
  name=ohm,
  symbol={\si{\ohm}},
  description=unit of electrical resistance%
}
%
\begin{document}
\glsaddallunused
%
\printglossaries
\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sample-si.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sample.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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 the glossaries 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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass[a4paper]{article}

\usepackage[margin=0.5in]{geometry}
\usepackage{booktabs}
\usepackage[acronym]{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}

\newcommand*{\samplerow}[1]{%
  \gls{#1} & \gls{#1} & \acrshort{#1} & \acrlong{#1}\\
 \glsreset{#1}\Gls{#1} & \Gls{#1} & \Acrshort{#1} & \Acrlong{#1}\\
 \glsreset{#1}\GLS{#1} & \GLS{#1} & \ACRshort{#1} & \ACRlong{#1}\\
}

\begin{document}

\begin{center}
\begin{tabular}{lllll}
\toprule
\bfseries First & \bfseries Next & \bfseries Short & \bfseries Long
\\\midrule
\samplerow{dr}
\midrule
\samplerow{eg}
\midrule
\samplerow{svm}
\bottomrule
\end{tabular}
\end{center}


\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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\documentclass[a4paper]{report}

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

\makeglossaries

 % Set the acronym style
\setacronymstyle{long-sc-short}

\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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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
           ]{glossaries}

\makeglossaries

% Change the acronym style to long-sc-short-desc:
\setacronymstyle{long-sc-short-desc}

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

% 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\ (but beware, converting the initial letter to
upper case for a small caps acronym is sometimes considered 
poor style).

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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\documentclass{article}

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

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

\makeglossaries

 % Use long (short) acronym style:
\setacronymstyle{long-short}

 % 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}
%<*sampleCustomAcr.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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
           ]{glossaries}

\makeglossaries

 % Define a new acronym style called "altfn" that's based on the
 % footnote-sc-desc style

\newacronymstyle
 {altfn}% style name
 {% Inherit display style from "footnote-sc-desc"
   \GlsUseAcrEntryDispStyle{footnote-sc-desc}%
 }%
 {% Inherit definitions from "footnote-sc-desc"
    \GlsUseAcrStyleDefs{footnote-sc-desc}%
 % Modify the first use display styles so they put the long form
 % followed by the description in the footnote:
 %
 % First use of \gls:
  \renewcommand*{\genacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshort{##1}}##2%
   \protect\footnote{\glsentrylong{##1}: \glsentrydesc{##1}}%
  }%
 % First use of \Gls:
  \renewcommand*{\Genacrfullformat}[2]{%
   \firstacronymfont{\Glsentryshort{##1}}##2%
   \protect\footnote{\glsentrylong{##1}: \glsentrydesc{##1}}%
  }%
 % First use of \glspl:
  \renewcommand*{\genplacrfullformat}[2]{%
   \protect\firstacronymfont{\glsentryshortpl{##1}}##2%
   \protect\footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}%
  }%
 % First use of \Glspl:
  \renewcommand*{\Genplacrfullformat}[2]{%
   \protect\firstacronymfont{\Glsentryshortpl{##1}}##2%
   \protect\footnote{\glsentrylongpl{##1}: \glsentrydesc{##1}}%
  }%
 % Sort according to long form:
  \renewcommand*{\acronymsort}[2]{##2}%
 % Set the name (as displayed in the glossary) to long (short)
  \renewcommand*{\acronymentry}[1]{%
     \glsentrylong{##1} (\acronymfont{\glsentryshort{##1}})}%
 % Since bold small caps isn't supported with this document's
 % fonts, adjust \acronymfont so that it switches to medium
 % small caps:
  \renewcommand{\acronymfont}[1]{\textmd{\scshape ##1}}%
 }

% Now use this new style:
\setacronymstyle{altfn}

% Change the "see" items so that they use \acronymfont:
\renewcommand*{\glsseeitemformat}[1]{\acronymfont{\glsentrytext{#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\ (but beware, converting the initial letter to
upper case for a small caps acronym is sometimes considered 
poor style).

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
(Reset all.)
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}
%</sampleCustomAcr.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleDB.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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
 %
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\documentclass[a4paper]{report}

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

\usepackage[style=altlist, % use altlist style
            toc % add the glossary to the table of contents
           ]{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
description={Statistical pattern recognition
technique~\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[xindy,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=gamma1}

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

\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)
 %
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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}
%<*sampleFnAcrDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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
           ]{glossaries}

\makeglossaries

 % Change the acronym style to a small-caps footnote style:
\setacronymstyle{footnote-sc-desc}

 % Make some minor adjustments to the style:
\renewcommand*{\acronymsort}[2]{#1}% sort by short form
\renewcommand*{\acronymentry}[1]{%
  \acronymfont{\glsentryshort{#1}}\space (\glsentrylong{#1})}

 % Not using a font that supports bold smallcaps so ensure
 % the acronym is always in medium weight.
\renewcommand*{\acronymfont}[1]{\textmd{\scshape #1}}

 % Change the "see" items so that they use \acronymfont:
\renewcommand*{\glsseeitemformat}[1]{\acronymfont{\glsentrytext{#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\ (but beware, converting the initial letter to
upper case for a small caps acronym is sometimes considered 
poor style).

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}
%</sampleFnAcrDesc.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleNtn.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\documentclass{report}

 % If you want to add babel to this document, you may have to
 % replace the : character in the labels if you are using a 
 % language setting (e.g. french) that makes : active.

\usepackage[plainpages=false,colorlinks]{hyperref}
\usepackage{html}
\usepackage[toc,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}
%<*samplePeople.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you are using arara, you need the following directives:
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\documentclass{report}

\usepackage[colorlinks]{hyperref}
\usepackage[toc,style=listgroup]{glossaries}

\makeglossaries

\newcommand{\sortname}[2]{#2, #1}
\newcommand{\textname}[2]{#1 #2}

 % Syntax: \name{first name}{surname}
 \let\name\textname

\renewcommand{\glsprestandardsort}[3]{%
 \let\name\sortname
 \edef#1{\expandafter\expandonce\expandafter{#1}}%
 \let\name\textname
 \glsdosanitizesort
}

\newglossaryentry{joebloggs}{name={\name{Joe}{Bloggs}},description={\nopostdesc}}

\newglossaryentry{johnsmith}{name={\name{John}{Smith}},description={\nopostdesc}}

\newglossaryentry{zoeadams}{name={\name{Zo\'e}{Adams}},description={\nopostdesc}}

\newglossaryentry{maryadams}{name={\name{Mary}{Adams}},description={\nopostdesc}}

\begin{document}
\tableofcontents

\chapter{\glsentrytext{joebloggs}}

\gls{joebloggs} was a fairly ordinary person.

\chapter{\glsentrytext{johnsmith}}

\gls{johnsmith} was great friends with \gls{joebloggs}.

\chapter{\glsentrytext{maryadams}}

\gls{maryadams} worked with \gls{johnsmith} but never met
\gls{joebloggs}.

\chapter{\glsentrytext{zoeadams}}

\gls{zoeadams} was \gls{maryadams}['s] sister.
\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</samplePeople.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampleSec.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\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}
%<*sampleSort.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
 % arara: pdflatex: { synctex: on }
\documentclass{report}

 % If you want to add babel to this document, you may have to
 % replace the : character in the labels if you are using a 
 % language setting (e.g. french) that makes : active.

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

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

\makeglossaries

\newcounter{sortcount}

\renewcommand{\glsprestandardsort}[3]{%
  \ifdefstring{#2}{notation}%
  {%
     \stepcounter{sortcount}%
     \edef#1{\glssortnumberfmt{\arabic{sortcount}}}%
  }%
  {%
     \glsdosanitizesort
  }%
}

 % Notation definitions

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

\newglossaryentry{not:emptyset}{type=notation,
name={$\emptyset$},
text={\emptyset},
description={The empty set}}

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

 % 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}}

 % Acronym definitions

\newacronym{zfc}{ZFC}{Zermelo-Fraenkel set theory}

\newacronym{ad}{AD}{axiom of determinacy}

\newacronym{nf}{NF}{new foundations}

\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, list of acronyms and index of notation.
\end{abstract}


\pagenumbering{roman}
\tableofcontents

\printglossaries

\chapter{Introduction}
\pagenumbering{arabic}

\Glspl{gls:set} are denoted by a calligraphic font 
e.g.\ $\gls{not:set}$.

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

Here are some acronyms: \gls{nf}, \gls{zfc} and \gls{ad}.

\chapter{Another Chapter}

Another mention of the empty set $\gls{not:emptyset}$.

Here are the acronyms again: \gls{nf}, \gls{zfc} and \gls{ad}.

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleSort.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*sampletree.tex>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
 % This file is public domain
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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},
plural={{œ}sophagi},
description={canal from mouth to stomach}}

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

\begin{document}
\glsaddall

\printglossaries

\end{document}
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%</sampleutf8.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
 % 
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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
 %
 % If you want to use arara, you need the following directives:
 % arara: pdflatex: { synctex: on }
 % arara: makeglossaries
 % arara: pdflatex: { synctex: on }
\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}
This example document has an eccentric section numbering system
where the section number is prefixed by the chapter number in square
brackets.

\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,$shortplural,$longplural);

   ($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);

   ($longplural,$opt) = &get_keyval('longplural', $opt);
   ($shortplural,$opt) = &get_keyval('shortplural', $opt);

   $longplural = $long.'s' unless ($longplural);
   $shortplural = $abbrv.'s' unless ($shortplural);

   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$shortplural$OP$id$CP,";
   $id = ++$global{'max_id'};
   $entry .= "firstplural=$OP$id$CP$longplural ($shortplural)$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
