I'm using the glossaries (or glossaries-extra) and am trying to add terms to the glossary silently. That is, inside my document, I occasionally want to add a term to the glossary without it appearing in the text output at the point where I use the command.

I tried glsadd{<key>}. This fulfills both criteria. But annoyingly it produces a space, when written on empty lines. Is there a package-option to prevent this or another command?

Any help would be appreciated. The following is minimal example which demonstrates the issues sufficiently.

\usepackage{glossaries} % problem exists under glossaries-extra too

\newglossaryentry{term}{sort={0}, name={Term}, description={Something.}}
\newglossaryentry{here}{sort={1}, name={Here}, description={Something.}}
\newglossaryentry{is}{sort={2}, name={Is}, description={Something.}}
\newglossaryentry{more}{sort={3}, name={More}, description={Something.}}
\newglossaryentry{proof}{sort={4}, name={Proof}, description={Something.}}




    Here is a sentence I want to to add a term \glsadd{term} silently and that works. But then consider writing a command on an empty line.

    Between me and the last paragraph is nothing.


    Between me and the last paragraph is a silent command.


    Between me and the last paragraph is a glsadd-command.




    For clarity, between me and the last paragraph are 3 glsadd-commands.
    Is there another command to glsadd to properly silently add terms to the glossary? If not\ldots why??!

glossaries keeps track of on which pages the glossary entries are used. In order to this, the page on which this happens needs to be well defined, i.e. \glsadd has to be part of a line of text. This is why glossaries adds an empty \mbox to the document using \@gls@adjustmode when you call \glsadd in vertical mode.

You should decide to which paragraph every \glsadd belongs, then you won't have this problem and glossaries will record reasonable page numbers. For example

This is a paragraph with some entries at the end.

This is a paragraph with other entries at the beginning and something between sentences.
This way it is always well defined where in the document you called \verb|\glsadd|.

If you don't care about page numbers (and are using the nonumberlist option), you can remove the feature with


in your preamble.

  • Thank you for the explanation!
    – Thomas
    Jul 9 '19 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.