%\iffalse
% glossaries-extra.dtx generated using makedtx version 1.1 (c) Nicola Talbot
% Command line args:
%   -author "Nicola Talbot"
%   -doc "glossaries-extra-codedoc.tex"
%   -section "chapter"
%   -codetitle "Main Package Code (\\styfmt{glossaries-extra.sty})"
%   -src "glossaries-extra.sty\Z=>glossaries-extra.sty"
%   -src "glossaries-extra-stylemods.sty\Z=>glossaries-extra-stylemods.sty"
%   glossaries-extra
% Created on 2016/12/17 13:01
%\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) 2016 Nicola Talbot, all rights reserved.
% \fi
% \iffalse
%<*driver>
\documentclass[report,widecs]{nlctdoc}

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

\usepackage{alltt}
\usepackage{pifont}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[colorlinks,
            bookmarks,
            hyperindex=false,
            pdfauthor={Nicola L.C. Talbot},
            pdftitle={glossaries-extra.sty: an extension to the glossaries
package},
            pdfkeywords={LaTeX,package,glossary,abbreviations}]{hyperref}
\usepackage[nonumberlist,nopostdot=false]{glossaries-extra}

\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}.
  \glsadd{firstuseflag}\glsadd{firstusetext}%
  \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{Counter}{counter}{glossary counters}
\doxitem{AbbrvStyle}{abbrvstyle}{abbreviation styles}

\setcounter{IndexColumns}{2}

\CheckSum{10014}

\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\sffamily#1}|main}}

\newcommand*{\acrstyle}[1]{\textsf{#1}\index{acronym
styles (glossaries):>#1={\protect\ttfamily#1}|main}}

\newcommand*{\abbrstyle}[1]{\textsf{#1}\index{abbreviation styles:>#1={\protect\sffamily#1}|main}}

\newcommand*{\category}[1]{\textsf{#1}\index{entry categories:>#1={\protect\sffamily#1}|main}}

\newcommand*{\catattr}[1]{\textsf{#1}\index{category attributes:>#1={\protect\sffamily#1}|main}}

\GlossaryPrologue{%
 \chapter*{{Change History}}%
 \markboth{{Change History}}{{Change History}}%
 \phantomsection
 \addcontentsline{toc}{chapter}{Change History}%
 \raggedright
}

\title{glossaries-extra.sty v1.10:
 documented code}
\author{Nicola L.C. Talbot\\[10pt]
Dickimaw Books\\
\url{http://www.dickimaw-books.com/}}

\date{2016-12-17}

\begin{document}
\DocInput{glossaries-extra.dtx}
\end{document}
%</driver>
%\fi
%\MakeShortVerb{"}
%\DeleteShortVerb{\|}
%
% \maketitle
%
%\begin{abstract}
%This is the documented code for the \sty{glossaries-extra} package.
%See glossaries-extra-manual.pdf for the user manual.
%
%\begin{important}
%This package is experimental and not stable. It's provided for
%testing purposes only. Future versions may not be compatible with
%this version. Once it has stabilised I'll add it to CTAN, at which
%point compatibility with the first stable version will be
%maintained.
%\end{important}
%\end{abstract}
%
%\tableofcontents
%
%\StopEventually{%
%  \printglossaries
%  \PrintChanges
%  \PrintIndex
%}
%
%
%
%\chapter{Main Package Code (\styfmt{glossaries-extra.sty})}
%\iffalse
%    \begin{macrocode}
%<*glossaries-extra.sty>
%    \end{macrocode}
%\fi
%\changes{0.1}{2015-11-22}{Initial experimental release}
%\section{Package Initialisation and Options}
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-extra}[2016/12/17 v1.10 (NLCT)]
%    \end{macrocode}
% Requires \sty{xkeyval} to define package options.
%    \begin{macrocode}
\RequirePackage{xkeyval}
%    \end{macrocode}
% Requires \sty{etoolbox} package.
%    \begin{macrocode}
\RequirePackage{etoolbox}
%    \end{macrocode}
% Has \styfmt{glossaries} already been loaded?
%    \begin{macrocode}
\@ifpackageloaded{glossaries}
{%
%    \end{macrocode}
% Already loaded so pass any options to \cs{setupglossaries}.
% This means that the options that can only be set when
% \styfmt{glossaries} is loaded can't be used.
%    \begin{macrocode}
   \newcommand{\glsxtr@dooption}[1]{\setupglossaries{#1}}%
   \let\@glsxtr@declareoption\@gls@declareoption
}
{%
%    \end{macrocode}
% Not already loaded, so pass options to \styfmt{glossaries}.
%    \begin{macrocode}
   \newcommand{\glsxtr@dooption}[1]{%
     \PassOptionsToPackage{#1}{glossaries}%
   }%
%    \end{macrocode}
% Set the defaults.
%    \begin{macrocode}
   \PassOptionsToPackage{toc}{glossaries}
   \PassOptionsToPackage{nopostdot}{glossaries}
   \PassOptionsToPackage{noredefwarn}{glossaries}
   \@ifpackageloaded{polyglossia}%
   {}%
   {%
     \@ifpackageloaded{babel}%
     {\PassOptionsToPackage{translate=babel}{glossaries}}%
     {}%
   }%
   \newcommand*{\@glsxtr@declareoption}[2]{%
     \DeclareOptionX{#1}{#2}%
     \DeclareOption{#1}{#2}%
   }
}
%    \end{macrocode}
% Declare package options.
%\begin{macro}{\glsxtrundefaction}
% Determines what to do if an entry hasn't been defined.
% The two arguments are the error or warning message and the help
% message if an error should be produced.
%    \begin{macrocode}
\newcommand*{\glsxtrundefaction}[2]{%
  \@glsxtrundeftag\PackageError{glossaries-extra}{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtr@warnonexistsordo}
% If user wants \pkgopt[warn]{undefaction}, then \styfmt{glossaries}
% v4.19 is required.
%    \begin{macrocode}
\newcommand*{\glsxtr@warnonexistsordo}[1]{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrundeftag}
% Text to display when an entry doesn't exist.
%    \begin{macrocode}
\newcommand*{\glsxtrundeftag}{??}
\newcommand*{\@glsxtrundeftag}{}
%    \end{macrocode}
% This text is switched on at the start of the document to prevent
% unwanted text inserted into the preamble if any tests are made
% before the start of the document.
%\end{macro}
%
%\begin{macro}{\@glsxtr@warn@undefaction}
%This is how \cs{glsxtrundefaction} should behave if
%\pkgopt[warn]{undefaction} is set.
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@warn@undefaction}[2]{%
  \@glsxtrundeftag\GlossariesExtraWarning{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@err@undefaction}
%This is how \cs{glsxtrundefaction} should behave if
%\pkgopt[error]{undefaction} is set.
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@err@undefaction}[2]{%
  \@glsxtrundeftag\PackageError{glossaries-extra}{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@warn@onexistsordo}
%This is how \cs{glsxtr@warnonexistsordo} should behave if
%\pkgopt[warn]{undefaction} is set.
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@warn@onexistsordo}[1]{%
  \GlossariesExtraWarning{glossaries-extra}{%
  \string#1\space hasn't been defined, so
  some errors won't be converted to warnings. 
  (This most likely means your version of
  glossaries.sty is below version 4.19.)}%
}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\define@choicekey{glossaries-extra.sty}{undefaction}[\val\nr]%
 {warn,error}%
 {%
   \ifcase\nr\relax
     \let\glsxtrundefaction\@glsxtr@warn@undefaction
     \let\glsxtr@warnonexistsordo\@glsxtr@warn@onexistsordo
   \or
     \let\glsxtrundefaction\@glsxtr@err@undefaction
     \let\glsxtr@warnonexistsordo\@gobble
   \fi
 }
%    \end{macrocode}
%
%In the event that someone wants to develop a post-processor
%that needs to know what entries have been used in the document,
%v1.08 introduces the \pkgopt{record} option, which will write
%information to the aux file whenever an entry needs to be indexed.
%
%\begin{macro}{\@glsxtr@record}
%\changes{1.08}{2016-12-13}{new}
%Does nothing by default.
%    \begin{macrocode}
\newcommand*{\@glsxtr@record}[2]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@glsxtr@record}
%\changes{1.08}{2016-12-13}{new}
%This is the actual code that does the recording
%The first argument is the option list (as passed in the first optional
%argument to commands like \cs{gls}). This allows the \gloskey[glslink]{noindex}
%setting to be picked up.
%    \begin{macrocode}
\newcommand*{\@@glsxtr@record}[2]{%
 \begingroup
   \def\@glsnumberformat{glsnumberformat}%
   \ifcsdef{glo@#2@counter}%
   {%
     \edef\@gls@counter{\csname glo@#2@counter\endcsname}%
   }%
   {%
%    \end{macrocode}
%Entry hasn't been defined, so we'll have to assume the page number by
%default.
%    \begin{macrocode}
     \def\@gls@counter{page}%
   }%
   \setkeys{glslink}{#1}%
   \ifKV@glslink@noindex
   \else
     \glswriteentry{#2}%
     {%
%    \end{macrocode}
%Save the entry counter.
%    \begin{macrocode}
       \glsxtr@saveentrycounter
%    \end{macrocode}
%Temporarily redefine \cs{@@do@@wrglossary} so we can use
%\cs{glsxtr@@do@wrglossary}.
%    \begin{macrocode}
       \let\@@do@@wrglossary\@glsxtr@dorecord
       \glsxtr@@do@wrglossary{#2}%
     }%
   \fi
 \endgroup
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@dorecord}
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*\@glsxtr@dorecord{%
   \protected@write\@auxout{}{\string\glsxtr@record
      {\@gls@label}{\@glo@counterprefix}{\@gls@counter}{\@glsnumberformat}%
      {\@glslocref}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@record}
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\glsxtr@record}[5]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@setup@record}
%\changes{1.08}{2016-12-13}{new}
%Initialise.
%    \begin{macrocode}
\newcommand*{\glsxtr@setup@record}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@indexonly@saveentrycounter}
%\changes{1.08}{2016-12-13}{new}
% Only store the entry counter information if the
%indexing is on.
%    \begin{macrocode}
\newcommand*{\glsxtr@indexonly@saveentrycounter}{%
 \ifKV@glslink@noindex
 \else
   \glsxtr@saveentrycounter
 \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@addloclistfield}
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\glsxtr@addloclistfield}{%
 \key@ifundefined{glossentry}{loclist}%
 {%
   \define@key{glossentry}{loclist}{\def\@glo@loclist{##1}}%
   \appto\@gls@keymap{,{loclist}{loclist}}%
   \appto\@newglossaryentryprehook{\def\@glo@loclist{}}%
   \appto\@newglossaryentryposthook{%
     \gls@assign@field{}{\@glo@label}{loclist}{\@glo@loclist}%
   }%
 }%
 {}%
}
%    \end{macrocode}
%\end{macro}
%
%Now define the \pkgopt{record} package option.
%\changes{1.08}{2016-12-13}{added \pkgopt{record} package option}
%    \begin{macrocode}
\define@choicekey{glossaries-extra.sty}{record}[\val\nr]%
 {off,only,alsoindex}%
 [only]%
 {%
   \ifcase\nr\relax
%    \end{macrocode}
%Don't record.
%    \begin{macrocode}
     \def\glsxtr@setup@record{%
       \renewcommand*{\@glsxtr@record}[2]{}%
       \let\@@do@wrglossary\glsxtr@@do@wrglossary
       \let\@gls@saveentrycounter\glsxtr@indexonly@saveentrycounter
       \let\glsxtrundefaction\@glsxtr@err@undefaction
       \let\glsxtr@warnonexistsordo\@gobble
     }%
   \or
%    \end{macrocode}
%Only record (don't index).
%    \begin{macrocode}
     \def\glsxtr@setup@record{%
       \let\@glsxtr@record\@@glsxtr@record
       \let\@@do@wrglossary\@gobble
       \let\@gls@saveentrycounter\relax
       \let\glsxtrundefaction\@glsxtr@warn@undefaction
       \let\glsxtr@warnonexistsordo\@glsxtr@warn@onexistsordo
       \glsxtr@addloclistfield
     }%
   \or
%    \end{macrocode}
%Record and index.
%    \begin{macrocode}
     \def\glsxtr@setup@record{%
       \let\@glsxtr@record\@@glsxtr@record
       \let\@@do@wrglossary\glsxtr@@do@wrglossary
       \let\@gls@saveentrycounter\glsxtr@indexonly@saveentrycounter
       \let\glsxtrundefaction\@glsxtr@warn@undefaction
       \let\glsxtr@warnonexistsordo\@glsxtr@warn@onexistsordo
       \glsxtr@addloclistfield
     }%
   \fi
 }
%    \end{macrocode}
%
%\changes{1.06}{2016-06-18}{docdef option changed to choice}
%Version 1.06 changes the \pkgopt{docdef} option to a choice rather
%than boolean setting. The available values are: false, true or
%restricted. The restricted option permits document definitions as
%long as they occur before the first glossary is displayed.
%
%\begin{macro}{\@glsxtr@docdefval}
%\changes{1.06}{2016-06-18}{new}
%The \pkgopt{docdef} value is stored as an integer: 0 (false), 1
%(true) and 2 (restricted).
%    \begin{macrocode}
\newcount\@glsxtr@docdefval
%    \end{macrocode}
%\end{macro}
%
%Need to provide conditional commands that are backward compatible:
%\begin{macro}{\if@glsxtrdocdef}
%    \begin{macrocode}
\newcommand*{\if@glsxtrdocdef}{\ifnum\@glsxtr@docdefval>0 }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtrdocdeftrue}
%    \begin{macrocode}
\newcommand*{\@glsxtrdocdeftrue}{\@glsxtr@docdefval=1 }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtrdocdeffalse}
%    \begin{macrocode}
\newcommand*{\@glsxtrdocdeffalse}{\@glsxtr@docdefval=0 }
%    \end{macrocode}
%\end{macro}
%
%
% By default don't allow entries to be defined in the document to
% encourage the user to define them in the preamble, but if the user
% is really determined to define them in the document allow them to
% request this.
%    \begin{macrocode}
\define@choicekey{glossaries-extra.sty}{docdef}[\val\nr]%
 {false,true,restricted}[true]%
{%
  \@glsxtr@docdefval=\nr\relax
  \ifnum\@glsxtr@docdefval=2\relax
    \renewcommand*{\@glsdoifexistsorwarn}{\glsdoifexists}%
  \fi
}
%    \end{macrocode}
%\begin{macro}{\if@glsxtrdocdefrestricted}
%\changes{1.06}{2016-06-18}{new}
%    \begin{macrocode}
\newcommand*{\if@glsxtrdocdefrestricted}{\ifnum\@glsxtr@docdefval=2 }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdoifexistsorwarn}
%\changes{1.06}{2016-06-18}{new}
%Need an error to notify user if an undefined entry is being referenced in the
%glossary for the \pkgopt[restricted]{docdef} option. This is used
%by \cs{glossentryname} (but not by \cs{glossentrydesc} etc as one error
%per entry is sufficient).
%    \begin{macrocode}
\newcommand*{\@glsdoifexistsorwarn}{\glsdoifexistsorwarn}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{indexcrossrefs}
% Automatically index cross references at the end of the document
%    \begin{macrocode}
\define@boolkey{glossaries-extra.sty}[@glsxtr]{indexcrossrefs}[true]{%
 \if@glsxtrindexcrossrefs
 \else
  \renewcommand*{\@glsxtr@autoindexcrossrefs}{}%
 \fi
}
%    \end{macrocode}
%\end{option}
% Switch off since this can increase the build time.
%    \begin{macrocode}
\@glsxtrindexcrossrefsfalse
%    \end{macrocode}
% But allow \gloskey{see} key to switch it on automatically.
%\begin{macro}{\@glsxtr@autoindexcrossrefs}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindexcrossrefs}{\@glsxtrindexcrossrefstrue}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlossariesExtraWarning}
%Allow users to suppress warnings.
%    \begin{macrocode}
\newcommand*{\GlossariesExtraWarning}[1]{\PackageWarning{glossaries-extra}{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlossariesExtraWarningNoLine}
%Allow users to suppress warnings.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\GlossariesExtraWarningNoLine}[1]{%
 \PackageWarningNoLine{glossaries-extra}{#1}}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\@glsxtr@declareoption{nowarn}{%
  \let\GlossariesExtraWarning\@gobble
  \let\GlossariesExtraWarningNoLine\@gobble
  \glsxtr@dooption{nowarn}%
}
%    \end{macrocode}
%
%\begin{macro}{\glsxtrabbrvtype}
% Glossary type for abbreviations.
%    \begin{macrocode}
\newcommand*{\glsxtrabbrvtype}{\glsdefaulttype}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@abbreviationsdef}
% Set by \pkgopt{abbreviations} option.
%    \begin{macrocode}
\newcommand*{\@glsxtr@abbreviationsdef}{}
%    \end{macrocode}
%\end{macro}

%\begin{macro}{\@glsxtr@doabbreviationsdef}
%\changes{0.5.3}{2015-12-09}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@doabbreviationsdef}{%
  \@ifpackageloaded{babel}%
  {\providecommand{\abbreviationsname}{\acronymname}}%
  {\providecommand{\abbreviationsname}{Abbreviations}}%
  \newglossary[glg-abr]{abbreviations}{gls-abr}{glo-abr}{\abbreviationsname}%
  \renewcommand*{\glsxtrabbrvtype}{abbreviations}%
  \newcommand*{\printabbreviations}[1][]{%
    \printglossary[type=\glsxtrabbrvtype,##1]%
  }%
  \disable@keys{glossaries-extra.sty}{abbreviations}%
%    \end{macrocode}
% If the \pkgopt{acronym} option hasn't been used, change
% \ics{acronymtype} to \ics{glsxtrabbrvtype}.
%\changes{0.4}{2015-12-03}{added redefinition of \cs{acronymtype}}
%    \begin{macrocode}
  \ifglsacronym
  \else
    \renewcommand*{\acronymtype}{\glsxtrabbrvtype}%
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{abbreviations}
% If \pkgopt{abbreviations}, create a new glossary type for abbreviations.
%    \begin{macrocode}
\@glsxtr@declareoption{abbreviations}{%
  \let\@glsxtr@abbreviationsdef\@glsxtr@doabbreviationsdef
}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\GlsXtrDefineAbbreviationShortcuts}
% Enable shortcut commands for the abbreviations. Unlike the analogous
% command provided by \styfmt{glossaries}, this uses \cs{newcommand}
% instead of \cs{let} as a safety feature.
%    \begin{macrocode}
\newcommand*{\GlsXtrDefineAbbreviationShortcuts}{%
  \newcommand*{\ab}{\cgls}%
  \newcommand*{\abp}{\cglspl}%
  \newcommand*{\as}{\glsxtrshort}%
  \newcommand*{\asp}{\glsxtrshortpl}%
  \newcommand*{\al}{\glsxtrlong}%
  \newcommand*{\alp}{\glsxtrlongpl}%
  \newcommand*{\af}{\glsxtrfull}%
  \newcommand*{\afp}{\glsxtrfullpl}%
  \newcommand*{\Ab}{\cGls}%
  \newcommand*{\Abp}{\cGlspl}%
  \newcommand*{\As}{\Glsxtrshort}%
  \newcommand*{\Asp}{\Glsxtrshortpl}%
  \newcommand*{\Al}{\Glsxtrlong}%
  \newcommand*{\Alp}{\Glsxtrlongpl}%
  \newcommand*{\Af}{\Glsxtrfull}%
  \newcommand*{\Afp}{\Glsxtrfullpl}%
  \newcommand*{\AB}{\cGLS}%
  \newcommand*{\ABP}{\cGLSpl}%
  \newcommand*{\AS}{\GLSxtrshort}%
  \newcommand*{\ASP}{\GLSxtrshortpl}%
  \newcommand*{\AL}{\GLSxtrlong}%
  \newcommand*{\ALP}{\GLSxtrlongpl}%
  \newcommand*{\AF}{\GLSxtrfull}%
  \newcommand*{\AFP}{\GLSxtrfullpl}%
  \newcommand*{\newabbr}{\newabbreviation}%
%    \end{macrocode}
% Disable this command after it's been used.
%    \begin{macrocode}
  \let\GlsXtrDefineAbbreviationShortcuts\relax
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrDefineOtherShortcuts}
% Similarly provide shortcut versions for the commands provided by
% the \pkgopt{symbols} and \pkgopt{numbers} options.
%    \begin{macrocode}
\newcommand*{\GlsXtrDefineOtherShortcuts}{%
  \newcommand*{\newentry}{\newglossaryentry}%
  \ifdef\printsymbols
  {%
    \newcommand*{\newsym}{\glsxtrnewsymbol}%
  }{}%
  \ifdef\printnumbers
  {%
    \newcommand*{\newnum}{\glsxtrnewnumber}%
  }{}%
  \let\GlsXtrDefineOtherShortcuts\relax
}
%    \end{macrocode}
%\end{macro}
%
% Always use the long forms, not the shortcuts, where portablity is
% an issue. (For example, when defining entries in a file that may
% be input by multiple documents.)
%
%\begin{macro}{\@glsxtr@setupshortcuts}
% Command used to set the shortcuts option.
%    \begin{macrocode}
\newcommand*{\@glsxtr@setupshortcuts}{}
%    \end{macrocode}
%\end{macro}
%
%Provide \pkgopt{shortcuts} option. Unlike the \styfmt{glossaries}
%version, this is a choice rather than a boolean key but it also provides
%\pkgopt[true]{shortcuts} and \pkgopt[false]{shortcuts}, which are
%equivalent to \pkgopt[all]{shortcuts} and
%\pkgopt[none]{shortcuts}. Multiple use of this option in the
%\emph{same} option list will override each other.
%    \begin{macrocode}
\define@choicekey{glossaries-extra.sty}{shortcuts}[\val\nr]%
 {acronyms,acro,abbreviations,abbr,other,all,true,none,false}[true]{%
   \ifcase\nr\relax % acronyms
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \glsacrshortcutstrue
       \DefineAcronymSynonyms
     }%
   \or % acro
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \glsacrshortcutstrue
       \DefineAcronymSynonyms
     }%
   \or % abbreviations
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \GlsXtrDefineAbbreviationShortcuts
     }%
   \or % abbr
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \GlsXtrDefineAbbreviationShortcuts
     }%
   \or % other
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \GlsXtrDefineOtherShortcuts
     }%
   \or % all
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \glsacrshortcutstrue
       \DefineAcronymSynonyms
       \GlsXtrDefineAbbreviationShortcuts
       \GlsXtrDefineOtherShortcuts
     }%
   \or % true
     \renewcommand*{\@glsxtr@setupshortcuts}{%
       \glsacrshortcutstrue
       \DefineAcronymSynonyms
       \GlsXtrDefineAbbreviationShortcuts
       \GlsXtrDefineOtherShortcuts
     }%
   \else % none, false
     \renewcommand*{\@glsxtr@setupshortcuts}{}%
   \fi
 }
%    \end{macrocode}
%
%\begin{macro}{\@glsxtr@doaccsupp}
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@doaccsupp}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{accsupp}
% If \pkgopt{accsupp}, load \sty{glossaries-accsupp} package.
%    \begin{macrocode}
\@glsxtr@declareoption{accsupp}{%
 \renewcommand*{\@glsxtr@doaccsupp}{\RequirePackage{glossaries-accsupp}}}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\glsxtrNoGlossaryWarning}
%\changes{0.3}{2015-12-02}{new}
% Warning text displayed in document if the external glossary file
% given by the argument is missing.
%    \begin{macrocode}
\newcommand{\glsxtrNoGlossaryWarning}[1]{%
  \@glsxtr@defaultnoglossarywarning{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{nomissingglstext}
% If true, suppress the text produced if the external glossary file
% is missing.
%    \begin{macrocode}
\define@choicekey{glossaries-extra.sty}{nomissingglstext}[\val\nr]%
 {true,false}[true]{%
   \ifcase\nr\relax % true
     \renewcommand{\glsxtrNoGlossaryWarning}[1]{%
       \null
     }%
   \else % false
     \renewcommand{\glsxtrNoGlossaryWarning}[1]{%
       \@glsxtr@defaultnoglossarywarning{#1}%
     }%
   \fi
 }
%    \end{macrocode}
%\end{option}
%
% Provide option to load \sty{glossaries-extra-stylemods}
% (Deferred to the end.)
%\begin{macro}{\@glsxtr@redefstyles}
%    \begin{macrocode}
\newcommand*{\@glsxtr@redefstyles}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{stylemods}
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\define@key{glossaries-extra.sty}{stylemods}{%
  \ifblank{#1}%
  {%
    \renewcommand*{\@glsxtr@redefstyles}{%
      \RequirePackage{glossaries-extra-stylemods}}%
  }%
  {%
    \renewcommand*{\@glsxtr@redefstyles}{}%
    \@for\@glsxtr@tmp:=#1\do{%
      \IfFileExists{glossary-\@glsxtr@tmp.sty}%
      {%
        \eappto\@glsxtr@redefstyles{%
          \noexpand\RequirePackage{glossary-\@glsxtr@tmp}}%
      }%
      {%
         \PackageError{glossaries-extra}%
           {Glossaries style package `glossary-\@glsxtr@tmp.sty' 
            doesn't exist (did you mean to use the `style' key?)}%
           {The list of values (#1) in the `stylemods' key should
            match the glossary-xxx.sty files provided with
            glossaries.sty}%
      }%
    }%
    \appto\@glsxtr@redefstyles{\RequirePackage{glossaries-extra-stylemods}}%
  }%
}
%    \end{macrocode}
%\end{option}
%
%\begin{macro}{\@glsxtr@do@style}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@do@style}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{option}{style}
%\changes{1.04}{2016-05-02}{new}
% Since the \pkgopt{stylemods} option can automatically load extra
% style packages, deal with the \pkgopt{style} option after those
% packages have been loaded.
%    \begin{macrocode}
\define@key{glossaries-extra.sty}{style}{%
 \renewcommand*{\@glsxtr@do@style}{%
%    \end{macrocode}
% Set this as the default style:
%    \begin{macrocode}
   \setkeys{glossaries.sty}{style={#1}}%
%    \end{macrocode}
% Set this style:
%    \begin{macrocode}
   \setglossarystyle{#1}%
 }%
}
%    \end{macrocode}
%\end{option}
%
% Pass all other options to \styfmt{glossaries}.
%    \begin{macrocode}
\DeclareOptionX*{%
 \expandafter\glsxtr@dooption\expandafter{\CurrentOption}}
%    \end{macrocode}
% Process options.
%    \begin{macrocode}
\ProcessOptionsX
%    \end{macrocode}
% Load \styfmt{glossaries} if not already loaded.
%    \begin{macrocode}
\RequirePackage{glossaries}
%    \end{macrocode}
% Load the \sty{glossaries-accsupp} package if required.
%    \begin{macrocode}
\@glsxtr@doaccsupp
%    \end{macrocode}
%
% Define abbreviations glossaries if required.
%    \begin{macrocode}
\@glsxtr@abbreviationsdef
\let\@glsxtr@abbreviationsdef\relax
%    \end{macrocode}
% Setup shortcuts if required.
%    \begin{macrocode}
\@glsxtr@setupshortcuts
%    \end{macrocode}
%
%\begin{macro}{\glossariesextrasetup}
%Allow user to set options after the package has been loaded.
% First modify \cs{glsxtr@dooption} so that it now uses
% \cs{setupglossaries}:
%    \begin{macrocode}
\renewcommand{\glsxtr@dooption}[1]{\setupglossaries{#1}}%
%    \end{macrocode}
% Now define the user command:
%    \begin{macrocode}
\newcommand*{\glossariesextrasetup}[1]{%
  \let\glsxtr@setup@record\relax
  \let\@glsxtr@setupshortcuts\relax
  \setkeys{glossaries-extra.sty}{#1}%
  \@glsxtr@abbreviationsdef
  \let\@glsxtr@abbreviationsdef\relax
  \@glsxtr@setupshortcuts
  \glsxtr@setup@record
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@@do@wrglossary}
%\changes{1.08}{2016-12-13}{new}
%Save original definition of \cs{@@do@wrglossary}.
%    \begin{macrocode}
\let\glsxtr@@do@wrglossary\@@do@wrglossary
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@saveentrycounter}
%\changes{1.08}{2016-12-13}{new}
%Save original definition of \cs{@gls@saveentrycounter}.
%    \begin{macrocode}
\let\glsxtr@saveentrycounter\@gls@saveentrycounter
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@saveentrycounter}
%\changes{1.08}{2016-12-13}{new}
%Change \cs{@gls@saveentrycounter} so that it only stores the entry
%counter information if the indexing is on.
%    \begin{macrocode}
\let\@gls@saveentrycounter\glsxtr@indexonly@saveentrycounter
%    \end{macrocode}
%\end{macro}
%
%Set up record option if required.
%    \begin{macrocode}
\glsxtr@setup@record
%    \end{macrocode}
%
% Disable preamble-only options and switch on the undefined tag at
% the start of the document.
%\changes{1.06}{2016-06-18}{disabled docdef key at the start of the
%document}
%    \begin{macrocode}
\AtBeginDocument{%
  \disable@keys{glossaries-extra.sty}{abbreviations,docdef,record}%
  \def\@glsxtrundeftag{\glsxtrundeftag}%
}
%    \end{macrocode}
%
%\section{Extra Utilities}
%\begin{macro}{\glsxtrifemptyglossary}
%\begin{definition}
%\cs{glsxtrifemptyglossary}\marg{type}\marg{true}\marg{false}
%\end{definition}
% Provide command to determine if any entries have been added to the
% glossary (where the glossary label is provided in the first
% argument). The entries are stored in the comma-separated list
% \cs{glolist@\meta{type}}. If this hasn't been defined, the glosary
% doesn't exist. If it has been defined and is simply a comma, the
% glossary exists and is empty. (It's initialised to a comma.)
%\changes{0.4}{2015-12-03}{new}
%    \begin{macrocode}
\newcommand{\glsxtrifemptyglossary}[3]{%
  \ifglossaryexists{#1}%
  {%
    \ifcsstring{glolist@#1}{,}{#2}{#3}%
  }%
  {%
    \glsxtrundefaction{Glossary type `#1' doesn't exist}{}%
    #2%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\section{Modifications to Commands Provided by \styfmt{glossaries}}
% Some of the commands provided by \styfmt{glossaries} are modified
% to take into account new options or to change default behaviour.
%
%\subsection{Existence Checks}
%\begin{macro}{\glsdoifexists}
% Modify \cs{glsdoifexists} to take account of the
% \pkgopt{undefaction} setting.
%    \begin{macrocode}
\renewcommand{\glsdoifexists}[2]{%
  \ifglsentryexists{#1}{#2}%
  {%
%    \end{macrocode}
% Define \cs{glslabel} in case it's needed after this command (for
% example in the post-link hook).
%\changes{1.08}{2016-12-13}{now defines \cs{glslabel}}
%    \begin{macrocode}
    \edef\glslabel{\glsdetoklabel{#1}}%
    \glsxtrundefaction{Glossary entry `\glslabel'
    has not been defined}{You need to define a glossary entry before
    you can reference it.}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdoifnoexists}
% Modify \cs{glsdoifnoexists} to take account of the
% \pkgopt{undefaction} setting.
%    \begin{macrocode}
\renewcommand{\glsdoifnoexists}[2]{%
   \ifglsentryexists{#1}{%
    \glsxtrundefaction{Glossary entry `\glsdetoklabel{#1}'
    has already been defined}{}}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdoifexistsordo}
% Modify \cs{glsdoifexistsordo} to take account of the
% \pkgopt{undefaction} setting. This command was introduced in 
% \styfmt{glossaries} version 4.19, so check if it has been defined first.
%    \begin{macrocode}
\ifdef\glsdoifexistsordo
{%
  \renewcommand{\glsdoifexistsordo}[3]{%
    \ifglsentryexists{#1}{#2}%
    {%
      \glsxtrundefaction{Glossary entry `\glsdetoklabel{#1}'
      has not been defined}{You need to define a glossary entry 
      before you can use it.}%
      #3%
    }%
  }%
}
{%
  \glsxtr@warnonexistsordo\glsdoifexistsordo
  \newcommand{\glsdoifexistsordo}[3]{%
    \ifglsentryexists{#1}{#2}%
    {%
      \glsxtrundefaction{Glossary entry `\glsdetoklabel{#1}'
      has not been defined}{You need to define a glossary entry 
      before you can use it.}%
      #3%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\doifglossarynoexistsordo}
% Similarly for \cs{doifglossarynoexistsordo}.
%    \begin{macrocode}
\ifdef\doifglossarynoexistsordo
{%
  \renewcommand{\doifglossarynoexistsordo}[3]{%
    \ifglossaryexists{#1}%
    {%
      \glsxtrundefaction{Glossary type `#1' already exists}{}%
      #3%
    }%
    {#2}%
  }%
}
{%
  \glsxtr@warnonexistsordo\doifglossarynoexistsordo
  \newcommand{\doifglossarynoexistsordo}[3]{%
    \ifglossaryexists{#1}%
    {%
      \glsxtrundefaction{Glossary type `#1' already exists}{}%
      #3%
    }%
    {#2}%
  }%
}

%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@newglossaryentryposthook}
% Hook into end of \cs{newglossaryentry} to add \qt{see} value as a
% field.
%\changes{0.5.4}{2015-12-15}{added empty see value if not set and added
% `see' to field key map}
%    \begin{macrocode}
\appto\@newglossaryentryposthook{%
  \ifdefvoid\@glo@see
   {\csxdef{glo@\@glo@label @see}{}}%
   {%
     \csxdef{glo@\@glo@label @see}{\@glo@see}%
     \@glsxtr@autoindexcrossrefs
   }%
}
\appto\@gls@keymap{,{see}{see}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrusesee}
%\changes{1.06}{2016-06-18}{new}
%Apply \cs{glsseeformat} to the \gloskey{see} key if not empty.
%    \begin{macrocode}
\newcommand*{\glsxtrusesee}[1]{%
  \glsdoifexists{#1}%
  {%
    \letcs{\@glo@see}{glo@\glsdetoklabel{#1}@see}%
    \ifdefempty\@glo@see
    {}%
    {%
      \expandafter\glsxtr@usesee\@glo@see\@end@glsxtr@usesee
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@usesee}
%\changes{1.06}{2016-06-18}{new}
%    \begin{macrocode}
\newcommand*{\glsxtr@usesee}[1][\seename]{%
  \@glsxtr@usesee[#1]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@usesee}
%\changes{1.06}{2016-06-18}{new}
%    \begin{macrocode}
\def\@glsxtr@usesee[#1]#2\@end@glsxtr@usesee{%
  \glsxtruseseeformat{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtruseseeformat}
%\changes{1.06}{2016-06-18}{new}
%The format used by \cs{glsxtrusesee}. The first argument is the tag
%(such as \cs{seename}). The second argument is the comma-separated
%list of cross-referenced labels.
%    \begin{macrocode}
\newcommand*{\glsxtruseseeformat}[2]{%
  \glsseeformat[#1]{#2}{}%
}
%    \end{macrocode}
%\end{macro}
%
% Add all unused cross-references at the end of the document.
%    \begin{macrocode}
\AtEndDocument{\if@glsxtrindexcrossrefs\glsxtraddallcrossrefs\fi}
%    \end{macrocode}
%
%\begin{macro}{\glsxtraddallcrossrefs}
% Iterate through all used entries and if they have a
% cross-reference, make sure the cross-reference has been added.
%    \begin{macrocode}
\newcommand*{\glsxtraddallcrossrefs}{%
  \forallglossaries{\@glo@type}%
  {%
     \forglsentries[\@glo@type]{\@glo@label}%
     {%
       \ifglsused{\@glo@label}{\@glsxtr@addunusedxrefs{\@glo@label}}{}%
     }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@addunusedxrefs}
% If the given entry has a see field add all unused
% cross-references.
%    \begin{macrocode}
\newcommand*{\@glsxtr@addunusedxrefs}[1]{%
  \letcs{\@glo@see}{glo@\glsdetoklabel{#1}@see}%
  \ifdefvoid\@glo@see
  {}%
  {%
    \expandafter\glsxtr@addunused\@glo@see\@end@glsxtr@addunused
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@addunused}
% Adds all the entries if they haven't been used.
%    \begin{macrocode}
\newcommand*{\glsxtr@addunused}[1][]{%
  \@glsxtr@addunused
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@addunused}
% Adds all the entries if they haven't been used.
%    \begin{macrocode}
\def\@glsxtr@addunused#1\@end@glsxtr@addunused{%
 \@for\@glsxtr@label:=#1\do
 {%
   \ifglsused{\@glsxtr@label}{}%
   {%
     \glsadd[format=glsxtrunusedformat]{\@glsxtr@label}%
     \glsunset{\@glsxtr@label}%
     \@glsxtr@addunusedxrefs{\@glsxtr@label}%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrunusedformat}
%    \begin{macrocode}
\newcommand*{\glsxtrunusedformat}[1]{\unskip}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Document Definitions}
%
%\begin{macro}{\makenoidxglossaries}
%Modify \cs{makenoidxglossaries} so that it automatically switches
%off (unless the restricted setting is on) and disables the \pkgopt{docdef} key.
%    \begin{macrocode}
\let\glsxtr@orgmakenoidxglossaries\makenoidxglossaries
\renewcommand{\makenoidxglossaries}{%
  \glsxtr@orgmakenoidxglossaries
  \if@glsxtrdocdefrestricted
%    \end{macrocode}
%If restricted document definitions allowed, adjust
%\cs{@gls@reference} so that it doesn't test for existence.
%    \begin{macrocode}
    \renewcommand*{\@gls@reference}[3]{%
      \ifcsundef{@glsref@##1}{\csgdef{@glsref@##1}{}}{}%
      \ifinlistcs{##2}{@glsref@##1}%
      {}%
      {\listcsgadd{@glsref@##1}{##2}}%
      \ifcsundef{glo@\glsdetoklabel{##2}@loclist}%
      {\csgdef{glo@\glsdetoklabel{##2}@loclist}{}}%
      {}%
      \listcsgadd{glo@\glsdetoklabel{##2}@loclist}{##3}%
    }%
  \else
%    \end{macrocode}
%Disable document definitions.
%    \begin{macrocode}
    \@glsxtrdocdeffalse
  \fi
  \disable@keys{glossaries-extra.sty}{docdef}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\gls@defdocnewglossaryentry}
% Modify \cs{gls@defdocnewglossaryentry} so that it checks
% the \pkgopt{docdef} value.
%    \begin{macrocode}
\renewcommand*{\gls@defdocnewglossaryentry}{%
  \ifcase\@glsxtr@docdefval
%    \end{macrocode}
% \pkgopt[false]{docdef}:
%    \begin{macrocode}
    \renewcommand*{\newglossaryentry}[2]{%
      \PackageError{glossaries-extra}{Glossary entries must
       be \MessageBreak defined in the preamble with \MessageBreak
       package option `docdef=false'\MessageBreak(consider using
       `docdef=restricted')}{Move your glossary definitions to
       the preamble. You can also put them in a \MessageBreak separate file
       and load them with \string\loadglsentries.}%
    }%
  \or
%    \end{macrocode}
% \pkgopt[true]{docdef}
% Since the \gloskey{see} value is now saved in a field, it
% can be used by entries that have been defined in the document.
%    \begin{macrocode}
    \let\gls@checkseeallowed\relax
    \let\newglossaryentry\new@glossaryentry
  \or
%    \end{macrocode}
%Restricted mode just needs to allow the \gloskey{see} value.
%    \begin{macrocode}
    \let\gls@checkseeallowed\relax
  \fi
}%
%    \end{macrocode}
%\end{macro}
%
% Permit a special form of document definition, but only allow
% it if the glossaries come at the end of the document. These
% commands behave a little like a combination of \cs{newterm}
% and \cs{gls}. This must be explicitly enabled with
% the following.
%
%\begin{macro}{\GlsXtrEnableOnTheFly}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrEnableOnTheFly}{%
  \@ifstar\@sGlsXtrEnableOnTheFly\@GlsXtrEnableOnTheFly
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@sGlsXtrEnableOnTheFly}
%\changes{0.5.4}{2015-12-15}{new}
% The starred version attempts to allow UTF8 characters in the
% label, but this may break! (Formatting commands mustn't be used in the 
% label, but the label may be a command whose replacement text is the
% actual label. This doesn't take into account a command that's
% defined in terms of another command that may eventually expand to
% the label text.)
%    \begin{macrocode}
\newcommand*{\@sGlsXtrEnableOnTheFly}{%
  \renewcommand*{\glsdetoklabel}[1]{%
    \expandafter\@glsxtr@ifcsstart\string##1 \@glsxtr@end@
    {%
      \expandafter\detokenize\expandafter{##1}%
    }%
    {\detokenize{##1}}%
  }%
  \@GlsXtrEnableOnTheFly
}
\def\@glsxtr@ifcsstart#1#2\@glsxtr@end@#3#4{%
  \expandafter\if\glsbackslash#1%
    #3%
  \else
    #4%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrstarflywarn}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrstarflywarn}{%
  \GlossariesExtraWarning{Experimental starred version of
  \string\GlsXtrEnableOnTheFly\space in use (please ensure you have
  read the warnings in the glossaries-extra user manual)}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GlsXtrEnableOnTheFly}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@GlsXtrEnableOnTheFly}{%
%    \end{macrocode}
%\end{macro}
% Don't redefine \cs{glsdetoklabel} if LuaTeX or XeTeX is being
% used, since it's mainly to allow accented characters in the
% label.
%
% These definitions are all assigned the category given by:
%\begin{macro}{\glsxtrcat}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\glsxtrcat}{general}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\glsxtr}[1][]{%
   \def\glsxtr@keylist{##1}%
   \@glsxtr
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\@glsxtr}[2][]{%
   \ifglsentryexists{##2}%
   {%
     \ifblank{##1}{}{\GlsXtrWarning{##1}{##2}}%
   }%
   {%
     \gls@defglossaryentry{##2}{name={##2},category=\glsxtrcat,
       description={\nopostdesc},##1}%
   }%
   \expandafter\gls\expandafter[\glsxtr@keylist]{##2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtr}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\Glsxtr}[1][]{%
   \def\glsxtr@keylist{##1}%
   \@Glsxtr
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\@Glsxtr}[2][]{%
   \ifglsentryexists{##2}%
   {%
     \ifblank{##1}{}{\GlsXtrWarning{##1}{##2}}%
   }%
   {%
     \gls@defglossaryentry{##2}{name={##2},category=\glsxtrcat,
       description={\nopostdesc},##1}%
   }%
   \expandafter\Gls\expandafter[\glsxtr@keylist]{##2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpl}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\glsxtrpl}[1][]{%
   \def\glsxtr@keylist{##1}%
   \@glsxtrpl
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtrpl}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\@glsxtrpl}[2][]{%
   \ifglsentryexists{##2}%
   {%
     \ifblank{##1}{}{\GlsXtrWarning{##1}{##2}}%
   }%
   {%
     \gls@defglossaryentry{##2}{name={##2},category=\glsxtrcat,
       description={\nopostdesc},##1}%
   }%
   \expandafter\glspl\expandafter[\glsxtr@keylist]{##2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrpl}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\Glsxtrpl}[1][]{%
   \def\glsxtr@keylist{##1}%
   \@Glsxtrpl
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtrpl}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\@Glsxtrpl}[2][]{%
   \ifglsentryexists{##2}
   {%
     \ifblank{##1}{}{\GlsXtrWarning{##1}{##2}}%
   }%
   {%
     \gls@defglossaryentry{##2}{name={##2},category=\glsxtrcat,
       description={\nopostdesc},##1}%
   }%
   \expandafter\Glspl\expandafter[\glsxtr@keylist]{##2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrWarning}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
  \newcommand*{\GlsXtrWarning}[2]{%
    \def\@glsxtr@optlist{##1}%
    \@onelevel@sanitize\@glsxtr@optlist
    \GlossariesExtraWarning{The options `\@glsxtr@optlist' have 
    been ignored for entry `##2' as it has already been defined}%
  }
%    \end{macrocode}
%\end{macro}
% Disable commands after the glossary:
%    \begin{macrocode}
  \renewcommand\@printglossary[2]{%
    \def\@glsxtr@printglossopts{##1}%
    \@glsxtr@orgprintglossary{##1}{##2}%
    \def\@glsxtr{\@glsxtr@disabledflycommand\glsxtr}%
    \def\@glsxtrpl{\@glsxtr@disabledflycommand\glsxtrpl}%
    \def\@Glsxtr{\@glsxtr@disabledflycommand\Glsxtr}%
    \def\@Glsxtrpl{\@glsxtr@disabledflycommand\Glsxtrpl}%
  }
%    \end{macrocode}
%
%\begin{macro}{\@glsxtr@disabledflycommand}
%    \begin{macrocode}
  \newcommand*{\@glsxtr@disabledflycommand}[1]{%
    \PackageError{glossaries-extra}%
    {\string##1\space can't be used after any of the \MessageBreak
     glossaries have been displayed}%
    {The on-the-fly commands enabled by 
     \string\GlsXtrEnableOnTheFly\space may only be used \MessageBreak
     before the glossaries. If you want to use any entries \MessageBreak
     after any of the glossaries, you must use the standard \MessageBreak
     method of first defining the entry and then using the \MessageBreak
     entry with commands like \string\gls}%
     \@@glsxtr@disabledflycommand
  }%
  \newcommand*{\@@glsxtr@disabledflycommand}[2][]{##2}
%    \end{macrocode}
%\end{macro}
%
% End of \cs{GlsXtrEnableOnTheFly}. Disable since it can only
% be used once.
%    \begin{macrocode}
  \let\GlsXtrEnableOnTheFly\relax
}
\@onlypreamble\GlsXtrEnableOnTheFly
%    \end{macrocode}
%
%\subsection{Existing Glossary Style Modifications}
%
% Modify \cs{setglossarystyle} to keep track of the current style.
% This allows the \cs{glossaries-extra-stylemods} package to reset the
% current style after the required modifications have been made.
%\begin{macro}{\@glsxtr@current@style}
%\changes{1.02}{2016-04-25}{new}
% Initialise the current style to the default style.
%    \begin{macrocode}
\newcommand*{\@glsxtr@current@style}{\@glossary@default@style}
%    \end{macrocode}
%\end{macro}
% Modify \cs{setglossarystyle} to set the above.
%\begin{macro}{\setglossarystyle}
%    \begin{macrocode}
\renewcommand*{\setglossarystyle}[1]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}{Glossary style `#1' undefined}{}%
  }%
  {%
    \csname @glsstyle@#1\endcsname
%    \end{macrocode}
% Only set the current style if it exists.
%    \begin{macrocode}
    \protected@edef\@glsxtr@current@style{#1}%
  }%
  \ifx\@glossary@default@style\relax
    \protected@edef\@glossary@default@style{#1}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
% In case we have an old version of \styfmt{glossaries}:
%    \begin{macrocode}
\ifdef\@glossary@default@style
{}
{%
  \let\@glossary@default@style\relax
}
%    \end{macrocode}
%
%\begin{macro}{\glslistdottedwidth}
%If \cs{glslistdottedwidth} has been defined and is currently equal
%to \verb|.5\hsize| then make the modification suggested in 
%\href{http://www.dickimaw-books.com/cgi-bin/bugtracker.cgi?action=view&key=92}{bug report \#92}
%    \begin{macrocode}
\ifdef\glslistdottedwidth
{%
  \ifdim\glslistdottedwidth=.5\hsize
    \setlength{\glslistdottedwidth}{-\dimexpr\maxdimen-1sp\relax}
    \AtBeginDocument{%
      \ifdim\glslistdottedwidth=-\dimexpr\maxdimen-1sp\relax
       \setlength{\glslistdottedwidth}{.5\columnwidth}%
      \fi
    }%
  \fi
}
{}%
%    \end{macrocode}
%\end{macro}
%
%Similarly for \cs{glsdescwidth}:
%\begin{macro}{\glsdescwidth}
%\changes{0.5.3}{2015-12-09}{added}
%    \begin{macrocode}
\ifdef\glsdescwidth
{%
  \ifdim\glsdescwidth=.6\hsize
    \setlength{\glsdescwidth}{-\dimexpr\maxdimen-1sp\relax}
    \AtBeginDocument{%
      \ifdim\glsdescwidth=-\dimexpr\maxdimen-1sp\relax
       \setlength{\glsdescwidth}{.6\columnwidth}%
      \fi
    }%
  \fi
}
{}%
%    \end{macrocode}
%\end{macro}
%and for \cs{glspagelistwidth}:
%\begin{macro}{\glspagelistwidth}
%\changes{0.5.3}{2015-12-09}{added}
%    \begin{macrocode}
\ifdef\glspagelistwidth
{%
  \ifdim\glspagelistwidth=.1\hsize
    \setlength{\glspagelistwidth}{-\dimexpr\maxdimen-1sp\relax}
    \AtBeginDocument{%
      \ifdim\glspagelistwidth=-\dimexpr\maxdimen-1sp\relax
       \setlength{\glspagelistwidth}{.1\columnwidth}%
      \fi
    }%
  \fi
}
{}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossaryentrynumbers}
% Has the \pkgopt{nonumberlist} option been used?
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\def\org@glossaryentrynumbers#1{#1\gls@save@numberlist{#1}}%
\ifx\org@glossaryentrynumbers\glossaryentrynumbers
  \glsnonumberlistfalse
  \renewcommand*{\glossaryentrynumbers}[1]{%
    \ifglsentryexists{\glscurrententrylabel}%
    {%
      \@glsxtrpreloctag
      \GlsXtrFormatLocationList{#1}%
      \@glsxtrpostloctag
      \gls@save@numberlist{#1}%
    }{}%
  }%
\else
  \glsnonumberlisttrue
  \renewcommand*{\glossaryentrynumbers}[1]{%
    \ifglsentryexists{\glscurrententrylabel}%
    {%
      \gls@save@numberlist{#1}%
    }{}%
  }%
\fi
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrFormatLocationList}
%\changes{0.5.2}{2015-12-08}{new}
% Provide an easy interface to change the format of the location
% list without removing the save number list stuff.
%    \begin{macrocode}
\newcommand*{\GlsXtrFormatLocationList}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% Sometimes users want to prefix the location list with
% \qt{page}\slash\qt{pages}. The simplest way to determine if the
% location list consists of a single location is to check for
% instances of \cs{delimN} or \cs{delimR}, but this isn't so easy to
% do as they might be embedded inside the argument of formatting
% commands. With a bit of trickery we can find out by adjusting
% \cs{delimN} and \cs{delimR} to set a flag and then save
% information to the auxiliary file for the next run.
%\begin{macro}{\GlsXtrEnablePreLocationTag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrEnablePreLocationTag}[2]{%
  \let\@glsxtrpreloctag\@@glsxtrpreloctag
  \let\@glsxtrpostloctag\@@glsxtrpostloctag
  \renewcommand*{\@glsxtr@pagetag}{#1}%
  \renewcommand*{\@glsxtr@pagestag}{#2}%
  \renewcommand*{\@glsxtr@savepreloctag}[2]{%
    \csgdef{@glsxtr@preloctag@##1}{##2}%
  }%
  \renewcommand*{\@glsxtr@doloctag}{%
    \ifcsundef{@glsxtr@preloctag@\glscurrententrylabel}%
    {%
      \GlossariesWarning{Missing pre-location tag for `\glscurrententrylabel'.
        Rerun required}%
    }%
    {%
      \csuse{@glsxtr@preloctag@\glscurrententrylabel}%
    }%
  }%
}
\@onlypreamble\GlsXtrEnablePreLocationTag
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtrpreloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@@glsxtrpreloctag}{%
   \let\@glsxtr@org@delimN\delimN
   \let\@glsxtr@org@delimR\delimR
   \let\@glsxtr@org@glsignore\glsignore
%    \end{macrocode}
% \cs{gdef} is required as the delimiters may occur inside a scope.
%    \begin{macrocode}
   \gdef\@glsxtr@thisloctag{\@glsxtr@pagetag}%
   \renewcommand*{\delimN}{%
     \gdef\@glsxtr@thisloctag{\@glsxtr@pagestag}%
     \@glsxtr@org@delimN}%
   \renewcommand*{\delimR}{%
     \gdef\@glsxtr@thisloctag{\@glsxtr@pagestag}%
     \@glsxtr@org@delimR}%
   \renewcommand*{\glsignore}[1]{%
     \gdef\@glsxtr@thisloctag{\relax}%
     \@glsxtr@org@glsignore{##1}}%
   \@glsxtr@doloctag
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtrpreloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtrpreloctag}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@pagetag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@pagetag}{}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtr@pagestag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@pagestag}{}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@@glsxtrpostloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@@glsxtrpostloctag}{%
   \let\delimN\@glsxtr@org@delimN
   \let\delimR\@glsxtr@org@delimR
   \let\glsignore\@glsxtr@org@glsignore
   \protected@write\@auxout{}%
    {\string\@glsxtr@savepreloctag{\glscurrententrylabel}{\@glsxtr@thisloctag}}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtrpostloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtrpostloctag}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@preloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@savepreloctag}[2]{}
\protected@write\@auxout{}{%
  \string\providecommand\string\@glsxtr@savepreloctag[2]{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@doloctag}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@doloctag}{}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\KV@printgloss@nonumberlist}
% Modify the \gloskey[printglossary]{nonumberlist} key to
% use \cs{GlsXtrFormatLocationList} (and also save the number list):
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\renewcommand*{\KV@printgloss@nonumberlist}[1]{%
 \XKV@plfalse
 \XKV@sttrue
 \XKV@checkchoice[\XKV@resa]{#1}{true,false}%
 {%
   \csname glsnonumberlist\XKV@resa\endcsname
   \ifglsnonumberlist
     \def\glossaryentrynumbers##1{\gls@save@numberlist{##1}}%
   \else
     \def\glossaryentrynumbers##1{%
       \@glsxtrpreloctag
       \GlsXtrFormatLocationList{##1}%
       \@glsxtrpostloctag
       \gls@save@numberlist{##1}}%
   \fi
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Entry Formatting, Hyperlinks and Indexing}
%
%\begin{macro}{\glsentryfmt}
% Change default entry format. Use the generic format for regular
% terms (that is, entries that have a category with the \catattr{regular}
% attribute set) or non-regular terms without a short value and use the abbreviation format for non-regular
% terms that have a short value. If further attributes need to be checked, then
% \cs{glsentryfmt} will need redefining as appropriate (or use
% \cs{defglsentryfmt}).
%\changes{0.3}{2015-12-02}{added check for short}
% The abbreviation format is set here for entries that have a short
% form, even if they are regular entries to ensure the abbreviation
% fonts are correct.
%\changes{0.5.2}{2015-12-08}{moved \cs{glssetabbrvfmt} from
%\cs{glsxtrabbrvfmt} to here}
%    \begin{macrocode}
\renewcommand*{\glsentryfmt}{%
  \ifglshasshort{\glslabel}{\glssetabbrvfmt{\glscategory{\glslabel}}}{}%
  \glsifregular{\glslabel}%
  {\glsxtrregularfont{\glsgenentryfmt}}%
  {%
    \ifglshasshort{\glslabel}%
    {\glsxtrgenabbrvfmt}%
    {\glsxtrregularfont{\glsgenentryfmt}}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrregularfont}
%\changes{1.04}{2016-05-02}{new}
% Font used for regular entries.
%    \begin{macrocode}
\newcommand*{\glsxtrregularfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
% Commands like \cs{glsifplural} are only used by the \cs{gls}-like
% commands in the \styfmt{glossaries} package, but it might be useful
% for the postlink hook to know if the user has used, say,
% \cs{glsfirst} or \cs{glsplural}. This can provide better
% consistency with the formatting of the \cs{gls}-like commands,
% even though they don't use \cs{glsentryfmt}.
%
%\begin{macro}{\@gls@field@link}
% Redefine \cs{@gls@field@link} so that commands like \cs{glsfirst}
% can setup \cs{glsxtrifwasfirstuse} etc to allow the postlink hook
% to work better. This now has an optional argument that sets up the
% defaults.
%\changes{0.3}{2015-12-02}{added optional argument}
%    \begin{macrocode}
\renewcommand{\@gls@field@link}[4][]{%
%    \end{macrocode}
%If the \pkgopt{record} option has been used, the information needs
%to be written to the aux file regardless of whether the enter
%exists.
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%    \begin{macrocode}
  \@glsxtr@record{#2}{#3}%
  \glsdoifexists{#3}%
  {%
%    \end{macrocode}
%Save and restore the hyper setting (\cs{@gls@link} also does this,
%but that's too late if the optional argument of \cs{@gls@field@link}
%modifies it).
%    \begin{macrocode}
    \let\glsxtrorg@ifKV@glslink@hyper\ifKV@glslink@hyper
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \def\glscustomtext{#4}%
    \@glsxtr@field@linkdefs
    #1%
    \@gls@link[#2]{#3}{#4}%
    \let\ifKV@glslink@hyper\glsxtrorg@ifKV@glslink@hyper
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%The commands \cs{gls}, \cs{Gls} etc don't use \cs{@gls@field@link},
%so they need modifying as well to use \cs{@glsxtr@record}.
%
%\begin{macro}{\@gls@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@gls@\@gls@
\def\@gls@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@gls@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glspl@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@glspl@\@glspl@
\def\@glspl@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@glspl@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Gls@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@Gls@\@Gls@
\def\@Gls@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@Gls@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glspl@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@Glspl@\@Glspl@
\def\@Glspl@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@Glspl@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLS@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@GLS@\@GLS@
\def\@GLS@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@GLS@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSpl@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%\changes{1.10}{2016-12-17}{fixed bug caused by typo in command name}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@GLSpl@\@GLSpl@
\def\@GLSpl@#1#2{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@GLSpl@{#1}{#2}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdispl}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Save the original definition and redefine.
%    \begin{macrocode}
\let\@glsxtr@org@glsdisp\@glsdisp
\renewcommand*{\@glsdisp}[3][]{%
  \@glsxtr@record{#1}{#2}%
  \@glsxtr@org@glsdisp[#1]{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@@link@}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Redefine to include \cs{@glsxtr@record}
%    \begin{macrocode}
\renewcommand*{\@gls@@link}[3][]{%
  \@glsxtr@record{#1}{#2}%
  \glsdoifexistsordo{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\relax
    \@gls@link[#1]{#2}{#3}%
  }%
  {%
    \glstextformat{#3}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsadd}
%\changes{1.08}{2016-12-13}{added \cs{@glsxtr@record}}
%Redefine to include \cs{@glsxtr@record}
%    \begin{macrocode}
\renewrobustcmd*{\glsadd}[2][]{%
  \@gls@adjustmode
  \@glsxtr@record{#1}{#2}%
  \glsdoifexists{#2}%
  {%
    \def\@glsnumberformat{glsnumberformat}%
    \edef\@gls@counter{\csname glo@\glsdetoklabel{#2}@counter\endcsname}%
    \setkeys{glossadd}{#1}%
    \@gls@saveentrycounter
    \@@do@wrglossary{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@field@linkdefs}
% Default settings for \cs{@gls@field@link}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@field@linkdefs}{%
  \let\glsxtrifwasfirstuse\@secondoftwo
  \let\glsifplural\@secondoftwo
  \let\glscapscase\@firstofthree
  \let\glsinsert\@empty
}
%    \end{macrocode}
%\end{macro}
%
%Redefine the field link commands that need to modify the above.
%Also add accessibility support and set the abbreviation styles if
%required.
%\begin{macro}{\glsxtrassignfieldfont}
%\changes{1.04}{2016-05-02}{new}
%\changes{1.08}{2016-12-13}{added check for existence}
%    \begin{macrocode}
\newcommand*{\glsxtrassignfieldfont}[1]{%
  \ifglsentryexists{#1}%
  {%
    \ifglshasshort{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
      \glsifregular{#1}%
      {\let\@gls@field@font\glsxtrregularfont}%
      {\let\@gls@field@font\@firstofone}%
    }%
    {%
      \glsifnotregular{#1}%
      {\let\@gls@field@font\@firstofone}%
      {\let\@gls@field@font\glsxtrregularfont}%
    }%
  }%
  {%
    \let\@gls@field@font\@gobble
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glstext@}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@glstext@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link{#1}{#2}{\@gls@field@font{\glsaccesstext{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLStext@}
% All uppercase version of \cs{glstext}.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@GLStext@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdofthree]{#1}{#2}%
    {\@gls@field@font{\GLSaccesstext{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glstext@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@Glstext@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@secondofthree]{#1}{#2}%
    {\@gls@field@font{\Glsaccesstext{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%Version 1.07 ensures that \cs{glsfirst} etc honours the
%\catattr{nohyperfirst} attribute. Allow a convenient way for the
%user to revert to ignoring this attribute for these commands.
%\begin{macro}{\glsxtrchecknohyperfirst}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrchecknohyperfirst}[1]{%
  \glsifattribute{#1}{nohyperfirst}{true}{\KV@glslink@hyperfalse}{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsfirst@}
% No case changing version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@glsfirst@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{glsfirst} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \glsxtrchecknohyperfirst{#2}%
  ]{#1}{#2}%
  {\@gls@field@font{\glsaccessfirst{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsfirst@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@Glsfirst@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{Glsfirst} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \let\glscapscase\@secondofthree
   \glsxtrchecknohyperfirst{#2}%
  ]%
   {#1}{#2}{\@gls@field@font{\Glsaccessfirst{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSfirst@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@GLSfirst@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{GLSfirst} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \let\glscapscase\@thirdofthree
   \glsxtrchecknohyperfirst{#2}%
  ]%
   {#1}{#2}{\@gls@field@font{\GLSaccessfirst{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsplural@}
% No case changing version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.03}{2016-04-27}{fixed bug \cs{@glsplural@} should be redefined
%not \cs{@glsplural}}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@glsplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glsifplural\@firstoftwo]{#1}{#2}%
    {\@gls@field@font{\glsaccessplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsplural@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.03}{2016-04-27}{fixed bug \cs{@Glsplural@} should be redefined
%not \cs{@Glsplural}}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@Glsplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glsifplural\@firstoftwo
   \let\glscapscase\@secondofthree
  ]%
    {#1}{#2}{\@gls@field@font{\Glsaccessplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSplural@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.03}{2016-04-27}{fixed bug \cs{@GLSplural@} should be redefined
%not \cs{@GLSplural}}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@GLSplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glsifplural\@firstoftwo
   \let\glscapscase\@thirdofthree
  ]%
    {#1}{#2}{\@gls@field@font{\GLSaccessplural{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsfirstplural@}
% No case changing version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@glsfirstplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{glsfirstplural} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \let\glsifplural\@firstoftwo
   \glsxtrchecknohyperfirst{#2}%
  ]%
   {#1}{#2}{\@gls@field@font{\glsaccessfirstplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsfirstplural@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.03}{2016-04-27}{bug fix: misspelt cs name}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@Glsfirstplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{glsfirstplural} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \let\glsifplural\@firstoftwo
   \let\glscapscase\@secondofthree
   \glsxtrchecknohyperfirst{#2}%
  ]%
   {#1}{#2}{\@gls@field@font{\Glsaccessfirstplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSfirstplural@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.03}{2016-04-27}{bug fix: misspelt cs name}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@GLSfirstplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
%    \end{macrocode}
% Ensure that \cs{glsfirstplural} honours the \catattr{nohyperfirst} attribute.
%\changes{1.07}{2016-08-15}{added check for nohyperfirst attribute}
%    \begin{macrocode}
  \@gls@field@link
  [\let\glsxtrifwasfirstuse\@firstoftwo
   \let\glsifplural\@firstoftwo
   \let\glscapscase\@thirdofthree
   \glsxtrchecknohyperfirst{#2}%
  ]%
   {#1}{#2}%
   {\@gls@field@font{\GLSaccessfirstplural{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsname@}
% Redefine to use accessibility support.
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@glsname@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link{#1}{#2}{\@gls@field@font{\glsaccessname{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsname@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{add accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@Glsname@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]{#1}{#2}%
  {\@gls@field@font{\Glsaccessname{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSname@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
% The abbreviation format may also need setting.
%    \begin{macrocode}
\def\@GLSname@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}%
    {\@gls@field@font{\GLSaccessname{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdesc@}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@glsdesc@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link{#1}{#2}{\@gls@field@font{\glsaccessdesc{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsdesc@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@Glsdesc@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]{#1}{#2}%
  {\@gls@field@font{\Glsaccessdesc{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSdesc@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@GLSdesc@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\GLSaccessdesc{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsdescplural@}
% No case-changing version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@glsdescplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo
   \let\glsifplural\@firstoftwo
  ]{#1}{#2}{\@gls@field@font{\glsaccessdescplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsdescplural@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@Glsdescplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo
   \let\glsifplural\@firstoftwo
  ]{#1}{#2}{\@gls@field@font{\Glsaccessdescplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSdescplural@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set abbreviation and regular format}
%    \begin{macrocode}
\def\@GLSdesc@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@thirdoftwo
   \let\glsifplural\@firstoftwo
  ]%
    {#1}{#2}%
    {\@gls@field@font{\GLSaccessdescplural{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glssymbol@}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@glssymbol@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link{#1}{#2}{\@gls@field@font{\glsaccesssymbol{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glssymbol@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glssymbol@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsaccesssymbol{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSsymbol@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSsymbol@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\GLSaccesssymbol{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glssymbolplural@}
% No case-changing version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@glssymbolplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo
   \let\glsifplural\@firstoftwo
  ]{#1}{#2}{\@gls@field@font{\glsaccesssymbolplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glssymbolplural@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glssymbolplural@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo
   \let\glsifplural\@firstoftwo
  ]{#1}{#2}{\@gls@field@font{\Glsaccesssymbolplural{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSsymbolplural@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{0.5.2}{2015-12-08}{added accessibility support}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSsymbol@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@thirdoftwo
   \let\glsifplural\@firstoftwo
  ]%
    {#1}{#2}%
    {\@gls@field@font{\GLSaccesssymbolplural{#2}\mfirstucMakeUppercase{#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuseri@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuseri@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]{#1}{#2}%
  {\@gls@field@font{\Glsentryuseri{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuseri@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuseri@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\mfirstucMakeUppercase{\glsentryuseri{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuserii@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuserii@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsentryuserii{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuserii@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuserii@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\mfirstucMakeUppercase{\glsentryuserii{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuseriii@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuseriii@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsentryuseriii{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuseriii@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuseriii@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\mfirstucMakeUppercase{\glsentryuseriii{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuseriv@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuseriv@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsentryuseriv{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuseriv@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuseriv@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}%
    {\@gls@field@font{\mfirstucMakeUppercase{\glsentryuseriv{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuserv@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuserv@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsentryuserv{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuserv@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuserv@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\mfirstucMakeUppercase{\glsentryuserv{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsuservi@}
% First letter uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@Glsuservi@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link
  [\let\glscapscase\@secondoftwo]%
   {#1}{#2}{\@gls@field@font{\Glsentryuservi{#2}#3}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSuservi@}
% All uppercase version.
%\changes{0.3}{2015-12-02}{added redefinition}
%\changes{1.04}{2016-05-02}{set regular format}
%    \begin{macrocode}
\def\@GLSuservi@#1#2[#3]{%
  \glsxtrassignfieldfont{#2}%
  \@gls@field@link[\let\glscapscase\@thirdoftwo]%
    {#1}{#2}{\@gls@field@font{\mfirstucMakeUppercase{\glsentryuservi{#2}#3}}}%
}
%    \end{macrocode}
%\end{macro}
%
%Commands like \cs{acrshort} already set \cs{glsifplural}, but they
%don't set \cs{glsxtrifwasfirstuse} so they need adjusting.
%
%\begin{macro}{\@acrshort}
%\changes{0.3}{2015-12-02}{added redefinition}
% No case change.
%    \begin{macrocode}
\def\@acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsaccessshort{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrshort}
%\changes{0.3}{2015-12-02}{added redefinition}
% First letter uppercase.
%    \begin{macrocode}
\def\@Acrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsaccessshort{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRshort}
%\changes{0.3}{2015-12-02}{added redefinition}
% All uppercase.
%    \begin{macrocode}
\def\@ACRshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsaccessshort{#2}}#3}%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrshortpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% No case change.
%    \begin{macrocode}
\def\@acrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsaccessshortpl{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrshortpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% First letter uppercase.
%    \begin{macrocode}
\def\@Acrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsaccessshortpl{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRshortpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% All uppercase.
%    \begin{macrocode}
\def\@ACRshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsaccessshortpl{#2}}#3}%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrlong}
%\changes{0.3}{2015-12-02}{added redefinition}
% No case change.
%    \begin{macrocode}
\def\@acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsaccesslong{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrlong}
%\changes{0.3}{2015-12-02}{added redefinition}
% First letter uppercase.
%    \begin{macrocode}
\def\@Acrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsaccesslong{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRlong}
%\changes{0.3}{2015-12-02}{added redefinition}
% All uppercase.
%    \begin{macrocode}
\def\@ACRlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsaccesslong{#2}}#3}%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@acrlongpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% No case change.
%    \begin{macrocode}
\def\@acrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\glsaccesslongpl{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Acrlongpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% First letter uppercase.
%    \begin{macrocode}
\def\@Acrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \acronymfont{\Glsaccesslongpl{#2}}#3%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@ACRlongpl}
%\changes{0.3}{2015-12-02}{added redefinition}
% All uppercase.
%    \begin{macrocode}
\def\@ACRlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\acronymfont{\glsaccesslongpl{#2}}#3}%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%Modify \cs{@glsaddkey} so additional keys provided by the user can
%be treated in a similar way.
%\begin{macro}{\@glsaddkey}
%    \begin{macrocode}
\renewcommand*{\@glsaddkey}[7]{%
  \key@ifundefined{glossentry}{#1}%
  {%
    \define@key{glossentry}{#1}{\csdef{@glo@#1}{##1}}%
    \appto\@gls@keymap{,{#1}{#1}}%
    \appto\@newglossaryentryprehook{\csdef{@glo@#1}{#2}}%
    \appto\@newglossaryentryposthook{%
      \letcs{\@glo@tmp}{@glo@#1}%
      \gls@assign@field{#2}{\@glo@label}{#1}{\@glo@tmp}%
    }%
    \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 (same as before):
%    \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}%
       {}%
    }%
    {%
      \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
% (modified):
%    \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}%
       {}%
    }%
    {%
      \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[\let\glscapscase\@secondofthree]%
          {##1}{##2}{#4{##2}##3}%
      }%
      \newrobustcmd*{#6}{%
        \expandafter\@gls@hyp@opt\csname @Gls@user@#1\endcsname}%
    }%
%    \end{macrocode}
% Finally the all caps version (modified):
%    \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}%
       {}%
    }%
    {%
      \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[\let\glscapscase\@thirdofthree]%
           {##1}{##2}{\mfirstucMakeUppercase{#3{##2}##3}}%
      }%
      \newrobustcmd*{#7}{%
        \expandafter\@gls@hyp@opt\csname @GLS@user@#1\endcsname}%
    }%
  }%
  {%
    \PackageError{glossaries-extra}{Key `#1' already exists}{}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@link@nocheckfirsthyper}
% Old versions of \styfmt{glossaries} don't define
% this, so provide it just in case it hasn't been defined.
%    \begin{macrocode}
\providecommand*{\@gls@link@nocheckfirsthyper}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@link@checkfirsthyper}
% Modify check to determine if the hyperlink should be automatically 
% suppressed, but save the original in case the acronyms are restored.
%    \begin{macrocode}
\let\@glsxtr@org@checkfirsthyper\@gls@link@checkfirsthyper
\renewcommand*{\@gls@link@checkfirsthyper}{%
%    \end{macrocode}
% \cs{ifglsused} isn't useful in the post link hook as it's already
% been unset by then, so define a command that can be used in the
% post link hook. Since \cs{@gls@link@checkfirsthyper} is only used
% by commands like \cs{gls} but not by other commands, this seems
% the best place to put it.
%    \begin{macrocode}
  \ifglsused{\glslabel}%
   {\let\glsxtrifwasfirstuse\@secondoftwo}
   {\let\glsxtrifwasfirstuse\@firstoftwo}%
%    \end{macrocode}
% Store the category label for convenience.
%    \begin{macrocode}
  \edef\glscategorylabel{\glscategory{\glslabel}}%
  \ifglsused{\glslabel}%
  {%
    \glsifcategoryattribute{\glscategorylabel}{nohypernext}{true}%
      {\KV@glslink@hyperfalse}{}%
  }%
  {%
    \glsifcategoryattribute{\glscategorylabel}{nohyperfirst}{true}%
      {\KV@glslink@hyperfalse}{}%
  }%
  \glslinkcheckfirsthyperhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\do@glsdisablehyperinlist}
% This command was introduced in \styfmt{glossaries} v4.19. If it
% hasn't been defined, we're using an earlier version, in which case
% the \catattr{nohyper} attribute can't be implemented.
%    \begin{macrocode}
\ifdef\do@glsdisablehyperinlist
{%
  \let\@glsxtr@do@glsdisablehyperinlist\do@glsdisablehyperinlist
  \renewcommand*{\do@glsdisablehyperinlist}{%
    \@glsxtr@do@glsdisablehyperinlist
    \glsifattribute{\glslabel}{nohyper}{true}{\KV@glslink@hyperfalse}{}%
  }
}
{}
%    \end{macrocode}
%\end{macro}
%
% Define a \gloskey[glslink]{noindex} key to prevent writing information to the
% external file.
%    \begin{macrocode}
\define@boolkey{glslink}{noindex}[true]{}
\KV@glslink@noindexfalse
%    \end{macrocode}
%
%If \cs{@gls@setdefault@glslink@opts} has been defined
%(\styfmt{glossaries} v4.20) use it to set the default keys in
%\cs{@glslink}.
%\begin{macro}{\@gls@setdefault@glslink@opts}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\ifdef\@gls@setdefault@glslink@opts
{
  \renewcommand*{\@gls@setdefault@glslink@opts}{%
    \KV@glslink@noindexfalse
  }
}
{
%    \end{macrocode}
% Not defined so prepend it to \cs{do@glsdisablehyperinlist} to
% achieve the same effect.
%    \begin{macrocode}
  \newcommand*{\@gls@setdefault@glslink@opts}{%
    \KV@glslink@noindexfalse
  }
  \preto\do@glsdisablehyperinlist{\@gls@setdefault@glslink@opts}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetDefaultGlsOpts}
%\changes{0.5.4}{2015-12-15}{new}
% Set the default options for \cs{glslink} etc.
%    \begin{macrocode}
\newcommand*{\GlsXtrSetDefaultGlsOpts}[1]{%
  \renewcommand*{\@gls@setdefault@glslink@opts}{\setkeys{glslink}{#1}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrifindexing}
% Provide user level command to access it in \cs{glswriteentry}.
%    \begin{macrocode}
\newcommand*{\glsxtrifindexing}[2]{%
  \ifKV@glslink@noindex #2\else #1\fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glswriteentry}
% Redefine to test for \catattr{indexonlyfirst} category attribute.
%    \begin{macrocode}
\renewcommand*{\glswriteentry}[2]{%
  \glsxtrifindexing
  {%
   \ifglsindexonlyfirst
     \ifglsused{#1}
     {\glsxtrdoautoindexname{#1}{dualindex}}%
     {#2}%
   \else
     \glsifattribute{#1}{indexonlyfirst}{true}%
     {\ifglsused{#1}
      {\glsxtrdoautoindexname{#1}{dualindex}}%
      {#2}}%
     {#2}%
   \fi
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@do@@wrglossary}
% Hook into glossary indexing command so that it can also use
% \ics{index} at the same time if required and add user hook.
%    \begin{macrocode}
\appto\@@do@@wrglossary{\@glsxtr@do@@wrindex
  \glsxtrdowrglossaryhook{\@gls@label}%
}
%    \end{macrocode}
% (The label can be obtained from \cs{@gls@label} at this point.)
%\end{macro}
% Similarly for the \qt{noidx} version:
%\begin{macro}{\gls@noidxglossary}
%    \begin{macrocode}
\appto\gls@noidxglossary{\@glsxtr@do@@wrindex
  \glsxtrdowrglossaryhook{\@gls@label}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@do@@wrindex}
%    \begin{macrocode}
\newcommand*{\@glsxtr@do@@wrindex}{%
  \glsxtrdoautoindexname{\@gls@label}{dualindex}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrdowrglossaryhook}
% Allow user to hook into indexing code. (Always used by
% \cs{glsadd}. Used by \cs{gls} when indexing, which may or may not occur
% depending on the indexing settings.)
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrdowrglossaryhook}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@alt@hyp@opt}
%\changes{0.5.4}{2015-12-15}{new}
% Commands like \cs{gls} have a star or plus version. Provide a
% third symbol that the user can adapt for convenience.
%    \begin{macrocode}
\newcommand*{\@gls@alt@hyp@opt}[1]{%
 \let\glslinkvar\@firstofthree
 \let\@gls@hyp@opt@cs#1\relax
 \@ifstar{\s@gls@hyp@opt}%
 {\@ifnextchar+%
   {\@firstoftwo{\p@gls@hyp@opt}}%
   {%
     \expandafter\@ifnextchar\@gls@alt@hyp@opt@char
     {\@firstoftwo{\@alt@gls@hyp@opt}}%
     {#1}%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@alt@gls@hyp@opt}
% User version
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@alt@gls@hyp@opt}[1][]{%
 \let\glslinkvar\@firstofthree
 \expandafter\@gls@hyp@opt@cs\expandafter[\@gls@alt@hyp@opt@keys,#1]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@alt@hyp@opt@char}
%\changes{0.5.4}{2015-12-15}{new}
%Contains the character used as the command modifier.
%    \begin{macrocode}
\newcommand*{\@gls@alt@hyp@opt@char}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@alt@hyp@opt@keys}
%\changes{0.5.4}{2015-12-15}{new}
%Contains the option list used as the command modifier.
%    \begin{macrocode}
\newcommand*{\@gls@alt@hyp@opt@keys}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetAltModifier}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrSetAltModifier}[2]{%
  \let\@gls@hyp@opt\@gls@alt@hyp@opt
  \def\@gls@alt@hyp@opt@char{#1}%
  \def\@gls@alt@hyp@opt@keys{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdohyperlink}
% Unpleasant complications can occur if the \gloskey{text} or
% \gloskey{first} key etc contains \cs{gls}, particularly if there
% are hyperlinks. To get around this problem, patch
% \cs{glsdohyperlink} so that it temporarily makes \ics{gls} behave
% like \ics{glstext}\oarg{hyper=false,noindex}. (This will be
% overridden if the user explicitly cancels either of those options
% in the optional argument of \cs{gls} or using the plus version.)
% This also patches the short form commands like \cs{acrshort}
% and \cs{glsxtrshort} to use \cs{glsentryshort} and, similarly, the
% long form commands like \cs{acrlong} and \cs{glsxtrlong} to use
% \cs{glsentrylong}.
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\renewcommand*{\glsdohyperlink}[2]{%
 \hyperlink{#1}{{\glsxtrprotectlinks#2}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdisablehyper}
%\changes{0.5.4}{2015-12-15}{added}
% Redefine in case we have an old version of \styfmt{glossaries}.
%    \begin{macrocode}
\ifundef\glsdonohyperlink
{%
  \renewcommand{\glsdisablehyper}{%
    \KV@glslink@hyperfalse
    \let\@glslink\glsdonohyperlink
    \let\@glstarget\@secondoftwo
  }
}
{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsdonohyperlink}
% This command was only introduced in \styfmt{glossaries} v4.20, so it may
% not be defined. For older \styfmt{glossaries} versions, this won't be
% used if \sty{hyperref} hasn't been loaded, which means the
% indexing will still take place.
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\def\glsdonohyperlink#1#2{{\glsxtrprotectlinks #2}}
%    \end{macrocode}
%\end{macro}
%
% Reset \cs{@glslink} with patched versions:
%    \begin{macrocode}
\ifcsundef{hyperlink}%
{%
  \let\@glslink\glsdonohyperlink
}%
{%
  \let\@glslink\glsdohyperlink
}
%    \end{macrocode}
%
%\begin{macro}{\glsxtrprotectlinks}
%\changes{0.5.4}{2015-12-15}{new}
% Make \cs{gls} (and variants) behave like the corresponding
% \cs{glstext} (and variants) with hyperlinking and indexing off.
%    \begin{macrocode}
\newcommand*{\glsxtrprotectlinks}{%
  \KV@glslink@hyperfalse
  \KV@glslink@noindextrue
  \let\@gls@\@glsxtr@p@text@
  \let\@Gls@\@Glsxtr@p@text@
  \let\@GLS@\@GLSxtr@p@text@
  \let\@glspl@\@glsxtr@p@plural@
  \let\@Glspl@\@Glsxtr@p@plural@
  \let\@GLSpl@\@GLSxtr@p@plural@
  \let\@glsxtrshort\@glsxtr@p@short@
  \let\@Glsxtrshort\@Glsxtr@p@short@
  \let\@GLSxtrshort\@GLSxtr@p@short@
  \let\@glsxtrlong\@glsxtr@p@long@
  \let\@Glsxtrlong\@Glsxtr@p@long@
  \let\@GLSxtrlong\@GLSxtr@p@long@
  \let\@glsxtrshortpl\@glsxtr@p@shortpl@
  \let\@Glsxtrshortpl\@Glsxtr@p@shortpl@
  \let\@GLSxtrshortpl\@GLSxtr@p@shortpl@
  \let\@glsxtrlongpl\@glsxtr@p@longpl@
  \let\@Glsxtrlongpl\@Glsxtr@p@longpl@
  \let\@GLSxtrlongpl\@GLSxtr@p@longpl@
  \let\@acrshort\@glsxtr@p@acrshort@
  \let\@Acrshort\@Glsxtr@p@acrshort@
  \let\@ACRshort\@GLSxtr@p@acrshort@
  \let\@acrshortpl\@glsxtr@p@acrshortpl@
  \let\@Acrshortpl\@Glsxtr@p@acrshortpl@
  \let\@ACRshortpl\@GLSxtr@p@acrshortpl@
  \let\@acrlong\@glsxtr@p@acrlong@
  \let\@Acrlong\@Glsxtr@p@acrlong@
  \let\@ACRlong\@GLSxtr@p@acrlong@
  \let\@acrlongpl\@glsxtr@p@acrlongpl@
  \let\@Acrlongpl\@Glsxtr@p@acrlongpl@
  \let\@ACRlongpl\@GLSxtr@p@acrlongpl@
}
%    \end{macrocode}
%\end{macro}
%
% These protected versions need grouping to prevent the label from 
% getting confused.
%\begin{macro}{\@glsxtr@p@text@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@text@#1#2[#3]{{\@glstext@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@text@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@text@#1#2[#3]{{\@Glstext@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@text@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@text@#1#2[#3]{{\@GLStext@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@plural@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@plural@#1#2[#3]{{\@glsplural@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@plural@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@plural@#1#2[#3]{{\@Glsplural@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@plural@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@plural@#1#2[#3]{{\@GLSplural@{#1}{#2}[#3]}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@short@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@short@#1#2[#3]{%
 {%
  \glssetabbrvfmt{\glscategory{#2}}%
  \glsabbrvfont{\glsentryshort{#2}}#3%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@short@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@short@#1#2[#3]{%
 {%
   \glssetabbrvfmt{\glscategory{#2}}%
   \glsabbrvfont{\Glsentryshort{#2}}#3%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@short@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@short@#1#2[#3]{%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \mfirstucMakeUppercase{\glsabbrvfont{\glsentryshort{#2}}#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@shortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@shortpl@#1#2[#3]{%
 {%
   \glssetabbrvfmt{\glscategory{#2}}%
   \glsabbrvfont{\glsentryshortpl{#2}}#3%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@shortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@shortpl@#1#2[#3]{%
 {%
   \glssetabbrvfmt{\glscategory{#2}}%
   \glsabbrvfont{\Glsentryshortpl{#2}}#3%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@shortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@shortpl@#1#2[#3]{%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \mfirstucMakeUppercase{\glsabbrvfont{\glsentryshortpl{#2}}#3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@long@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@long@#1#2[#3]{{\glsentrylong{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@long@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@long@#1#2[#3]{{\Glsentrylong{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@long@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@long@#1#2[#3]{%
  {\mfirstucMakeUppercase{\glslongfont{\glsentrylong{#2}}#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@longpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@longpl@#1#2[#3]{{\glsentrylongpl{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@longpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@longpl@#1#2[#3]{{\glslongfont{\Glsentrylongpl{#2}}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@longpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@longpl@#1#2[#3]{%
  {\mfirstucMakeUppercase{\glslongfont{\glsentrylongpl{#2}}#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@acrshort@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@acrshort@#1#2[#3]{{\acronymfont{\glsentryshort{#2}}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@acrshort@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@acrshort@#1#2[#3]{{\acronymfont{\Glsentryshort{#2}}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@acrshort@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@acrshort@#1#2[#3]{%
  {\mfirstucMakeUppercase{\acronymfont{\glsentryshort{#2}}#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@acrshortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@acrshortpl@#1#2[#3]{{\acronymfont{\glsentryshortpl{#2}}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@acrshortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@acrshortpl@#1#2[#3]{{\acronymfont{\Glsentryshortpl{#2}}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@acrshortpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@acrshortpl@#1#2[#3]{%
  {\mfirstucMakeUppercase{\acronymfont{\glsentryshortpl{#2}}#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@acrlong@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@acrlong@#1#2[#3]{{\glsentrylong{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@acrlong@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@acrlong@#1#2[#3]{{\Glsentrylong{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@acrlong@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@acrlong@#1#2[#3]{%
 {\mfirstucMakeUppercase{\glsentrylong{#2}#3}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@p@acrlongpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@glsxtr@p@acrlongpl@#1#2[#3]{{\glsentrylongpl{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtr@p@acrlongpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@Glsxtr@p@acrlongpl@#1#2[#3]{{\Glsentrylongpl{#2}#3}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtr@p@acrlongpl@}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\def\@GLSxtr@p@acrlongpl@#1#2[#3]{%
 {\mfirstucMakeUppercase{\glsentrylongpl{#2}#3}}}
%    \end{macrocode}
%\end{macro}
%
%Commands to minimise conflict.
%\begin{macro}{\@glsxtrp@opt}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtrp@opt}{hyper=false,noindex}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrsetpopts}
%\changes{1.07}{2016-08-15}{new}
%Used in glossary to switch hyperlinks on for the \cs{glsxtrp} type
%of commands.
%    \begin{macrocode}
\newcommand*{\glsxtrsetpopts}[1]{%
  \renewcommand*{\@glsxtrp@opt}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossxtrsetpopts}
%\changes{1.07}{2016-08-15}{new}
%Used in glossary to switch hyperlinks on for the \cs{glsxtrp} type
%of commands.
%    \begin{macrocode}
\newcommand*{\glossxtrsetpopts}{%
  \glsxtrsetpopts{noindex}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@glsxtrp}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@@glsxtrp}[2]{%
%    \end{macrocode}
%Add scope.
%    \begin{macrocode}
  {%
    \let\glspostlinkhook\relax
    \csname#1\expandafter\endcsname\expandafter[\@glsxtrp@opt]{#2}[]%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtrp}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@glsxtrp}[2]{%
  \ifcsdef{gls#1}%
  {%
    \@@glsxtrp{gls#1}{#2}%
  }%
  {%
    \ifcsdef{glsxtr#1}%
    {%
      \@@glsxtrp{glsxtr#1}{#2}%
    }%
    {%
      \PackageError{glossaries-extra}{`#1' not recognised by
        \string\glsxtrp}{}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@Glsxtrp}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@Glsxtrp}[2]{%
  \ifcsdef{Gls#1}%
  {%
    \@@glsxtrp{Gls#1}{#2}%
  }%
  {%
    \ifcsdef{Glsxtr#1}%
    {%
      \@@glsxtrp{Glsxtr#1}{#2}%
    }%
    {%
      \PackageError{glossaries-extra}{`#1' not recognised by
        \string\Glsxtrp}{}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@GLSxtrp}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@GLSxtrp}[2]{%
  \ifcsdef{GLS#1}%
  {%
    \@@glsxtrp{GLS#1}{#2}%
  }%
  {%
    \ifcsdef{GLSxtr#1}%
    {%
      \@@glsxtrp{GLSxtr#1}{#2}%
    }%
    {%
      \PackageError{glossaries-extra}{`#1' not recognised by
        \string\GLSxtrp}{}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@entry@p}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtr@headentry@p}[2]{%
 \glsifattribute{#1}{headuc}{true}%
 {%
   \mfirstucMakeUppercase{\@gls@entry@field{#1}{#2}}%
 }%
 {%
   \@gls@entry@field{#1}{#2}%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrp}
%\changes{1.07}{2016-08-15}{new}
%Not robust as it needs to expand somewhat.
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand{\glsxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\texorpdfstring
      {%
        \protect\glsxtrifinmark
        {%
          \ifcsdef{glsxtrhead#1}%
          {%
            {\protect\csuse{glsxtrhead#1}{#2}}%
          }%
          {%
            \glsxtr@headentry@p{#2}{#1}%
          }%
        }%
        {%
          \@glsxtrp{#1}{#2}%
        }%
      }%
      {%
        \protect\@gls@entry@field{#2}{#1}%
      }%
    }%
  }
}
{
  \newcommand{\glsxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\glsxtrifinmark
      {%
        \ifcsdef{glsxtrhead#1}%
        {%
          {\protect\csuse{glsxtrhead#1}}%
        }%
        {%
          \glsxtr@headentry@p{#2}{#1}%
        }%
      }%
      {%
        \@glsxtrp{#1}{#2}%
      }%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%Provide short synonyms for the most common option.
%\begin{macro}{\glsps}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\glsps}{\glsxtrp{short}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glspt}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\glspt}{\glsxtrp{text}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrp}
%\changes{1.07}{2016-08-15}{new}
%As above but use first letter upper case (but not for the
%bookmarks, which can't process \cs{uppercase}).
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand{\Glsxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\texorpdfstring
      {%
        \protect\glsxtrifinmark
        {%
          \ifcsdef{Glsxtrhead#1}%
          {%
            {\protect\csuse{Glsxtrhead#1}{#2}}%
          }%
          {%
            \protect\@Gls@entry@field{#2}{#1}%
          }%
        }%
        {%
          \@Glsxtrp{#1}{#2}%
        }%
      }%
      {%
        \protect\@gls@entry@field{#2}{#1}%
      }%
    }%
  }
}
{
  \newcommand{\Glsxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\glsxtrifinmark
      {%
        \ifcsdef{Glsxtrhead#1}%
        {%
          {\protect\csuse{Glsxtrhead#1}}%
        }%
        {%
          \protect\@Gls@entry@field{#2}{#1}%
        }%
      }%
      {%
        \@Glsxtrp{#1}{#2}%
      }%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrp}
%\changes{1.07}{2016-08-15}{new}
%As above but all upper case (but not for the
%bookmarks, which can't process \cs{uppercase}).
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand{\GLSxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\texorpdfstring
      {%
        \protect\glsxtrifinmark
        {%
          \ifcsdef{GLSxtr#1}%
          {%
            {\protect\GLSxtrshort[noindex,hyper=false]{#1}[]}%
          }%
          {%
            \protect\mfirstucMakeUppercase
            {%
              \protect\@gls@entry@field{#2}{#1}%
            }%
          }%
        }%
        {%
          \@GLSxtrp{#1}{#2}%
        }%
      }%
      {%
        \protect\@gls@entry@field{#2}{#1}%
      }%
    }%
  }
}
{
  \newcommand{\GLSxtrp}[2]{%
    \protect\NoCaseChange
    {%
      \protect\glsxtrifinmark
      {%
        \ifcsdef{GLSxtr#1}%
        {%
          {\protect\GLSxtrshort[noindex,hyper=false]{#1}[]}%
        }%
        {%
          \protect\mfirstucMakeUppercase
          {%
            \protect\@gls@entry@field{#2}{#1}%
          }%
        }%
      }%
      {%
        \@GLSxtrp{#1}{#2}%
      }%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%
%\subsection{Entry Counting}
%
% The entry counting mechanism from \styfmt{glossaries} is adjusted
% here to work with category attributes. Provide a convenient
% command to enable entry counting, set the \catattr{entrycount}
% attribute for given categories and redefine \ics{gls} etc to 
% use \cs{cgls} instead.
%
% First adjust definitions of the unset and reset commands to
% provide a hook.
%
%\begin{macro}{\@glsunset}
% Global unset.
%    \begin{macrocode}
\renewcommand*{\@glsunset}[1]{%
  \@@glsunset{#1}%
  \glsxtrpostunset{#1}%
}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrpostunset}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrpostunset}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glslocalunset}
% Local unset.
%    \begin{macrocode}
  \renewcommand*{\@glslocalunset}[1]{%
    \@@glslocalunset{#1}%
    \glsxtrpostlocalunset{#1}%
  }%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrpostlocalunset}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrpostlocalunset}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsreset}
% Global reset.
%    \begin{macrocode}
\renewcommand*{\@glsreset}[1]{%
  \@@glsreset{#1}%
  \glsxtrpostreset{#1}%
}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrpostreset}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrpostreset}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glslocalreset}
% Local reset.
%    \begin{macrocode}
\renewcommand*{\@glslocalreset}[1]{%
  \@@glslocalreset{#1}%
  \glsxtrpostlocalreset{#1}%
}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrpostlocalreset}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrpostlocalreset}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrEnableEntryCounting}
% The first argument is the list of categories and the second
% argument is the value of the \catattr{entrycount} attribute.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrEnableEntryCounting}[2]{%
%    \end{macrocode}
% Enable entry counting:
%    \begin{macrocode}
  \glsenableentrycount
%    \end{macrocode}
% Redefine \cs{gls} etc:
%    \begin{macrocode}
  \renewcommand*{\gls}{\cgls}%
  \renewcommand*{\Gls}{\cGls}%
  \renewcommand*{\glspl}{\cglspl}%
  \renewcommand*{\Glspl}{\cGlspl}%
  \renewcommand*{\GLS}{\cGLS}%
  \renewcommand*{\GLSpl}{\cGLSpl}%
%    \end{macrocode}
% Set the \catattr{entrycount} attribute:
%    \begin{macrocode}
  \@glsxtr@setentrycountunsetattr{#1}{#2}%
%    \end{macrocode}
% In case this command is used again:
%    \begin{macrocode}
  \let\GlsXtrEnableEntryCounting\@glsxtr@setentrycountunsetattr
  \renewcommand*{\GlsXtrEnableEntryUnitCounting}[3]{%
   \PackageError{glossaries-extra}{\string\GlsXtrEnableEntryUnitCounting\space
    can't be used with \string\GlsXtrEnableEntryCounting}%
   {Use one or other but not both commands}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@setentrycountunsetattr}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@setentrycountunsetattr}[2]{%
 \@for\@glsxtr@cat:=#1\do
 {%
   \ifdefempty{\@glsxtr@cat}{}%
   {%
     \glssetcategoryattribute{\@glsxtr@cat}{entrycount}{#2}%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
% Redefine the entry counting commands to take into account the
%\catattr{entrycount} attribute.
%\begin{macro}{\glsenableentrycount}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\renewcommand*{\glsenableentrycount}{%
%    \end{macrocode}
% Enable new fields:
%    \begin{macrocode}
  \appto\@newglossaryentry@defcounters{\@@newglossaryentry@defcounters}%
%    \end{macrocode}
% Just in case the user has switched on the \pkgopt{docdef} option.
%    \begin{macrocode}
  \renewcommand*{\gls@defdocnewglossaryentry}{%
    \renewcommand*\newglossaryentry[2]{%
      \PackageError{glossaries}{\string\newglossaryentry\space
      may only be used in the preamble when entry counting has
      been activated}{If you use \string\glsenableentrycount\space
      you must place all entry definitions in the preamble not in
      the document environment}%
    }%
  }%
%    \end{macrocode}
% New commands to access new fields:
%    \begin{macrocode}
  \newcommand*{\glsentrycurrcount}[1]{%
   \ifcsundef{glo@\glsdetoklabel{##1}@currcount}%
   {0}{\@gls@entry@field{##1}{currcount}}%
  }%
  \newcommand*{\glsentryprevcount}[1]{%
   \ifcsundef{glo@\glsdetoklabel{##1}@prevcount}%
   {0}{\@gls@entry@field{##1}{prevcount}}%
  }%
%    \end{macrocode}
% Adjust post unset and reset:
%    \begin{macrocode}
  \let\@glsxtr@entrycount@org@unset\glsxtrpostunset
  \renewcommand*{\glsxtrpostunset}[1]{%
    \@glsxtr@entrycount@org@unset{##1}%
    \@gls@increment@currcount{##1}%
  }%
  \let\@glsxtr@entrycount@org@localunset\glsxtrpostlocalunset
  \renewcommand*{\glsxtrpostlocalunset}[1]{%
    \@glsxtr@entrycount@org@localunset{##1}%
    \@gls@local@increment@currcount{##1}%
  }%
  \let\@glsxtr@entrycount@org@reset\glsxtrpostreset
  \renewcommand*{\glsxtrpostreset}[1]{%
    \@glsxtr@entrycount@org@reset{##1}%
    \csgdef{glo@\glsdetoklabel{##1}@currcount}{0}%
  }%
  \let\@glsxtr@entrycount@org@localreset\glsxtrpostlocalreset
  \renewcommand*{\glsxtrpostlocalreset}[1]{%
    \@glsxtr@entrycount@org@localreset{##1}%
    \csdef{glo@\glsdetoklabel{##1}@currcount}{0}%
  }%
%    \end{macrocode}
% Modifications to take into account the attributes that govern
% whether the entry should be unset.
%    \begin{macrocode}
  \let\@cgls@\@@cgls@
  \let\@cglspl@\@@cglspl@
  \let\@cGLS@\@@cGLS@
  \let\@cGlspl@\@@cGlspl@
  \let\@cGLS@\@@cGLS@
  \let\@cGLSpl@\@@cGLSpl@
%    \end{macrocode}
% The rest is as the original definition.
%    \begin{macrocode}
  \AtEndDocument{\@gls@write@entrycounts}%
  \renewcommand*{\@gls@entry@count}[2]{%
    \csgdef{glo@\glsdetoklabel{##1}@prevcount}{##2}%
  }%
  \let\glsenableentrycount\relax
  \renewcommand*{\glsenableentryunitcount}{%
    \PackageError{glossaries-extra}{\string\glsenableentryunitcount\space
     can't be used with \string\glsenableentrycount}%
    {Use one or other but not both commands}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@write@entrycounts}
% Modify this command so that it only writes the information for
% entries with the \catattr{entrycount} attribute and issue
% warning if no entries have this attribute set.
%    \begin{macrocode}
\renewcommand*{\@gls@write@entrycounts}{%
  \immediate\write\@auxout
    {\string\providecommand*{\string\@gls@entry@count}[2]{}}%
  \count@=0\relax
  \forallglsentries{\@glsentry}{%
    \glshasattribute{\@glsentry}{entrycount}%
    {%
      \ifglsused{\@glsentry}%
      {%
        \immediate\write\@auxout
         {\string\@gls@entry@count{\@glsentry}{\glsentrycurrcount{\@glsentry}}}%
      }%
      {}%
      \advance\count@ by \@ne
    }%
    {}%
  }%
  \ifnum\count@=0
    \GlossariesExtraWarningNoLine{Entry counting has been enabled 
     \MessageBreak with \string\glsenableentrycount\space but the 
     \MessageBreak attribute `entrycount' hasn't 
     \MessageBreak been assigned to any of the defined
     \MessageBreak entries}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrifcounttrigger}
%\begin{definition}
%\cs{glsxtrifcounttrigger}\marg{label}\marg{trigger format}\marg{normal}
%\end{definition}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrifcounttrigger}[3]{%
 \glshasattribute{#1}{entrycount}%
 {%
   \ifnum\glsentryprevcount{#1}>\glsgetattribute{#1}{entrycount}\relax
    #3%
   \else
    #2%
   \fi
 }%
 {#3}% 
}
%    \end{macrocode}
%\end{macro}
%
% Actual internal definitions of \cs{cgls} used when entry counting
% is enabled.
%
%\begin{macro}{\@@cgls@}
%    \begin{macrocode}
\def\@@cgls@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cglsformat{#2}{#3}%
    \glsunset{#2}%
  }% 
  {%
    \@gls@{#1}{#2}[#3]%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@cgls@}
%    \begin{macrocode}
\def\@@cglspl@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cglsplformat{#2}{#3}%
    \glsunset{#2}%
  }%
  {%
    \@glspl@{#1}{#2}[#3]%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@cGls@}
%    \begin{macrocode}
\def\@@cGls@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cGlsformat{#2}{#3}%
    \glsunset{#2}%
  }%
  {%
    \@Gls@{#1}{#2}[#3]%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@cGlspl@}
%    \begin{macrocode}
\def\@@cGlspl@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cGlsplformat{#2}{#3}%
    \glsunset{#2}%
  }%
  {%
    \@Glspl@{#1}{#2}[#3]%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@cGLS@}
%    \begin{macrocode}
\def\@@cGLS@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cGLSformat{#2}{#3}%
    \glsunset{#2}%
  }% 
  {%
    \@GLS@{#1}{#2}[#3]%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@cGLSpl@}
%    \begin{macrocode}
\def\@@cGLSpl@#1#2[#3]{%
  \glsxtrifcounttrigger{#2}%
  {%
    \cGLSplformat{#2}{#3}%
    \glsunset{#2}%
  }%
  {%
    \@GLSpl@{#1}{#2}[#3]%
  }%
}%
%
% Remove default warnings from \cs{cgls} etc so that it can be used
% interchangeable with \cs{gls} etc.
%\begin{macro}{\@cgls@}
%    \begin{macrocode}
\def\@cgls@#1#2[#3]{\@gls@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@cGls@}
%    \begin{macrocode}
\def\@cGls@#1#2[#3]{\@Gls@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@cglspl@}
%    \begin{macrocode}
\def\@cglspl@#1#2[#3]{\@glspl@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@cGlspl@}
%    \begin{macrocode}
\def\@cGlspl@#1#2[#3]{\@Glspl@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
% Add all upper case versions not provided by \styfmt{glossaries}.
%\begin{macro}{\cGLS}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newrobustcmd*{\cGLS}{\@gls@hyp@opt\@cGLS}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@cGLS}
%\changes{0.5}{2015-12-07}{new}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@cGLS}[2][]{%
  \new@ifnextchar[{\@cGLS@{#1}{#2}}{\@cGLS@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@cGLS@}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\def\@cGLS@#1#2[#3]{\@GLS@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cGLSformat}
%\changes{0.5}{2015-12-07}{new}
% Format used by \cs{cGLS} if entry only used once on previous run.
% The first argument is the label, the second argument is the insert
% text.
%    \begin{macrocode}
\newcommand*{\cGLSformat}[2]{%
 \expandafter\mfirstucMakeUppercase\expandafter{\cglsformat{#1}{#2}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cGLSpl}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newrobustcmd*{\cGLSpl}{\@gls@hyp@opt\@cGLSpl}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@cGLSpl}
%\changes{0.5}{2015-12-07}{new}
% Defined the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\@cGLSpl}[2][]{%
  \new@ifnextchar[{\@cGLSpl@{#1}{#2}}{\@cGLSpl@{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@cGLSpl@}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\def\@cGLSpl@#1#2[#3]{\@GLSpl@{#1}{#2}[#3]}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cGLSplformat}
%\changes{0.5}{2015-12-07}{new}
% Format used by \cs{cGLSpl} if entry only used once on previous run.
% The first argument is the label, the second argument is the insert
% text.
%    \begin{macrocode}
\newcommand*{\cGLSplformat}[2]{%
 \expandafter\mfirstucMakeUppercase\expandafter{\cglsplformat{#1}{#2}}%
}
%    \end{macrocode}
%\end{macro}
%
% Modify the trigger formats to check for the \catattr{regular} attribute.
%\begin{macro}{\cglsformat}
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\renewcommand*{\cglsformat}[2]{%
  \glsifregular{#1}
  {\glsentryfirst{#1}}%
  {\ifglshaslong{#1}{\glsentrylong{#1}}{\glsentryfirst{#1}}}#2%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cGlsformat}
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\renewcommand*{\cGlsformat}[2]{%
  \glsifregular{#1}
  {\Glsentryfirst{#1}}%
  {\ifglshaslong{#1}{\Glsentrylong{#1}}{\Glsentryfirst{#1}}}#2%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cglsplformat}
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\renewcommand*{\cglsplformat}[2]{%
  \glsifregular{#1}
  {\glsentryfirstplural{#1}}%
  {\ifglshaslong{#1}{\glsentrylongpl{#1}}{\glsentryfirstplural{#1}}}#2%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\cGlsplformat}
%\changes{0.5.4}{2015-12-15}{added}
%    \begin{macrocode}
\renewcommand*{\cGlsplformat}[2]{%
  \glsifregular{#1}
  {\Glsentryfirstplural{#1}}%
  {\ifglshaslong{#1}{\Glsentrylongpl{#1}}{\Glsentryfirstplural{#1}}}#2%
}
%    \end{macrocode}
%\end{macro}
%
%New code similar to above for unit counting.
%
%\begin{macro}{\@@newglossaryentry@defunitcounters}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@@newglossaryentry@defunitcounters}{%
  \edef\@glo@countunit{\csuse{@glsxtr@categoryattr@@\@glo@category @unitcount}}%
  \ifdefvoid\@glo@countunit
  {}%
  {%
    \@glsxtr@ifunitcounter{\@glo@countunit}%
    {}%
    {\expandafter\@glsxtr@addunitcounter\expandafter{\@glo@countunit}}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@unitcountlist}
%\changes{0.5.4}{2015-12-15}{new}
% List to keep track of which counters are being used by the entry
% unit count facility.
%    \begin{macrocode}
\newcommand*{\@glsxtr@unitcountlist}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@addunitcounter}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@addunitcounter}[1]{%
 \listadd{\@glsxtr@unitcountlist}{#1}%
 \ifcsundef{glsxtr@theunit@#1}
 {%
   \ifcsdef{theH#1}%
   {\csdef{glsxtr@theunit@#1}{\csuse{theH#1}}}%
   {\csdef{glsxtr@theunit@#1}{\csuse{the#1}}}%
 }%
 {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@ifunitcounter}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@ifunitcounter}[3]{%
  \xifinlist{#1}{\@glsxtr@unitcountlist}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@currentunitcount}
%    \begin{macrocode}
\newcommand*\@glsxtr@currentunitcount[1]{%
 glo@\glsdetoklabel{#1}@currunit@\glsgetattribute{#1}{unitcount}.%
 \csuse{glsxtr@theunit@\glsgetattribute{#1}{unitcount}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@previousunitcount}
%    \begin{macrocode}
\newcommand*\@glsxtr@previousunitcount[1]{%
 glo@\glsdetoklabel{#1}@prevunit@\glsgetattribute{#1}{unitcount}.%
 \csuse{glsxtr@theunit@\glsgetattribute{#1}{unitcount}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@increment@currunitcount}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@gls@increment@currunitcount}[1]{%
  \glshasattribute{#1}{unitcount}%
  {%
    \edef\@glsxtr@csname{\@glsxtr@currentunitcount{#1}}%
    \ifcsundef{\@glsxtr@csname}%
    {%
      \csgdef{\@glsxtr@csname}{1}%
      \listcsxadd
       {glo@\glsdetoklabel{#1}@unitlist}%
       {\glsgetattribute{#1}{unitcount}.%
        \csuse{glsxtr@theunit@\glsgetattribute{#1}{unitcount}}%
       }%
    }%
    {%
      \csxdef{\@glsxtr@csname}%
      {\number\numexpr\csname\@glsxtr@csname\endcsname+1}%
    }%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@local@increment@currunitcount}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@gls@local@increment@currunitcount}[1]{%
  \glshasattribute{#1}{unitcount}%
  {%
    \edef\@glsxtr@csname{\@glsxtr@currentunitcount{#1}}%
    \ifcsundef{\@glsxtr@csname}%
    {%
      \csdef{\@glsxtr@csname}{1}%
      \listcseadd
       {glo@\glsdetoklabel{#1}@unitlist}%
       {\glsgetattribute{#1}{unitcount}.%
        \csuse{glsxtr@theunit@\glsgetattribute{#1}{unitcount}}%
       }%
    }%
    {%
      \csedef{\@glsxtr@csname}%
      {\number\numexpr\csname\@glsxtr@csname\endcsname+1}%
    }%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@currunitcount}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@currunitcount}[2]{%
 \ifcsundef
 {glo@\glsdetoklabel{#1}@currunit@#2}%
 {0}%
 {\csuse{glo@\glsdetoklabel{#1}@currunit@#2}}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@prevunitcount}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@prevunitcount}[2]{%
 \ifcsundef
 {glo@\glsdetoklabel{#1}@prevunit@#2}%
 {0}%
 {\csuse{glo@\glsdetoklabel{#1}@prevunit@#2}}%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsenableentryunitcount}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\glsenableentryunitcount}{%
%    \end{macrocode}
% Enable new fields:
%    \begin{macrocode}
  \appto\@newglossaryentry@defcounters{\@@newglossaryentry@defunitcounters}%
%    \end{macrocode}
% Just in case the user has switched on the \pkgopt{docdef} option.
%    \begin{macrocode}
  \renewcommand*{\gls@defdocnewglossaryentry}{%
    \renewcommand*\newglossaryentry[2]{%
      \PackageError{glossaries}{\string\newglossaryentry\space
      may only be used in the preamble when entry counting has
      been activated}{If you use \string\glsenableentryunitcount\space
      you must place all entry definitions in the preamble not in
      the document environment}%
    }%
  }%
%    \end{macrocode}
% New commands to access new fields:
%    \begin{macrocode}
  \newcommand*{\glsentrycurrcount}[1]{%
    \@glsxtr@currunitcount{##1}{\glsgetattribute{##1}{unitcount}.%
     \csuse{glsxtr@theunit@\glsgetattribute{##1}{unitcount}}}%
  }%
  \newcommand*{\glsentryprevcount}[1]{%
    \@glsxtr@prevunitcount{##1}{\glsgetattribute{##1}{unitcount}.%
     \csuse{glsxtr@theunit@\glsgetattribute{##1}{unitcount}}}%
  }%
%    \end{macrocode}
% Access total count:
%    \begin{macrocode}
  \newcommand*{\glsentryprevtotalcount}[1]{%
    \ifcsundef{glo@\glsdetoklabel{##1}@prevunittotal}%
    {0}%
    {%
      \number\csuse{glo@\glsdetoklabel{##1}@prevunittotal}
    }%
  }%
%    \end{macrocode}
% Access max value:
%    \begin{macrocode}
  \newcommand*{\glsentryprevmaxcount}[1]{%
    \ifcsundef{glo@\glsdetoklabel{##1}@prevunitmax}%
    {0}%
    {%
      \number\csuse{glo@\glsdetoklabel{##1}@prevunitmax}
    }%
  }%
%    \end{macrocode}
% Adjust post unset and reset:
%    \begin{macrocode}
  \let\@glsxtr@entryunitcount@org@unset\glsxtrpostunset
  \renewcommand*{\glsxtrpostunset}[1]{%
    \@glsxtr@entryunitcount@org@unset{##1}%
    \@gls@increment@currunitcount{##1}%
  }%
  \let\@glsxtr@entryunitcount@org@localunset\glsxtrpostlocalunset
  \renewcommand*{\glsxtrpostlocalunset}[1]{%
    \@glsxtr@entryunitcount@org@localunset{##1}%
    \@gls@local@increment@currunitcount{##1}%
  }%
  \let\@glsxtr@entryunitcount@org@reset\glsxtrpostreset
  \renewcommand*{\glsxtrpostreset}[1]{%
    \glshasattribute{##1}{unitcount}%
    {%
      \edef\@glsxtr@csname{\@glsxtr@currentunitcount{##1}}%
      \ifcsundef{\@glsxtr@csname}%
      {}%
      {\csgdef{\@glsxtr@csname}{0}}%
    }%
    {}%
  }%
  \let\@glsxtr@entryunitcount@org@localreset\glsxtrpostlocalreset
  \renewcommand*{\glsxtrpostlocalreset}[1]{%
    \@glsxtr@entryunitcount@org@localreset{##1}%
    \glshasattribute{##1}{unitcount}%
    {%
      \edef\@glsxtr@csname{\@glsxtr@currentunitcount{##1}}%
      \ifcsundef{\@glsxtr@csname}%
      {}%
      {\csdef{\@glsxtr@csname}{0}}%
    }%
    {}%
  }%
%    \end{macrocode}
% Modifications to take into account the attributes that govern
% whether the entry should be unset.
%    \begin{macrocode}
  \let\@cgls@\@@cgls@
  \let\@cglspl@\@@cglspl@
  \let\@cGLS@\@@cGLS@
  \let\@cGlspl@\@@cGlspl@
  \let\@cGLS@\@@cGLS@
  \let\@cGLSpl@\@@cGLSpl@
%    \end{macrocode}
% Write information to the aux file.
%    \begin{macrocode}
  \AtEndDocument{\@gls@write@entryunitcounts}%
  \renewcommand*{\@gls@entry@unitcount}[3]{%
    \csgdef{glo@\glsdetoklabel{##1}@prevunit@##3}{##2}%
    \ifcsundef{glo@\glsdetoklabel{##1}@prevunittotal}%
    {\csgdef{glo@\glsdetoklabel{##1}@prevunittotal}{##2}}%
    {%
      \csxdef{glo@\glsdetoklabel{##1}@prevunittotal}{
        \number\numexpr\csuse{glo@\glsdetoklabel{##1}@prevunittotal}+##2}%
    }%
    \ifcsundef{glo@\glsdetoklabel{##1}@prevunitmax}%
    {\csgdef{glo@\glsdetoklabel{##1}@prevunitmax}{##2}}%
    {%
      \ifnum\csuse{glo@\glsdetoklabel{##1}@prevunitmax}<##2
       \csgdef{glo@\glsdetoklabel{##1}@prevunitmax}{##2}%
      \fi
    }%
  }%
  \let\glsenableentryunitcount\relax
  \renewcommand*{\glsenableentrycount}{%
    \PackageError{glossaries-extra}{\string\glsenableentrycount\space
     can't be used with \string\glsenableentryunitcount}%
    {Use one or other but not both commands}%
  }%
}
\@onlypreamble\glsenableentryunitcount
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@entry@unitcount}
%    \begin{macrocode}
\newcommand*{\@gls@entry@unitcount}[3]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@write@entryunitcounts@do}
%    \begin{macrocode}
\newcommand*{\@gls@write@entryunitcounts@do}[1]{%
  \immediate\write\@auxout
   {\string\@gls@entry@unitcount
     {\@glsentry}%
     {\@glsxtr@currunitcount{\@glsentry}{#1}%
     }%
     {#1}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@write@entryunitcounts}
%    \begin{macrocode}
\newcommand*{\@gls@write@entryunitcounts}{%
  \immediate\write\@auxout
    {\string\providecommand*{\string\@gls@entry@unitcount}[3]{}}%
  \count@=0\relax
  \forallglsentries{\@glsentry}{%
    \glshasattribute{\@glsentry}{unitcount}%
    {%
      \ifglsused{\@glsentry}%
      {%
        \forlistcsloop
          {\@gls@write@entryunitcounts@do}%
          {glo@\glsdetoklabel{\@glsentry}@unitlist}%
      }%
      {}%
      \advance\count@ by \@ne
    }%
    {}%
  }%
  \ifnum\count@=0
    \GlossariesExtraWarningNoLine{Entry counting has been enabled 
     \MessageBreak with \string\glsenableentryunitcount\space but the 
     \MessageBreak attribute `unitcount' hasn't 
     \MessageBreak been assigned to any of the defined
     \MessageBreak entries}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrEnableEntryUnitCounting}
% The first argument is the list of categories, the second
% argument is the value of the \catattr{entrycount} attribute
% and the third is the counter name.
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrEnableEntryUnitCounting}[3]{%
%    \end{macrocode}
% Enable entry counting:
%    \begin{macrocode}
  \glsenableentryunitcount
%    \end{macrocode}
% Redefine \cs{gls} etc:
%    \begin{macrocode}
  \renewcommand*{\gls}{\cgls}%
  \renewcommand*{\Gls}{\cGls}%
  \renewcommand*{\glspl}{\cglspl}%
  \renewcommand*{\Glspl}{\cGlspl}%
  \renewcommand*{\GLS}{\cGLS}%
  \renewcommand*{\GLSpl}{\cGLSpl}%
%    \end{macrocode}
% Set the \catattr{entrycount} attribute:
%    \begin{macrocode}
  \@glsxtr@setentryunitcountunsetattr{#1}{#2}{#3}%
%    \end{macrocode}
% In case this command is used again:
%    \begin{macrocode}
  \let\GlsXtrEnableEntryUnitCounting\@glsxtr@setentryunitcountunsetattr
  \renewcommand*{\GlsXtrEnableEntryCounting}[2]{%
   \PackageError{glossaries-extra}{\string\GlsXtrEnableEntryCounting\space
    can't be used with \string\GlsXtrEnableEntryUnitCounting}%
   {Use one or other but not both commands}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@setentryunitcountunsetattr}
%\changes{0.5.4}{2015-12-15}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@setentryunitcountunsetattr}[3]{%
 \@for\@glsxtr@cat:=#1\do
 {%
   \ifdefempty{\@glsxtr@cat}{}%
   {%
     \glssetcategoryattribute{\@glsxtr@cat}{entrycount}{#2}%
     \glssetcategoryattribute{\@glsxtr@cat}{unitcount}{#3}%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%
%\subsection{Acronym Modifications}
% It's more consistent to use the abbreviation code for acronyms,
% but make some adjustments to allow for continued use of the
% \styfmt{glossaries} package's custom acronym format. (For example,
% user may already have defined some acronym styles with
% \cs{newacronymstyle} which they would like to continue to use.)
% The original \styfmt{glossaries} acronym code can be restored 
% with \cs{RestoreAcronyms}, but adjust \cs{SetGenericNewAcronym} 
% so that \cs{newacronym} adds the category.
%
%\begin{macro}{\SetGenericNewAcronym}
%    \begin{macrocode}
\renewcommand*{\SetGenericNewAcronym}{%
  \let\@Gls@entryname\@Gls@acrentryname
  \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},%
        category=acronym,
        \GenericAcronymFields,%
        \the\glskeylisttok
      }%
    }%
    \@do@newglossaryentry
  }%
  \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}}}}%
  \renewcommand*{\glsentryfull}[1]{\genacrfullformat{##1}{}}%
  \renewcommand*{\Glsentryfull}[1]{\Genacrfullformat{##1}{}}%
  \renewcommand*{\glsentryfullpl}[1]{\genplacrfullformat{##1}{}}%
  \renewcommand*{\Glsentryfullpl}[1]{\Genplacrfullformat{##1}{}}%
}
%    \end{macrocode}
%\end{macro}
%
% This will cause a problem for glossaries that contain a mixture of
% acronyms and abbreviations, so redefine \cs{newacronym} to use the
% new abbreviation interface.
%
% First save the original definitions:
%    \begin{macrocode}
\let\@glsxtr@org@setacronymstyle\setacronymstyle
\let\@glsxtr@org@newacronymstyle\newacronymstyle
%    \end{macrocode}
%
%\begin{macro}{\MakeAcronymsAbbreviations}
% Make acronyms use the same interface as abbreviations.
% Note that \cs{newacronymstyle} has a different implementation to
% \cs{newabbrevationstyle} so disable \cs{newacronymstyle} and
% \cs{setacronymstyle}.
%\changes{0.4}{2015-12-03}{set the default type to \cs{acronymtype}}
%\changes{0.5.4}{2015-12-15}{now disables \cs{setacronymstyle}}
%    \begin{macrocode}
\newcommand*{\MakeAcronymsAbbreviations}{%
   \renewcommand*{\newacronym}[4][]{%
     \newabbreviation[type=\acronymtype,category=acronym,##1]{##2}{##3}{##4}%
   }%
   \renewcommand*{\firstacronymfont}[1]{\glsfirstabbrvfont{##1}}%
   \renewcommand*{\acronymfont}[1]{\glsabbrvfont{##1}}%
   \renewcommand*{\setacronymstyle}[1]{%
      \PackageError{glossaries-extra}{\string\setacronymstyle{##1}
      unavailable.
      Use \string\setabbreviationstyle\space instead.
      The original acronym interface can be restored with
      \string\RestoreAcronyms}{}%
   }%
   \renewcommand*{\newacronymstyle}[1]{%
      \GlossariesExtraWarning{New acronym style `##1' won't be
      available unless you restore the original acronym interface with
      \string\RestoreAcronyms}%
      \@glsxtr@org@newacronymstyle{##1}%
   }%
}
%    \end{macrocode}
%\end{macro}
%
% Switch acronyms to abbreviations:
%    \begin{macrocode}
\MakeAcronymsAbbreviations
%    \end{macrocode}
%
%\begin{macro}{\RestoreAcronyms}
% Restore acronyms to \styfmt{glossaries} interface.
%    \begin{macrocode}
\newcommand*{\RestoreAcronyms}{%
  \SetGenericNewAcronym
  \renewcommand{\firstacronymfont}[1]{\acronymfont{##1}}%
  \renewcommand{\acronymfont}[1]{##1}%
  \let\setacronymstyle\@glsxtr@org@setacronymstyle
  \let\newacronymstyle\@glsxtr@org@newacronymstyle
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{modified \cs{@gls@link@checkfirsthyper} to set
%\cs{glsxtrifwasfirstuse}}
% Need to restore the original definition of \cs{@gls@link@checkfirsthyper}
% but \cs{glsxtrifwasfirstuse} still needs setting for the benefit
% of the post-link hook.
%    \begin{macrocode}
  \renewcommand*\@gls@link@checkfirsthyper{%
    \ifglsused{\glslabel}%
    {\let\glsxtrifwasfirstuse\@secondoftwo}
    {\let\glsxtrifwasfirstuse\@firstoftwo}%
    \@glsxtr@org@checkfirsthyper
  }
  \glssetcategoryattribute{acronym}{regular}{false}%
  \setacronymstyle{long-short}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsacspace}
% Allow the user to customise the maximum value.
%    \begin{macrocode}
\renewcommand*{\glsacspace}[1]{%
  \settowidth{\dimen@}{(\firstacronymfont{\glsentryshort{#1}})}%
  \ifdim\dimen@<\glsacspacemax~\else\space\fi
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsacspacemax}
% Value used in the above.
%    \begin{macrocode}
\newcommand*{\glsacspacemax}{3em}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Indexing and Displaying Glossaries}
%From time-to-time users ask if they can have one glossary sorted
%normally and another sorted by definition or usage. With the
% base \styfmt{glossaries} package this can only be achieved with the
% \qt{noidx} commands (Option~1). This is an attempt to mix and
% match.
%
%First we need a list of the glossaries that require
%\gls{makeindex}\slash\gls{xindy}.
%\begin{macro}{\@glsxtr@reg@glosslist}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@reg@glosslist}{}
%    \end{macrocode}
%\end{macro}
% Save the original definition of \cs{makeglossaries}:
%    \begin{macrocode}
\let\@glsxtr@org@makeglossaries\makeglossaries
%    \end{macrocode}
%
% Redefine \cs{makeglossaries} to take an optional argument.
% This should be empty for the usual behaviour (all glossaries
% need processing with an indexing application) or a comma-separated
% list of glossary labels indicating those glossaries that should be
% processed with an indexing application.
%\begin{macro}{\makeglossaries}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\renewcommand*{\makeglossaries}[1][]{%
 \ifblank{#1}%
 {\@glsxtr@org@makeglossaries}%
 {%
   \edef\@glsxtr@reg@glosslist{#1}%
   \ifundef{\glswrite}{\newwrite\glswrite}{}%
   \protected@write\@auxout{}{\string\providecommand
     \string\@glsorder[1]{}}
   \protected@write\@auxout{}{\string\providecommand
     \string\@istfilename[1]{}}
   \protected@write\@auxout{}{\string\@istfilename{\istfilename}}%
   \protected@write\@auxout{}{\string\@glsorder{\glsorder}}
   \protected@write\@auxout{}{\string\glsxtr@makeglossaries{#1}}
   \write\@auxout{\string\providecommand\string\@gls@reference[3]{}}%
%    \end{macrocode}
% Iterate through each supplied glossary type and activate it.
%    \begin{macrocode}
   \@for\@glo@type:=#1\do{%
    \ifdefempty{\@glo@type}{}{\@makeglossary{\@glo@type}}%
   }%
%    \end{macrocode}
% New glossaries must be created before \cs{makeglossaries}:
%    \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
  \renewcommand\makeglossaries[1][]{}%
%    \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}
%Adjust \cs{@do@seeglossary}
%    \begin{macrocode}
  \let\@glsxtr@org@doseeglossary\@do@seeglossary
  \renewcommand*{\@do@seeglossary}[2]{%
    \edef\@gls@label{\glsdetoklabel{##1}}%
    \edef\@gls@type{\csname glo@\@gls@label @type\endcsname}%
    \expandafter\DTLifinlist\expandafter{\@gls@type}{\@glsxtr@reg@glosslist}%
    {\@glsxtr@org@doseeglossary{##1}{##2}}%
    {%
      \protected@write\@auxout{}{%
        \string\@gls@reference
          {\gls@type}{\@gls@label}{\string\glsseeformat##2{}}%
      }%
    }%
  }%
%    \end{macrocode}
% Adjust \cs{@@do@@wrglossary}
%    \begin{macrocode}
  \let\@glsxtr@@do@@wrglossary\@@do@@wrglossary
  \def\@@do@@wrglossary{%
    \edef\@gls@type{\csname glo@\@gls@label @type\endcsname}%
    \expandafter\DTLifinlist\expandafter{\@gls@type}{\@glsxtr@reg@glosslist}%
    {\@glsxtr@@do@@wrglossary}%
    {\gls@noidxglossary}%
  }%
%    \end{macrocode}
% Suppress warning about no \cs{makeglossaries}
%    \begin{macrocode}
  \let\warn@nomakeglossaries\relax
  \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}
% Only warn for glossaries not listed.
%    \begin{macrocode}
  \renewcommand{\@gls@noref@warn}[1]{%
    \edef\@gls@type{##1}%
    \expandafter\DTLifinlist\expandafter{\@gls@type}{\@glsxtr@reg@glosslist}%
    {%
      \GlossariesExtraWarning{Can't use
         \string\printnoidxglossary[type={\@gls@type}]
         when `\@gls@type' is listed in the optional argument of
         \string\makeglossaries}%
    }%
    {%
      \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}
% Adjust display number list to check for type:
%    \begin{macrocode}
  \renewcommand*{\glsdisplaynumberlist}[1]{%
    \expandafter\DTLifinlist\expandafter{##1}{\@glsxtr@reg@glosslist}%
    {\@glsxtr@idx@displaynumberlist{##1}}%
    {\@glsxtr@noidx@displaynumberlist{##1}}%
  }%
%    \end{macrocode}
% Adjust entry list:
%    \begin{macrocode}
  \renewcommand*{\glsentrynumberlist}[1]{%
    \expandafter\DTLifinlist\expandafter{##1}{\@glsxtr@reg@glosslist}%
    {\@glsxtr@idx@entrynumberlist{##1}}%
    {\@glsxtr@noidx@entrynumberlist{##1}}%
  }%
%    \end{macrocode}
% Adjust number list loop
%    \begin{macrocode}
  \renewcommand*{\glsnumberlistloop}[2]{%
    \expandafter\DTLifinlist\expandafter{##1}{\@glsxtr@reg@glosslist}%
    {%
       \PackageError{glossaries-extra}{\string\glsnumberlistloop\space
        not available for glossary `##1'}{}%
    }%
    {\@glsxtr@noidx@numberlistloop{##1}{##2}}%
  }%
%    \end{macrocode}
% Only sanitize sort for normal indexing glossaries.
%    \begin{macrocode}
  \renewcommand*{\glsprestandardsort}[3]{%
    \expandafter\DTLifinlist\expandafter{##2}{\@glsxtr@reg@glosslist}%
    {%
      \glsdosanitizesort
    }%
    {%
      \ifglssanitizesort
       \@gls@noidx@sanitizesort
      \else
       \@gls@noidx@nosanitizesort
      \fi
    }%
  }%
%    \end{macrocode}
% Unlike \cs{makenoidxglossaries} we can't automatically set
% sanitizesort=false. All entries must be defined in the preamble.
%    \begin{macrocode}
  \renewcommand*\new@glossaryentry[2]{%
    \PackageError{glossaries-extra}{Glossary entries must be defined
     in the preamble\MessageBreak when you use the optional argument
     of \string\makeglossaries}{Either move your definitions to the
     preamble or don't use the optional argument of
     \string\makeglossaries}%
  }%
%    \end{macrocode}
% Only activate sort key for glossaries that aren't listed in
% \verb|#1| (glossary label is stored in \cs{@glo@type} but this
% defaults to \cs{glsdefaulttype} so some expansion is required).
%    \begin{macrocode}
  \let\@glo@assign@sortkey\@glsxtr@mixed@assign@sortkey
  \renewcommand*{\@printgloss@setsort}{%
%    \end{macrocode}
% Need to extract just the \gloskey[printglossary]{type} value.
%    \begin{macrocode}
    \expandafter\@glsxtr@gettype\expandafter,\@glsxtr@printglossopts,%
      type=\glsdefaulttype,\@end@glsxtr@gettype
    \def\@glo@sorttype{\@glo@default@sorttype}%
  }%
%    \end{macrocode}
% Check \pkgopt{automake} setting:
%    \begin{macrocode}
    \ifglsautomake
      \renewcommand*{\@gls@doautomake}{%
        \@for\@gls@type:=\@glsxtr@reg@glosslist\do{%
          \ifdefempty{\@gls@type}{}{\@gls@automake{\@gls@type}}%
        }%
      }%
    \fi
 }%
}
%    \end{macrocode}
%\end{macro}
%
%The optional argument version of \cs{makeglossaries} needs an
%adjustment to \cs{@printglossary} to allow \cs{@glo@assign@sortkey}
%to pick up the glossary type.
%
%\begin{macro}{\@glsxtr@orgprintglossary}
%Save original definition (also needed for the on-the-fly macro).
%    \begin{macrocode}
\let\@glsxtr@orgprintglossary\@printglossary
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@printglossary}
%Redefine.
%\changes{1.09}{2016-12-16}{redefined to save options}
%    \begin{macrocode}
\renewcommand{\@printglossary}[2]{%
  \def\@glsxtr@printglossopts{#1}%
  \@glsxtr@orgprintglossary{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@makeglossaries}
%For the benefit of \app{makeglossaries}
%\changes{1.09}{2016-12-16}{new}
%    \begin{macrocode}
\newcommand*{\glsxtr@makeglossaries}[1]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@gettype}
%Get just the type.
%\changes{1.09}{2016-12-16}{new}
%    \begin{macrocode}
\def\@glsxtr@gettype#1,type=#2,#3\@end@glsxtr@gettype{%
  \def\@glo@type{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@mixed@assign@sortkey}
%Assign the sort key.
%\changes{1.09}{2016-12-16}{new}
%    \begin{macrocode}
\newcommand\@glsxtr@mixed@assign@sortkey[1]{%
  \edef\@glo@type{\@glo@type}%
  \expandafter\DTLifinlist\expandafter{\@glo@type}{\@glsxtr@reg@glosslist}%
  {%
    \@glo@no@assign@sortkey{#1}%
  }%
  {%
    \@@glo@assign@sortkey{#1}%
  }%
}%
%    \end{macrocode}
%\end{macro}
% Display number list for the regular version:
%\begin{macro}{\@glsxtr@idx@displaynumberlist}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\let\@glsxtr@idx@displaynumberlist\glsdisplaynumberlist
%    \end{macrocode}
%\end{macro}
%
% Display number list for the \qt{noidx} version:
%\begin{macro}{\@glsxtr@noidx@displaynumberlist}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@noidx@displaynumberlist}[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
  }%
  {%
    ??\glsdoifexists{#1}%
    {%
      \GlossariesWarning{Missing location list for `#1'. Either
        a rerun is required or you haven't referenced the entry.}%
    }%
  }%
}%

%    \end{macrocode}
%\end{macro}
%And for the number list loop:
%\begin{macro}{\@glsxtr@noidx@numberlistloop}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@noidx@numberlistloop}[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}%
  }%
  {%
    ??\glsdoifexists{#1}%
    {%
      \GlossariesWarning{Missing location list for `##1'. Either
        a rerun is required or you haven't referenced the entry.}%
    }%
  }%
  \let\glsnoidxdisplayloc\@gls@org@glsnoidxdisplayloc
  \let\glsseeformat\@gls@org@glsseeformat
}%
%    \end{macrocode}
%\end{macro}
%
%Same for entry number list.
%\begin{macro}{\@glsxtr@noidx@entrynumberlist}
%\changes{1.0}{2016-01-24}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@noidx@entrynumberlist}[1]{%
  \letcs{\@gls@loclist}{glo@\glsdetoklabel{#1}@loclist}%
  \ifdef\@gls@loclist
  {%
    \glsnoidxloclist{\@gls@loclist}%
  }%
  {%
    ??\glsdoifexists{#1}%
    {%
      \GlossariesWarning{Missing location list for `#1'. Either
        a rerun is required or you haven't referenced the entry.}%
    }%
  }%
}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@idx@entrynumberlist}
%\changes{1.0}{2016-01-24}{new}
%\changes{1.04}{2016-05-02}{switched from \cs{let} to \cs{newcommand}}
%    \begin{macrocode}
\newcommand*{\@glsxtr@idx@entrynumberlist}[1]{\glsentrynumberlist{#1}}
%    \end{macrocode}
%\end{macro}
%
% Give a bit of assistance to new users who are confused and don't
% know how to read transcript messages.
%\begin{macro}{\@print@glossary}
%\changes{0.3}{2015-12-02}{added redefinition}
%    \begin{macrocode}
\renewcommand{\@print@glossary}{%
  \makeatletter
  \@input@{\jobname.\csname @glotype@\@glo@type @in\endcsname}%
  \IfFileExists{\jobname.\csname @glotype@\@glo@type @in\endcsname}%
  {}%
  {\glsxtrNoGlossaryWarning{\@glo@type}}%
  \ifglsxindy
    \ifcsundef{@xdy@\@glo@type @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}{\@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{%
         \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
  \renewcommand*{\@warn@nomakeglossaries}{%
    \GlossariesWarningNoLine{\string\makeglossaries\space
    hasn't been used,^^Jthe glossaries will not be updated}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% Setup the warning text to display if the external file for the given
% glossary is missing.
%
%\begin{macro}{\GlsXtrNoGlsWarningHead}
% Header message.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningHead}[2]{%
 This document is incomplete. The external file associated with
 the glossary `#1' (which should be called \texttt{#2})
 hasn't been created.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningEmptyStart}
% No entries have been added to the glossary.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningEmptyStart}{%
  This has probably happened because there are no entries defined 
  in this glossary.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningEmptyMain}
% The default \qt{main} glossary is empty.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningEmptyMain}{%
 If you don't want this glossary,
 add \texttt{nomain} to your package option list when you load
 \texttt{glossaries-extra.sty}. For example:%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningEmptyNotMain}
% A glossary that isn't the default \qt{main} glossary is empty.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningEmptyNotMain}[1]{%
 Did you forget to use \texttt{type=#1} when you defined your
 entries? If you tried to load entries into this glossary with
 \texttt{\string\loadglsentries} did you remember to use
 \texttt{[#1]} as the optional argument? If you did, check that
 the definitions in the file you loaded all had the type set
 to \texttt{\string\glsdefaulttype}.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningCheckFile}
% Advisory message to check the file contents.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningCheckFile}[1]{%
  Check the contents of the file \texttt{#1}. If
  it's empty, that means you haven't indexed any of your entries in this
  glossary (using commands like \texttt{\string\gls} or
  \texttt{\string\glsadd}) so this list can't be generated.
  If the file isn't empty, the document build process hasn't been
  completed.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningAutoMake}
% Message when \pkgopt{automake} option has been used.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningAutoMake}[1]{%
  You may need to rerun \LaTeX. If you already have, it may be that
  \TeX's shell escape doesn't allow you to run
  \ifglsxindy xindy\else makeindex\fi. Check the
  transcript file \texttt{\jobname.log}. If the shell escape is
  disabled, try one of the following:

  \begin{itemize}
    \item Run the external (Lua) application:

       \texttt{makeglossaries-lite.lua \string"\jobname\string"}

    \item Run the external (Perl) application:

       \texttt{makeglossaries \string"\jobname\string"}
  \end{itemize}
  
  Then rerun \LaTeX\ on this document.
  \GlossariesExtraWarning{Rerun required to build the 
  glossary `#1' or check TeX's shell escape allows
  you to run \ifglsxindy xindy\else makeindex\fi}%
}
%    \end{macrocode}
%\end{macro}
%
%\changes{0.5.3}{2015-12-09}{removed \cs{GlsXtrNoGlsWarningNoAutoMakeMain}}
%
%\begin{macro}{\GlsXtrNoGlsWarningMisMatch}
% Mismatching \cs{makenoidxglossaries}.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningMisMatch}{%
  You need to either replace \texttt{\string\makenoidxglossaries}
  with \texttt{\string\makeglossaries} or replace
  \texttt{\string\printglossary} (or \texttt{\string\printglossaries}) with
  \texttt{\string\printnoidxglossary}
  (or \texttt{\string\printnoidxglossaries}) and then rebuild
  this document.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningBuildInfo}
% Build advice.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningBuildInfo}{%
  Try one of the following:
  \begin{itemize}
    \item Add \texttt{automake} to your package option list when you load
          \texttt{glossaries-extra.sty}. For example:

          \texttt{\string\usepackage[automake]%
              \glsopenbrace glossaries-extra\glsclosebrace}

    \item Run the external (Lua) application:

          \texttt{makeglossaries-lite.lua \string"\jobname\string"}

    \item Run the external (Perl) application:

          \texttt{makeglossaries \string"\jobname\string"}
  \end{itemize}
  
  Then rerun \LaTeX\ on this document.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningTail}
% Final paragraph.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningTail}{%
 This message will be removed once the problem has been fixed.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrNoGlsWarningNoOut}
% No out file created.
% Build advice.
%    \begin{macrocode}
\newcommand{\GlsXtrNoGlsWarningNoOut}[1]{%
  The file \texttt{#1} doesn't exist. This most likely means you haven't used
  \texttt{\string\makeglossaries} or you have used
  \texttt{\string\nofiles}. If this is just a draft version of the
  document, you can suppress this message using the 
  \texttt{nomissingglstext} package option.%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@defaultnoglossarywarning}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@defaultnoglossarywarning}[1]{%
 \glossarysection[\glossarytoctitle]{\glossarytitle}
 \GlsXtrNoGlsWarningHead{#1}{\jobname.\csname @glotype@\@glo@type @in\endcsname}
 \par
 \glsxtrifemptyglossary{#1}%
 {%
    \GlsXtrNoGlsWarningEmptyStart\space
    \ifthenelse{\equal{#1}{main}}{\GlsXtrNoGlsWarningEmptyMain\par
    \medskip
    \noindent\texttt{\string\usepackage[nomain\ifglsacronym ,acronym\fi]%
        \glsopenbrace glossaries-extra\glsclosebrace}
    \medskip
    }%
    {\GlsXtrNoGlsWarningEmptyNotMain{#1}}%
 }%
 {%
   \IfFileExists{\jobname.\csname @glotype@\@glo@type @out\endcsname}
   {%
     \GlsXtrNoGlsWarningCheckFile
       {\jobname.\csname @glotype@\@glo@type @out\endcsname}

     \ifglsautomake
 
      \GlsXtrNoGlsWarningAutoMake{#1}

     \else

        \ifthenelse{\equal{#1}{main}}%
        {%
          \GlsXtrNoGlsWarningEmptyMain\par
          \medskip
          \noindent\texttt{\string\usepackage[nomain]%
            \glsopenbrace glossaries-extra\glsclosebrace}
          \medskip
        }%
        {}%

        \ifdefequal\makeglossaries\@no@makeglossaries
        {%
          \GlsXtrNoGlsWarningMisMatch
        }%
        {%
          \GlsXtrNoGlsWarningBuildInfo
        }%
     \fi
   }%
   {%
     \GlsXtrNoGlsWarningNoOut
       {\jobname.\csname @glotype@\@glo@type @out\endcsname}%
   }%
 }%
 \par
 \GlsXtrNoGlsWarningTail
}
%    \end{macrocode}
%\end{macro}
%
%Provide some commands to accompany the \pkgopt{record} option.
%\begin{macro}{\glsxtrresourcefile}
%\changes{1.08}{2016-12-13}{new}
%This is provided for the benefit of any external helper
%application.
%    \begin{macrocode}
\newcommand*{\glsxtrresourcefile}[2][]{%
  \protected@write\@auxout{}{\string\glsxtr@resource{#1}{#2}}%
  \InputIfFileExists{#2}{}%
  {%
    \GlossariesExtraWarning{No file `#2'}% 
  }%
}
\@onlypreamble\glsxtrresourcefile
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@resource}
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\glsxtr@resource}[2]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\printunsrtglossary}
%\changes{1.08}{2016-12-13}{new}
%Similar to \cs{printnoidxglossary} but it displays all entries
%defined for the given glossary without sorting.
%    \begin{macrocode}
\newcommand*{\printunsrtglossary}[1][type=\glsdefaulttype]{%
  \@printglossary{#1}{\@print@unsrt@glossary}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\printunsrtglossaries}
%\changes{1.08}{2016-12-13}{new}
%Similar to \cs{printnoidxglossaries} but it displays all entries
%defined for the given glossary without sorting.
%    \begin{macrocode}
\newcommand*{\printunsrtglossaries}{%
  \forallglossaries{\@@glo@type}{\printunsrtglossary[type=\@@glo@type]}%
}
%    \end{macrocode}
%\end{macro}

%\begin{macro}{\@print@unsrt@glossary}
%\changes{1.08}{2016-12-13}{new}
%    \begin{macrocode}
\newcommand*{\@print@unsrt@glossary}{%
  \glossarysection[\glossarytoctitle]{\glossarytitle}%
  \glossarypreamble
%    \end{macrocode}
%check for empty list
%    \begin{macrocode}
  \ifcsempty{glolist@\@glo@type}
  {%
     \GlossariesExtraWarning{No entries defined in glossary `\@glo@type'}% 
  }%
  {%
    \begin{theglossary}%
    \glossaryheader
    \glsresetentrylist
    \def\@gls@currentlettergroup{}%
    \expandafter\@for\expandafter\glscurrententrylabel\expandafter
      :\expandafter=\csname glolist@\@glo@type\endcsname\do{%
      \ifdefempty{\glscurrententrylabel}
      {}%
      {\@gls@noidx@do\glscurrententrylabel}%
    }%
    \end{theglossary}%
  }%
  \glossarypostamble
}
%    \end{macrocode}
%\end{macro}
%
%\section{Integration with glossaries-accsupp}
% Provide better integration with the \sty{glossaries-accsupp}
% package. (Must be loaded before the main code of
% \styfmt{glossaries-extra} either explicitly or through the
% \pkgopt{accsupp} package option.)
%
% These commands have their definitions set according to whether
% or not \styfmt{glossaries-extra} has been loaded.
%\changes{0.5.2}{2015-12-08}{fixed typo in glossaries-accsupp and tidied up code to use
% just one \cs{@ifpackageloaded}}
%    \begin{macrocode}
\@ifpackageloaded{glossaries-accsupp}
{
%    \end{macrocode}
% Define (or redefine) commands to use the accessibility
% information.
%\begin{macro}{\glsaccessname}
% Display the \gloskey{name} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessname}[1]{%
    \glsnameaccessdisplay
    {%
      \glsentryname{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessname}
% Display the \gloskey{name} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessname}[1]{%
    \glsnameaccessdisplay
    {%
      \Glsentryname{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessname}
% Display the \gloskey{name} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessname}[1]{%
    \glsnameaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryname{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesstext}
% Display the \gloskey{text} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccesstext}[1]{%
    \glstextaccessdisplay
    {%
      \glsentrytext{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesstext}
% Display the \gloskey{text} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccesstext}[1]{%
    \glstextaccessdisplay
    {%
      \Glsentrytext{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesstext}
% Display the \gloskey{text} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesstext}[1]{%
    \glstextaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrytext{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessplural}[1]{%
    \glspluralaccessdisplay
    {%
      \glsentryplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessplural}[1]{%
    \glspluralaccessdisplay
    {%
      \Glsentryplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessplural}[1]{%
    \glspluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryplural{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessfirst}[1]{%
    \glsfirstaccessdisplay
    {%
      \glsentryfirst{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessfirst}[1]{%
    \glsfirstaccessdisplay
    {%
      \Glsentryfirst{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessfirst}[1]{%
    \glsfirstaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryfirst{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessfirstplural}[1]{%
    \glsfirstpluralaccessdisplay
    {%
      \glsentryfirstplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessfirstplural}[1]{%
    \glsfirstpluralaccessdisplay
    {%
      \Glsentryfirstplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessfirstplural}[1]{%
    \glsfirstpluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryfirstplural{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccesssymbol}[1]{%
    \glssymbolaccessdisplay
    {%
      \glsentrysymbol{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccesssymbol}[1]{%
    \glssymbolaccessdisplay
    {%
      \Glsentrysymbol{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesssymbol}[1]{%
    \glssymbolaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrysymbol{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccesssymbolplural}[1]{%
    \glssymbolpluralaccessdisplay
    {%
      \glsentrysymbolplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccesssymbolplural}[1]{%
    \glssymbolpluralaccessdisplay
    {%
      \Glsentrysymbolplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesssymbolplural}[1]{%
    \glssymbolpluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrysymbolplural{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessdesc}[1]{%
    \glsdescriptionaccessdisplay
    {%
      \glsentrydesc{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessdesc}[1]{%
    \glsdescriptionaccessdisplay
    {%
      \Glsentrydesc{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessdesc}[1]{%
    \glsdescriptionaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrydesc{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessdescplural}[1]{%
    \glsdescriptionpluralaccessdisplay
    {%
      \glsentrydescplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessdescplural}[1]{%
    \glsdescriptionpluralaccessdisplay
    {%
      \Glsentrydescplural{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessdescplural}[1]{%
    \glsdescriptionpluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrydescplural{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessshort}
% Display the short form (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessshort}[1]{%
    \glsshortaccessdisplay
    {%
      \glsentryshort{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessshort}
% Display the short form with first letter converted to uppercase
% (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessshort}[1]{%
    \glsshortaccessdisplay
    {%
      \Glsentryshort{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessshort}
% Display the \gloskey{short} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessshort}[1]{%
    \glsshortaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryshort{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessshortpl}
% Display the short plural form (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccessshortpl}[1]{%
    \glsshortpluralaccessdisplay
    {%
      \glsentryshortpl{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessshortpl}
% Display the short plural form with first letter converted to
% uppercase (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\Glsaccessshortpl}[1]{%
    \glsshortpluralaccessdisplay
    {%
      \Glsentryshortpl{#1}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessshortpl}
% Display the \gloskey{shortplural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessshortpl}[1]{%
    \glsshortpluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentryshortpl{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesslong}
% Display the long form (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccesslong}[1]{%
    \glslongaccessdisplay{\glsentrylong{#1}}{#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesslong}
% Display the long form (no link and no check for existence).
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}

  \newcommand*{\Glsaccesslong}[1]{%
    \glslongaccessdisplay{\Glsentrylong{#1}}{#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesslong}
% Display the \gloskey{long} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesslong}[1]{%
    \glslongaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrylong{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesslongpl}
% Display the long plural form (no link and no check for existence).
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\glsaccesslongpl}[1]{%
    \glslongpluralaccessdisplay{\glsentrylongpl{#1}}{#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesslongpl}
% Display the long plural form (no link and no check for existence).
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}

  \newcommand*{\Glsaccesslongpl}[1]{%
    \glslongpluralaccessdisplay{\Glsentrylongpl{#1}}{#1}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesslongpl}
% Display the \gloskey{longplural} value (no link and no check for existence)
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesslongpl}[1]{%
    \glslongpluralaccessdisplay
    {%
      \mfirstucMakeUppercase{\glsentrylongpl{#1}}%
    }%
    {#1}%
  }
%    \end{macrocode}
%\end{macro}
%
% End of if part
%    \begin{macrocode}
}
{
%    \end{macrocode}
% No accessibility support. Just define these commands to do 
% \cs{glsentry}\meta{xxx}
%\begin{macro}{\glsaccessname}
% Display the \gloskey{name} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessname}[1]{\glsentryname{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessname}
% Display the \gloskey{name} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessname}[1]{\Glsentryname{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessname}
% Display the \gloskey{name} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessname}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryname{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesstext}
% Display the \gloskey{text} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccesstext}[1]{\glsentrytext{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesstext}
% Display the \gloskey{text} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccesstext}[1]{\Glsentrytext{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesstext}
% Display the \gloskey{text} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesstext}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrytext{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessplural}[1]{\glsentryplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessplural}[1]{\Glsentryplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessplural}
% Display the \gloskey{plural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessplural}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryplural{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessfirst}[1]{\glsentryfirst{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessfirst}[1]{\Glsentryfirst{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessfirst}
% Display the \gloskey{first} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessfirst}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryfirst{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessfirstplural}[1]{\glsentryfirstplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessfirstplural}[1]{\Glsentryfirstplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessfirstplural}
% Display the \gloskey{firstplural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessfirstplural}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryfirstplural{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccesssymbol}[1]{\glsentrysymbol{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccesssymbol}[1]{\Glsentrysymbol{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesssymbol}
% Display the \gloskey{symbol} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesssymbol}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrysymbol{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccesssymbolplural}[1]{\glsentrysymbolplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccesssymbolplural}[1]{\Glsentrysymbolplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesssymbolplural}
% Display the \gloskey{symbolplural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesssymbolplural}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrysymbolplural{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessdesc}[1]{\glsentrydesc{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessdesc}[1]{\Glsentrydesc{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessdesc}
% Display the \gloskey{desc} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessdesc}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrydesc{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessdescplural}[1]{\glsentrydescplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence)
% with the first letter converted to upper case.
%    \begin{macrocode}
  \newcommand*{\Glsaccessdescplural}[1]{\Glsentrydescplural{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessdescplural}
% Display the \gloskey{descplural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessdescplural}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrydescplural{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessshort}
% Display the short form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessshort}[1]{\glsentryshort{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessshort}
% Display the short form with first letter converted to uppercase
% (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\Glsaccessshort}[1]{\Glsentryshort{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessshort}
% Display the \gloskey{short} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessshort}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryshort{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccessshortpl}
% Display the short plural form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccessshortpl}[1]{\glsentryshortpl{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccessshortpl}
% Display the short plural form with first letter converted to
% uppercase (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\Glsaccessshortpl}[1]{\Glsentryshortpl{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccessshortpl}
% Display the \gloskey{shortplural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccessshortpl}[1]{%
   \protect\mfirstucMakeUppercase{\glsentryshortpl{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesslong}
% Display the long form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccesslong}[1]{\glsentrylong{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesslong}
% Display the long form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\Glsaccesslong}[1]{\Glsentrylong{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesslong}
% Display the \gloskey{long} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesslong}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrylong{#1}}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsaccesslongpl}
% Display the long plural form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\glsaccesslongpl}[1]{\glsentrylongpl{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsaccesslongpl}
% Display the long plural form (no link and no check for existence).
%    \begin{macrocode}
  \newcommand*{\Glsaccesslongpl}[1]{\Glsentrylongpl{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSaccesslongpl}
% Display the \gloskey{longplural} value (no link and no check for existence).
% converted to upper case.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
  \newcommand*{\GLSaccesslongpl}[1]{%
   \protect\mfirstucMakeUppercase{\glsentrylongpl{#1}}}
%    \end{macrocode}
%\end{macro}
%
% End of else part
%    \begin{macrocode}
}
%    \end{macrocode}
%
%\section{Categories}
%\begin{macro}{\glscategory}
% Add a new storage key that can be used to indicate a category. The
% default category is \category{general}.
%    \begin{macrocode}
\glsaddstoragekey{category}{general}{\glscategory}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifcategory}
% Convenient shortcut to determine if an entry has the given
% category.
%    \begin{macrocode}
\newcommand{\glsifcategory}[4]{%
 \ifglsfieldeq{#1}{category}{#2}{#3}{#4}%
}
%    \end{macrocode}
%\end{macro}
%
% Categories can have attributes.
%\begin{macro}{\glssetcategoryattribute}
%\begin{definition}
%\cs{glssetcategoryattribute}\marg{category}\marg{attribute-label}\marg{value}
%\end{definition}
% Set (or override if already set) an attribute for the given
% category.
%    \begin{macrocode}
\newcommand*{\glssetcategoryattribute}[3]{%
  \csdef{@glsxtr@categoryattr@@#1@#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgetcategoryattribute}
%\begin{definition}
%\cs{glsgetcategoryattribute}\marg{category}\marg{attribute-label}
%\end{definition}
% Get the value of the given attribute for the given
% category. Does nothing if the attribute isn't defined.
%    \begin{macrocode}
\newcommand*{\glsgetcategoryattribute}[2]{%
  \csuse{@glsxtr@categoryattr@@#1@#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glshascategoryattribute}
%\begin{definition}
%\cs{glshascategoryattribute}\marg{category}\marg{attribute-label}\marg{true}\marg{false}
%\end{definition}
%\changes{0.5}{2015-12-07}{new}
% Tests if the category has the given attribute set.
%    \begin{macrocode}
\newcommand*{\glshascategoryattribute}[4]{%
  \ifcsvoid{@glsxtr@categoryattr@@#1@#2}{#4}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssetattribute}
%\begin{definition}
%\cs{glssetattribute}\marg{entry label}\marg{attribute-label}\marg{value}
%\end{definition}
% Short cut where the category label is obtained from the entry
% information.
%    \begin{macrocode}
\newcommand*{\glssetattribute}[3]{%
  \glssetcategoryattribute{\glscategory{#1}}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgetattribute}
%\begin{definition}
%\cs{glsgetattribute}\marg{entry label}\marg{attribute-label}
%\end{definition}
% Short cut where the category label is obtained from the entry
% information.
%    \begin{macrocode}
\newcommand*{\glsgetattribute}[2]{%
  \glsgetcategoryattribute{\glscategory{#1}}{#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glshasattribute}
%\begin{definition}
%\cs{glshasattribute}\marg{entry
%label}\marg{attribute-label}\marg{true}\marg{false}
%\end{definition}
%\changes{0.5}{2015-12-07}{new}
%\changes{0.5.4}{2015-12-15}{added check for entry's existence}
% Short cut to test if the given attribute has been set where the
% category label is obtained from the entry information.
%    \begin{macrocode}
\newcommand*{\glshasattribute}[4]{%
  \ifglsentryexists{#1}%
  {\glshascategoryattribute{\glscategory{#1}}{#2}{#3}{#4}}%
  {#4}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifcategoryattribute}
%\begin{definition}
%\cs{glsifcategoryattribute}\marg{category}\marg{attribute-label}\marg{value}\marg{true
%part}\marg{false part}
%\end{definition}
% True if category has the attribute with the given value.
%    \begin{macrocode}
\newcommand{\glsifcategoryattribute}[5]{%
 \ifcsundef{@glsxtr@categoryattr@@#1@#2}%
 {#5}%
 {\ifcsstring{@glsxtr@categoryattr@@#1@#2}{#3}{#4}{#5}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifattribute}
%\begin{definition}
%\cs{glsifattribute}\marg{entry label}\marg{attribute-label}\marg{value}\marg{true
%part}\marg{false part}
%\end{definition}
%Short cut to determine if the given entry has a category with the
%given attribute set.
%\changes{0.5.4}{2015-12-15}{added check for entry's existence}
%    \begin{macrocode}
\newcommand{\glsifattribute}[5]{%
  \ifglsentryexists{#1}%
  {\glsifcategoryattribute{\glscategory{#1}}{#2}{#3}{#4}{#5}}%
  {#5}%
}
%    \end{macrocode}
%\end{macro}
%
% Set attributes for the default \category{general} category:
%    \begin{macrocode}
\glssetcategoryattribute{general}{regular}{true}
%    \end{macrocode}
% Acronyms are regular by default, since they're typically just
% treated like normal words.
%    \begin{macrocode}
\glssetcategoryattribute{acronym}{regular}{true}
%    \end{macrocode}
%
%\begin{macro}{\glssetregularcategory}
%Convenient shortcut to create add the regular attribute.
%    \begin{macrocode}
\newcommand*{\glssetregularcategory}[1]{%
 \glssetcategoryattribute{#1}{regular}{true}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifregularcategory}
%\begin{definition}
%\cs{glsifregularcategory}\marg{category}\marg{true part}\marg{false part}
%\end{definition}
% Short cut to determine if a category has the regular attribute
% explicitly set to true.
%    \begin{macrocode}
\newcommand{\glsifregularcategory}[3]{%
  \glsifcategoryattribute{#1}{regular}{true}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifnotregularcategory}
%\begin{definition}
%\cs{glsifnotregularcategory}\marg{category}\marg{true part}\marg{false part}
%\end{definition}
% Short cut to determine if a category has the regular attribute
% explicitly set to false.
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand{\glsifnotregularcategory}[3]{%
  \glsifcategoryattribute{#1}{regular}{false}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifregular}
%\begin{definition}
%\cs{glsifregular}\marg{entry label}\marg{true part}\marg{false part}
%\end{definition}
% Short cut to determine if an entry has a regular attribute set to
% true.
%    \begin{macrocode}
\newcommand{\glsifregular}[3]{%
  \glsifregularcategory{\glscategory{#1}}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsifnotregular}
%\begin{definition}
%\cs{glsifnotregular}\marg{entry label}\marg{true part}\marg{false part}
%\end{definition}
% Short cut to determine if an entry has a regular attribute set to
% false.
%    \begin{macrocode}
\newcommand{\glsifnotregular}[3]{%
  \glsifnotregularcategory{\glscategory{#1}}{#2}{#3}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsforeachincategory}
%\begin{definition}
%\cs{glsforeachincategory}\oarg{glossary
%labels}\marg{category-label}\marg{glossary-cs}\marg{label-cs}\marg{body}
%\end{definition}
% Iterates through all entries in all the glossaries (or just those
% listed in \meta{glossary labels}) and does \meta{body} if the
% category matches \meta{category-label}. The control sequences
% \meta{glossary-cs} and \meta{label-cs} may be used in \meta{body}
% to access the glossary label and entry label for the current
% iteration.
%    \begin{macrocode}
\newcommand{\glsforeachincategory}[5][\@glo@types]{%
  \forallglossaries[#1]{#3}%
  {%
     \forglsentries[#3]{#4}%
     {%
       \glsifcategory{#4}{#2}{#5}{}%
     }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsforeachwithattribute}
%\begin{definition}
%\cs{glsforeachwithattribute}\oarg{glossary
%labels}\marg{attribute-label}\marg{attribute-value}\marg{glossary-cs}\marg{label-cs}\marg{body}
%\end{definition}
% Iterates through all entries in all the glossaries (or just those
% listed in \meta{glossary labels}) and does \meta{body} if the
% category attribute \meta{attribute-label} matches
% \meta{attribute-value}. The control sequences
% \meta{glossary-cs} and \meta{label-cs} may be used in \meta{body}
% to access the glossary label and entry label for the current
% iteration.
%    \begin{macrocode}
\newcommand{\glsforeachwithattribute}[6][\@glo@types]{%
  \forallglossaries[#1]{#4}%
  {%
     \forglsentries[#4]{#5}%
     {%
       \glsifattribute{#5}{#2}{#3}{#6}{}%
     }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
% If \cs{newterm} has been defined, redefine it so that it
% automatically sets the category label to \category{index} and add
% \cs{glsxtrpostdescription}.
%    \begin{macrocode}
\ifdef\newterm
{%
%    \end{macrocode}
%\begin{macro}{\newterm}
%\changes{0.4}{2015-12-03}{fixed name argument}
%    \begin{macrocode}
  \renewcommand*{\newterm}[2][]{%
    \newglossaryentry{#2}%
    {type={index},category=index,name={#2},%
     description={\glsxtrpostdescription\nopostdesc},#1}%
  }
%    \end{macrocode}
%\end{macro}
% Indexed terms are regular by default.
%    \begin{macrocode}
  \glssetcategoryattribute{index}{regular}{true}
%    \end{macrocode}
%\begin{macro}{\glsxtrpostdescindex}
%    \begin{macrocode}
  \newcommand*{\glsxtrpostdescindex}{}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
}
{}
%    \end{macrocode}
%
%If the \pkgopt{symbols} package option was used, define a similar
%command for symbols, but set the default sort to the label rather
%than the name as the symbols will typically contain commands that
%will confuse makeindex and xindy.
%    \begin{macrocode}
\ifdef\printsymbols
{%
%    \end{macrocode}
%\begin{macro}{\glsxtrnewsymbol}
%\changes{0.4}{2015-12-03}{added extra argument}
% Unlike \cs{newterm}, this has a separate argument for the label
% (since the symbol will likely contain commands).
%    \begin{macrocode}
  \newcommand*{\glsxtrnewsymbol}[3][]{%
    \newglossaryentry{#2}{name={#3},sort={#2},type=symbols,category=symbol,#1}%
  }
%    \end{macrocode}
%\end{macro}
% Symbols are regular by default.
%    \begin{macrocode}
  \glssetcategoryattribute{symbol}{regular}{true}
%    \end{macrocode}
%\begin{macro}{\glsxtrpostdescsymbol}
%    \begin{macrocode}
  \newcommand*{\glsxtrpostdescsymbol}{}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
}
{}
%    \end{macrocode}
%
% Similar for the numbers option.
%    \begin{macrocode}
\ifdef\printnumbers
{%
%    \end{macrocode}
%\begin{macro}{\glsxtrnewnumber}
%\changes{0.4}{2015-12-03}{added extra argument}
%    \begin{macrocode}
\ifdef\printnumbers
  \newcommand*{\glsxtrnewnumber}[3][]{%
    \newglossaryentry{#2}{name={#3},sort={#2},type=numbers,category=number,#1}%
  }
%    \end{macrocode}
%\end{macro}
% Numbers are regular by default.
%    \begin{macrocode}
  \glssetcategoryattribute{number}{regular}{true}
%    \end{macrocode}
%\begin{macro}{\glsxtrpostdescnumber}
%    \begin{macrocode}
  \newcommand*{\glsxtrpostdescnumber}{}
%    \end{macrocode}
%\end{macro}
%    \begin{macrocode}
}
{}
%    \end{macrocode}
%
%\begin{macro}{\glsxtrsetcategory}
% Set the category for all listed labels. The first argument is the
% list of entry labels and the second argument is the category label.
%    \begin{macrocode}
\newcommand*{\glsxtrsetcategory}[2]{%
  \@for\@glsxtr@label:=#1\do
  {%
    \glsfieldxdef{\@glsxtr@label}{category}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrsetcategoryforall}
% Set the category for all entries in the listed glossaries. The first argument 
% is the list of glossary labels and the second argument is the category label.
%    \begin{macrocode}
\newcommand*{\glsxtrsetcategoryforall}[2]{%
  \forallglossaries[#1]{\@glsxtr@type}{%
    \forglsentries[\@glsxtr@type]{\@glsxtr@label}%
    {%
      \glsfieldxdef{\@glsxtr@label}{category}{#2}%
    }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfieldtitlecase}
%\begin{definition}
%\cs{glsxtrfieldtitlecase}\marg{label}\marg{field}
%\end{definition}
% Apply title casing to the contents of the given field.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrfieldtitlecase}[2]{%
  \expandafter\glsxtrfieldtitlecasecs\expandafter
    {\csname glo@\glsdetoklabel{#1}@#2\endcsname}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfieldtitlecasecs}
%The command used by \cs{glsxtrfieldtitlecase}. May be
%redefined to use a different command, for example,
%\cs{xcapitalisefmtwords}.
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrfieldtitlecasecs}[1]{\xcapitalisewords{#1}}
%    \end{macrocode}
%\end{macro}
%
% Provide a convenient way to modify glossary styles without having
% to define a new style just to convert the first letter of fields
% to upper case.
%\begin{macro}{\glossentrydesc}
% If the \catattr{glossdesc} attribute is \qt{firstuc} convert first
% letter to upper case. If the attribute is \qt{title} use title
% case.
%    \begin{macrocode}
\@ifpackageloaded{glossaries-accsupp}
{
  \renewcommand*{\glossentrydesc}[1]{%
    \glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
%    \end{macrocode}
% As from version 1.04, allow the \catattr{glossdescfont} attribute
% to determine the font applied.
%\changes{1.04}{2016-05-02}{added glossdescfont attribute check}
%    \begin{macrocode}
      \glshasattribute{#1}{glossdescfont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossdescfont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossdescfont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossdescfont attribute
          for entry `#1'. Ignoring}%
          \let\@glsxtr@glossdescfont\@firstofone
        }%
      }%
      {\let\@glsxtr@glossdescfont\@firstofone}%
      \glsifattribute{#1}{glossdesc}{firstuc}%
      {%
        \@glsxtr@glossdescfont{\Glsaccessdesc{#1}}%
      }%
      {%
        \glsifattribute{#1}{glossdesc}{title}%
        {%
          \@glsxtr@do@titlecaps@warn
          \glsdescriptionaccessdisplay
          {%
            \@glsxtr@glossdescfont{\glsxtrfieldtitlecase{#1}{desc}}%
          }%
          {#1}%
        }%
        {%
          \@glsxtr@glossdescfont{\glsaccessdesc{#1}}%
        }%
      }%
    }%
  }
}
{
  \renewcommand*{\glossentrydesc}[1]{%
    \glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
      \glshasattribute{#1}{glossdescfont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossdescfont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossdescfont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossdescfont attribute
          for entry `#1'. Ignoring}%
          \let\@glsxtr@glossdescfont\@firstofone
        }%
      }%
      {\let\@glsxtr@glossdescfont\@firstofone}%
      \glsifattribute{#1}{glossdesc}{firstuc}%
      {%
        \@glsxtr@glossdescfont{\Glsentrydesc{#1}}%
      }%
      {%
        \glsifattribute{#1}{glossdesc}{title}%
        {%
          \@glsxtr@do@titlecaps@warn
          \@glsxtr@glossdescfont{\glsxtrfieldtitlecase{#1}{desc}}%
        }%
        {%
          \@glsxtr@glossdescfont{\glsentrydesc{#1}}%
        }%
      }%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossentryname}
% If the \catattr{glossname} attribute is \qt{firstuc} convert first
% letter to upper case. If the attribute is \qt{title} use title
% case.
%    \begin{macrocode}
\@ifpackageloaded{glossaries-accsupp}
{
  \renewcommand*{\glossentryname}[1]{%
    \@glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
%    \end{macrocode}
% As from version 1.04, allow the \catattr{glossnamefont} attribute
% to determine the font applied.
%\changes{1.04}{2016-05-02}{added glossnamefont attribute check}
%    \begin{macrocode}
      \glshasattribute{#1}{glossnamefont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossnamefont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossnamefont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossnamefont attribute
          for entry `#1'. Reverting to default \string\glsnamefont}%
          \let\@glsxtr@glossnamefont\glsnamefont
        }%
      }%
      {\let\@glsxtr@glossnamefont\glsnamefont}%
      \glsifattribute{#1}{glossname}{firstuc}%
      {%
        \glsnameaccessdisplay
        {%
          \@glsxtr@glossnamefont{\Glsentryname{#1}}%
        }%
        {#1}%
      }%
      {%
        \glsifattribute{#1}{glossname}{title}%
        {%
          \@glsxtr@do@titlecaps@warn
          \glsnameaccessdisplay
          {%
            \@glsxtr@glossnamefont{\glsxtrfieldtitlecase{#1}{name}}%
          }%
          {#1}%
        }%
        {%
          \glsifattribute{#1}{glossname}{uc}%
          {%
            \glsnameaccessdisplay
            {%
%    \end{macrocode}
% Hide the label from the upper-casing command.
%    \begin{macrocode}
               \letcs{\glo@name}{glo@\glsdetoklabel{#1}@name}%
               \@glsxtr@glossnamefont{\mfirstucMakeUppercase{\glo@name}}%
            }%
            {#1}%
          }%
          {%
            \letcs{\glo@name}{glo@\glsdetoklabel{#1}@name}%
            \glsnameaccessdisplay
            {%
              \expandafter\@glsxtr@glossnamefont\expandafter{\glo@name}%
            }%
            {#1}%
          }%
        }%
      }%
%    \end{macrocode}
% Do post-name hook:
%    \begin{macrocode}
      \glsxtrpostnamehook{#1}%
    }%
  }
}
{
  \renewcommand*{\glossentryname}[1]{%
    \@glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
      \glshasattribute{#1}{glossnamefont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossnamefont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossnamefont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossnamefont attribute
          for entry `#1'. Reverting to default \string\glsnamefont}%
          \let\@glsxtr@glossnamefont\glsnamefont
        }%
      }%
      {\let\@glsxtr@glossnamefont\glsnamefont}%
      \glsifattribute{#1}{glossname}{firstuc}%
      {%
        \@glsxtr@glossnamefont{\Glsentryname{#1}}%
      }%
      {%
        \glsifattribute{#1}{glossname}{title}%
        {%
          \@glsxtr@do@titlecaps@warn
          \@glsxtr@glossnamefont{\glsxtrfieldtitlecase{#1}{name}}%
        }%
        {%
          \glsifattribute{#1}{glossname}{uc}%
          {%
%    \end{macrocode}
% Hide the label from the upper-casing command.
%    \begin{macrocode}
            \letcs{\glo@name}{glo@\glsdetoklabel{#1}@name}%
            \@glsxtr@glossnamefont{\mfirstucMakeUppercase{\glo@name}}%
          }%
          {%
%    \end{macrocode}
% This little trick is used by \styfmt{glossaries} to allow the user to
% redefine \ics{glsnamefont} to use \cs{makefirstuc}. Support it
% even though they can now use the \catattr{firstuc} attribute.
%    \begin{macrocode}
            \letcs{\glo@name}{glo@\glsdetoklabel{#1}@name}%
            \expandafter\@glsxtr@glossnamefont\expandafter{\glo@name}%
          }%
        }%
      }%
%    \end{macrocode}
% Do post-name hook.
%\changes{1.04}{2016-05-02}{moved post name hook inside condition}
%    \begin{macrocode}
      \glsxtrpostnamehook{#1}%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentryname}
% Redefine to set the abbreviation format and accessibility support.
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\@ifpackageloaded{glossaries-accsupp}
{
  \renewcommand*{\Glossentryname}[1]{%
    \@glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
%    \end{macrocode}
% As from version 1.04, allow the \catattr{glossnamefont} attribute
% to determine the font applied.
%\changes{1.04}{2016-05-02}{added glossnamefont attribute check}
%    \begin{macrocode}
      \glshasattribute{#1}{glossnamefont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossnamefont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossnamefont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossnamefont attribute
          for entry `#1'. Reverting to default \string\glsnamefont}%
          \let\@glsxtr@glossnamefont\glsnamefont
        }%
      }%
      {\let\@glsxtr@glossnamefont\glsnamefont}%
      \glsnameaccessdisplay
      {%
        \@glsxtr@glossnamefont{\Glsentryname{#1}}%
      }%
      {#1}%
%    \end{macrocode}
% Do post-name hook:
%    \begin{macrocode}
      \glsxtrpostnamehook{#1}%
    }%
  }
}
{
  \renewcommand*{\Glossentryname}[1]{%
    \@glsdoifexistsorwarn{#1}%
    {%
      \glssetabbrvfmt{\glscategory{#1}}%
      \glshasattribute{#1}{glossnamefont}%
      {%
        \edef\@glsxtr@attrval{\glsgetattribute{#1}{glossnamefont}}%
        \ifcsdef{\@glsxtr@attrval}%
        {%
          \letcs{\@glsxtr@glossnamefont}{\@glsxtr@attrval}%
        }%
        {%
          \GlossariesExtraWarning{Unknown control sequence name 
          `\@glsxtr@attrval' supplied in glossnamefont attribute
          for entry `#1'. Reverting to default \string\glsnamefont}%
          \let\@glsxtr@glossnamefont\glsnamefont
        }%
      }%
      {\let\@glsxtr@glossnamefont\glsnamefont}%
      \@glsxtr@glossnamefont{\Glsentryname{#1}}%
%    \end{macrocode}
% Do post-name hook:
%    \begin{macrocode}
      \glsxtrpostnamehook{#1}%
    }%
  }
}
%    \end{macrocode}
%\end{macro}
%
% Provide a convenient way to also index the entries using the
% standard \ics{index} mechanism. This may use different actual,
% encap and escape characters to those used for the glossaries.
%
%\begin{macro}{\glsxtrpostnamehook}
%\changes{0.5.3}{2015-12-09}{new}
% Hook to append stuff after the name is displayed in the glossary. 
% The argument is the entry's label.
%    \begin{macrocode}
\newcommand*{\glsxtrpostnamehook}[1]{%
  \def\@glsnumberformat{glsnumberformat}%
  \glsxtrdoautoindexname{#1}{indexname}%
%    \end{macrocode}
% Allow categories to hook in here.
%\changes{1.04}{2016-05-02}{added category check}
%    \begin{macrocode}
  \csuse{glsxtrpostname\glscategory{\glscurrententrylabel}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\if@glsxtr@format@override}
%\changes{0.5.3}{2015-12-09}{new}
% Determines if the \gloskey[glslink]{format} key should override
% the indexing attribute value.
%    \begin{macrocode}
\newif\if@glsxtr@format@override
\@glsxtr@format@overridefalse
%    \end{macrocode}
%\end{macro}
%
%If overriding is enabled, the \ics{glshypernumber} command will have to 
%be redefined in the index to use \cs{hyperpage} instead.
%\begin{macro}{\GlsXtrEnableIndexFormatOverride}
%    \begin{macrocode}
\@ifpackageloaded{hyperref}
{
%    \end{macrocode}
% If \sty{hyperref}'s \pkgoptfmt{hyperindex} option is on, then
% \sty{hyperref} will automatically add \cs{hyperpage}, so don't
% add it.
%    \begin{macrocode}
  \ifHy@hyperindex
    \newcommand*{\GlsXtrEnableIndexFormatOverride}{%
      \@glsxtr@format@overridetrue
      \appto\theindex{\let\glshypernumber\@firstofone}%
    }
  \else
    \newcommand*{\GlsXtrEnableIndexFormatOverride}{%
      \@glsxtr@format@overridetrue
      \appto\theindex{\let\glshypernumber\hyperpage}%
    }
  \fi
}
{
  \newcommand*{\GlsXtrEnableIndexFormatOverride}{%
    \@glsxtr@format@overridetrue
  }
}
\@onlypreamble\GlsXtrEnableIndexFormatOverride
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrdoautoindexname}
%\changes{0.5.3}{2015-12-09}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrdoautoindexname}[2]{%
  \glshasattribute{#1}{#2}%
  {%
%    \end{macrocode}
% Escape any makeindex/xindy characters in the value of the \gloskey{name}
% field. Take care with \sty{babel} as this won't work if the
% category code has changed for those characters.
%    \begin{macrocode}
    \@glsxtr@autoindex@setname{#1}%
%    \end{macrocode}
% If the attribute value is simply \qt{true} don't add an encap,
% otherwise use the value as the encap.
%    \begin{macrocode}
    \protected@edef\@glsxtr@attrval{\glsgetattribute{#1}{#2}}%
    \if@glsxtr@format@override
      \ifdefstring{\@glsnumberformat}{glsnumberformat}{}%
      {\let\@glsxtr@attrval\@glsnumberformat}%
    \fi
    \ifdefstring{\@glsxtr@attrval}{true}%
    {}%
    {\eappto\@glo@name{\@glsxtr@autoindex@encap\@glsxtr@attrval}}%
    \expandafter\index\expandafter{\@glo@name}%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@autoindex@setname}
%\changes{0.5.3}{2015-12-09}{new}
% Assign \cs{@glo@name} for use with \catattr{indexname} attribute.
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@setname}[1]{%
  \def\@glo@name{\string\glsentryname{#1}}%
  \glsletentryfield{\@glo@sort}{#1}{sort}%
  \@gls@checkmkidxchars\@glo@sort
  \@glsxtr@autoindex@doextra@esc\@glo@sort
  \epreto\@glo@name{\@glo@sort\@glsxtr@autoindex@at}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@autoindex@doextra@esc}
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@doextra@esc}[1]{%
%    \end{macrocode}
% Escape the escape character unless it has already been escaped.
%    \begin{macrocode}
  \ifx\@glsxtr@autoindex@esc\@gls@quotechar
  \else
    \def\@gls@checkedmkidx{}%
    \edef\@@glsxtr@checkspch{%
      \noexpand\@glsxtr@autoindex@escquote\expandonce{#1}%
        \noexpand\@empty\@glsxtr@autoindex@esc\noexpand\@nnil
        \@glsxtr@autoindex@esc\noexpand\@empty\noexpand\@glsxtr@endescspch}%
    \@@glsxtr@checkspch
    \let#1\@gls@checkedmkidx\relax
  \fi
%    \end{macrocode}
% Escape actual character unless it has already been escaped.
%    \begin{macrocode}
  \ifx\@glsxtr@autoindex@at\@gls@actualchar
  \else
    \def\@gls@checkedmkidx{}%
    \edef\@@glsxtr@checkspch{%
      \noexpand\@glsxtr@autoindex@escat\expandonce{#1}%
        \noexpand\@empty\@glsxtr@autoindex@at\noexpand\@nnil
        \@glsxtr@autoindex@at\noexpand\@empty\noexpand\@glsxtr@endescspch}%
    \@@glsxtr@checkspch
    \let#1\@gls@checkedmkidx\relax
  \fi
%    \end{macrocode}
% Escape level character unless it has already been escaped.
%    \begin{macrocode}
  \ifx\@glsxtr@autoindex@level\@gls@levelchar
  \else
    \def\@gls@checkedmkidx{}%
    \edef\@@glsxtr@checkspch{%
      \noexpand\@glsxtr@autoindex@esclevel\expandonce{#1}%
        \noexpand\@empty\@glsxtr@autoindex@level\noexpand\@nnil
        \@glsxtr@autoindex@level\noexpand\@empty\noexpand\@glsxtr@endescspch}%
    \@@glsxtr@checkspch
    \let#1\@gls@checkedmkidx\relax
  \fi
%    \end{macrocode}
% Escape encap character unless it has already been escaped.
%    \begin{macrocode}
  \ifx\@glsxtr@autoindex@encap\@gls@encapchar
  \else
    \def\@gls@checkedmkidx{}%
    \edef\@@glsxtr@checkspch{%
      \noexpand\@glsxtr@autoindex@escencap\expandonce{#1}%
        \noexpand\@empty\@glsxtr@autoindex@encap\noexpand\@nnil
        \@glsxtr@autoindex@encap\noexpand\@empty\noexpand\@glsxtr@endescspch}%
    \@@glsxtr@checkspch
    \let#1\@gls@checkedmkidx\relax
  \fi
}
%    \end{macrocode}
%\end{macro}
%
% The user commands here have a preamble-only restriction to ensure
% they are set before required and also to reduce the chances of
% complications caused by \sty{babel}'s shorthands.
%
%\begin{macro}{\@glsxtr@autoindex@at}
%\changes{0.5.3}{2015-12-09}{new}
% Actual character for use with \cs{index}.
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@at}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetActualChar}
% Set the actual character.
%    \begin{macrocode}
\newcommand*{\GlsXtrSetActualChar}[1]{%
  \gdef\@glsxtr@autoindex@at{#1}%
  \def\@glsxtr@autoindex@escat##1#1##2#1##3\@glsxtr@endescspch{%
    \@@glsxtr@autoindex@escspch{#1}{\@glsxtr@autoindex@escat}{##1}{##2}{##3}%
  }%
}
\@onlypreamble\GlsXtrSetActualChar
\makeatother
\GlsXtrSetActualChar{@}
\makeatletter
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@autoindex@encap}
%\changes{0.5.3}{2015-12-09}{new}
% Encap character for use with \cs{index}.
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@encap}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetEncapChar}
% Set the encap character.
%    \begin{macrocode}
\newcommand*{\GlsXtrSetEncapChar}[1]{%
  \gdef\@glsxtr@autoindex@encap{#1}%
  \def\@glsxtr@autoindex@escencap##1#1##2#1##3\@glsxtr@endescspch{%
    \@@glsxtr@autoindex@escspch{#1}{\@glsxtr@autoindex@escencap}{##1}{##2}{##3}%
  }%
}
\GlsXtrSetEncapChar{|}
\@onlypreamble\GlsXtrSetEncapChar
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@autoindex@level}
%\changes{0.5.3}{2015-12-09}{new}
% Level character for use with \cs{index}.
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@level}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetLevelChar}
% Set the encap character.
%    \begin{macrocode}
\newcommand*{\GlsXtrSetLevelChar}[1]{%
  \gdef\@glsxtr@autoindex@level{#1}%
  \def\@glsxtr@autoindex@esclevel##1#1##2#1##3\@glsxtr@endescspch{%
    \@@glsxtr@autoindex@escspch{#1}{\@glsxtr@autoindex@esclevel}{##1}{##2}{##3}%
  }%
}
\GlsXtrSetLevelChar{!}
\@onlypreamble\GlsXtrSetLevelChar
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@autoindex@esc}
%\changes{0.5.3}{2015-12-09}{new}
% Escape character for use with \cs{index}.
%    \begin{macrocode}
\newcommand*{\@glsxtr@autoindex@esc}{"}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrSetEscChar}
% Set the escape character.
%    \begin{macrocode}
\newcommand*{\GlsXtrSetEscChar}[1]{%
  \gdef\@glsxtr@autoindex@esc{#1}%
  \def\@glsxtr@autoindex@escquote##1#1##2#1##3\@glsxtr@endescspch{%
    \@@glsxtr@autoindex@escspch{#1}{\@glsxtr@autoindex@escquote}{##1}{##2}{##3}%
  }%
}
\GlsXtrSetEscChar{"}
\@onlypreamble\GlsXtrSetEscChar
%    \end{macrocode}
%\end{macro}
%
% Set if defined. (For example, if \sty{doc} package has been
% loaded.) Actual character \ics{actualchar}:
%    \begin{macrocode}
\ifdef\actualchar
 {\expandafter\GlsXtrSetActualChar\expandafter{\actualchar}}
 {}
%    \end{macrocode}
% Quote character \ics{quotechar}:
%    \begin{macrocode}
\ifdef\quotechar
 {\expandafter\GlsXtrSetEscChar\expandafter{\quotechar}}
 {}
%    \end{macrocode}
% Level character \ics{levelchar}:
%    \begin{macrocode}
\ifdef\levelchar
 {\expandafter\GlsXtrSetLevelChar\expandafter{\levelchar}}
 {}
%    \end{macrocode}
% Encap character \ics{encapchar}:
%    \begin{macrocode}
\ifdef\encapchar
 {\expandafter\GlsXtrSetEncapChar\expandafter{\encapchar}}
 {}
%    \end{macrocode}
%
%\begin{macro}{\@glsxtr@gobbleto@endescspch}
%    \begin{macrocode}
\def\@glsxtr@gobbleto@endescspch#1\@glsxtr@endescspch{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@@glsxtr@autoindex@esc@spch}
%\begin{definition}
%\cs{@@glsxtr@autoindex@escspch}\marg{char}\marg{cs}\marg{pre}\marg{mid}\marg{post}
%\end{definition}
%    \begin{macrocode}
\newcommand*{\@@glsxtr@autoindex@escspch}[5]{%
  \@gls@tmpb=\expandafter{\@gls@checkedmkidx}%
  \toks@={#3}%
  \ifx\@nnil#3\relax
    \def\@@glsxtr@checkspch{\@glsxtr@gobbleto@endescspch#5\@glsxtr@endescspch}%
  \else
    \ifx\@nnil#4\relax
      \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@}%
     \def\@@glsxtr@checkspch{\@glsxtr@gobbleto@endescspch
        #4#5\@glsxtr@endescspch}%
    \else
      \edef\@gls@checkedmkidx{\the\@gls@tmpb\the\toks@
       \@glsxtr@autoindex@esc#1}%
      \def\@@glsxtr@checkspch{#2#5#1\@nnil#1\@glsxtr@endescspch}%
    \fi
  \fi
  \@@glsxtr@checkspch
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentrydesc}
% Redefine to set the abbreviation format and accessibility support.
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\renewcommand*{\Glossentrydesc}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \glssetabbrvfmt{\glscategory{#1}}%
    \Glsaccessdesc{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glossentrysymbol}
% Redefine to set the abbreviation format and accessibility support.
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\renewcommand*{\glossentrysymbol}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \glssetabbrvfmt{\glscategory{#1}}%
    \glsaccesssymbol{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glossentrysymbol}
% Redefine to set the abbreviation format and accessibility support.
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\renewcommand*{\Glossentrysymbol}[1]{%
  \glsdoifexistsorwarn{#1}%
  {%
    \glssetabbrvfmt{\glscategory{#1}}%
    \Glsaccesssymbol{#1}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%Allow initials to be marked but only use the formatting for the
%tag in the glossary.
%\begin{macro}{\GlsXtrEnableInitialTagging}
% Allow initial tagging. The first argument is a list of categories
% to apply this to. The second argument is the name of the command to
% use to tag the initials. This can't already be defined for safety
% unless the starred version is used.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrEnableInitialTagging}{%
  \@ifstar\s@glsxtr@enabletagging\@glsxtr@enabletagging
}
\@onlypreamble\GlsXtrEnableInitialTagging
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@enabletagging}
% Starred version undefines command.
%    \begin{macrocode}
\newcommand*{\s@glsxtr@enabletagging}[2]{%
  \undef#2%
  \@glsxtr@enabletagging{#1}{#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtr@enabletagging}
% Internal command.
%    \begin{macrocode}
\newcommand*{\@glsxtr@enabletagging}[2]{%
%    \end{macrocode}
% Set attributes for categories given in the first argument.
%    \begin{macrocode}
  \@for\@glsxtr@cat:=#1\do
  {%
    \ifdefempty\@glsxtr@cat
    {}%
    {\glssetcategoryattribute{\@glsxtr@cat}{tagging}{true}}%
  }%
  \newrobustcmd*#2[1]{##1}%
  \def\@glsxtr@taggingcs{#2}%
  \renewcommand*\@glsxtr@activate@initialtagging{%
    \let#2\@glsxtr@tag
  }%
  \ifundef\@gls@preglossaryhook
  {\GlossariesExtraWarning{Initial tagging requires at least 
    glossaries.sty v4.19 to work correctly}}%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%Are we using an old version of \sty{mfirstuc} that has a bug in 
%\cs{capitalisewords}? If so, patch it so we don't have a problem
% with a combination of tagging and title case.
%\begin{macro}{\mfu@checkword@do}
%If this command hasn't been defined, then we have pre v2.02 of
%\sty{mfirstuc}
%\changes{0.5.2}{2015-12-08}{added}
%    \begin{macrocode}
\ifundef\mfu@checkword@do
{
  \newcommand*{\mfu@checkword@do}[1]{%
   \ifdefstring{\mfu@checkword@arg}{#1}%
   {%
     \let\@mfu@domakefirstuc\@firstofone
     \listbreak
   }%
   {}%
  }
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\mfu@checkword}
% \cs{capitalisewords} was introduced in \sty{mfirstuc} v1.06.
% If \cs{mfu@checkword} hasn't been defined \sty{mfirstuc} is too
% old to support the title case attribute.
%    \begin{macrocode}
  \ifundef\mfu@checkword
  {
    \newcommand{\@glsxtr@do@titlecaps@warn}{%
     \GlossariesExtraWarning{mfirstuc.sty too old. Title Caps
      support not available}%
%    \end{macrocode}
% One warning should suffice.
%    \begin{macrocode}
      \let\@glsxtr@do@titlecaps@warn\relax
    }
  }
  {
    \renewcommand*{\mfu@checkword}[1]{%
      \def\mfu@checkword@arg{#1}%
      \let\@mfu@domakefirstuc\makefirstuc
      \forlistloop\mfu@checkword@do\@mfu@nocaplist
    }
  }
}
{}% no patch required
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@do@titlecaps@warn}
% Do warning if title case not supported.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*{\@glsxtr@do@titlecaps@warn}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@activate@initialtagging}
% Used in \cs{printglossary} but at least v4.19 of \styfmt{glossaries}
% required.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*\@glsxtr@activate@initialtagging{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@tag}
%\changes{0.5.2}{2015-12-08}{new}
% Definition of tagging command when used in glossary.
%    \begin{macrocode}
\newrobustcmd*{\@glsxtr@tag}[1]{%
  \glsifattribute{\glscurrententrylabel}{tagging}{true}%
  {\glsxtrtagfont{#1}}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtagfont}
% Used in the glossary.
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrtagfont}[1]{\underline{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@gls@preglossaryhook}
% This macro was introduced in \styfmt{glossaries} version 4.19, so it
% may not be defined. If it hasn't been defined this feature is
% unavailable. A check is added for the entry's existence to prevent
% errors from occurring if the user removes an entry or changes the
% label, which can interrupt the build process.
%\changes{1.04}{2016-05-02}{added check for entry's existence}
%    \begin{macrocode}
\ifdef\@gls@preglossaryhook
{
  \renewcommand*{\@gls@preglossaryhook}{%
    \@glsxtr@activate@initialtagging
    \let\@glsxtr@org@postdescription\glspostdescription
    \renewcommand*{\glspostdescription}{%
      \ifglsentryexists{\glscurrententrylabel}%
      {%
        \glsxtrpostdescription
        \@glsxtr@org@postdescription
      }{}%
    }%
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{added \cs{glossxtrsetpopts}}
%Enable the options used by \cs{@@glsxtrp}:
%    \begin{macrocode}
    \glossxtrsetpopts
  }%
}
{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostdescription}
%This command will only be used if \cs{@gls@preglossaryhook} is
%available \emph{and} the glossary style uses
%\cs{glspostdescription} without modifying it. (\cs{nopostdesc}
%will suppress this.) The \sty{glossaries-extra-stylemods} package will
%add the post description hook to all the predefined styles that
%don't include it.
%    \begin{macrocode}
\newcommand*{\glsxtrpostdescription}{%
  \csuse{glsxtrpostdesc\glscategory{\glscurrententrylabel}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostdescgeneral}
%    \begin{macrocode}
\newcommand*{\glsxtrpostdescgeneral}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostdescterm}
%    \begin{macrocode}
\newcommand*{\glsxtrpostdescterm}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostdescacronym}
%    \begin{macrocode}
\newcommand*{\glsxtrpostdescacronym}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostdescabbreviation}
%    \begin{macrocode}
\newcommand*{\glsxtrpostdescabbreviation}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glspostlinkhook}
% Redefine the post link hook used by commands like \cs{gls} to
% make it easier for categories or attributes to modify this action.
% Since this hook occurs outside the existence check of commands like
% \cs{gls}, this needs to be checked again here. Do nothing if the
% entry hasn't been defined.
%\changes{0.5.4}{2015-12-15}{added existence check}
%    \begin{macrocode}
\renewcommand*{\glspostlinkhook}{%
 \ifglsentryexists{\glslabel}{\glsxtrpostlinkhook}{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostlinkhook}
% The entry label should already be stored in \cs{glslabel} by
% \cs{@gls@link}.
%    \begin{macrocode}
\newcommand*{\glsxtrpostlinkhook}{%
 \glsxtrdiscardperiod{\glslabel}%
 {\glsxtrpostlinkendsentence}%
 {\glsxtrpostlink}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostlink}
%    \begin{macrocode}
\newcommand*{\glsxtrpostlink}{%
 \csuse{glsxtrpostlink\glscategory{\glslabel}}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostlinkendsentence}
%\changes{0.3}{2015-12-02}{new}
% Done by \cs{glsxtrpostlinkhook} if a full stop is discarded.
%    \begin{macrocode}
\newcommand*{\glsxtrpostlinkendsentence}{%
 \ifcsdef{glsxtrpostlink\glscategory{\glslabel}}
 {%
   \csuse{glsxtrpostlink\glscategory{\glslabel}}%
%    \end{macrocode}
% Put the full stop back.
%    \begin{macrocode}
   .\spacefactor\sfcode`\. \relax
 }%
 {%
%    \end{macrocode}
% Assume the full stop was discarded because the entry ends with a
% period, so adjust the spacefactor.
%    \begin{macrocode}
   \spacefactor\sfcode`\. \relax
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostlinkAddDescOnFirstUse}
%\changes{0.3}{2015-12-02}{new}
% Provide a command for appending the description in parentheses on
% first use, for the convenience of users wanting to add this to the
% post link hook.
%    \begin{macrocode}
\newcommand*{\glsxtrpostlinkAddDescOnFirstUse}{%
  \glsxtrifwasfirstuse{\space(\glsaccessdesc{\glslabel})}{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrpostlinkAddSymbolOnFirstUse}
%\changes{0.3}{2015-12-02}{new}
% Provide a command for appending the symbol (if defined) in parentheses on
% first use, for the convenience of users wanting to add this to the
% post link hook.
%    \begin{macrocode}
\newcommand*{\glsxtrpostlinkAddSymbolOnFirstUse}{%
  \glsxtrifwasfirstuse
  {%
    \ifglshassymbol{\glslabel}{\space(\glsaccesssymbol{\glslabel})}{}%
  }%
  {}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrdiscardperiod}
% Discard following period (if present) if the
% \catattr{discardperiod} attribute is true. If a period is
% discarded, do the second argument otherwise do the third
% argument. The entry label is in the first argument.
% Since this is designed for abbreviations that end with a period,
% check if the plural form was used (which typically won't end with
% a period).
%\changes{0.3}{2015-12-02}{added check for plural}
%\changes{1.01}{2016-02-02}{added check for first use}
%    \begin{macrocode}
\newcommand*{\glsxtrdiscardperiod}[3]{%
 \glsxtrifwasfirstuse
 {%
   \glsifattribute{#1}{retainfirstuseperiod}{true}%
   {#3}%
   {%
     \glsifattribute{#1}{discardperiod}{true}%
     {%
       \glsifplural
       {%
         \glsifattribute{#1}{pluraldiscardperiod}{true}%
         {\glsxtrifperiod{#2}{#3}}%
         {#3}%
       }%
       {%
         \glsxtrifperiod{#2}{#3}%
       }%
     }%
     {#3}%
   }%
 }%
 {%
   \glsifattribute{#1}{discardperiod}{true}%
   {%
     \glsifplural
     {%
       \glsifattribute{#1}{pluraldiscardperiod}{true}%
       {\glsxtrifperiod{#2}{#3}}%
       {#3}%
     }%
     {%
       \glsxtrifperiod{#2}{#3}%
     }%
   }%
   {#3}%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrifperiod}
% Make a convenient user command to check if the next character is a
% full stop (period). Works like \cs{@ifstar} but uses
% \cs{new@ifnextchar} rather than \cs{@ifnextchar}
%    \begin{macrocode}
\newcommand*{\glsxtrifperiod}[1]{\new@ifnextchar.{\@firstoftwo{#1}}}
%    \end{macrocode}
%\end{macro}
%
% Sometimes it's useful to test if there's a punctuation character
% following the glossary entry.
%\begin{macro}{\glsxtr@punclist}
% List of characters identified as punctuation marks. (Be careful of
% \sty{babel} shorthands!) This doesn't allow for punctuation marks
% made up from multiple characters (such as \verb|''|).
%    \begin{macrocode}
\newcommand*{\glsxtr@punclist}{.,:;?!}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtraddpunctuationmark}
% Add character to punctuation list.
%    \begin{macrocode}
\newcommand*{\glsxtraddpunctuationmark}[1]{\appto\glsxtr@punclist{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrsetpunctuationmarks}
% Reset the punctuation list.
%    \begin{macrocode}
\newcommand*{\glsxtrsetpunctuationmarks}[1]{\def\glsxtr@punclist{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrifpunc}
%\begin{definition}
%\cs{glsxtrifnextpunc}\marg{true part}\marg{false part}
%\end{definition}
%Test if this is followed by a punctuation mark. (Adapted from
%\cs{new@ifnextchar}.)
%    \begin{macrocode}
\newcommand*{\glsxtrifnextpunc}[2]{%
  \def\reserved@a{#1}% 
  \def\reserved@b{#2}%
  \futurelet\@glspunc@token\glsxtr@ifnextpunc
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@ifnextpunc}
%    \begin{macrocode}
\newcommand*{\glsxtr@ifnextpunc}{%
 \glsxtr@ifpunctoken{\@glspunc@token}{\let\reserved@b\reserved@a}{}%
 \reserved@b
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@ifpunctoken}
% Test if the token given in the first argument is in the
% punctuation list.
%    \begin{macrocode}
\newcommand*{\glsxtr@ifpunctoken}[1]{%
  \expandafter\@glsxtr@ifpunctoken\expandafter#1\glsxtr@punclist\@nnil
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@ifpunctoken}
%    \begin{macrocode}
\def\@glsxtr@ifpunctoken#1#2{%
  \let\reserved@d=#2%
  \ifx\reserved@d\@nnil
    \let\glsxtr@next\@glsxtr@notfoundinlist
  \else
    \ifx#1\reserved@d
     \let\glsxtr@next\@glsxtr@foundinlist
    \else
     \let\glsxtr@next\@glsxtr@ifpunctoken
    \fi
  \fi
  \glsxtr@next#1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@foundinlist}
%    \begin{macrocode}
\def\@glsxtr@foundinlist#1\@nnil{\@firstoftwo}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@notfoundinlist}
%    \begin{macrocode}
\def\@glsxtr@notfoundinlist#1{\@secondoftwo}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrdopostpunc}
%\begin{definition}
%\cs{glsxtrdopostpunc}\marg{code}
%\end{definition}
% If this is followed be a punctuation character, do \meta{code}
% after the character otherwise do \meta{code} before whatever comes
% next.
%    \begin{macrocode}
\newcommand{\glsxtrdopostpunc}[1]{%
  \glsxtrifnextpunc{\@glsxtr@swaptwo{#1}}{#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@swaptwo}
%    \begin{macrocode}
\newcommand{\@glsxtr@swaptwo}[2]{#2#1}
%    \end{macrocode}
%\end{macro}
%
%\section{Abbreviations}
%
%The \qt{acronym} code from \styfmt{glossaries} is misnamed as it's more
%often used for other forms of abbreviations. This code corrects
%this inconsistency, but rather than just having synonyms, provide 
% commands for abbreviations that have a similar, but not identical,
% underlying mechanism to acronyms.
%
% If there's a style for the given category, apply it.
%    \begin{macrocode}
\define@key{glsxtrabbrv}{category}{%
 \edef\glscategorylabel{#1}%
 \ifcsdef{@glsabbrv@current@#1}%
 {%
%    \end{macrocode}
% Warning should already have been issued.
%    \begin{macrocode}
   \let\@glsxtr@orgwarndep\GlsXtrWarnDeprecatedAbbrStyle
   \let\GlsXtrWarnDeprecatedAbbrStyle\@gobbletwo
   \glsxtr@applyabbrvstyle{\csname @glsabbrv@current@#1\endcsname}%
   \let\GlsXtrWarnDeprecatedAbbrStyle\@glsxtr@orgwarndep
 }%
 {}%
}
%    \end{macrocode}
% Save the short plural form. This may be needed before the entry is
% defined.
%    \begin{macrocode}
\define@key{glsxtrabbrv}{shortplural}{%
  \def\@gls@shortpl{#1}%
}
%    \end{macrocode}
% Similarly for the long plural form.
%    \begin{macrocode}
\define@key{glsxtrabbrv}{longplural}{%
  \def\@gls@longpl{#1}%
}
%    \end{macrocode}
%
% Token registers for the short plural and long plural, provided for
% use in the abbreviation style definitions.
%\begin{macro}{\glsshortpltok}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newtoks\glsshortpltok
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glslongpltok}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newtoks\glslongpltok
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@insertdots}
%\changes{0.3}{2015-12-02}{new}
% Provided in case user wants to automatically insert dots between
% each letter of the abbreviation. This should be applied before
% defining the abbreviation to optimise the document build.
% (Otherwise, it would have to be done each time the short form is
% required, which is an unnecessary waste of time.) For this to work
% the short form must be expanded when passed to
% \cs{newabbreviation}. Note that explicitly using the
% \gloskey{short} or \gloskey{shortplural} keys will override this.
%    \begin{macrocode}
\newcommand*{\@glsxtr@insertdots}[2]{%
  \def#1{}%
  \@glsxtr@insert@dots#1#2\@nnil
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtr@insert@dots}
%    \begin{macrocode}
\newcommand*{\@glsxtr@insert@dots}[2]{%
  \ifx\@nnil#2\relax
   \let\@glsxtr@insert@dots@next\@gobble
  \else
   \ifx\relax#2\relax
   \else
     \appto#1{#2.}%
   \fi
   \let\@glsxtr@insert@dots@next\@glsxtr@insert@dots
  \fi
  \@glsxtr@insert@dots@next#1%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newabbreviation}
% Define a new generic abbreviation.
%    \begin{macrocode}
\newcommand*{\newabbreviation}[4][]{%
  \glskeylisttok{#1}%
  \glslabeltok{#2}%
  \glsshorttok{#3}%
  \glslongtok{#4}%
%    \end{macrocode}
% Get the category.
%\changes{0.3}{2015-12-02}{fixed family name in \cs{setkeys}}
%    \begin{macrocode}
  \def\glscategorylabel{abbreviation}%
  \glsxtr@applyabbrvstyle{\@glsabbrv@current@abbreviation}%
  \setkeys*{glsxtrabbrv}[shortplural,longplural]{#1}%
%    \end{macrocode}
% Set the default long plural
%    \begin{macrocode}
  \def\@gls@longpl{#4\glspluralsuffix}%
%    \end{macrocode}
% Has the \catattr{insertdots} attribute been set?
%    \begin{macrocode}
  \glsifcategoryattribute{\glscategorylabel}{insertdots}{true}%
  {%
    \@glsxtr@insertdots\@gls@short{#3}%
    \expandafter\glsshorttok\expandafter{\@gls@short\spacefactor1000 \relax}%
    \glsifcategoryattribute{\glscategorylabel}{aposplural}{true}%
    {%
      \expandafter\def\expandafter\@gls@shortpl\expandafter{\@gls@short
        '\abbrvpluralsuffix}%
    }%
    {%
      \glsifcategoryattribute{\glscategorylabel}{noshortplural}{true}%
      {%
        \let\@gls@shortpl\@gls@short
      }%
      {%
        \expandafter\def\expandafter\@gls@shortpl\expandafter{\@gls@short
          \abbrvpluralsuffix}%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% \catattr{insertdots} not true.
%    \begin{macrocode}
    \glsifcategoryattribute{\glscategorylabel}{aposplural}{true}%
    {%
      \def\@gls@shortpl{#3'\abbrvpluralsuffix}%
    }% 
    {%
      \glsifcategoryattribute{\glscategorylabel}{noshortplural}{true}%
      {%
        \def\@gls@shortpl{#3}%
      }%
      {%
        \def\@gls@shortpl{#3\abbrvpluralsuffix}%
      }%
    }%
  }%
%    \end{macrocode}
% Hook for further customisation if required:
%    \begin{macrocode}
  \glsxtrnewabbrevpresetkeyhook{#1}{#2}{#3}%
%    \end{macrocode}
% Get the short and long plurals provided by user in optional
% argument to override defaults, if necessary.
%    \begin{macrocode}
  \setkeys*{glsxtrabbrv}[category]{#1}%
%    \end{macrocode}
% Set the plural token registers so the values can be accessed by
% the abbreviation styles.
%    \begin{macrocode}
  \expandafter\glsshortpltok\expandafter{\@gls@shortpl}%
  \expandafter\glslongpltok\expandafter{\@gls@longpl}%
%    \end{macrocode}
% Do any extra setup provided by hook:
%    \begin{macrocode}
  \newabbreviationhook
%    \end{macrocode}
% Define this entry:
%    \begin{macrocode}
  \protected@edef\@do@newglossaryentry{%
    \noexpand\newglossaryentry{\the\glslabeltok}%
    {%
      type=\glsxtrabbrvtype,%
      category=abbreviation,%
      short={\the\glsshorttok},%
      shortplural={\the\glsshortpltok},%
      long={\the\glslongtok},%
      longplural={\the\glslongpltok},%
      name={\the\glsshorttok},%
      \CustomAbbreviationFields,%
      \the\glskeylisttok
    }%
  }%
  \@do@newglossaryentry
  \GlsXtrPostNewAbbreviation
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrnewabbrevpresetkeyhook}
% Hook for extra stuff in \cs{newabbreviation}
%\changes{0.5.2}{2015-12-08}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrnewabbrevpresetkeyhook}[3]{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrPostNewAbbreviation}
% Hook used by abbreviation styles.
%    \begin{macrocode}
\newcommand*{\GlsXtrPostNewAbbreviation}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newabbreviationhook}
% Hook for use with \cs{newabbreviation}.
%    \begin{macrocode}
\newcommand*{\newabbreviationhook}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\CustomAbbreviationFields}
%    \begin{macrocode}
\newcommand*{\CustomAbbreviationFields}{}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfullformat}
% Full format without case change.
%    \begin{macrocode}
\newcommand*{\glsxtrfullformat}[2]{%
  \glsfirstlongfont{\glsaccesslong{#1}}#2\glsxtrfullsep{#1}%
  (\protect\glsfirstabbrvfont{\glsaccessshort{#1}})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrfullformat}
% Full format with case change.
%    \begin{macrocode}
\newcommand*{\Glsxtrfullformat}[2]{%
  \glsfirstlongfont{\Glsaccesslong{#1}}#2\glsxtrfullsep{#1}%
  (\protect\glsfirstabbrvfont{\glsaccessshort{#1}})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfullplformat}
% Plural full format without case change.
%    \begin{macrocode}
\newcommand*{\glsxtrfullplformat}[2]{%
  \glsfirstlongfont{\glsaccesslongpl{#1}}#2\glsxtrfullsep{#1}%
  (\protect\glsfirstabbrvfont{\glsaccessshortpl{#1}})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrfullplformat}
% Plural full format with case change.
%    \begin{macrocode}
\newcommand*{\Glsxtrfullplformat}[2]{%
  \glsfirstlongfont{\Glsaccesslongpl{#1}}#2\glsxtrfullsep{#1}%
  (\protect\glsfirstabbrvfont{\glsaccessshortpl{#1}})%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfullsep}
% Separator used by full format is a space by default. The argument
% is the entry's label.
%    \begin{macrocode}
\newcommand*{\glsxtrfullsep}[1]{\space}
%    \end{macrocode}
%\end{macro}
%
% In-line formats in case first use isn't compatible with
% \cs{glsentryfull} (for example, first use suppresses the long form
% or uses a footnote).
%\begin{macro}{\glsxtrinlinefullformat}
% Full format without case change.
%    \begin{macrocode}
\newcommand*{\glsxtrinlinefullformat}{\glsxtrfullformat}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrinlinefullformat}
% Full format with case change.
%    \begin{macrocode}
\newcommand*{\Glsxtrinlinefullformat}{\Glsxtrfullformat}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfullplformat}
% Plural full format without case change.
%    \begin{macrocode}
\newcommand*{\glsxtrinlinefullplformat}{\glsxtrfullplformat}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrinlinefullplformat}
% Plural full format with case change.
%    \begin{macrocode}
\newcommand*{\Glsxtrinlinefullplformat}{\Glsxtrfullplformat}
%    \end{macrocode}
%\end{macro}
%
% Redefine \cs{glsentryfull} etc to use the inline format.
% Since these commands as supposed to be expandable, they can only
% use the currently applied style. If there are mixed styles, you'll
% need to use the \cs{glsxtrfull} set of commands instead.
%\begin{macro}{\glsentryfull}
%    \begin{macrocode}
\renewcommand*{\glsentryfull}[1]{\glsxtrinlinefullformat{#1}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsentryfull}
%    \begin{macrocode}
\renewcommand*{\Glsentryfull}[1]{\Glsxtrinlinefullformat{#1}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsentryfullpl}
%    \begin{macrocode}
\renewcommand*{\glsentryfullpl}[1]{\glsxtrinlinefullplformat{#1}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsentryfullpl}
%    \begin{macrocode}
\renewcommand*{\Glsentryfullpl}[1]{\Glsxtrinlinefullplformat{#1}{}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfirstabbrvfont}
% Font changing command used for the abbreviation on first use or in
% the full format.
%    \begin{macrocode}
\newcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfirstabbrvdefaultfont}
% Font changing command used for the abbreviation on first use or in
% the full format.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsfirstabbrvdefaultfont}[1]{\glsabbrvfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsabbrvfont}
% Font changing command used for the abbreviation on subsequent use.
%    \begin{macrocode}
\newcommand*{\glsabbrvfont}[1]{\glsabbrvdefaultfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsabbrvdefaultfont}
%\changes{0.3}{2015-12-02}{renamed from \cs{abbrvdefaultfont}}
%    \begin{macrocode}
\newcommand*{\glsabbrvdefaultfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongfont}
%\changes{1.04}{2016-05-02}{new}
% Font changing command used for the long form in commands like
% \cs{glsxtrlong}.
%    \begin{macrocode}
\newcommand*{\glslongfont}[1]{\glslongdefaultfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongdefaultfont}
% Default font changing command used for the long form in commands like
%\changes{1.04}{2016-05-02}{new}
% \cs{glsxtrlong}.
%    \begin{macrocode}
\newcommand*{\glslongdefaultfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfirstlongfont}
% Font changing command used for the long form on first use or in
% the full format.
%    \begin{macrocode}
\newcommand*{\glsfirstlongfont}[1]{\glslongfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfirstlongdefaultfont}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsfirstlongdefaultfont}[1]{\glslongdefaultfont{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\abbrvpluralsuffix}
% Default plural suffix.
%    \begin{macrocode}
\newcommand*{\abbrvpluralsuffix}{\glspluralsuffix}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfull}
% Full form (no case-change).
%    \begin{macrocode}
\newrobustcmd*{\glsxtrfull}{\@gls@hyp@opt\ns@glsxtrfull}
\newcommand*\ns@glsxtrfull[2][]{%
  \new@ifnextchar[{\@glsxtr@full{#1}{#2}}%
                  {\@glsxtr@full{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtr@full}
% Low-level macro:
%    \begin{macrocode}
\def\@glsxtr@full#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{\glsxtrinlinefullformat{#2}{#3}}%
%    \end{macrocode}
% What should \cs{glsxtrifwasfirstuse} be set to here? Where the inline
% and display full forms are the same, this is essentially emulating
% first use, to it make sense for the postlink hook to pretend it 
% was a first use instance. It makes less sense if the inline and
% display forms are different. Provide a hook to make it easier to
% reconfigure.
%    \begin{macrocode}
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrsetupfulldefs}
%    \begin{macrocode}
\newcommand*{\glsxtrsetupfulldefs}{%
  \let\glsxtrifwasfirstuse\@firstoftwo
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrfull}
% Full form (first letter uppercase).
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrfull}{\@gls@hyp@opt\ns@Glsxtrfull}
\newcommand*\ns@Glsxtrfull[2][]{%
  \new@ifnextchar[{\@Glsxtr@full{#1}{#2}}%
                  {\@Glsxtr@full{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@Glsxtr@full}
% Low-level macro:
%    \begin{macrocode}
\def\@Glsxtr@full#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{\Glsxtrinlinefullformat{#2}{#3}}%
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrfull}
% Full form (all uppercase).
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrfull}{\@gls@hyp@opt\ns@GLSxtrfull}
\newcommand*\ns@GLSxtrfull[2][]{%
  \new@ifnextchar[{\@GLSxtr@full{#1}{#2}}%
                  {\@GLSxtr@full{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@GLSxtr@full}
% Low-level macro:
%    \begin{macrocode}
\def\@GLSxtr@full#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{\mfirstucMakeUppercase{\glsxtrinlinefullformat{#2}{#3}}}%
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrfullpl}
% Plural full form (no case-change).
%    \begin{macrocode}
\newrobustcmd*{\glsxtrfullpl}{\@gls@hyp@opt\ns@glsxtrfullpl}
\newcommand*\ns@glsxtrfullpl[2][]{%
  \new@ifnextchar[{\@glsxtr@fullpl{#1}{#2}}%
                  {\@glsxtr@fullpl{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtr@fullpl}
% Low-level macro:
%    \begin{macrocode}
\def\@glsxtr@fullpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{\glsxtrinlinefullplformat{#2}{#3}}%
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrfullpl}
% Plural full form (first letter uppercase).
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrfullpl}{\@gls@hyp@opt\ns@Glsxtrfullpl}
\newcommand*\ns@Glsxtrfullpl[2][]{%
  \new@ifnextchar[{\@Glsxtr@fullpl{#1}{#2}}%
                  {\@Glsxtr@fullpl{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@Glsxtr@fullpl}
% Low-level macro:
%    \begin{macrocode}
\def\@Glsxtr@fullpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{\Glsxtrinlinefullplformat{#2}{#3}}%
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrfullpl}
% Plural full form (all upper case).
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrfullpl}{\@gls@hyp@opt\ns@GLSxtrfullpl}
\newcommand*\ns@GLSxtrfullpl[2][]{%
  \new@ifnextchar[{\@GLSxtr@fullpl{#1}{#2}}%
                  {\@GLSxtr@fullpl{#1}{#2}[]}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@GLSxtr@fullpl}
% Low-level macro:
%    \begin{macrocode}
\def\@GLSxtr@fullpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase{\glsxtrinlinefullplformat{#2}{#3}}}%
    \glsxtrsetupfulldefs
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
% The short and long forms work in a similar way to acronyms.
%\begin{macro}{\glsxtrshort}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrshort}{\@gls@hyp@opt\ns@glsxtrshort}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@glsxtrshort}[2][]{%
  \new@ifnextchar[{\@glsxtrshort{#1}{#2}}{\@glsxtrshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsxtrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
%    \end{macrocode}
% Need to make sure \cs{glsabbrvfont} is set correctly.
%    \begin{macrocode}
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glsabbrvfont{\glsaccessshort{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrshort}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrshort}{\@gls@hyp@opt\ns@Glsxtrshort}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Glsxtrshort}[2][]{%
  \new@ifnextchar[{\@Glsxtrshort{#1}{#2}}{\@Glsxtrshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsxtrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glsabbrvfont{\Glsaccessshort{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrshort}
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrshort}{\@gls@hyp@opt\ns@GLSxtrshort}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@GLSxtrshort}[2][]{%
  \new@ifnextchar[{\@GLSxtrshort{#1}{#2}}{\@GLSxtrshort{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSxtrshort#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase
      {\glsabbrvfont{\glsaccessshort{#2}\ifglsxtrinsertinside#3\fi}%
        \ifglsxtrinsertinside\else#3\fi
      }%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrlong}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrlong}{\@gls@hyp@opt\ns@glsxtrlong}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@glsxtrlong}[2][]{%
  \new@ifnextchar[{\@glsxtrlong{#1}{#2}}{\@glsxtrlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsxtrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glslongfont{\glsaccesslong{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrlong}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrlong}{\@gls@hyp@opt\ns@Glsxtrlong}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Glsxtrlong}[2][]{%
  \new@ifnextchar[{\@Glsxtrlong{#1}{#2}}{\@Glsxtrlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsxtrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glslongfont{\Glsaccesslong{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrlong}
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrlong}{\@gls@hyp@opt\ns@GLSxtrlong}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@GLSxtrlong}[2][]{%
  \new@ifnextchar[{\@GLSxtrlong{#1}{#2}}{\@GLSxtrlong{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSxtrlong#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@secondoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
     \mfirstucMakeUppercase
     {\glslongfont{\glsaccesslong{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
     }%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
% Plural short forms:
%\begin{macro}{\glsxtrshortpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrshortpl}{\@gls@hyp@opt\ns@glsxtrshortpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@glsxtrshortpl}[2][]{%
  \new@ifnextchar[{\@glsxtrshortpl{#1}{#2}}{\@glsxtrshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsxtrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glsabbrvfont{\glsaccessshortpl{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrshortpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrshortpl}{\@gls@hyp@opt\ns@Glsxtrshortpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Glsxtrshortpl}[2][]{%
  \new@ifnextchar[{\@Glsxtrshortpl{#1}{#2}}{\@Glsxtrshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsxtrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glsabbrvfont{\Glsaccessshortpl{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrshortpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrshortpl}{\@gls@hyp@opt\ns@GLSxtrshortpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@GLSxtrshortpl}[2][]{%
  \new@ifnextchar[{\@GLSxtrshortpl{#1}{#2}}{\@GLSxtrshortpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSxtrshortpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \glssetabbrvfmt{\glscategory{#2}}%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase
      {\glsabbrvfont{\glsaccessshortpl{#2}\ifglsxtrinsertinside#3\fi}%
       \ifglsxtrinsertinside\else#3\fi
      }%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
% Plural long forms:
%\begin{macro}{\glsxtrlongpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrlongpl}{\@gls@hyp@opt\ns@glsxtrlongpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@glsxtrlongpl}[2][]{%
  \new@ifnextchar[{\@glsxtrlongpl{#1}{#2}}{\@glsxtrlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@glsxtrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@firstofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glslongfont{\glsaccesslongpl{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrlongpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrlongpl}{\@gls@hyp@opt\ns@Glsxtrlongpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@Glsxtrlongpl}[2][]{%
  \new@ifnextchar[{\@Glsxtrlongpl{#1}{#2}}{\@Glsxtrlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@Glsxtrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@secondofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \glslongfont{\Glsaccesslongpl{#2}\ifglsxtrinsertinside#3\fi}%
      \ifglsxtrinsertinside\else#3\fi
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GLSxtrlongpl}
%\changes{0.3}{2015-12-02}{new}
%    \begin{macrocode}
\newrobustcmd*{\GLSxtrlongpl}{\@gls@hyp@opt\ns@GLSxtrlongpl}
%    \end{macrocode}
% Define the un-starred form. Need to determine if there is
% a final optional argument
%    \begin{macrocode}
\newcommand*{\ns@GLSxtrlongpl}[2][]{%
  \new@ifnextchar[{\@GLSxtrlongpl{#1}{#2}}{\@GLSxtrlongpl{#1}{#2}[]}%
}
%    \end{macrocode}
% Read in the final optional argument:
%    \begin{macrocode}
\def\@GLSxtrlongpl#1#2[#3]{%
  \glsdoifexists{#2}%
  {%
    \let\do@gls@link@checkfirsthyper\@gls@link@nocheckfirsthyper
    \let\glsxtrifwasfirstuse\@secondoftwo
    \let\glsifplural\@firstoftwo
    \let\glscapscase\@thirdofthree
    \let\glsinsert\@empty
    \def\glscustomtext{%
      \mfirstucMakeUppercase
      {\glslongfont{\glsaccesslongpl{#2}\ifglsxtrinsertinside#3\fi}%
       \ifglsxtrinsertinside\else#3\fi
      }%
    }%
    \@gls@link[#1]{#2}{\csname gls@\glstype @entryfmt\endcsname}%
  }%
  \glspostlinkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glssetabbrvfmt}
% Set the current format for the given category (or the
% \category{abbreviation} category if unset).
%    \begin{macrocode}
\newcommand*{\glssetabbrvfmt}[1]{%
  \ifcsdef{@glsabbrv@current@#1}%
  {\glsxtr@applyabbrvfmt{\csname @glsabbrv@current@#1\endcsname}}%
  {\glsxtr@applyabbrvfmt{\@glsabbrv@current@abbreviation}}%
}
%    \end{macrocode}
%\end{macro}
%
%\changes{0.5.2}{2015-12-08}{removed \cs{glsxtrabbrvfmt}}
%\begin{macro}{\glsxtrgenabbrvfmt}
% Similar to \cs{glsgenacfmt}, but for abbreviations.
%    \begin{macrocode}
\newcommand*{\glsxtrgenabbrvfmt}{%
  \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}
          \glsabbrvfont{\glsaccessshortpl{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, make first letter upper case:
%    \begin{macrocode}
          \glsabbrvfont{\Glsaccessshortpl{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\glsabbrvfont{\glsaccessshortpl{\glslabel}}\glsinsert}%
        }%
      }%
      {%
%    \end{macrocode}
% Subsequent singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% Subsequent singular form, don't adjust case:
%    \begin{macrocode}
          \glsabbrvfont{\glsaccessshort{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, make first letter upper case:
%    \begin{macrocode}
          \glsabbrvfont{\Glsaccessshort{\glslabel}}\glsinsert
        }%
        {%
%    \end{macrocode}
% Subsequent singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\glsabbrvfont{\glsaccessshort{\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}
          \glsxtrfullplformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, make first letter upper case:
%    \begin{macrocode}
          \Glsxtrfullplformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use plural form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
            {\glsxtrfullplformat{\glslabel}{\glsinsert}}%
        }%
      }%
      {%
%    \end{macrocode}
% First use singular form
%    \begin{macrocode}
        \glscapscase
        {%
%    \end{macrocode}
% First use singular form, don't adjust case:
%    \begin{macrocode}
          \glsxtrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, make first letter upper case:
%    \begin{macrocode}
          \Glsxtrfullformat{\glslabel}{\glsinsert}%
        }%
        {%
%    \end{macrocode}
% First use singular form, all caps:
%    \begin{macrocode}
          \mfirstucMakeUppercase
           {\glsxtrfullformat{\glslabel}{\glsinsert}}%
        }%
      }%
    }%
  }%
  {%
%    \end{macrocode}
% User supplied text.
%    \begin{macrocode}
    \glscustomtext
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Abbreviation Styles Setup}
%
%\begin{macro}{\setabbreviationstyle}
%    \begin{macrocode}
\newcommand*{\setabbreviationstyle}[2][abbreviation]{%
  \ifcsundef{@glsabbrv@dispstyle@setup@#2}
  {%
    \PackageError{glossaries-extra}{Undefined abbreviation style `#2'}{}%
  }%
  {%
%    \end{macrocode}
% Have abbreviations already been defined for this category?
%\changes{0.5.2}{2015-12-08}{added check for post-definition style switch}
%    \begin{macrocode}
     \ifcsstring{@glsabbrv@current@#1}{#2}%
     {%
%    \end{macrocode}
% Style already set.
%    \begin{macrocode}
     }%
     {%
       \def\@glsxtr@dostylewarn{}%
       \glsforeachincategory{#1}{\@gls@type}{\@gls@label}%
       {%
         \def\@glsxtr@dostylewarn{\GlossariesWarning{Abbreviation
           style has been switched \MessageBreak
           for category `#1', \MessageBreak
           but there have already been entries \MessageBreak
           defined for this category. Unwanted \MessageBreak
           side-effects may result}}%
         \@endfortrue
       }%
       \@glsxtr@dostylewarn
%    \end{macrocode}
% Set up the style for the given category.
%    \begin{macrocode}
       \csdef{@glsabbrv@current@#1}{#2}%
       \glsxtr@applyabbrvstyle{#2}%
     }%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@applyabbrvstyle}
% Apply the abbreviation style without existence check.
%    \begin{macrocode}
\newcommand*{\glsxtr@applyabbrvstyle}[1]{%
  \csuse{@glsabbrv@dispstyle@setup@#1}%
  \csuse{@glsabbrv@dispstyle@fmts@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtr@applyabbrvfmt}
% Only apply the style formats.
%    \begin{macrocode}
\newcommand*{\glsxtr@applyabbrvfmt}[1]{%
  \csuse{@glsabbrv@dispstyle@fmts@#1}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\newabbreviationstyle}
% This is different from \cs{newacronymstyle}. The first argument is
% the label, the second argument sets the information required when
% defining the new abbreviation and the third argument sets the
% commands used to display the full format.
%\changes{1.04}{2016-05-02}{bug fix: corrected test for existence}
%    \begin{macrocode}
\newcommand*{\newabbreviationstyle}[3]{%
  \ifcsdef{@glsabbrv@dispstyle@setup@#1}
  {%
    \PackageError{glossaries-extra}{Abbreviation style `#1' already
     defined}{}%
  }%
  {%
    \csdef{@glsabbrv@dispstyle@setup@#1}{%
%    \end{macrocode}
% Initialise hook to do nothing. The style may change this.
%    \begin{macrocode}
     \renewcommand*{\GlsXtrPostNewAbbreviation}{}%
     #2}%
    \csdef{@glsabbrv@dispstyle@fmts@#1}{%
%    \end{macrocode}
% Assume in-line form is the same as first use. The style may change
% this.
%    \begin{macrocode}
    \renewcommand*{\glsxtrinlinefullformat}{\glsxtrfullformat}%
    \renewcommand*{\Glsxtrinlinefullformat}{\Glsxtrfullformat}%
    \renewcommand*{\glsxtrinlinefullplformat}{\glsxtrfullplformat}%
    \renewcommand*{\Glsxtrinlinefullplformat}{\Glsxtrfullplformat}%
    #3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\renewabbreviationstyle}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\renewabbreviationstyle}[3]{%
  \ifcsundef{@glsabbrv@dispstyle@setup@#1}
  {%
    \PackageError{glossaries-extra}{Abbreviation style `#1' not defined}{}%
  }%
  {%
    \csdef{@glsabbrv@dispstyle@setup@#1}{%
%    \end{macrocode}
% Initialise hook to do nothing. The style may change this.
%    \begin{macrocode}
     \renewcommand*{\GlsXtrPostNewAbbreviation}{}%
     #2}%
    \csdef{@glsabbrv@dispstyle@fmts@#1}{%
%    \end{macrocode}
% Assume in-line form is the same as first use. The style may change
% this.
%    \begin{macrocode}
    \renewcommand*{\glsxtrinlinefullformat}{\glsxtrfullformat}%
    \renewcommand*{\Glsxtrinlinefullformat}{\Glsxtrfullformat}%
    \renewcommand*{\glsxtrinlinefullplformat}{\glsxtrfullplformat}%
    \renewcommand*{\Glsxtrinlinefullplformat}{\Glsxtrfullplformat}%
    #3}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\letabbreviationstyle}
%\changes{1.04}{2016-05-02}{new}
% Define a synonym for an abbreviation style. The first argument is
% the new name. The second argument is the original style's name.
%    \begin{macrocode}
\newcommand*{\letabbreviationstyle}[2]{%
  \csletcs{@glsabbrv@dispstyle@setup@#1}{@glsabbrv@dispstyle@setup@#2}%
  \csletcs{@glsabbrv@dispstyle@fmts@#1}{@glsabbrv@dispstyle@fmts@#2}%
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\@glsxtr@deprecated@abbrstyle}
%\changes{1.04}{2016-05-02}{new}
%\begin{definition}
%\cs{@glsxtr@deprecated@abbrstyle}\marg{old-name}\marg{new-name}
%\end{definition}
% Define a synonym for a deprecated abbreviation style.
%    \begin{macrocode}
\newcommand*{\@glsxtr@deprecated@abbrstyle}[2]{%
  \csdef{@glsabbrv@dispstyle@setup@#1}{%
    \GlsXtrWarnDeprecatedAbbrStyle{#1}{#2}%
    \csuse{@glsabbrv@dispstyle@setup@#2}%
  }%
  \csletcs{@glsabbrv@dispstyle@fmts@#1}{@glsabbrv@dispstyle@fmts@#2}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrWarnDeprecatedAbbrStyle}
%Generate warning for deprecated style use.
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\GlsXtrWarnDeprecatedAbbrStyle}[2]{%
  \GlossariesExtraWarning{Deprecated abbreviation style name `#1',
  use `#2' instead}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrUseAbbrStyleSetup}
%    \begin{macrocode}
\newcommand*{\GlsXtrUseAbbrStyleSetup}[1]{%
  \ifcsundef{@glsabbrv@dispstyle@setup@#1}%
  {%
     \PackageError{glossaries-extra}%
     {Unknown abbreviation style definitions `#1'}{}%
  }%
  {%
     \csname @glsabbrv@dispstyle@setup@#1\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\GlsXtrUseAbbrStyleFmts}
%    \begin{macrocode}
\newcommand*{\GlsXtrUseAbbrStyleFmts}[1]{%
  \ifcsundef{@glsabbrv@dispstyle@fmts@#1}%
  {%
     \PackageError{glossaries-extra}%
     {Unknown abbreviation style formats `#1'}{}%
  }%
  {%
     \csname @glsabbrv@dispstyle@fmts@#1\endcsname
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\subsection{Predefined Styles (Default Font)}
% Define some common styles. These will set the \gloskey{first},
% \gloskey{firstplural}, \gloskey{text} and \gloskey{plural}
% keys, even if the \catattr{regular} attribute isn't set to
% \qt{true}. If this attribute is set, commands like \cs{gls} will
% use them as per a regular entry, otherwise those keys will be
% ignored unless explicitly invoked by the user with commands like
% \cs{glsfirst}. In order for the first letter uppercase versions to
% work correctly, \cs{glsxtrfullformat} needs to be expanded when
% those keys are set. The final optional argument of \cs{glsfirst}
% will behave differently to the final optional argument of \cs{gls}
% with some styles.
%
%\begin{macro}{\ifglsxtrinsertinside}
%\changes{1.02}{2016-04-25}{new}
% Switch to determine if the insert text should be inside or outside
% the font changing command. The default is outside.
%    \begin{macrocode}
\newif\ifglsxtrinsertinside
\glsxtrinsertinsidefalse
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short}
%    \begin{macrocode}
\newabbreviationstyle{long-short}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstlongfont{\the\glslongtok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshorttok})},%
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshortpltok})},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}},%
    description={\the\glslongtok}}%
%    \end{macrocode}
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongdefaultfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongdefaultfont{##1}}%
%    \end{macrocode}
% The first use full form and the inline full form are the same for
% this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstlongfont{\glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtrfullsep{##1}%
    (\glsfirstabbrvfont{\glsaccessshort{##1}})%
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstlongfont{\Glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstabbrvfont{\glsaccessshort{##1}})%
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\Glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
% Set this as the default style for general abbreviations:
%    \begin{macrocode}
\setabbreviationstyle{long-short}
%    \end{macrocode}
%
%\begin{macro}{\glsxtrlongshortdescsort}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrlongshortdescsort}{\the\glslongtok\space(\the\glsshorttok)}
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short-desc}
% User supplies description. The long form is included in the name.
%\changes{0.3}{2015-12-02}{fixed name to use \cs{glslabeltok}}
%    \begin{macrocode}
\newabbreviationstyle{long-short-desc}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsxtrfullformat{\the\glslabeltok}{}},
    sort={\glsxtrlongshortdescsort},%
    first={\protect\glsfirstlongfont{\the\glslongtok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshorttok})},%
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshortpltok})},%
%    \end{macrocode}
%The \gloskey{text} key should only have the short form.
%\changes{1.07}{2016-08-15}{added missing text key}
%    \begin{macrocode}
    text={\protect\glsabbrvfont{\the\glsshorttok}},%
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{fixed misspelling of \cs{glsabbrvfont}}
%    \begin{macrocode}
    plural={\protect\glsabbrvfont{\the\glsshortpltok}}%
  }%
%    \end{macrocode}
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
  \GlsXtrUseAbbrStyleFmts{long-short}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-long}
% Short form followed by long form in parenthesis on first use.
%    \begin{macrocode}
\newabbreviationstyle{short-long}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    description={\the\glslongtok},%
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongtok})},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongpltok})},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}}}%
%    \end{macrocode}
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongdefaultfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongdefaultfont{##1}}%
%    \end{macrocode}
% The first use full form and the inline full form are the same for
% this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslongpl{##1}})%
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslongpl{##1}})%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-long-desc}
% User supplies description. The long form is included in the name.
%\changes{0.3}{2015-12-02}{fixed name to use \cs{glslabeltok}}
%    \begin{macrocode}
\newabbreviationstyle{short-long-desc}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsxtrfullformat{\the\glslabeltok}{}},
    sort={\the\glsshorttok},%
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongtok})},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongpltok})},%
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{added text key}
%    \begin{macrocode}
    text={\protect\glsabbrvfont{\the\glsshorttok}},%
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{fixed misspelling of \cs{glsabbrvfont} in plural
%key}
%    \begin{macrocode}
    plural={\protect\glsabbrvfont{\the\glsshortpltok}}%
  }%
%    \end{macrocode}
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
  \GlsXtrUseAbbrStyleFmts{short-long}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{macro}{\glsfirstlongfootnotefont}
%\changes{1.05}{2016-06-10}{new}
%Only used by the \qt{footnote} styles.
%    \begin{macrocode}
\newcommand*{\glsfirstlongfootnotefont}[1]{\glslongfootnotefont{#1}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongfootnotefont}
%\changes{1.05}{2016-06-10}{new}
%Only used by the \qt{footnote} styles.
%    \begin{macrocode}
\newcommand*{\glslongfootnotefont}[1]{\glslongdefaultfont{#1}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrabbrvfootnote}
%\begin{definition}
%\cs{glsxtrabbrvfootnote}\marg{label}\marg{long}
%\end{definition}
%\changes{1.07}{2016-08-15}{new}
%Command used by footnote abbreviation styles. The default
%definition ignores the first argument. The second argument
%\meta{long} includes the font changing command and may be the
%singular or plural form, depending on the command that was used
%(for example, \cs{gls} or \cs{glspl}).
%    \begin{macrocode}
\newcommand*{\glsxtrabbrvfootnote}[2]{\footnote{#2}}
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{footnote}
% Short form followed by long form in footnote on first use.
%    \begin{macrocode}
\newabbreviationstyle{footnote}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    description={\the\glslongtok},%
%    \end{macrocode}
%\changes{1.07}{2016-08-15}{changed first forms to use
%\cs{glsfirstlongfootnotefont}}
%    \begin{macrocode}
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}%
     \protect\glsxtrabbrvfootnote{\the\glslabeltok}%
       {\protect\glsfirstlongfootnotefont{\the\glslongtok}}},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}%
     \protect\glsxtrabbrvfootnote{\the\glslabeltok}%
       {\protect\glsfirstlongfootnotefont{\the\glslongpltok}}},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}}}%
%    \end{macrocode}
% Switch off hyperlinks on first use to prevent nested hyperlinks,
% and unset the \catattr{regular} attribute if it has been set.
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{nohyperfirst}{true}%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongfootnotefont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongfootnotefont{##1}}%
%    \end{macrocode}
% The full format displays the short form followed by the long form
% as a footnote.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \protect\glsxtrabbrvfootnote{##1}%
      {\glsfirstlongfootnotefont{\glsaccesslong{##1}}}%
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \protect\glsxtrabbrvfootnote{##1}%
      {\glsfirstlongfootnotefont{\glsaccesslongpl{##1}}}%
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \protect\glsxtrabbrvfootnote{##1}%
      {\glsfirstlongfootnotefont{\glsaccesslong{##1}}}%
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \protect\glsxtrabbrvfootnote{##1}%
      {\glsfirstlongfootnotefont{\glsaccesslongpl{##1}}}%
  }%
%    \end{macrocode}
% The first use full form and the inline full form use the short
% (long) style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslongpl{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslongpl{##1}})%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-footnote}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-footnote}{footnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{postfootnote}
% Similar to the above but the footnote is placed afterwards,
% outside the link. This avoids nested links and can also move the
% footnote marker after any following punctuation mark.
% Pre v1.07 included \cs{footnote} in the first keys, which was
% incorrect as it caused duplicate footnotes.
%\changes{1.07}{2016-08-15}{removed \cs{footnote} from first keys}
%    \begin{macrocode}
\newabbreviationstyle{postfootnote}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    description={\the\glslongtok},%
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}}}%
%    \end{macrocode}
% Make this category insert a footnote after the link if this was
% the first use, and
% unset the \catattr{regular} attribute if it has been set.
%\changes{0.5.1}{2015-12-07}{switch off regular attribute if set}
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \csdef{glsxtrpostlink\glscategorylabel}{%
      \glsxtrifwasfirstuse
      {%
%    \end{macrocode}
% Needs the specific font command here as the style may have been
% lost by the time the footnote occurs.
%    \begin{macrocode}
        \glsxtrdopostpunc{\protect\glsxtrabbrvfootnote{\glslabel}%
        {\glsfirstlongfootnotefont{\glsentrylong{\glslabel}}}}%
      }%
      {}%
    }%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
%    \end{macrocode}
%\changes{1.02}{2016-04-25}{added redef of \cs{glsxtrsetupfulldefs}}
% The footnote needs to be suppressed in the inline form, so
% \cs{glsxtrfull} must set the first use switch off.
%    \begin{macrocode}
  \renewcommand*{\glsxtrsetupfulldefs}{%
    \let\glsxtrifwasfirstuse\@secondoftwo
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongfootnotefont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongfootnotefont{##1}}%
%    \end{macrocode}
% The full format displays the short form. The long form is
% deferred.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
%    \end{macrocode}
% The first use full form and the inline full form use the short
% (long) style.
%\changes{1.07}{2016-08-15}{switched from \cs{glsfirstlongfont} to
%\cs{glsfirstlongfootnotefont}}
%    \begin{macrocode}
  \renewcommand*{\glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslongpl{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfootnotefont{\glsaccesslongpl{##1}})%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-postfootnote}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-postfootnote}{postfootnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short}
% Provide a style that only displays the short form on first use,
% but the short and long form can be displayed with the \qt{full}
% commands that use the inline format. If the user supplies a
% description, the long form won't be displayed in the predefined
% glossary styles, but the post description hook can be employed to
% automatically insert it.
%    \begin{macrocode}
\newabbreviationstyle{short}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}},
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}},
    text={\protect\glsabbrvfont{\the\glsshorttok}},
    plural={\protect\glsabbrvfont{\the\glsshortpltok}},
    description={\the\glslongtok}}%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{regular}{true}}%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongdefaultfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongdefaultfont{##1}}%
%    \end{macrocode}
% The inline full form displays the short form followed by the
% long form in parentheses.
%\changes{0.2}{2015-11-30}{switched inline full form to short (long)}
%    \begin{macrocode}
  \renewcommand*{\glsxtrinlinefullformat}[2]{%
    \protect\glsfirstabbrvfont{\glsaccessshort{##1}%
      \ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\glsxtrinlinefullplformat}[2]{%
    \protect\glsfirstabbrvfont{\glsaccessshortpl{##1}%
     \ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslongpl{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullformat}[2]{%
    \protect\glsfirstabbrvfont{\glsaccessshort{##1}%
      \ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\Glsaccesslong{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullplformat}[2]{%
    \protect\glsfirstabbrvfont{\glsaccessshortpl{##1}%
       \ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\Glsaccesslongpl{##1}})%
  }%
%    \end{macrocode}
% The first use full form only displays the short form, but it
% typically won't be used as the \catattr{regular} attribute is set by this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
% Set this as the default style for acronyms:
%    \begin{macrocode}
\setabbreviationstyle[acronym]{short}
%    \end{macrocode}
%\begin{abbrvstyle}{short-nolong}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-nolong}{short}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-desc}
% The user must supply the description in this style. The long form
% is added to the name. The \abbrstyle{short} style (possibly with the
% post-description hooks set) might be a better option.
%\changes{1.01}{2016-02-02}{fixed typo in
%\cs{glsxtrinlinefullformat} and added missing second argument}
%    \begin{macrocode}
\newabbreviationstyle{short-desc}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsxtrinlinefullformat{\the\glslabeltok}{}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}},
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}},
    text={\protect\glsabbrvfont{\the\glsshorttok}},
    plural={\protect\glsabbrvfont{\the\glsshortpltok}},
    description={\the\glslongtok}}%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{regular}{true}}%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongdefaultfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongdefaultfont{##1}}%
%    \end{macrocode}
% The inline full form displays the short format followed by the
% long form in parentheses.
%    \begin{macrocode}
  \renewcommand*{\glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslongpl{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslong{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\glsfirstlongfont{\glsaccesslongpl{##1}})%
  }%
%    \end{macrocode}
% The first use full form only displays the short form, but it
% typically won't be used as the \catattr{regular} attribute is set by this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-nolong-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-nolong-desc}{short-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-desc}
% Provide a style that only displays the long form,
% but the long and short form can be displayed with the \qt{full}
% commands that use the inline format. The predefined glossary styles
% won't show the short form. The user must supply a description for
% this style.
%    \begin{macrocode}
\newabbreviationstyle{long-desc}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\protect\glsfirstlongfont{\the\glslongtok}},
    sort={\the\glslongtok},
    first={\protect\glsfirstlongfont{\the\glslongtok}},
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}},
    text={\the\glslongtok},
    plural={\the\glslongpltok}%
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{regular}{true}}%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glspluralsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvdefaultfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongdefaultfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongdefaultfont{##1}}%
%    \end{macrocode}
% The inline full form displays the long format followed by the
% short form in parentheses.
%    \begin{macrocode}
  \renewcommand*{\glsxtrinlinefullformat}[2]{%
    \glsfirstlongfont{\glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\protect\glsfirstabbrvfont{\glsaccessshort{##1}})%
  }%
  \renewcommand*{\glsxtrinlinefullplformat}[2]{%
    \glsfirstlongfont{\glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\protect\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullformat}[2]{%
    \glsfirstlongfont{\Glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\protect\glsfirstabbrvfont{\glsaccessshort{##1}})%
  }%
  \renewcommand*{\Glsxtrinlinefullplformat}[2]{%
    \glsfirstlongfont{\Glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
     \ifglsxtrinsertinside\else##2\fi\glsxtrfullsep{##1}%
    (\protect\glsfirstabbrvfont{\glsaccessshortpl{##1}})%
  }%
%    \end{macrocode}
% The first use full form only displays the long form, but it
% typically won't be used as the \catattr{regular} attribute is set by this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstlongfont{\glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstlongfont{\glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-noshort-desc}
%\changes{1.04}{2016-05-02}{new}
%Provide a synonym that matches similar styles.
%    \begin{macrocode}
\letabbreviationstyle{long-noshort-desc}{long-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long}
% It doesn't really make a great deal of sense to have a long-only
% style that doesn't have a description, but the best course of
% action here is to use the short form as the name and the long
% form as the description.
%    \begin{macrocode}
\newabbreviationstyle{long}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstlongfont{\the\glslongtok}},
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}},
    text={\the\glslongtok},
    plural={\the\glslongpltok},%
    description={\the\glslongtok}%
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{regular}{true}}%
}%
{%
  \GlsXtrUseAbbrStyleFmts{long-desc}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-noshort}
%\changes{1.04}{2016-05-02}{new}
%Provide a synonym that matches similar styles.
%    \begin{macrocode}
\letabbreviationstyle{long-noshort}{long}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\subsection{Predefined Styles (Small Capitals)}
%These styles use:
%\begin{macro}{\glsxtrscfont}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrscfont}[1]{\textsc{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrfirstscfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrfirstscfont}[1]{\glsxtrscfont{#1}}
%    \end{macrocode}
%\end{macro}
% and for the default short form suffix:
%\begin{macro}{\glsxtrscsuffix}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrscsuffix}{\glstextup{\glspluralsuffix}}
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short-sc}
%    \begin{macrocode}
\newabbreviationstyle{long-short-sc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short}%
}%
{%
%    \end{macrocode}
% Mostly as long-short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%
%\begin{abbrvstyle}{long-short-sc-desc}
%    \begin{macrocode}
\newabbreviationstyle{long-short-sc-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long-short-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short-desc}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%
% Now the short (long) version
%    \begin{macrocode}
\newabbreviationstyle{short-sc-long}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long}%
}%
{%
%    \end{macrocode}
% Mostly as short-long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
% As before but user provides description
%    \begin{macrocode}
\newabbreviationstyle{short-sc-long-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short-long-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long-desc}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sc}
%    \begin{macrocode}
\newabbreviationstyle{short-sc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-nolong}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-nolong}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sc-nolong}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-sc-nolong}{short-sc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sc-desc}
%    \begin{macrocode}
\newabbreviationstyle{short-sc-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-desc}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-sc-nolong-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-sc-nolong-desc}{short-sc-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-sc}
%\changes{1.04}{2016-05-02}{renamed from \qt{long-sc}}
% The smallcaps font will only be used if
% the short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-sc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-sc}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-sc}{long-noshort-sc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-sc-desc}
%\changes{1.04}{2016-05-02}{renamed from \qt{long-desc-sc}}
% The smallcaps font will only be used if
% the short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-sc-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort-desc}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-desc-sc}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-desc-sc}{long-noshort-sc-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sc-footnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{footnote-sc}}
%    \begin{macrocode}
\newabbreviationstyle{short-sc-footnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-footnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-footnote}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{footnote-sc}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{footnote-sc}{short-sc-footnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sc-postfootnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{postfootnote-sc}}
%    \begin{macrocode}
\newabbreviationstyle{short-sc-postfootnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-postfootnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-postfootnote}%
%    \end{macrocode}
% Use smallcaps and adjust the plural suffix to revert to upright.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrscsuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrscfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstscfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{postfootnote-sc}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{postfootnote-sc}{short-sc-postfootnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\subsection{Predefined Styles (Fake Small Capitals)}
% These styles require the \sty{relsize} package, which must be
% loaded by the user. These styles all use:
%\begin{macro}{\glsxtrsmfont}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrsmfont}[1]{\textsmaller{#1}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsxtrfirstsmfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrfirstsmfont}[1]{\glsxtrsmfont{#1}}
%    \end{macrocode}
%\end{macro}
% and for the default short form suffix:
%\begin{macro}{\glsxtrsmsuffix}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrsmsuffix}{\glspluralsuffix}
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short-sm}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-sm}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short}%
}%
{%
%    \end{macrocode}
% Mostly as long-short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-short-sm-desc}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-sm-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long-short-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm-long}
% Now the short (long) version
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-sm-long}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long}%
}%
{%
%    \end{macrocode}
% Mostly as short-long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm-long-desc}
% As before but user provides description
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-sm-long-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short-long-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-sm}%
{%
  \GlsXtrUseAbbrStyleSetup{short-nolong}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-nolong}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-sm-nolong}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-sm-nolong}{short-sm}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm-desc}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-sm-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-nolong-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-nolong-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-sm-nolong-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-sm-nolong-desc}{short-sm-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-sm}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{long-sm}}
% The smallcaps font will only be used if
% the short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-sm}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-sm}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-sm}{long-noshort-sm}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-sm-desc}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \cs{long-desc-sm}}
% The smaller font will only be used if
% the short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-sm-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-desc-sm}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-desc-sm}{long-noshort-sm-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm-footnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{footnote-sm}}
%    \begin{macrocode}
\newabbreviationstyle{short-sm-footnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-footnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-footnote}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{footnote-sm}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{footnote-sm}{short-sm-footnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-sm-postfootnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{postfootnote-sm}}
%    \begin{macrocode}
\newabbreviationstyle{short-sm-postfootnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-postfootnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-postfootnote}%
  \renewcommand*\glsabbrvfont[1]{\glsxtrsmfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsxtrfirstsmfont{##1}}%
  \renewcommand*{\abbrvpluralsuffix}{\protect\glsxtrsmsuffix}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{postfootnote-sm}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{postfootnote-sm}{short-sm-postfootnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\subsection{Predefined Styles (Emphasized)}
% These styles use \ics{emph} for the short form.
%\begin{macro}{\glsabbrvemfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsabbrvemfont}[1]{\emph{#1}}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstabbrvemfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsfirstabbrvemfont}[1]{\glsabbrvemfont{#1}}%
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\glsfirstlongemfont}
%\changes{1.04}{2016-05-02}{new}
%Only used by the \qt{long-em} styles.
%    \begin{macrocode}
\newcommand*{\glsfirstlongemfont}[1]{\glslongemfont{#1}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glslongemfont}
%\changes{1.04}{2016-05-02}{new}
%Only used by the \qt{long-em} styles.
%    \begin{macrocode}
\newcommand*{\glslongemfont}[1]{\emph{#1}}%
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short-em}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-em}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short}%
}%
{%
%    \end{macrocode}
% Mostly as long-short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-short-em-desc}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long-short-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-em-short-em}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-em-short-em}%
{%
%    \end{macrocode}
%\cs{glslongemfont} is used in the description since \cs{glsdesc}
%doesn't set the style.
%    \begin{macrocode}
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstlongfont{\the\glslongtok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshorttok})},%
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstabbrvfont{\the\glsshortpltok})},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}},%
    description={\protect\glslongemfont{\the\glslongtok}}}%
%    \end{macrocode}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-em-short-em-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-em-short-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short-desc}%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-short-desc}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-long}
% Now the short (long) version
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em-long}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long}%
}%
{%
%    \end{macrocode}
% Mostly as short-long style:
%\changes{1.05}{2016-06-10}{fixed incorrect font used by long form}
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-long-desc}
% As before but user provides description
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em-long-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short-long-desc style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*\glsfirstabbrvfont[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-long-em}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em-long-em}%
{%
%    \end{macrocode}
%\cs{glslongemfont} is used in the description since \cs{glsdesc}
%doesn't set the style.
%    \begin{macrocode}
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    description={\protect\glslongemfont{\the\glslongtok}},%
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongtok})},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}%
     \protect\glsxtrfullsep{\the\glslabeltok}%
     (\protect\glsfirstlongfont{\the\glslongpltok})},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}}}%
%    \end{macrocode}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-long-em-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em-long-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long-desc}%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-long-desc}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em}%
{%
  \GlsXtrUseAbbrStyleSetup{short-nolong}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-nolong}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-em-nolong}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-em-nolong}{short-em}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-desc}
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-nolong-desc}%
}%
{%
%    \end{macrocode}
% Mostly as short style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-nolong-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{short-em-nolong-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\letabbreviationstyle{short-em-nolong-desc}{short-em-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-em}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{long-em}}
% The short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-em}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort}%
}%
{%
%    \end{macrocode}
% Mostly as \abbrstyle{long-noshort} style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-em}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-em}{long-noshort-em}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-em-noshort-em}
%\changes{1.04}{2016-05-02}{new}
% The short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-em-noshort-em}%
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstlongfont{\the\glslongtok}},
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}},
    text={\the\glslongtok},
    plural={\the\glslongpltok},%
    description={\protect\glslongemfont{\the\glslongtok}}%
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glssetattribute{\the\glslabeltok}{regular}{true}}%
}%
{%
%    \end{macrocode}
% Mostly as \abbrstyle{long-noshort} style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-noshort-em-desc}
%\changes{1.04}{2016-05-02}{renamed from \qt{long-desc-em}}
%\changes{0.5}{2015-12-07}{new}
% The emphasized font will only be used if
% the short form is explicitly invoked through commands like
% \cs{glsshort}.
%    \begin{macrocode}
\newabbreviationstyle{long-noshort-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{long-desc-em}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{long-desc-em}{long-noshort-em-desc}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-em-noshort-em-desc}
%\changes{1.04}{2016-05-02}{new}
% The short form is explicitly invoked through commands like
% \cs{glsshort}. The long form is emphasized.
%    \begin{macrocode}
\newabbreviationstyle{long-em-noshort-em-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-noshort-desc}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{long-noshort-desc}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlongemfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslongemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-footnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2015-04-30}{renamed from \qt{footnote-em}}
%    \begin{macrocode}
\newabbreviationstyle{short-em-footnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-footnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-footnote}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{footnote-em}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{footnote-em}{short-em-footnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-em-postfootnote}
%\changes{0.5}{2015-12-07}{new}
%\changes{1.04}{2016-05-02}{renamed from \qt{postfootnote-em}}
%    \begin{macrocode}
\newabbreviationstyle{short-em-postfootnote}%
{%
  \GlsXtrUseAbbrStyleSetup{short-postfootnote}%
}%
{%
%    \end{macrocode}
% Mostly as long style:
%    \begin{macrocode}
  \GlsXtrUseAbbrStyleFmts{short-postfootnote}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvemfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvemfont{##1}}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%\begin{abbrvstyle}{postfootnote-em}
%Backward compatibility: 
%    \begin{macrocode}
\@glsxtr@deprecated@abbrstyle{postfootnote-em}{short-em-postfootnote}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\subsection{Predefined Styles (User Parentheses Hook)}
% These styles allow the user to adjust the parenthetical forms.
% These styles all test for the existence of the
% field given by:
%\begin{macro}{\glsxtruserfield}
%\changes{1.04}{2016-05-02}{new}
% Default is the useri field.
%    \begin{macrocode}
\newcommand*{\glsxtruserfield}{useri}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtruserparen}
%\changes{1.04}{2016-05-02}{new}
% The format of the parenthetical information.
% The first argument is the long/short form. The second argument
% is the entry's label. If \cs{glscurrentfieldvalue} has been
% defined, then we have at least \styfmt{glossaries} v4.23, which makes
% it easier for the user to adjust this.
%    \begin{macrocode}
\ifdef\glscurrentfieldvalue
{
  \newcommand*{\glsxtruserparen}[2]{%
    \glsxtrfullsep{#2}%
    (#1\ifglshasfield{\glsxtruserfield}{#2}{, \glscurrentfieldvalue}{})%
  }
}
{
  \newcommand*{\glsxtruserparen}[2]{%
    \glsxtrfullsep{#2}%
    (#1\ifglshasfield{\glsxtruserfield}{#2}{, \@glo@thisvalue}{})%
  }
}
%    \end{macrocode}
%\end{macro}
% Font used for short form:
%\begin{macro}{\glsabbrvuserfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsabbrvuserfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
% Font used for short form on first use:
%\begin{macro}{\glsfirstabbrvuserfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsfirstabbrvuserfont}[1]{\glsabbrvuserfont{#1}}
%    \end{macrocode}
%\end{macro}
% Font used for long form:
%\begin{macro}{\glslonguserfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glslonguserfont}[1]{#1}
%    \end{macrocode}
%\end{macro}
% Font used for long form on first use:
%\begin{macro}{\glsfirstlonguserfont}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsfirstlonguserfont}[1]{\glslonguserfont{#1}}
%    \end{macrocode}
%\end{macro}
% The default short form suffix:
%\begin{macro}{\glsxtrusersuffix}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrusersuffix}{\glspluralsuffix}
%    \end{macrocode}
%\end{macro}
%
%\begin{abbrvstyle}{long-short-user}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-user}%
{%
%    \end{macrocode}
%\cs{glslonguserfont} is used in the description since \cs{glsdesc}
%doesn't set the style.
%    \begin{macrocode}
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    first={\protect\glsfirstlongfont{\the\glslongtok}%
     \protect\glsxtruserparen{\protect\glsfirstabbrvfont{\the\glsshorttok}}{\the\glslabeltok}},%
    firstplural={\protect\glsfirstlongfont{\the\glslongpltok}%
     \protect\glsxtruserparen{\protect\glsfirstabbrvfont{\the\glsshortpltok}}{\the\glslabeltok}},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}},%
    description={\protect\glslonguserfont{\the\glslongtok}}}%
%    \end{macrocode}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glsxtrusersuffix}%
  \renewcommand*{\glsabbrvfont}[1]{\glsabbrvuserfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvuserfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlonguserfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslonguserfont{##1}}%
%    \end{macrocode}
% The first use full form and the inline full form are the same for
% this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstlongfont{\glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstabbrvfont{\glsaccessshort{##1}}}{##1}%
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstabbrvfont{\glsaccessshortpl{##1}}}{##1}%
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstlongfont{\Glsaccesslong{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstabbrvfont{\glsaccessshort{##1}}}{##1}%
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstlongfont{\Glsaccesslongpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstabbrvfont{\glsaccessshortpl{##1}}}{##1}%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{long-short-user-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{long-short-user-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{long-short-desc}%
}%
{%
  \GlsXtrUseAbbrStyleFmts{long-short-user}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-long-user}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-long-user}%
{%
%    \end{macrocode}
%\cs{glslonguserfont} is used in the description since \cs{glsdesc}
%doesn't set the style.
%    \begin{macrocode}
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\protect\glsabbrvfont{\the\glsshorttok}},
    sort={\the\glsshorttok},
    description={\protect\glslonguserfont{\the\glslongtok}},%
    first={\protect\glsfirstabbrvfont{\the\glsshorttok}%
     \protect\glsxtruserparen{\protect\glslonguserfont{\the\glslongtok}}{\the\glslabeltok}},%
    firstplural={\protect\glsfirstabbrvfont{\the\glsshortpltok}%
     \protect\glsxtruserparen{\protect\glslonguserfont{\the\glslongpltok}}{\the\glslabeltok}},%
    plural={\protect\glsabbvfont{\the\glsshortpltok}}}%
%    \end{macrocode}
% Unset the \catattr{regular} attribute if it has been set.
%    \begin{macrocode}
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}%
{%
%    \end{macrocode}
% In case the user wants to mix and match font styles, these are
% redefined here.
%    \begin{macrocode}
  \renewcommand*{\abbrvpluralsuffix}{\glsxtrusersuffix}%
  \renewcommand*\glsabbrvfont[1]{\glsabbrvuserfont{##1}}%
  \renewcommand*{\glsfirstabbrvfont}[1]{\glsfirstabbrvuserfont{##1}}%
  \renewcommand*{\glsfirstlongfont}[1]{\glsfirstlonguserfont{##1}}%
  \renewcommand*{\glslongfont}[1]{\glslonguserfont{##1}}%
%    \end{macrocode}
% The first use full form and the inline full form are the same for
% this style.
%    \begin{macrocode}
  \renewcommand*{\glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstlongfont{\glsaccesslong{##1}}}{##1}%
  }%
  \renewcommand*{\glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstlongfont{\glsaccesslongpl{##1}}}{##1}%
  }%
  \renewcommand*{\Glsxtrfullformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshort{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstlongfont{\glsaccesslong{##1}}}{##1}%
  }%
  \renewcommand*{\Glsxtrfullplformat}[2]{%
    \glsfirstabbrvfont{\Glsaccessshortpl{##1}\ifglsxtrinsertinside##2\fi}%
    \ifglsxtrinsertinside\else##2\fi
    \glsxtruserparen{\glsfirstlongfont{\glsaccesslongpl{##1}}}{##1}%
  }%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\begin{abbrvstyle}{short-long-user-desc}
%\changes{1.04}{2016-05-02}{new}
%    \begin{macrocode}
\newabbreviationstyle{short-long-user-desc}%
{%
  \GlsXtrUseAbbrStyleSetup{short-long-desc}%
}%
{%
  \GlsXtrUseAbbrStyleFmts{short-long-user}%
}
%    \end{macrocode}
%\end{abbrvstyle}
%
%\section{Using Entries in Headings}
%
% There are four main problems with using entries in sectioning
% commands: they can mess with the first use flag if they end up in
% the table of contents, they can add unwanted numbers to the
% entry's location list, the label is corrupted if used inside
% \ics{MakeUppercase} (which is used by the default headings style)
% and they need to be expandable for PDF bookmarks. The
% \styfmt{glossaries} package therefore recommends the use of the
% expandable commands, such as \cs{glsentryshort}, instead but this
% doesn't reflect the formatting since it doesn't include
% \cs{glsabbrvfont}. The commands below are an attempt to get around
% these problems.
%
% The PDF bookmark issue can easily be fixed with \sty{hyperref}'s
% \cs{texorpdfstring} which can simply use the expandable command
% in the PDF string case. The \TeX\ string case can now use
% \cs{glsxtrshort} with the \gloskey[glslink]{noindex} key set, which
% prevents the unwanted additions to the location list, and the
% \gloskey[glslink]{hyper} key set to false, which prevents the problem of
% nested links. This just leaves one thing left that needs to be
% dealt with, and that's what to do if the heading style 
% uses \cs{MakeUppercase}.
%
% Note that \styfmt{glossaries} automatically loads \sty{textcase}, so
% the label can be protected from case change with \sty{textcase}'s
% \cs{NoCaseChange}. This means that we don't have a problem
% provided the page style uses \cs{MakeTextUppercase}, but the
% default heading page style uses \cs{MakeUppercase}.
%
% To get around this, save the original definition of \cs{markboth}
% and \cs{markright} and adjust it so that \cs{MakeUppercase} is
% temporarily redefined to \cs{MakeTextUppercase}. Some packages or
% classes redefine these commands, so we can't just assume they
% still have the original kernel definition.
%
%\begin{macro}{\markright}
% Save original definition:
%    \begin{macrocode}
\let\@glsxtr@org@markright\markright
%    \end{macrocode}
% Redefine (grouping not added in case it interferes with the
% original code):
%    \begin{macrocode}
\renewcommand*{\markright}[1]{%
 \glsxtrmarkhook
 \@glsxtr@org@markright{\@glsxtrinmark#1\@glsxtrnotinmark}%
 \glsxtrrestoremarkhook
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\markboth}
% Save original definition:
%    \begin{macrocode}
\let\@glsxtr@org@markboth\markboth
%    \end{macrocode}
% Redefine (grouping not added in case it interferes with the
% original code):
%    \begin{macrocode}
\renewcommand*{\markboth}[2]{%
 \glsxtrmarkhook
 \@glsxtr@org@markboth
   {\@glsxtrinmark#1\@glsxtrnotinmark}%
   {\@glsxtrinmark#2\@glsxtrnotinmark}%
 \glsxtrrestoremarkhook
}
%    \end{macrocode}
%\end{macro}
%
% If this causes a problem provide a simple way of switching back to
% the original definitions:
%\begin{macro}{\glsxtrRevertMarks}
%    \begin{macrocode}
\newcommand*{\glsxtrRevertMarks}{%
  \let\markright\@glsxtr@org@markright
  \let\markboth\@glsxtr@org@markboth
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrifinmark}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrifinmark}[2]{#2}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtrinmark}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@glsxtrinmark}{%
  \let\glsxtrifinmark\@firstoftwo
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\@glsxtrnotinmark}
%\changes{1.07}{2016-08-15}{new}
%    \begin{macrocode}
\newrobustcmd*{\@glsxtrnotinmark}{%
  \let\glsxtrifinmark\@secondoftwo
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\glsxtrmarkhook}
% Hook used in new definition of \cs{markboth} and \cs{markright}
% to make some changes to apply to the marks:
%    \begin{macrocode}
\newcommand*{\glsxtrmarkhook}{%
%    \end{macrocode}
% Save current definitions:
%    \begin{macrocode}
  \let\@glsxtr@org@MakeUppercase\MakeUppercase
  \let\@glsxtr@org@glsxtrtitleshort\glsxtrtitleshort
  \let\@glsxtr@org@glsxtrtitleshortpl\glsxtrtitleshortpl
  \let\@glsxtr@org@Glsxtrtitleshort\Glsxtrtitleshort
  \let\@glsxtr@org@Glsxtrtitleshortpl\Glsxtrtitleshortpl
  \let\@glsxtr@org@glsxtrtitletext\glsxtrtitletext
  \let\@glsxtr@org@Glsxtrtitletext\Glsxtrtitletext
  \let\@glsxtr@org@glsxtrtitleplural\glsxtrtitleplural
  \let\@glsxtr@org@Glsxtrtitleplural\Glsxtrtitleplural
  \let\@glsxtr@org@glsxtrtitlefirst\glsxtrtitlefirst
  \let\@glsxtr@org@Glsxtrtitlefirst\Glsxtrtitlefirst
  \let\@glsxtr@org@glsxtrtitlefirstplural\glsxtrtitlefirstplural
  \let\@glsxtr@org@Glsxtrtitlefirstplural\Glsxtrtitlefirstplural
  \let\@glsxtr@org@glsxtrtitlelong\glsxtrtitlelong
  \let\@glsxtr@org@glsxtrtitlelongpl\glsxtrtitlelongpl
  \let\@glsxtr@org@Glsxtrtitlelong\Glsxtrtitlelong
  \let\@glsxtr@org@Glsxtrtitlelongpl\Glsxtrtitlelongpl
  \let\@glsxtr@org@glsxtrtitlefull\glsxtrtitlefull
  \let\@glsxtr@org@glsxtrtitlefullpl\glsxtrtitlefullpl
  \let\@glsxtr@org@Glsxtrtitlefull\Glsxtrtitlefull
  \let\@glsxtr@org@Glsxtrtitlefullpl\Glsxtrtitlefullpl
%    \end{macrocode}
% New definitions
%    \begin{macrocode}
  \let\glsxtrifinmark\@firstoftwo
  \let\MakeUppercase\MakeTextUppercase
  \let\glsxtrtitleshort\glsxtrheadshort
  \let\glsxtrtitleshortpl\glsxtrheadshortpl
  \let\Glsxtrtitleshort\Glsxtrheadshort
  \let\Glsxtrtitleshortpl\Glsxtrheadshortpl
  \let\glsxtrtitletext\glsxtrheadtext
  \let\Glsxtrtitletext\Glsxtrheadtext
  \let\glsxtrtitleplural\glsxtrheadplural
  \let\Glsxtrtitleplural\Glsxtrheadplural
  \let\glsxtrtitlefirst\glsxtrheadfirst
  \let\Glsxtrtitlefirst\Glsxtrheadfirst
  \let\glsxtrtitlefirstplural\glsxtrheadfirstplural
  \let\Glsxtrtitlefirstplural\Glsxtrheadfirstplural
  \let\glsxtrtitlelong\glsxtrheadlong
  \let\glsxtrtitlelongpl\glsxtrheadlongpl
  \let\Glsxtrtitlelong\Glsxtrheadlong
  \let\Glsxtrtitlelongpl\Glsxtrheadlongpl
  \let\glsxtrtitlefull\glsxtrheadfull
  \let\glsxtrtitlefullpl\glsxtrheadfullpl
  \let\Glsxtrtitlefull\Glsxtrheadfull
  \let\Glsxtrtitlefullpl\Glsxtrheadfullpl
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrrestoremarkhook}
% Hook used in new definition of \cs{markboth} and \cs{markright}
% to restore the modified definitions. (This is in case the original
% \cs{markboth} and \cs{markright} shouldn't be grouped for some
% reason. There already is some grouping within those original
% definitions, but some of the code lies outside that grouping, and
% possibly there's a reason for it.)
%    \begin{macrocode}
\newcommand*{\glsxtrrestoremarkhook}{%
  \let\glsxtrifinmark\@secondoftwo
  \let\MakeUppercase\@glsxtr@org@MakeUppercase
  \let\glsxtrtitleshort\@glsxtr@org@glsxtrtitleshort
  \let\glsxtrtitleshortpl\@glsxtr@org@glsxtrtitleshortpl
  \let\Glsxtrtitleshort\@glsxtr@org@Glsxtrtitleshort
  \let\Glsxtrtitleshortpl\@glsxtr@org@Glsxtrtitleshortpl
  \let\glsxtrtitletext\@glsxtr@org@glsxtrtitletext
  \let\Glsxtrtitletext\@glsxtr@org@Glsxtrtitletext
  \let\glsxtrtitleplural\@glsxtr@org@glsxtrtitleplural
  \let\Glsxtrtitleplural\@glsxtr@org@Glsxtrtitleplural
  \let\glsxtrtitlefirst\@glsxtr@org@glsxtrtitlefirst
  \let\Glsxtrtitlefirst\@glsxtr@org@Glsxtrtitlefirst
  \let\glsxtrtitlefirstplural\@glsxtr@org@glsxtrtitlefirstplural
  \let\Glsxtrtitlefirstplural\@glsxtr@org@Glsxtrtitlefirstplural
  \let\glsxtrtitlelong\@glsxtr@org@glsxtrtitlelong
  \let\glsxtrtitlelongpl\@glsxtr@org@glsxtrtitlelongpl
  \let\Glsxtrtitlelong\@glsxtr@org@Glsxtrtitlelong
  \let\Glsxtrtitlelongpl\@glsxtr@org@Glsxtrtitlelongpl
  \let\glsxtrtitlefull\@glsxtr@org@glsxtrtitlefull
  \let\glsxtrtitlefullpl\@glsxtr@org@glsxtrtitlefullpl
  \let\Glsxtrtitlefull\@glsxtr@org@Glsxtrtitlefull
  \let\Glsxtrtitlefullpl\@glsxtr@org@Glsxtrtitlefullpl
}
%    \end{macrocode}
%\end{macro}
%
%\changes{0.5.1}{2015-12-07}{removed \cs{ifglsxtruseuchead}}
% Instead of using one document-wide conditional, use
% \catattr{headuc} attribute to determine whether or not to use the
% all upper case form.
%
%\begin{macro}{\glsxtrheadshort}
% Command used to display short form in the page header.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadshort}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrshort[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsxtrshort[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitleshort}
% Command to display short form of abbreviation in section title and
% table of contents.
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitleshort}[1]{%
  \glsxtrshort[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadshortpl}
% Command used to display plural short form in the page header.
% If you want the text converted to upper case, this needs to be
% redefined to use \cs{GLSxtrshortpl} instead. If you are using a
% smallcaps style, the default fonts don't provide italic smallcaps.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadshortpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
      \GLSxtrshortpl[noindex,hyper=false]{#1}[]%
   }%
   {%
      \glsxtrshortpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitleshortpl}
% Command to display plural short form of abbreviation in section title and
% table of contents.
%\changes{1.03}{2016-04-27}{bug fix: changed \cs{glsxtrshort} to
%\cs{glsxtrshortpl}}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitleshortpl}[1]{%
  \glsxtrshortpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadshort}
% Command used to display short form in the page header with the
% first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadshort}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrshort[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrshort[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitleshort}
% Command to display short form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitleshort}[1]{%
  \Glsxtrshort[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadshortpl}
% Command used to display plural short form in the page header with the
% first letter converted to upper case.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadshortpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrshortpl[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrshortpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitleshortpl}
% Command to display plural short form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitleshortpl}[1]{%
  \Glsxtrshortpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadtext}
% As above but for the \gloskey{text} value.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadtext}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLStext[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glstext[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitletext}
% Command to display \gloskey{text} value in section title and
% table of contents.
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitletext}[1]{%
  \glstext[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%
%\begin{macro}{\Glsxtrheadtext}
% First letter converted to upper case
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadtext}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLStext[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glstext[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitletext}
% Command to display \gloskey{text} value in section title and
% table of contents with the first letter changed to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitletext}[1]{%
  \Glstext[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadplural}
% As above but for the \gloskey{plural} value.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadplural}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSplural[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsplural[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitleplural}
% Command to display \gloskey{plural} value in section title and
% table of contents.
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitleplural}[1]{%
  \glsplural[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadplural}
% Convert first letter to upper case.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadplural}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSplural[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsplural[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitleplural}
% Command to display \gloskey{plural} value in section title and
% table of contents with the first letter changed to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitleplural}[1]{%
  \Glsplural[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadfirst}
% As above but for the \gloskey{first} value.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadfirst}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSfirst[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsfirst[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlefirst}
% Command to display \gloskey{first} value in section title and
% table of contents.
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlefirst}[1]{%
  \glsfirst[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadfirst}
% First letter converted to upper case
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadfirst}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSfirst[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsfirst[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlefirst}
% Command to display \gloskey{first} value in section title and
% table of contents with the first letter changed to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlefirst}[1]{%
  \Glsfirst[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadfirstplural}
% As above but for the \gloskey{firstplural} value.
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\glsxtrheadfirstplural}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSfirstplural[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsfirstplural[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlefirstplural}
% Command to display \gloskey{firstplural} value in section title and
% table of contents.
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlefirstplural}[1]{%
  \glsfirstplural[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadfirstplural}
% First letter converted to upper case
%\changes{0.5.1}{2015-12-07}{now uses headuc attribute}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadfirstplural}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSfirstplural[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsfirstplural[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlefirstplural}
% Command to display \gloskey{first} value in section title and
% table of contents with the first letter changed to upper case.
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlefirstplural}[1]{%
  \Glsfirstplural[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadlong}
% Command used to display long form in the page header.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrheadlong}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrlong[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsxtrlong[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlelong}
% Command to display long form of abbreviation in section title and
% table of contents.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlelong}[1]{%
  \glsxtrlong[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadlongpl}
% Command used to display plural long form in the page header.
% If you want the text converted to upper case, this needs to be
% redefined to use \cs{GLSxtrlongpl} instead. If you are using a
% smallcaps style, the default fonts don't provide italic smallcaps.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrheadlongpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
      \GLSxtrlongpl[noindex,hyper=false]{#1}[]%
   }%
   {%
      \glsxtrlongpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlelongpl}
% Command to display plural long form of abbreviation in section title and
% table of contents.
%\changes{1.02}{2016-04-25}{new}
%\changes{1.03}{2016-04-27}{bug fix: changed \cs{glsxtrlong} to
%\cs{glsxtrlongpl}}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlelongpl}[1]{%
  \glsxtrlongpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadlong}
% Command used to display long form in the page header with the
% first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadlong}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrlong[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrlong[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlelong}
% Command to display long form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlelong}[1]{%
  \Glsxtrlong[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadlongpl}
% Command used to display plural long form in the page header with the
% first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadlongpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrlongpl[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrlongpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlelongpl}
% Command to display plural long form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlelongpl}[1]{%
  \Glsxtrlongpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadfull}
% Command used to display full form in the page header.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrheadfull}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrfull[noindex,hyper=false]{#1}[]%
   }%
   {%
     \glsxtrfull[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlefull}
% Command to display full form of abbreviation in section title and
% table of contents.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlefull}[1]{%
  \glsxtrfull[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrheadfullpl}
% Command used to display plural full form in the page header.
% If you want the text converted to upper case, this needs to be
% redefined to use \cs{GLSxtrfullpl} instead. If you are using a
% smallcaps style, the default fonts don't provide italic smallcaps.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\glsxtrheadfullpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
      \GLSxtrfullpl[noindex,hyper=false]{#1}[]%
   }%
   {%
      \glsxtrfullpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtitlefullpl}
% Command to display plural full form of abbreviation in section title and
% table of contents.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\glsxtrtitlefullpl}[1]{%
  \glsxtrfullpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadfull}
% Command used to display full form in the page header with the
% first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadfull}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrfull[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrfull[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlefull}
% Command to display full form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlefull}[1]{%
  \Glsxtrfull[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrheadfullpl}
% Command used to display plural full form in the page header with the
% first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newcommand*{\Glsxtrheadfullpl}[1]{%
 \protect\NoCaseChange
 {%
   \glsifattribute{#1}{headuc}{true}%
   {%
     \GLSxtrfullpl[noindex,hyper=false]{#1}[]%
   }%
   {%
     \Glsxtrfullpl[noindex,hyper=false]{#1}[]%
   }%
 }%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsxtrtitlefullpl}
% Command to display plural full form of abbreviation in section title and
% table of contents with the first letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\newrobustcmd*{\Glsxtrtitlefullpl}[1]{%
  \Glsxtrfullpl[noindex,hyper=false]{#1}[]%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtshort}
% Provide a way of using the formatted short form in section
% headings. If \sty{hyperref} has been loaded, use
% \cs{texorpdfstring} for convenience in PDF bookmarks.
%\changes{0.2}{2015-11-30}{new}
%\changes{0.4}{2015-12-03}{changed to use \cs{glsxtrshort}}
%\changes{0.5}{2015-12-07}{changed to use \cs{glsxtrtitleshort}}
%\changes{0.5}{2015-12-07}{renamed from \cs{glsentryfmtshort}}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtshort}[1]{%
    \texorpdfstring
      {\glsxtrtitleshort{#1}}%
      {\glsentryshort{#1}}%
  }
}
{
  \newcommand*{\glsfmtshort}[1]{%
   \glsxtrtitleshort{#1}}
}
%    \end{macrocode}
%\end{macro}
%Similarly for the plural version.
%\begin{macro}{\glsfmtshortpl}
%\changes{0.2}{2015-11-30}{new}
%\changes{0.4}{2015-12-03}{changed to use \cs{glsxtrshortpl}}
%\changes{0.5}{2015-12-07}{changed to use \cs{glsxtrtitleshortpl}}
%\changes{0.5}{2015-12-07}{renamed from \cs{glsentryfmtshortpl}}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtshortpl}[1]{%
    \texorpdfstring
      {\glsxtrtitleshortpl{#1}}%
      {\glsentryshortpl{#1}}%
  }
}
{
  \newcommand*{\glsfmtshortpl}[1]{%
   \glsxtrtitleshortpl{#1}}
}
%    \end{macrocode}
%\end{macro}
% The case-changing version isn't suitable for PDF bookmarks, so the
% PDF alternative uses the non-case-changing version.
%\begin{macro}{\Glsfmtshort}
% Singular form (first letter uppercase).
%\changes{0.2}{2015-11-30}{new}
%\changes{0.4}{2015-12-03}{changed to use \cs{Glsxtrshort}}
%\changes{0.5}{2015-12-07}{changed to use \cs{Glsxtrtitleshort}}
%\changes{0.5}{2015-12-07}{renamed from \cs{Glsentryfmtshort}}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtshort}[1]{%
    \texorpdfstring
      {\Glsxtrtitleshort{#1}}%
      {\glsentryshort{#1}}%
  }
}
{
  \newcommand*{\Glsfmtshort}[1]{%
   \Glsxtrtitleshort{#1}}
}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\Glsfmtshortpl}
%Plural form (first letter uppercase).
%\changes{0.2}{2015-11-30}{new}
%\changes{0.4}{2015-12-03}{changed to use \cs{glsxtrshortpl}}
%\changes{0.5}{2015-12-07}{changed to use \cs{Glsxtrtitleshortpl}}
%\changes{0.5}{2015-12-07}{renamed from \cs{Glsentryfmtshortpl}}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtshortpl}[1]{%
    \texorpdfstring
    {\Glsxtrtitleshortpl{#1}}%
    {\glsentryshortpl{#1}}%
  }
}
{
  \newcommand*{\Glsfmtshortpl}[1]{%
   \Glsxtrtitleshortpl{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmttext}
%As above but for the \gloskey{text} value.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmttext}[1]{%
    \texorpdfstring
    {\glsxtrtitletext{#1}}%
    {\glsentrytext{#1}}%
  }
}
{
  \newcommand*{\glsfmttext}[1]{%
   \glsxtrtitletext{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmttext}
%First letter converted to upper case.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmttext}[1]{%
    \texorpdfstring
    {\Glsxtrtitletext{#1}}%
    {\glsentrytext{#1}}%
  }
}
{
  \newcommand*{\Glsfmttext}[1]{%
   \Glsxtrtitletext{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtplural}
%As above but for the \gloskey{plural} value.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtplural}[1]{%
    \texorpdfstring
    {\glsxtrtitleplural{#1}}%
    {\glsentryplural{#1}}%
  }
}
{
  \newcommand*{\glsfmtplural}[1]{%
   \glsxtrtitleplural{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtplural}
%First letter converted to upper case.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtplural}[1]{%
    \texorpdfstring
    {\Glsxtrtitleplural{#1}}%
    {\glsentryplural{#1}}%
  }
}
{
  \newcommand*{\Glsfmtplural}[1]{%
   \Glsxtrtitleplural{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtfirst}
%As above but for the \gloskey{first} value.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtfirst}[1]{%
    \texorpdfstring
    {\glsxtrtitlefirst{#1}}%
    {\glsentryfirst{#1}}%
  }
}
{
  \newcommand*{\glsfmtfirst}[1]{%
   \glsxtrtitlefirst{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtfirst}
%First letter converted to upper case.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtfirst}[1]{%
    \texorpdfstring
    {\Glsxtrtitlefirst{#1}}%
    {\glsentryfirst{#1}}%
  }
}
{
  \newcommand*{\Glsfmtfirst}[1]{%
   \Glsxtrtitlefirst{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtfirstpl}
%As above but for the \gloskey{firstplural} value.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtfirstpl}[1]{%
    \texorpdfstring
    {\glsxtrtitlefirstplural{#1}}%
    {\glsentryfirstplural{#1}}%
  }
}
{
  \newcommand*{\glsfmtfirstpl}[1]{%
   \glsxtrtitlefirstplural{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtfirstpl}
%First letter converted to upper case.
%\changes{0.5}{2015-12-07}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtfirstpl}[1]{%
    \texorpdfstring
    {\Glsxtrtitlefirstplural{#1}}%
    {\glsentryfirstplural{#1}}%
  }
}
{
  \newcommand*{\Glsfmtfirstpl}[1]{%
   \Glsxtrtitlefirstplural{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtlong}
%As above but for the \gloskey{long} value.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtlong}[1]{%
    \texorpdfstring
    {\glsxtrtitlelong{#1}}%
    {\glsentrylong{#1}}%
  }
}
{
  \newcommand*{\glsfmtlong}[1]{%
   \glsxtrtitlelong{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtlong}
%First letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtlong}[1]{%
    \texorpdfstring
    {\Glsxtrtitlelong{#1}}%
    {\glsentrylong{#1}}%
  }
}
{
  \newcommand*{\Glsfmtlong}[1]{%
   \Glsxtrtitlelong{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtlongpl}
%As above but for the \gloskey{longplural} value.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtlongpl}[1]{%
    \texorpdfstring
    {\glsxtrtitlelongpl{#1}}%
    {\glsentrylongpl{#1}}%
  }
}
{
  \newcommand*{\glsfmtlongpl}[1]{%
   \glsxtrtitlelongpl{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtlongpl}
%First letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtlongpl}[1]{%
    \texorpdfstring
    {\Glsxtrtitlelongpl{#1}}%
    {\glsentrylongpl{#1}}%
  }
}
{
  \newcommand*{\Glsfmtlongpl}[1]{%
   \Glsxtrtitlelongpl{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtfull}
%In-line full format.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtfull}[1]{%
    \texorpdfstring
    {\glsxtrtitlefull{#1}}%
    {\glsxtrinlinefullformat{#1}{}}%
  }
}
{
  \newcommand*{\glsfmtfull}[1]{%
   \glsxtrtitlefull{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtfull}
%First letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtfull}[1]{%
    \texorpdfstring
    {\Glsxtrtitlefull{#1}}%
    {\Glsxtrinlinefullformat{#1}{}}%
  }
}
{
  \newcommand*{\Glsfmtfull}[1]{%
   \Glsxtrtitlefull{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsfmtfullpl}
%In-line full plural format.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\glsfmtfullpl}[1]{%
    \texorpdfstring
    {\glsxtrtitlefullpl{#1}}%
    {\glsxtrinlinefullplformat{#1}{}}%
  }
}
{
  \newcommand*{\glsfmtfullpl}[1]{%
   \glsxtrtitlefullpl{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\Glsfmtfullpl}
%First letter converted to upper case.
%\changes{1.02}{2016-04-25}{new}
%    \begin{macrocode}
\ifdef\texorpdfstring
{
  \newcommand*{\Glsfmtfullpl}[1]{%
    \texorpdfstring
    {\Glsxtrtitlefullpl{#1}}%
    {\Glsxtrinlinefullplformat{#1}{}}%
  }
}
{
  \newcommand*{\Glsfmtfullpl}[1]{%
   \Glsxtrtitlefullpl{#1}}
}
%    \end{macrocode}
%\end{macro}
%
%\section{Multi-Lingual Support}
% Add the facility to load language modules, if they are installed,
% but none are provided with this package.
%
%\begin{macro}{\RequireGlossariesExtraLang}
%\changes{0.5.3}{2015-12-09}{new}
%    \begin{macrocode}
\newcommand*{\RequireGlossariesExtraLang}[1]{%
  \@ifundefined{ver@glossariesxtr-#1.ldf}{\input{glossariesxtr-#1.ldf}}{}%
}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\ProvidesGlossariesExtraLang}
%\changes{0.5.3}{2015-12-09}{new}
%    \begin{macrocode}
\newcommand*{\ProvidesGlossariesExtraLang}[1]{%
  \ProvidesFile{glossariesxtr-#1.ldf}%
}
%    \end{macrocode}
%\end{macro}
%
% Load any required language modules that are available. This
% doesn't generate any warning if none are found, since they're not 
% essential. (The only command that really needs defining for the
% document is \ics{abbreviationsname}, which can simply be redefined.)
%    \begin{macrocode}
\@ifpackageloaded{tracklang}
{%
  \AnyTrackedLanguages
  {%
    \ForEachTrackedDialect{\this@dialect}{%
      \IfTrackedLanguageFileExists{\this@dialect}%
      {glossariesxtr-}% prefix
      {.ldf}%
      {%
        \RequireGlossariesExtraLang{\CurrentTrackedTag}%
      }%
      {%
      }%
    }%
  }%
  {}%
}
{}
%    \end{macrocode}
% Load \sty{glossaries-extra-stylemods} if required.
%    \begin{macrocode}
\@glsxtr@redefstyles
%    \end{macrocode}
% and set the style:
%    \begin{macrocode}
\@glsxtr@do@style
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-extra.sty>
%    \end{macrocode}
%\fi
%\iffalse
%    \begin{macrocode}
%<*glossaries-extra-stylemods.sty>
%    \end{macrocode}
%\fi
%\chapter{Style Adjustments (\styfmt{glossaries-extra-stylemods.sty})}
% This package adjusts the predefined styles so that they include the post
% description hook. Also, some other minor adjustments may be made
% to make existing styles more flexible.
%
%\section{Package Initialisation}
% First identify package:
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{glossaries-extra-stylemods}[2016/12/17 v1.10 (NLCT)]
%    \end{macrocode}
% Provide package options to automatically load required predefined
% styles. The simplest method is to just test for the existence of
% the file \texttt{glossary-}\meta{option}\texttt{.sty}. Packages
% can't be loaded whilst the options are being processed, so save
% the list in \cs{@glsxtr@loadstyles}.
%\begin{macro}{\@glsxtr@loadstyles}
%    \begin{macrocode}
\newcommand*{\@glsxtr@loadstyles}{}
%    \end{macrocode}
%\end{macro}
%
%    \begin{macrocode}
\DeclareOption*{%
  \IfFileExists{glossary-\CurrentOption.sty}
   {\eappto\@glsxtr@loadstyles{%
      \noexpand\RequirePackage{glossary-\CurrentOption}}}%
   {\PackageError{glossaries-extra-styles}%
    {Unknown option `\CurrentOption'}{}}
}
%    \end{macrocode}
% Process the package options:
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
%
% Load the required packages:
%    \begin{macrocode}
\@glsxtr@loadstyles
%    \end{macrocode}
% Adjust the styles that the post description hook added, but only
% for styles that have already been defined. All the tree styles in
% \sty{glossary-tree} include the post description hook, so they
% don't require adjustment. Similarly for \sty{glossary-mcols} which
% builds on the tree styles.
%
%In case we have an old version of \sty{glossaries}:
%\begin{macro}{\renewglossarystyle}
%    \begin{macrocode}
\providecommand{\renewglossarystyle}[2]{%
  \ifcsundef{@glsstyle@#1}%
  {%
    \PackageError{glossaries}{Glossary style `#1' isn't already defined}{}%
  }%
  {%
    \csdef{@glsstyle@#1}{#2}%
  }%
}
%    \end{macrocode}
%\end{macro}
%
%\section{List-Like Styles}
% The list-like styles mostly already use the post description hook.
% Only the \glostyle{listdotted} style need modifying.
%    \begin{macrocode}
\ifdef{\@glsstyle@listdotted}
{%
 \renewglossarystyle{listdotted}{%
   \setglossarystyle{list}%
   \renewcommand*{\glossentry}[2]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
      \glsentryitem{##1}%
      \glstarget{##1}{\glossentryname{##1}}%
      \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}%
      \glossentrydesc{##1}\glspostdescription}%
   \renewcommand*{\subglossentry}[3]{%
    \item[]\makebox[\glslistdottedwidth][l]{%
    \glssubentryitem{##2}%
    \glstarget{##2}{\glossentryname{##2}}%
    \unskip\leaders\hbox to 2.9mm{\hss.}\hfill\strut}%
    \glossentrydesc{##2}\glspostdescription}%
 }
}
{}
%    \end{macrocode}
% The \glostyle{sublistdotted} style doesn't display the description
% for top-level entries. Sub-level entries use the
% \glostyle{listdottedstyle}.
%
%\section{Longtable Styles}
% The three and four column styles require adjustment, but not the
% two column styles.
%    \begin{macrocode}
\ifcsdef{@glsstyle@long3col}
{%
  \renewglossarystyle{long3col}{%
    \renewenvironment{theglossary}%
      {\begin{longtable}{lp{\glsdescwidth}p{\glspagelistwidth}}}%
      {\end{longtable}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription & ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
     \ifglsnogroupskip\else & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
% Four column style:
%    \begin{macrocode}
\ifcsdef{@glsstyle@long4col}
{%
  \renewglossarystyle{long4col}{%
    \renewenvironment{theglossary}%
      {\begin{longtable}{llll}}%
      {\end{longtable}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription &
      \glossentrysymbol{##1} &
      ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       \glossentrysymbol{##2} & ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
      \ifglsnogroupskip\else & & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
%
%The styles in \sty{glossary-longbooktabs} are all based on the
%styles in \sty{glossary-long}, so no adjustments are needed for
%that package.
%
%\section{Long Ragged Styles}
% The three and four column styles require adjustment, but not the
% two column styles.
%    \begin{macrocode}
\ifcsdef{@glsstyle@longragged3col}
{%
  \renewglossarystyle{longragged3col}{%
    \renewenvironment{theglossary}%
      {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}%
         >{\raggedright}p{\glspagelistwidth}}}%
      {\end{longtable}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription & ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
      \ifglsnogroupskip\else & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
% Four column style:
%    \begin{macrocode}
\ifcsdef{@glsstyle@altlongragged4col}
{%
  \renewglossarystyle{altlongragged4col}{%
    \renewenvironment{theglossary}%
      {\begin{longtable}{l>{\raggedright}p{\glsdescwidth}l%
         >{\raggedright}p{\glspagelistwidth}}}%
      {\end{longtable}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription & \glossentrysymbol{##1} &
      ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       \glossentrysymbol{##2} & ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
      \ifglsnogroupskip\else & & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
%
%\section{Supertabular Styles}
% The three and four column styles require adjustment, but not the
% two column styles.
%    \begin{macrocode}
\ifcsdef{@glsstyle@super3col}
{%
  \renewglossarystyle{super3col}{%
    \renewenvironment{theglossary}%
      {\tablehead{}\tabletail{}%
       \begin{supertabular}{lp{\glsdescwidth}p{\glspagelistwidth}}}%
      {\end{supertabular}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription & ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
      \ifglsnogroupskip\else & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
% Four column styles:
%    \begin{macrocode}
\ifcsdef{@glsstyle@super4col}
{%
  \renewglossarystyle{super4col}{%
    \renewenvironment{theglossary}%
      {\tablehead{}\tabletail{}%
       \begin{supertabular}{llll}}{%
       \end{supertabular}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription &
      \glossentrysymbol{##1} & ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       \glossentrysymbol{##2} & ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{%
      \ifglsnogroupskip\else & & &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
%
%\section{Super Ragged Styles}
% The three and four column styles require adjustment, but not the
% two column styles.
%    \begin{macrocode}
\ifcsdef{@glsstyle@superragged3col}
{%
  \renewglossarystyle{superragged3col}{%
    \renewenvironment{theglossary}%
      {\tablehead{}\tabletail{}%
       \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}%
          >{\raggedright}p{\glspagelistwidth}}}%
      {\end{supertabular}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription &
      ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else &
    &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
% Four columns:
%    \begin{macrocode}
\ifcsdef{@glsstyle@altsuperragged4col}
{%
  \renewglossarystyle{altsuperragged4col}{%
    \renewenvironment{theglossary}%
      {\tablehead{}\tabletail{}%
       \begin{supertabular}{l>{\raggedright}p{\glsdescwidth}l%
         >{\raggedright}p{\glspagelistwidth}}}%
      {\end{supertabular}}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand{\glossentry}[2]{%
      \glsentryitem{##1}\glstarget{##1}{\glossentryname{##1}} &
      \glossentrydesc{##1}\glspostdescription &
      \glossentrysymbol{##1} & ##2\tabularnewline
    }%
    \renewcommand{\subglossentry}[3]{%
       &
       \glssubentryitem{##2}%
       \glstarget{##2}{\strut}\glossentrydesc{##2}\glspostdescription &
       \glossentrysymbol{##2} & ##3\tabularnewline
    }%
    \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else & &
     &\tabularnewline\fi}%
  }
}
{}
%    \end{macrocode}
%
%\section{Inline Style}
% The \glostyle{inline} style is dealt with slightly differently.
% The \cs{glspostdescription} hook is actually in
% \cs{glspostinline}, which is called at the end of the glossary.
% The original definition of \cs{glspostinline} also includes a
% space, which is unnecessary. Here, instead of redefining the
% \glostyle{inline} style, just redefine \cs{glspostinline} and 
% \cs{glsinlinedescformat}.
%    \begin{macrocode}
\ifdef{\@glsstyle@inline}
{%
   \renewcommand*{\glspostinline}{.\spacefactor\sfcode`\.}
%    \end{macrocode}
% Just use \cs{glsxtrpostdescription} instead of
% \cs{glspostdescription}.
%    \begin{macrocode}
   \renewcommand*{\glsinlinedescformat}[3]{%
     \space#1\glsxtrpostdescription}
   \renewcommand*{\glsinlinesubdescformat}[3]{%
     #1\glsxtrpostdescription}
}
{}
%    \end{macrocode}
%
%\section{Tree Styles}
% The \glostyle{alttree} style is redefined to make it easier to
% made minor adjustments.
%    \begin{macrocode}
\ifdef{\@glsstyle@alttree}
{%
%    \end{macrocode}
% Only redefine this style if it's already been defined.
%
%\begin{macro}{\glsxtralttreeSymbolDescLocation}
%\changes{1.05}{2016-06-10}{new}
%\begin{definition}
%\cs{glsxtralttreeSymbolDescLocation}\marg{label}\marg{location
%list}
%\end{definition}
%Layout the symbol, description and location for top-level entries.
%    \begin{macrocode}
  \newcommand{\glsxtralttreeSymbolDescLocation}[2]{%
    {%
      \let\par\glsxtrAltTreePar
      \ifglshassymbol{#1}{(\glossentrysymbol{#1})\space}{}%
      \glossentrydesc{#1}\glspostdescription \space #2\par
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrAltTreeIndent}
%\changes{1.05}{2016-06-10}{new}
% Paragraph indent for subsequent paragraphs in multi-paragraph
% descriptions.
%    \begin{macrocode}
  \newlength\glsxtrAltTreeIndent
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrAltTreePar}
%\changes{1.05}{2016-06-10}{new}
%Multi-paragraph descriptions need to keep the hanging indent.
%    \begin{macrocode}
  \newcommand{\glsxtrAltTreePar}{%
    \@@par
    \glsxtrAltTreeSetHangIndent
    \setlength{\parindent}{\dimexpr\hangindent+\glsxtrAltTreeIndent}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtralttreeSubSymbolDescLocation}
%\changes{1.05}{2016-06-10}{new}
%\begin{definition}
%\cs{glsxtralttreeSubSymbolDescLocation}\marg{level}\marg{label}\marg{location
%list}
%\end{definition}
%Layout the symbol, description and location for sub-entries.
% Defaults to the same as the top-level.
%    \begin{macrocode}
  \newcommand{\glsxtralttreeSubSymbolDescLocation}[3]{%
    \glsxtralttreeSymbolDescLocation{#2}{#3}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrtreetopindent}
%\changes{1.05}{2016-06-10}{new}
% The original style has to keep computing the width of the name at
% each entry. This register allows the style to compute it once for
% the top-level at the start of the glossary.
%    \begin{macrocode}
  \newlength\glsxtrtreetopindent
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtralttreeInit}
%\changes{1.05}{2016-06-10}{new}
% User-level initialisation for the \glostyle{alttree} style.
%    \begin{macrocode}
  \newcommand*{\glsxtralttreeInit}{%
    \settowidth{\glsxtrtreetopindent}{\glstreenamefmt{\glsgetwidestname\space}}%
    \glsxtrAltTreeIndent=\parindent
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\eglssetwidest}
%\changes{1.05}{2016-06-10}{new}
% The original \cs{glssetwidest} only uses \cs{def}. This uses
% \cs{protected@csedef}.
%    \begin{macrocode}
  \newcommand*{\eglssetwidest}[2][0]{%
    \protected@csedef{@glswidestname\romannumeral#1}{#2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\xglssetwidest}
%\changes{1.05}{2016-06-10}{new}
%Like the above but uses \cs{protected@csxdef}.
%    \begin{macrocode}
  \newcommand*{\xglssetwidest}[2][0]{%
    \protected@csxdef{@glswidestname\romannumeral#1}{#2}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgetwidestname}
%\changes{1.05}{2016-06-10}{new}
% Provide a user-level macro to obtain the widest top-level name.
%    \begin{macrocode}
  \newcommand*{\glsgetwidestname}{\@glswidestname}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsgetwidestsubname}
%\changes{1.05}{2016-06-10}{new}
% Provide a user-level macro to obtain the widest sub-entry name.
%    \begin{macrocode}
  \newcommand*{\glsgetwidestsubname}[1]{%
    \ifcsundef{@glswidestname\romannumeral#1}%
    {\@glswidestname}%
    {\csuse{@glswidestname\romannumeral#1}}%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestTopLevelName}
%CamelCase is easier for long command names. Provide a CamelCase
%synonym of \ics{glsfindwidesttoplevelname}.
%    \begin{macrocode}
  \let\glsFindWidestTopLevelName\glsfindwidesttoplevelname
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedTopLevelName}
%\changes{1.05}{2016-06-10}{new}
% Like \cs{glsfindwidesttoplevelname} but has an additional check
% that the entry has been used. Only useful if the glossaries occur
% at the end of the document, in which case this command should go
% at the start of the glossary. Alternatively, place at the end of
% the document and save for the next run.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedTopLevelName}[1][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \ifglshasparent{\@glo@label}%
          {}%
          {%
            \settowidth{\dimen@}%
             {\glstreenamefmt{\glsentryname{\@glo@label}}}%
            \ifdim\dimen@>\gls@tmplen
              \gls@tmplen=\dimen@
              \eglssetwidest{\glsentryname{\@glo@label}}%
            \fi
          }%
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedAnyName}
%\changes{1.05}{2016-06-10}{new}
% Like the above but doesn't check the parent key. Useful if all
% levels should have the same width for the name.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedAnyName}[1][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \settowidth{\dimen@}%
           {\glstreenamefmt{\glsentryname{\@glo@label}}}%
          \ifdim\dimen@>\gls@tmplen
            \gls@tmplen=\dimen@
            \eglssetwidest{\glsentryname{\@glo@label}}%
          \fi
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestAnyName}
%\changes{1.05}{2016-06-10}{new}
% Like the above but doesn't check is the entry has been used.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestAnyName}[1][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \settowidth{\dimen@}%
         {\glstreenamefmt{\glsentryname{\@glo@label}}}%
        \ifdim\dimen@>\gls@tmplen
          \gls@tmplen=\dimen@
          \eglssetwidest{\glsentryname{\@glo@label}}%
        \fi
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedLevelTwo}
%\changes{1.05}{2016-06-10}{new}
% This is like \cs{glsFindWidestUsedTopLevelName} but also sets the
% first two sub-levels as well. Any entry that has a
% great-grandparent is ignored.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedLevelTwo}[1][\@glo@types]{%
    \dimen@=0pt\relax
    \dimen@i=0pt\relax
    \dimen@ii=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \ifglshasparent{\@glo@label}%
          {%
            \edef\@glo@parent{\csuse{glo@\glsdetoklabel{\@glo@label}@parent}}%
            \ifglshasparent{\@glo@parent}%
            {%
              \edef\@glo@parent{\csuse{glo@\glsdetoklabel{\@glo@parent}@parent}}%
              \ifglshasparent{\@glo@parent}%
              {}%
              {%
                \settowidth{\gls@tmplen}%
                   {\glstreenamefmt{\glsentryname{\@glo@label}}}%
                \ifdim\gls@tmplen>\dimen@ii
                  \dimen@ii=\gls@tmplen
                  \eglssetwidest[2]{\glsentryname{\@glo@label}}%
                \fi
              }%
            }%
            {%
              \settowidth{\gls@tmplen}%
                 {\glstreenamefmt{\glsentryname{\@glo@label}}}%
              \ifdim\gls@tmplen>\dimen@i
                \dimen@i=\gls@tmplen
                \eglssetwidest[1]{\glsentryname{\@glo@label}}%
              \fi
            }%
          }%
          {%
            \settowidth{\gls@tmplen}%
               {\glstreenamefmt{\glsentryname{\@glo@label}}}%
            \ifdim\gls@tmplen>\dimen@
              \dimen@=\gls@tmplen
              \eglssetwidest{\glsentryname{\@glo@label}}%
            \fi
          }%
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestLevelTwo}
%\changes{1.05}{2016-06-10}{new}
% This is like \cs{glsFindWidestUsedLevelTwo} but doesn't check if the
% entry has been used.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestLevelTwo}[1][\@glo@types]{%
    \dimen@=0pt\relax
    \dimen@i=0pt\relax
    \dimen@ii=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglshasparent{\@glo@label}%
        {%
          \edef\@glo@parent{\csuse{glo@\glsdetoklabel{\@glo@label}@parent}}%
          \ifglshasparent{\@glo@parent}%
          {%
            \edef\@glo@parent{\csuse{glo@\glsdetoklabel{\@glo@parent}@parent}}%
            \ifglshasparent{\@glo@parent}%
            {}%
            {%
              \settowidth{\gls@tmplen}%
                 {\glstreenamefmt{\glsentryname{\@glo@label}}}%
              \ifdim\gls@tmplen>\dimen@ii
                \dimen@ii=\gls@tmplen
                \eglssetwidest[2]{\glsentryname{\@glo@label}}%
              \fi
            }%
          }%
          {%
            \settowidth{\gls@tmplen}%
               {\glstreenamefmt{\glsentryname{\@glo@label}}}%
            \ifdim\gls@tmplen>\dimen@i
              \dimen@i=\gls@tmplen
              \eglssetwidest[1]{\glsentryname{\@glo@label}}%
            \fi
          }%
        }%
        {%
          \settowidth{\gls@tmplen}%
             {\glstreenamefmt{\glsentryname{\@glo@label}}}%
          \ifdim\gls@tmplen>\dimen@
            \dimen@=\gls@tmplen
            \eglssetwidest{\glsentryname{\@glo@label}}%
          \fi
        }%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedAnyNameSymbol}
%\changes{1.05}{2016-06-10}{new}
% Like the \cs{glsFindWidestUsedAnyName} but also measures the
% symbol. The length of the widest symbol is stored in the second argument
% should be a length register.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedAnyNameSymbol}[2][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \settowidth{\dimen@}%
           {\glstreenamefmt{\glsentryname{\@glo@label}}}%
          \ifdim\dimen@>\gls@tmplen
            \gls@tmplen=\dimen@
            \eglssetwidest{\glsentryname{\@glo@label}}%
          \fi
          \settowidth{\dimen@}%
           {\glsentrysymbol{\@glo@label}}%
          \ifdim\dimen@>#2\relax
            #2=\dimen@
          \fi
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestAnyNameSymbol}
%\changes{1.05}{2016-06-10}{new}
% Like the above but doesn't check if the entry has been used.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestAnyNameSymbol}[2][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \settowidth{\dimen@}%
         {\glstreenamefmt{\glsentryname{\@glo@label}}}%
        \ifdim\dimen@>\gls@tmplen
          \gls@tmplen=\dimen@
          \eglssetwidest{\glsentryname{\@glo@label}}%
        \fi
        \settowidth{\dimen@}%
         {\glsentrysymbol{\@glo@label}}%
        \ifdim\dimen@>#2\relax
          #2=\dimen@
        \fi
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedAnyNameSymbolLocation}
%\changes{1.05}{2016-06-10}{new}
% Like the \cs{glsFindWidestUsedAnyNameSymbol} but also measures the
% location list. This requires \ics{glsentrynumberlist}.
% The length of the widest symbol is stored in the second argument
% should be a length register. The length of the widest location
% list is stored in the third argument, which should also be a
% length register.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedAnyNameSymbolLocation}[3][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    #3=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \settowidth{\dimen@}%
           {\glstreenamefmt{\glsentryname{\@glo@label}}}%
          \ifdim\dimen@>\gls@tmplen
            \gls@tmplen=\dimen@
            \eglssetwidest{\glsentryname{\@glo@label}}%
          \fi
          \settowidth{\dimen@}%
           {\glsentrysymbol{\@glo@label}}%
          \ifdim\dimen@>#2\relax
            #2=\dimen@
          \fi
          \settowidth{\dimen@}%
           {\GlsXtrFormatLocationList{\glsentrynumberlist{\@glo@label}}}%
          \ifdim\dimen@>#3\relax
            #3=\dimen@
          \fi
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestAnyNameSymbolLocation}
%\changes{1.05}{2016-06-10}{new}
% Like the \cs{glsFindWidestUsedAnyNameSymbol} but doesn't check if
% the entry has been used.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestAnyNameSymbolLocation}[3][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    #3=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \settowidth{\dimen@}%
         {\glstreenamefmt{\glsentryname{\@glo@label}}}%
        \ifdim\dimen@>\gls@tmplen
          \gls@tmplen=\dimen@
          \eglssetwidest{\glsentryname{\@glo@label}}%
        \fi
        \settowidth{\dimen@}%
         {\glsentrysymbol{\@glo@label}}%
        \ifdim\dimen@>#2\relax
          #2=\dimen@
        \fi
        \settowidth{\dimen@}%
          {\GlsXtrFormatLocationList{\glsentrynumberlist{\@glo@label}}}%
        \ifdim\dimen@>#3\relax
          #3=\dimen@
        \fi
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestUsedAnyNameLocation}
%\changes{1.05}{2016-06-10}{new}
% Like the \cs{glsFindWidestUsedAnyNameSymbolLocation} but doesn't
% measure the symbol. The length of the widest location
% list is stored in the second argument, which should be a
% length register.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestUsedAnyNameLocation}[2][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \ifglsused{\@glo@label}%
        {%
          \settowidth{\dimen@}%
           {\glstreenamefmt{\glsentryname{\@glo@label}}}%
          \ifdim\dimen@>\gls@tmplen
            \gls@tmplen=\dimen@
            \eglssetwidest{\glsentryname{\@glo@label}}%
          \fi
          \settowidth{\dimen@}%
           {\GlsXtrFormatLocationList{\glsentrynumberlist{\@glo@label}}}%
          \ifdim\dimen@>#2\relax
            #2=\dimen@
          \fi
        }%
        {}%
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsFindWidestAnyNameLocation}
%\changes{1.05}{2016-06-10}{new}
% Like the \cs{glsFindWidestAnyNameLocation} but doesn't
% check the \gls{firstuse} flag.
%    \begin{macrocode}
  \newrobustcmd*{\glsFindWidestAnyNameLocation}[2][\@glo@types]{%
    \dimen@=0pt\relax
    \gls@tmplen=0pt\relax
    #2=0pt\relax
    \forallglossaries[#1]{\@gls@type}%
    {%
      \forglsentries[\@gls@type]{\@glo@label}%
      {%
        \settowidth{\dimen@}%
         {\glstreenamefmt{\glsentryname{\@glo@label}}}%
        \ifdim\dimen@>\gls@tmplen
          \gls@tmplen=\dimen@
          \eglssetwidest{\glsentryname{\@glo@label}}%
        \fi
        \settowidth{\dimen@}%
         {\GlsXtrFormatLocationList{\glsentrynumberlist{\@glo@label}}}%
        \ifdim\dimen@>#2\relax
          #2=\dimen@
        \fi
      }%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrComputeTreeIndent}
%\changes{1.05}{2016-06-10}{new}
% Compute the value of \cs{glstreeindent}. Argument is the entry label.
% (Ignored in default definition, but this command may be redefined
% to take the particular entry into account.)  Note that the
% sub-levels modify \cs{glstreeindent}.
%    \begin{macrocode}
  \newcommand*{\glsxtrComputeTreeIndent}[1]{%
    \glstreeindent=\glsxtrtreetopindent\relax
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrComputeTreeSubIndent}
%\changes{1.05}{2016-06-10}{new}
%\begin{macrocode}
%\cs{\glsxtrComputeTreeSubIndent}\marg{level}\marg{label}\marg{register}
%\end{macrocode}
% Compute the indent for the sub-entries. The first argument is the
% level, the second argument is the entry label and the third
% argument is the length register used to store the computed indent.
%    \begin{macrocode}
  \newcommand*{\glsxtrComputeTreeSubIndent}[3]{%
    \ifcsundef{@glswidestname\romannumeral#1}%
    {%
      \settowidth{#3}{\glstreenamefmt{\@glswidestname\space}}%
    }%
    {%
      \settowidth{#3}{\glstreenamefmt{%
             \csname @glswidestname\romannumeral#1\endcsname\space}}%
    }%
  }
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrAltTreeSetHangIndent}
%\changes{1.05}{2016-06-10}{new}
% Set \cs{hangindent} for top-level entries:
%    \begin{macrocode}
\newcommand*{\glsxtrAltTreeSetHangIndent}{\hangindent\glstreeindent}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\glsxtrAltTreeSetSubHangIndent}
%\changes{1.05}{2016-06-10}{new}
% Set \cs{hangindent} for sub-entries:
%    \begin{macrocode}
\newcommand*{\glsxtrAltTreeSetSubHangIndent}[1]{\hangindent\glstreeindent}
%    \end{macrocode}
%\end{macro}
%
% Redefine \glostyle{alttree}:
%    \begin{macrocode}
  \renewglossarystyle{alttree}{%
    \renewenvironment{theglossary}%
      {%
       \glsxtralttreeInit
       \def\@gls@prevlevel{-1}%
       \mbox{}\par}%
      {\par}%
    \renewcommand*{\glossaryheader}{}%
    \renewcommand*{\glsgroupheading}[1]{}%
    \renewcommand{\glossentry}[2]{%
      \ifnum\@gls@prevlevel=0\relax
      \else
        \glsxtrComputeTreeIndent{##1}%
      \fi
      \parindent\glstreeindent
      \glsxtrAltTreeSetHangIndent
      \makebox[0pt][r]%
      {%
        \glstreenamebox{\glstreeindent}%
        {%
           \glsentryitem{##1}%
           \glstreenamefmt{\glstarget{##1}{\glossentryname{##1}}}%
        }%
      }%
      \glsxtralttreeSymbolDescLocation{##1}{##2}%
      \def\@gls@prevlevel{0}%
    }
    \renewcommand{\subglossentry}[3]{%
      \ifnum##1=1\relax
        \glssubentryitem{##2}%
      \fi
      \ifnum\@gls@prevlevel=##1\relax
      \else
        \glsxtrComputeTreeSubIndent{##1}{##2}{\gls@tmplen}%
        \ifnum\@gls@prevlevel<##1\relax
          \setlength\glstreeindent\gls@tmplen
          \addtolength\glstreeindent\parindent
          \parindent\glstreeindent
        \else
          \ifnum\@gls@prevlevel=0\relax
            \glsxtrComputeTreeIndent{##2}%
          \else
            \glsxtrComputeTreeSubIndent{\@gls@prevlevel}{##2}{\glstreeindent}%
          \fi
          \addtolength\parindent{-\glstreeindent}%
          \setlength\glstreeindent\parindent
        \fi
      \fi
      \glsxtrAltTreeSetSubHangIndent{##1}%
      \makebox[0pt][r]{\glstreenamebox{\gls@tmplen}{%
        \glstreenamefmt{\glstarget{##2}{\glossentryname{##2}}}}}%
      \glsxtralttreeSubSymbolDescLocation{##1}{##2}{##3}%
      \def\@gls@prevlevel{##1}%
    }%
    \renewcommand*{\glsgroupskip}{\ifglsnogroupskip\else\indexspace\fi}%
  }
}%
{%
%    \end{macrocode}
% Assume the style isn't required if it hasn't already been defined.
%    \begin{macrocode}
}
%    \end{macrocode}
%
% Reset the default style
%    \begin{macrocode}
\ifx\@glossary@default@style\relax
\else
  \setglossarystyle{\@glsxtr@current@style}
\fi
%    \end{macrocode}
%\iffalse
%    \begin{macrocode}
%</glossaries-extra-stylemods.sty>
%    \end{macrocode}
%\fi
%\Finale
\endinput
