# Glossaries for acronyms and symbols: page references for acronyms and equation references for symbols

I'd like to use the glossaries package for both acronyms and symbols, showing page references for the acronyms and equation references for the symbols.

I know that the counter can be set to counter=equation \usepackage[counter=equation]{glossaries}, however, then the acronyms glossary shows number of euqations which are dead links.

I modified a sample file from CTAN (sampleSort.tex) to provide a minimal working example.

% This file is public domain
% If you want to use arara, you need the following directives:
% arara: pdflatex: { synctex: on }
% arara: makeglossaries
% arara: pdflatex: { synctex: on }
% arara: pdflatex: { synctex: on }
\documentclass{report}

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

\usepackage[toc,acronym,counter=equation]{glossaries}

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

\makeglossaries

\newcounter{sortcount}

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

% Notation definitions

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

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

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

\newglossaryentry{not:a}{type=notation,
name={\ensuremath{a}},
text={a},
description={a variable}}

\newglossaryentry{not:b}{type=notation,
name={\ensuremath{b}},
text={b},
description={another variable}}

% Main glossary definitions

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

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

% Acronym definitions

\newacronym{zfc}{ZFC}{Zermelo-Fraenkel set theory}
\newacronym{nf}{NF}{new foundations}

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

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

\pagenumbering{roman}
\tableofcontents

\printglossaries

\chapter{Introduction}
\pagenumbering{arabic}

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

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

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

\chapter{Another Chapter}

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

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

$$\gls{not:a} = \gls{not:b}$$

\end{document}


If all your terms for a particular glossary are always used in a numbered maths environment, then you can set the counter in the final optional argument of \newglossary:

\newglossary[nlg]{notation}{not}{ntn}{Notation}[equation]


All your terms in the other glossaries will use the default counter (page or the value of the counter package option).

If your symbols are mixed in numbered and non-numbered maths environments (for example, $$\gls{not:a}$$ and $\gls{not:a}$) then you need to use the counter=equation option in the numbered maths environments:

$$\gls[counter=equation]{not:a} = \gls[counter=equation]{not:b}$$


If you try this modification with the MWE in your question, you'll find warnings like:

Package glossaries Warning: Hyper target 2.0.1' can't be formed by prefixing
location 2.1'. You need to modify the definition of \theHequation
otherwise you will get the warning: "name{equation.2.1}' has been
referenced but does not exist"


This means you need to redefine \theHequation so that it's in the form prefix.\theequation or just make it the same as \theequation. This is a limitation imposed by the way the glossaries package tries to reconstruct the hyperlinks in the number list given the counter name, prefix and the indexed value.

In this example, \theequation is formed from the chapter number and the value of the equation counter, which should typically form unique target names, so \theHequation can simply be redefined to \theequation.

Complete example:

\documentclass{report}

\usepackage[toc,acronym]{glossaries}

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

\renewcommand\theHequation{\theequation}

\makeglossaries

\newcounter{sortcount}

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

% Notation definitions

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

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

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

\newglossaryentry{not:a}{type=notation,
name={\ensuremath{a}},
text={a},
description={a variable}}

\newglossaryentry{not:b}{type=notation,
name={\ensuremath{b}},
text={b},
description={another variable}}

% Main glossary definitions

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

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

% Acronym definitions

\newacronym{zfc}{ZFC}{Zermelo-Fraenkel set theory}
\newacronym{nf}{NF}{new foundations}

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

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

\pagenumbering{roman}
\tableofcontents

\printglossaries

\chapter{Introduction}
\pagenumbering{arabic}

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

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

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

\chapter{Another Chapter}

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

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

$$\gls[counter=equation]{not:a} = \gls[counter=equation]{not:b}$$

\end{document}
`
• Thank you very much for your time and effort providing this package along with all the documentation and help here at stackexchange and all the other forums! – Stefan Jaumann Sep 24 '17 at 18:17