How do I reset the glossary count after a section?

I have an abstract where I use some acronyms. I use those same acronyms later in my introduction and the rest of the thesis. What I want to achieve is to have the entry count reset after the abstract so all abbrievations are expaned in the introduction again for the first time.

Is there a way of doing so?

Are you using a package for this? Could you please provide a minimum working example so we can see what you are trying to achieve?

This is the first way that I found, no guarantees about how good it is since I don’t know the package.


There is an update parameter of the gls() function which, for the abstract, can be set to false. Then before the body it can be set to true:

#import "@preview/glossarium:0.5.10": make-glossary, register-glossary, print-glossary, gls, glspl
#show: make-glossary
#let entry-list = (
  (
    key: "kuleuven",
    short: "KU Leuven",
    long: "Katholieke Universiteit Leuven",
    description: "A university in Belgium.",
  ),
  // Add more terms
)
#register-glossary(entry-list)

= Asbstract
#let gls = gls.with(update: false)
Instance in abstract: #gls("kuleuven")



= Document Body
#let gls = gls.with(update: true)
First instance: #gls("kuleuven")
Second instance: #gls("kuleuven")

If you’ve never seen it, this line might be confusing:

#let gls = gls.with(update: false)

What this does is redefine the gls variable (in this case a function). The new definition is the result of calling gls.with(/**/). In Typst you can call .with() on any function to create a new function that has the parameters defined as they are specified in with().
There’s probably a better way to phrase all that but the short version is that it allows you to create new defaults for a function.

Would this fit your request?

Version v0.5.9 introduces a new contextual function reset-counts
that clears the usage counts of entries by @quachpas in #156.
By default, it clears all usage counts.

#context reset-counts() // clears the usage counts of all entries

Pass any registered keys to selectively reset them.

#context reset-counts("foo", "bar") // clears the usage counts of "foo" and "bar"

Note that print-glossary will print all used entries regardless of
whether they have been reset throughout the document.

See the changelog. I forgot to update the README with that function!

2 Likes

Thanks! This was exactly what I wanted.