% arara: pdflatex
% arara: makeglossaries
% arara: pdflatex
% arara: makeindex
% arara: pdflatex
\documentclass[index=totoc]{scrreprt}

\usepackage[T1]{fontenc}

\usepackage{makeidx}
\usepackage[colorlinks,
            hyperindex=false% necessary for the encap entry
            ]{hyperref}
\usepackage[abbreviations]{glossaries-extra}

\renewcommand{\abbreviationsname}{List of Abbreviations}

\makeindex
\makeglossaries

% Provided by koma classes:
\setindexpreamble{Page numbers in bold indicate an entry
in the glossary or list of abbreviations.\par\medskip}

% Automatically index the location of entry in the glossary
% for those entries that are in the "general" category and
% use "htextbf" as the encap value:

% (Without the troublesome "encap" entry, hyperref's default
% hyperindex=true option could've been used and the attribute
% could simply be set to "textbf" and there'd be no need
% to define "htextbf".)

\glssetcategoryattribute{general}{indexname}{htextbf}
\glssetcategoryattribute{general}{dualindex}{hyperpage}

% Automatically index the location of entry in the glossary
% for those entries that are in the "abbreviation" category
% and use "htextbf" as the encap value:

\newcommand*{\htextbf}[1]{\textbf{\hyperpage{#1}}}
\glssetcategoryattribute{abbreviation}{indexname}{htextbf}
\glssetcategoryattribute{abbreviation}{dualindex}{hyperpage}

% Allow "format" key to override "dualindex" attribute.
\GlsXtrEnableIndexFormatOverride

% Convert the first letter of the name to upper case in the 
% glossary for general entries:
\glssetcategoryattribute{general}{glossname}{firstuc}

% Convert the name to upper case in the glossary for
% abbreviations:
\glssetcategoryattribute{abbreviation}{glossname}{uc}

% Define general entries:

\newglossaryentry{duck}{name=duck,%
  description={a waterbird with webbed feet}}

\newglossaryentry{parrot}{name=parrot,%
  description={mainly tropical bird with bright plumage}}

\newglossaryentry{at}{name={@},%
  description={makeindex's default for the ``actual value''}}

\newglossaryentry{level}{name={!},%
  description={makeindex's default for the ``level value''}}

\newglossaryentry{esc}{name={"},%
  description={makeindex's default for the ``escape value''}}

\newglossaryentry{encap}{name={|},%
  description={makeindex's default for the ``encap value''}}

% Set abbreviation style:

\setabbreviationstyle{long-short-sc}

% Define abbreviations:

\newabbreviation
 {html}% identifying label
 {html}% short form
 {hypertext markup language}% long form

\newabbreviation
 {xml}% identifying label
 {xml}% short form
 {extensible markup language}% long form

\title{Sample document testing the glossaries-extra package}
\author{Nicola Talbot}

\begin{document}
\maketitle

\tableofcontents

\chapter{Introduction}

% If hyperref's default hyperindex=true option is in use
% the indexed term here won't need the |hyperpage bit.
This is a sample\index{sample|hyperpage} document testing the
\texttt{glossaries-extra} package.

\chapter{General Entries}

Sample entries: \gls{duck} and \gls{parrot}.

Test makeindex's special characters: \gls{at} (actual)
\gls{esc} (escape) \gls{level} (level) and \gls{encap} (encap).

\newpage

Use some entries again: \gls{duck} and \gls[format=hyperit]{parrot}.

\chapter{Abbreviations}

First use: \gls{html} and \gls{xml}.

Next use: \gls{html} and \gls{xml}.

\printglossaries

\printindex

\end{document}

