I would like to generate an index of notation using the glossaries
-package such that certain page numbers are suppressed.
It is easy to define some standard notation and include it in the index using \glsaddall
.
But this adds the page numbers to the index, which is what I want to avoid.
Adding nonumberlist
to the definition of an entry suppresses the page number. (nonumberlist
also exists as package option, but not as option to \glsaddall
.) But this has to be done for each entry and would also suppress future references.
Here is my question: How can I suppress all page numbers generated by \glsaddall
? In other words: \glsaddall
ensures that all notation not referenced by \gls
appears in the index, but without having a page number. All entries generated by \gls
add page numbers.
Here is a good example:
\documentclass{article}
\usepackage{amsfonts}
\newcommand*{\Z}{\mathbb{Z}}
\newcommand*{\Q}{\mathbb{Q}}
% glossaries-user.pdf (v3.03):
% If you use hyperref and glossaries, you must load hyperref first.
\usepackage{hyperref}
\usepackage[
style=long3colheader,
hyperfirst=false
]{glossaries}
\newglossaryentry{integers}{name=\ensuremath{\Z},
description={the ring of integers}, sort=!}
\newglossaryentry{rationals}{name=\ensuremath{\Q},
description={the field of rational numbers}, sort=!, nonumberlist}
\newglossaryentry{vector-space}{name=\ensuremath{V},
description={a vector space}, sort=V}
\makeglossaries
\begin{document}
\glsaddall
A vector space \gls{vector-space} \ldots
\printglossaries
\end{document}
The output is the following. The pages for Z and Q should not appear. (The page for Q is suppressed manually.)
(This question is related but not equal to glossaries: including an entry without page location.)
Best Answer
Here is an approach that works with only a minor restriction: Instead of issuing
\gladdall
in the beginning, we issue a\glsaddallunused
right before we do\printglossaries
. This new command\glsaddallunused
will write all entries that have not been used up to this point to the glossaries, with suppressed page numbers. For the suppression we will use lockstep's answer that you linked to.If we were to write all entries with
\glsaddall
to the auxiliary glossary file, we would have a hard time to teachmakeindex
which page numbers to suppress, and how to sort and compress that correctly. In my approach, we only have entries with all page numbers shown (those explicitly referenced), and entries with completely suppressed page list.